src/Controller/AgencyController.php line 49

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Agency;
  4. use App\Entity\CarBuy;
  5. use App\Entity\Client;
  6. use App\Repository\ClientRepository;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use App\Entity\CarSale;
  12. // Include Dompdf required namespaces
  13. use Dompdf\Dompdf;
  14. use Dompdf\Options;
  15. /**
  16.  * @Route("/agency")
  17.  */
  18. class AgencyController extends AbstractController
  19. {
  20.     /**
  21.      * @Route("/sales/", name="agency_sales")
  22.      */
  23.     public function indexSales(): Response
  24.     {
  25.         return $this->render('agency/index_sales.html.twig', [
  26.             'currentMenu' => 'agency',
  27.         ]);
  28.     }
  29.     /**
  30.      * @Route("/purchases/", name="agency_purchases")
  31.      */
  32.     public function indexPurchases(): Response
  33.     {
  34.         return $this->render('agency/index_purchases.html.twig', [
  35.             'currentMenu' => 'agency',
  36.         ]);
  37.     }
  38.     /**
  39.      * @Route("/sales/{id}/forms/", name="agency_forms_sale", methods={"GET"})
  40.      */
  41.     public function agencyFormsSale(Request $requestCarSale $carSale$id): Response
  42.     {
  43.         $isCreated false;
  44.         $procedureLocation 'VILLA CARLOS PAZ';
  45.         $procedureDate date('Y-m-d');
  46.         $procedureTime date('H:i:s');
  47.         $businessPrice    $carSale->getCurrency().number_format($carSale->getPrice(), 0'''.');
  48.         $businessPayment  '';
  49.         $businessExpenses '';
  50.         $businessDocumentation 'CERTIF. DE TRANSFERENCIA, CONTRATO DE COMPRA VENTA Y CEDULA TITULAR. -';
  51.         $moneyAdvance '';
  52.         $mandateSalePrice      '';
  53.         $mandateRetirementCost '';
  54.         $mandateOthers         '';
  55.         $mandateIsShow         '';
  56.         $sellerAlternative '';
  57.         $sellerName '';
  58.         $sellerDni  '';
  59.         $sellerAddressName      '';
  60.         $sellerAddressNumber    '';
  61.         $sellerAddressFloor     '';
  62.         $sellerAddressApartment '';
  63.         $agency $this->getDoctrine()->getRepository('App\Entity\Agency')->findOneBy([ 'saleId' => $id ]);
  64.         $enabledNotification false;
  65.         $status              'no-ready';
  66.         //dump($agency); exit();
  67.         if ($agency != null) {
  68.             $isCreated true;
  69.             $businessPrice    $agency->getBusinessPrice();
  70.             $businessPayment  $agency->getBusinessPayment();
  71.             $businessExpenses $agency->getBusinessExpenses();
  72.             $businessDocumentation $agency->getBusinessDocumentation();
  73.             $moneyAdvance $agency->getMoneyAdvance();
  74.             $mandateSalePrice      $agency->getMandateSalePrice();
  75.             $mandateRetirementCost $agency->getMandateRetirementCost();
  76.             $mandateOthers         $agency->getMandateOthers();
  77.             $mandateIsShow         $agency->getMandateIsShow();
  78.             $sellerAlternative $agency->getSellerAlternative();
  79.             $sellerName $agency->getSellerName();
  80.             $sellerDni  $agency->getSellerDni();
  81.             $sellerAddressName      $agency->getSellerAddressName();
  82.             $sellerAddressNumber    $agency->getSellerAddressNumber();
  83.             $sellerAddressFloor     $agency->getSellerAddressFloor();
  84.             $sellerAddressApartment $agency->getSellerAddressApartment();
  85.             if ($agency->getEnabledNotification()) {
  86.                 $enabledNotification true;
  87.             }
  88.             $status $agency->getStatus();
  89.             //$agency = $this->getDoctrine()->getRepository('App\Entity\Agency')->findBy([ 'saleId' => $id ]);
  90.         }
  91.         //dump($carSale->getCarPayment()); exit();
  92.         //dump(json_decode($mandateSalePrice)); exit();
  93.         
  94.         return $this->render('agency/document_sale.html.twig', [
  95.             'car_sale' => $carSale,
  96.             'procedure_location' => $procedureLocation,
  97.             'procedure_date' => $procedureDate,
  98.             'procedure_time' => $procedureTime,
  99.             'business_price' => $businessPrice,
  100.             'business_payment' => $businessPayment,
  101.             'business_expenses' => $businessExpenses,
  102.             'business_documentation' => $businessDocumentation,
  103.             'money_advance' => $moneyAdvance,
  104.             'seller_alternative' => $sellerAlternative,
  105.             'seller_name' => $sellerName,
  106.             'seller_dni' => $sellerDni,
  107.             'seller_address_name' => $sellerAddressName,
  108.             'seller_address_number' => $sellerAddressNumber,
  109.             'seller_address_floor' => $sellerAddressFloor,
  110.             'seller_address_apartment' => $sellerAddressApartment,
  111.             'isCreated' => $isCreated,
  112.             'enabledNotification' => $enabledNotification,
  113.             'status' => $status,
  114.             'mandate_sale_price' => json_decode($mandateSalePricetrue),
  115.             'mandate_retirement_cost' => json_decode($mandateRetirementCosttrue),
  116.             'mandate_others' => json_decode($mandateOtherstrue),
  117.             'mandate_is_show' => json_decode($mandateIsShowtrue),
  118.             'form_number' => $agency $agency->getId() : '-',
  119.             'currentMenu' => 'agency',
  120.         ]);
  121.     }
  122.     /**
  123.      * @Route("/purchases/{id}/forms/", name="agency_forms_purchase", methods={"GET"})
  124.      */
  125.     public function agencyFormsPurchase(Request $requestCarBuy $carBuy$id): Response
  126.     {
  127.         $isCreated false;
  128.         $procedureLocation 'VILLA CARLOS PAZ';
  129.         $procedureDate date('Y-m-d');
  130.         $procedureTime date('H:i:s');
  131.         $businessPrice    $carBuy->getCurrency().number_format($carBuy->getPrice(), 0'''.');
  132.         $businessPayment  '';
  133.         $businessExpenses '';
  134.         $businessDocumentation 'CERTIF. DE TRANSFERENCIA, CONTRATO DE COMPRA VENTA Y CEDULA TITULAR. -';
  135.         $mandateSalePrice      '';
  136.         $mandateRetirementCost '';
  137.         $mandateOthers         '';
  138.         $mandateIsShow         '';
  139.         $sellerName '';
  140.         $sellerDni  '';
  141.         $sellerAddressName      '';
  142.         $sellerAddressNumber    '';
  143.         $sellerAddressFloor     '';
  144.         $sellerAddressApartment '';
  145.         $agency $this->getDoctrine()->getRepository('App\Entity\Agency')->findOneBy([ 'saleId' => $id ]);
  146.         $enabledNotification false;
  147.         $status              'no-ready';
  148.         //dump($agency); exit();
  149.         if ($agency != null) {
  150.             $isCreated true;
  151.             $businessPrice    $agency->getBusinessPrice();
  152.             $businessPayment  $agency->getBusinessPayment();
  153.             $businessExpenses $agency->getBusinessExpenses();
  154.             $businessDocumentation $agency->getBusinessDocumentation();
  155.             /*
  156.             $mandateSalePrice      = $agency->getMandateSalePrice();
  157.             $mandateRetirementCost = $agency->getMandateRetirementCost();
  158.             $mandateOthers         = $agency->getMandateOthers();
  159.             $mandateIsShow         = $agency->getMandateIsShow();
  160.             $sellerAlternative = $agency->getSellerAlternative();
  161.             $sellerName = $agency->getSellerName();
  162.             $sellerDni  = $agency->getSellerDni();
  163.             $sellerAddressName      = $agency->getSellerAddressName();
  164.             $sellerAddressNumber    = $agency->getSellerAddressNumber();
  165.             $sellerAddressFloor     = $agency->getSellerAddressFloor();
  166.             $sellerAddressApartment = $agency->getSellerAddressApartment();
  167.             if ($agency->getEnabledNotification()) {
  168.                 $enabledNotification = true;
  169.             }
  170.             */
  171.             $status $agency->getStatus();
  172.             //$agency = $this->getDoctrine()->getRepository('App\Entity\Agency')->findBy([ 'saleId' => $id ]);
  173.         }
  174.         //dump($carBuy); exit();
  175.         //dump($carSale->getCar()); exit();
  176.         //dump(json_decode($mandateSalePrice)); exit();
  177.         $carSwap $this->getDoctrine()->getRepository('App\Entity\Car')->findOneBy([ 'id' => $carBuy->getCarSwap() ]);
  178.         return $this->render('agency/document_purchase.html.twig', [
  179.             'car_sale' => $carBuy,
  180.             'car_buy' => $carBuy,
  181.             'car_swap' => $carSwap,
  182.             'procedure_location' => $procedureLocation,
  183.             'procedure_date' => $procedureDate,
  184.             'procedure_time' => $procedureTime,
  185.             'business_price' => $businessPrice,
  186.             'business_payment' => $businessPayment,
  187.             'business_expenses' => $businessExpenses,
  188.             'business_documentation' => $businessDocumentation,
  189.             'seller_name' => $sellerName,
  190.             'seller_dni' => $sellerDni,
  191.             'seller_address_name' => $sellerAddressName,
  192.             'seller_address_number' => $sellerAddressNumber,
  193.             'seller_address_floor' => $sellerAddressFloor,
  194.             'seller_address_apartment' => $sellerAddressApartment,
  195.             'isCreated' => $isCreated,
  196.             'enabledNotification' => $enabledNotification,
  197.             'status' => $status,
  198.             'mandate_sale_price' => json_decode($mandateSalePricetrue),
  199.             'mandate_retirement_cost' => json_decode($mandateRetirementCosttrue),
  200.             'mandate_others' => json_decode($mandateOtherstrue),
  201.             'mandate_is_show' => json_decode($mandateIsShowtrue),
  202.             'currentMenu' => 'agency',
  203.         ]);
  204.     }
  205.     /**
  206.      * @Route("/sales/{id}/save/", name="agency_save", methods="POST")
  207.      */
  208.     public function agencySave(Request $request$id)
  209.     {
  210.         $data json_decode($request->getContent(), true);
  211.         $isPurchase = isset($data['is-purchase']) ? $data['is-purchase'] : false;
  212.         
  213.         $aProcedure['location'] = $data['procedure-location'];
  214.         $aProcedure['date']     = new \DateTime($data['procedure-date'].' 00:00:01');
  215.         $aProcedure['time']     = new \DateTime($data['procedure-date'].' '.$data['procedure-time']);
  216.         $aBusiness['price']         = $data['business-price'];
  217.         $aBusiness['payment']       = $data['business-payment'];
  218.         $aBusiness['expenses']      = $data['business-expenses'];
  219.         $aBusiness['documentation'] = $data['business-documentation'];
  220.         //$moneyAdvance = $data['money-advance'];
  221.         if (!$isPurchase) {
  222.             $aMandate['sale-price']      = json_encode($data['mandate-sale-price']);
  223.             $aMandate['retirement-cost'] = json_encode($data['mandate-retirement-cost']);
  224.             $aMandate['others']          = json_encode($data['mandate-others']);
  225.             $aMandate['is-show']         = json_encode($data['mandate-is-show']);
  226.             $aSeller['alternative'] = $data['seller-alternative'];
  227.             $aSeller['name'] = $data['seller-name'];
  228.             $aSeller['dni'] = $data['seller-dni'];
  229.             $aSeller['address-name'] = $data['seller-address-name'];
  230.             $aSeller['address-number'] = $data['seller-address-number'];
  231.             $aSeller['address-floor'] = $data['seller-address-floor'];
  232.             $aSeller['address-apartment'] = $data['seller-address-apartment'];
  233.             $enabledNotification $data['enabled-notification'] ?? false;
  234.             $status              $data['status'] ?? null;
  235.         }
  236.         $aCar['chassis-number'] = $data['car-chassis-number'];
  237.         $aCar['engine-number'] = $data['car-engine-number'];
  238.         $aCar['id'] = $data['car-id'];
  239.         $aCar['type'] = $data['car-type'];
  240.         $aCar['settlement'] = $data['car-settlement'];
  241.         $aBuyer['id'] = $data['buyer-id'];
  242.         $aBuyer['last-name'] = $data['buyer-last-name'];
  243.         $aBuyer['first-name'] = $data['buyer-first-name'];
  244.         $aBuyer['dni'] = $data['buyer-dni'];
  245.         $aBuyer['telephone'] = $data['buyer-telephone'];
  246.         $aBuyer['address'] = $data['buyer-address'];
  247.         $aBuyer['address-number'] = $data['buyer-address-number'];
  248.         $aBuyer['address-floor'] = $data['buyer-address-floor'];
  249.         $aBuyer['address-apartment'] = $data['buyer-address-apartment'];
  250.         $aBuyer['location'] = $data['buyer-location'];
  251.         $aBuyer['state'] = $data['buyer-state'];
  252.         /*dump($aProcedure);
  253.         dump($aBusiness);
  254.         dump($id);*/
  255.         /*---- Agency [BEGIN] ----*/
  256.         $agency $this->getDoctrine()->getRepository('App\Entity\Agency')->findOneBy([ 'saleId' => $id ]);
  257.         if ($agency == null) {
  258.             $agency = new Agency();
  259.             $agency->setSaleId($id);
  260.             $agency->setCreatedAt(new \DateTime);
  261.         } else {
  262.         }
  263.         $agency->setProcedureLocation($aProcedure['location']);
  264.         $agency->setProcedureDate($aProcedure['date']);
  265.         $agency->setProcedureTime($aProcedure['time']);
  266.         $agency->setBusinessPrice($aBusiness['price']);
  267.         $agency->setBusinessPayment($aBusiness['payment']);
  268.         $agency->setBusinessExpenses($aBusiness['expenses']);
  269.         $agency->setBusinessDocumentation($aBusiness['documentation']);
  270.         //$agency->setMoneyAdvance($moneyAdvance);
  271.         if (!$isPurchase) {
  272.             $agency->setMandateSalePrice($aMandate['sale-price']);
  273.             $agency->setMandateRetirementCost($aMandate['retirement-cost']);
  274.             $agency->setMandateOthers($aMandate['others']);
  275.             $agency->setMandateIsShow($aMandate['is-show']);
  276.             $agency->setSellerAlternative($aSeller['alternative']);
  277.             $agency->setSellerName($aSeller['name']);
  278.             $agency->setSellerDNI($aSeller['dni']);
  279.             $agency->setSellerAddressName($aSeller['address-name']);
  280.             $agency->setSellerAddressNumber($aSeller['address-number']);
  281.             $agency->setSellerAddressFloor($aSeller['address-floor']);
  282.             $agency->setSellerAddressApartment($aSeller['address-apartment']);
  283.             $agency->setEnabledNotification($enabledNotification);
  284.             $agency->setStatus($status);
  285.         } else {
  286.             $agency->setSellerName('');
  287.             $agency->setSellerDNI('');
  288.             $agency->setSellerAddressName('');
  289.             $agency->setSellerAddressNumber('');
  290.             $agency->setSellerAddressFloor('');
  291.             $agency->setSellerAddressApartment('');
  292.         }
  293.         $agency->setUpdatedAt(new \DateTime);
  294.         $this->getDoctrine()->getManager()->persist($agency);
  295.         $this->getDoctrine()->getManager()->flush();
  296.         /*---- Agency [END] ----*/
  297.         /*---- Car [START] ----*/
  298.         $car $this->getDoctrine()->getRepository('App\Entity\Car')->find($aCar['id']);
  299.         $car->setType($aCar['type']);
  300.         $car->setSettlement($aCar['settlement']);
  301.         $car->setChassisNumber($aCar['chassis-number']);
  302.         $car->setEngineNumber($aCar['engine-number']);
  303.         $this->getDoctrine()->getManager()->persist($car);
  304.         $this->getDoctrine()->getManager()->flush();
  305.         /*---- Car [END] ----*/
  306.         /*---- Buyer [BEGIN] ----*/
  307.         //dump($aBuyer); exit();
  308.         $buyer $this->getDoctrine()->getRepository('App\Entity\Client')->find($aBuyer['id']);
  309.         $buyer->setLastName($aBuyer['last-name']);
  310.         $buyer->setFirstName($aBuyer['first-name']);
  311.         $buyer->setDni($aBuyer['dni']);
  312.         $buyer->setCellphone($aBuyer['telephone']);
  313.         $buyer->setAddress($aBuyer['address']);
  314.         $buyer->setAddressNumber($aBuyer['address-number']);
  315.         $buyer->setAddressFloor($aBuyer['address-floor']);
  316.         $buyer->setAddressApartment($aBuyer['address-apartment']);
  317.         $buyer->setLocation($aBuyer['location']);
  318.         $buyer->setState($aBuyer['state']);
  319.         $this->getDoctrine()->getManager()->persist($buyer);
  320.         $this->getDoctrine()->getManager()->flush();
  321.         /*---- Buyer [END] ----*/
  322.         //dump($agency);
  323.         //dump($car);
  324.         //exit();
  325.         return $this->json('ok');
  326.     }
  327.     /**
  328.      * @Route("/sales/{id}/pdf/", name="agency_pdf", methods="GET")
  329.      */
  330.     public function agencyPdf(Request $requestCarSale $carSale$id)
  331.     {
  332.         $procedureLocation 'VILLA CARLOS PAZ';
  333.         $procedureDate date('Y-m-d');
  334.         $procedureTime date('H:i:s');
  335.         $businessPrice    $carSale->getCurrency().number_format($carSale->getPrice(), 0'''.');
  336.         $businessPayment  '';
  337.         $businessExpenses '';
  338.         $businessDocumentation 'CERTIF. DE TRANSFERENCIA, CONTRATO DE COMPRA VENTA Y CEDULA TITULAR. -';
  339.         $mandateSalePrice      '';
  340.         $mandateRetirementCost '';
  341.         $mandateOthers         '';
  342.         $mandateIsShow         '';
  343.         $sellerName '';
  344.         $sellerDni  '';
  345.         $sellerAddressName      '';
  346.         $sellerAddressNumber    '';
  347.         $sellerAddressFloor     '';
  348.         $sellerAddressApartment '';
  349.         $agency $this->getDoctrine()->getRepository('App\Entity\Agency')->findOneBy([ 'saleId' => $id ]);
  350.         //dump($agency); exit();
  351.         if ($agency != null) {
  352.             $isCreated true;
  353.             $businessPrice    $agency->getBusinessPrice();
  354.             $businessPayment  $agency->getBusinessPayment();
  355.             $businessExpenses $agency->getBusinessExpenses();
  356.             $businessDocumentation $agency->getBusinessDocumentation();
  357.             $mandateSalePrice      $agency->getMandateSalePrice();
  358.             $mandateRetirementCost $agency->getMandateRetirementCost();
  359.             $mandateOthers         $agency->getMandateOthers();
  360.             $mandateIsShow         $agency->getMandateIsShow();
  361.             $sellerAlternative $agency->getSellerAlternative();
  362.             $sellerName $agency->getSellerName();
  363.             $sellerDni  $agency->getSellerDni();
  364.             $sellerAddressName      $agency->getSellerAddressName();
  365.             $sellerAddressNumber    $agency->getSellerAddressNumber();
  366.             $sellerAddressFloor     $agency->getSellerAddressFloor();
  367.             $sellerAddressApartment $agency->getSellerAddressApartment();
  368.             $agency $this->getDoctrine()->getRepository('App\Entity\Agency')->findBy([ 'saleId' => $id ]);
  369.         }
  370.         // Configure Dompdf according to your needs
  371.         $pdfOptions = new Options();
  372.         //$pdfOptions->set('defaultFont', 'Arial');
  373.         $pdfOptions->setIsHtml5ParserEnabled(true);
  374.         $pdfOptions->setIsRemoteEnabled(true);
  375.         // Instantiate Dompdf with our options
  376.         $dompdf = new Dompdf($pdfOptions);
  377.         //exit( $this->getParameter('kernel.project_dir') );
  378.         $dompdf->getOptions()->setChroot$this->getParameter('kernel.project_dir').'\public' );
  379.         // Retrieve the HTML generated in our twig file
  380.         $html $this->renderView('pdf/agency_sales.html.twig', [
  381.             'car_sale' => $carSale,
  382.             'procedure_location' => $procedureLocation,
  383.             'procedure_date' => $procedureDate,
  384.             'procedure_time' => $procedureTime,
  385.             'business_price' => $businessPrice,
  386.             'business_payment' => $businessPayment,
  387.             'business_expenses' => $businessExpenses,
  388.             'business_documentation' => $businessDocumentation,
  389.             'seller_alternative' => $sellerAlternative,
  390.             'seller_name' => $sellerName,
  391.             'seller_dni' => $sellerDni,
  392.             'seller_address_name' => $sellerAddressName,
  393.             'seller_address_number' => $sellerAddressNumber,
  394.             'seller_address_floor' => $sellerAddressFloor,
  395.             'seller_address_apartment' => $sellerAddressApartment,
  396.             /*'mandate_sale_price' => $mandateSalePrice,
  397.             'mandate_retirement_cost' => $mandateRetirementCost,
  398.             'mandate_others' => $mandateOthers,*/
  399.             'mandate_sale_price' => json_decode($mandateSalePricetrue),
  400.             'mandate_retirement_cost' => json_decode($mandateRetirementCosttrue),
  401.             'mandate_others' => json_decode($mandateOtherstrue),
  402.             'mandate_is_show' => json_decode($mandateIsShowtrue),
  403.             'server_root' => $_SERVER["DOCUMENT_ROOT"],
  404.         ]);
  405.         //dump($html); exit();
  406.         // Load HTML to Dompdf
  407.         $dompdf->loadHtml($html);
  408.         // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  409.         $dompdf->setPaper('A4''portrait');
  410.         // Render the HTML as PDF
  411.         $dompdf->render();
  412.         ob_get_clean();
  413.         // Output the generated PDF to Browser (inline view)
  414.         $dompdf->stream("/mypdf.pdf", [
  415.             "Attachment" => false,
  416.         ]);
  417.         //exit(0);
  418.     }
  419.     /**
  420.      * @Route("/purchase/{id}/pdf/", name="agency_pdf_purchase", methods="GET")
  421.      */
  422.     public function agencyPdfPurchase(Request $requestCarBuy $carBuy$id)
  423.     {
  424.         $procedureLocation 'VILLA CARLOS PAZ';
  425.         $procedureDate date('Y-m-d');
  426.         $procedureTime date('H:i:s');
  427.         $businessPrice    $carBuy->getCurrency().number_format($carBuy->getPrice(), 0'''.');
  428.         $businessPayment  '';
  429.         $businessExpenses '';
  430.         $businessDocumentation 'CERTIF. DE TRANSFERENCIA, CONTRATO DE COMPRA VENTA Y CEDULA TITULAR. -';
  431.         $mandateSalePrice      '';
  432.         $mandateRetirementCost '';
  433.         $mandateOthers         '';
  434.         $mandateIsShow         '';
  435.         $sellerName '';
  436.         $sellerDni  '';
  437.         $sellerAddressName      '';
  438.         $sellerAddressNumber    '';
  439.         $sellerAddressFloor     '';
  440.         $sellerAddressApartment '';
  441.         $agency $this->getDoctrine()->getRepository('App\Entity\Agency')->findOneBy([ 'saleId' => $id ]);
  442.         $enabledNotification false;
  443.         $status              'no-ready';
  444.         if ($agency != null) {
  445.             $isCreated true;
  446.             $businessPrice    $agency->getBusinessPrice();
  447.             $businessPayment  $agency->getBusinessPayment();
  448.             $businessExpenses $agency->getBusinessExpenses();
  449.             $businessDocumentation $agency->getBusinessDocumentation();
  450.             $status $agency->getStatus();
  451.         }
  452.         $carSwap $this->getDoctrine()->getRepository('App\Entity\Car')->findOneBy([ 'id' => $carBuy->getCarSwap() ]);
  453.         // Configure Dompdf according to your needs
  454.         $pdfOptions = new Options();
  455.         //$pdfOptions->set('defaultFont', 'Arial');
  456.         $pdfOptions->setIsHtml5ParserEnabled(true);
  457.         $pdfOptions->setIsRemoteEnabled(true);
  458.         // Instantiate Dompdf with our options
  459.         $dompdf = new Dompdf($pdfOptions);
  460.         //exit( $this->getParameter('kernel.project_dir') );
  461.         $dompdf->getOptions()->setChroot$this->getParameter('kernel.project_dir').'\public' );
  462.         // Retrieve the HTML generated in our twig file
  463.         $html $this->renderView('pdf/agency_purchases.html.twig', [
  464.             'car_sale' => $carBuy,
  465.             'car_swap' => $carSwap,
  466.             'procedure_location' => $procedureLocation,
  467.             'procedure_date' => $procedureDate,
  468.             'procedure_time' => $procedureTime,
  469.             'business_price' => $businessPrice,
  470.             'business_payment' => $businessPayment,
  471.             'business_expenses' => $businessExpenses,
  472.             'business_documentation' => $businessDocumentation,
  473.             'seller_name' => $sellerName,
  474.             'seller_dni' => $sellerDni,
  475.             'seller_address_name' => $sellerAddressName,
  476.             'seller_address_number' => $sellerAddressNumber,
  477.             'seller_address_floor' => $sellerAddressFloor,
  478.             'seller_address_apartment' => $sellerAddressApartment,
  479.             'isCreated' => $isCreated,
  480.             'enabledNotification' => $enabledNotification,
  481.             'status' => $status,
  482.             'mandate_sale_price' => json_decode($mandateSalePricetrue),
  483.             'mandate_retirement_cost' => json_decode($mandateRetirementCosttrue),
  484.             'mandate_others' => json_decode($mandateOtherstrue),
  485.             'mandate_is_show' => json_decode($mandateIsShowtrue),
  486.             'server_root' => $_SERVER["DOCUMENT_ROOT"],
  487.         ]);
  488.         //dump($html); exit();
  489.         // Load HTML to Dompdf
  490.         $dompdf->loadHtml($html);
  491.         // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  492.         $dompdf->setPaper('A4''portrait');
  493.         // Render the HTML as PDF
  494.         $dompdf->render();
  495.         ob_get_clean();
  496.         // Output the generated PDF to Browser (inline view)
  497.         $dompdf->stream("/Compra - Boleto.pdf", [
  498.             "Attachment" => false,
  499.         ]);
  500.         //exit(0);
  501.     }
  502.     /**
  503.      * @Route("/settings/", name="agency_settings", methods={"GET"})
  504.      */
  505.     public function agencySettings(): Response
  506.     {
  507.         $notificationDays $this->getDoctrine()->getRepository(\App\Entity\Settings::class)->findOneBy(['name' => 'agency_notification_days'])->getValue();
  508.         return $this->render('agency/settings.html.twig', [
  509.             'notificationDays' => $notificationDays,
  510.             'currentMenu' => 'agency',
  511.         ]);
  512.     }
  513.     /**
  514.      * @Route("/save/notificationDdays", name="agency_save_notification_days", methods={"POST"})
  515.      */
  516.     public function saveNotificationDays(Request $request): Response
  517.     {
  518.         $setting $this->getDoctrine()->getManager()->getRepository(\App\Entity\Settings::class)->findOneBy(['name' => 'agency_notification_days']);
  519.         $setting->setValue$request->get('d') );
  520.         $this->getDoctrine()->getManager()->persist($setting);
  521.         $this->getDoctrine()->getManager()->flush();
  522.         return $this->json('1');
  523.     }
  524. }