src/Controller/HomeController.php line 57

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Log;
  4. use App\Entity\ProcessStep;
  5. use App\Entity\StepStatus;
  6. use App\Repository\StepStatusRepository;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use Knp\Snappy\Pdf;
  9. use Psr\Log\LoggerInterface;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Mercure\PublisherInterface;
  12. use Symfony\Component\Mercure\Update;
  13. use Symfony\Component\Messenger\MessageBusInterface;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
  17. class HomeController extends ConsoleController
  18. {
  19.     /**
  20.      * @var Pdf
  21.      */
  22.     private $kpnsnappy;
  23.     /**
  24.      * @var LoggerInterface
  25.      */
  26.     private $logger;
  27.     public function __construct(
  28.         Pdf $kpnsnappy,
  29.         EntityManagerInterface $em,
  30.         LoggerInterface $logger,
  31.         MessageBusInterface $bus
  32.     )
  33.     {
  34.         parent::__construct($em,$bus);
  35.         $this->kpnsnappy $kpnsnappy;
  36.         $this->logger $logger;
  37.     }
  38.     /**
  39.      * @return Response
  40.      * @Route("/", name="public.index")
  41.      */
  42.     public function PagePublicIndex(): Response
  43.     {
  44.         return ($this->redirectToRoute('private.index'));
  45.     }
  46.     /**
  47.      * @param Request $request
  48.      * @return Response
  49.      * @Route("/review/render.html", name="public.review.render")
  50.      */
  51.     public function PagePublicReviewRender(Request $request): Response
  52.     {
  53.         //dump($request->query->get('coucou'));
  54.         if(($request->query->get('style') == null) || !is_numeric($request->query->get('style')))
  55.             $style "default.css";
  56.         else
  57.             $style $request->query->get('style') . ".css";
  58.         return $this->render('pages/public/review/render2.html.twig',[
  59.             'this' => $this,
  60.             'rav' => $this->reviewRepository->findXXlastBySite(5,4,"AVIS-VERIFIES"),
  61.             'rmn' => $this->reviewRepository->findXXlastBySite(5,4,"MARIAGE.NET"),
  62.             'rf' => $this->reviewRepository->findXXlastBySite(5,4,"FACEBOOK"),
  63.             'rg' => $this->reviewRepository->findXXlastBySite(5,4,"GOOGLE"),
  64.         ]);
  65.     }
  66.     /**
  67.      * @return Response
  68.      * @Route("/private/", name="private.index")
  69.      */
  70.     public function PagePrivateIndex(): Response
  71.     {
  72.         $Postes = new PostesController($this->em,$this->bus);
  73.         $moisStart = new \DateTime();
  74.         $moisEnd = new \DateTime();
  75.         $lastmonthStart = new \DateTime('first day of last month');
  76.         $lastmonthEnd = new \DateTime('last day of last month');
  77.         $Stats["CA_WEB_TODAY"] = $this->orderRepository->findStatCA($this->showroomRepository->find(1))["total"];
  78.     $Stats["CA_WEB_MONTH"] = $this->orderRepository->findStatCA($this->showroomRepository->find(1),$moisStart->format('Y-m-01'),$moisEnd->format('Y-m-t'))["total"];
  79.         $Stats["CA_WEB_MONTH_1"] = $this->orderRepository->findStatCA($this->showroomRepository->find(1),$lastmonthStart->format('Y-m-01'),$lastmonthEnd->format('Y-m-t'))["total"];
  80. //    print date('m');
  81.         for ($i 1$i <= 30+date('m')-1$i++) {
  82.             $months[] = date("Y-m"strtotimedate'Y-m-01' )." -$i months"));
  83.         }
  84.         $Stats["ByMonth"][$i]["CA"] =  /*random_int(15000,25000);*/$Stats["CA_WEB_MONTH"];
  85.         $Stats["ByMonth"][$i]["Date"] =  date("Y-m"strtotimedate'Y-m-01' )));
  86.         $i 1;
  87.         foreach($months as $month){
  88.             $start = new \DateTime($month."-01");
  89.             $Stats["ByMonth"][$i]["CA"] = $this->orderRepository->findStatCA($this->showroomRepository->find(1),$start->format('Y-m-01'),$start->format('Y-m-t'))["total"];
  90.             //$Stats["ByMonth"][$i]["CA"] = random_int(15000,25000);
  91.             $Stats["ByMonth"][$i]["Date"] = $month;
  92.             $i++;
  93.         }
  94. dump($Stats["ByMonth"]);
  95.         return $this->render('pages/private/index.html.twig',[
  96.             'this' => $this,
  97.             'Stats' => $Stats,
  98.             'postes' => $Postes->getAllPostesArray()
  99.         ]);
  100.     }
  101.     /**
  102.      * @return Response
  103.      * @Route("/private/test/index.html", name="private.test.index")
  104.      */
  105.     public function PagePrivateTestIndex(PublisherInterface $publisher): Response
  106.     {
  107.         return new Response('published!');
  108.     }
  109.     /**
  110.      * @Route("/private/invoice.pdf", name="private.test.invoice")
  111.      */
  112.     public function PageTestInvoice(): Response
  113.     {
  114.         $invoice = new InvoicePrinterController("A4","€","fr");
  115.         /* Header Settings */
  116.         $invoice->setLogo('images/logoFacture.png',300,150);
  117.         $invoice->setColor('#AA3939');
  118.         $invoice->setType('FACTURE');
  119.         $invoice->setReference('INV-55033645');
  120.         $invoice->setDate(date('d/m/Y'time()));
  121.         $invoice->setDue(date('d/m/Y'strtotime('+3 months')));
  122.         $invoice->setFrom(['Seller Name''Sample Company Name''128 AA Juanita Ave''Glendora , CA 91740''United States of America']);
  123.         $invoice->setTo(['Purchaser Name''Sample Company Name''128 AA Juanita Ave''Glendora , CA 91740''United States of America']);
  124.         /* Adding Items in table */
  125.         $invoice->addItem('AMD Athlon X2DC-7450''2.4GHz/1GB/160GB/SMP-DVD/VB'6058003480);
  126.         $invoice->addItem('PDC-E5300''2.6GHz/1GB/320GB/SMP-DVD/FDD/VB'4064502580);
  127.         $invoice->addItem('LG 18.5" WLCD''2.4GHz/1GB/160GB/SMP-DVD/VB'10023002300);
  128.         $invoice->addItem('HP LaserJet 5200''2.4GHz/1GB/160GB/SMP-DVD/VB'10110001100);
  129.         /* Add totals */
  130.         $invoice->addTotal('Total'9460);
  131.         $invoice->addTotal('TVA 20%'1986.6);
  132.         $invoice->addTotal('Total due'11446.6true);
  133.         /* Set badge */
  134.         $invoice->addBadge('Invoice Copy');
  135.         $invoice->addBadge('Invoice Copy 2');
  136.         /* Add title */
  137.         $invoice->addTitle('Important Notice');
  138.         /* Add Paragraph */
  139.         $invoice->addParagraph("No item will be replaced or refunded if you don't have the invoice with you. You can refund within 2 days of purchase.");
  140.         $invoice->addTitle('Important Notice');
  141.         /* Add Paragraph */
  142.         $invoice->addParagraph("No item will be replaced or refunded if you don't have the invoice with you. You can refund within 2 days of purchase.");
  143.         /* Set footer note */
  144.         $invoice->setFooternote('My Company Name Here');
  145.         /* Render */
  146.         $invoice->render('example2.pdf''I'); /* I => Display on browser, D => Force Download, F => local path save, S => return document path */
  147.         exit();
  148.         //return new BinaryFileResponse($invoice->render('example2.pdf', 'S'));
  149.     }
  150. }