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/develupprofdeposit/{id}",  name="print_mdv_proforma_deposit_pdf")
  472.      * Pdf de la proforma de deposito de Develup
  473.      */
  474.     public function pdfDevelupProformaDepositAction($idRequest $requestPdf $snappy)
  475.     {
  476.         $pageUrl $this->generateUrl('mdv_print_proforma_deposit', 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-' $id '.pdf"'
  483.             )
  484.         );
  485.     }
  486.     /**
  487.      * @Route("/pdf/develupinvdeposit/{id}",  name="print_mdv_invoice_deposit_pdf")
  488.      * Pdf de la factura de deposito de Develup
  489.      */
  490.     public function pdfDevelupInvoiceDepositAction($idRequest $requestPdf $snappy)
  491.     {
  492.         $pageUrl $this->generateUrl('mdv_print_invoice_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  493.         return new Response(
  494.             $snappy->getOutput($pageUrl),
  495.             200,
  496.             array(
  497.                 'Content-Type'          => 'application/pdf',
  498.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  499.             )
  500.         );
  501.     }
  502.     /**
  503.      * @Route("/pdf/develupinvdepositrec/{id}",  name="print_mdv_invoice_deposit_rec_pdf")
  504.      * Pdf de la factura de deposito rectificativa de Develup
  505.      */
  506.     public function pdfDevelupInvoiceDepositRecAction($idRequest $requestPdf $snappy)
  507.     {
  508.         $pageUrl $this->generateUrl('mdv_print_invoice_deposit_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  509.         return new Response(
  510.             $snappy->getOutput($pageUrl),
  511.             200,
  512.             array(
  513.                 'Content-Type'          => 'application/pdf',
  514.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  515.             )
  516.         );
  517.     }
  518.     /**
  519.      * @Route("/pdf/develupproforma/{id}",  name="print_mdv_proforma_pdf")
  520.      * Pdf de la proforma de Develup
  521.      */
  522.     public function pdfDevelupProformaAction($idRequest $requestPdf $snappy)
  523.     {
  524.         $pageUrl $this->generateUrl('mdv_print_proforma', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  525.         return new Response(
  526.             $snappy->getOutput($pageUrl),
  527.             200,
  528.             array(
  529.                 'Content-Type'          => 'application/pdf',
  530.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  531.             )
  532.         );
  533.     }
  534.     /**
  535.      * @Route("/pdf/develupinvoice/{id}",  name="print_mdv_invoice_pdf")
  536.      * Pdf de la factura de Develup
  537.      */
  538.     public function pdfDevelupInvoiceAction($idRequest $requestPdf $snappy)
  539.     {
  540.         $pageUrl $this->generateUrl('mdv_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  541.         return new Response(
  542.             $snappy->getOutput($pageUrl),
  543.             200,
  544.             array(
  545.                 'Content-Type'          => 'application/pdf',
  546.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  547.             )
  548.         );
  549.     }
  550.     /**
  551.      * @Route("/pdf/develupinvoicerec/{id}",  name="print_mdv_invoice_rec_pdf")
  552.      * Pdf de la factura rectificativa de Develup
  553.      */
  554.     public function pdfDevelupInvoiceRecAction($idRequest $requestPdf $snappy)
  555.     {
  556.         $pageUrl $this->generateUrl('mdv_print_invoice_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  557.         return new Response(
  558.             $snappy->getOutput($pageUrl),
  559.             200,
  560.             array(
  561.                 'Content-Type'          => 'application/pdf',
  562.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  563.             )
  564.         );
  565.     }
  566.     /**
  567.      * @Route("/pdf/avexpressprofdeposit/{id}",  name="print_ave_proforma_deposit_pdf")
  568.      * Pdf de la proforma de deposito de AV Express
  569.      */
  570.     public function pdfProformaDepositAction($idRequest $requestPdf $snappy)
  571.     {
  572.         $pageUrl $this->generateUrl('ave_print_proforma_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  573.         return new Response(
  574.             $snappy->getOutput($pageUrl),
  575.             200,
  576.             array(
  577.                 'Content-Type'          => 'application/pdf',
  578.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  579.             )
  580.         );
  581.     }
  582.     /**
  583.      * @Route("/pdf/avexpressinvdeposit/{id}",  name="print_ave_invoice_deposit_pdf")
  584.      * Pdf de la factura de deposito de AV Express
  585.      */
  586.     public function pdfInvoiceDepositAction($idRequest $requestPdf $snappy)
  587.     {
  588.         $pageUrl $this->generateUrl('ave_print_invoice_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  589.         return new Response(
  590.             $snappy->getOutput($pageUrl),
  591.             200,
  592.             array(
  593.                 'Content-Type'          => 'application/pdf',
  594.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  595.             )
  596.         );
  597.     }
  598.     /**
  599.      * @Route("/pdf/avexpressinvdepositrec/{id}",  name="print_ave_invoice_deposit_rec_pdf")
  600.      * Pdf de la factura de deposito rectificativa de AV Express
  601.      */
  602.     public function pdfInvoiceDepositRecAction($idRequest $requestPdf $snappy)
  603.     {
  604.         $pageUrl $this->generateUrl('ave_print_invoice_deposit_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  605.         return new Response(
  606.             $snappy->getOutput($pageUrl),
  607.             200,
  608.             array(
  609.                 'Content-Type'          => 'application/pdf',
  610.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  611.             )
  612.         );
  613.     }
  614.     /**
  615.      * @Route("/pdf/avexpressproforma/{id}",  name="print_ave_proforma_pdf")
  616.      * Pdf de la proforma de AV Express
  617.      */
  618.     public function pdfProformaAction($idRequest $requestPdf $snappy)
  619.     {
  620.         $pageUrl $this->generateUrl('ave_print_proforma', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  621.         return new Response(
  622.             $snappy->getOutput($pageUrl),
  623.             200,
  624.             array(
  625.                 'Content-Type'          => 'application/pdf',
  626.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  627.             )
  628.         );
  629.     }
  630.     /**
  631.      * @Route("/pdf/avexpressinvoice/{id}",  name="print_ave_invoice_pdf")
  632.      * Pdf de la factura de AV Express
  633.      */
  634.     public function pdfInvoiceAction($idRequest $requestPdf $snappy)
  635.     {
  636.         $pageUrl $this->generateUrl('ave_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  637.         return new Response(
  638.             $snappy->getOutput($pageUrl),
  639.             200,
  640.             array(
  641.                 'Content-Type'          => 'application/pdf',
  642.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  643.             )
  644.         );
  645.     }
  646.     /**
  647.      * @Route("/pdf/avexpressinvoicerec/{id}",  name="print_ave_invoice_rec_pdf")
  648.      * Pdf de la factura rectificativa de AV Express
  649.      */
  650.     public function pdfInvoiceRecAction($idRequest $requestPdf $snappy)
  651.     {
  652.         $pageUrl $this->generateUrl('ave_print_invoice_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  653.         return new Response(
  654.             $snappy->getOutput($pageUrl),
  655.             200,
  656.             array(
  657.                 'Content-Type'          => 'application/pdf',
  658.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  659.             )
  660.         );
  661.     }
  662.     /**
  663.      * @Route("/pdf/avexpressinvoiceext/{token}",  name="print_ave_invoice_ext_pdf")
  664.      * Pdf de la factura de AV Express para acceso externo de clientes
  665.      */
  666.     public function pdfInvoiceExtAction($tokenRequest $requestPdf $snappy)
  667.     {
  668.         $em $this->getDoctrine()->getManager();
  669.         $invoice $em->getRepository(AveDocInvoice::class)->findOneByAccessKey($token);
  670.         $id $invoice->getId();
  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/printcontractreservation/{token}",  name="print_reservation_contract_pdf")
  683.      * Pdf del contrato de la reserva token
  684.      */
  685.     public function pdfContractReservationAction($tokenRequest $requestPdf $snappy)
  686.     {
  687.         $pageUrl $this->generateUrl('reservations_greenpatio_view_contract', array('id' => $token), 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="CONTRATO.pdf"'
  694.             )
  695.         );
  696.     }
  697.     /**
  698.      * @Route("/pdf/miceinvoice/{id}",  name="print_mice_invoice_pdf")
  699.      * Pdf de la factura de InOut MICE
  700.      */
  701.     public function pdfInvoiceMiceAction($idRequest $requestPdf $snappy)
  702.     {
  703.         $pageUrl $this->generateUrl('proposal_mice_invoice_print', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  704.         return new Response(
  705.             $snappy->getOutput($pageUrl),
  706.             200,
  707.             array(
  708.                 'Content-Type'          => 'application/pdf',
  709.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  710.             )
  711.         );
  712.     }
  713.     /**
  714.      * @Route("/pdf/pdfsummaryhtfile/{id}",  name="ht_file_summary_pdf")
  715.      */
  716.     public function pdfHtFileSummaryAction($idPdf $snappyEntityManagerInterface $em)
  717.     {
  718.         // Local
  719.         // $snappy = new Pdf('"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf"');
  720.         $htFile $em->getRepository(HtFile::class)->findOneById($id);
  721.         // Renderizar la cabecera y pie de página
  722.         $headerHtml $this->renderView('higotrigo/ht_file/header.html.twig', [
  723.             'ht_file' => $htFile
  724.         ]);
  725.         $snappy->setOption('header-html'$headerHtml);
  726.         $footerHtml $this->renderView('higotrigo/ht_file/footer.html.twig');
  727.         // $snappy->setOption('footer-html', $footerHtml);
  728.         $arrayElem = [];
  729.         $htItems $htFile->getHtItems();
  730.         if(!empty($htItems)) {
  731.             foreach ($htItems as $htItem) {
  732.                 $arrayEscandallos = [];
  733.                 $arrayMenus = [];
  734.                 $lounge = empty($htItem->getLoungeGp()) ? $htItem->getLoungeOther() : $htItem->getLoungeGp()->getName();
  735.                 $lounge = empty($lounge) ? 'No se ha indicado la sala' $lounge;
  736.                 if (!empty($htItem->getHtMenus())) {
  737.                     foreach (($htItem->getHtMenus()) as $htMenu){
  738.                         foreach (($htMenu->getEscandallo()) as $escan){
  739.                             $arrayEscandallos[] = array('escandallo' => $escan'nota' => $escan->getHtNotes()[0],);
  740.                         }
  741.                         $arrayMenus[] = array('htMenu' => $htMenu'arrayEscandallos' => $arrayEscandallos,);
  742.                     }
  743.                 }
  744.                 $arrayElem[$htItem->getDateStart()->format('YmdHi').str_pad($htItem->getId(), 6"0"STR_PAD_LEFT)] = array(
  745.                     'htItem'=>$htItem,
  746.                     'htMenus'=> $arrayMenus,
  747.                     'lounge'=>$lounge,
  748.                 );
  749.             }
  750.         }
  751.         ksort($arrayElem);
  752.         $reserva null$lngMont null$lngDesMont null;
  753.         $reservaIdNotLinked $htFile->getReservation();
  754.         if (!empty($reservaIdNotLinked)){ $reserva $em->getRepository(Reservation::class)->findOneById($reservaIdNotLinked->getId()); }
  755.         if (!empty($reserva)){
  756.             $lngMont $em->getRepository(ReservationLoungeSimple::class)->findOneBy( array( 'idReservation' => $reserva->getId(), 'type' => 'Montaje', ) );
  757.             $lngDesMont $em->getRepository(ReservationLoungeSimple::class)->findOneBy( array( 'idReservation' => $reserva->getId(), 'type' => 'Desmontaje', ) );
  758.         }
  759.         // Pdf de ordenes de trabajo de Higo&Trigo
  760.         $htmlContent $this->renderView('higotrigo/ht_file/summary-htfile-pdf.html.twig', [
  761.             'ht_file' => $htFile,
  762.             'arrayElem' => $arrayElem,
  763.             'reserva' => $reserva,
  764.             'montaje' => $lngMont,
  765.             'desmontaje' => $lngDesMont,
  766.         ]);
  767.         $snappy->setOption('enable-local-file-access'true);
  768.         $snappy->setOption('header-spacing'0); // Espaciado en milímetros
  769.         $snappy->setOption('footer-center''Página [page] de [toPage]');
  770.         $snappy->setOption('footer-font-size''8'); // Tamaño de fuente opcional
  771.         $snappy->setOption('footer-spacing'5); // Espaciado en milímetros
  772.         $snappy->setOption('margin-top''25mm'); // Aumentar el margen para acomodar el encabezado
  773.         $snappy->setOption('margin-bottom''15mm'); // Aumentar el margen para acomodar el pie de página
  774.         try {
  775.             $output $snappy->getOutputFromHtml($htmlContent);
  776.         } catch (\Exception $e) {
  777.             dd($e->getMessage());
  778.         }
  779.         return new Response(
  780.             $output,
  781.             200,
  782.             [
  783.                 'Content-Type'        => 'application/pdf',
  784.                 'Content-Disposition' => 'inline; filename="pdf-' $id '.pdf"',
  785.             ]
  786.         );
  787.     }
  788.     /**
  789.      * @Route("/pdf/pdfhtinvoice/{id}",  name="ht_invoice_pdf")
  790.      * Pdf de Factura de HT
  791.      */
  792.     public function pdfHtInvoiceAction($idRequest $requestPdf $snappyEntityManagerInterface $em)
  793.     {
  794.         $idNum = (substr($id01) == 'F') ? substr($id1) : substr($id2);      // F1, GP1, CV1
  795.         $prefix = (substr($id01) == 'F') ? 'F' substr($id02);
  796.         $parameters = array( 'idNum' => $idNum'prefix' => $prefix, );
  797.         $dql 'SELECT p
  798.                 FROM App\Entity\HtInvoice p
  799.                 WHERE p.idNum = :idNum AND p.prefix = :prefix';
  800.         $query $em->createQuery($dql)->setParameters($parameters);
  801.         $invoice $query->getResult();
  802.         $invoice = (!empty($invoice)) ? $invoice[0] : null;
  803.         $htFile $invoice->getHtFile();
  804.         $client $em->getRepository(Client::class)->findOneById($htFile->getClient());
  805.         // Pdf de ordenes de trabajo de Higo&Trigo
  806.         $pageUrl $this->generateUrl('ht_view_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  807.         return new Response(
  808.             $snappy->getOutput($pageUrl, [
  809.                 'margin-top' => 10,
  810.                 'margin-bottom' => 10,
  811.                 'footer-line' => true,
  812.             ]),
  813.             200,
  814.             array(
  815.                 'Content-Type'          => 'application/pdf',
  816.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  817.             )
  818.         );
  819.     }
  820.     /**
  821.      * @Route("/pdf/pdfhtinvoicerec/{id}",  name="ht_invoice_rec_pdf")
  822.      * Pdf de Factura Rectificativa de HT
  823.      */
  824.     public function pdfHtInvoiceRecAction($idRequest $requestPdf $snappyEntityManagerInterface $em)
  825.     {
  826.         $idNum = (substr($id02) == 'RF') ? substr($id2) : substr($id3);      // RF1, RGP1, RCV1
  827.         $prefix = (substr($id02) == 'RF') ? 'RF' substr($id03);
  828.         $parameters = array( 'idNum' => $idNum'prefix' => $prefix, );
  829.         $dql 'SELECT p
  830.                 FROM App\Entity\HtInvoice p
  831.                 WHERE p.idNum = :idNum AND p.prefix = :prefix';
  832.         $query $em->createQuery($dql)->setParameters($parameters);
  833.         $invoice $query->getResult();
  834.         $invoice = (!empty($invoice)) ? $invoice[0] : null;
  835.         $htFile $invoice->getHtFile();
  836.         $client $em->getRepository(Client::class)->findOneById($htFile->getClient());
  837.         // Pdf de ordenes de trabajo de Higo&Trigo
  838.         $pageUrl $this->generateUrl('ht_view_print_invoicerec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  839.         return new Response(
  840.             $snappy->getOutput($pageUrl, [
  841.                 'margin-top' => 10,
  842.                 'margin-bottom' => 10,
  843.                 'footer-line' => true,
  844.             ]),
  845.             200,
  846.             array(
  847.                 'Content-Type'          => 'application/pdf',
  848.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  849.             )
  850.         );
  851.     }
  852.     /**
  853.      * @Route("/pdf/pdfhtproforma/{id}",  name="ht_proforma_pdf")
  854.      * Pdf de Proforma de HT
  855.      */
  856.     public function pdfHtProformaAction($idRequest $requestPdf $snappyEntityManagerInterface $em)
  857.     {
  858.         $proforma $em->getRepository(HtProforma::class)->findOneById($id);
  859.         $htFile $em->getRepository(HtFile::class)->findOneById($proforma->getHtFile());
  860.         $client $htFile->getClient();
  861.         // Pdf de ordenes de trabajo de Higo&Trigo
  862.         $pageUrl $this->generateUrl('ht_view_print_proforma', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
  863.         return new Response(
  864.             $snappy->getOutput($pageUrl, [
  865.                 'margin-top' => 10,
  866.                 'margin-bottom' => 10,
  867.                 'footer-line' => true,
  868.             ]),
  869.             200,
  870.             array(
  871.                 'Content-Type'          => 'application/pdf',
  872.                 'Content-Disposition'   => 'inline; filename="pdf-' $id '.pdf"'
  873.             )
  874.         );
  875.     }
  876. }