Esempio n. 1
0
 /**
  * @Route("/passage/pdf-mission/{id}", name="passage_pdf_mission")
  * @ParamConverter("passage", class="AppBundle:Passage")
  */
 public function pdfMissionAction(Request $request, Passage $passage)
 {
     $pm = $this->get('passage.manager');
     $passagesHistory = $pm->getRepository()->findHistoriqueByEtablissementAndPrestationsAndNumeroContrat($passage->getContrat(), $passage->getEtablissement(), $passage->getPrestations());
     $filename = sprintf("suivi_client_%s_%s.pdf", $passage->getDateDebut()->format("Y-m-d_H:i"), strtoupper(Transliterator::urlize($passage->getTechniciens()->first()->getIdentite())));
     $html = $this->renderView('passage/pdfMission.html.twig', array('passage' => $passage, 'passagesHistory' => $passagesHistory));
     if ($request->get('output') == 'html') {
         return new Response($html, 200);
     }
     return new Response($this->get('knp_snappy.pdf')->getOutputFromHtml($html, $this->getPdfGenerationOptions()), 200, array('Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="' . $filename . '"'));
 }