Exemplo n.º 1
0
 /**
  * @Route("/relance-pdf/{id}/{numeroRelance}", name="facture_relance_pdf")
  * @ParamConverter("facture", class="AppBundle:Facture")
  */
 public function relancePdfAction(Request $request, Facture $facture, $numeroRelance = 0)
 {
     set_time_limit(0);
     $fm = $this->get('facture.manager');
     $lignes = array();
     foreach ($facture->getLignes() as $key => $ligneFacture) {
         $ligne = $this->buildLignePDFFacture($ligneFacture);
         $lignes[] = $ligne;
     }
     $html = $this->renderView('facture/pdfGeneriqueRelance.html.twig', array('facture' => $facture, 'lignes' => $lignes, 'numeroRelance' => $numeroRelance, 'parameters' => $fm->getParameters()));
     $terme_relance = FactureManager::$types_nb_relance[$numeroRelance];
     $filename = sprintf("relance_%s_facture_%s_%s.pdf", $terme_relance, $facture->getNumeroFacture(), (new \DateTime())->format("Y-m-d_His"));
     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 . '"'));
 }