src/Controller/Front/ProductOptionController.php line 71

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: Slim Sayari
  5.  * Date: 10/07/2019
  6.  * Time: 13:43
  7.  */
  8. namespace App\Controller\Front;
  9. use App\Entity\BesoinProductPage;
  10. use App\Entity\BesoinProductPageCategory;
  11. use App\Entity\CartDetail;
  12. use App\Entity\CartDetailPhotos;
  13. use App\Entity\ConfigProductDescription;
  14. use App\Entity\DocUpload;
  15. use App\Entity\NosCrea;
  16. use App\Entity\OrderDetail;
  17. use App\Entity\Orders;
  18. use App\Entity\Product;
  19. use App\Entity\ProductAttribute;
  20. use App\Services\CartService;
  21. use App\Services\CheckoutService;
  22. use App\Services\NbDesigner;
  23. use App\Services\OrderService;
  24. use Doctrine\ORM\EntityManager;
  25. use Doctrine\ORM\EntityManagerInterface;
  26. use JMS\Serializer\Tests\Fixtures\Order;
  27. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  28. use Symfony\Component\HttpFoundation\JsonResponse;
  29. use Symfony\Component\HttpFoundation\RedirectResponse;
  30. use Symfony\Component\Routing\Annotation\Route;
  31. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  32. use Twig\Environment;
  33. use Symfony\Component\HttpFoundation\Response;
  34. use Symfony\Component\HttpFoundation\Request;
  35. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  36. use App\Services\Users;
  37. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  38. /**
  39.  * @Route("/product-option")
  40.  */
  41. class ProductOptionController extends AbstractController
  42. {
  43.     private $twig;
  44.     private $router;
  45.     private $users_service;
  46.     private $nbDesigner;
  47.     private $params;
  48.     private $cart_service;
  49.     private $checkout_service;
  50.     public function __constructOrderService $orderService ,EntityManagerInterface $entityManager ,CheckoutService $checkout_serviceEnvironment $twigUrlGeneratorInterface $routerParameterBagInterface $paramsUsers $users_serviceNbDesigner $nbDesigner,CartService $cart_service)
  51.     {
  52.         $this->twig $twig;
  53.         $this->router $router;
  54.         $this->users_service $users_service;
  55.         $this->nbDesigner $nbDesigner;
  56.         $this->params $params;
  57.         $this->cart_service $cart_service;
  58.         $this->checkout_service $checkout_service;
  59.         $this->em $entityManager;
  60.         $this->orderService $orderService;
  61.     }
  62.     /**
  63.      * @Route("/{token}", name="product_option",options={"expose"=true})
  64.      */
  65.     public function index(Request $request,$token null) : Response
  66.     {
  67.         $result $this->cart_service->checkB2bUser($this->getUser());
  68.         $abonnement $result['abonnement'];
  69.         $isAbonnementProInCart $result['isAbonnementProInCart'];
  70.         $cartDetail $this->nbDesigner->getCartDetail($request,$token);
  71.         $product $this->nbDesigner->getProductByRequest($request);
  72.         if($abonnement['is_abonnemen_pro'] || $isAbonnementProInCart){
  73.             if($product && !$product->getIsColorLab() && !in_array($product->getTypeProduct(),[Product::PAPIER,Product::PAPIER_POSTE]) ){
  74.                 $response $this->twig->render('front/b2b/creer-communiquer/new-product-option2.html.twig', ['product'=>$product,'cartDetail' => $cartDetail'cart' => $this->cart_service->createCart(true)]);
  75.             }else {
  76.                 if (($cartDetail && $cartDetail->getProduct()->getIsColorLab() && !$cartDetail->getProduct()->getIsNewDisplayColorLab()) || ($product && $product->getIsColorLab() && !$product->getIsNewDisplayColorLab())) {
  77. //                    $response = $this->twig->render('front/b2b/creer-communiquer/product-option.html.twig', ['cartDetail' => $cartDetail, 'cart' => $this->cart_service->createCart(true)]);
  78.                     $response $this->twig->render('front/b2b/creer-communiquer/new-product-option2.html.twig', ['product'=>$product,'cartDetail' => $cartDetail'cart' => $this->cart_service->createCart(true)]);
  79.                 } else {
  80. //                    $response = $this->twig->render('front/b2b/creer-communiquer/new-product-option.html.twig', ['cartDetail' => $cartDetail, 'cart' => $this->cart_service->createCart(true)]);
  81.                     $response $this->twig->render('front/b2b/creer-communiquer/new-product-option2.html.twig', ['product'=>$product,'cartDetail' => $cartDetail'cart' => $this->cart_service->createCart(true)]);
  82.                 }
  83.             }
  84.         }else{
  85.             if($product && !$product->getIsColorLab() && !in_array($product->getTypeProduct(),[Product::PAPIER,Product::PAPIER_POSTE]) ){
  86.                 $response $this->twig->render('front/product-option/new_index2.html.twig', ['product'=>$product,'cartDetail' => $cartDetail'cart' => $this->cart_service->createCart(true)]);
  87.             }else{
  88.                 if(($cartDetail && $cartDetail->getProduct()->getIsColorLab()  && !$cartDetail->getProduct()->getIsNewDisplayColorLab()) || ($product && $product->getIsColorLab() && !$product->getIsNewDisplayColorLab())) {
  89.                     $response $this->twig->render('front/product-option/new_index2.html.twig', ['product'=>$product,'cartDetail' => $cartDetail'cart' => $this->cart_service->createCart(true)]);
  90.                 }else{
  91.                     $response $this->twig->render('front/product-option/new_index2.html.twig', ['product'=>$product,'cartDetail' => $cartDetail'cart' => $this->cart_service->createCart(true)]);
  92. //                    $response = $this->twig->render('front/product-option/new_index.html.twig', ['product'=>$product,'cartDetail' => $cartDetail, 'cart' => $this->cart_service->createCart(true)]);
  93.                 }
  94.             }
  95.         }
  96.         $response = new Response($response);
  97.         return $response;
  98.     }
  99.     /**
  100.      * @Route("/get-option-by-token/{token}", name="get_option_by_token",options={"expose"=true})
  101.      */
  102.     public function optionByToken(Request $request,$token) : Response
  103.     {
  104.         $data $this->nbDesigner->getOptionByToken($request,$token);
  105.         $responseInfoTaille $this->twig->render('front/product-option/info-taille.html.twig',$data);
  106.         $responseOption $this->twig->render('front/product-option/options-global.html.twig',$data);
  107.         $responseQty $this->twig->render('front/product-option/qty-block.html.twig',$data);
  108.         $responsePrice $this->twig->render('front/product-option/getPrice.html.twig',isset($data['price'])?$data['price']:null);
  109.         $data['isFormatType'] = true;
  110.         $responseOptionFormatType $this->twig->render('front/product-option/options-global-new.html.twig',$data);
  111.         $data['isFormatType'] = false;
  112.         $responseOptionAutre $this->twig->render('front/product-option/options-global-new.html.twig',$data);
  113.         $responseOptionMobile $this->twig->render('front/product-option/options-global-new-mobile.html.twig',$data);
  114.         $responseQtyNew $this->twig->render('front/product-option/qty-block-new.html.twig',$data);
  115.         $responseNosLovesPrinterNew $this->twig->render('front/product-option/nosLovesPrinter.html.twig',$data);
  116.         $response = new Response(json_encode(array('responseNosLovesPrinterNew'=>$responseNosLovesPrinterNew,'responseQtyNew'=>$responseQtyNew,'responseOptionFormatType'=>$responseOptionFormatType,'responseOptionAutre'=>$responseOptionAutre,'responseOptionMobile'=>$responseOptionMobile,'responseInfoTaille'=>$responseInfoTaille,'responseoption'=>$responseOption,'responseQty'=>$responseQty,'responsePrice'=>$responsePrice)));
  117.         return $response;
  118.     }
  119.     /**
  120.      * @Route("/get-option-by-product/{idProduct}", name="get_option_by_product",options={"expose"=true})
  121.      */
  122.     public function optionByProduct(Request $request,$idProduct) : Response
  123.     {
  124.         $data $this->nbDesigner->getOptionByProduct($request,$idProduct);
  125.         $responseInfoTaille $this->twig->render('front/product-option/info-taille.html.twig',$data);
  126.         $responseOption $this->twig->render('front/product-option/options-global.html.twig',$data);
  127.         $data['isFormatType'] = true;
  128.         $responseOptionFormatType $this->twig->render('front/product-option/options-global-new.html.twig',$data);
  129.         $data['isFormatType'] = false;
  130.         $responseOptionAutre $this->twig->render('front/product-option/options-global-new.html.twig',$data);
  131.         $responseQty $this->twig->render('front/product-option/qty-block.html.twig',$data);
  132.         $responseQtyNew $this->twig->render('front/product-option/qty-block-new.html.twig',$data);
  133.         $responsePrice $this->twig->render('front/product-option/getPrice.html.twig',isset($data['price'])?$data['price']:null);
  134.         $responseOptionMobile $this->twig->render('front/product-option/options-global-new-mobile.html.twig',$data);
  135.         $responseNosLovesPrinterNew $this->twig->render('front/product-option/nosLovesPrinter.html.twig',$data);
  136.         $response = new Response(json_encode(array('responseNosLovesPrinterNew'=>$responseNosLovesPrinterNew,'responseQtyNew'=>$responseQtyNew,'responseOptionFormatType'=>$responseOptionFormatType,'responseOptionAutre'=>$responseOptionAutre,'responseOptionMobile'=>$responseOptionMobile,'responseInfoTaille'=>$responseInfoTaille,'responseoption'=>$responseOption,'responseQty'=>$responseQty,'responsePrice'=>$responsePrice)));
  137.         return $response;
  138.     }
  139.     /**
  140.      * @Route("/get-next-option/product/{idProduct}/type-attribute/{typeAttribute}/value/{valueAttribute}", name="get_nex_option_product_colorLab",options={"expose"=true})
  141.      */
  142.     public function getNextOption(Request $request,$idProduct,$typeAttribute,$valueAttribute) : Response
  143.     {
  144.         $data $this->nbDesigner->getNextOptionByProduct($request,$idProduct,$typeAttribute,$valueAttribute);
  145.         $data['isFormatType'] = true;
  146.         $responseOption $this->twig->render('front/product-option/options-next-new.html.twig',$data);
  147.         $data['isFormatType'] = false;
  148.         $responseOptionAutre $this->twig->render('front/product-option/options-next-new.html.twig',$data);
  149.         $responseQty $this->twig->render('front/product-option/qty-block.html.twig',$data);
  150.         $responsePrice $this->twig->render('front/product-option/getPrice.html.twig',isset($data['price'])?$data['price']:null);
  151.         $responseQtyNew $this->twig->render('front/product-option/qty-block-new.html.twig',$data);
  152.         $responseNosLovesPrinterNew $this->twig->render('front/product-option/nosLovesPrinter.html.twig',$data);
  153.         $responseOptionMobile $this->twig->render('front/product-option/options-next-mobile-new.html.twig',$data);
  154.         $response = new Response(json_encode(array('responseNosLovesPrinterNew'=>$responseNosLovesPrinterNew,'responseQtyNew'=>$responseQtyNew,'responseOptionAutre'=>$responseOptionAutre,'responseOption'=>$responseOption,'responseQty'=>$responseQty,'responsePrice'=>$responsePrice,'responseOptionMobile'=>$responseOptionMobile)));
  155.         return $response;
  156.     }
  157.     /**
  158.      * @Route("/get-option-by-product-and-format/{idProduct}-{idFormat}", name="get_option_by_product_and_format",options={"expose"=true})
  159.      */
  160.     public function optionByProductAndFormat(Request $request,$idProduct,$idFormat) : Response
  161.     {
  162.         $product $this->em->getRepository(Product::class)->find($idProduct);
  163.         if($product && $product->getIsColorlab()){
  164.             $data $this->nbDesigner->getOptionByProduct($request,$idProduct);
  165.         }else{
  166.             $data $this->nbDesigner->optionByProductAndFormat($request,$idProduct,$idFormat);
  167.         }
  168.         $responseInfoTaille $this->twig->render('front/product-option/info-taille.html.twig',$data);
  169.         $responseOption $this->twig->render('front/product-option/options-global.html.twig',$data);
  170.         $responseQty $this->twig->render('front/product-option/qty-block.html.twig',$data);
  171.         $responsePrice $this->twig->render('front/product-option/getPrice.html.twig',isset($data['price'])?$data['price']:null);
  172.         $data['isFormatType'] = true;
  173.         $responseOptionFormatType $this->twig->render('front/product-option/options-global-new.html.twig',$data);
  174.         $data['isFormatType'] = false;
  175.         $responseOptionAutre $this->twig->render('front/product-option/options-global-new.html.twig',$data);
  176.         $responseOptionMobile $this->twig->render('front/product-option/options-global-new-mobile.html.twig',$data);
  177.         $responseQtyNew $this->twig->render('front/product-option/qty-block-new.html.twig',$data);
  178.         $responseNosLovesPrinterNew $this->twig->render('front/product-option/nosLovesPrinter.html.twig',$data);
  179.         $response = new Response(json_encode(array('responseNosLovesPrinterNew'=>$responseNosLovesPrinterNew,'responseQtyNew'=>$responseQtyNew,'responseOptionFormatType'=>$responseOptionFormatType,'responseOptionAutre'=>$responseOptionAutre,'responseOptionMobile'=>$responseOptionMobile,'responseInfoTaille'=>$responseInfoTaille,'responseoption'=>$responseOption,'responseQty'=>$responseQty,'responsePrice'=>$responsePrice)));
  180.         return $response;
  181.     }
  182.     /**
  183.      * @Route("/get-option-and-price-by-format/{idProduct}", name="get_option_and_price_by_format",options={"expose"=true})
  184.      */
  185.     public function getOptionByformat(Request $request,$idProduct) : Response
  186.     {
  187.         $requestData $request->request->all();
  188.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  189.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  190.         $typeImpression_id = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  191.         $data $this->nbDesigner->getOptionByformat($request,$idProduct,$format_id,false,$rectoverso,$typeImpression_id);
  192.         $responseInfoTaille $this->twig->render('front/product-option/info-taille.html.twig',$data);
  193.         $responseOption $this->twig->render('front/product-option/options-global-by-format.html.twig',$data);
  194.         $responseOptionMobile $this->twig->render('front/product-option/options-global-by-format-mobile.html.twig',$data);
  195.         $responseQty $this->twig->render('front/product-option/qty-block.html.twig',$data);
  196.         $responsePrice $this->twig->render('front/product-option/getPrice.html.twig',isset($data['price'])?$data['price']:null);
  197.         $responseImageDesc $this->twig->render('front/product-option/options-image-desc.html.twig',$data);
  198.         $responseQtyNew $this->twig->render('front/product-option/qty-block-new.html.twig',$data);
  199.         $responseNosLovesPrinterNew $this->twig->render('front/product-option/nosLovesPrinter.html.twig',$data);
  200.         $response = new Response(json_encode(array('responseNosLovesPrinterNew'=>$responseNosLovesPrinterNew,'responseQtyNew'=>$responseQtyNew,'responseImageDesc'=>$responseImageDesc,'responseInfoTaille'=>$responseInfoTaille,'responseoptionByFormat'=>$responseOption,'responseoptionByFormatMobile'=>$responseOptionMobile,'responseQty'=>$responseQty,'responsePrice'=>$responsePrice)));
  201.         return $response;
  202.     }
  203.     /**
  204.      * @Route("/get-grammage-and-price-by-typeImpression-or-rectoVerso/{idProduct}", name="get_grammage_and_price_by_typeImpression_or_rectoVerso",options={"expose"=true})
  205.      */
  206.     public function getGramgeByTypeImpressionOrRectoVerso(Request $request,$idProduct) : Response
  207.     {
  208.         $requestData $request->request->all();
  209.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  210.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  211.         $finition = isset($requestData['finition'])? $requestData['finition'] : null;
  212.         $typeImpression_id = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  213.         $typeImpression_id null;
  214.         $verification = isset($requestData['verification'])? $requestData['verification'] : null;
  215.         $bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : null;
  216.         $plastification = isset($requestData['plastification'])? $requestData['plastification'] : null;
  217.         $data $this->nbDesigner->getGramgeByTypeImpressionOrRectoVerso($request,$idProduct,$format_id,$rectoverso,$finition,$typeImpression_id,false,$verification,$bordsArrondis,$plastification);
  218.         $responseOptionGramage $this->twig->render('front/product-option/options-gramage.html.twig',$data);
  219.         $responseQty $this->twig->render('front/product-option/qty-block.html.twig',$data);
  220.         $responsePrice $this->twig->render('front/product-option/getPrice.html.twig',isset($data['price'])?$data['price']:null);
  221.         $data['isFormatType'] = true;
  222.         $responseOptionFormatType $this->twig->render('front/product-option/options-global-new.html.twig',$data);
  223.         $data['isFormatType'] = false;
  224.         $responseOptionAutre $this->twig->render('front/product-option/options-global-new.html.twig',$data);
  225.         $responseOptionMobile $this->twig->render('front/product-option/options-global-new-mobile.html.twig',$data);
  226.          $responseQtyNew $this->twig->render('front/product-option/qty-block-new.html.twig',$data);
  227.         $response = new Response(json_encode(array('responseQtyNew'=>$responseQtyNew,'responseOptionFormatType'=>$responseOptionFormatType,'responseOptionAutre'=>$responseOptionAutre,'responseOptionMobile'=>$responseOptionMobile,'responseOptionGramage'=>$responseOptionGramage,'responseQty'=>$responseQty,'responsePrice'=>$responsePrice)));
  228.         return $response;
  229.     }
  230.     /**
  231.      * @Route("/get-price-and-qty/{idProduct}", name="get_price_and_qty_by_product",options={"expose"=true})
  232.      */
  233.     public function priceAndQtyByProduct(Request $request,$idProduct) : Response
  234.     {
  235.         $requestData $request->request->all();
  236.         $qty = isset($requestData['qty'])? $requestData['qty'] : null;
  237.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  238.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  239.         $finition = isset($requestData['finition'])? $requestData['finition'] : null;
  240.         $gramage_id = isset($requestData['gramage_id'])? $requestData['gramage_id'] : null;
  241.         $typeImpression_id = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  242.         $isEnveloppe = isset($requestData['isEnveloppe'])? $requestData['isEnveloppe'] : false;
  243.         $plus_expert = isset($requestData['plus_expert'])? $requestData['plus_expert'] : false;
  244.         $isTrait = isset($requestData['isTrait'])? $requestData['isTrait'] : false;
  245.         $verification = isset($requestData['verification'])? $requestData['verification'] : false;
  246.         $bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : null;
  247.         $plastification = isset($requestData['plastification'])? $requestData['plastification'] : null;
  248.         $imprimeurLivraison = isset($requestData['imprimeurLivraison'])? $requestData['imprimeurLivraison'] : null;
  249.         $dateLivraison = isset($requestData['dateLivraison'])? $requestData['dateLivraison'] : null;
  250.         $timeLivraison = isset($requestData['timeLivraison'])? $requestData['timeLivraison'] : null;
  251.         $carrierId = isset($requestData['carrierId'])? $requestData['carrierId'] : null;
  252.         $typeLivraisonNational = isset($requestData['typeLivraisonNational'])? $requestData['typeLivraisonNational'] : null;
  253.         $typeLivraison30min = isset($requestData['typeLivraison30min'])? $requestData['typeLivraison30min'] : null;
  254.         $lat = isset($requestData['latLiv'])? $requestData['latLiv'] : null;
  255.         $long = isset($requestData['longLiv'])? $requestData['longLiv'] : null;
  256.         $codePostal = isset($requestData['codePostalLiv'])? $requestData['codePostalLiv'] : null;
  257.         $data $this->nbDesigner->getPriceAndQuantity($request,$idProduct,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id,$isEnveloppe,$plus_expert,$isTrait,$carrierId ,$typeLivraisonNational ,$typeLivraison30min,null,$imprimeurLivraison,$dateLivraison,$timeLivraison,$lat,$long,$codePostal,$verification,$bordsArrondis,$plastification);
  258.         $responseQty $this->twig->render('front/product-option/qty-block.html.twig',$data);
  259.         $responsePrice $this->twig->render('front/product-option/getPrice.html.twig',isset($data['price'])?$data['price']:null);
  260.         $responseDetail $this->twig->render('front/product-option/detail-block.html.twig',$data);
  261.         $responseDetailMobile $this->twig->render('front/product-option/detail-block-mobile.html.twig',$data);
  262.         $responseQtyNew $this->twig->render('front/product-option/qty-block-new.html.twig',$data);
  263.         $response = new Response(json_encode(array('responseQtyNew'=>$responseQtyNew,'responseQty'=>$responseQty,'responsePrice'=>$responsePrice,'responseDetail'=>$responseDetail,'responseDetailMobile'=>$responseDetailMobile)));
  264.         return $response;
  265.     }
  266.     /**
  267.      * @Route("/get-btn-crello/", name="get_btn_crello",options={"expose"=true})
  268.      */
  269.     public function getBtnCrello(Request $request) : Response
  270.     {
  271.         $requestData $request->request->all();
  272.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  273.         $response $this->nbDesigner->getBtnCrello($request,$format_id);
  274.         $response = new Response($response);
  275.         return $response;
  276.     }
  277.     /**
  278.      * @Route("/add-to-cart/", name="add_to_cart_new_nb_designer",options={"expose"=true})
  279.      */
  280.     public function addToCartNewNbDesigner(Request $request) : Response
  281.     {
  282.         $data $this->nbDesigner->addToCartNewNbDesigner($request,$this->getUser());
  283.         $responseDetail $this->twig->render('front/product-option/detail-modal.html.twig',$data);
  284.         $response = new Response(json_encode(array($data,'responseDetail'=>$responseDetail)));
  285.         return $response;
  286.     }
  287.     /**
  288.      * @Route("/upload-crea/", name="upload_crea_new_nb_designer",options={"expose"=true})
  289.      */
  290.     public function uploadCreaNewNbDesigner(Request $request) : Response
  291.     {
  292.         $files $request->files->get('fileDesign');
  293.         $data $this->nbDesigner->addImageCreaNewNbDesigner($files);
  294.         $response = new Response(json_encode($data));
  295.         return $response;
  296.     }
  297.     /**
  298.      * @Route("/get-array-pdf-crello/", name="get_array_pdf_crello",options={"expose"=true})
  299.      */
  300.     public function getArrayPdfCrello(Request $request) : Response
  301.     {
  302.         $fileUrl $request->request->get('designUrl');
  303.         $data $this->nbDesigner->downloadPdfCrello($request,$fileUrl,'tmp-'.md5());
  304.         $response = new Response(json_encode($data));
  305.         return $response;
  306.     }
  307.     /**
  308.      * @Route("/get-detail/{idProduct}", name="get_detail_product",options={"expose"=true})
  309.      */
  310.     public function getDetailProduct(Request $request,$idProduct) : Response
  311.     {
  312.         $requestData $request->request->all();
  313.         $qty = isset($requestData['qty'])? $requestData['qty'] : null;
  314.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  315.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  316.         $finition = isset($requestData['finition'])? $requestData['finition'] : null;
  317.         $gramage_id = isset($requestData['gramage_id'])? $requestData['gramage_id'] : null;
  318.         $typeImpression_id = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  319.         $carrierId = isset($requestData['carrierId'])? $requestData['carrierId'] : null;
  320.         $typeLivraisonNational = isset($requestData['typeLivraisonNational'])? $requestData['typeLivraisonNational'] : null;
  321.         $typeLivraison30min = isset($requestData['typeLivraison30min'])? $requestData['typeLivraison30min'] : null;
  322.         $isEnveloppe = isset($requestData['isEnveloppe'])? $requestData['isEnveloppe'] : false;
  323.         $verification = isset($requestData['verification'])? $requestData['verification'] : false;
  324.         $bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : null;
  325.         $plastification = isset($requestData['plastification'])? $requestData['plastification'] : null;
  326.         $plus_expert = isset($requestData['plus_expert'])? $requestData['plus_expert'] : false;
  327.         $isTrait = isset($requestData['isTrait'])? $requestData['isTrait'] : false;
  328.         $tokenDetail = isset($requestData['tokenDetail'])? $requestData['tokenDetail'] : null;
  329.         $data $this->nbDesigner->getDetailProduct($request,$idProduct,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id,$isEnveloppe,$plus_expert,$isTrait,$carrierId ,$typeLivraisonNational ,$typeLivraison30min,$tokenDetail,$verification,$bordsArrondis,$plastification);
  330.         $response = new Response($data);
  331.         return $response;
  332.     }
  333.     /**
  334.      * @Route("/get-detail-photos/{idProduct}", name="get_detail_product_photos",options={"expose"=true})
  335.      */
  336.     public function getDetailProductPhotos(Request $request,$idProduct) : Response
  337.     {
  338.         $requestData $request->request->all();
  339.         $qty = isset($requestData['qty'])? $requestData['qty'] : null;
  340.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  341.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  342.         $finition = isset($requestData['finition'])? $requestData['finition'] : null;
  343.         $gramage_id = isset($requestData['gramage_id'])? $requestData['gramage_id'] : null;
  344.         $typeImpression_id = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  345.         $carrierId = isset($requestData['carrierId'])? $requestData['carrierId'] : null;
  346.         $typeLivraisonNational = isset($requestData['typeLivraisonNational'])? $requestData['typeLivraisonNational'] : null;
  347.         $typeLivraison30min = isset($requestData['typeLivraison30min'])? $requestData['typeLivraison30min'] : null;
  348.         $isEnveloppe = isset($requestData['isEnveloppe'])? $requestData['isEnveloppe'] : false;
  349.         $verification = isset($requestData['verification'])? $requestData['verification'] : false;
  350.         $bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : null;
  351.         $plastification = isset($requestData['plastification'])? $requestData['plastification'] : null;
  352.         $plus_expert = isset($requestData['plus_expert'])? $requestData['plus_expert'] : false;
  353.         $isTrait = isset($requestData['isTrait'])? $requestData['isTrait'] : false;
  354.         $tokenDetail = isset($requestData['tokenDetail'])? $requestData['tokenDetail'] : null;
  355.         $data $this->nbDesigner->getDetailProductPhotos($request,$idProduct,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id,$isEnveloppe,$plus_expert,$isTrait,$carrierId ,$typeLivraisonNational ,$typeLivraison30min,$tokenDetail,$verification,$bordsArrondis,$plastification);
  356.         $response = new Response(json_encode($data));
  357.         return $response;
  358.     }
  359.     /**
  360.      * @Route("/get-detail-mobile/{idProduct}", name="get_detail_product_mobile",options={"expose"=true})
  361.      */
  362.     public function getDetailProductMobile(Request $request,$idProduct) : Response
  363.     {
  364.         $requestData $request->request->all();
  365.         $qty = isset($requestData['qty'])? $requestData['qty'] : null;
  366.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  367.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  368.         $finition = isset($requestData['finition'])? $requestData['finition'] : null;
  369.         $gramage_id = isset($requestData['gramage_id'])? $requestData['gramage_id'] : null;
  370.         $typeImpression_id = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  371.         $carrierId = isset($requestData['carrierId'])? $requestData['carrierId'] : null;
  372.         $typeLivraisonNational = isset($requestData['typeLivraisonNational'])? $requestData['typeLivraisonNational'] : null;
  373.         $typeLivraison30min = isset($requestData['typeLivraison30min'])? $requestData['typeLivraison30min'] : null;
  374.         $isEnveloppe = isset($requestData['isEnveloppe'])? $requestData['isEnveloppe'] : false;
  375.         $verification = isset($requestData['verification'])? $requestData['verification'] : false;
  376.         $bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : null;
  377.         $plastification = isset($requestData['plastification'])? $requestData['plastification'] : null;
  378.         $plus_expert = isset($requestData['plus_expert'])? $requestData['plus_expert'] : false;
  379.         $isTrait = isset($requestData['isTrait'])? $requestData['isTrait'] : false;
  380.         $tokenDetail = isset($requestData['tokenDetail'])? $requestData['tokenDetail'] : null;
  381.         $data $this->nbDesigner->getDetailProductMobile($request,$idProduct,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id,$isEnveloppe,$plus_expert,$isTrait,$carrierId ,$typeLivraisonNational ,$typeLivraison30min,$tokenDetail,$verification,$bordsArrondis,$plastification);
  382.         $response = new Response($data);
  383.         return $response;
  384.     }
  385.     /**
  386.      * @Route("/get-detail-tag-google/{idProduct}", name="get_detail_product_tag_google",options={"expose"=true})
  387.      */
  388.     public function getDetailProductTagGoogle(Request $request,$idProduct) : Response
  389.     {
  390.         $requestData $request->request->all();
  391.         $qty = isset($requestData['qty'])? $requestData['qty'] : null;
  392.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  393.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  394.         $finition = isset($requestData['finition'])? $requestData['finition'] : null;
  395.         $gramage_id = isset($requestData['gramage_id'])? $requestData['gramage_id'] : null;
  396.         $typeImpression_id = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  397.         $carrierId = isset($requestData['carrierId'])? $requestData['carrierId'] : null;
  398.         $typeLivraisonNational = isset($requestData['typeLivraisonNational'])? $requestData['typeLivraisonNational'] : null;
  399.         $typeLivraison30min = isset($requestData['typeLivraison30min'])? $requestData['typeLivraison30min'] : null;
  400.         $isEnveloppe = isset($requestData['isEnveloppe'])? $requestData['isEnveloppe'] : false;
  401.         $verification = isset($requestData['verification'])? $requestData['verification'] : false;
  402.         $bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : null;
  403.         $plastification = isset($requestData['plastification'])? $requestData['plastification'] : null;
  404.         $plus_expert = isset($requestData['plus_expert'])? $requestData['plus_expert'] : false;
  405.         $isTrait = isset($requestData['isTrait'])? $requestData['isTrait'] : false;
  406.         $tokenDetail = isset($requestData['tokenDetail'])? $requestData['tokenDetail'] : null;
  407.         $data $this->nbDesigner->getDetailProductTagGoogle($request,$idProduct,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id,$isEnveloppe,$plus_expert,$isTrait,$carrierId ,$typeLivraisonNational ,$typeLivraison30min,$tokenDetail,$verification,$bordsArrondis,$plastification);
  408.         $response = new Response(json_encode($data));
  409.         return $response;
  410.     }
  411.     /**
  412.      * @Route("/get-list-product-tag-google/{idCategory}", name="get_list_products_tag_google",options={"expose"=true})
  413.      */
  414.     public function getListProductsTagGoogle(Request $request,$idCategory) : Response
  415.     {
  416.         $produits $this->em->getRepository(BesoinProductPage::class)->getAllActiveByCategory($idCategory);
  417.         if($produits){
  418.             $data $this->nbDesigner->getListProductsBy($produits);
  419.             $response = new Response(json_encode($data));
  420.         }else{
  421.             $response = new Response(0);
  422.         }
  423.         return $response;
  424.     }
  425.     /**
  426.      * @Route("/get-list-product-tag-google-cat/{num}", name="get_list_products_tag_google_cat",options={"expose"=true})
  427.      */
  428.     public function getListProductsCatTagGoogle(Request $request,$num) : Response
  429.     {
  430.         if($num == 1){
  431.             $produits $this->em->getRepository(NosCrea::class)->findBy([]);
  432.         }else if($num == 2){
  433.             $produits $this->em->getRepository(Product::class)->findBy(['besoinProductIsNew'=>true]);
  434.         }else if($num 3){
  435.             $produits $this->em->getRepository(Product::class)->findBy(['besoinProductIsPromo'=>true]);
  436.         }else if($num 4){
  437.             $produits $this->em->getRepository(Product::class)->findBy(['besoinProductIsLuxe'=>true]);
  438.         }else{
  439.             $produits null;
  440.         }
  441.         if($produits){
  442.             $data $this->nbDesigner->getListProductsBy($produits,$num);
  443.             $response = new Response(json_encode($data));
  444.         }else{
  445.             $response = new Response(0);
  446.         }
  447.         return $response;
  448.     }
  449.     /**
  450.      * @Route("/block-livraison-product/{idProduct}", name="block_livraison_page_option_product",options={"expose"=true})
  451.      */
  452.     public function blockLivraison(Request $request,$idProduct): Response
  453.     {
  454.         $cart $this->cart_service->createCart(true);
  455.         $requestData $request->request->all();
  456.         if (isset($requestData['codePostalLiv'])) {
  457.             $data['lat'] = $requestData['latLiv'];
  458.             $data['longi'] = $requestData['longLiv'];
  459.             $data['postalcode'] = $requestData['codePostalLiv'];
  460.             $data['CountryLiv'] = $requestData['CountryLiv'];
  461.             $data['CountryCodeLiv'] = isset($requestData['CountryCodeLiv']) ? $requestData['CountryCodeLiv'] : 'Fr';
  462.         } else {
  463.             return $this->render('front/product-option/blockLivraison.html.twig', array('latLongiRequired' => 1));
  464.         }
  465.         $qty = isset($requestData['qty'])? $requestData['qty'] : 1000;
  466.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  467.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  468.         $gramage_id = isset($requestData['gramage_id'])? $requestData['gramage_id'] : null;
  469.         $typeImpression_id = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  470.         $tokenDetail = isset($requestData['tokenDetail'])? $requestData['tokenDetail'] : null;
  471.         $product $this->em->getRepository(Product::class)->find($idProduct);
  472.         $productAttribute $this->nbDesigner->getProductAttributeNewNbDesigner($request,$idProduct,$format_id,$gramage_id,$typeImpression_id,$rectoverso,ProductAttribute::SANS_PLASTIFICATION);
  473.         $dataLivrason $this->checkout_service->getModeLivraisonProductOptionPage($cart,$data,$productAttribute,$qty$this->getUser(),$tokenDetail);
  474.          $dataLivrasonHtml $this->twig->render('front/product-option/blockLivraison-new.html.twig'$dataLivrason);
  475.         $response = new Response(json_encode(array('dataLivrasonHtml'=>$dataLivrasonHtml,'isStock'=>$dataLivrason['is_stock'])));
  476.         return $response;
  477.     }
  478.     /**
  479.      * @Route("/get-mode-livraison-possible/{idProduct}", name="get_mode_livraison_possible",options={"expose"=true})
  480.      */
  481.     public function getModeLivraisonPossible(Request $request,$idProduct) : Response
  482.     {
  483.         $cart $this->cart_service->createCart(true);
  484.         $requestData $request->request->all();
  485.         if (isset($requestData['codePostalLiv'])) {
  486.             $data['lat'] = $requestData['latLiv'];
  487.             $data['longi'] = $requestData['longLiv'];
  488.             $data['postalcode'] = $requestData['codePostalLiv'];
  489.             $data['CountryLiv'] = $requestData['CountryLiv'];
  490.             $data['CountryCodeLiv'] = isset($requestData['CountryCodeLiv']) ? $requestData['CountryCodeLiv'] : 'Fr';
  491.         }
  492.         $qty = isset($requestData['qty'])? $requestData['qty'] : null;
  493.         $tokenDetail = isset($requestData['tokenDetail'])? $requestData['tokenDetail'] : null;
  494.         $product $this->em->getRepository(Product::class)->find($idProduct);
  495.         $dataLivrason $this->checkout_service->getModeLivraisonPossible($cart,$data,$product,$qty$this->getUser(),$tokenDetail);
  496.         $result $this->cart_service->checkB2bUser($this->getUser());
  497.         $abonnement $result['abonnement'];
  498.         $isAbonnementProInCart $result['isAbonnementProInCart'];
  499.         if($abonnement['is_abonnemen_pro'] || $isAbonnementProInCart) {
  500.             if ($product && !$product->getIsColorLab() && !in_array($product->getTypeProduct(), [Product::PAPIERProduct::PAPIER_POSTE])) {
  501.                 return $this->render('front/product-option/blockLivraison-new.html.twig'$dataLivrason);
  502.             } else {
  503.                 return $this->render('front/product-option/blockLivraison.html.twig'$dataLivrason);
  504.             }
  505.         }else {
  506.             if ($product && !$product->getIsColorLab() && !in_array($product->getTypeProduct(), [Product::PAPIERProduct::PAPIER_POSTE])) {
  507.                 return $this->render('front/product-option/blockLivraison-new.html.twig'$dataLivrason);
  508.             } else {
  509.                 return $this->render('front/product-option/blockLivraison.html.twig'$dataLivrason);
  510.             }
  511.         }
  512.     }
  513.     /**
  514.      * @Route("/modal-stock/block-livraison-product-check-stock/{idProduct}", name="page_option_product_check_stock",options={"expose"=true})
  515.      */
  516.     public function checkiFinStock(Request $request,$idProduct): Response
  517.     {
  518.         $cart $this->cart_service->createCart(true);
  519.         $requestData $request->request->all();
  520.         if (isset($requestData['codePostalLiv'])) {
  521.             $data['lat'] = $requestData['latLiv'];
  522.             $data['longi'] = $requestData['longLiv'];
  523.             $data['postalcode'] = $requestData['codePostalLiv'];
  524.             $data['CountryLiv'] = $requestData['CountryLiv'];
  525.             $data['CountryCodeLiv'] = isset($requestData['CountryCodeLiv']) ? $requestData['CountryCodeLiv'] : 'Fr';
  526.         }
  527.         $qty = isset($requestData['qty'])? $requestData['qty'] : null;
  528.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  529.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  530.         $gramage_id = isset($requestData['gramage_id'])? $requestData['gramage_id'] : null;
  531.         $typeImpression_id = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  532.         $tokenDetail = isset($requestData['tokenDetail'])? $requestData['tokenDetail'] : null;
  533.         $productAttribute $this->nbDesigner->getProductAttributeNewNbDesigner($request,$idProduct,$format_id,$gramage_id,$typeImpression_id,$rectoverso,ProductAttribute::SANS_PLASTIFICATION);
  534.         $dataLivrason $this->checkout_service->getModeLivraisonProductOptionPage($cart,$data,$productAttribute,$qty$this->getUser(),$tokenDetail);
  535.         if(!$dataLivrason['is_stock']){
  536.             if($productAttribute){
  537.                 $dataLivrason['productAttributes'] = $this->checkout_service->getProductAttributes($cart,$data,$productAttribute->getProduct(),$qty$this->getUser(),$tokenDetail);
  538.             }
  539.             return $this->render('front/product-option/outOfStockModal.html.twig'$dataLivrason);
  540.         }else{
  541.             return new Response(1);
  542.         }
  543.     }
  544.     /**
  545.      * @Route("/modal-stock/get-btn-and-option-by-product-attribute", name="get_btn_and_option_by_product_attribute",options={"expose"=true})
  546.      */
  547.     public function getBtnAndOptionByProductAttribute(Request $request) : Response
  548.     {
  549.         $btns $this->nbDesigner->getBtnByProductAttribute($request);
  550.         $data $this->nbDesigner->getOptionByProductAttributeAndFinitionAndQty($request);
  551.         $responseInfoTaille $this->twig->render('front/product-option/info-taille.html.twig',$data);
  552.         $responseOption $this->twig->render('front/product-option/options-global.html.twig',$data);
  553.         $responseQty $this->twig->render('front/product-option/qty-block.html.twig',$data);
  554.         $responsePrice $this->twig->render('front/product-option/getPrice.html.twig',isset($data['price'])?$data['price']:null);
  555.         $response = new Response(json_encode(array('responseInfoTaille'=>$responseInfoTaille,'responseoption'=>$responseOption,'responseQty'=>$responseQty,'responsePrice'=>$responsePrice,'btns'=>$btns)));
  556.         return $response;
  557.     }
  558.     /**
  559.      * @Route("/get-detail-carrier/{idProduct}", name="get_block_detail_livraison",options={"expose"=true})
  560.      */
  561.     public function getPriceCarrier(Request $request,$idProduct) : Response
  562.     {
  563.         $requestData $request->request->all();
  564.         $qty = isset($requestData['qty'])? $requestData['qty'] : null;
  565.         $format_id = isset($requestData['format_id'])? $requestData['format_id'] : null;
  566.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  567.         $finition = isset($requestData['finition'])? $requestData['finition'] : null;
  568.         $gramage_id = isset($requestData['gramage_id'])? $requestData['gramage_id'] : null;
  569.         $typeImpression_id = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  570.         $isEnveloppe = isset($requestData['isEnveloppe'])? $requestData['isEnveloppe'] : false;
  571.         $verification = isset($requestData['verification'])? $requestData['verification'] : false;
  572.         $bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : null;
  573.         $plastification = isset($requestData['plastification'])? $requestData['plastification'] : null;
  574.         $plus_expert = isset($requestData['plus_expert'])? $requestData['plus_expert'] : false;
  575.         $isTrait = isset($requestData['isTrait'])? $requestData['isTrait'] : false;
  576.         $adresseCarrier = isset($requestData['adresseCarrier'])? $requestData['adresseCarrier'] : null;
  577.         $imprimeurLivraison = isset($requestData['imprimeurLivraison'])? $requestData['imprimeurLivraison'] : null;
  578.         $dateLivraison = isset($requestData['dateLivraison'])? $requestData['dateLivraison'] : null;
  579.         $timeLivraison = isset($requestData['timeLivraison'])? $requestData['timeLivraison'] : null;
  580.         $carrierId = isset($requestData['carrierId'])? $requestData['carrierId'] : null;
  581.         $typeLivraisonNational = isset($requestData['typeLivraisonNational'])? $requestData['typeLivraisonNational'] : null;
  582.         $typeLivraison30min = isset($requestData['typeLivraison30min'])? $requestData['typeLivraison30min'] : null;
  583.         $lat = isset($requestData['latLiv'])? $requestData['latLiv'] : null;
  584.         $long = isset($requestData['longLiv'])? $requestData['longLiv'] : null;
  585.         $codePostal = isset($requestData['codePostalLiv'])? $requestData['codePostalLiv'] : null;
  586.         $data $this->nbDesigner->getPriceAndQuantity($request,$idProduct,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id,$isEnveloppe,$plus_expert,$isTrait,$carrierId ,$typeLivraisonNational ,$typeLivraison30min,$adresseCarrier,$imprimeurLivraison,$dateLivraison,$timeLivraison,$lat,$long,$codePostal,$verification,$bordsArrondis,$plastification);
  587.         $responseQty $this->twig->render('front/product-option/qty-block.html.twig',$data);
  588.         $responsePrice $this->twig->render('front/product-option/getPrice.html.twig',isset($data['price'])?$data['price']:null);
  589.         $response = new Response(json_encode(array('responseQty'=>$responseQty,'responsePrice'=>$responsePrice,'blockLivraison'=>$data['blockLivraison'],'livraisonPrice'=>$data['livraisonPrice'])));
  590.         return $response;
  591.     }
  592.     /**
  593.      * @Route("/search/product", name="searchProductOption",options={"expose"=true})
  594.      */
  595.     public function searchProduct(Request $request) : Response
  596.     {
  597.         $requestData $request->query->get('search');
  598.         $data $this->nbDesigner->searchProductOption($request,$requestData,$this->getUser());
  599.         $response = new Response(json_encode($data,true));
  600.         return $response;
  601.     }
  602.     /**
  603.      * @Route("/save-category/b2b", name="saveCategoryProductOption",options={"expose"=true})
  604.      */
  605.     public function saveCategory(Request $request) : Response
  606.     {
  607.         $data $this->nbDesigner->saveCustomCatCrello($this->getUser(),$request->query->all());
  608.         $response = new Response($data);
  609.         return $response;
  610.     }
  611.     /**
  612.      * @Route("/upload-photos/", name="upload_photos_product_option",options={"expose"=true})
  613.      */
  614.     public function uploadPhotos(Request $request) : Response
  615.     {
  616.         $file $request->files->get('fileDesignPhoto');
  617.         $data $this->nbDesigner->uploadPhotos($file,$request);
  618.         $response = new Response(json_encode(['token'=>$data['token'],'thumb'=>$data['thumb'],'image'=>$data['image']]));
  619.         return $response;
  620.     }
  621.     /**
  622.      * @Route("/download-photos/{token}", name="download_photos_product_option" , options={"expose"=true})
  623.      */
  624.     public function downloadFile(Request $request,$token): Response
  625.     {
  626.         $file  $this->em->getRepository(CartDetailPhotos::class)->findOneBy(['token'=>$token]);
  627.         $filePath $this->params->get('uploads_directory')."/tmp/".$file->getFile();
  628.         $response = new Response();
  629.         $response->setContent(file_get_contents($filePath));
  630.         $response->headers->set('Content-Type''application/force-download');
  631.         $response->headers->set('Content-disposition''filename='.$file->getFile());
  632.         $response->setStatusCode(200);
  633.         return $response;
  634.     }
  635.     /**
  636.      * @Route("/delete-photos/{token}", name="delete_photos_product_option" , options={"expose"=true})
  637.      */
  638.     public function deleteFile(Request $request,$token)
  639.     {
  640.         $file  $this->em->getRepository(CartDetailPhotos::class)->findOneBy(['token'=>$token]);
  641.         if(is_object($file)) {
  642.             if ($file->getFile() and trim($file->getFile()) != '') {
  643.                 $filePath $this->params->get('uploads_directory')."/tmp/".$file->getFile();
  644.                 if (file_exists($filePath)) unlink($filePath);
  645.             }
  646.             $this->em->remove($file);
  647.             $this->em->flush();
  648.         }
  649.         $response = new Response(1);
  650.         $response->setStatusCode(200);
  651.         return $response;
  652.     }
  653.     /**
  654.      * @Route("/get-msg-erreur/{tag}", name="get_msg_erreur_product_option" , options={"expose"=true})
  655.      */
  656.     public function getMsgErreur(Request $request,$tag): Response
  657.     {
  658.         $config $this->em->getRepository(ConfigProductDescription::class)->findOneBy(array('tagId' => $tag));
  659.         $msg 'erreur !';
  660.         if($config) {
  661.             $msg $config->getDescription();
  662.         }
  663.         $response = new Response();
  664.         $response->setContent($msg);
  665.         $response->setStatusCode(200);
  666.         return $response;
  667.     }
  668.     /**
  669.      * @Route("/download-file-cmd/{id}/order/{token}", name="download_file_order" , options={"expose"=true})
  670.      */
  671.     public function downloadFileOrder(Request $request,$id,$token): Response
  672.     {
  673.         $orderDetail  $this->em->getRepository(OrderDetail::class)->getOrdersDetailByOrderToken($id,$token);
  674.         $orderDetail->setDownloadNbr($orderDetail->getDownloadNbr() + 1);
  675.         $this->em->persist($orderDetail);
  676.         $this->em->flush();
  677.         $pdf $orderDetail->getUrlFile();
  678.         if($pdf && trim($pdf) != '' && !empty($pdf)) {
  679.             $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  680.             if ($orderDetail->getOrders()->getIsCopeesApi()) {
  681.                 $baseurl substr_replace($this->params->get('url_site'), "", -1);
  682.             }
  683.             if ($orderDetail->getTypeProduct() != Product::SIMPLE and $orderDetail->getTypeProduct() != Product::PAPIER_POSTE and $orderDetail->getTypeProduct() != Product::PAPIER) {
  684.                 if($orderDetail->getOrders()->getCreatedAt() > new \DateTime('23-10-2023') and $orderDetail->getOrders()->getCreatedAt() <= new \DateTime('10-11-2023')){
  685.                     $cartDetail $this->em->getRepository(CartDetail::class)->findOneBy(['token'=>$orderDetail->getToken()]);
  686.                     if($cartDetail){
  687.                         $pdf $cartDetail->getFilePapier();
  688.                     }
  689.                 }
  690.                 $path_pdf $this->params->get('uploads_directory') . '/tmp/' $pdf;
  691.                 $url $baseurl '/uploads/tmp/' $pdf;
  692.             } else {
  693.                 if ($orderDetail->getIsModif()) {
  694.                     $path_pdf $this->params->get('pdfModif_directory') . '/' $pdf;
  695.                     $url $baseurl '/modifPdf/' $pdf;
  696.                 } else {
  697.                     if ($orderDetail->getIsTopImp()) {
  698.                         $path_pdf $this->params->get('productPdf_directory') . '/' $pdf;
  699.                         $url $baseurl '/productPdf/' $pdf;
  700.                     } else {
  701.                         $path_pdf $this->params->get('uploads_directory') . '/' $pdf;
  702.                         $url $baseurl '/uploads/' $pdf;
  703.                     }
  704.                 }
  705.             }
  706.             // Generate response
  707.             $response = new Response($pdf);
  708.             // Set headers
  709.             $response->headers->set('Cache-Control''private');
  710.             if ($orderDetail->getOrders()->getIsCopeesApi()) {
  711.                 $result $this->orderService->get_remote_file_info($url);
  712.                 $buffer file_get_contents($url);
  713.                 $finfo = new \finfo(FILEINFO_MIME_TYPE);
  714.                 $mime_content_type $finfo->buffer($buffer);
  715.                 $response->headers->set('Content-type'$mime_content_type);
  716.                 $response->headers->set('Content-Disposition''attachment; filename="' basename($path_pdf) . '";');
  717.                 $response->headers->set('Content-length'$result['fileSize']);
  718.             } else {
  719.                 $response->headers->set('Content-type'mime_content_type($path_pdf));
  720.                 $response->headers->set('Content-Disposition''attachment; filename="' basename($path_pdf) . '";');
  721.                 $response->headers->set('Content-length'filesize($path_pdf));
  722.             }
  723.             // Send headers before outputting anything
  724.             $response->sendHeaders();
  725.             $response->setContent(file_get_contents(str_replace(' ''%20'$url)));
  726.             return $response;
  727.         }
  728.         $response = new Response();
  729.         $response->setContent('erreur !');
  730.         $response->setStatusCode(200);
  731.         return $response;
  732.     }
  733. }