Associate generate document with evaluation and update UX to go back to

documents
This commit is contained in:
2021-08-20 12:44:15 +02:00
parent 80672a038c
commit 7f28effc1e
8 changed files with 175 additions and 16 deletions

View File

@@ -4,6 +4,9 @@ namespace Chill\DocGeneratorBundle\Controller;
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use GuzzleHttp\Exception\TransferException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
@@ -105,14 +108,26 @@ class DocGeneratorTemplateController extends AbstractController
]);
if ($putResponse->getStatusCode() == 201) {
$em = $this->getDoctrine()->getManager();
$storedObject = new StoredObject();
$storedObject
// currently, only docx is supported
->setType('application/vnd.openxmlformats-officedocument.wordprocessingml.document')
->setFilename($genDocName);
$em = $this->getDoctrine()->getManager();
$em->persist($storedObject);
// Only for evaluation
if ($entity instanceof AccompanyingPeriodWorkEvaluation) {
$doc = new AccompanyingPeriodWorkEvaluationDocument();
$doc
->setStoredObject($storedObject)
->setTemplate($template)
;
$entity->addDocument($doc);
$em->persist($doc);
}
$em->flush();
return $this->redirectToRoute('chill_wopi_file_edit', [

View File

@@ -4,11 +4,11 @@ namespace Chill\DocGeneratorBundle\Entity;
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
* @ORM\Table(name="chill_docgen_template")
*/
class DocGeneratorTemplate
{
@@ -16,11 +16,13 @@ class DocGeneratorTemplate
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"read"})
*/
private int $id;
/**
* @ORM\Column(type="json_array")
* @Serializer\Groups({"read"})
*/
private array $name = [];