X-Git-Url: https://git.rapsys.eu/.gitweb.cgi/airbundle/blobdiff_plain/40d20c715e67927f04b58462179065eb44ad267b..9d0fc27f4e1d889446092fbee4e7f1fb6914e9c9:/Controller/DefaultController.php diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php index 11597f6..034448a 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 @@ -350,7 +351,7 @@ class DefaultController { } //Render template - return $this->render('@RapsysAir/form/dispute.html.twig', ['title' => $title, 'section' => $section, 'form' => $form->createView(), 'sent' => $request->query->get('sent', 0)]+$this->context); + return $this->render('@RapsysAir/default/dispute.html.twig', ['title' => $title, 'section' => $section, 'form' => $form->createView(), 'sent' => $request->query->get('sent', 0)]+$this->context); } /**