src/Controller/PdfExternalPrint.php line 1002

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by Mediterranean Develup Solutions
  4.  * User: jorge.defreitas@develup.solutions
  5.  * Date: 18/01/2018
  6.  * Time: 19:22
  7.  */
  8. namespace App\Controller;
  9. use App\Entity\Client;
  10. use App\Entity\Configuration;
  11. use App\Entity\HtFile;
  12. use App\Entity\HtInvoice;
  13. use App\Entity\HtProforma;
  14. use App\Entity\SendMail;
  15. use App\Entity\SettingsCompany;
  16. use App\Form\SendMailType;
  17. use App\MDS\AvexpressBundle\Entity\AveDocInvoice;
  18. use App\MDS\EventsBundle\Entity\Proposal;
  19. use App\MDS\GreenPatioBundle\Entity\Reservation;
  20. use App\MDS\GreenPatioBundle\Entity\ReservationLoungeSimple;
  21. use Doctrine\ORM\EntityManagerInterface;
  22. use Doctrine\ORM\EntityRepository;
  23. use Knp\Snappy\Pdf;
  24. use Psr\Log\LoggerInterface;
  25. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  26. use Symfony\Component\Routing\Annotation\Route;
  27. use Symfony\Component\Form\FormError;
  28. use Symfony\Component\HttpFoundation\JsonResponse;
  29. use Symfony\Component\HttpFoundation\Request;
  30. use Symfony\Component\HttpFoundation\Response;
  31. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  32. use Symfony\Component\Validator\Constraints as Assert;
  33. class PdfExternalPrint extends AbstractController
  34. {
  35.     /**
  36.      * @Route("/pdf/pro/{id}",  name="print_invoice_proforma_pdf")
  37.      */
  38.     public function pdfProformaPdfActionAction($idRequest $requestPdf $snappy)
  39.     {
  40.         // use absolute path !
  41.         $pageUrl $this->generateUrl('proposal_invoice_proforma_print_externo', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  42.         return new Response(
  43.             $snappy->getOutput($pageUrl),
  44.             200,
  45.             array(
  46.                 'Content-Type'          => 'application/pdf',
  47.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  48.             )
  49.         );
  50.     }
  51.     /**
  52.      * @Route("/pdf/inv/{id}",  name="print_invoice_invoice_pdf")
  53.      */
  54.     public function pdfInvoicePdfActionAction($idRequest $requestPdf $snappy)
  55.     {
  56.         // use absolute path !
  57.         $pageUrl $this->generateUrl('proposal_invoice_detector_print_externo', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  58.         return new Response(
  59.             $snappy->getOutput($pageUrl),
  60.             200,
  61.             array(
  62.                 'Content-Type'          => 'application/pdf',
  63.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  64.             )
  65.         );
  66.     }
  67.     /**
  68.      * @Route("/pdf/prodeposit/{id}",  name="print_invoice_deposit_proforma_pdf")
  69.      */
  70.     public function pdfProformaDepositPdfActionAction($idRequest $requestPdf $snappy)
  71.     {
  72.         // use absolute path !
  73.         $pageUrl $this->generateUrl('proposal_invoice_deposit_proforma_print_externo', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  74.         return new Response(
  75.             $snappy->getOutput($pageUrl),
  76.             200,
  77.             array(
  78.                 'Content-Type'          => 'application/pdf',
  79.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  80.             )
  81.         );
  82.     }
  83.     /**
  84.      * @Route("/pdf/invdeposit/{id}/{fid}",  name="print_invoice_deposit_invoice_pdf")
  85.      */
  86.     public function pdfInvoiceDepositPdfActionAction($id$fidRequest $requestPdf $snappy)
  87.     {
  88.         // use absolute path !
  89.         $pageUrl $this->generateUrl('proposal_invoice_deposit_invoice_print_externo', array('id' => $id'fid' => $fid), UrlGeneratorInterface::ABSOLUTE_URL);
  90.         return new Response(
  91.             $snappy->getOutput($pageUrl),
  92.             200,
  93.             array(
  94.                 'Content-Type'          => 'application/pdf',
  95.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  96.             )
  97.         );
  98.     }
  99.     /**
  100.      * @Route("/pdf/clientAgenda/{token}",  name="print_agenda_pdf_client")
  101.      */
  102.     public function pdfClientAgendaPdfActionAction($tokenRequest $requestPdf $snappy)
  103.     {
  104.         $em $this->getDoctrine()->getManager();
  105.         $proposal $em->getRepository(Proposal::class)->findOneByAccessKey($token);
  106.         // use absolute path !
  107.         $pageUrl $this->generateUrl('presentation_client_view_agenda', array('token' => $token), UrlGeneratorInterface::ABSOLUTE_URL);
  108.         return new Response(
  109.             $snappy->getOutput($pageUrl),
  110.             200,
  111.             array(
  112.                 'Content-Type'          => 'application/pdf',
  113.                 'Content-Disposition'   => 'inline; filename="pdf-' $proposal->getId() . '.pdf"'
  114.             )
  115.         );
  116.     }
  117.     /**
  118.      * @Route("/pdf/managerAgenda/{token}",  name="print_agenda_pdf_manager")
  119.      */
  120.     public function pdfManagerAgendaPdfActionAction($tokenRequest $requestPdf $snappy)
  121.     {
  122.         $em $this->getDoctrine()->getManager();
  123.         $proposal $em->getRepository(Proposal::class)->findOneByAccessKey($token);
  124.         // use absolute path !
  125.         $pageUrl $this->generateUrl('presentation_manager_view_agenda', array('token' => $token), UrlGeneratorInterface::ABSOLUTE_URL);
  126.         return new Response(
  127.             $snappy->getOutput($pageUrl),
  128.             200,
  129.             array(
  130.                 'Content-Type'          => 'application/pdf',
  131.                 'Content-Disposition'   => 'inline; filename="pdf-' $proposal->getId() . '.pdf"'
  132.             )
  133.         );
  134.     }
  135.     /**
  136.      * @Route("/pdf/disclaimer/{token}",  name="print_disclaimer_pdf")
  137.      */
  138.     public function pdfManagerDisclaimerPdfActionAction($tokenRequest $requestPdf $snappy)
  139.     {
  140.         $em $this->getDoctrine()->getManager();
  141.         // use absolute path !
  142.         $pageUrl $this->generateUrl('print_disclaimer', array('token' => $token), UrlGeneratorInterface::ABSOLUTE_URL);
  143.         return new Response(
  144.             $snappy->getOutput($pageUrl),
  145.             200,
  146.             array(
  147.                 'Content-Type'          => 'application/pdf',
  148.                 'Content-Disposition'   => 'inline; filename="pdf-disclaimer.pdf"'
  149.             )
  150.         );
  151.     }
  152.     /**
  153.      * @Route("/pdf/calendar",  name="print_calendar_pdf")
  154.      */
  155.     public function pdfManagerCalendarPdfAction(Request $requestPdf $snappy)
  156.     {
  157.         $token $request->request->get('token');
  158.         $em $this->getDoctrine()->getManager();
  159.         // use absolute path !
  160.         $pageUrl $this->generateUrl('calendar-full-pdf', array('token' => $token), UrlGeneratorInterface::ABSOLUTE_URL);
  161.         return new Response(
  162.             $snappy->getOutput($pageUrl),
  163.             200,
  164.             array(
  165.                 'Content-Type'          => 'application/pdf',
  166.                 'Content-Disposition'   => 'inline; filename="pdf-calendar.pdf"'
  167.             )
  168.         );
  169.     }
  170.     /**
  171.      * @Route("/pdf/simpleagenda/view/{token}/{logo}",  name="proposal_agenda_simple_pdf_view")
  172.      */
  173.     public function AgendaSimplePdfCreateAction($token$logoRequest $request)
  174.     {
  175.         $em $this->getDoctrine()->getManager();
  176.         $proposal $em->getRepository(Proposal::class)->findOneByAccessKey($token);
  177.         $parameters = array(
  178.             'id' => $proposal->getId()
  179.         );
  180.         $dql 'SELECT p
  181.                 FROM EventsBundle:ProposalSimpleAgenda p
  182.                 WHERE p.idProposal = :id
  183.                 ORDER BY p.date, p.hour ASC ';
  184.         $query $em->createQuery($dql)->setParameters($parameters);
  185.         $simpleAgenda_data $query->getResult();
  186.         $simpleAgenda = array();
  187.         if (!empty($simpleAgenda_data)) {
  188.             foreach ($simpleAgenda_data as $item) {
  189.                 $date $item->getDate()->format('Y-m-d');
  190.                 $simpleAgenda[$date][] = $item;
  191.             }
  192.         }
  193.         //  --- Prueba en PDF para generar el arreglo jumpDays
  194.         $lineCounter 0;
  195.         $jumpDays = array();
  196.         $previusDayId 0;
  197.         // -- Determino en cual elemento debo poner el mensaje de salto de pagina
  198.         if (!empty($simpleAgenda)) {
  199.             foreach ($simpleAgenda as $day) {
  200.                 if ((substr_count($day[0]->getText(), '</p>') + $lineCounter) > 40) {         // -- Verifico si el dia cabe en su totalidad la primera entrada del dia
  201.                     $jumpDays[] = $previusDayId;                                         // -- Poner el jumpday en el previus
  202.                     $lineCounter 0;
  203.                 }
  204.                 foreach ($day as $item) {
  205.                     if (substr_count($item->getText(), '</p>') == 0) {
  206.                         $lineCounter $lineCounter 1;                 // Se detecto que con un font especifico (Comic) si no hay salto de linea, substr_count($item->getText(),'</p>') da cero
  207.                     } else {
  208.                         $lineCounter $lineCounter substr_count($item->getText(), '</p>');
  209.                     }
  210.                     if ($lineCounter >= 40) {
  211.                         $jumpDays[] = $item->getId();
  212.                         $lineCounter 0;
  213.                     }
  214.                     $previusDayId $item->getId();
  215.                 }
  216.             }
  217.         }
  218.         $rutaLogo null;
  219.         if ($logo == 1) {
  220.             $company $em->getRepository(SettingsCompany::class)->findOneById('1');
  221.             $rutaLogo $company->getPicture();
  222.         }
  223.         $proposalName $proposal->getName();
  224.         //  --- Prueba en PDF para generar el arreglo jumpDays
  225.         return $this->render(
  226.             'MDS/EventsBundle/agenda/add-task-simple-agenda-pdf.html.twig',
  227.             array(
  228.                 'simpleAgenda' => $simpleAgenda,         //cada elemento debe ser un dia de la agenda
  229.                 'jumpDays' => $jumpDays,
  230.                 'logo' => $logo,
  231.                 'rutaLogo' => $rutaLogo,
  232.                 'proposalName' => $proposalName
  233.             )
  234.         );
  235.     }
  236.     /**
  237.      * @Route("/pdf/simpleagendaprint/{token}/{logo}",  name="proposal_agenda_simple_pdf_print")
  238.      */
  239.     public function pdfSimpleAgendaPdfActionAction($token$logoRequest $requestPdf $snappy)
  240.     {
  241.         $pageUrl $this->generateUrl('proposal_agenda_simple_pdf_view', array('token' => $token'logo' => $logo), UrlGeneratorInterface::ABSOLUTE_URL);
  242.         return new Response(
  243.             $snappy->getOutput($pageUrl),
  244.             200,
  245.             array(
  246.                 'Content-Type'          => 'application/pdf',
  247.                 'Content-Disposition'   => 'inline; filename="pdf-' $token '.pdf"'
  248.             )
  249.         );
  250.     }
  251.     /**
  252.      * @Route("/pdf/summaryideapdfprint/{id}",  name="summary_idea_pdf_print")
  253.      */
  254.     public function pdfSummaryIdeaPdfActionAction($idRequest $requestPdf $snappy)
  255.     {
  256.         $pageUrl $this->generateUrl('summary_idea_pdf_view', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  257.         return new Response(
  258.             $snappy->getOutput($pageUrl),
  259.             200,
  260.             array(
  261.                 'Content-Type'          => 'application/pdf',
  262.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  263.             )
  264.         );
  265.     }
  266.     /**
  267.      * @Route("/pdf/greenpatiopro/{id}",  name="print_greenpatio_proforma_pdf")
  268.      */
  269.     public function pdfGreenPatioProformaPdfActionAction($idRequest $requestPdf $snappy)
  270.     {
  271.         $pageUrl $this->generateUrl('reservations_invoice_proforma_print', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  272.         return new Response(
  273.             $snappy->getOutput($pageUrl),
  274.             200,
  275.             array(
  276.                 'Content-Type'          => 'application/pdf',
  277.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  278.             )
  279.         );
  280.     }
  281.     /**
  282.      * @Route("/pdf/greenpatioinv/{id}",  name="print_greenpatio_invoice_pdf")
  283.      */
  284.     public function pdfGreenPatioInvoicePdfActionAction($idRequest $requestPdf $snappy)
  285.     {
  286.         $pageUrl $this->generateUrl('reservations_invoice_print', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  287.         return new Response(
  288.             $snappy->getOutput($pageUrl),
  289.             200,
  290.             array(
  291.                 'Content-Type'          => 'application/pdf',
  292.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  293.             )
  294.         );
  295.     }
  296.     /**
  297.      * @Route("/pdf/greenpatioinv/invdeposit/{id}/{fid}",  name="print_reservation_invoice_deposit_invoice_pdf")
  298.      */
  299.     public function pdfReservationInvoiceDepositPdfActionAction($id$fidRequest $requestPdf $snappy)
  300.     {
  301.         // use absolute path !
  302.         $pageUrl $this->generateUrl('reservation_invoice_deposit_invoice_print_externo', array('id' => $id'fid' => $fid), UrlGeneratorInterface::ABSOLUTE_URL);
  303.         return new Response(
  304.             $snappy->getOutput($pageUrl),
  305.             200,
  306.             array(
  307.                 'Content-Type'          => 'application/pdf',
  308.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  309.             )
  310.         );
  311.     }
  312.     /**
  313.      * @Route("/pdf/greenpatioinvprof/{type}/{id}",  name="print_reservation_invoice_proforma_pdf")
  314.      */
  315.     public function pdfInvoiceProformaPdfActionAction($type$idRequest $requestPdf $snappy)
  316.     {
  317.         // use absolute path !
  318.         $request->setDefaultLocale('es');
  319.         $request->getSession()->set('_locale''es');
  320.         $pageUrl $this->generateUrl('reservations_invoiceorproforma_print', array('type' => $type'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  321.         return new Response(
  322.             $snappy->getOutput($pageUrl),
  323.             200,
  324.             array(
  325.                 'Content-Type'          => 'application/pdf',
  326.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  327.             )
  328.         );
  329.     }
  330.     /**
  331.      * @Route("/pdf/greenpatioinvprofdeposit/{type}/{id}",  name="print_reservation_invoice_proforma_deposit_pdf")
  332.      */
  333.     public function pdfInvoiceProformaDepositPdfActionAction($type$idRequest $requestPdf $snappy)
  334.     {
  335.         // use absolute path !
  336.         $pageUrl $this->generateUrl('reservations_invoicedepositproforma_print', array('type' => $type'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  337.         return new Response(
  338.             $snappy->getOutput($pageUrl),
  339.             200,
  340.             array(
  341.                 'Content-Type'          => 'application/pdf',
  342.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  343.             )
  344.         );
  345.     }
  346.     /**
  347.      * @Route("/pdf/lclinvprofdeposit/{type}/{id}",  name="print_lcl_invoice_proforma_deposit_pdf")
  348.      */
  349.     public function pdfLclInvoiceProformaDepositPdfActionAction($type$idRequest $requestPdf $snappy)
  350.     {
  351.         // use absolute path !
  352.         $pageUrl $this->generateUrl('lcl_invoicedepositproforma_print', array('type' => $type'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  353.         return new Response(
  354.             $snappy->getOutput($pageUrl),
  355.             200,
  356.             array(
  357.                 'Content-Type'          => 'application/pdf',
  358.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  359.             )
  360.         );
  361.     }
  362.     /**
  363.      * @Route("/pdf/lclinvprof/{type}/{id}",  name="print_lcl_invoice_proforma_pdf")
  364.      */
  365.     public function pdfLclInvoiceProformaPdfActionAction($type$idRequest $requestPdf $snappy)
  366.     {
  367.         // use absolute path !
  368.         $request->setDefaultLocale('es');
  369.         $request->getSession()->set('_locale''es');
  370.         $pageUrl $this->generateUrl('lcl_invoiceorproforma_print', array('type' => $type'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  371.         return new Response(
  372.             $snappy->getOutput($pageUrl),
  373.             200,
  374.             array(
  375.                 'Content-Type'          => 'application/pdf',
  376.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  377.             )
  378.         );
  379.     }
  380.     /**
  381.      * @Route("/pdf/lcl-invprof/{type}/{id}",  name="print_lcl_invoice_or_proforma_pdf")
  382.      */
  383.     public function pdfLclInvoiceOrProformaPdfActionAction($type$idRequest $requestPdf $snappy)
  384.     {
  385.         // use absolute path !
  386.         $request->setDefaultLocale('es');
  387.         $request->getSession()->set('_locale''es');
  388.         $pageUrl $this->generateUrl('lcl_invoiceorproforma_print', array('type' => $type'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  389.         return new Response(
  390.             $snappy->getOutput($pageUrl),
  391.             200,
  392.             array(
  393.                 'Content-Type'          => 'application/pdf',
  394.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  395.             )
  396.         );
  397.     }
  398.     /**
  399.      * @Route("/pdf/lclforecast/",  name="print_lcl_forecast_pdf")
  400.      */
  401.     public function pdfLclForecastPdfActionAction(Request $requestPdf $snappy)
  402.     {
  403.         $newRequest $request->request->get('forecast');
  404.         $dateStartReq $newRequest['date_start'];
  405.         $dateEndReq $newRequest['date_end'];
  406.         $pageUrl $this->generateUrl('reservations_lcl_createforecastprint', array('dateStartReq' => $dateStartReq'dateEndReq' => $dateEndReq), UrlGeneratorInterface::ABSOLUTE_URL);
  407.         return new Response(
  408.             $snappy->getOutput($pageUrl),
  409.             200,
  410.             array(
  411.                 'Content-Type'          => 'application/pdf',
  412.                 'Content-Disposition'   => 'inline; filename="pdf-Prevision.pdf"'
  413.             )
  414.         );
  415.     }
  416.     /**
  417.      * @Route("/pdf/cvrgreenpatioinvprof/{type}/{id}",  name="print_cvr_reservation_invoice_proforma_pdf")
  418.      */
  419.     public function pdfCvrInvoiceProformaPdfActionAction($type$idRequest $requestPdf $snappy)
  420.     {
  421.         // Pdf de facturas, facturas rectificativas y proformas de Green Patio para la linea de faturacion de Covarrubias
  422.         // use absolute path !
  423.         $request->setDefaultLocale('es');
  424.         $request->getSession()->set('_locale''es');
  425.         $pageUrl $this->generateUrl('reservations_invoiceorproforma_print_cvr', array('type' => $type'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  426.         return new Response(
  427.             $snappy->getOutput($pageUrl),
  428.             200,
  429.             array(
  430.                 'Content-Type'          => 'application/pdf',
  431.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  432.             )
  433.         );
  434.     }
  435.     /**
  436.      * @Route("/pdf/cvrgreenpatioinvprofdeposit/{type}/{id}",  name="print_cvr_reservation_invoice_proforma_deposit_pdf")
  437.      */
  438.     public function pdfCvrInvoiceProformaDepositPdfActionAction($type$idRequest $requestPdf $snappy)
  439.     {
  440.         // Pdf de facturas, facturas rectificativas y proformas de Green Patio
  441.         // use absolute path !
  442.         $pageUrl $this->generateUrl('reservations_invoicedepositproforma_print_cvr', array('type' => $type'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  443.         return new Response(
  444.             $snappy->getOutput($pageUrl),
  445.             200,
  446.             array(
  447.                 'Content-Type'          => 'application/pdf',
  448.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  449.             )
  450.         );
  451.     }
  452.     /**
  453.      * @Route("/pdf/greenpatioforecast/",  name="print_greenpatio_forecast_pdf")
  454.      */
  455.     public function pdfGreenPatioForecastPdfActionAction(Request $requestPdf $snappy)
  456.     {
  457.         $newRequest $request->request->get('forecast');
  458.         $dateStartReq $newRequest['date_start'];
  459.         $dateEndReq $newRequest['date_end'];
  460.         $pageUrl $this->generateUrl('reservations_greenpatio_createforecastprint', array('dateStartReq' => $dateStartReq'dateEndReq' => $dateEndReq), UrlGeneratorInterface::ABSOLUTE_URL);
  461.         return new Response(
  462.             $snappy->getOutput($pageUrl),
  463.             200,
  464.             array(
  465.                 'Content-Type'          => 'application/pdf',
  466.                 'Content-Disposition'   => 'inline; filename="pdf-Prevision.pdf"'
  467.             )
  468.         );
  469.     }
  470.     /**
  471.      * @Route("/pdf/greenpatiocontract/{id}",  name="print_greenpatio_contract")
  472.      * Imprime el PDF del contrato de la reserva ID
  473.      */
  474.     public function pdfGreenPatioPdfContractAction($idRequest $requestPdf $snappy)
  475.     {
  476.         $pageUrl $this->generateUrl('reservations_contract', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  477.         return new Response(
  478.             $snappy->getOutput($pageUrl),
  479.             200,
  480.             array(
  481.                 'Content-Type'          => 'application/pdf',
  482.                 'Content-Disposition'   => 'inline; filename="pdf-Contract.pdf"'
  483.             )
  484.         );
  485.     }
  486.     /**
  487.      * @Route("/pdf/blvgreenpatioinvprof/{type}/{id}",  name="print_blv_reservation_invoice_proforma_pdf")
  488.      */
  489.     public function pdfBlvInvoiceProformaPdfActionAction($type$idRequest $requestPdf $snappy)
  490.     {
  491.         // Pdf de facturas, facturas rectificativas y proformas de Green Patio para la linea de faturacion de Bella View
  492.         // use absolute path !
  493.         $request->setDefaultLocale('es');
  494.         $request->getSession()->set('_locale''es');
  495.         $pageUrl $this->generateUrl('reservations_invoiceorproforma_print_blv', array('type' => $type'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  496.         return new Response(
  497.             $snappy->getOutput($pageUrl),
  498.             200,
  499.             array(
  500.                 'Content-Type'          => 'application/pdf',
  501.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  502.             )
  503.         );
  504.     }
  505.     /**
  506.      * @Route("/pdf/develupprofdeposit/{id}",  name="print_mdv_proforma_deposit_pdf")
  507.      * Pdf de la proforma de deposito de Develup
  508.      */
  509.     public function pdfDevelupProformaDepositAction($idRequest $requestPdf $snappy)
  510.     {
  511.         $pageUrl $this->generateUrl('mdv_print_proforma_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  512.         return new Response(
  513.             $snappy->getOutput($pageUrl),
  514.             200,
  515.             array(
  516.                 'Content-Type'          => 'application/pdf',
  517.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  518.             )
  519.         );
  520.     }
  521.     /**
  522.      * @Route("/pdf/develupinvdeposit/{id}",  name="print_mdv_invoice_deposit_pdf")
  523.      * Pdf de la factura de deposito de Develup
  524.      */
  525.     public function pdfDevelupInvoiceDepositAction($idRequest $requestPdf $snappy)
  526.     {
  527.         $pageUrl $this->generateUrl('mdv_print_invoice_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  528.         return new Response(
  529.             $snappy->getOutput($pageUrl),
  530.             200,
  531.             array(
  532.                 'Content-Type'          => 'application/pdf',
  533.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  534.             )
  535.         );
  536.     }
  537.     /**
  538.      * @Route("/pdf/develupinvdepositrec/{id}",  name="print_mdv_invoice_deposit_rec_pdf")
  539.      * Pdf de la factura de deposito rectificativa de Develup
  540.      */
  541.     public function pdfDevelupInvoiceDepositRecAction($idRequest $requestPdf $snappy)
  542.     {
  543.         $pageUrl $this->generateUrl('mdv_print_invoice_deposit_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  544.         return new Response(
  545.             $snappy->getOutput($pageUrl),
  546.             200,
  547.             array(
  548.                 'Content-Type'          => 'application/pdf',
  549.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  550.             )
  551.         );
  552.     }
  553.     /**
  554.      * @Route("/pdf/develupproforma/{id}",  name="print_mdv_proforma_pdf")
  555.      * Pdf de la proforma de Develup
  556.      */
  557.     public function pdfDevelupProformaAction($idRequest $requestPdf $snappy)
  558.     {
  559.         $pageUrl $this->generateUrl('mdv_print_proforma', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  560.         return new Response(
  561.             $snappy->getOutput($pageUrl),
  562.             200,
  563.             array(
  564.                 'Content-Type'          => 'application/pdf',
  565.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  566.             )
  567.         );
  568.     }
  569.     /**
  570.      * @Route("/pdf/develupinvoice/{id}",  name="print_mdv_invoice_pdf")
  571.      * Pdf de la factura de Develup
  572.      */
  573.     public function pdfDevelupInvoiceAction($idRequest $requestPdf $snappy)
  574.     {
  575.         $pageUrl $this->generateUrl('mdv_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  576.         return new Response(
  577.             $snappy->getOutput($pageUrl),
  578.             200,
  579.             array(
  580.                 'Content-Type'          => 'application/pdf',
  581.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  582.             )
  583.         );
  584.     }
  585.     /**
  586.      * @Route("/pdf/develupinvoicerec/{id}",  name="print_mdv_invoice_rec_pdf")
  587.      * Pdf de la factura rectificativa de Develup
  588.      */
  589.     public function pdfDevelupInvoiceRecAction($idRequest $requestPdf $snappy)
  590.     {
  591.         $pageUrl $this->generateUrl('mdv_print_invoice_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  592.         return new Response(
  593.             $snappy->getOutput($pageUrl),
  594.             200,
  595.             array(
  596.                 'Content-Type'          => 'application/pdf',
  597.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  598.             )
  599.         );
  600.     }
  601.     /**
  602.      * @Route("/pdf/avexpressprofdeposit/{id}",  name="print_ave_proforma_deposit_pdf")
  603.      * Pdf de la proforma de deposito de AV Express
  604.      */
  605.     public function pdfProformaDepositAction($idRequest $requestPdf $snappy)
  606.     {
  607.         $pageUrl $this->generateUrl('ave_print_proforma_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  608.         return new Response(
  609.             $snappy->getOutput($pageUrl),
  610.             200,
  611.             array(
  612.                 'Content-Type'          => 'application/pdf',
  613.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  614.             )
  615.         );
  616.     }
  617.     /**
  618.      * @Route("/pdf/avexpressinvdeposit/{id}",  name="print_ave_invoice_deposit_pdf")
  619.      * Pdf de la factura de deposito de AV Express
  620.      */
  621.     public function pdfInvoiceDepositAction($idRequest $requestPdf $snappy)
  622.     {
  623.         $pageUrl $this->generateUrl('ave_print_invoice_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  624.         return new Response(
  625.             $snappy->getOutput($pageUrl),
  626.             200,
  627.             array(
  628.                 'Content-Type'          => 'application/pdf',
  629.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  630.             )
  631.         );
  632.     }
  633.     /**
  634.      * @Route("/pdf/avexpressinvdepositrec/{id}",  name="print_ave_invoice_deposit_rec_pdf")
  635.      * Pdf de la factura de deposito rectificativa de AV Express
  636.      */
  637.     public function pdfInvoiceDepositRecAction($idRequest $requestPdf $snappy)
  638.     {
  639.         $pageUrl $this->generateUrl('ave_print_invoice_deposit_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  640.         return new Response(
  641.             $snappy->getOutput($pageUrl),
  642.             200,
  643.             array(
  644.                 'Content-Type'          => 'application/pdf',
  645.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  646.             )
  647.         );
  648.     }
  649.     /**
  650.      * @Route("/pdf/avexpressproforma/{id}",  name="print_ave_proforma_pdf")
  651.      * Pdf de la proforma de AV Express
  652.      */
  653.     public function pdfProformaAction($idRequest $requestPdf $snappy)
  654.     {
  655.         $pageUrl $this->generateUrl('ave_print_proforma', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  656.         return new Response(
  657.             $snappy->getOutput($pageUrl),
  658.             200,
  659.             array(
  660.                 'Content-Type'          => 'application/pdf',
  661.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  662.             )
  663.         );
  664.     }
  665.     /**
  666.      * @Route("/pdf/avexpressinvoice/{id}",  name="print_ave_invoice_pdf")
  667.      * Pdf de la factura de AV Express
  668.      */
  669.     public function pdfInvoiceAction($idRequest $requestPdf $snappy)
  670.     {
  671.         $pageUrl $this->generateUrl('ave_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  672.         return new Response(
  673.             $snappy->getOutput($pageUrl),
  674.             200,
  675.             array(
  676.                 'Content-Type'          => 'application/pdf',
  677.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  678.             )
  679.         );
  680.     }
  681.     /**
  682.      * @Route("/pdf/avexpressinvoicerec/{id}",  name="print_ave_invoice_rec_pdf")
  683.      * Pdf de la factura rectificativa de AV Express
  684.      */
  685.     public function pdfInvoiceRecAction($idRequest $requestPdf $snappy)
  686.     {
  687.         $pageUrl $this->generateUrl('ave_print_invoice_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  688.         return new Response(
  689.             $snappy->getOutput($pageUrl),
  690.             200,
  691.             array(
  692.                 'Content-Type'          => 'application/pdf',
  693.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  694.             )
  695.         );
  696.     }
  697.     /**
  698.      * @Route("/pdf/avexpressinvoiceext/{token}",  name="print_ave_invoice_ext_pdf")
  699.      * Pdf de la factura de AV Express para acceso externo de clientes
  700.      */
  701.     public function pdfInvoiceExtAction($tokenRequest $requestPdf $snappy)
  702.     {
  703.         $em $this->getDoctrine()->getManager();
  704.         $invoice $em->getRepository(AveDocInvoice::class)->findOneByAccessKey($token);
  705.         $id $invoice->getId();
  706.         $pageUrl $this->generateUrl('ave_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  707.         return new Response(
  708.             $snappy->getOutput($pageUrl),
  709.             200,
  710.             array(
  711.                 'Content-Type'          => 'application/pdf',
  712.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  713.             )
  714.         );
  715.     }
  716.     /**
  717.      * @Route("/pdf/printcontractreservation/{token}",  name="print_reservation_contract_pdf")
  718.      * Pdf del contrato de la reserva token
  719.      */
  720.     public function pdfContractReservationAction($tokenRequest $requestPdf $snappy)
  721.     {
  722.         $pageUrl $this->generateUrl('reservations_greenpatio_view_contract', array('id' => $token), UrlGeneratorInterface::ABSOLUTE_URL);
  723.         return new Response(
  724.             $snappy->getOutput($pageUrl),
  725.             200,
  726.             array(
  727.                 'Content-Type'          => 'application/pdf',
  728.                 'Content-Disposition'   => 'inline; filename="CONTRATO.pdf"'
  729.             )
  730.         );
  731.     }
  732.     /**
  733.      * @Route("/pdf/miceinvoice/{id}",  name="print_mice_invoice_pdf")
  734.      * Pdf de la factura de InOut MICE
  735.      */
  736.     public function pdfInvoiceMiceAction($idRequest $requestPdf $snappy)
  737.     {
  738.         $pageUrl $this->generateUrl('proposal_mice_invoice_print', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  739.         return new Response(
  740.             $snappy->getOutput($pageUrl),
  741.             200,
  742.             array(
  743.                 'Content-Type'          => 'application/pdf',
  744.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  745.             )
  746.         );
  747.     }
  748.     /**
  749.      * @Route("/pdf/pdfsummaryhtfile/{id}",  name="ht_file_summary_pdf")
  750.      */
  751.     public function pdfHtFileSummaryAction($idPdf $snappyEntityManagerInterface $em)
  752.     {
  753.         // Local
  754.         // $snappy = new Pdf('"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf"');
  755.         $htFile $em->getRepository(HtFile::class)->findOneById($id);
  756.         // Renderizar la cabecera y pie de página
  757.         $headerHtml $this->renderView('higotrigo/ht_file/header.html.twig', [
  758.             'ht_file' => $htFile
  759.         ]);
  760.         $snappy->setOption('header-html'$headerHtml);
  761.         $footerHtml $this->renderView('higotrigo/ht_file/footer.html.twig');
  762.         // $snappy->setOption('footer-html', $footerHtml);
  763.         $arrayElem = [];
  764.         $htItems $htFile->getHtItems();
  765.         if(!empty($htItems)) {
  766.             foreach ($htItems as $htItem) {
  767.                 $arrayEscandallos = [];
  768.                 $arrayMenus = [];
  769.                 $lounge = empty($htItem->getLoungeGp()) ? $htItem->getLoungeOther() : $htItem->getLoungeGp()->getName();
  770.                 $lounge = empty($lounge) ? 'No se ha indicado la sala' $lounge;
  771.                 if (!empty($htItem->getHtMenus())) {
  772.                     foreach (($htItem->getHtMenus()) as $htMenu){
  773.                         foreach (($htMenu->getEscandallo()) as $escan){
  774.                             $arrayEscandallos[] = array('escandallo' => $escan'nota' => $escan->getHtNotes()[0],);
  775.                         }
  776.                         $arrayMenus[] = array('htMenu' => $htMenu'arrayEscandallos' => $arrayEscandallos,);
  777.                     }
  778.                 }
  779.                 $arrayElem[$htItem->getDateStart()->format('YmdHi').str_pad($htItem->getId(), 6"0"STR_PAD_LEFT)] = array(
  780.                     'htItem'=>$htItem,
  781.                     'htMenus'=> $arrayMenus,
  782.                     'lounge'=>$lounge,
  783.                 );
  784.             }
  785.         }
  786.         ksort($arrayElem);
  787.         $reserva null$lngMont null$lngDesMont null;
  788.         $reservaIdNotLinked $htFile->getReservation();
  789.         if (!empty($reservaIdNotLinked)){ $reserva $em->getRepository(Reservation::class)->findOneById($reservaIdNotLinked->getId()); }
  790.         if (!empty($reserva)){
  791.             $lngMont $em->getRepository(ReservationLoungeSimple::class)->findOneBy( array( 'idReservation' => $reserva->getId(), 'type' => 'Montaje', ) );
  792.             $lngDesMont $em->getRepository(ReservationLoungeSimple::class)->findOneBy( array( 'idReservation' => $reserva->getId(), 'type' => 'Desmontaje', ) );
  793.         }
  794.         // Pdf de ordenes de trabajo de Higo&Trigo
  795.         $htmlContent $this->renderView('higotrigo/ht_file/summary-htfile-pdf.html.twig', [
  796.             'ht_file' => $htFile,
  797.             'arrayElem' => $arrayElem,
  798.             'reserva' => $reserva,
  799.             'montaje' => $lngMont,
  800.             'desmontaje' => $lngDesMont,
  801.         ]);
  802.         $snappy->setOption('enable-local-file-access'true);
  803.         $snappy->setOption('header-spacing'0); // Espaciado en milímetros
  804.         $snappy->setOption('footer-center''Página [page] de [toPage]');
  805.         $snappy->setOption('footer-font-size''8'); // Tamaño de fuente opcional
  806.         $snappy->setOption('footer-spacing'5); // Espaciado en milímetros
  807.         $snappy->setOption('margin-top''25mm'); // Aumentar el margen para acomodar el encabezado
  808.         $snappy->setOption('margin-bottom''15mm'); // Aumentar el margen para acomodar el pie de página
  809.         try {
  810.             $output $snappy->getOutputFromHtml($htmlContent);
  811.         } catch (\Exception $e) {
  812.             dd($e->getMessage());
  813.         }
  814.         return new Response(
  815.             $output,
  816.             200,
  817.             [
  818.                 'Content-Type'        => 'application/pdf',
  819.                 'Content-Disposition' => 'inline; filename="pdf-' $id '.pdf"',
  820.             ]
  821.         );
  822.     }
  823.     /**
  824.      * @Route("/pdf/pdfhtinvoice/{id}",  name="ht_invoice_pdf")
  825.      * Pdf de Factura de HT
  826.      */
  827.     public function pdfHtInvoiceAction($idRequest $requestPdf $snappyEntityManagerInterface $em)
  828.     {
  829.         $idNum = (substr($id01) == 'F') ? substr($id1) : substr($id2);      // F1, GP1, CV1
  830.         $prefix = (substr($id01) == 'F') ? 'F' substr($id02);
  831.         $parameters = array( 'idNum' => $idNum'prefix' => $prefix, );
  832.         $dql 'SELECT p
  833.                 FROM App\Entity\HtInvoice p
  834.                 WHERE p.idNum = :idNum AND p.prefix = :prefix';
  835.         $query $em->createQuery($dql)->setParameters($parameters);
  836.         $invoice $query->getResult();
  837.         $invoice = (!empty($invoice)) ? $invoice[0] : null;
  838.         $htFile $invoice->getHtFile();
  839.         $client $em->getRepository(Client::class)->findOneById($htFile->getClient());
  840.         // Pdf de ordenes de trabajo de Higo&Trigo
  841.         $pageUrl $this->generateUrl('ht_view_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  842.         return new Response(
  843.             $snappy->getOutput($pageUrl, [
  844.                 'margin-top' => 10,
  845.                 'margin-bottom' => 10,
  846.                 'footer-line' => true,
  847.             ]),
  848.             200,
  849.             array(
  850.                 'Content-Type'          => 'application/pdf',
  851.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  852.             )
  853.         );
  854.     }
  855.     /**
  856.      * @Route("/pdf/pdfhtinvoicerec/{id}",  name="ht_invoice_rec_pdf")
  857.      * Pdf de Factura Rectificativa de HT
  858.      */
  859.     public function pdfHtInvoiceRecAction($idRequest $requestPdf $snappyEntityManagerInterface $em)
  860.     {
  861.         $idNum = (substr($id02) == 'RF') ? substr($id2) : substr($id3);      // RF1, RGP1, RCV1
  862.         $prefix = (substr($id02) == 'RF') ? 'RF' substr($id03);
  863.         $parameters = array( 'idNum' => $idNum'prefix' => $prefix, );
  864.         $dql 'SELECT p
  865.                 FROM App\Entity\HtInvoice p
  866.                 WHERE p.idNum = :idNum AND p.prefix = :prefix';
  867.         $query $em->createQuery($dql)->setParameters($parameters);
  868.         $invoice $query->getResult();
  869.         $invoice = (!empty($invoice)) ? $invoice[0] : null;
  870.         $htFile $invoice->getHtFile();
  871.         $client $em->getRepository(Client::class)->findOneById($htFile->getClient());
  872.         // Pdf de ordenes de trabajo de Higo&Trigo
  873.         $pageUrl $this->generateUrl('ht_view_print_invoicerec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  874.         return new Response(
  875.             $snappy->getOutput($pageUrl, [
  876.                 'margin-top' => 10,
  877.                 'margin-bottom' => 10,
  878.                 'footer-line' => true,
  879.             ]),
  880.             200,
  881.             array(
  882.                 'Content-Type'          => 'application/pdf',
  883.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  884.             )
  885.         );
  886.     }
  887.     /**
  888.      * @Route("/pdf/pdfhtproforma/{id}",  name="ht_proforma_pdf")
  889.      * Pdf de Proforma de HT
  890.      */
  891.     public function pdfHtProformaAction($idRequest $requestPdf $snappyEntityManagerInterface $em)
  892.     {
  893.         $proforma $em->getRepository(HtProforma::class)->findOneById($id);
  894.         $htFile $em->getRepository(HtFile::class)->findOneById($proforma->getHtFile());
  895.         $client $htFile->getClient();
  896.         // Pdf de ordenes de trabajo de Higo&Trigo
  897.         $pageUrl $this->generateUrl('ht_view_print_proforma', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  898.         return new Response(
  899.             $snappy->getOutput($pageUrl, [
  900.                 'margin-top' => 10,
  901.                 'margin-bottom' => 10,
  902.                 'footer-line' => true,
  903.             ]),
  904.             200,
  905.             array(
  906.                 'Content-Type'          => 'application/pdf',
  907.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  908.             )
  909.         );
  910.     }
  911. }