<?php
/**
* Created by Mediterranean Develup Solutions
* User: jorge.defreitas@develup.solutions
* Date: 18/01/2018
* Time: 19:22
*/
namespace App\Controller;
use App\Entity\Client;
use App\Entity\Configuration;
use App\Entity\HtFile;
use App\Entity\HtInvoice;
use App\Entity\HtProforma;
use App\Entity\SendMail;
use App\Entity\SettingsCompany;
use App\Form\SendMailType;
use App\MDS\AvexpressBundle\Entity\AveDocInvoice;
use App\MDS\EventsBundle\Entity\Proposal;
use App\MDS\GreenPatioBundle\Entity\Reservation;
use App\MDS\GreenPatioBundle\Entity\ReservationLoungeSimple;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Knp\Snappy\Pdf;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Validator\Constraints as Assert;
class PdfExternalPrint extends AbstractController
{
/**
* @Route("/pdf/pro/{id}", name="print_invoice_proforma_pdf")
*/
public function pdfProformaPdfActionAction($id, Request $request, Pdf $snappy)
{
// use absolute path !
$pageUrl = $this->generateUrl('proposal_invoice_proforma_print_externo', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/inv/{id}", name="print_invoice_invoice_pdf")
*/
public function pdfInvoicePdfActionAction($id, Request $request, Pdf $snappy)
{
// use absolute path !
$pageUrl = $this->generateUrl('proposal_invoice_detector_print_externo', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/prodeposit/{id}", name="print_invoice_deposit_proforma_pdf")
*/
public function pdfProformaDepositPdfActionAction($id, Request $request, Pdf $snappy)
{
// use absolute path !
$pageUrl = $this->generateUrl('proposal_invoice_deposit_proforma_print_externo', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/invdeposit/{id}/{fid}", name="print_invoice_deposit_invoice_pdf")
*/
public function pdfInvoiceDepositPdfActionAction($id, $fid, Request $request, Pdf $snappy)
{
// use absolute path !
$pageUrl = $this->generateUrl('proposal_invoice_deposit_invoice_print_externo', array('id' => $id, 'fid' => $fid), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/clientAgenda/{token}", name="print_agenda_pdf_client")
*/
public function pdfClientAgendaPdfActionAction($token, Request $request, Pdf $snappy)
{
$em = $this->getDoctrine()->getManager();
$proposal = $em->getRepository(Proposal::class)->findOneByAccessKey($token);
// use absolute path !
$pageUrl = $this->generateUrl('presentation_client_view_agenda', array('token' => $token), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $proposal->getId() . '.pdf"'
)
);
}
/**
* @Route("/pdf/managerAgenda/{token}", name="print_agenda_pdf_manager")
*/
public function pdfManagerAgendaPdfActionAction($token, Request $request, Pdf $snappy)
{
$em = $this->getDoctrine()->getManager();
$proposal = $em->getRepository(Proposal::class)->findOneByAccessKey($token);
// use absolute path !
$pageUrl = $this->generateUrl('presentation_manager_view_agenda', array('token' => $token), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $proposal->getId() . '.pdf"'
)
);
}
/**
* @Route("/pdf/disclaimer/{token}", name="print_disclaimer_pdf")
*/
public function pdfManagerDisclaimerPdfActionAction($token, Request $request, Pdf $snappy)
{
$em = $this->getDoctrine()->getManager();
// use absolute path !
$pageUrl = $this->generateUrl('print_disclaimer', array('token' => $token), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-disclaimer.pdf"'
)
);
}
/**
* @Route("/pdf/calendar", name="print_calendar_pdf")
*/
public function pdfManagerCalendarPdfAction(Request $request, Pdf $snappy)
{
$token = $request->request->get('token');
$em = $this->getDoctrine()->getManager();
// use absolute path !
$pageUrl = $this->generateUrl('calendar-full-pdf', array('token' => $token), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-calendar.pdf"'
)
);
}
/**
* @Route("/pdf/simpleagenda/view/{token}/{logo}", name="proposal_agenda_simple_pdf_view")
*/
public function AgendaSimplePdfCreateAction($token, $logo, Request $request)
{
$em = $this->getDoctrine()->getManager();
$proposal = $em->getRepository(Proposal::class)->findOneByAccessKey($token);
$parameters = array(
'id' => $proposal->getId()
);
$dql = 'SELECT p
FROM EventsBundle:ProposalSimpleAgenda p
WHERE p.idProposal = :id
ORDER BY p.date, p.hour ASC ';
$query = $em->createQuery($dql)->setParameters($parameters);
$simpleAgenda_data = $query->getResult();
$simpleAgenda = array();
if (!empty($simpleAgenda_data)) {
foreach ($simpleAgenda_data as $item) {
$date = $item->getDate()->format('Y-m-d');
$simpleAgenda[$date][] = $item;
}
}
// --- Prueba en PDF para generar el arreglo jumpDays
$lineCounter = 0;
$jumpDays = array();
$previusDayId = 0;
// -- Determino en cual elemento debo poner el mensaje de salto de pagina
if (!empty($simpleAgenda)) {
foreach ($simpleAgenda as $day) {
if ((substr_count($day[0]->getText(), '</p>') + $lineCounter) > 40) { // -- Verifico si el dia cabe en su totalidad la primera entrada del dia
$jumpDays[] = $previusDayId; // -- Poner el jumpday en el previus
$lineCounter = 0;
}
foreach ($day as $item) {
if (substr_count($item->getText(), '</p>') == 0) {
$lineCounter = $lineCounter + 1; // Se detecto que con un font especifico (Comic) si no hay salto de linea, substr_count($item->getText(),'</p>') da cero
} else {
$lineCounter = $lineCounter + substr_count($item->getText(), '</p>');
}
if ($lineCounter >= 40) {
$jumpDays[] = $item->getId();
$lineCounter = 0;
}
$previusDayId = $item->getId();
}
}
}
$rutaLogo = null;
if ($logo == 1) {
$company = $em->getRepository(SettingsCompany::class)->findOneById('1');
$rutaLogo = $company->getPicture();
}
$proposalName = $proposal->getName();
// --- Prueba en PDF para generar el arreglo jumpDays
return $this->render(
'MDS/EventsBundle/agenda/add-task-simple-agenda-pdf.html.twig',
array(
'simpleAgenda' => $simpleAgenda, //cada elemento debe ser un dia de la agenda
'jumpDays' => $jumpDays,
'logo' => $logo,
'rutaLogo' => $rutaLogo,
'proposalName' => $proposalName
)
);
}
/**
* @Route("/pdf/simpleagendaprint/{token}/{logo}", name="proposal_agenda_simple_pdf_print")
*/
public function pdfSimpleAgendaPdfActionAction($token, $logo, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('proposal_agenda_simple_pdf_view', array('token' => $token, 'logo' => $logo), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $token . '.pdf"'
)
);
}
/**
* @Route("/pdf/summaryideapdfprint/{id}", name="summary_idea_pdf_print")
*/
public function pdfSummaryIdeaPdfActionAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('summary_idea_pdf_view', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/greenpatiopro/{id}", name="print_greenpatio_proforma_pdf")
*/
public function pdfGreenPatioProformaPdfActionAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('reservations_invoice_proforma_print', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/greenpatioinv/{id}", name="print_greenpatio_invoice_pdf")
*/
public function pdfGreenPatioInvoicePdfActionAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('reservations_invoice_print', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/greenpatioinv/invdeposit/{id}/{fid}", name="print_reservation_invoice_deposit_invoice_pdf")
*/
public function pdfReservationInvoiceDepositPdfActionAction($id, $fid, Request $request, Pdf $snappy)
{
// use absolute path !
$pageUrl = $this->generateUrl('reservation_invoice_deposit_invoice_print_externo', array('id' => $id, 'fid' => $fid), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/greenpatioinvprof/{type}/{id}", name="print_reservation_invoice_proforma_pdf")
*/
public function pdfInvoiceProformaPdfActionAction($type, $id, Request $request, Pdf $snappy)
{
// use absolute path !
$request->setDefaultLocale('es');
$request->getSession()->set('_locale', 'es');
$pageUrl = $this->generateUrl('reservations_invoiceorproforma_print', array('type' => $type, 'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/greenpatioinvprofdeposit/{type}/{id}", name="print_reservation_invoice_proforma_deposit_pdf")
*/
public function pdfInvoiceProformaDepositPdfActionAction($type, $id, Request $request, Pdf $snappy)
{
// use absolute path !
$pageUrl = $this->generateUrl('reservations_invoicedepositproforma_print', array('type' => $type, 'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/lclinvprofdeposit/{type}/{id}", name="print_lcl_invoice_proforma_deposit_pdf")
*/
public function pdfLclInvoiceProformaDepositPdfActionAction($type, $id, Request $request, Pdf $snappy)
{
// use absolute path !
$pageUrl = $this->generateUrl('lcl_invoicedepositproforma_print', array('type' => $type, 'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/lclinvprof/{type}/{id}", name="print_lcl_invoice_proforma_pdf")
*/
public function pdfLclInvoiceProformaPdfActionAction($type, $id, Request $request, Pdf $snappy)
{
// use absolute path !
$request->setDefaultLocale('es');
$request->getSession()->set('_locale', 'es');
$pageUrl = $this->generateUrl('lcl_invoiceorproforma_print', array('type' => $type, 'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/lcl-invprof/{type}/{id}", name="print_lcl_invoice_or_proforma_pdf")
*/
public function pdfLclInvoiceOrProformaPdfActionAction($type, $id, Request $request, Pdf $snappy)
{
// use absolute path !
$request->setDefaultLocale('es');
$request->getSession()->set('_locale', 'es');
$pageUrl = $this->generateUrl('lcl_invoiceorproforma_print', array('type' => $type, 'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/lclforecast/", name="print_lcl_forecast_pdf")
*/
public function pdfLclForecastPdfActionAction(Request $request, Pdf $snappy)
{
$newRequest = $request->request->get('forecast');
$dateStartReq = $newRequest['date_start'];
$dateEndReq = $newRequest['date_end'];
$pageUrl = $this->generateUrl('reservations_lcl_createforecastprint', array('dateStartReq' => $dateStartReq, 'dateEndReq' => $dateEndReq), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-Prevision.pdf"'
)
);
}
/**
* @Route("/pdf/cvrgreenpatioinvprof/{type}/{id}", name="print_cvr_reservation_invoice_proforma_pdf")
*/
public function pdfCvrInvoiceProformaPdfActionAction($type, $id, Request $request, Pdf $snappy)
{
// Pdf de facturas, facturas rectificativas y proformas de Green Patio para la linea de faturacion de Covarrubias
// use absolute path !
$request->setDefaultLocale('es');
$request->getSession()->set('_locale', 'es');
$pageUrl = $this->generateUrl('reservations_invoiceorproforma_print_cvr', array('type' => $type, 'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/cvrgreenpatioinvprofdeposit/{type}/{id}", name="print_cvr_reservation_invoice_proforma_deposit_pdf")
*/
public function pdfCvrInvoiceProformaDepositPdfActionAction($type, $id, Request $request, Pdf $snappy)
{
// Pdf de facturas, facturas rectificativas y proformas de Green Patio
// use absolute path !
$pageUrl = $this->generateUrl('reservations_invoicedepositproforma_print_cvr', array('type' => $type, 'id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/greenpatioforecast/", name="print_greenpatio_forecast_pdf")
*/
public function pdfGreenPatioForecastPdfActionAction(Request $request, Pdf $snappy)
{
$newRequest = $request->request->get('forecast');
$dateStartReq = $newRequest['date_start'];
$dateEndReq = $newRequest['date_end'];
$pageUrl = $this->generateUrl('reservations_greenpatio_createforecastprint', array('dateStartReq' => $dateStartReq, 'dateEndReq' => $dateEndReq), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-Prevision.pdf"'
)
);
}
/**
* @Route("/pdf/develupprofdeposit/{id}", name="print_mdv_proforma_deposit_pdf")
* Pdf de la proforma de deposito de Develup
*/
public function pdfDevelupProformaDepositAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('mdv_print_proforma_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/develupinvdeposit/{id}", name="print_mdv_invoice_deposit_pdf")
* Pdf de la factura de deposito de Develup
*/
public function pdfDevelupInvoiceDepositAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('mdv_print_invoice_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/develupinvdepositrec/{id}", name="print_mdv_invoice_deposit_rec_pdf")
* Pdf de la factura de deposito rectificativa de Develup
*/
public function pdfDevelupInvoiceDepositRecAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('mdv_print_invoice_deposit_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/develupproforma/{id}", name="print_mdv_proforma_pdf")
* Pdf de la proforma de Develup
*/
public function pdfDevelupProformaAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('mdv_print_proforma', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/develupinvoice/{id}", name="print_mdv_invoice_pdf")
* Pdf de la factura de Develup
*/
public function pdfDevelupInvoiceAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('mdv_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/develupinvoicerec/{id}", name="print_mdv_invoice_rec_pdf")
* Pdf de la factura rectificativa de Develup
*/
public function pdfDevelupInvoiceRecAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('mdv_print_invoice_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/avexpressprofdeposit/{id}", name="print_ave_proforma_deposit_pdf")
* Pdf de la proforma de deposito de AV Express
*/
public function pdfProformaDepositAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('ave_print_proforma_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/avexpressinvdeposit/{id}", name="print_ave_invoice_deposit_pdf")
* Pdf de la factura de deposito de AV Express
*/
public function pdfInvoiceDepositAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('ave_print_invoice_deposit', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/avexpressinvdepositrec/{id}", name="print_ave_invoice_deposit_rec_pdf")
* Pdf de la factura de deposito rectificativa de AV Express
*/
public function pdfInvoiceDepositRecAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('ave_print_invoice_deposit_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/avexpressproforma/{id}", name="print_ave_proforma_pdf")
* Pdf de la proforma de AV Express
*/
public function pdfProformaAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('ave_print_proforma', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/avexpressinvoice/{id}", name="print_ave_invoice_pdf")
* Pdf de la factura de AV Express
*/
public function pdfInvoiceAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('ave_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/avexpressinvoicerec/{id}", name="print_ave_invoice_rec_pdf")
* Pdf de la factura rectificativa de AV Express
*/
public function pdfInvoiceRecAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('ave_print_invoice_rec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/avexpressinvoiceext/{token}", name="print_ave_invoice_ext_pdf")
* Pdf de la factura de AV Express para acceso externo de clientes
*/
public function pdfInvoiceExtAction($token, Request $request, Pdf $snappy)
{
$em = $this->getDoctrine()->getManager();
$invoice = $em->getRepository(AveDocInvoice::class)->findOneByAccessKey($token);
$id = $invoice->getId();
$pageUrl = $this->generateUrl('ave_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/printcontractreservation/{token}", name="print_reservation_contract_pdf")
* Pdf del contrato de la reserva token
*/
public function pdfContractReservationAction($token, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('reservations_greenpatio_view_contract', array('id' => $token), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="CONTRATO.pdf"'
)
);
}
/**
* @Route("/pdf/miceinvoice/{id}", name="print_mice_invoice_pdf")
* Pdf de la factura de InOut MICE
*/
public function pdfInvoiceMiceAction($id, Request $request, Pdf $snappy)
{
$pageUrl = $this->generateUrl('proposal_mice_invoice_print', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/pdfsummaryhtfile/{id}", name="ht_file_summary_pdf")
*/
public function pdfHtFileSummaryAction($id, Pdf $snappy, EntityManagerInterface $em)
{
// Local
// $snappy = new Pdf('"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf"');
$htFile = $em->getRepository(HtFile::class)->findOneById($id);
// Renderizar la cabecera y pie de página
$headerHtml = $this->renderView('higotrigo/ht_file/header.html.twig', [
'ht_file' => $htFile
]);
$snappy->setOption('header-html', $headerHtml);
$footerHtml = $this->renderView('higotrigo/ht_file/footer.html.twig');
// $snappy->setOption('footer-html', $footerHtml);
$arrayElem = [];
$htItems = $htFile->getHtItems();
if(!empty($htItems)) {
foreach ($htItems as $htItem) {
$arrayEscandallos = [];
$arrayMenus = [];
$lounge = empty($htItem->getLoungeGp()) ? $htItem->getLoungeOther() : $htItem->getLoungeGp()->getName();
$lounge = empty($lounge) ? 'No se ha indicado la sala' : $lounge;
if (!empty($htItem->getHtMenus())) {
foreach (($htItem->getHtMenus()) as $htMenu){
foreach (($htMenu->getEscandallo()) as $escan){
$arrayEscandallos[] = array('escandallo' => $escan, 'nota' => $escan->getHtNotes()[0],);
}
$arrayMenus[] = array('htMenu' => $htMenu, 'arrayEscandallos' => $arrayEscandallos,);
}
}
$arrayElem[$htItem->getDateStart()->format('YmdHi').str_pad($htItem->getId(), 6, "0", STR_PAD_LEFT)] = array(
'htItem'=>$htItem,
'htMenus'=> $arrayMenus,
'lounge'=>$lounge,
);
}
}
ksort($arrayElem);
$reserva = null; $lngMont = null; $lngDesMont = null;
$reservaIdNotLinked = $htFile->getReservation();
if (!empty($reservaIdNotLinked)){ $reserva = $em->getRepository(Reservation::class)->findOneById($reservaIdNotLinked->getId()); }
if (!empty($reserva)){
$lngMont = $em->getRepository(ReservationLoungeSimple::class)->findOneBy( array( 'idReservation' => $reserva->getId(), 'type' => 'Montaje', ) );
$lngDesMont = $em->getRepository(ReservationLoungeSimple::class)->findOneBy( array( 'idReservation' => $reserva->getId(), 'type' => 'Desmontaje', ) );
}
// Pdf de ordenes de trabajo de Higo&Trigo
$htmlContent = $this->renderView('higotrigo/ht_file/summary-htfile-pdf.html.twig', [
'ht_file' => $htFile,
'arrayElem' => $arrayElem,
'reserva' => $reserva,
'montaje' => $lngMont,
'desmontaje' => $lngDesMont,
]);
$snappy->setOption('enable-local-file-access', true);
$snappy->setOption('header-spacing', 0); // Espaciado en milímetros
$snappy->setOption('footer-center', 'Página [page] de [toPage]');
$snappy->setOption('footer-font-size', '8'); // Tamaño de fuente opcional
$snappy->setOption('footer-spacing', 5); // Espaciado en milímetros
$snappy->setOption('margin-top', '25mm'); // Aumentar el margen para acomodar el encabezado
$snappy->setOption('margin-bottom', '15mm'); // Aumentar el margen para acomodar el pie de página
try {
$output = $snappy->getOutputFromHtml($htmlContent);
} catch (\Exception $e) {
dd($e->getMessage());
}
return new Response(
$output,
200,
[
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"',
]
);
}
/**
* @Route("/pdf/pdfhtinvoice/{id}", name="ht_invoice_pdf")
* Pdf de Factura de HT
*/
public function pdfHtInvoiceAction($id, Request $request, Pdf $snappy, EntityManagerInterface $em)
{
$idNum = (substr($id, 0, 1) == 'F') ? substr($id, 1) : substr($id, 2); // F1, GP1, CV1
$prefix = (substr($id, 0, 1) == 'F') ? 'F' : substr($id, 0, 2);
$parameters = array( 'idNum' => $idNum, 'prefix' => $prefix, );
$dql = 'SELECT p
FROM App\Entity\HtInvoice p
WHERE p.idNum = :idNum AND p.prefix = :prefix';
$query = $em->createQuery($dql)->setParameters($parameters);
$invoice = $query->getResult();
$invoice = (!empty($invoice)) ? $invoice[0] : null;
$htFile = $invoice->getHtFile();
$client = $em->getRepository(Client::class)->findOneById($htFile->getClient());
// Pdf de ordenes de trabajo de Higo&Trigo
$pageUrl = $this->generateUrl('ht_view_print_invoice', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl, [
'margin-top' => 10,
'margin-bottom' => 10,
'footer-line' => true,
]),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/pdfhtinvoicerec/{id}", name="ht_invoice_rec_pdf")
* Pdf de Factura Rectificativa de HT
*/
public function pdfHtInvoiceRecAction($id, Request $request, Pdf $snappy, EntityManagerInterface $em)
{
$idNum = (substr($id, 0, 2) == 'RF') ? substr($id, 2) : substr($id, 3); // RF1, RGP1, RCV1
$prefix = (substr($id, 0, 2) == 'RF') ? 'RF' : substr($id, 0, 3);
$parameters = array( 'idNum' => $idNum, 'prefix' => $prefix, );
$dql = 'SELECT p
FROM App\Entity\HtInvoice p
WHERE p.idNum = :idNum AND p.prefix = :prefix';
$query = $em->createQuery($dql)->setParameters($parameters);
$invoice = $query->getResult();
$invoice = (!empty($invoice)) ? $invoice[0] : null;
$htFile = $invoice->getHtFile();
$client = $em->getRepository(Client::class)->findOneById($htFile->getClient());
// Pdf de ordenes de trabajo de Higo&Trigo
$pageUrl = $this->generateUrl('ht_view_print_invoicerec', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl, [
'margin-top' => 10,
'margin-bottom' => 10,
'footer-line' => true,
]),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
/**
* @Route("/pdf/pdfhtproforma/{id}", name="ht_proforma_pdf")
* Pdf de Proforma de HT
*/
public function pdfHtProformaAction($id, Request $request, Pdf $snappy, EntityManagerInterface $em)
{
$proforma = $em->getRepository(HtProforma::class)->findOneById($id);
$htFile = $em->getRepository(HtFile::class)->findOneById($proforma->getHtFile());
$client = $htFile->getClient();
// Pdf de ordenes de trabajo de Higo&Trigo
$pageUrl = $this->generateUrl('ht_view_print_proforma', array('id' => $id), UrlGeneratorInterface::ABSOLUTE_URL);
return new Response(
$snappy->getOutput($pageUrl, [
'margin-top' => 10,
'margin-bottom' => 10,
'footer-line' => true,
]),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="pdf-' . $id . '.pdf"'
)
);
}
}