Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
www.humitest.fr
/
htdocs
/
src
/
Controller
/
back
/
/srv/data/web/vhosts/www.humitest.fr/htdocs/src/Controller/back/CommandController.php
<?php namespace App\Controller\back; use App\Entity\Command; use App\Services\Mailer; use App\Form\CommandType; use App\Services\GeneratePdfService; use App\Repository\CommandRepository; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\HeaderUtils; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; /** * @Route("/admin/command") */ class CommandController extends AbstractController { /** * @Route("/", name="admin_command_search", methods="GET") */ public function search(CommandRepository $commandRepository): Response { return $this->render('back/command/search.html.twig', [ 'commands' => $commandRepository->findBy(array(), array('createdAt' => 'DESC')), 'slug' => 'admin_command', 'totalNouveauProduit' => $commandRepository->totalNewProduct(), ]); } /** * @Route("/{id}", name="admin_command_read", methods="GET") */ public function read(Command $command, CommandRepository $commandRepository): Response { return $this->render('back/command/read.html.twig', [ 'command' => $command, 'slug' => 'admin_command', 'totalNouveauProduit' => $commandRepository->totalNewProduct(), ]); } /** * @Route("/update/{id}", name="admin_command_update", methods="GET|POST") */ public function update(Request $request, Command $command, CommandRepository $commandRepository, Mailer $mailer): Response { $form = $this->createForm(CommandType::class, $command); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $conf_company_name = $this->getParameter('conf_company_name'); $conf_company_email = $this->getParameter('conf_company_email'); $conf_company_email2 = $this->getParameter('conf_company_email2'); $conf_server_email = $this->getParameter('conf_server_email'); $emailCommandeClient = $command->getEmail(); $numCommandeClient = $command->getOrderKey(); $nameCommandeClient = $command->getFirstName() . ' ' . $command->getLastName(); $this->getDoctrine()->getManager()->flush(); $statutCommandeClient = $command->getStape(); if ($statutCommandeClient == "Commande Expédiée") { // on utilise le service Mailer créé $em->flush();récédemment $bodyMailConfirmation = $mailer->createBodyMail('front/pages/mail/commande_expedie_confirmation.html.twig', [ 'client_name' => $nameCommandeClient, 'client_email' => $emailCommandeClient, 'client_name' => $nameCommandeClient, 'client_num_commande' => $numCommandeClient, 'conf_company_name' => $conf_company_name, ]); $mailer->sendMessage($conf_company_name, $conf_server_email, $command->getEmail(), 'Commande ' . $numCommandeClient . ' expédiée - Maindron Structures', $bodyMailConfirmation); } $this->addFlash('success', 'Statut de commande modifié avec succèes'); return $this->redirectToRoute('admin_command_search'); } return $this->render('back/command/update.html.twig', [ 'command' => $command, 'form' => $form->createView(), 'slug' => 'admin_command', 'totalNouveauProduit' => $commandRepository->totalNewProduct(), ]); } /** * @Route("/delete/{id}", name="admin_command_delete", methods="DELETE") */ public function delete(Request $request, Command $command): Response { $msg = 'Enregistrement supprimé avec succès'; $em = $this->getDoctrine()->getManager(); $em->remove($command); $em->flush(); $this->addFlash('success', $msg); return $this->redirectToRoute('admin_command_search'); } /** * @Route("/document/download/{document}", name="download_document") */ public function downloadDocument($document): BinaryFileResponse { /* // Code pour généré un PDF de test $generatePdfService = new GeneratePdfService; $data = [ "conf_company_business" => "conf_company_business", "conf_company_address" => "conf_company_address", "conf_company_zipcode" => "conf_company_zipcode", "conf_company_city" => "conf_company_city", "conf_company_country" => "conf_company_country", "conf_company_siret" => "conf_company_siret", "conf_company_email" => "conf_company_email", "conf_company_phone" => "conf_company_phone", "firstname" => "firstname", "lastname" => "lastname", "address" => "address", "zipcode" => "zipcode", "city" => "city", "phone" => "phone", "productKey" => "productKey", "products" => [], "totalHt" => 0, "delivery" => 0, "totalWithoutSolde" => 0, "rateVat" => 0, "totalTtc" => 0, "company" => $this->getUser()->getCompany() ]; $template = $this->renderView('front/product/billing/billing.html.twig', [ 'data' => $data, ]); $generatePdfService->Pdf($this->getParameter('kernel.project_dir') . '/public/' . "upload/billing/BDC-X.pdf", $template); */ $document = "../public/upload/billing/$document"; return new BinaryFileResponse($document); } }