From: Raphaël Gertz Date: Sat, 8 May 2021 02:58:02 +0000 (+0200) Subject: Add dispute pdf class X-Git-Tag: 0.2.2~3 X-Git-Url: https://git.rapsys.eu/airbundle/commitdiff_plain/c14a98c5655e1203d69ce40479c70f1330af522b?ds=inline;hp=2cbaed2219dc86624bc3b325da56d985b9a7d76a Add dispute pdf class Add traffic and gathering offense type --- diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php index 11597f6..c64a96c 100644 --- a/Controller/DefaultController.php +++ b/Controller/DefaultController.php @@ -7,6 +7,8 @@ use Rapsys\AirBundle\Entity\Location; use Rapsys\AirBundle\Entity\Session; use Rapsys\AirBundle\Entity\Slot; use Rapsys\AirBundle\Entity\User; +use Rapsys\AirBundle\Pdf\DisputePdf; +use Rapsys\UserBundle\Utils\Slugger; use Symfony\Bridge\Twig\Mime\TemplatedEmail; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -20,7 +22,6 @@ use Symfony\Component\Mime\Address; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Translation\TranslatorInterface; -use Rapsys\UserBundle\Utils\Slugger; use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait; use Symfony\Component\DependencyInjection\ContainerAwareTrait; @@ -262,7 +263,7 @@ class DefaultController { //Create the form according to the FormType created previously. //And give the proper parameters - $form = $this->createForm('Rapsys\AirBundle\Form\DisputeType', null, [ + $form = $this->createForm('Rapsys\AirBundle\Form\DisputeType', ['court' => 'Paris', 'abstract' => 'Pour constater cette prétendue infraction, les agents verbalisateurs ont pénétré dans un jardin privatif, sans visibilité depuis la voie publique, situé derrière un batiment privé, pour ce faire ils ont franchi au moins un grillage de chantier ou des potteaux métalliques séparant le terrain privé de la voie publique de l\'autre côté du batiment.'], [ 'action' => $this->generateUrl('rapsys_air_dispute'), 'method' => 'POST' ]); @@ -275,35 +276,35 @@ class DefaultController { //Get data $data = $form->getData(); - header('Content-Type: text/plain'); - - //Infraction - var_dump($data['offense']); - - //Numéro d'avis - var_dump($data['notice']); - - //Numéro d'agent - var_dump($data['agent']); - - //Code service - var_dump($data['service']); - - //Masque porté - var_dump($data['mask']); + //Gathering offense + if (!empty($data['offense']) && $data['offense'] == 'gathering') { + //Add gathering + $output = DisputePdf::genGathering($data['court'], $data['notice'], $data['agent'], $data['service'], $data['abstract'], $this->translator->trans($this->getUser()->getCivility()->getTitle()), $this->getUser()->getForename(), $this->getUser()->getSurname()); + //Traffic offense + } elseif (!empty($data['offense'] && $data['offense'] == 'traffic')) { + //Add traffic + $output = DisputePdf::genTraffic($data['court'], $data['notice'], $data['agent'], $data['service'], $data['abstract'], $this->translator->trans($this->getUser()->getCivility()->getTitle()), $this->getUser()->getForename(), $this->getUser()->getSurname()); + //Unsupported offense + } else { + header('Content-Type: text/plain'); + die('TODO'); + exit; + } - //Civilité - var_dump($this->translator->trans($this->getUser()->getCivility()->getTitle())); + //Send common headers + header('Content-Type: application/pdf'); - //Prénom - var_dump($this->getUser()->getForename()); + //Send remaining headers + header('Cache-Control: private, max-age=0, must-revalidate'); + header('Pragma: public'); - //Nom - var_dump($this->getUser()->getSurname()); + //Send content-length + header('Content-Length: '.strlen($output)); - //Mail - var_dump($this->getUser()->getMail()); + //Display the pdf + echo $output; + //Die for now exit; # //Create message