src/Services/NbDesigner.php line 428

Open in your IDE?
  1. <?php
  2. namespace App\Services;
  3. use App\Entity\Abonnement;
  4. use App\Entity\AbonnementPro;
  5. use App\Entity\Attribut;
  6. use App\Entity\Carrier;
  7. use App\Entity\Cart;
  8. use App\Entity\CartDetail;
  9. use App\Entity\CartDetailPhotos;
  10. use App\Entity\CodePromo;
  11. use App\Entity\FilesClient;
  12. use App\Entity\FilesClientCrello;
  13. use App\Entity\FilesClientCrelloCategory;
  14. use App\Entity\Imprimeur;
  15. use App\Entity\NbElements;
  16. use App\Entity\NbFiles;
  17. use App\Entity\NbTemplates;
  18. use App\Entity\NbTextes;
  19. use App\Entity\NbUserTemplates;
  20. use App\Entity\NosCrea;
  21. use App\Entity\PriceProduct;
  22. use App\Entity\Product;
  23. use App\Entity\ProductAttribute;
  24. use App\Entity\TemplatesPage;
  25. use App\Entity\TemplatesPageCategory;
  26. use Spipu\Html2Pdf\Html2Pdf;
  27. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  28. use Doctrine\ORM\EntityManagerInterface;
  29. use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
  30. use Symfony\Contracts\Translation\TranslatorInterface;
  31. use Symfony\Component\Security\Core\Security;
  32. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  33. use Symfony\Contracts\HttpClient\HttpClientInterface;
  34. use Symfony\Component\Finder\Finder;
  35. use Twig\Environment;
  36. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  37. use App\Services\CartService;
  38. use Symfony\Component\HttpFoundation\File\File;
  39. use Symfony\Component\HttpFoundation\File\UploadedFile;
  40. use App\Services\AbonnementService;
  41. use Imagick;
  42. class NbDesigner extends AbstractController
  43. {
  44.     private $em;
  45.     private $flashBag;
  46.     private $trans;
  47.     private $params;
  48.     private $security;
  49.     private $session;
  50.     private $httpClient;
  51.     private $twig;
  52.     private $cart_service;
  53.     private $abonnementService;
  54.     public function __construct(AbonnementService $abonnementService,CartService $cart_service ,Environment $twig,HttpClientInterface $httpClientParameterBagInterface $paramsSecurity $securityEntityManagerInterface $emFlashBagInterface $flashBagTranslatorInterface $transSessionInterface $session)
  55.     {
  56.         $this->security $security;
  57.         $this->em $em;
  58.         $this->flashBag $flashBag;
  59.         $this->trans $trans;
  60.         $this->params $params;
  61.         $this->session $session;
  62.         $this->httpClient $httpClient;
  63.         $this->twig $twig;
  64.         $this->cart_service $cart_service;
  65.         $this->abonnementService $abonnementService;
  66.     }
  67.     public function init($request,$token): array
  68.     {
  69.         $data $request->query->all();
  70.         $format_id = isset($data['format']) ? $data['format'] : 2;
  71.         $product_id = isset($data['product']) ? $data['product'] : 2;
  72.         $isPaysage = (isset($data['isPaysage']) && $data['isPaysage'] == 1) ? 0;
  73.         $templates $this->em->getRepository(NbTemplates::class)->getTemplates($format_id,'ASC',16,0,null,$isPaysage);
  74.         $textes $this->em->getRepository(NbTextes::class)->findBy(array(), array(), 200);
  75.         $files $this->security->getUser() ? $this->em->getRepository(NbFiles::class)->findAll() : array();
  76.         $elementShapes $this->em->getRepository(NbElements::class)->findBy(array('category' => 66), array(), 100);
  77.         $elementIcones $this->em->getRepository(NbElements::class)->findBy(array('category' => 73), array(), 100);
  78.         if($token){
  79.             $this->session->set('nbToken'$token);
  80.             $userTemplate $this->em->getRepository(NbUserTemplates::class)->findOneBy(array('token' => $this->session->get('nbToken')));
  81.             $new =false;
  82.         }else {
  83.             $userTemplate = new NbUserTemplates();
  84.             if ($this->security->getUser())
  85.                 $userTemplate->setUser($this->security->getUser());
  86.             $userTemplate->setToken($this->generateToken(32));
  87.             $userTemplate->setName($this->generateToken(10));
  88.             $this->em->persist($userTemplate);
  89.             $this->session->set('nbToken'$userTemplate->getToken());
  90.             $new =true;
  91.         }
  92.         if($request->get('rectoverso'false)){
  93.             $rectoverso ProductAttribute::VERSO;
  94.             $userTemplate->setRectoverso($rectoverso);
  95.         } else{
  96.             $rectoverso ProductAttribute::RECTO;
  97.             $userTemplate->setRectoverso($rectoverso);
  98.         }
  99.         $product $this->em->getRepository(Product::class)->find($product_id);
  100.         if($product && $product->getTypeProduct()== Product::AFFICHE){
  101.             $typeImpression $this->getTypeImpression($product_id,$format_id);
  102.             $gramage $this->getGrammageByTypeImpression($product_id,$format_id,isset($typeImpression[0]['id'])?$typeImpression[0]['id']:null);
  103.             $qtys = isset($gramage[0]['id']) ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage[0]['id'],$format_id,isset($typeImpression[0]['id'])?$typeImpression[0]['id']:null,ProductAttribute::SANS_PLASTIFICATION,$userTemplate->getFinition()):array();
  104.         }else{
  105.             $gramage $this->getGramage($product_id,$format_id,$rectoverso);
  106.             $qtys = isset($gramage[0]['id'])?$this->getQtyPosibleByGrammage($gramage[0]['id'],$format_id,$rectoverso,$userTemplate->getFinition()):array();
  107.             $typeImpression false;
  108.         }
  109.         $this->em->flush();
  110.         return array(
  111.             'templates' => $templates,
  112.             'format_id' => $format_id,
  113.             'isPaysage' => $isPaysage,
  114.             'gramage' => $gramage,
  115.             'typeImpression' => $typeImpression,
  116.             'qtys' => $qtys['qtys'],
  117.             'qtysPlus' => $qtys['qtysPlus'],
  118.             'qtysTeam' => $qtys['qtysTeam'],
  119.             'textes' => $textes,
  120.             'files' => $files,
  121.             'shapes' => $elementShapes,
  122.             'icones' => $elementIcones,
  123.             'userTemplate' => $userTemplate,
  124.             'product_id' => $product_id,
  125.             'product' => $product,
  126.             'isNew' => $new,
  127.             'myTemplates' => $this->cart_service->getListeTemplateSaved($this->security->getUser()),
  128.             'myDesign' => $this->em->getRepository(NbUserTemplates::class)->getTemplateNotEmpty($this->security->getUser()),
  129.             'rectoverso' => $request->get('rectoverso'),
  130.             'imagesCrea' => $images $this->em->getRepository(NbFiles::class)->findBy(array('token'=>$this->session->get('nbToken'),'isCrea'=>true)),
  131.             'images' => $images $this->em->getRepository(NbFiles::class)->findBy(array('token'=>$this->session->get('nbToken'),'isCrea'=>false))
  132.         );
  133.     }
  134.     public function getQantityVitrophonies($product,$qtys,$formatL=100,$formatH=100){
  135.         $surface $formatL $formatH;
  136.         if(in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
  137.             if($surface 10000 ){
  138.                 $surface 10000;
  139.             }
  140.             foreach ($qtys as &$item){
  141.                 $item['prixTtc'] = $this->cart_service->updatePriceByCountry( (float)$item['prixTtc'],$product) * $surface;
  142.                 $item['prixHt'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHt'],$product) * $surface;
  143.                 $item['prixTtcAbonnementPro'] = $this->cart_service->updatePriceByCountry( (float)$item['prixTtcAbonnementPro'],$product) * $surface;
  144.                 $item['prixHtAbonnementPro'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHtAbonnementPro'],$product) * $surface;
  145.                 $item['prixTtcAbonnementTeam'] = $this->cart_service->updatePriceByCountry( (float)$item['prixTtcAbonnementTeam'],$product) * $surface;
  146.                 $item['prixHtAbonnementTeam'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHtAbonnementTeam'],$product) * $surface;
  147.                 $item['prixTtcAbonnementEntreprise'] = $this->cart_service->updatePriceByCountry( (float)$item['prixTtcAbonnementEntreprise'],$product) * $surface;
  148.                 $item['prixHtAbonnementEntreprise'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHtAbonnementEntreprise'],$product) * $surface;
  149.                 $item['prixPromoTtc'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoTtc'],$product) * $surface;
  150.                 $item['prixPromoHt'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoHt'],$product) * $surface;
  151.                 $item['prixPromoTtcAbonnementPro'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoTtcAbonnementPro'],$product) * $surface;
  152.                 $item['prixPromoHtAbonnementPro'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoHtAbonnementPro'],$product) * $surface;
  153.                 $item['prixHtAbonnementEntreprise'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHtAbonnementEntreprise'],$product) * $surface;
  154.                 $item['prixPromoTtcAbonnementTeam'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoTtcAbonnementTeam'],$product) * $surface;
  155.                 $item['prixPromoHtAbonnementTeam'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoHtAbonnementTeam'],$product) * $surface;
  156.                 $item['prixTtcWithoutPromo'] = $this->cart_service->updatePriceByCountry( (float)$item['prixTtcWithoutPromo'],$product) * $surface;
  157.                 $item['prixHtWithoutPromo'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHtWithoutPromo'],$product) * $surface;
  158.             }
  159.         }
  160.         return $qtys;
  161.     }
  162.     // get option and price by product new nb_designer
  163.     public function getOptionByProduct($request,$id_product){
  164.         $product =  $this->em->getRepository(Product::class)->find($id_product);
  165.         if($product){
  166.             if($product->getIsColorLab()){
  167.                 $productAttributeDefault $this->em->getRepository(ProductAttribute::class)->findOneBy(['product'=>$product->getId(),'isDefault'=>1]);
  168.                 $types $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_FORMAT,null,null,null,null,null,null,null,null,null);
  169.                 $type null;
  170.                 $qtys $qty null;
  171.                 $specificites $specificite null;
  172.                 $typeImpression =  $typeImpressions null ;
  173.                 $formats $format null;
  174.                 $couleurs $couleur null;
  175.                 $supportSuspensions $supportSuspension null;
  176.                 $typeCartons $typeCarton null;
  177.                 $oeilles $oeille null;
  178.                 $tailles $taille null;
  179.                 $zoneImpressions $zoneImpression null;
  180.                 $nbrCouleurs $nbrCouleur null;
  181.                 $gramages $gramage null;
  182.                 $finition null;
  183.                 $isFinitionGlace null;
  184.                 $isFinitionMate null;
  185.                 $isFinitionTransparent null;
  186.                 $isFinitionRepositionalble null;
  187.                 $isFinitionSoftTouch null;
  188.                 $isFinitionPelliculemat null;
  189.                 $isFinitionPelliculeBrillant null;
  190.                 $verification null;
  191.                 $bordsArrondis null;
  192.                 $plastification null;
  193.                 $formatL 100;
  194.                 $formatH 100;
  195.                 if($types){
  196.                     if($productAttributeDefault){
  197.                         $type =   $productAttributeDefault->getTypeFormat()->getId();
  198.                     }else {
  199.                         $type $types[0];
  200.                     }
  201.                     $formats $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,$type['id'],null,null,null,null,null);
  202.                     $specificites $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SPECIFICITE,null,null,null,$type['id'],null,null,null,null,null);
  203.                     if($types && in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
  204.                         $isFinitionGlace $type['isFinitionGlasse'];
  205.                         $isFinitionMate $type['isFinitionMate'];
  206.                         $isFinitionRepositionalble $type['isFinitionRepositionalble'];
  207.                         $isFinitionTransparent $type['isFinitionTransparent'];
  208.                         $isFinitionSoftTouch $type['isFinitionSoftTouch'];
  209.                         $isFinitionPelliculemat $type['isFinitionPelliculemat'];
  210.                         $isFinitionPelliculeBrillant $type['isFinitionPelliculeBrillant'];
  211.                         if( $isFinitionGlace ){
  212.                             $finition CartDetail::FINITION_GLACE;
  213.                         }elseif ($isFinitionMate){
  214.                             $finition CartDetail::FINITION_MATE;
  215.                         }elseif ($isFinitionRepositionalble){
  216.                             $finition CartDetail::FINITION_REPOSITIONALBLE;
  217.                         }elseif ($isFinitionTransparent){
  218.                             $finition CartDetail::FINITION_TRANSPARENT;
  219.                         }elseif ($isFinitionSoftTouch){
  220.                             $finition CartDetail::FINITION_SoftTouch;
  221.                         }elseif ($isFinitionPelliculemat){
  222.                             $finition CartDetail::FINITION_Pelliculemat;
  223.                         }elseif ($isFinitionTransparent){
  224.                             $finition CartDetail::FINITION_TRANSPARENT;
  225.                         }else{
  226.                             $finition null;
  227.                         }
  228.                         $verification CartDetail::VERIFICATION_CHECKED;
  229.                         $bordsArrondis CartDetail::BORDS_ARRONDIS_NOT_CHECKED;
  230.                         $plastification CartDetail::PLASTIFICATION_NOT_CHECKED;
  231.                     }else{
  232.                         if($formats){
  233.                             if($productAttributeDefault){
  234.                                 $format =   $productAttributeDefault->getFormat()->getId();
  235.                             }else {
  236.                                 $format $formats[0];
  237.                             }
  238.                             $isFinitionGlace $format['isFinitionGlasse'];
  239.                             $isFinitionMate $format['isFinitionMate'];
  240.                             $isFinitionRepositionalble $format['isFinitionRepositionalble'];
  241.                             $isFinitionTransparent $format['isFinitionTransparent'];
  242.                             $isFinitionSoftTouch $format['isFinitionSoftTouch'];
  243.                             $isFinitionPelliculemat $format['isFinitionPelliculemat'];
  244.                             $isFinitionPelliculeBrillant $format['isFinitionPelliculeBrillant'];
  245.                             if( $isFinitionGlace ){
  246.                                 $finition CartDetail::FINITION_GLACE;
  247.                             }elseif ($isFinitionMate){
  248.                                 $finition CartDetail::FINITION_MATE;
  249.                             }elseif ($isFinitionRepositionalble){
  250.                                 $finition CartDetail::FINITION_REPOSITIONALBLE;
  251.                             }elseif ($isFinitionTransparent){
  252.                                 $finition CartDetail::FINITION_TRANSPARENT;
  253.                             }elseif ($isFinitionSoftTouch){
  254.                                 $finition CartDetail::FINITION_SoftTouch;
  255.                             }elseif ($isFinitionPelliculemat){
  256.                                 $finition CartDetail::FINITION_Pelliculemat;
  257.                             }elseif ($isFinitionTransparent){
  258.                                 $finition CartDetail::FINITION_TRANSPARENT;
  259.                             }else{
  260.                                 $finition null;
  261.                             }
  262.                             $verification CartDetail::VERIFICATION_CHECKED;
  263.                             $bordsArrondis CartDetail::BORDS_ARRONDIS_NOT_CHECKED;
  264.                             $plastification CartDetail::PLASTIFICATION_NOT_CHECKED;
  265.                         }
  266.                     }
  267.                     if($specificites){
  268.                         if($productAttributeDefault){
  269.                             $specificite =   $productAttributeDefault->getSpecificite()->getId();
  270.                         }else {
  271.                             $specificite $specificites[0];
  272.                         }
  273.                     }
  274.                     $couleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format['id']:null,null,null,$type['id'],$specificite?$specificite['id']:null,null,null,null,null);
  275.                     if($couleurs){
  276.                         if($productAttributeDefault){
  277.                             $couleur =   $productAttributeDefault->getTypeCouleur()->getId();
  278.                         }else {
  279.                             $couleur $couleurs[0];
  280.                         }
  281.                     }
  282.                     $tailles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format['id']:null,null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,null,null,null);
  283.                     if($tailles){
  284.                         if($productAttributeDefault){
  285.                             $taille =   $productAttributeDefault->getTaille()->getId();
  286.                         }else {
  287.                             $taille $tailles[0];
  288.                         }
  289.                     }
  290.                     $zoneImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format['id']:null,null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,null,null);
  291.                     if($zoneImpressions){
  292.                         if($productAttributeDefault){
  293.                             $zoneImpression =   $productAttributeDefault->getZoneImpression()->getId();
  294.                         }else {
  295.                             $zoneImpression $zoneImpressions[0];
  296.                         }
  297.                     }
  298.                     $nbrCouleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format['id']:null,null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,null);
  299.                     if($nbrCouleurs){
  300.                         if($productAttributeDefault){
  301.                             $nbrCouleur =   $productAttributeDefault->getNbrCouleur()->getId();
  302.                         }else {
  303.                             $nbrCouleur $nbrCouleurs[0];
  304.                         }
  305.                     }
  306.                     $gramages $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format['id']:null,null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  307.                     if($gramages){
  308.                         if($productAttributeDefault){
  309.                             $gramage =   $productAttributeDefault->getGramage()->getId();
  310.                         }else {
  311.                             $gramage $gramages[0];
  312.                         }
  313.                     }
  314.                     $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format['id']:null,$gramage?$gramage['id']:null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  315.                     if($supportSuspensions){
  316.                         if($productAttributeDefault){
  317.                             $supportSuspension =   $productAttributeDefault->getSupportSuspension()->getId();
  318.                         }else {
  319.                             $supportSuspension $supportSuspensions[0];
  320.                         }
  321.                     }
  322.                     $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format['id']:null,$gramage?$gramage['id']:null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  323.                     if($typeImpressions){
  324.                         if($productAttributeDefault){
  325.                             $typeImpression =   $productAttributeDefault->getTypeImpression()->getId();
  326.                         }else {
  327.                             $typeImpression $typeImpressions[0];
  328.                         }
  329.                     }
  330.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  331.                     if($typeCartons){
  332.                         if($productAttributeDefault){
  333.                             $typeCarton =   $productAttributeDefault->gettypeCarton()->getId();
  334.                         }else {
  335.                             $typeCarton $typeCartons[0];
  336.                         }
  337.                     }
  338.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
  339.                     if($oeilles){
  340.                         if($productAttributeDefault){
  341.                             $oeille =   $productAttributeDefault->getOeille()->getId();
  342.                         }else {
  343.                             $oeille $oeilles[0];
  344.                         }
  345.                     }
  346.                     $qtys1 $this->getQtyPosible($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
  347.                     $qty = isset($qtys1['qtys'][0]['qty'])?$qtys1['qtys'][0]['qty']:null;
  348.                     $qtys $this->getQantityVitrophonies($product,$qtys1['qtys'],$formatL,$formatH);
  349.                     $qtysPlus $this->getQantityVitrophonies($product,$qtys1['qtysPlus'],$formatL,$formatH);
  350.                     $qtysTeam $this->getQantityVitrophonies($product,$qtys1['qtysTeam'],$formatL,$formatH);
  351.                 }
  352.                 return  array(
  353.                     'product' => $product,
  354.                     'types' => $types,
  355.                     'type' => $type,
  356.                     'formats' => $formats,
  357.                     'format' => $format,
  358.                     'specificites' => $specificites,
  359.                     'specificite' => $specificite,
  360.                     'couleurs' => $couleurs,
  361.                     'couleur' => $couleur,
  362.                     'tailles' => $tailles,
  363.                     'taille' => $taille,
  364.                     'zoneImpressions' => $zoneImpressions,
  365.                     'zoneImpression' => $zoneImpression,
  366.                     'nbrCouleurs' => $nbrCouleurs,
  367.                     'nbrCouleur' => $nbrCouleur,
  368.                     'typeImpressions' => $typeImpressions,
  369.                     'typeImpression' => $typeImpression,
  370.                     'supportSuspensions' => $supportSuspensions,
  371.                     'supportSuspension' => $supportSuspension,
  372.                     'typeCartons' => $typeCartons,
  373.                     'typeCarton' => $typeCarton,
  374.                     'oeilles' => $oeilles,
  375.                     'oeille' => $oeille,
  376.                     'gramages' => $gramages,
  377.                     'gramage' => $gramage,
  378.                     'isFinitionGlace' => $isFinitionGlace,
  379.                     'isFinitionMate' => $isFinitionMate,
  380.                     'isFinitionRepositionalble' => $isFinitionRepositionalble,
  381.                     'isFinitionTransparent' => $isFinitionTransparent,
  382.                     'isFinitionSoftTouch' => $isFinitionSoftTouch,
  383.                     'isFinitionPelliculemat' => $isFinitionPelliculemat,
  384.                     'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
  385.                     'finition' => $finition,
  386.                     'verification' => $verification,
  387.                     'bordsArrondis' => $bordsArrondis,
  388.                     'plastification' => $plastification,
  389.                     'formatL' => $formatL,
  390.                     'formatH' => $formatH,
  391.                     'qtys' => $qtys,
  392.                     'qtysPlus' => $qtysPlus,
  393.                     'qtysTeam' => $qtysTeam,
  394.                     'qty' => $qty,
  395.                     'price' => $this->getPriceColorLab($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$qty,null,null,null,null,null,null,null,$supportSuspension,$formatL,$formatH,$typeCarton,$oeille),
  396.                 );
  397.             }
  398.             else{
  399.                 $typeImpression_id null;
  400.                 $productAttributeDefault $this->em->getRepository(ProductAttribute::class)->findOneBy(['product'=>$product->getId(),'isDefault'=>1]);
  401.                 $formats $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,null,null,null,null,null,null);
  402.                 if($productAttributeDefault){
  403.                     $format_id =  $productAttributeDefault->getFormat()->getId();
  404.                     foreach ($formats as $formatItem){
  405.                         if($formatItem['id'] == $format_id){
  406.                             $format $formatItem;
  407.                         }
  408.                     }
  409.                     $rectoverso $productAttributeDefault->getRectoverso();
  410.                 }else{
  411.                     if($product->getTypeProduct() == Product::CARTE){
  412.                         $format = isset($formats[1]) ? $formats[1] : $formats[0] ;
  413.                     }else{
  414.                         $format $formats[0];
  415.                     }
  416.                     $format_id $format['id'];
  417.                     if($product->getIsRecto()){
  418.                         $rectoverso ProductAttribute::RECTO;
  419.                     }elseif ($product->getIsRectoVerso()){
  420.                         $rectoverso ProductAttribute::VERSO;
  421.                     }else{
  422.                         $rectoverso ProductAttribute::RECTO;
  423.                     }
  424.                 }
  425.                 $isFinitionGlace $format['isFinitionGlasse'];
  426.                 $isFinitionMate $format['isFinitionMate'];
  427.                 $isFinitionRepositionalble $format['isFinitionRepositionalble'];
  428.                 $isFinitionTransparent $format['isFinitionTransparent'];
  429.                 $isFinitionSoftTouch $format['isFinitionSoftTouch'];
  430.                 $isFinitionPelliculemat $format['isFinitionPelliculemat'];
  431.                 $isFinitionPelliculeBrillant $format['isFinitionPelliculeBrillant'];
  432.                 if( $isFinitionGlace ){
  433.                     $finition CartDetail::FINITION_GLACE;
  434.                 }elseif ($isFinitionMate){
  435.                     $finition CartDetail::FINITION_MATE;
  436.                 }elseif ($isFinitionRepositionalble){
  437.                     $finition CartDetail::FINITION_REPOSITIONALBLE;
  438.                 }elseif ($isFinitionTransparent){
  439.                     $finition CartDetail::FINITION_TRANSPARENT;
  440.                 }elseif ($isFinitionSoftTouch){
  441.                     $finition CartDetail::FINITION_SoftTouch;
  442.                 }elseif ($isFinitionPelliculemat){
  443.                     $finition CartDetail::FINITION_Pelliculemat;
  444.                 }elseif ($isFinitionPelliculeBrillant){
  445.                     $finition CartDetail::FINITION_PelliculeBrillant;
  446.                 }else{
  447.                     $finition null;
  448.                 }
  449.                 if($product && $product->getTypeProduct()== Product::AFFICHE){
  450.                     $typeImpression $this->getTypeImpression($id_product,$format_id);
  451.                     $typeImpression_id = isset($typeImpression[0]['id'])?$typeImpression[0]['id']:null;
  452.                     $gramage $this->getGrammageByTypeImpression($id_product,$format_id,$typeImpression_id);
  453.                     if($productAttributeDefault) {
  454.                         $gramage_id $productAttributeDefault->getGramage()->getId();
  455.                     }else{
  456.                         $gramage_id = isset($gramage[0]['id']) ? $gramage[0]['id'] : null;
  457.                     }
  458.                     $qtys = isset($gramage[0]['id']) ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id,$format_id,$typeImpression_id,ProductAttribute::SANS_PLASTIFICATION,$finition):array();
  459.                 }else{
  460.                     $gramage $this->getGramage($id_product,$format_id,$rectoverso);
  461.                     if($productAttributeDefault) {
  462.                         $gramage_id $productAttributeDefault->getGramage()->getId();
  463.                     }else{
  464.                         $gramage_id = isset($gramage[0]['id']) ? $gramage[0]['id'] : null;
  465.                     }
  466.                     $qtys = isset($gramage[0]['id'])?$this->getQtyPosibleByGrammage($gramage_id,$format_id,$rectoverso,$finition):array();
  467.                     $typeImpression false;
  468.                 }
  469.                 $qty = isset($qtys['qtys'][0]['qty'])?$qtys['qtys'][0]['qty']:null;
  470.                 $isEnveloppe false;
  471.                 $verification CartDetail::VERIFICATION_CHECKED;
  472.                 $bordsArrondis CartDetail::BORDS_ARRONDIS_NOT_CHECKED;
  473.                 $plastification CartDetail::PLASTIFICATION_NOT_CHECKED;
  474.                 return array(
  475.                     'isFinitionGlace' => $isFinitionGlace,
  476.                     'isFinitionMate' => $isFinitionMate,
  477.                     'isFinitionTransparent' => $isFinitionTransparent,
  478.                     'isFinitionRepositionalble' => $isFinitionRepositionalble,
  479.                     'isFinitionSoftTouch' => $isFinitionSoftTouch,
  480.                     'isFinitionPelliculemat' => $isFinitionPelliculemat,
  481.                     'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
  482.                     'formats' => $formats,
  483.                     'format_id' => $format_id,
  484.                     'format' => $format,
  485.                     'gramage' => $gramage,
  486.                     'gramage_id' => $gramage_id,
  487.                     'typeImpression' => $typeImpression,
  488.                     'typeImpression_id' => $typeImpression_id,
  489.                     'qtys' => $qtys['qtys'],
  490.                     'qtysPlus' => $qtys['qtysPlus'],
  491.                     'qtysTeam' => $qtys['qtysTeam'],
  492.                     'qty' => $qty,
  493.                     'id_product' => $id_product,
  494.                     'product' => $product,
  495.                     'rectoverso' => $rectoverso,
  496.                     'finition' => $finition,
  497.                     'isEnveloppe' => $isEnveloppe,
  498.                     'verification' => $verification,
  499.                     'bordsArrondis' => $bordsArrondis,
  500.                     'plastification' => $plastification,
  501.                     'price' => $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,$isEnveloppe,false,false,ProductAttribute::SANS_PLASTIFICATION,null,null,null,null,null,null,null,$verification,$bordsArrondis,$plastification),
  502.                 );
  503.             }
  504.         }
  505.         return array();
  506.     }
  507.     // get next option  and price by product colorLab
  508.     public function getNextOptionByProduct($request,$idProduct,$typeAttribute,$valueAttribute){
  509.         $product =  $this->em->getRepository(Product::class)->find($idProduct);
  510.         $requestData $request->request->all();
  511.         $typeFormatId = isset($requestData['typeFormat'])? $requestData['typeFormat'] : null;
  512.         $formatId = isset($requestData['format'])? $requestData['format'] : null;
  513.         $specificiteId = isset($requestData['specificite'])? $requestData['specificite'] : null;
  514.         $couleurId = isset($requestData['couleur'])? $requestData['couleur'] : null;
  515.         $tailleId = isset($requestData['taille'])? $requestData['taille'] : null;
  516.         $zoneImpressionId = isset($requestData['zoneImpression'])? $requestData['zoneImpression'] : null;
  517.         $nbrCouleurId = isset($requestData['nbrCouleur'])? $requestData['nbrCouleur'] : null;
  518.         $supportSuspensionId = isset($requestData['supportSuspension'])? $requestData['supportSuspension'] : null;
  519.         $typeCartonId = isset($requestData['typeCarton'])? $requestData['typeCarton'] : null;
  520.         $oeilleId = isset($requestData['oeille'])? $requestData['oeille'] : null;
  521.         $typeImpressionId = isset($requestData['typeImpression'])? $requestData['typeImpression'] : null;
  522.         $gramageId = isset($requestData['gramage'])? $requestData['gramage'] : null;
  523.         $verification = isset($requestData['verification'])? $requestData['verification'] : null;
  524.         $bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : null;
  525.         $plastification = isset($requestData['plastification'])? $requestData['plastification'] : null;
  526.         $finition = isset($requestData['finition'])? $requestData['finition'] : null;
  527.         $formatL = isset($requestData['formatL'])? $requestData['formatL'] : 100;
  528.         $formatH = isset($requestData['formatH'])? $requestData['formatH'] : 100;
  529.         $isFinitionGlace null;
  530.         $isFinitionMate null;
  531.         $isFinitionTransparent null;
  532.         $isFinitionRepositionalble null;
  533.         $isFinitionSoftTouch null;
  534.         $isFinitionPelliculemat null;
  535.         $isFinitionPelliculeBrillant null;
  536.         if($product){
  537.             if($product->getIsColorLab()){
  538.                 $blockdescriptionProduct null;
  539.                 $type $types null;
  540.                 $specificites $specificite null;
  541.                 $formats $format null;
  542.                 $couleurs $couleur null;
  543.                 $tailles $taille null;
  544.                 $zoneImpressions $zoneImpression null;
  545.                 $nbrCouleurs $nbrCouleur null;
  546.                 $typeImpressions $typeImpression null;
  547.                 $supportSuspensions $supportSuspension null;
  548.                 $typeCartons $typeCarton null;
  549.                 $oeilles $oeille null;
  550.                 $gramages $gramage null;
  551.                 $isFinitionGlace null;
  552.                 $isFinitionMate null;
  553.                 if($typeAttribute == Attribut::TYPE_FORMAT){
  554.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
  555.                     $formats $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,$type?$type->getId():null,null,null,null,null,null);
  556.                     $specificites $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SPECIFICITE,null,null,null,$type?$type->getId():null,null,null,null,null,null);
  557.                     if($type && in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
  558.                         $isFinitionGlace $type->getIsFinitionGlasse();
  559.                         $isFinitionMate $type->getIsFinitionMate();
  560.                         $isFinitionTransparent $type->getIsFinitionTransparent();
  561.                         $isFinitionRepositionalble $type->getIsFinitionRepositionalble();
  562.                         $isFinitionSoftTouch $type->getIsFinitionSoftTouch();
  563.                         $isFinitionPelliculemat $type->getIsFinitionPelliculemat();
  564.                         $isFinitionPelliculeBrillant $type->getIsFinitionPelliculeBrillant();
  565.                     }else {
  566.                         if ($formats) {
  567.                             $format $formats[0];
  568.                             $isFinitionGlace $format['isFinitionGlasse'];
  569.                             $isFinitionMate $format['isFinitionMate'];
  570.                             $isFinitionRepositionalble $format['isFinitionRepositionalble'];
  571.                             $isFinitionTransparent $format['isFinitionTransparent'];
  572.                             $isFinitionSoftTouch $format['isFinitionSoftTouch'];
  573.                             $isFinitionPelliculemat $format['isFinitionPelliculemat'];
  574.                             $isFinitionPelliculeBrillant $format['isFinitionPelliculeBrillant'];
  575.                         }
  576.                     }
  577.                     if($specificites){$specificite $specificites[0];}
  578.                     $couleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format['id']:null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,null,null,null,null);
  579.                     if($couleurs){$couleur $couleurs[0];}
  580.                     $tailles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format['id']:null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,null,null,null);
  581.                     if($tailles){$taille $tailles[0];}
  582.                     $zoneImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format['id']:null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,null,null);
  583.                     if($zoneImpressions){$zoneImpression $zoneImpressions[0];}
  584.                     $nbrCouleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format['id']:null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,null);
  585.                     if($nbrCouleurs){$nbrCouleur $nbrCouleurs[0];}
  586.                     $gramages $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format['id']:null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  587.                     if($gramages){$gramage $gramages[0];}
  588.                     $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  589.                     if($supportSuspensions){$supportSuspension $supportSuspensions[0];}
  590.                     $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  591.                     if($typeImpressions){$typeImpression $typeImpressions[0];}
  592.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  593.                     if($typeCartons){$typeCarton $typeCartons[0];}
  594.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
  595.                     if($oeilles){$oeille $oeilles[0];}
  596.                     $blockdescriptionProduct 1;
  597.                 }
  598.                 if($typeAttribute == Attribut::FORMAT){
  599.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  600.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
  601.                     if($format) {
  602.                         $isFinitionGlace $format->getIsFinitionGlasse();
  603.                         $isFinitionMate $format->getIsFinitionMate();
  604.                         $isFinitionRepositionalble $format->getIsFinitionRepositionalble();
  605.                         $isFinitionTransparent $format->getIsFinitionTransparent();
  606.                         $isFinitionSoftTouch $format->getIsFinitionSoftTouch();
  607.                         $isFinitionPelliculemat $format->getIsFinitionPelliculemat();
  608.                         $isFinitionPelliculeBrillant $format->getIsFinitionPelliculeBrillant();
  609.                     }
  610.                     $specificites $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SPECIFICITE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null);
  611.                     if($specificites){$specificite $specificites[0];}
  612.                     $couleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,null,null,null,null);
  613.                     if($couleurs){$couleur $couleurs[0];}
  614.                     $tailles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,null,null,null);
  615.                     if($tailles){$taille $tailles[0];}
  616.                     $zoneImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,null,null);
  617.                     if($zoneImpressions){$zoneImpression $zoneImpressions[0];}
  618.                     $nbrCouleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,null);
  619.                     if($nbrCouleurs){$nbrCouleur $nbrCouleurs[0];}
  620.                     $gramages $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  621.                     if($gramages){$gramage $gramages[0];}
  622.                     $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  623.                     if($supportSuspensions){$supportSuspension $supportSuspensions[0];}
  624.                     $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  625.                     if($typeImpressions){$typeImpression $typeImpressions[0];}
  626.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  627.                     if($typeCartons){$typeCarton $typeCartons[0];}
  628.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
  629.                     if($oeilles){$oeille $oeilles[0];}
  630.                 }
  631.                 if($typeAttribute == Attribut::SPECIFICITE){
  632.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  633.                     $specificite $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
  634.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
  635.                     if($format) {
  636.                         $isFinitionGlace $format->getIsFinitionGlasse();
  637.                         $isFinitionMate $format->getIsFinitionMate();
  638.                     }
  639.                     $couleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,null,null,null,null);
  640.                     if($couleurs){$couleur $couleurs[0];}
  641.                     $tailles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,null,null,null);
  642.                     if($tailles){$taille $tailles[0];}
  643.                     $zoneImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,null,null);
  644.                     if($zoneImpressions){$zoneImpression $zoneImpressions[0];}
  645.                     $nbrCouleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,null);
  646.                     if($nbrCouleurs){$nbrCouleur $nbrCouleurs[0];}
  647.                     $gramages $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  648.                     if($gramages){$gramage $gramages[0];}
  649.                     $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  650.                     if($supportSuspensions){$supportSuspension $supportSuspensions[0];}
  651.                     $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  652.                     if($typeImpressions){$typeImpression $typeImpressions[0];}
  653.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  654.                     if($typeCartons){$typeCarton $typeCartons[0];}
  655.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
  656.                     if($oeilles){$oeille $oeilles[0];}
  657.                 }
  658.                 if($typeAttribute == Attribut::TYPE_COULEUR){
  659.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  660.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
  661.                     if($format) {
  662.                         $isFinitionGlace $format->getIsFinitionGlasse();
  663.                         $isFinitionMate $format->getIsFinitionMate();
  664.                     }
  665.                     $specificite $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
  666.                     $couleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
  667.                     $tailles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,null,null,null);
  668.                     if($tailles){$taille $tailles[0];}
  669.                     $zoneImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,null,null);
  670.                     if($zoneImpressions){$zoneImpression $zoneImpressions[0];}
  671.                     $nbrCouleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,null);
  672.                     if($nbrCouleurs){$nbrCouleur $nbrCouleurs[0];}
  673.                     $gramages $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  674.                     if($gramages){$gramage $gramages[0];}
  675.                     $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  676.                     if($supportSuspensions){$supportSuspension $supportSuspensions[0];}
  677.                     $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  678.                     if($typeImpressions){$typeImpression $typeImpressions[0];}
  679.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeImpression?$typeImpression['id']:null);
  680.                     if($typeCartons){$typeCarton $typeCartons[0];}
  681.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeImpression?$typeImpression['id']:null,$typeCarton?$typeCarton['id']:null);
  682.                     if($oeilles){$oeille $oeilles[0];}
  683.                 }
  684.                 if($typeAttribute == Attribut::TAILLE){
  685.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  686.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
  687.                     if($format) {
  688.                         $isFinitionGlace $format->getIsFinitionGlasse();
  689.                         $isFinitionMate $format->getIsFinitionMate();
  690.                     }
  691.                     $specificite $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
  692.                     $couleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
  693.                     $taille $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
  694.                     $zoneImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,null,null);
  695.                     if($zoneImpressions){$zoneImpression $zoneImpressions[0];}
  696.                     $nbrCouleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,null);
  697.                     if($nbrCouleurs){$nbrCouleur $nbrCouleurs[0];}
  698.                     $gramages $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  699.                     if($gramages){$gramage $gramages[0];}
  700.                     $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
  701.                     if($supportSuspensions){$supportSuspension $supportSuspensions[0];}
  702.                     $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  703.                     if($typeImpressions){$typeImpression $typeImpressions[0];}
  704.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  705.                     if($typeCartons){$typeCarton $typeCartons[0];}
  706.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
  707.                     if($oeilles){$oeille $oeilles[0];}
  708.                 }
  709.                 if($typeAttribute == Attribut::ZONE_IMPRESSION){
  710.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  711.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
  712.                     if($format) {
  713.                         $isFinitionGlace $format->getIsFinitionGlasse();
  714.                         $isFinitionMate $format->getIsFinitionMate();
  715.                     }
  716.                     $specificite $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
  717.                     $couleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
  718.                     $taille $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
  719.                     $zoneImpression $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
  720.                     $nbrCouleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,null);
  721.                     if($nbrCouleurs){$nbrCouleur $nbrCouleurs[0];}
  722.                     $gramages $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur['id']:null);
  723.                     if($gramages){$gramage $gramages[0];}
  724.                     $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur['id']:null);
  725.                     if($supportSuspensions){$supportSuspension $supportSuspensions[0];}
  726.                     $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  727.                     if($typeImpressions){$typeImpression $typeImpressions[0];}
  728.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
  729.                     if($typeCartons){$typeCarton $typeCartons[0];}
  730.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
  731.                     if($oeilles){$oeille $oeilles[0];}
  732.                 }
  733.                 if($typeAttribute == Attribut::NBR_COULEUR){
  734.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  735.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
  736.                     if($format) {
  737.                         $isFinitionGlace $format->getIsFinitionGlasse();
  738.                         $isFinitionMate $format->getIsFinitionMate();
  739.                     }
  740.                     $specificite $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
  741.                     $couleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
  742.                     $taille $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
  743.                     $zoneImpression $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
  744.                     $nbrCouleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
  745.                     $gramages $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
  746.                     if($gramages){$gramage $gramages[0];}
  747.                     $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
  748.                     if($supportSuspensions){$supportSuspension $supportSuspensions[0];}
  749.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension['id']:null);
  750.                     if($typeCartons){$typeCarton $typeCartons[0];}
  751.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
  752.                     if($oeilles){$oeille $oeilles[0];}
  753.                 }
  754.                 if($typeAttribute == Attribut::GRAMMAGE){
  755.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  756.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
  757.                     if($format) {
  758.                         $isFinitionGlace $format->getIsFinitionGlasse();
  759.                         $isFinitionMate $format->getIsFinitionMate();
  760.                     }
  761.                     $specificite $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
  762.                     $couleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
  763.                     $taille $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
  764.                     $zoneImpression $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
  765.                     $nbrCouleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$nbrCouleurId]);
  766.                     $gramage $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=> $gramageId]);
  767.                     $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
  768.                     if($supportSuspensions){$supportSuspension $supportSuspensions[0];}
  769.                     $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension['id']:null);
  770.                     if($typeImpressions){$typeImpression $typeImpressions[0];}
  771.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension['id']:null);
  772.                     if($typeCartons){$typeCarton $typeCartons[0];}
  773.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
  774.                     if($oeilles){$oeille $oeilles[0];}
  775.                 }
  776.                 if($typeAttribute == Attribut::SUPPORT_SUSPENSION){
  777.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  778.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
  779.                     if($format) {
  780.                         $isFinitionGlace $format->getIsFinitionGlasse();
  781.                         $isFinitionMate $format->getIsFinitionMate();
  782.                     }
  783.                     $specificite $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
  784.                     $couleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
  785.                     $taille $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
  786.                     $zoneImpression $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
  787.                     $nbrCouleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$nbrCouleurId]);
  788.                     $gramage $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$gramageId]);
  789.                     $supportSuspension $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$supportSuspensionId]);
  790.                     $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
  791.                     if($typeImpressions){$typeImpression $typeImpressions[0];}
  792.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
  793.                     if($typeCartons){$typeCarton $typeCartons[0];}
  794.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null,$typeCarton?$typeCarton['id']:null);
  795.                     if($oeilles){$oeille $oeilles[0];}
  796.                 }
  797.                 if($typeAttribute == Attribut::TYPE_IMPRESSION){
  798.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  799.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
  800.                     if($format) {
  801.                         $isFinitionGlace $format->getIsFinitionGlasse();
  802.                         $isFinitionMate $format->getIsFinitionMate();
  803.                     }
  804.                     $specificite $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
  805.                     $couleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
  806.                     $taille $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
  807.                     $zoneImpression $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
  808.                     $nbrCouleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$nbrCouleurId]);
  809.                     $gramage $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$gramageId]);
  810.                     $supportSuspension $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$supportSuspensionId]);
  811.                     $typeImpression $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeImpressionId]);
  812.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
  813.                     if($typeCartons){$typeCarton $typeCartons[0];}
  814.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null,$typeCarton?$typeCarton['id']:null);
  815.                     if($oeilles){$oeille $oeilles[0];}
  816.                 }
  817.                 if($typeAttribute == Attribut::TYPE_CARTON){
  818.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  819.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
  820.                     if($format) {
  821.                         $isFinitionGlace $format->getIsFinitionGlasse();
  822.                         $isFinitionMate $format->getIsFinitionMate();
  823.                     }
  824.                     $specificite $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
  825.                     $couleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
  826.                     $taille $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
  827.                     $zoneImpression $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
  828.                     $nbrCouleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$nbrCouleurId]);
  829.                     $gramage $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$gramageId]);
  830.                     $supportSuspension $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$supportSuspensionId]);
  831.                     $typeImpression $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeImpressionId]);
  832.                     $typeCarton $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeCartonId]);
  833.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null,$typeCarton?$typeCarton->getId():null);
  834.                     if($oeilles){$oeille $oeilles[0];}
  835.                 }
  836.                 if($typeAttribute == Attribut::OEILLE){
  837.                     $type $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
  838.                     $format $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
  839.                     if($format) {
  840.                         $isFinitionGlace $format->getIsFinitionGlasse();
  841.                         $isFinitionMate $format->getIsFinitionMate();
  842.                     }
  843.                     $specificite $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
  844.                     $couleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
  845.                     $taille $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
  846.                     $zoneImpression $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
  847.                     $nbrCouleur $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$nbrCouleurId]);
  848.                     $gramage $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$gramageId]);
  849.                     $supportSuspension $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$supportSuspensionId]);
  850.                     $typeImpression $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeImpressionId]);
  851.                     $typeCarton $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeCartonId]);
  852.                     $oeille $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$oeilleId]);
  853.                 }
  854.                 $qtys1 $this->getQtyPosible($idProduct,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
  855.                 $qty = isset($qtys1['qtys'][0]['qty'])?$qtys1['qtys'][0]['qty']:null;
  856.                 $qtys $this->getQantityVitrophonies($product,$qtys1['qtys'],$formatL,$formatH);
  857.                 $qtysPlus $this->getQantityVitrophonies($product,$qtys1['qtysPlus'],$formatL,$formatH);
  858.                 $qtysTeam $this->getQantityVitrophonies($product,$qtys1['qtysTeam'],$formatL,$formatH);
  859.                 return array(
  860.                     'product' => $product,
  861.                     'types' => $types,
  862.                     'type' => $type,
  863.                     'formats' => $formats,
  864.                     'format' => $format,
  865.                     'specificites' => $specificites,
  866.                     'specificite' => $specificite,
  867.                     'couleurs' => $couleurs,
  868.                     'couleur' => $couleur,
  869.                     'tailles' => $tailles,
  870.                     'taille' => $taille,
  871.                     'zoneImpressions' => $zoneImpressions,
  872.                     'zoneImpression' => $zoneImpression,
  873.                     'nbrCouleurs' => $nbrCouleurs,
  874.                     'nbrCouleur' => $nbrCouleur,
  875.                     'supportSuspensions' => $supportSuspensions,
  876.                     'supportSuspension' => $supportSuspension,
  877.                     'typeCartons' => $typeCartons,
  878.                     'typeCarton' => $typeCarton,
  879.                     'typeImpressions' => $typeImpressions,
  880.                     'typeImpression' => $typeImpression,
  881.                     'oeilles' => $oeilles,
  882.                     'oeille' => $oeille,
  883.                     'gramages' => $gramages,
  884.                     'gramage' => $gramage,
  885.                     'qtys' => $qtys,
  886.                     'qtysPlus' => $qtysPlus,
  887.                     'qtysTeam' => $qtysTeam,
  888.                     'qty' => $qty,
  889.                     'isFinitionGlace' => $isFinitionGlace,
  890.                     'isFinitionMate' => $isFinitionMate,
  891.                     'isFinitionRepositionalble' => $isFinitionRepositionalble,
  892.                     'isFinitionTransparent' => $isFinitionTransparent,
  893.                     'isFinitionSoftTouch' => $isFinitionSoftTouch,
  894.                     'isFinitionPelliculemat' => $isFinitionPelliculemat,
  895.                     'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
  896.                     'finition' => $finition,
  897.                     'verification' => $verification ,
  898.                     'bordsArrondis' => $bordsArrondis ,
  899.                     'plastification' => $plastification ,
  900.                     'formatL' => $formatL,
  901.                     'formatH' => $formatH,
  902.                     'blockdescriptionProduct' => $blockdescriptionProduct,
  903.                     'price' => $this->getPriceColorLab($idProduct,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$qty,null,null,null,null,null,null,null,$supportSuspension,$formatL,$formatH,$typeCarton,$oeille),
  904.                 );
  905.             }
  906.         }
  907.         return array();
  908.     }
  909.     // get option and price by product new nb_designer
  910.     public function optionByProductAndFormat($request,$id_product,$format_id){
  911.         $product =  $this->em->getRepository(Product::class)->find($id_product);
  912.         $formats = array();
  913.         if($product){
  914.             $formats $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,null,null,null,null,null,null);
  915.             $format $this->em->getRepository(Attribut::class)->find($format_id);
  916.             $typeImpression_id null;
  917.             if($product->getIsRecto()){
  918.                 $rectoverso ProductAttribute::RECTO;
  919.             }elseif ($product->getIsRectoVerso()){
  920.                 $rectoverso ProductAttribute::VERSO;
  921.             }else{
  922.                 $rectoverso ProductAttribute::RECTO;
  923.             }
  924.             $isFinitionGlace $format->getIsFinitionGlasse();
  925.             $isFinitionMate $format->getIsFinitionMate();
  926.             $isFinitionTransparent $format->getIsFinitionTransparent();
  927.             $isFinitionRepositionalble $format->getIsFinitionRepositionalble();
  928.             $isFinitionSoftTouch $format->getIsFinitionSoftTouch();
  929.             $isFinitionPelliculemat $format->getIsFinitionPelliculemat();
  930.             $isFinitionPelliculeBrillant $format->getIsFinitionPelliculeBrillant();
  931.             if( $isFinitionGlace ){
  932.                 $finition CartDetail::FINITION_GLACE;
  933.             }elseif ($isFinitionMate){
  934.                 $finition CartDetail::FINITION_MATE;
  935.             }elseif ($isFinitionTransparent){
  936.                 $finition CartDetail::FINITION_TRANSPARENT;
  937.             }elseif ($isFinitionRepositionalble){
  938.                 $finition CartDetail::FINITION_REPOSITIONALBLE;
  939.             }elseif ($isFinitionSoftTouch){
  940.                 $finition CartDetail::FINITION_SoftTouch;
  941.             }elseif ($isFinitionPelliculemat){
  942.                 $finition CartDetail::FINITION_Pelliculemat;
  943.             }elseif ($isFinitionPelliculeBrillant){
  944.                 $finition CartDetail::FINITION_PelliculeBrillant;
  945.             }
  946.             else{
  947.                 $finition null;
  948.             }
  949.             $bordsArrondis CartDetail::BORDS_ARRONDIS_NOT_CHECKED;
  950.             $plastification CartDetail::PLASTIFICATION_NOT_CHECKED;
  951.             if($product && $product->getTypeProduct()== Product::AFFICHE){
  952.                 $typeImpression $this->getTypeImpression($id_product,$format_id);
  953.                 $typeImpression_id = isset($typeImpression[0]['id'])?$typeImpression[0]['id']:null;
  954.                 $gramage $this->getGrammageByTypeImpression($id_product,$format_id,$typeImpression_id);
  955.                 $gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
  956.                 $qtys = isset($gramage[0]['id']) ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id,$format_id,$typeImpression_id,ProductAttribute::SANS_PLASTIFICATION,$finition,false,$bordsArrondis,$plastification):array();
  957.             }else{
  958.                 $gramage $this->getGramage($id_product,$format_id,$rectoverso);
  959.                 $gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
  960.                 $qtys = isset($gramage[0]['id'])?$this->getQtyPosibleByGrammage($gramage_id,$format_id,$rectoverso,$finition,$bordsArrondis,$plastification):array();
  961.                 $typeImpression false;
  962.             }
  963.             $qty = isset($qtys['qtys'][0]['qty'])?$qtys['qtys'][0]['qty']:null;
  964.         }
  965.         $isEnveloppe false;
  966.         $verification CartDetail::VERIFICATION_CHECKED;
  967.         return array(
  968.             'isFinitionGlace' => $isFinitionGlace,
  969.             'isFinitionMate' => $isFinitionMate,
  970.             'isFinitionRepositionalble' => $isFinitionRepositionalble,
  971.             'isFinitionTransparent' => $isFinitionTransparent,
  972.             'isFinitionSoftTouch' => $isFinitionSoftTouch,
  973.             'isFinitionPelliculemat' => $isFinitionPelliculemat,
  974.             'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
  975.             'formats' => $formats,
  976.             'format_id' => $format_id,
  977.             'format' => $format,
  978.             'gramage' => $gramage,
  979.             'gramage_id' => $gramage_id,
  980.             'typeImpression' => $typeImpression,
  981.             'typeImpression_id' => $typeImpression_id,
  982.             'qtys' => $qtys['qtys'],
  983.             'qtysPlus' => $qtys['qtysPlus'],
  984.             'qtysTeam' => $qtys['qtysTeam'],
  985.             'qty' => $qty,
  986.             'id_product' => $id_product,
  987.             'product' => $product,
  988.             'rectoverso' => $rectoverso,
  989.             'finition' => $finition,
  990.             'isEnveloppe' => $isEnveloppe,
  991.             'verification' => $verification,
  992.             'bordsArrondis' => $bordsArrondis,
  993.             'plastification' => $plastification,
  994.             'price' => $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,$isEnveloppe,false,false,ProductAttribute::SANS_PLASTIFICATION,null,null,null,null,null,null,null,$verification,$bordsArrondis,$plastification),
  995.         );
  996.     }
  997.     // get option and price by token new nb_designer
  998.     public function getOptionByToken($request,$token){
  999.         $cartDetail =  $this->em->getRepository(CartDetail::class)->findOneBy(array('token'=>$token));
  1000.         if($cartDetail){
  1001.             $product $cartDetail->getProduct();
  1002.             if($product->getIsColorLab()){
  1003.                 $types $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_FORMAT,null,null,null,null,null,null,null,null,null);
  1004.                 $type $cartDetail->getProductAttribute()->getTypeFormat();
  1005.                 $formats $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,$type?$type->getId():null,null,null,null,null,null);
  1006.                 $format $cartDetail->getProductAttribute()->getFormat();
  1007.                 $specificites $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SPECIFICITE,null,null,null,$type?$type->getId():null,null,null,null,null,null);
  1008.                 $specificite $cartDetail->getProductAttribute()->getSpecificite();
  1009.                 $finition $cartDetail->getFinition();
  1010.                 $bordsArrondis $cartDetail->getIsPlusBordsArrondis();
  1011.                 $plastification $cartDetail->getIsPlusPlastification();
  1012.                 $isFinitionGlace null;
  1013.                 $isFinitionMate null;
  1014.                 $isFinitionRepositionalble null;
  1015.                 $isFinitionTransparent null;
  1016.                 $isFinitionSoftTouch null;
  1017.                 $isFinitionPelliculemat null;
  1018.                 $isFinitionPelliculeBrillant null;
  1019.                 $verification null;
  1020.                 $couleur null;
  1021.                 $taille null;
  1022.                 $nbrCouleur null;
  1023.                 $typeImpression null;
  1024.                 $gramage null;
  1025.                 $supportSuspension null;
  1026.                 $typeCarton null;
  1027.                 $oeille null;
  1028.                 $formatL $cartDetail->getFormatLargeur();
  1029.                 $formatH $cartDetail->getFormatHauteur();
  1030.                 if($types && in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
  1031.                     $isFinitionGlace $type->getIsFinitionGlasse();
  1032.                     $isFinitionMate $type->getIsFinitionMate();
  1033.                     $isFinitionTransparent $type->getIsFinitionTransparent();
  1034.                     $isFinitionRepositionalble $type->getIsFinitionRepositionalble();
  1035.                     $isFinitionSoftTouch $type->getIsFinitionSoftTouch();
  1036.                     $isFinitionPelliculemat $type->getIsFinitionPelliculemat();
  1037.                     $isFinitionPelliculeBrillant $type->getIsFinitionPelliculeBrillant();
  1038.                     $verification $cartDetail->getIsPlusVerification();
  1039.                 }else {
  1040.                     if ($formats) {
  1041.                         $format $cartDetail->getProductAttribute()->getFormat();
  1042.                         if ($format) {
  1043.                             $isFinitionGlace $format->getIsFinitionGlasse();
  1044.                             $isFinitionMate $format->getIsFinitionMate();
  1045.                             $isFinitionTransparent $format->getIsFinitionTransparent();
  1046.                             $isFinitionRepositionalble $format->getIsFinitionRepositionalble();
  1047.                             $isFinitionSoftTouch $format->getIsFinitionSoftTouch();
  1048.                             $isFinitionPelliculemat $format->getIsFinitionPelliculemat();
  1049.                             $isFinitionPelliculeBrillant $format->getIsFinitionPelliculeBrillant();
  1050.                             $verification $cartDetail->getIsPlusVerification();
  1051.                         }
  1052.                     }
  1053.                 }
  1054.                 if($specificites){$specificite $cartDetail->getProductAttribute()->getSpecificite();}
  1055.                 $couleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,null,null,null,null);
  1056.                 if($couleurs){$couleur $cartDetail->getProductAttribute()->getTypeCouleur();}
  1057.                 $tailles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,null,null,null);
  1058.                 if($tailles){$taille $cartDetail->getProductAttribute()->getTaille();}
  1059.                 $zoneImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,null,null);
  1060.                 if($zoneImpressions){$zoneImpression $cartDetail->getProductAttribute()->getZoneImpression();}
  1061.                 $nbrCouleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,null);
  1062.                 if($nbrCouleurs){$nbrCouleur $cartDetail->getProductAttribute()->getNbrCouleur();}
  1063.                 $gramages $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
  1064.                 if($gramages){$gramage $cartDetail->getProductAttribute()->getGramage();}
  1065.                 $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
  1066.                 if($supportSuspensions){$supportSuspension $cartDetail->getProductAttribute()->getSupportSuspension();}
  1067.                 $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
  1068.                 if($typeImpressions){$typeImpression $cartDetail->getProductAttribute()->getTypeImpression();}
  1069.                 $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
  1070.                 if($typeCartons){$typeCarton $cartDetail->getProductAttribute()->getTypeCarton();}
  1071.                 $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null,$typeCarton?$typeCarton->getId():null);
  1072.                 if($oeilles){$oeille $cartDetail->getProductAttribute()->getOeille();}
  1073.                 $qtys1 $this->getQtyPosible($product->getId(),$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
  1074.                 $qtys $this->getQantityVitrophonies($product,$qtys1['qtys'],$formatL,$formatH);
  1075.                 $qtysPlus $this->getQantityVitrophonies($product,$qtys1['qtysPlus'],$formatL,$formatH);
  1076.                 $qtysTeam $this->getQantityVitrophonies($product,$qtys1['qtysTeam'],$formatL,$formatH);
  1077.                 return array(
  1078.                     'product' => $product,
  1079.                     'types' => $types,
  1080.                     'type' => $type,
  1081.                     'formats' => $formats,
  1082.                     'format' => $format,
  1083.                     'specificites' => $specificites,
  1084.                     'specificite' => $specificite,
  1085.                     'couleurs' => $couleurs,
  1086.                     'couleur' => $couleur,
  1087.                     'tailles' => $tailles,
  1088.                     'taille' => $taille,
  1089.                     'zoneImpressions' => $zoneImpressions,
  1090.                     'zoneImpression' => $zoneImpression,
  1091.                     'nbrCouleurs' => $nbrCouleurs,
  1092.                     'nbrCouleur' => $nbrCouleur,
  1093.                     'gramages' => $gramages,
  1094.                     'gramage' => $gramage,
  1095.                     'supportSuspensions' => $supportSuspensions,
  1096.                     'supportSuspension' => $supportSuspension,
  1097.                     'typeCartons' => $typeCartons,
  1098.                     'typeCarton' => $typeCarton,
  1099.                     'oeilles' => $oeilles,
  1100.                     'oeille' => $oeille,
  1101.                     'typeImpressions' => $typeImpressions,
  1102.                     'typeImpression' => $typeImpression,
  1103.                     'isFinitionGlace' => $isFinitionGlace,
  1104.                     'isFinitionMate' => $isFinitionMate,
  1105.                     'isFinitionRepositionalble' => $isFinitionRepositionalble,
  1106.                     'isFinitionTransparent' => $isFinitionTransparent,
  1107.                     'isFinitionSoftTouch' => $isFinitionSoftTouch,
  1108.                     'isFinitionPelliculemat' => $isFinitionPelliculemat,
  1109.                     'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
  1110.                     'finition' => $finition,
  1111.                     'verification' => $verification,
  1112.                     'bordsArrondis' => $bordsArrondis ,
  1113.                     'plastification' => $plastification ,
  1114.                     'formatL' => $formatL,
  1115.                     'formatH' => $formatH,
  1116.                     'qtys' => $qtys,
  1117.                     'qtysPlus' => $qtysPlus,
  1118.                     'qtysTeam' => $qtysTeam,
  1119.                     'qty' => $cartDetail->getNbrPapier(),
  1120.                     'price' => $this->getPriceColorLab($product->getId(),$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$cartDetail->getNbrPapier(),null,null,null,null,null,null,null,$supportSuspension,$formatL,$formatH,$typeCarton,$oeille),
  1121.                 );
  1122.             }
  1123.             else {
  1124.                 $id_product $product->getId();
  1125.                 $formats $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,null,null,null,null,null,null);;
  1126.                 $format $cartDetail->getProductAttribute()->getFormat();
  1127.                 $format_id $cartDetail->getProductAttribute()->getFormat()->getId();
  1128.                 $rectoverso $cartDetail->getProductAttribute()->getRectoverso();
  1129.                 $finition $cartDetail->getFinition();
  1130.                 $bordsArrondis $cartDetail->getIsPlusBordsArrondis();
  1131.                 $plastification $cartDetail->getIsPlusPlastification();
  1132.                 $verification $cartDetail->getIsPlusVerification();
  1133.                 $gramage_id $cartDetail->getProductAttribute()->getGramage()->getId();
  1134.                 if ($product && $product->getTypeProduct() == Product::AFFICHE) {
  1135.                     $typeImpression_id $cartDetail->getProductAttribute()->getTypeImpression()->getId();
  1136.                     $typeImpression $this->getTypeImpression($id_product$format_id);
  1137.                     $gramage $this->getGrammageByTypeImpression($id_product$format_id$typeImpression_id);
  1138.                     $qtys $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id$format_id$typeImpression_id$cartDetail->getProductAttribute()->getPlastification(), $finition,false,$bordsArrondis,$plastification);
  1139.                 } else {
  1140.                     $gramage $this->getGramage($id_product$format_id$rectoverso);
  1141.                     $qtys $this->getQtyPosibleByGrammage($gramage_id$format_id$rectoverso$finition,$bordsArrondis,$plastification);
  1142.                     $typeImpression false;
  1143.                     $typeImpression_id false;
  1144.                 }
  1145.                 $isFinitionGlace $format->getIsFinitionGlasse();
  1146.                 $isFinitionMate $format->getIsFinitionMate();
  1147.                 $isFinitionTransparent $format->getIsFinitionTransparent();
  1148.                 $isFinitionRepositionalble $format->getIsFinitionRepositionalble();
  1149.                 $isFinitionSoftTouch $format->getIsFinitionSoftTouch();
  1150.                 $isFinitionPelliculemat $format->getIsFinitionPelliculemat();
  1151.                 $isFinitionPelliculeBrillant $format->getIsFinitionPelliculeBrillant();
  1152.                 $qty $cartDetail->getNbrPapier();
  1153.                 $isEnveloppe $cartDetail->getIsEnveloppe();
  1154.                 return array(
  1155.                     'isFinitionGlace' => $isFinitionGlace,
  1156.                     'isFinitionMate' => $isFinitionMate,
  1157.                     'isFinitionRepositionalble' => $isFinitionRepositionalble,
  1158.                     'isFinitionTransparent' => $isFinitionTransparent,
  1159.                     'isFinitionSoftTouch' => $isFinitionSoftTouch,
  1160.                     'isFinitionPelliculemat' => $isFinitionPelliculemat,
  1161.                     'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
  1162.                     'formats' => $formats,
  1163.                     'format_id' => $format_id,
  1164.                     'format' => $format,
  1165.                     'gramage' => $gramage,
  1166.                     'gramage_id' => $gramage_id,
  1167.                     'typeImpression' => $typeImpression,
  1168.                     'typeImpression_id' => $typeImpression_id,
  1169.                     'qtys' => $qtys['qtys'],
  1170.                     'qtysPlus' => $qtys['qtysPlus'],
  1171.                     'qtysTeam' => $qtys['qtysTeam'],
  1172.                     'qty' => $qty,
  1173.                     'id_product' => $id_product,
  1174.                     'product' => $product,
  1175.                     'rectoverso' => $rectoverso,
  1176.                     'finition' => $finition,
  1177.                     'isEnveloppe' => $isEnveloppe,
  1178.                     'verification' => $verification,
  1179.                     'bordsArrondis' => $bordsArrondis,
  1180.                     'plastification' => $plastification,
  1181.                     'price' => $this->getPrice($id_product$format_id$gramage_id$typeImpression_id$rectoverso$qty$finition$isEnveloppefalsefalse$cartDetail->getProductAttribute()->getPlastification(), nullnullnullnullnullnullnull$verification,$bordsArrondis,$plastification),
  1182.                 );
  1183.             }
  1184.         }
  1185.        return [];
  1186.     }
  1187.     // get option and price by format  new nb_designer
  1188.     public function getOptionByformat($request,$id_product,$format_id,$isEnveloppe=false,$rectoverso=null,$typeImpression_id=null){
  1189.         $product =  $this->em->getRepository(Product::class)->find($id_product);
  1190.         if($product){
  1191.             $formats $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,null,null,null,null,null,null);
  1192.             if($rectoverso){
  1193.             }else {
  1194.                 if ($product->getIsRecto()) {
  1195.                     $rectoverso ProductAttribute::RECTO;
  1196.                 } elseif ($product->getIsRectoVerso()) {
  1197.                     $rectoverso ProductAttribute::VERSO;
  1198.                 } else {
  1199.                     $rectoverso ProductAttribute::RECTO;
  1200.                 }
  1201.             }
  1202.             $format $this->em->getRepository(Attribut::class)->find($format_id);
  1203.             $isFinitionGlace $format->getIsFinitionGlasse();
  1204.             $isFinitionMate $format->getIsFinitionMate();
  1205.             $isFinitionTransparent $format->getIsFinitionTransparent();
  1206.             $isFinitionRepositionalble $format->getIsFinitionRepositionalble();
  1207.             $isFinitionSoftTouch $format->getIsFinitionSoftTouch();
  1208.             $isFinitionPelliculemat $format->getIsFinitionPelliculemat();
  1209.             $isFinitionPelliculeBrillant $format->getIsFinitionPelliculeBrillant();
  1210.             if( $isFinitionGlace ){
  1211.                 $finition CartDetail::FINITION_GLACE;
  1212.             }elseif ($isFinitionMate){
  1213.                 $finition CartDetail::FINITION_MATE;
  1214.             }elseif ($isFinitionTransparent){
  1215.                 $finition CartDetail::FINITION_TRANSPARENT;
  1216.             }elseif ($isFinitionRepositionalble){
  1217.                 $finition CartDetail::FINITION_REPOSITIONALBLE;
  1218.             }elseif ($isFinitionSoftTouch){
  1219.                 $finition CartDetail::FINITION_SoftTouch;
  1220.             }elseif ($isFinitionPelliculemat){
  1221.                 $finition CartDetail::FINITION_Pelliculemat;
  1222.             }elseif ($isFinitionPelliculeBrillant){
  1223.                 $finition CartDetail::FINITION_PelliculeBrillant;
  1224.             }else{
  1225.                 $finition null;
  1226.             }
  1227.             $bordsArrondis CartDetail::BORDS_ARRONDIS_NOT_CHECKED;
  1228.             $plastification CartDetail::PLASTIFICATION_NOT_CHECKED;
  1229.             if($product && $product->getTypeProduct()== Product::AFFICHE){
  1230.                 $typeImpression $this->em->getRepository(Attribut::class)->find($typeImpression_id);
  1231.                 $gramage $this->getGrammageByTypeImpression($id_product,$format_id,$typeImpression_id);
  1232.                 $gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
  1233.                 $qtys = isset($gramage[0]['id']) ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id,$format_id,$typeImpression_id,ProductAttribute::SANS_PLASTIFICATION,$finition,false,$bordsArrondis):array();
  1234.             }else{
  1235.                 $gramage $this->getGramage($id_product,$format_id,$rectoverso);
  1236.                 $gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
  1237.                 $qtys = isset($gramage[0]['id'])?$this->getQtyPosibleByGrammage($gramage_id,$format_id,$rectoverso,$finition,$bordsArrondis,$plastification):array();
  1238.                 $typeImpression false;
  1239.             }
  1240.             $qty = isset($qtys['qtys'][0]['qty'])?$qtys['qtys'][0]['qty']:null;
  1241.         }
  1242.         $verification CartDetail::VERIFICATION_CHECKED;
  1243.         return array(
  1244.             'isFinitionGlace' => $isFinitionGlace,
  1245.             'isFinitionMate' => $isFinitionMate,
  1246.             'isFinitionRepositionalble' => $isFinitionRepositionalble,
  1247.             'isFinitionTransparent' => $isFinitionTransparent,
  1248.             'isFinitionSoftTouch' => $isFinitionSoftTouch,
  1249.             'isFinitionPelliculemat' => $isFinitionPelliculemat,
  1250.             'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
  1251.             'format_id' => $format_id,
  1252.             'formats' => $formats,
  1253.             'format' => $format,
  1254.             'gramage' => $gramage,
  1255.             'gramage_id' => $gramage_id,
  1256.             'typeImpression' => $typeImpression,
  1257.             'typeImpression_id' => $typeImpression_id,
  1258.             'qtys' => $qtys['qtys'],
  1259.             'qtysPlus' => $qtys['qtysPlus'],
  1260.             'qtysTeam' => $qtys['qtysTeam'],
  1261.             'qty' => $qty,
  1262.             'id_product' => $id_product,
  1263.             'product' => $product,
  1264.             'rectoverso' => $rectoverso,
  1265.             'finition' => $finition,
  1266.             'isEnveloppe' => $isEnveloppe,
  1267.             'verification' => $verification,
  1268.             'bordsArrondis' => $bordsArrondis,
  1269.             'plastification' => $plastification,
  1270.             'price' => $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,$isEnveloppe,false,false,ProductAttribute::SANS_PLASTIFICATION,null,null,null,null,null,null,null,$verification,$bordsArrondis,$plastification),
  1271.         );
  1272.     }
  1273.     // get grammage and price by TypeImpression RectoVerso new nb_designer
  1274.     public function getGramgeByTypeImpressionOrRectoVerso($request,$id_product,$format_id,$rectoverso,$finition,$typeImpression_id=null,$isEnveloppe=false,$verification=CartDetail::VERIFICATION_NOT_CHECKED,$bordsArrondisCartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification CartDetail::PLASTIFICATION_NOT_CHECKED){
  1275.         $product =  $this->em->getRepository(Product::class)->find($id_product);
  1276.         if($product){
  1277.             if($product && $product->getTypeProduct()== Product::AFFICHE){
  1278.                 $gramage $this->getGrammageByTypeImpression($id_product,$format_id,$typeImpression_id);
  1279.                 $gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
  1280.                 $qtys = isset($gramage[0]['id']) ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id,$format_id,$typeImpression_id,ProductAttribute::SANS_PLASTIFICATION,$finition):array();
  1281.             }else{
  1282.                 $gramage $this->getGramage($id_product,$format_id,$rectoverso);
  1283.                 $gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
  1284.                 $qtys = isset($gramage[0]['id'])?$this->getQtyPosibleByGrammage($gramage_id,$format_id,$rectoverso,$finition):array();
  1285.             }
  1286.             $qty = isset($qtys['qtys'][0]['qty'])?$qtys['qtys'][0]['qty']:null;
  1287.         }
  1288.         return array(
  1289.             'format_id' => $format_id,
  1290.             'format' => $this->em->getRepository(Attribut::class)->find($format_id),
  1291.             'gramage' => $gramage,
  1292.             'gramage_id' => $gramage_id,
  1293.             'typeImpression_id' => $typeImpression_id,
  1294.             'qtys' => $qtys['qtys'],
  1295.             'qtysPlus' => $qtys['qtysPlus'],
  1296.             'qtysTeam' => $qtys['qtysTeam'],
  1297.             'qty' => $qty,
  1298.             'id_product' => $id_product,
  1299.             'product' => $product,
  1300.             'rectoverso' => $rectoverso,
  1301.             'finition' => $finition,
  1302.             'isEnveloppe' => $isEnveloppe,
  1303.             'verification' => $verification,
  1304.             'bordsArrondis' => $bordsArrondis,
  1305.             'plastification' => $plastification,
  1306.             'price' => $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,false,false,false,ProductAttribute::SANS_PLASTIFICATION,null,null,null,null,null,null,null,$verification,$bordsArrondis,$plastification),
  1307.         );
  1308.     }
  1309.     public function getDetailLivraison($carrierId,$typeLivraisonNational null,$typeLivraison30min null,$adresseCarrier null,$imprimeurLivraison,$dateLivraison null,$timeLivraison null){
  1310.         $data = [];
  1311.         if($carrierId && $imprimeurLivraison){
  1312.             $carrier $this->em->getRepository(Carrier::class)->find($carrierId);
  1313.             $imprimeur $this->em->getRepository(Imprimeur::class)->find($imprimeurLivraison);
  1314.             $carrierNationalJ1 $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J1));
  1315.             $carrierNationalJ2 $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J2));
  1316.             $carrierNationalJ5 $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J5));
  1317.             $carrier30MIN $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::STUART));
  1318.             $carrierRetrait $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::RETRAIT));
  1319.             $data['num'] =  $carrier->getNum();
  1320.             if($carrier == $carrierRetrait){
  1321.                 $data['name'] = $carrier->getName();
  1322.                 $data['adresse'] = $imprimeur->getName().' '.$imprimeur->getAddress();
  1323.             }else if($carrier == $carrier30MIN){
  1324.                 $data['name'] = $carrier->getName();
  1325.                 $data['adresse'] = $adresseCarrier;
  1326.                 if($timeLivraison && $dateLivraison){
  1327.                     $date = new \DateTime($dateLivraison);
  1328.                     $time explode(' - '$timeLivraison);
  1329.                     $dateNow = new \DateTime('now', new \DateTimeZone('Europe/Paris'));
  1330.                     if($date){
  1331.                         $dayJourDispo $date->format('d');
  1332.                         if($dateNow->format('d') == $dayJourDispo){
  1333.                             $dayName 'Aujourd’hui';
  1334.                         }else if($dateNow->modify('+1 day')->format('d') == $dayJourDispo){
  1335.                             $dayName 'Demain';
  1336.                         }else if($dateNow->modify('+1 day')->format('d') == $dayJourDispo){
  1337.                             $dayName 'Après-demain';
  1338.                         }else{
  1339.                             $dayNameFormat = new \IntlDateFormatter('fr', \IntlDateFormatter::LONG, \IntlDateFormatter::NONEnullnull'EEEE');
  1340.                             $dayName $dayNameFormat->format($date);
  1341.                         }
  1342.                     }
  1343.                     $data['livraisonJour'] = $dayName .' entre '.$time[0].' et '.$time[0];
  1344.                     $data['livraisonJour2'] = $date->format('d/m/Y') .', '.$time[0].'-'.$time[0];
  1345.                 }
  1346.             }else if($carrier == $carrierNationalJ1 || $carrier == $carrierNationalJ2){
  1347.                 $data['name'] = $carrier->getName();
  1348.                 $data['adresse'] = $adresseCarrier;
  1349.             }else if($carrier == $carrierNationalJ5){
  1350.                 $data['name'] = $carrier->getName();
  1351.                 $data['adresse'] = $adresseCarrier;
  1352.             }
  1353.         }
  1354.         return $this->twig->render('front/product-option/detail-livraison.html.twig',$data);
  1355.     }
  1356.     public function getJourLivraison($carrierId,$typeLivraisonNational null,$typeLivraison30min null,$adresseCarrier null,$imprimeurLivraison,$dateLivraison null,$timeLivraison null){
  1357.         $data = [];
  1358.         if($carrierId && $imprimeurLivraison){
  1359.             $carrier $this->em->getRepository(Carrier::class)->find($carrierId);
  1360.             $imprimeur $this->em->getRepository(Imprimeur::class)->find($imprimeurLivraison);
  1361.             $carrierNationalJ1 $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J1));
  1362.             $carrierNationalJ2 $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J2));
  1363.             $carrier30MIN $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::STUART));
  1364.             $carrierRetrait $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::RETRAIT));
  1365.             if($carrier == $carrierRetrait){
  1366.                 $data['date'] = null;
  1367.                 $data['time'] = null;
  1368.             }else if($carrier == $carrier30MIN){
  1369.                 $data['name'] = $carrier->getName();
  1370.                 $data['adresse'] = $adresseCarrier;
  1371.                 if($timeLivraison && $dateLivraison){
  1372.                     $date = new \DateTime($dateLivraison);
  1373.                     $time explode(' - '$timeLivraison);
  1374.                     $dateFormat = new \IntlDateFormatter('fr', \IntlDateFormatter::LONG, \IntlDateFormatter::NONEnullnull'EEEE d MMMM');
  1375.                     $dateName $dateFormat->format($date);
  1376.                     $data['date'] = $dateName;
  1377.                     $data['time'] = isset($time[0])?$time[0]:null;
  1378.                 }
  1379.             }else if($carrier == $carrierNationalJ1 || $carrier == $carrierNationalJ2){
  1380.                 $data['date'] = null;
  1381.                 $data['time'] = null;
  1382.             }
  1383.         }
  1384.         return $data;
  1385.     }
  1386.     // get price and qty new nb_designer
  1387.     public function getPriceAndQuantity($request,$id_product,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id=null,$isEnveloppe=false,$plus_expert=false,$isTrait=false,$carrierId null,$typeLivraisonNational null,$typeLivraison30min null,$adresseCarrier null,$imprimeurLivraison null,$dateLivraison null,$timeLivraison null,$lat=null,$long=null,$codePostal=null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
  1388.         $product =  $this->em->getRepository(Product::class)->find($id_product);
  1389.         if($product){
  1390.             if($product->getIsColorLab()){
  1391.                 $requestData $request->request->all();
  1392.                 $typeFormatId = isset($requestData['typeFormat'])? $requestData['typeFormat'] : null;
  1393.                 $formatId = isset($requestData['format'])? $requestData['format'] : null;
  1394.                 $specificiteId = isset($requestData['specificite'])? $requestData['specificite'] : null;
  1395.                 $couleurId = isset($requestData['couleur'])? $requestData['couleur'] : null;
  1396.                 $tailleId = isset($requestData['taille'])? $requestData['taille'] : null;
  1397.                 $zoneImpressionId = isset($requestData['zoneImpression'])? $requestData['zoneImpression'] : null;
  1398.                 $nbrCouleurId = isset($requestData['nbrCouleur'])? $requestData['nbrCouleur'] : null;
  1399.                 $gramageId = isset($requestData['gramage'])? $requestData['gramage'] : null;
  1400.                 $supportSuspensionId = isset($requestData['supportSuspension'])? $requestData['supportSuspension'] : null;
  1401.                 $typeCartonId = isset($requestData['typeCarton'])? $requestData['typeCarton'] : null;
  1402.                 $oeilleId = isset($requestData['oeille'])? $requestData['oeille'] : null;
  1403.                 $typeImpressionId = isset($requestData['typeImpression'])? $requestData['typeImpression'] : null;
  1404.                 $formatL = isset($requestData['formatL'])? $requestData['formatL'] : 100;
  1405.                 $formatH = isset($requestData['formatH'])? $requestData['formatH'] : 100;
  1406.                 $format =  $formatId $this->em->getRepository(Attribut::class)->find($formatId):null;
  1407.                 $gramage =  $gramageId $this->em->getRepository(Attribut::class)->find($gramageId):null;
  1408.                 $type =  $typeFormatId $this->em->getRepository(Attribut::class)->find($typeFormatId):null;
  1409.                 $specificite =  $specificiteId $this->em->getRepository(Attribut::class)->find($specificiteId):null;
  1410.                 $couleur =  $couleurId $this->em->getRepository(Attribut::class)->find($couleurId):null;
  1411.                 $taille =  $tailleId $this->em->getRepository(Attribut::class)->find($tailleId):null;
  1412.                 $zoneImpression =  $zoneImpressionId $this->em->getRepository(Attribut::class)->find($zoneImpressionId):null;
  1413.                 $supportSuspension =  $supportSuspensionId $this->em->getRepository(Attribut::class)->find($supportSuspensionId):null;
  1414.                 $typeCarton =  $typeCartonId $this->em->getRepository(Attribut::class)->find($typeCartonId):null;
  1415.                 $oeille =  $oeilleId $this->em->getRepository(Attribut::class)->find($oeilleId):null;
  1416.                 $typeImpression =  $typeImpressionId $this->em->getRepository(Attribut::class)->find($typeImpressionId):null;
  1417.                 $nbrCouleur =  $nbrCouleurId $this->em->getRepository(Attribut::class)->find($nbrCouleurId):null;
  1418.                 $qtys1 $this->getQtyPosible($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
  1419.                 $qtys $this->getQantityVitrophonies($product,$qtys1['qtys'],$formatL,$formatH);
  1420.                 $qtysPlus $this->getQantityVitrophonies($product,$qtys1['qtysPlus'],$formatL,$formatH);
  1421.                 $qtysTeam $this->getQantityVitrophonies($product,$qtys1['qtysTeam'],$formatL,$formatH);
  1422.                 $blockLivraison null;
  1423.                 $jourLivraison null;
  1424.                 $livraisonPrice null;
  1425.                 if ($carrierId && $imprimeurLivraison) {
  1426.                     $blockLivraison $this->getDetailLivraison($carrierId$typeLivraisonNational$typeLivraison30min$adresseCarrier$imprimeurLivraison$dateLivraison$timeLivraison);
  1427.                     $jourLivraison $this->getJourLivraison($carrierId$typeLivraisonNational$typeLivraison30min$adresseCarrier$imprimeurLivraison$dateLivraison$timeLivraison);
  1428.                     $priceBloc $this->getPriceColorLab($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$qty,$carrierId,$typeLivraisonNational,$typeLivraison30min,$lat,$long,$codePostal,$imprimeurLivraison,$supportSuspension,$formatL,$formatH,$typeCarton,$oeille);
  1429.                     $livraisonPrice $this->cart_service->getPriceCarrier($priceBloc['prixHt'],$carrierId,$typeLivraison30min,$typeLivraisonNational);
  1430.                 }
  1431.                 return array(
  1432.                     'product' => $product,
  1433.                     'type' => $type,
  1434.                     'format' => $format,
  1435.                     'specificite' => $specificite,
  1436.                     'couleur' => $couleur,
  1437.                     'taille' => $taille,
  1438.                     'zoneImpression' => $zoneImpression,
  1439.                     'nbrCouleur' => $nbrCouleur,
  1440.                     'gramage' => $gramage,
  1441.                     'supportSuspension' => $supportSuspension,
  1442.                     'typeCarton' => $typeCarton,
  1443.                     'oeille' => $oeille,
  1444.                     'typeImpression' => $typeImpression,
  1445.                     'finition' => $finition,
  1446.                     'verification' => $verification,
  1447.                     'bordsArrondis' => $bordsArrondis,
  1448.                     'plastification' => $plastification,
  1449.                     'formatL' => $formatL,
  1450.                     'formatH' => $formatH,
  1451.                     'qtys' => $qtys,
  1452.                     'qtysPlus' => $qtysPlus,
  1453.                     'qtysTeam' => $qtysTeam,
  1454.                     'qty' => $qty,
  1455.                     'blockLivraison' => $blockLivraison,
  1456.                     'livraisonPrice' => $livraisonPrice,
  1457.                     'jourLivraison' => $jourLivraison,
  1458.                     'price' => $this->getPriceColorLab($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$qty,$carrierId,$typeLivraisonNational,$typeLivraison30min,$lat,$long,$codePostal,$imprimeurLivraison,$supportSuspension,$formatL,$formatH,$typeCarton,$oeille),
  1459.                 );
  1460.             }
  1461.             else {
  1462.                 if ($product && $product->getTypeProduct() == Product::AFFICHE) {
  1463.                     $qtys $gramage_id $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id$format_id$typeImpression_idProductAttribute::SANS_PLASTIFICATION$finition,false,$bordsArrondis,$plastification) : array();
  1464.                 } else {
  1465.                     $qtys $gramage_id $this->getQtyPosibleByGrammage($gramage_id$format_id$rectoverso$finition,$bordsArrondis,$plastification) : array();
  1466.                 }
  1467.                 $blockLivraison null;
  1468.                 $jourLivraison null;
  1469.                 $livraisonPrice null;
  1470.                 if ($carrierId && $imprimeurLivraison) {
  1471.                     $blockLivraison $this->getDetailLivraison($carrierId$typeLivraisonNational$typeLivraison30min$adresseCarrier$imprimeurLivraison$dateLivraison$timeLivraison);
  1472.                     $jourLivraison $this->getJourLivraison($carrierId$typeLivraisonNational$typeLivraison30min$adresseCarrier$imprimeurLivraison$dateLivraison$timeLivraison);
  1473.                     $priceBloc $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,$isEnveloppe,$plus_expert,$isTrait,ProductAttribute::SANS_PLASTIFICATION,$carrierId,$typeLivraisonNational,$typeLivraison30min,$lat,$long,$codePostal,$imprimeurLivraison,$verification,$bordsArrondis,$plastification);
  1474.                     $livraisonPrice $this->cart_service->getPriceCarrier($priceBloc['prixHt'],$carrierId,$typeLivraison30min,$typeLivraisonNational);
  1475.                 }
  1476.                 return array(
  1477.                     'id_product' => $id_product,
  1478.                     'product' => $product,
  1479.                     'qty' => $qty,
  1480.                     'format_id' => $format_id,
  1481.                     'format' => $this->em->getRepository(Attribut::class)->find($format_id),
  1482.                     'rectoverso' => $rectoverso,
  1483.                     'finition' => $finition,
  1484.                     'gramage_id' => $gramage_id,
  1485.                     'gramage' => $this->em->getRepository(Attribut::class)->find($gramage_id),
  1486.                     'typeImpression_id' => $typeImpression_id,
  1487.                     'typeImpression' => ($typeImpression_id)?$this->em->getRepository(Attribut::class)->find($typeImpression_id):null,
  1488.                     'isEnveloppe' => $isEnveloppe,
  1489.                     'plus_expert' => $plus_expert,
  1490.                     'verification' => $verification,
  1491.                     'bordsArrondis' => $bordsArrondis,
  1492.                     'plastification' => $plastification,
  1493.                     'isTrait' => $isTrait,
  1494.                     'qtys' => $qtys['qtys'],
  1495.                     'qtysPlus' => $qtys['qtysPlus'],
  1496.                     'qtysTeam' => $qtys['qtysTeam'],
  1497.                     'qty' => $qty,
  1498.                     'blockLivraison' => $blockLivraison,
  1499.                     'livraisonPrice' => $livraisonPrice,
  1500.                     'jourLivraison' => $jourLivraison,
  1501.                     'price' => $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,$isEnveloppe,$plus_expert,$isTrait,ProductAttribute::SANS_PLASTIFICATION,$carrierId,$typeLivraisonNational,$typeLivraison30min,$lat,$long,$codePostal,$imprimeurLivraison,$verification,$bordsArrondis,$plastification),
  1502.                 );
  1503.             }
  1504.         }
  1505.         return  array();
  1506.     }
  1507.     // get detail product new nb_designer
  1508.     public function getDetailProduct($request,$id_product,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id=null,$isEnveloppe=false,$plus_expert=false,$isTrait=false,$carrierId null,$typeLivraisonNational null,$typeLivraison30min null,$tokenDetail=null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
  1509.         $product =  $this->em->getRepository(Product::class)->find($id_product);
  1510.         if($product) {
  1511.             if ($product->getIsColorLab()) {
  1512.                 $requestData $request->request->all();
  1513.                 $typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
  1514.                 $formatId = isset($requestData['format']) ? $requestData['format'] : null;
  1515.                 $specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
  1516.                 $couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
  1517.                 $tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
  1518.                 $zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
  1519.                 $nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
  1520.                 $gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
  1521.                 $supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
  1522.                 $typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
  1523.                 $oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
  1524.                 $typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
  1525.                 $format $formatId $this->em->getRepository(Attribut::class)->find($formatId) : null;
  1526.                 $gramage $gramageId $this->em->getRepository(Attribut::class)->find($gramageId) : null;
  1527.                 $type $typeFormatId $this->em->getRepository(Attribut::class)->find($typeFormatId) : null;
  1528.                 $specificite $specificiteId $this->em->getRepository(Attribut::class)->find($specificiteId) : null;
  1529.                 $couleur $couleurId $this->em->getRepository(Attribut::class)->find($couleurId) : null;
  1530.                 $taille $tailleId $this->em->getRepository(Attribut::class)->find($tailleId) : null;
  1531.                 $zoneImpression $zoneImpressionId $this->em->getRepository(Attribut::class)->find($zoneImpressionId) : null;
  1532.                 $nbrCouleur $nbrCouleurId $this->em->getRepository(Attribut::class)->find($nbrCouleurId) : null;
  1533.                 $supportSuspension $supportSuspensionId $this->em->getRepository(Attribut::class)->find($supportSuspensionId) : null;
  1534.                 $typeCarton $typeCartonId $this->em->getRepository(Attribut::class)->find($typeCartonId) : null;
  1535.                 $oeille $oeilleId $this->em->getRepository(Attribut::class)->find($oeilleId) : null;
  1536.                 $typeImpression $typeImpressionId $this->em->getRepository(Attribut::class)->find($typeImpressionId) : null;
  1537.                 $qtys $this->getQtyPosible($id_product$format$gramage$typeImpression$type$specificite$couleur$taille$zoneImpression$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
  1538.                if($product->getTypeProduct() == Product::PHOTOS){
  1539.                    $filesToken = isset($requestData['photosToken']) ? $requestData['photosToken'] : null;
  1540.                    $qty $this->getFilePhotoQuantiy($filesToken);
  1541.                }
  1542.                 $cartDetail null;
  1543.                 if ($tokenDetail) {
  1544.                     $cartDetail $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
  1545.                 }
  1546.                 $data =  array(
  1547.                     'product' => $product,
  1548.                     'type' => $type,
  1549.                     'format' => $format,
  1550.                     'specificite' => $specificite,
  1551.                     'couleur' => $couleur,
  1552.                     'taille' => $taille,
  1553.                     'zoneImpression' => $zoneImpression,
  1554.                     'nbrCouleur' => $nbrCouleur,
  1555.                     'gramage' => $gramage,
  1556.                     'supportSuspension' => $supportSuspension,
  1557.                     'typeCarton' => $typeCarton,
  1558.                     'oeille' => $oeille,
  1559.                     'typeImpression' => $typeImpression,
  1560.                     'cartDetail' => $cartDetail,
  1561.                     'finition' => $finition,
  1562.                     'verification' => $verification,
  1563.                     'bordsArrondis' => $bordsArrondis,
  1564.                     'plastification' => $plastification,
  1565.                     'qtys' => $qtys['qtys'],
  1566.                     'qtysPlus' => $qtys['qtysPlus'],
  1567.                     'qtysTeam' => $qtys['qtysTeam'],
  1568.                     'qty' => $qty,
  1569.                     'price' => $this->getPriceColorLab($id_product$format$gramage$typeImpression$type$specificite$couleur$taille$zoneImpression$nbrCouleur$qty$carrierId$typeLivraisonNational$typeLivraison30minnullnullnullnull,$supportSuspension,null,null,$typeCarton,$oeille),
  1570.                 );
  1571.             } else {
  1572.                 if ($product && $product->getTypeProduct() == Product::AFFICHE) {
  1573.                     $qtys $gramage_id $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id$format_id$typeImpression_idProductAttribute::SANS_PLASTIFICATION$finition,false,$bordsArrondis,$plastification) : array();
  1574.                 } else {
  1575.                     $qtys $gramage_id $this->getQtyPosibleByGrammage($gramage_id$format_id$rectoverso$finition,$bordsArrondis,$plastification) : array();
  1576.                 }
  1577.                 $cartDetail null;
  1578.                 if ($tokenDetail) {
  1579.                     $cartDetail $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
  1580.                 }
  1581.                 $data = array(
  1582.                     'id_product' => $id_product,
  1583.                     'product' => $product,
  1584.                     'qty' => $qty,
  1585.                     'format_id' => $format_id,
  1586.                     'format' => $this->em->getRepository(Attribut::class)->find($format_id),
  1587.                     'rectoverso' => $rectoverso,
  1588.                     'finition' => $finition,
  1589.                     'gramage_id' => $gramage_id,
  1590.                     'gramage' => $this->em->getRepository(Attribut::class)->find($gramage_id),
  1591.                     'typeImpression_id' => $typeImpression_id,
  1592.                     'typeImpression' => ($typeImpression_id) ? $this->em->getRepository(Attribut::class)->find($typeImpression_id) : null,
  1593.                     'isEnveloppe' => $isEnveloppe,
  1594.                     'verification' => $verification,
  1595.                     'bordsArrondis' => $bordsArrondis,
  1596.                     'plastification' => $plastification,
  1597.                     'plus_expert' => $plus_expert,
  1598.                     'isTrait' => $isTrait,
  1599.                     'cartDetail' => $cartDetail,
  1600.                     'qtys' => $qtys['qtys'],
  1601.                     'qtysPlus' => $qtys['qtysPlus'],
  1602.                     'qtysTeam' => $qtys['qtysTeam'],
  1603.                     'qty' => $qty,
  1604.                     'price' => $this->getPrice($id_product$format_id$gramage_id$typeImpression_id$rectoverso$qty$finition$isEnveloppe$plus_expert$isTraitProductAttribute::SANS_PLASTIFICATION$carrierId$typeLivraisonNational$typeLivraison30minnullnullnullnull$verification,$bordsArrondis,$plastification),
  1605.                 );
  1606.             }
  1607.             return $this->twig->render('front/product-option/detail-block.html.twig'$data);
  1608.         }
  1609.         return array();
  1610.     }
  1611.     // get detail product photos new nb_designer
  1612.     public function getDetailProductPhotos($request,$id_product,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id=null,$isEnveloppe=false,$plus_expert=false,$isTrait=false,$carrierId null,$typeLivraisonNational null,$typeLivraison30min null,$tokenDetail=null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
  1613.         $product =  $this->em->getRepository(Product::class)->find($id_product);
  1614.         if($product) {
  1615.             if ($product->getIsColorLab()) {
  1616.                 $requestData $request->request->all();
  1617.                 $typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
  1618.                 $formatId = isset($requestData['format']) ? $requestData['format'] : null;
  1619.                 $specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
  1620.                 $couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
  1621.                 $tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
  1622.                 $zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
  1623.                 $nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
  1624.                 $gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
  1625.                 $supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
  1626.                 $typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
  1627.                 $oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
  1628.                 $typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
  1629.                 $format $formatId $this->em->getRepository(Attribut::class)->find($formatId) : null;
  1630.                 $gramage $gramageId $this->em->getRepository(Attribut::class)->find($gramageId) : null;
  1631.                 $type $typeFormatId $this->em->getRepository(Attribut::class)->find($typeFormatId) : null;
  1632.                 $specificite $specificiteId $this->em->getRepository(Attribut::class)->find($specificiteId) : null;
  1633.                 $couleur $couleurId $this->em->getRepository(Attribut::class)->find($couleurId) : null;
  1634.                 $taille $tailleId $this->em->getRepository(Attribut::class)->find($tailleId) : null;
  1635.                 $zoneImpression $zoneImpressionId $this->em->getRepository(Attribut::class)->find($zoneImpressionId) : null;
  1636.                 $nbrCouleur $nbrCouleurId $this->em->getRepository(Attribut::class)->find($nbrCouleurId) : null;
  1637.                 $supportSuspension $supportSuspensionId $this->em->getRepository(Attribut::class)->find($supportSuspensionId) : null;
  1638.                 $typeCarton $typeCartonId $this->em->getRepository(Attribut::class)->find($typeCartonId) : null;
  1639.                 $oeille $oeilleId $this->em->getRepository(Attribut::class)->find($oeilleId) : null;
  1640.                 $typeImpression $typeImpressionId $this->em->getRepository(Attribut::class)->find($typeImpressionId) : null;
  1641.                 $qtys $this->getQtyPosible($id_product$format$gramage$typeImpression$type$specificite$couleur$taille$zoneImpression$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
  1642.                 if($product->getTypeProduct() == Product::PHOTOS){
  1643.                     $filesToken = isset($requestData['photosToken']) ? $requestData['photosToken'] : null;
  1644.                     $qty $this->getFilePhotoQuantiy($filesToken);
  1645.                 }
  1646.                 $cartDetail null;
  1647.                 if ($tokenDetail) {
  1648.                     $cartDetail $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
  1649.                 }
  1650.                 $data =  array(
  1651.                     'product' => $product,
  1652.                     'type' => $type,
  1653.                     'format' => $format,
  1654.                     'specificite' => $specificite,
  1655.                     'couleur' => $couleur,
  1656.                     'taille' => $taille,
  1657.                     'zoneImpression' => $zoneImpression,
  1658.                     'nbrCouleur' => $nbrCouleur,
  1659.                     'gramage' => $gramage,
  1660.                     'supportSuspension' => $supportSuspension,
  1661.                     'typeCarton' => $typeCarton,
  1662.                     'oeille' => $oeille,
  1663.                     'typeImpression' => $typeImpression,
  1664.                     'cartDetail' => $cartDetail,
  1665.                     'finition' => $finition,
  1666.                     'verification' => $verification,
  1667.                     'bordsArrondis' => $bordsArrondis,
  1668.                     'plastification' => $plastification,
  1669.                     'qtys' => $qtys['qtys'],
  1670.                     'qtysPlus' => $qtys['qtysPlus'],
  1671.                     'qtysTeam' => $qtys['qtysTeam'],
  1672.                     'qty' => $qty,
  1673.                     'price' => $this->getPriceColorLab($id_product$format$gramage$typeImpression$type$specificite$couleur$taille$zoneImpression$nbrCouleur$qty$carrierId$typeLivraisonNational$typeLivraison30minnullnullnullnull,$supportSuspension,null,null,$typeCarton,$oeille),
  1674.                 );
  1675.                 return $data;
  1676.             }
  1677.         }
  1678.         return array();
  1679.     }
  1680.     // get detail product new nb_designer mobile
  1681.     public function getDetailProductMobile($request,$id_product,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id=null,$isEnveloppe=false,$plus_expert=false,$isTrait=false,$carrierId null,$typeLivraisonNational null,$typeLivraison30min null,$tokenDetail=null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
  1682.         $product =  $this->em->getRepository(Product::class)->find($id_product);
  1683.         if($product) {
  1684.             if ($product->getIsColorLab()) {
  1685.                 $requestData $request->request->all();
  1686.                 $typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
  1687.                 $formatId = isset($requestData['format']) ? $requestData['format'] : null;
  1688.                 $specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
  1689.                 $couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
  1690.                 $tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
  1691.                 $zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
  1692.                 $nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
  1693.                 $gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
  1694.                 $supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
  1695.                 $typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
  1696.                 $oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
  1697.                 $typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
  1698.                 $format $formatId $this->em->getRepository(Attribut::class)->find($formatId) : null;
  1699.                 $gramage $gramageId $this->em->getRepository(Attribut::class)->find($gramageId) : null;
  1700.                 $type $typeFormatId $this->em->getRepository(Attribut::class)->find($typeFormatId) : null;
  1701.                 $specificite $specificiteId $this->em->getRepository(Attribut::class)->find($specificiteId) : null;
  1702.                 $couleur $couleurId $this->em->getRepository(Attribut::class)->find($couleurId) : null;
  1703.                 $taille $tailleId $this->em->getRepository(Attribut::class)->find($tailleId) : null;
  1704.                 $zoneImpression $zoneImpressionId $this->em->getRepository(Attribut::class)->find($zoneImpressionId) : null;
  1705.                 $nbrCouleur $nbrCouleurId $this->em->getRepository(Attribut::class)->find($nbrCouleurId) : null;
  1706.                 $supportSuspension $supportSuspensionId $this->em->getRepository(Attribut::class)->find($supportSuspensionId) : null;
  1707.                 $typeCarton $typeCartonId $this->em->getRepository(Attribut::class)->find($typeCartonId) : null;
  1708.                 $oeille $oeilleId $this->em->getRepository(Attribut::class)->find($oeilleId) : null;
  1709.                 $typeImpression $typeImpressionId $this->em->getRepository(Attribut::class)->find($typeImpressionId) : null;
  1710.                 $qtys $this->getQtyPosible($id_product$format$gramage$typeImpression$type$specificite$couleur$taille$zoneImpression$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
  1711.                 $cartDetail null;
  1712.                 if ($tokenDetail) {
  1713.                     $cartDetail $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
  1714.                 }
  1715.                 $data =  array(
  1716.                     'product' => $product,
  1717.                     'type' => $type,
  1718.                     'format' => $format,
  1719.                     'specificite' => $specificite,
  1720.                     'couleur' => $couleur,
  1721.                     'taille' => $taille,
  1722.                     'zoneImpression' => $zoneImpression,
  1723.                     'nbrCouleur' => $nbrCouleur,
  1724.                     'gramage' => $gramage,
  1725.                     'supportSuspension' => $supportSuspension,
  1726.                     'typeCarton' => $typeCarton,
  1727.                     'oeille' => $oeille,
  1728.                     'typeImpression' => $typeImpression,
  1729.                     'cartDetail' => $cartDetail,
  1730.                     'finition' => $finition,
  1731.                     'verification' => $verification,
  1732.                     'bordsArrondis' => $bordsArrondis,
  1733.                     'plastification' => $plastification,
  1734.                     'qtys' => $qtys['qtys'],
  1735.                     'qtysPlus' => $qtys['qtysPlus'],
  1736.                     'qtysTeam' => $qtys['qtysTeam'],
  1737.                     'qty' => $qty,
  1738.                     'price' => $this->getPriceColorLab($id_product$format$gramage$typeImpression$type$specificite$couleur$taille$zoneImpression$nbrCouleur$qty$carrierId$typeLivraisonNational$typeLivraison30minnullnullnullnull,$supportSuspension,null,null,$typeCarton,$oeille),
  1739.                 );
  1740.             } else {
  1741.                 if ($product && $product->getTypeProduct() == Product::AFFICHE) {
  1742.                     $qtys $gramage_id $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id$format_id$typeImpression_idProductAttribute::SANS_PLASTIFICATION$finition,false,$bordsArrondis,$plastification) : array();
  1743.                 } else {
  1744.                     $qtys $gramage_id $this->getQtyPosibleByGrammage($gramage_id$format_id$rectoverso$finition,$bordsArrondis,$plastification) : array();
  1745.                 }
  1746.                 $cartDetail null;
  1747.                 if ($tokenDetail) {
  1748.                     $cartDetail $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
  1749.                 }
  1750.                 $data = array(
  1751.                     'id_product' => $id_product,
  1752.                     'product' => $product,
  1753.                     'qty' => $qty,
  1754.                     'format_id' => $format_id,
  1755.                     'format' => $this->em->getRepository(Attribut::class)->find($format_id),
  1756.                     'rectoverso' => $rectoverso,
  1757.                     'finition' => $finition,
  1758.                     'gramage_id' => $gramage_id,
  1759.                     'gramage' => $this->em->getRepository(Attribut::class)->find($gramage_id),
  1760.                     'typeImpression_id' => $typeImpression_id,
  1761.                     'typeImpression' => ($typeImpression_id) ? $this->em->getRepository(Attribut::class)->find($typeImpression_id) : null,
  1762.                     'isEnveloppe' => $isEnveloppe,
  1763.                     'verification' => $verification,
  1764.                     'bordsArrondis' => $bordsArrondis,
  1765.                     'plastification' => $plastification,
  1766.                     'plus_expert' => $plus_expert,
  1767.                     'isTrait' => $isTrait,
  1768.                     'cartDetail' => $cartDetail,
  1769.                     'qtys' => $qtys['qtys'],
  1770.                     'qtysPlus' => $qtys['qtysPlus'],
  1771.                     'qtysTeam' => $qtys['qtysTeam'],
  1772.                     'qty' => $qty,
  1773.                     'price' => $this->getPrice($id_product$format_id$gramage_id$typeImpression_id$rectoverso$qty$finition$isEnveloppe$plus_expert$isTraitProductAttribute::SANS_PLASTIFICATION$carrierId$typeLivraisonNational$typeLivraison30minnullnullnullnull$verification,$bordsArrondis,$plastification),
  1774.                 );
  1775.             }
  1776.             return $this->twig->render('front/product-option/detail-block-mobile.html.twig'$data);
  1777.         }
  1778.         return array();
  1779.     }
  1780.     public function getDetailProductTagGoogle($request,$id_product,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id=null,$isEnveloppe=false,$plus_expert=false,$isTrait=false,$carrierId null,$typeLivraisonNational null,$typeLivraison30min null,$tokenDetail=null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
  1781.         $product =  $this->em->getRepository(Product::class)->find($id_product);
  1782.         if($product) {
  1783.             if ($product->getIsColorLab()) {
  1784.                 $requestData $request->request->all();
  1785.                 $typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
  1786.                 $formatId = isset($requestData['format']) ? $requestData['format'] : null;
  1787.                 $specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
  1788.                 $couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
  1789.                 $tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
  1790.                 $zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
  1791.                 $nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
  1792.                 $gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
  1793.                 $supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
  1794.                 $typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
  1795.                 $oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
  1796.                 $typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
  1797.                 $format $formatId $this->em->getRepository(Attribut::class)->find($formatId) : null;
  1798.                 $gramage $gramageId $this->em->getRepository(Attribut::class)->find($gramageId) : null;
  1799.                 $type $typeFormatId $this->em->getRepository(Attribut::class)->find($typeFormatId) : null;
  1800.                 $specificite $specificiteId $this->em->getRepository(Attribut::class)->find($specificiteId) : null;
  1801.                 $couleur $couleurId $this->em->getRepository(Attribut::class)->find($couleurId) : null;
  1802.                 $taille $tailleId $this->em->getRepository(Attribut::class)->find($tailleId) : null;
  1803.                 $zoneImpression $zoneImpressionId $this->em->getRepository(Attribut::class)->find($zoneImpressionId) : null;
  1804.                 $nbrCouleur $nbrCouleurId $this->em->getRepository(Attribut::class)->find($nbrCouleurId) : null;
  1805.                 $supportSuspension $supportSuspensionId $this->em->getRepository(Attribut::class)->find($supportSuspensionId) : null;
  1806.                 $typeCarton $typeCartonId $this->em->getRepository(Attribut::class)->find($typeCartonId) : null;
  1807.                 $oeille $oeilleId $this->em->getRepository(Attribut::class)->find($oeilleId) : null;
  1808.                 $typeImpression $typeImpressionId $this->em->getRepository(Attribut::class)->find($typeImpressionId) : null;
  1809.                 $price =  $this->getPriceColorLab($id_product$format$gramage$typeImpression$type$specificite$couleur$taille$zoneImpression$nbrCouleur$qty$carrierId$typeLivraisonNational$typeLivraison30minnullnullnullnull,$supportSuspension,null,null,$typeCarton,$oeille);
  1810.             } else {
  1811.                 $format $this->em->getRepository(Attribut::class)->find($format_id);
  1812.                 $price $this->getPrice($id_product$format_id$gramage_id$typeImpression_id$rectoverso$qty$finition$isEnveloppe$plus_expert$isTraitProductAttribute::SANS_PLASTIFICATION$carrierId$typeLivraisonNational$typeLivraison30minnullnullnullnull$verification,$bordsArrondis,$plastification);
  1813.             }
  1814.             if($product->getIsColorLab()){
  1815.                 if($type && $type->getName()){$name $product->getTitre().' '.$type->getName();}
  1816.                 else{$name $product->getTitre();}
  1817.             }else{
  1818.                 if($format && $format->getName()){$name $product->getTitre().' '.$format->getName();}
  1819.                 else{$name $product->getTitre().' '.$format->getName();}
  1820.             }
  1821.             $array = [
  1822.                 'id' => $id_product,
  1823.                 'name' => $name,
  1824.                 'category' => 'articles',
  1825.                 'price' => $price['prixTtc'] ,
  1826.                 'quantity' => $qty,
  1827.             ];
  1828.             return $array;
  1829.         }
  1830.         return array();
  1831.     }
  1832.     public function getListProductsBy($products,$num null){
  1833.         $arrays = [];
  1834.         if($products){
  1835.             foreach ($products as $product){
  1836.                 if(is_null($num)){
  1837.                     if($product->getProduct() && $product->getProduct()->getId()){
  1838.                         $id $product->getProduct()->getId();
  1839.                     }else{
  1840.                         $id '00'.$product->getId();
  1841.                     }
  1842.                     $array = [
  1843.                         'item_id' => $id,
  1844.                         'item_name' => $product->getBesoinProductTextPrix(),
  1845.                         'item_category' => 'articles',
  1846.                     ];
  1847.                 }elseif ($num == 1){
  1848.                     $array = [
  1849.                         'item_id' => $product->getProduct()->getId(),
  1850.                         'item_name' => $product->getProductTextPrix(),
  1851.                         'item_category' => 'articles',
  1852.                     ];
  1853.                 }elseif(in_array($num ,[2,3,4])){
  1854.                     $array = [
  1855.                         'item_id' => $product->getId(),
  1856.                         'item_name' => $product->getBesoinProductTextTitre(),
  1857.                         'item_category' => 'articles',
  1858.                     ];
  1859.                 }
  1860.                 $arrays[] = $array;
  1861.             }
  1862.         }
  1863.         return $arrays;
  1864.     }
  1865.     // get product Attribute new nb_designer
  1866.     public function getProductAttributeNewNbDesigner($request,$id_product,$id_format,$id_grammage,$typeImpression,$rectoverso,$plastificationn=ProductAttribute::SANS_PLASTIFICATION)
  1867.     {
  1868.         $product $this->em->getRepository(Product::class)->find($id_product);
  1869.         if($product->getIsColorLab()){
  1870.             $requestData $request->request->all();
  1871.             $typeFormatId = isset($requestData['typeFormat'])? $requestData['typeFormat'] : null;
  1872.             $formatId = isset($requestData['format'])? $requestData['format'] : null;
  1873.             $specificiteId = isset($requestData['specificite'])? $requestData['specificite'] : null;
  1874.             $couleurId = isset($requestData['couleur'])? $requestData['couleur'] : null;
  1875.             $tailleId = isset($requestData['taille'])? $requestData['taille'] : null;
  1876.             $zoneImpressionId = isset($requestData['zoneImpression'])? $requestData['zoneImpression'] : null;
  1877.             $nbrCouleurId = isset($requestData['nbrCouleur'])? $requestData['nbrCouleur'] : null;
  1878.             $gramageId = isset($requestData['gramage'])? $requestData['gramage'] : null;
  1879.             $supportSuspensionId = isset($requestData['supportSuspension'])? $requestData['supportSuspension'] : null;
  1880.             $typeCartonId = isset($requestData['typeCarton'])? $requestData['typeCarton'] : null;
  1881.             $oeilleId = isset($requestData['oeille'])? $requestData['oeille'] : null;
  1882.             $typeImpressionId = isset($requestData['typeImpression'])? $requestData['typeImpression'] : null;
  1883.             $format =  $formatId $this->em->getRepository(Attribut::class)->find($formatId):null;
  1884.             $gramage =  $gramageId $this->em->getRepository(Attribut::class)->find($gramageId):null;
  1885.             $type =  $typeFormatId $this->em->getRepository(Attribut::class)->find($typeFormatId):null;
  1886.             $specificite =  $specificiteId $this->em->getRepository(Attribut::class)->find($specificiteId):null;
  1887.             $couleur =  $couleurId $this->em->getRepository(Attribut::class)->find($couleurId):null;
  1888.             $taille =  $tailleId $this->em->getRepository(Attribut::class)->find($tailleId):null;
  1889.             $zoneImpression =  $zoneImpressionId $this->em->getRepository(Attribut::class)->find($zoneImpressionId):null;
  1890.             $nbrCouleur =  $nbrCouleurId $this->em->getRepository(Attribut::class)->find($nbrCouleurId):null;
  1891.             $supportSuspension =  $supportSuspensionId $this->em->getRepository(Attribut::class)->find($supportSuspensionId):null;
  1892.             $typeCarton =  $typeCartonId $this->em->getRepository(Attribut::class)->find($typeCartonId):null;
  1893.             $oeille =  $oeilleId $this->em->getRepository(Attribut::class)->find($oeilleId):null;
  1894.             $typeImpression =  $typeImpressionId $this->em->getRepository(Attribut::class)->find($typeImpressionId):null;
  1895.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(
  1896.                 array(
  1897.                     'product'=>$id_product,
  1898.                     'format'=>$formatis_object($format)?$format->getId():$format['id']:null,
  1899.                     'gramage'=>$gramage?is_object($gramage)?$gramage->getId():$gramage['id']:null,
  1900.                     'typeImpression'=>$typeImpression?is_object($typeImpression)?$typeImpression->getId():$typeImpression['id']:null,
  1901.                     'typeFormat'=>$type?is_object($type)?$type->getId():$type['id']:null,
  1902.                     'specificite'=>$specificite?is_object($specificite)?$specificite->getId():$specificite['id']:null,
  1903.                     'typeCouleur'=>$couleur?is_object($couleur)?$couleur->getId():$couleur['id']:null,
  1904.                     'taille'=>$taille?is_object($taille)?$taille->getId():$taille['id']:null,
  1905.                     'zoneImpression'=>$zoneImpression?is_object($zoneImpression)?$zoneImpression->getId():$zoneImpression['id']:null,
  1906.                     'nbrCouleur'=>$nbrCouleur?is_object($nbrCouleur)?$nbrCouleur->getId():$nbrCouleur['id']:null,
  1907.                     'supportSuspension'=>$supportSuspension?is_object($supportSuspension)?$supportSuspension->getId():$supportSuspension['id']:null,
  1908.                     'oeille'=>$oeille?is_object($oeille)?$oeille->getId():$oeille['id']:null,
  1909.                     'typeCarton'=>$typeCarton?is_object($typeCarton)?$typeCarton->getId():$typeCarton['id']:null,
  1910.                     'isEnabled'=>true
  1911.                 )
  1912.             );
  1913.         }
  1914.         else {
  1915.             if ($product and $product->getTypeProduct() == Product::AFFICHE) {
  1916.                 $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format' => $id_format'gramage' => $id_grammage'typeImpression' => $typeImpression'plastification' => $plastificationn'isEnabled' => true));
  1917.             } else {
  1918.                 $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format' => $id_format'gramage' => $id_grammage'rectoverso' => $rectoverso'isEnabled' => true));
  1919.             }
  1920.         }
  1921.         return $productAttribute;
  1922.     }
  1923.     // get price new nb_designer
  1924.     public function getPrice($id_product,$id_format,$id_grammage,$typeImpression,$rectoverso,$quantite,$finition,$isEnveloppe,$plus_expert=false,$isTrait=false,$plastificationn=ProductAttribute::SANS_PLASTIFICATION,$carrierId null,$typeLivraisonNational null,$typeLivraison30min null,$lat null,$long null,$codePostal null,$imprimeur null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED)
  1925.     {
  1926.         $prixHt null;
  1927.         $prixTtc null;
  1928.         $prixHtWithoutReduction 0;
  1929.         $prixTtcWithoutReduction 0;
  1930.         $user $this->security->getUser();
  1931.         $cart $this->cart_service->createCart(true);
  1932.         $product $this->em->getRepository(Product::class)->find($id_product);
  1933.         if($product && $product->getIsDeleted()){
  1934.             return ['productDesabled' => true];
  1935.         }
  1936.         // check abonnementPro
  1937.         $abonnement  $this->cart_service->checkAbonnementToCartOrOrder($user,$cart->getId());
  1938.         $typeAbonnement null;
  1939.         if($abonnement){
  1940.             $typeAbonnement $abonnement['type'];
  1941.         }
  1942.         $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement);
  1943.         if($product and $product->getTypeProduct() == Product::AFFICHE){
  1944.             $typeImpression null;
  1945.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_grammage,'typeImpression'=>$typeImpression,'plastification'=>$plastificationn,'isEnabled'=>true));
  1946.         }else{
  1947.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_grammage,'rectoverso'=>$rectoverso,'isEnabled'=>true));
  1948.         }
  1949.         if($productAttribute) {
  1950.             $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $quantite);
  1951.             if ($priceProductAttr) {
  1952.                 $priceFinitonHt  0;
  1953.                 $priceFinitonTtc  0;
  1954.                 $priceFinitonHtWithoutReduction  0;
  1955.                 $priceFinitonTtcWithoutReduction  0;
  1956.                 $pourcentageFinition 0;
  1957.                 if($finition == CartDetail::FINITION_GLACE){
  1958.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  1959.                 }else if($finition == CartDetail::FINITION_MATE){
  1960.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  1961.                 }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  1962.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  1963.                 }else if($finition == CartDetail::FINITION_TRANSPARENT){
  1964.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  1965.                 }else if($finition == CartDetail::FINITION_SoftTouch){
  1966.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  1967.                 }else if($finition == CartDetail::FINITION_Pelliculemat){
  1968.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  1969.                 }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  1970.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  1971.                 }
  1972.                 $priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) )* $pourcentageFinition;
  1973.                 $priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
  1974.                 $priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
  1975.                 $priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
  1976.                 $priceVerificationCheckedTtc  0;
  1977.                 $priceVerificationCheckedHt  0;
  1978.                 if($verification == CartDetail::VERIFICATION_CHECKED){
  1979.                     $priceVerificationCheckedTtc CartDetail::VERIFICATION_TTC;
  1980.                     $priceVerificationCheckedHt CartDetail::VERIFICATION_HT;
  1981.                 }
  1982.                 $priceBordsArrondisHt  0;
  1983.                 $priceBordsArrondisTtc  0;
  1984.                 $priceBordsArrondisHtWithoutReduction  0;
  1985.                 $priceBordsArrondisTtcWithoutReduction  0;
  1986.                 if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
  1987.                     $priceBordsArrondisHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  1988.                     $priceBordsArrondisTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  1989.                     $priceBordsArrondisHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  1990.                     $priceBordsArrondisTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  1991.                 }
  1992.                 $pricePlastificationHt  0;
  1993.                 $pricePlastificationTtc  0;
  1994.                 $pricePlastificationHtWithoutReduction  0;
  1995.                 $pricePlastificationTtcWithoutReduction  0;
  1996.                 if($plastification == CartDetail::PLASTIFICATION_CHECKED){
  1997.                     $pricePlastificationHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  1998.                     $pricePlastificationTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  1999.                     $pricePlastificationHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  2000.                     $pricePlastificationTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  2001.                 }
  2002.                 if($plus_expert){
  2003.                     $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())  + CartDetail::PLUS_EXPERT_HT +$priceFinitonHt +$priceVerificationCheckedHt+$priceBordsArrondisHt+$pricePlastificationHt;
  2004.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() ) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtc +$priceVerificationCheckedTtc+$priceBordsArrondisTtc+$pricePlastificationTtc;
  2005.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())  + CartDetail::PLUS_EXPERT_HT +$priceFinitonHtWithoutReduction +$priceVerificationCheckedHt+$priceBordsArrondisHtWithoutReduction+$pricePlastificationHtWithoutReduction;
  2006.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtcWithoutReduction +$priceVerificationCheckedTtc+$priceBordsArrondisTtcWithoutReduction+$pricePlastificationTtcWithoutReduction;
  2007.                 }else{
  2008.                     $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt  +$priceVerificationCheckedHt+$priceBordsArrondisHt+$pricePlastificationHt;
  2009.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()  + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+ $priceFinitonTtc  +$priceVerificationCheckedTtc+$priceBordsArrondisTtc+$pricePlastificationTtc;
  2010.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction  +$priceVerificationCheckedHt+$priceBordsArrondisHtWithoutReduction+$pricePlastificationHtWithoutReduction;
  2011.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc()  + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+ $priceFinitonTtcWithoutReduction  +$priceVerificationCheckedTtc+$priceBordsArrondisTtcWithoutReduction+$pricePlastificationTtcWithoutReduction;
  2012.                 }
  2013.                 if(($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or  ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  2014.                     if($isEnveloppe) {
  2015.                         $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $quantite);
  2016.                         $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $quantite);
  2017.                         $prixHtWithoutReduction $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT $quantite);
  2018.                         $prixTtcWithoutReduction $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC $quantite);
  2019.                     }
  2020.                 }
  2021.                 $prixHt $this->cart_service->updatePriceByCountry($prixHt,$product);
  2022.                 $prixTtc $this->cart_service->updatePriceByCountry($prixTtc,$product);
  2023.                 $prixHtWithoutReduction $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
  2024.                 $prixTtcWithoutReduction $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
  2025.             }
  2026.         }
  2027.         $priceAbonnement = [
  2028.             'pricePro' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_PRO,$product,$productAttribute,$quantite,$finition,$plus_expert,$isEnveloppe,$bordsArrondis,100,100,$plastification),
  2029.             'priceTeam' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_TEAM,$product,$productAttribute,$quantite,$finition,$plus_expert,$isEnveloppe,$bordsArrondis,100,100,$plastification),
  2030.             'priceEntreprise' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_ENTREPRISE,$product,$productAttribute,$quantite,$finition,$plus_expert,$isEnveloppe,$bordsArrondis,100,100,$plastification)
  2031.         ];
  2032.         $dataLocalisation = [
  2033.             'lat' => $lat,
  2034.             'longi' => $long,
  2035.             'codePostal' =>$codePostal ,
  2036.         ];
  2037.         return $this->getPriceAfterPromoAndAbonnement$prixHt,$prixTtc,$prixHtWithoutReduction,$prixTtcWithoutReduction,$abonnement,$carrierId,$typeLivraisonNational,$typeLivraison30min,$priceAbonnement,$dataLocalisation,$imprimeur);
  2038.     }
  2039.     public function getPriceColorLab($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$quantite,$carrierId null,$typeLivraisonNational null,$typeLivraison30min null,$lat null,$long null,$codePostal null,$imprimeur null,$supportSuspension=null,$formatL=100,$formatH=100,$typeCarton=null,$oeille=null)
  2040.     {
  2041.         $prixHt null;
  2042.         $prixTtc null;
  2043.         $prixHtWithoutReduction 0;
  2044.         $prixTtcWithoutReduction 0;
  2045.         $user $this->security->getUser();
  2046.         $cart $this->cart_service->createCart(true);
  2047.         $product $this->em->getRepository(Product::class)->find($id_product);
  2048.         if($product && $product->getIsDeleted()){
  2049.          return ['productDesabled' => true];
  2050.         }
  2051.         // check abonnementPro
  2052.         $abonnement  $this->cart_service->checkAbonnementToCartOrOrder($user,$cart->getId());
  2053.         $typeAbonnement null;
  2054.         if($abonnement){
  2055.             $typeAbonnement $abonnement['type'];
  2056.         }
  2057.         $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement);
  2058.         $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(
  2059.             array(
  2060.                 'product'=>$id_product,
  2061.                 'format'=>$formatis_object($format)?$format->getId():$format['id']:null,
  2062.                 'gramage'=>$gramage?is_object($gramage)?$gramage->getId():$gramage['id']:null,
  2063.                 'typeImpression'=>$typeImpression?is_object($typeImpression)?$typeImpression->getId():$typeImpression['id']:null,
  2064.                 'typeFormat'=>$type?is_object($type)?$type->getId():$type['id']:null,
  2065.                 'specificite'=>$specificite?is_object($specificite)?$specificite->getId():$specificite['id']:null,
  2066.                 'typeCouleur'=>$couleur?is_object($couleur)?$couleur->getId():$couleur['id']:null,
  2067.                 'taille'=>$taille?is_object($taille)?$taille->getId():$taille['id']:null,
  2068.                 'zoneImpression'=>$zoneImpression?is_object($zoneImpression)?$zoneImpression->getId():$zoneImpression['id']:null,
  2069.                 'nbrCouleur'=>$nbrCouleur?is_object($nbrCouleur)?$nbrCouleur->getId():$nbrCouleur['id']:null,
  2070.                 'supportSuspension'=>$supportSuspension?is_object($supportSuspension)?$supportSuspension->getId():$supportSuspension['id']:null,
  2071.                 'typeCarton'=>$typeCarton?is_object($typeCarton)?$typeCarton->getId():$typeCarton['id']:null,
  2072.                 'oeille'=>$oeille?is_object($oeille)?$oeille->getId():$oeille['id']:null,
  2073.                 'isEnabled'=>true
  2074.             )
  2075.         );
  2076.         if($productAttribute) {
  2077.             if(in_array($product->getTypeProduct(),[Product::PHOTOS])){
  2078.                 $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $quantite);
  2079.                 if ($priceProductAttr) {
  2080.                     $prixHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * $quantite;
  2081.                     $prixTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()  + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * $quantite;
  2082.                     $prixHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())) * $quantite;
  2083.                     $prixTtcWithoutReduction = ($priceProductAttr->getPrixTtc()  + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())) * $quantite;
  2084.                 }
  2085.             }else{
  2086.                 $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $quantite);
  2087.                 if ($priceProductAttr) {
  2088.                     $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}());
  2089.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()  + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}());
  2090.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt());
  2091.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc()  + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc());
  2092.                 }
  2093.             }
  2094.         }
  2095.         //update price by country
  2096.         $prixHt $this->cart_service->updatePriceByCountry($prixHt,$product);
  2097.         $prixTtc $this->cart_service->updatePriceByCountry($prixTtc,$product);
  2098.         $prixHtWithoutReduction $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
  2099.         $prixTtcWithoutReduction $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
  2100.         $priceAbonnement = [
  2101.             'pricePro' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_PRO,$product,$productAttribute,$quantite,null,null,null,CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$formatL,$formatH),
  2102.             'priceTeam' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_TEAM,$product,$productAttribute,$quantite,null,null,null,CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$formatL,$formatH),
  2103.             'priceEntreprise' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_ENTREPRISE,$product,$productAttribute,$quantite,null,null,null,CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$formatL,$formatH)
  2104.         ];
  2105.         if(in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
  2106.             $surface $formatH $formatL;
  2107.             if($surface 10000){
  2108.                 $surface 10000;
  2109.             }
  2110.             $prixHt *= $surface;
  2111.             $prixTtc *= $surface;
  2112.             $prixHtWithoutReduction *= $surface;
  2113.             $prixTtcWithoutReduction *= $surface;
  2114.         }
  2115.         $dataLocalisation = [
  2116.             'lat' => $lat,
  2117.             'longi' => $long,
  2118.             'codePostal' =>$codePostal ,
  2119.         ];
  2120.         return $this->getPriceAfterPromoAndAbonnement$prixHt,$prixTtc,$prixHtWithoutReduction,$prixTtcWithoutReduction,$abonnement,$carrierId,$typeLivraisonNational,$typeLivraison30min,$priceAbonnement,$dataLocalisation,$imprimeur);
  2121.     }
  2122.     // get btn crello new nb_designer
  2123.     public function getBtnCrello($request,$format_id){
  2124.         $requestData $request->request->all();
  2125.         $idProduct = isset($requestData['idProduct'])? $requestData['idProduct'] : null;
  2126.         $product $this->em->getRepository(Product::class)->find($idProduct);
  2127.         if($product && $product->getIsColorLab()) {
  2128.             $typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
  2129.             $formatId = isset($requestData['format']) ? $requestData['format'] : null;
  2130.             $specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
  2131.             $couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
  2132.             $tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
  2133.             $zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
  2134.             $nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
  2135.             $gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
  2136.             $supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
  2137.             $typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
  2138.             $oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
  2139.             $typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
  2140.             $qty = isset($requestData['qty']) ? $requestData['qty'] : null;
  2141.             $isMobileInterface = isset($requestData['isMobileInterface']) ? $requestData['isMobileInterface'] : null;
  2142.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(
  2143.                 array(
  2144.                     'product'=>$idProduct,
  2145.                     'format'=>$formatId,
  2146.                     'gramage'=>$gramageId,
  2147.                     'typeImpression'=>$typeImpressionId,
  2148.                     'typeFormat'=>$typeFormatId,
  2149.                     'specificite'=>$specificiteId,
  2150.                     'typeCouleur'=>$couleurId,
  2151.                     'taille'=>$tailleId,
  2152.                     'zoneImpression'=>$zoneImpressionId,
  2153.                     'nbrCouleur'=>$nbrCouleurId,
  2154.                     'supportSuspension'=>$supportSuspensionId,
  2155.                     'typeCarton'=>$typeCartonId,
  2156.                     'oeille'=>$oeilleId,
  2157.                     'isEnabled'=>true
  2158.                 )
  2159.             );
  2160.             $designType null;
  2161.             if($productAttribute){
  2162.                 if(!$qty){
  2163.                     $qty 1;
  2164.                 }
  2165.                if($productAttribute->getDesignTypeColorLab() and !empty($productAttribute->getDesignTypeColorLab())){
  2166.                    $designType $productAttribute->getDesignTypeColorLab();
  2167.                }else{
  2168.                    $resultPrice $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(),$qty);
  2169.                    $designType $resultPrice->getDesignTypeColorLab();
  2170.                }
  2171.             }
  2172.              return $this->twig->render('front/product-option/btn-crello-new.html.twig', ['isMobileInterface'=>$isMobileInterface,'product'=>$product,'isColorLab' => true,'designType' => $designType,'format'=> $productAttribute->getFormat(),'type'=>$productAttribute->getTypeFormat()]);
  2173.         }else {
  2174.             if ($format_id) {
  2175.                 $gramge_id = isset($requestData['gramageVista']) ? $requestData['gramageVista'] : null;
  2176.                 $gramage =$gramge_id $this->em->getRepository(Attribut::class)->find($gramge_id):null;
  2177.                 $format $this->em->getRepository(Attribut::class)->find($format_id);
  2178.                 if($product && !$product->getIsColorLab() && !in_array($product->getTypeProduct(),[Product::PAPIER,Product::PAPIER_POSTE]) ){
  2179.                     return $this->twig->render('front/product-option/btn-crello-new.html.twig', ['product'=>$product,'format' => $format,'gramage'=>$gramage]);
  2180.                 }else{
  2181.                     return $this->twig->render('front/product-option/btn-crello.html.twig', ['product'=>$product,'format' => $format,'gramage'=>$gramage]);
  2182.                 }
  2183.             }
  2184.         }
  2185.         return 1;
  2186.     }
  2187.     public function getBtnByProductAttribute($request)
  2188.     {
  2189.         $requestData $request->request->all();
  2190.         $idProductAttribute = isset($requestData['idProductAttribute']) ? $requestData['idProductAttribute'] : null;
  2191.         $qty = isset($requestData['qty']) ? $requestData['qty'] : null;
  2192.         $productAttribute $this->em->getRepository(ProductAttribute::class)->find($idProductAttribute);
  2193.         if ($productAttribute) {
  2194.             if ($productAttribute->getProduct() && $productAttribute->getProduct()->getIsColorLab()) {
  2195.                 if (!$qty) {
  2196.                     $qty 1;
  2197.                 }
  2198.                 if ($productAttribute->getDesignTypeColorLab() and !empty($productAttribute->getDesignTypeColorLab())) {
  2199.                     $designType $productAttribute->getDesignTypeColorLab();
  2200.                 } else {
  2201.                     $resultPrice $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
  2202.                     $designType $resultPrice->getDesignTypeColorLab();
  2203.                 }
  2204.                 return $this->twig->render('front/product-option/btn-select-product-attribute.html.twig', ['product' => $productAttribute->getProduct(), 'isColorLab' => true'designType' => $designType]);
  2205.             } else {
  2206.                 if ($productAttribute->getFormat()) {
  2207.                     $format $this->em->getRepository(Attribut::class)->find($productAttribute->getFormat()->getId());
  2208.                     return $this->twig->render('front/product-option/btn-select-product-attribute.html.twig', ['product' => $productAttribute->getProduct(), 'format' => $format]);
  2209.                 }
  2210.             }
  2211.         }
  2212.         return 1;
  2213.     }
  2214.     public function getOptionByProductAttributeAndFinitionAndQty($request){
  2215.         $requestData $request->request->all();
  2216.         $idProductAttribute = isset($requestData['idProductAttribute']) ? $requestData['idProductAttribute'] : null;
  2217.         $qty = isset($requestData['qty']) ? $requestData['qty'] : null;
  2218.         $finition = isset($requestData['finition']) ? $requestData['finition'] : null;
  2219.         $verification = isset($requestData['verification']) ? $requestData['verification'] : null;
  2220.         $bordsArrondis = isset($requestData['bordsArrondis']) ? $requestData['bordsArrondis'] : null;
  2221.         $plastification = isset($requestData['plastification']) ? $requestData['$plastification'] : null;
  2222.         $productAttribute $this->em->getRepository(ProductAttribute::class)->find($idProductAttribute);
  2223.         if ($productAttribute) {
  2224.             $product $productAttribute->getProduct();
  2225.             if($product->getIsColorLab()){
  2226.                     $types $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_FORMAT,null,null,null,null,null,null,null,null,null);
  2227.                     $type $productAttribute->getTypeFormat();
  2228.                     $formats $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,$type?$type->getId():null,null,null,null,null,null);
  2229.                     $specificites $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SPECIFICITE,null,null,null,$type?$type->getId():null,null,null,null,null,null);
  2230.                     $isFinitionGlace null;
  2231.                     $isFinitionMate null;
  2232.                     $isFinitionRepositionalble null;
  2233.                     $isFinitionTransparent null;
  2234.                     $isFinitionSoftTouch null;
  2235.                     $isFinitionPelliculemat null;
  2236.                     $isFinitionPelliculeBrillant null;
  2237.                     $couleur null;
  2238.                     $taille null;
  2239.                     $nbrCouleur null;
  2240.                     $gramage null;
  2241.                     $supportSuspension null;
  2242.                     $typeCarton null;
  2243.                     $oeille null;
  2244.                     $typeImpression null;
  2245.                     if($formats){
  2246.                         $format $productAttribute->getFormat();
  2247.                         if($format){
  2248.                             $isFinitionGlace $format->getIsFinitionGlasse();
  2249.                             $isFinitionMate $format->getIsFinitionMate();
  2250.                             $isFinitionTransparent $format->getIsFinitionTransparent();
  2251.                             $isFinitionRepositionalble $format->getIsFinitionRepositionalble();
  2252.                             $isFinitionSoftTouch $format->getIsFinitionSoftTouch();
  2253.                             $isFinitionPelliculemat $format->getIsFinitionPelliculemat();
  2254.                             $isFinitionPelliculeBrillant $format->getIsFinitionPelliculeBrillant();
  2255.                         }
  2256.                     }
  2257.                     if($specificites){$specificite $productAttribute->getSpecificite();}
  2258.                     $couleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,null,null,null,null);
  2259.                     if($couleurs){$couleur $productAttribute->getTypeCouleur();}
  2260.                     $tailles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,null,null,null);
  2261.                     if($tailles){$taille $productAttribute->getTaille();}
  2262.                     $zoneImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,null,null);
  2263.                     if($zoneImpressions){$zoneImpression $productAttribute->getZoneImpression();}
  2264.                     $nbrCouleurs $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,null);
  2265.                     if($nbrCouleurs){$nbrCouleur $productAttribute->getNbrCouleur();}
  2266.                     $gramages $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
  2267.                     if($gramages){$gramage $productAttribute->getGramage();}
  2268.                     $supportSuspensions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
  2269.                     if($supportSuspensions){$supportSuspension $productAttribute->getSupportSuspension();}
  2270.                     $typeImpressions $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
  2271.                     if($typeImpressions){$typeImpression $productAttribute->getTypeImpression();}
  2272.                     $typeCartons $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
  2273.                     if($typeCartons){$typeCarton $productAttribute->getTypeCarton();}
  2274.                     $oeilles $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null,$typeCarton?$typeCarton->getId():null);
  2275.                     if($oeilles){$oeille $productAttribute->getOeille();}
  2276.                     $qtys $this->getQtyPosible($product->getId(),$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$supportSuspension,$supportSuspension,$typeCarton,$oeille);
  2277.                     return array(
  2278.                         'product' => $product,
  2279.                         'types' => $types,
  2280.                         'type' => $type,
  2281.                         'formats' => $formats,
  2282.                         'format' => $format,
  2283.                         'specificites' => $specificites,
  2284.                         'specificite' => $specificite,
  2285.                         'couleurs' => $couleurs,
  2286.                         'couleur' => $couleur,
  2287.                         'tailles' => $tailles,
  2288.                         'taille' => $taille,
  2289.                         'zoneImpressions' => $zoneImpressions,
  2290.                         'zoneImpression' => $zoneImpression,
  2291.                         'nbrCouleurs' => $nbrCouleurs,
  2292.                         'nbrCouleur' => $nbrCouleur,
  2293.                         'gramages' => $gramages,
  2294.                         'gramage' => $gramage,
  2295.                         'supportSuspensions' => $supportSuspensions,
  2296.                         'supportSuspension' => $supportSuspension,
  2297.                         'typeCartons' => $typeCartons,
  2298.                         'typeCarton' => $typeCarton,
  2299.                         'oeilles' => $oeilles,
  2300.                         'oeille' => $oeille,
  2301.                         'typeImpressions' => $typeImpressions,
  2302.                         'typeImpression' => $typeImpression,
  2303.                         'isFinitionGlace' => $isFinitionGlace,
  2304.                         'isFinitionMate' => $isFinitionMate,
  2305.                         'isFinitionRepositionalble' => $isFinitionRepositionalble,
  2306.                         'isFinitionTransparent' => $isFinitionTransparent,
  2307.                         'isFinitionSoftTouch' => $isFinitionSoftTouch,
  2308.                         'isFinitionPelliculemat' => $isFinitionPelliculemat,
  2309.                         'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
  2310.                         'finition' => $finition,
  2311.                         'verification' => $verification,
  2312.                         'bordsArrondis' => $bordsArrondis,
  2313.                         'plastification' => $plastification,
  2314.                         'qtys' => $qtys['qtys'],
  2315.                         'qtysPlus' => $qtys['qtysPlus'],
  2316.                         'qtysTeam' => $qtys['qtysTeam'],
  2317.                         'qty' => $qty,
  2318.                         'price' => $this->getPriceColorLab($product->getId(),$format,$gramage,null,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$qty,null,null,null,null,null,null,null,$supportSuspension,100,100,$typeCarton,$oeille),
  2319.                     );
  2320.             }
  2321.             else {
  2322.                 $id_product $product->getId();
  2323.                 $formats $this->em->getRepository(Attribut::class)->getFormatByProduct($product);
  2324.                 $format $productAttribute->getFormat();
  2325.                 $format_id $productAttribute->getFormat()->getId();
  2326.                 $rectoverso $productAttribute->getRectoverso();
  2327.                 $gramage_id $productAttribute->getGramage()->getId();
  2328.                 if ($product && $product->getTypeProduct() == Product::AFFICHE) {
  2329.                     $typeImpression_id $productAttribute->getTypeImpression()->getId();
  2330.                     $typeImpression $this->getTypeImpression($id_product$format_id);
  2331.                     $gramage $this->getGrammageByTypeImpression($id_product$format_id$typeImpression_id);
  2332.                     $qtys $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id$format_id$typeImpression_id$productAttribute->getPlastification(), $finition);
  2333.                 } else {
  2334.                     $gramage $this->getGramage($id_product$format_id$rectoverso);
  2335.                     $qtys $this->getQtyPosibleByGrammage($gramage_id$format_id$rectoverso$finition);
  2336.                     $typeImpression false;
  2337.                     $typeImpression_id false;
  2338.                 }
  2339.                 $isFinitionGlace $format->getIsFinitionGlasse();
  2340.                 $isFinitionMate $format->getIsFinitionMate();
  2341.                 $isFinitionTransparent $format->getIsFinitionTransparent();
  2342.                 $isFinitionRepositionalble $format->getIsFinitionRepositionalble();
  2343.                 $isFinitionSoftTouch $format->getIsFinitionSoftTouch();
  2344.                 $isFinitionPelliculemat $format->getIsFinitionPelliculemat();
  2345.                 $isFinitionPelliculeBrillant $format->getIsFinitionPelliculeBrillant();
  2346.                 $isEnveloppe 0;
  2347.                 return array(
  2348.                     'isFinitionGlace' => $isFinitionGlace,
  2349.                     'isFinitionMate' => $isFinitionMate,
  2350.                     'isFinitionRepositionalble' => $isFinitionRepositionalble,
  2351.                     'isFinitionSoftTouch' => $isFinitionSoftTouch,
  2352.                     'isFinitionPelliculemat' => $isFinitionPelliculemat,
  2353.                     'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
  2354.                     'isFinitionTransparent' => $isFinitionTransparent,
  2355.                     'formats' => $formats,
  2356.                     'format_id' => $format_id,
  2357.                     'format' => $format,
  2358.                     'gramage' => $gramage,
  2359.                     'gramage_id' => $gramage_id,
  2360.                     'typeImpression' => $typeImpression,
  2361.                     'typeImpression_id' => $typeImpression_id,
  2362.                     'qtys' => $qtys['qtys'],
  2363.                     'qtysPlus' => $qtys['qtysPlus'],
  2364.                     'qtysTeam' => $qtys['qtysTeam'],
  2365.                     'qty' => $qty,
  2366.                     'id_product' => $id_product,
  2367.                     'product' => $product,
  2368.                     'rectoverso' => $rectoverso,
  2369.                     'finition' => $finition,
  2370.                     'isEnveloppe' => $isEnveloppe,
  2371.                     'verification' => $verification,
  2372.                     'bordsArrondis' => $bordsArrondis,
  2373.                     'plastification' => $plastification,
  2374.                     'price' => $this->getPrice($id_product$format_id$gramage_id$typeImpression_id$rectoverso$qty$finition$isEnveloppefalsefalse$productAttribute->getPlastification(), nullnullnullnullnullnullnull$verification,$bordsArrondis,$plastification),
  2375.                 );
  2376.             }
  2377.         }
  2378.         return [];
  2379.     }
  2380.     public function gePriceCartWithAbonnementProAndWithTypeProduct($typeAbonnement,$product,$productAttribute,$quantite,$finition,$plus_expert,$isEnveloppe,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$formatL=100,$formatH=100,$plastification CartDetail::PLASTIFICATION_NOT_CHECKED){
  2381.         if($productAttribute) {
  2382.             $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement);
  2383.             $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $quantite);
  2384.             if ($priceProductAttr) {
  2385.                 $priceFinitonHt  0;
  2386.                 $priceFinitonTtc  0;
  2387.                 $priceFinitonHtWithoutReduction  0;
  2388.                 $priceFinitonTtcWithoutReduction  0;
  2389.                 $pourcentageFinition 0;
  2390.                 if($finition == CartDetail::FINITION_GLACE){
  2391.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  2392.                 }else if($finition == CartDetail::FINITION_MATE){
  2393.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  2394.                 }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  2395.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  2396.                 }else if($finition == CartDetail::FINITION_TRANSPARENT){
  2397.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  2398.                 }else if($finition == CartDetail::FINITION_SoftTouch){
  2399.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  2400.                 }else if($finition == CartDetail::FINITION_Pelliculemat){
  2401.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  2402.                 }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  2403.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  2404.                 }
  2405.                 $priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) )* $pourcentageFinition;
  2406.                 $priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
  2407.                 $priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
  2408.                 $priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
  2409.                 $priceBordsArrondisHt  0;
  2410.                 $priceBordsArrondisTtc  0;
  2411.                 $priceBordsArrondisHtWithoutReduction  0;
  2412.                 $priceBordsArrondisTtcWithoutReduction  0;
  2413.                 if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
  2414.                     $priceBordsArrondisHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  2415.                     $priceBordsArrondisTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  2416.                     $priceBordsArrondisHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  2417.                     $priceBordsArrondisTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  2418.                 }
  2419.                 $pricePlastificationHt  0;
  2420.                 $pricePlastificationTtc  0;
  2421.                 $pricePlastificationHtWithoutReduction  0;
  2422.                 $pricePlastificationTtcWithoutReduction  0;
  2423.                 if($plastification == CartDetail::PLASTIFICATION_CHECKED){
  2424.                     $pricePlastificationHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  2425.                     $pricePlastificationTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  2426.                     $pricePlastificationHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  2427.                     $pricePlastificationTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  2428.                 }
  2429. //                if($plus_expert && $isCrea){
  2430.                 if($plus_expert){
  2431.                     $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())  + CartDetail::PLUS_EXPERT_HT +$priceFinitonHt $priceBordsArrondisHt $pricePlastificationHt;
  2432.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() ) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtc $priceBordsArrondisTtc $pricePlastificationTtc;
  2433.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())  + CartDetail::PLUS_EXPERT_HT +$priceFinitonHtWithoutReduction $priceBordsArrondisHtWithoutReduction  $pricePlastificationHtWithoutReduction;
  2434.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtcWithoutReduction $priceBordsArrondisTtcWithoutReduction $pricePlastificationTtcWithoutReduction;
  2435.                 }else{
  2436.                     $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt $priceBordsArrondisHt $pricePlastificationHt;
  2437.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()  + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+ $priceFinitonTtc $priceBordsArrondisTtc $pricePlastificationTtc;
  2438.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction $priceBordsArrondisHtWithoutReduction $pricePlastificationHtWithoutReduction;
  2439.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc()  + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+ $priceFinitonTtcWithoutReduction $priceBordsArrondisTtcWithoutReduction $pricePlastificationTtcWithoutReduction;
  2440.                 }
  2441.                 if(($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or  ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  2442.                     if($isEnveloppe) {
  2443.                         $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $quantite);
  2444.                         $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $quantite);
  2445.                         $prixHtWithoutReduction $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT $quantite);
  2446.                         $prixTtcWithoutReduction $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC $quantite);
  2447.                     }
  2448.                 }
  2449.                 $surface 1;
  2450.                 if(in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
  2451.                     $surface $formatL $formatH;
  2452.                     if($surface <10000){
  2453.                         $surface 10000;
  2454.                     }
  2455.                 }
  2456.                 $prixHt $this->cart_service->updatePriceByCountry($prixHt,$product);
  2457.                 $prixTtc $this->cart_service->updatePriceByCountry($prixTtc,$product);
  2458.                 $prixHtWithoutReduction $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
  2459.                 $prixTtcWithoutReduction $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
  2460.                 return [
  2461.                     'prixHtTotal' => number_format((float)$prixHt $surface,2),
  2462.                     'prixTtcTotal' => number_format((float)$prixTtc $surface,2),
  2463.                     'prixHtWithoutReductionTotal' => number_format((float)$prixHtWithoutReduction $surface,2),
  2464.                     'prixTtcWithoutReductionTotal' => number_format((float)$prixTtcWithoutReduction $surface,2)
  2465.                 ];
  2466.             }
  2467.         }
  2468.         return [
  2469.             'prixHtTotal' => 0,
  2470.             'prixTtcTotal' => 0,
  2471.             'prixHtWithoutReductionTotal' => 0,
  2472.             'prixTtcWithoutReductionTotal' => 0
  2473.         ];
  2474.     }
  2475.     // add to cart new nb_designer
  2476.     private function getFilePhotoQuantiy($filesToken){
  2477.         if($filesToken){
  2478.             $array explode(',',$filesToken);
  2479.             return count($array);
  2480.         }
  2481.         return 0;
  2482.     }
  2483.     private function addFilesInCartDetail($filesToken,$cartDetail){
  2484.         if($filesToken){
  2485.             $array explode(',',$filesToken);
  2486.             foreach ($array as $item) {
  2487.                 $file $this->em->getRepository(CartDetailPhotos::class)->findOneBy(['token' => $item]);
  2488.                 if ($file) {
  2489.                     $file->setCartDetail($cartDetail);
  2490.                     $this->em->persist($file);
  2491.                     $this->em->flush();
  2492.                 }
  2493.             }
  2494.         }
  2495.     }
  2496.     private function addFilesPhotoInZip($filesToken,$token){
  2497.         $array = [];
  2498.         if($filesToken){
  2499.             $zip = new \ZipArchive();
  2500.             $nameFichier 'ma_crea_' $token '.zip';
  2501.             $zipfile $this->params->get('uploads_directory') . '/tmp/' $nameFichier;
  2502.             if (file_exists($zipfile)) unlink($zipfile);
  2503.             if ($zip->open($zipfile, \ZipArchive::CREATE) === TRUE) {
  2504.                 $arrayToken explode(','$filesToken);
  2505.                 $filePapierFirstImage null;
  2506.                 foreach ($arrayToken as $key => $item) {
  2507.                     $file $this->em->getRepository(CartDetailPhotos::class)->findOneBy(['token' => $item]);
  2508.                     if ($file) {
  2509.                         if($key == 0){
  2510.                             $filePapierFirstImage $file->getFile();
  2511.                         }
  2512.                         $zip->addFile($this->params->get('uploads_directory') . '/tmp/' $file->getFile(), $file->getFile());
  2513.                     }
  2514.                 }
  2515.                 $zip->close();
  2516.                 $array['fileZipe'] = $nameFichier;
  2517.                 $array['filePapierFirstImage'] = $filePapierFirstImage;
  2518.             }
  2519.         }
  2520.         return $array;
  2521.     }
  2522.     public function addToCartNewNbDesigner($request,$user) : array
  2523.     {
  2524.         $requestData $request->request->all();
  2525.         $productId = isset($requestData['idProduct'])? $requestData['idProduct'] : null;
  2526.         $qty = isset($requestData['qty'])? $requestData['qty'] : null;
  2527.         $id_format = isset($requestData['format_id'])? $requestData['format_id'] : null;
  2528.         $rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
  2529.         $finition = isset($requestData['finition'])? $requestData['finition'] : null;
  2530.         $id_grammage = isset($requestData['gramage_id'])? $requestData['gramage_id'] : null;
  2531.         $typeImpression = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
  2532.         $isEnveloppe = isset($requestData['isEnveloppe'])? $requestData['isEnveloppe'] : false;
  2533.         $verification = isset($requestData['verification'])? $requestData['verification'] : false;
  2534.         $bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : false;
  2535.         $plastification = isset($requestData['plastification'])? $requestData['plastification'] : false;
  2536.         $plus_expert = isset($requestData['plus_expert'])? $requestData['plus_expert'] : false;
  2537.         $isTrait = isset($requestData['isTrait'])? $requestData['isTrait'] : false;
  2538.         $isFontBlanc = isset($requestData['isFontBlanc'])? $requestData['isFontBlanc'] : 0;
  2539.         $tokenDetail = isset($requestData['tokenDetail'])? $requestData['tokenDetail'] : null;
  2540.         $designUrl = isset($requestData['designUrl'])? $requestData['designUrl'] : null;
  2541.         $designId = isset($requestData['designId'])? $requestData['designId'] : null;
  2542.         $fileDesignUrl = isset($requestData['fileDesignUrl'])? $requestData['fileDesignUrl'] : null;
  2543.         $fileDesignFirstImage = isset($requestData['fileDesignFirstImage'])? $requestData['fileDesignFirstImage'] : null;
  2544.         $typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
  2545.         $formatId = isset($requestData['format']) ? $requestData['format'] : null;
  2546.         $specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
  2547.         $couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
  2548.         $tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
  2549.         $zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
  2550.         $nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
  2551.         $gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
  2552.         $supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
  2553.         $typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
  2554.         $oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
  2555.         $typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
  2556.         $formatL = isset($requestData['formatL'])? $requestData['formatL'] : 100;
  2557.         $formatH = isset($requestData['formatH'])? $requestData['formatH'] : 100;
  2558.         $photosToken = isset($requestData['photosToken']) ? $requestData['photosToken'] : null;
  2559.         $product $this->em->getRepository(Product::class)->find($productId);
  2560.         if($tokenDetail){
  2561.             $cartDetail $this->em->getRepository(CartDetail::class)->findOneBy(['token'=>$tokenDetail]);
  2562.             if(!$cartDetail){
  2563.                 return ['erreur'=> 'erreur !'];
  2564.             }
  2565.             $token $cartDetail->getToken();
  2566.         }else{
  2567.             $cartDetail = new CartDetail();
  2568.             $token $this->generateToken(32);
  2569.         }
  2570.         $cart $this->cart_service->getCartCurrent();
  2571.         if(!$cart){
  2572.             $cart $this->cart_service->createCart(true);
  2573.         }
  2574.         $typeAbonnement $this->cart_service->getTypeAbonnementPro($user,$cart->getId()); // get type abonnement
  2575.         $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
  2576.         $cartDetail->setTypeProduct($product->getTypeProduct());
  2577.         $cartDetail->setToken($token);
  2578.         $cartDetail->setProduct($product);
  2579.         $cartDetail->setCart($cart);
  2580.         if($photosToken){
  2581.             $qty $this->getFilePhotoQuantiy($photosToken);
  2582.             $cartDetail->setNbrPapier($qty);
  2583.         }else{
  2584.             $cartDetail->setNbrPapier($qty);
  2585.         }
  2586.         $cartDetail->setQty(0);
  2587.         $cartDetail->setQtyColor(0);
  2588.         $cartDetail->setQtyNoir(0);
  2589.         $cartDetail->setProductName($product->getTitre());
  2590.         if(in_array($product->getTypeProduct(),[Product::PHOTOS])){
  2591.             if($photosToken){
  2592.                 $arrayFiles $this->addFilesPhotoInZip($photosToken,$token);
  2593.             }else{
  2594.                 return ['erreur'=> 'il faut uploader les photos'];
  2595.             }
  2596.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(
  2597.                 array(
  2598.                     'product'=>$productId,
  2599.                     'format'=>$formatId,
  2600.                     'gramage'=>$gramageId,
  2601.                     'typeImpression'=>$typeImpressionId,
  2602.                     'typeFormat'=>$typeFormatId,
  2603.                     'specificite'=>$specificiteId,
  2604.                     'typeCouleur'=>$couleurId,
  2605.                     'taille'=>$tailleId,
  2606.                     'zoneImpression'=>$zoneImpressionId,
  2607.                     'nbrCouleur'=>$nbrCouleurId,
  2608.                     'supportSuspension'=>$supportSuspensionId,
  2609.                     'typeCarton'=>$typeCartonId,
  2610.                     'oeille'=>$oeilleId,
  2611.                     'isEnabled'=>true
  2612.                 )
  2613.             );
  2614.             if(!$productAttribute ){
  2615.                 return ['erreur'=> 'il faut choisr un produit'];
  2616.             }
  2617.             $cartDetail->setIsMaCrea(true);
  2618.             if($arrayFiles && isset($arrayFiles['fileZipe']) && isset($arrayFiles['filePapierFirstImage'])){
  2619.                 $fileDesignUrl $arrayFiles['fileZipe'];
  2620.                 $filePapierFirstImage $arrayFiles['filePapierFirstImage'];
  2621.                 $cartDetail->setFilePapier($fileDesignUrl);
  2622.                 $cartDetail->setFilePapierFirstImage($filePapierFirstImage);
  2623.                 $name str_replace(' ','_',$product->getTitre());
  2624.                 $cartDetail->setFilePapierName($name.'-'.$fileDesignUrl);
  2625.             }
  2626.             $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), (int)$qty);;
  2627.             if($priceProductAttr->getIsExaprint()){
  2628.                 $cartDetail->setIsExaprint(true);
  2629.             }else{
  2630.                 $cartDetail->setIsExaprint(false);
  2631.             }
  2632.             $cartDetail->setMauvaisFormat($isFontBlanc);
  2633.             $priceFinitonHt  0;
  2634.             $priceFinitonTtc  0;
  2635.             $priceFinitonHtWithoutReduction  0;
  2636.             $priceFinitonTtcWithoutReduction  0;
  2637.             $pourcentageFinition 0;
  2638.             if($finition == CartDetail::FINITION_GLACE){
  2639.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  2640.             }else if($finition == CartDetail::FINITION_MATE){
  2641.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  2642.             }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  2643.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  2644.             }else if($finition == CartDetail::FINITION_TRANSPARENT){
  2645.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  2646.             }else if($finition == CartDetail::FINITION_SoftTouch){
  2647.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  2648.             }else if($finition == CartDetail::FINITION_Pelliculemat){
  2649.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  2650.             }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  2651.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  2652.             }
  2653.             $priceFinitonHt = (($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* $pourcentageFinition) * (int)$qty;
  2654.             $priceFinitonTtc = (($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))*$pourcentageFinition) * (int)$qty;
  2655.             $priceFinitonHtWithoutReduction = (($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition) * (int)$qty;
  2656.             $priceFinitonTtcWithoutReduction = (($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition) * (int)$qty;
  2657.             $priceVerificationCheckedTtc  0;
  2658.             $priceVerificationCheckedHt  0;
  2659.             if($verification == CartDetail::VERIFICATION_CHECKED){
  2660.                 $priceVerificationCheckedTtc CartDetail::VERIFICATION_TTC;
  2661.                 $priceVerificationCheckedHt CartDetail::VERIFICATION_HT;
  2662.             }
  2663.             $priceBordsArrondisHt  0;
  2664.             $priceBordsArrondisTtc  0;
  2665.             $priceBordsArrondisHtWithoutReduction  0;
  2666.             $priceBordsArrondisTtcWithoutReduction  0;
  2667.             if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
  2668.                 $priceBordsArrondisHt = (($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())))* CartDetail::POURCENTAGE_BORDS_ARRONDIS* (int)$qty;
  2669.                 $priceBordsArrondisTtc = (($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())))* CartDetail::POURCENTAGE_BORDS_ARRONDIS* (int)$qty;
  2670.                 $priceBordsArrondisHtWithoutReduction = (($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())))* CartDetail::POURCENTAGE_BORDS_ARRONDIS* (int)$qty;
  2671.                 $priceBordsArrondisTtcWithoutReduction = (($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())))* CartDetail::POURCENTAGE_BORDS_ARRONDIS* (int)$qty;
  2672.             }
  2673.             $pricePlastificationHt  0;
  2674.             $pricePlastificationTtc  0;
  2675.             $pricePlastificationHtWithoutReduction  0;
  2676.             $pricePlastificationTtcWithoutReduction  0;
  2677.             if($plastification == CartDetail::PLASTIFICATION_CHECKED){
  2678.                 $pricePlastificationHt = (($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())))* CartDetail::POURCENTAGE_PLASTIFICATION* (int)$qty;
  2679.                 $pricePlastificationTtc = (($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())))* CartDetail::POURCENTAGE_PLASTIFICATION* (int)$qty;
  2680.                 $pricePlastificationHtWithoutReduction = (($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())))* CartDetail::POURCENTAGE_PLASTIFICATION* (int)$qty;
  2681.                 $pricePlastificationTtcWithoutReduction = (($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())))* CartDetail::POURCENTAGE_PLASTIFICATION* (int)$qty;
  2682.             }
  2683.             $prixHt  = (($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * (int)$qty)+$priceFinitonHt +$priceVerificationCheckedHt $priceBordsArrondisHt  $pricePlastificationHt;
  2684.             $prixTtc = (($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * (int)$qty)+$priceFinitonTtc $priceVerificationCheckedTtc $priceBordsArrondisTtc  $pricePlastificationTtc;
  2685.             $prixHtWithoutReduction = (($priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())) * (int)$qty)+$priceFinitonHtWithoutReduction +$priceVerificationCheckedHt $priceBordsArrondisHtWithoutReduction  $pricePlastificationHtWithoutReduction;
  2686.             $prixTtcWithoutReduction = (($priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())) * (int)$qty)+$priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc $priceBordsArrondisTtcWithoutReduction  $pricePlastificationTtcWithoutReduction;
  2687.             $cartDetail->setIsEnveloppe($isEnveloppe);
  2688.             $cartDetail->setIsPlusExpert($plus_expert);
  2689.             $cartDetail->setFinition($finition);
  2690.             $cartDetail->setIsPlusVerification($verification);
  2691.             $cartDetail->setIsPlusBordsArrondis($bordsArrondis);
  2692.             $cartDetail->setIsPlusPlastification($plastification);
  2693.             $cartDetail->setIsTrait($isTrait);
  2694.         }else{
  2695.             if($product->getIsColorLab()){
  2696.                 $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(
  2697.                     array(
  2698.                         'product'=>$productId,
  2699.                         'format'=>$formatId,
  2700.                         'gramage'=>$gramageId,
  2701.                         'typeImpression'=>$typeImpressionId,
  2702.                         'typeFormat'=>$typeFormatId,
  2703.                         'specificite'=>$specificiteId,
  2704.                         'typeCouleur'=>$couleurId,
  2705.                         'taille'=>$tailleId,
  2706.                         'zoneImpression'=>$zoneImpressionId,
  2707.                         'nbrCouleur'=>$nbrCouleurId,
  2708.                         'supportSuspension'=>$supportSuspensionId,
  2709.                         'oeille'=>$oeilleId,
  2710.                         'typeCarton'=>$typeCartonId,
  2711.                         'isEnabled'=>true
  2712.                     )
  2713.                 );
  2714.                 if(!$productAttribute ){
  2715.                     return ['erreur'=> 'il faut choisr un produit'];
  2716.                 }
  2717.                 $designColorLabTokenProduct = isset($requestData['designColorLabTokenProduct']) ? $requestData['designColorLabTokenProduct'] : null;
  2718.                 $designColorLabIdProduct = isset($requestData['designColorLabIdProduct']) ? $requestData['designColorLabIdProduct'] : null;
  2719.                 $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
  2720.                 if($priceProductAttr->getIsExaprint()){
  2721.                     $cartDetail->setIsExaprint(true);
  2722.                 }else{
  2723.                     $cartDetail->setIsExaprint(false);
  2724.                 }
  2725.                 $priceFinitonHt  0;
  2726.                 $priceFinitonTtc  0;
  2727.                 $priceFinitonHtWithoutReduction  0;
  2728.                 $priceFinitonTtcWithoutReduction  0;
  2729.                 $pourcentageFinition 0;
  2730.                 if($finition == CartDetail::FINITION_GLACE){
  2731.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  2732.                 }else if($finition == CartDetail::FINITION_MATE){
  2733.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  2734.                 }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  2735.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  2736.                 }else if($finition == CartDetail::FINITION_TRANSPARENT){
  2737.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  2738.                 }else if($finition == CartDetail::FINITION_SoftTouch){
  2739.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  2740.                 }else if($finition == CartDetail::FINITION_Pelliculemat){
  2741.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  2742.                 }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  2743.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  2744.                 }
  2745.                 $priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* $pourcentageFinition;
  2746.                 $priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
  2747.                 $priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
  2748.                 $priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
  2749.                 $prixHt  $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())+$priceFinitonHt  ;
  2750.                 $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+$priceFinitonTtc ;
  2751.                 $prixHtWithoutReduction $priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())+$priceFinitonHtWithoutReduction;
  2752.                 $prixTtcWithoutReduction $priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+$priceFinitonTtcWithoutReduction;
  2753.                 $surface 1;
  2754.                 if(in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
  2755.                     $surface $formatL $formatH;
  2756.                     if($surface 10000){
  2757.                         $surface 10000;
  2758.                     }
  2759.                     $prixHt *= $surface;
  2760.                     $prixTtc *= $surface;
  2761.                     $prixHtWithoutReduction *= $surface;
  2762.                     $prixTtcWithoutReduction *= $surface;
  2763.                     $cartDetail->setFormatHauteur($formatH);
  2764.                     $cartDetail->setFormatLargeur($formatL);
  2765.                 }
  2766.                 $filePapierFirstImage null;
  2767.                 if($designColorLabTokenProduct && $designColorLabIdProduct){
  2768.                     $dataPdf $this->downloadPdfColorlab($request,$designColorLabTokenProduct,$designColorLabIdProduct,$token);
  2769.                     $filePapier = isset($dataPdf['pdfName'])? $dataPdf['pdfName'] : false;
  2770.                     $filePapierFirstImage = isset($dataPdf['firstImage'])? $dataPdf['firstImage'] : false;
  2771.                     if(!$filePapier || !$filePapierFirstImage ){
  2772.                         return ['erreur'=> 'erreur convert pdf !'];
  2773.                     }
  2774.                     $cartDetail->setIsMaCrea(false);
  2775.                     $cartDetail->setFilePapier($filePapier);
  2776.                     $cartDetail->setFilePapierFirstImage($filePapierFirstImage);
  2777.                     $name str_replace(' ','_',$product->getTitre());
  2778.                     $cartDetail->setFilePapierName($name.'-'.$filePapier);
  2779.                     $cartDetail->setColorLabTokenProduct($designColorLabTokenProduct);
  2780.                     $cartDetail->setColorLabIdProduct($designColorLabIdProduct);
  2781.                 }else if($fileDesignUrl){
  2782.                     $filePapierFirstImage $fileDesignFirstImage;
  2783.                     $cartDetail->setIsMaCrea(true);
  2784.                     $cartDetail->setFilePapier($fileDesignUrl);
  2785.                     $cartDetail->setFilePapierFirstImage($filePapierFirstImage);
  2786.                     $name str_replace(' ','_',$product->getTitre());
  2787.                     $cartDetail->setFilePapierName($name.'-'.$fileDesignUrl);
  2788.                 }else if($tokenDetail ){
  2789.                     $filePapierFirstImage $cartDetail->getFilePapierFirstImage();
  2790.                 }
  2791.             }
  2792.             else{
  2793.                 if(!$productId || !$qty || !$id_format ){
  2794.                     return ['erreur'=> 'il faut choisr un produit'];
  2795.                 }
  2796.                 if($designUrl){
  2797.                     $dataPdf $this->downloadPdfCrello($request,$designUrl,$token);
  2798.                     $filePapier = isset($dataPdf['pdfName'])? $dataPdf['pdfName'] : false;
  2799.                     $filePapierFirstImage = isset($dataPdf['firstImage'])? $dataPdf['firstImage'] : false;
  2800.                     if(!$filePapier || !$filePapierFirstImage ){
  2801.                         return ['erreur'=> 'erreur convert pdf !'];
  2802.                     }
  2803.                     $cartDetail->setIsMaCrea(false);
  2804.                     $cartDetail->setFilePapier($filePapier);
  2805.                     $cartDetail->setFilePapierFirstImage($filePapierFirstImage);
  2806.                     if($product->getTypeProduct() == Product::CARTE){
  2807.                         $name 'carte-visite';
  2808.                     }else if($product->getTypeProduct() == Product::FLYERS){
  2809.                         $name 'flyrs';
  2810.                     }else if($product->getTypeProduct() == Product::AFFICHE){
  2811.                         $name 'affiche';
  2812.                     }else if($product->getTypeProduct() == Product::MENU){
  2813.                         $name 'menu';
  2814.                     }else if($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
  2815.                         $name 'faire_naissance';
  2816.                     }else if($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
  2817.                         $name 'faire_mariage';
  2818.                     }else{
  2819.                         $name str_replace(' ','_',$product->getTitre());
  2820.                     }
  2821.                     $cartDetail->setFilePapierName($name.'-'.$filePapier);
  2822.                     $cartDetail->setTemplateIdCrello($designId);
  2823.                 }else if($fileDesignUrl){
  2824.                     $filePapierFirstImage $fileDesignFirstImage;
  2825.                     $cartDetail->setIsMaCrea(true);
  2826.                     $cartDetail->setFilePapier($fileDesignUrl);
  2827.                     $cartDetail->setFilePapierFirstImage($filePapierFirstImage);
  2828.                     if($product->getTypeProduct() == Product::CARTE){
  2829.                         $name 'carte-visite';
  2830.                     }else if($product->getTypeProduct() == Product::FLYERS){
  2831.                         $name 'flyrs';
  2832.                     }else if($product->getTypeProduct() == Product::AFFICHE){
  2833.                         $name 'affiche';
  2834.                     }else if($product->getTypeProduct() == Product::MENU){
  2835.                         $name 'menu';
  2836.                     }else if($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
  2837.                         $name 'faire_naissance';
  2838.                     }else if($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
  2839.                         $name 'faire_mariage';
  2840.                     }else{
  2841.                         $name str_replace(' ','_',$product->getTitre());
  2842.                     }
  2843.                     $cartDetail->setFilePapierName($name.'-'.$fileDesignUrl);
  2844.                 }else if($tokenDetail ){
  2845.                     $filePapierFirstImage $cartDetail->getFilePapierFirstImage();
  2846.                 }else if($designId){
  2847.                     return ['erreur'=> 'Vous n\'avez pas choisi votre modéle'];
  2848.                 }
  2849.                 if($product and $product->getTypeProduct() == Product::AFFICHE){
  2850.                     $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_grammage,'typeImpression'=>$typeImpression,'plastification'=>ProductAttribute::SANS_PLASTIFICATION,'isEnabled'=>true));
  2851.                 }else{
  2852.                     $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_grammage,'rectoverso'=>$rectoverso,'isEnabled'=>true));
  2853.                 }
  2854.                 $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
  2855.                 if($priceProductAttr->getIsExaprint()){
  2856.                     $cartDetail->setIsExaprint(true);
  2857.                 }else{
  2858.                     $cartDetail->setIsExaprint(false);
  2859.                 }
  2860.                 $cartDetail->setMauvaisFormat($isFontBlanc);
  2861.                 $priceFinitonHt  0;
  2862.                 $priceFinitonTtc  0;
  2863.                 $priceFinitonHtWithoutReduction  0;
  2864.                 $priceFinitonTtcWithoutReduction  0;
  2865.                 $pourcentageFinition 0;
  2866.                 if($finition == CartDetail::FINITION_GLACE){
  2867.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  2868.                 }else if($finition == CartDetail::FINITION_MATE){
  2869.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  2870.                 }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  2871.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  2872.                 }else if($finition == CartDetail::FINITION_TRANSPARENT){
  2873.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  2874.                 }else if($finition == CartDetail::FINITION_SoftTouch){
  2875.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  2876.                 }else if($finition == CartDetail::FINITION_Pelliculemat){
  2877.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  2878.                 }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  2879.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  2880.                 }
  2881.                 $priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* $pourcentageFinition;
  2882.                 $priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
  2883.                 $priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
  2884.                 $priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
  2885.                 $priceVerificationCheckedTtc  0;
  2886.                 $priceVerificationCheckedHt  0;
  2887.                 if($verification == CartDetail::VERIFICATION_CHECKED){
  2888.                     $priceVerificationCheckedTtc CartDetail::VERIFICATION_TTC;
  2889.                     $priceVerificationCheckedHt CartDetail::VERIFICATION_HT;
  2890.                 }
  2891.                 $priceBordsArrondisHt  0;
  2892.                 $priceBordsArrondisTtc  0;
  2893.                 $priceBordsArrondisHtWithoutReduction  0;
  2894.                 $priceBordsArrondisTtcWithoutReduction  0;
  2895.                 if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
  2896.                     $priceBordsArrondisHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  2897.                     $priceBordsArrondisTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  2898.                     $priceBordsArrondisHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  2899.                     $priceBordsArrondisTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  2900.                 }
  2901.                 $pricePlastificationHt  0;
  2902.                 $pricePlastificationTtc  0;
  2903.                 $pricePlastificationHtWithoutReduction  0;
  2904.                 $pricePlastificationTtcWithoutReduction  0;
  2905.                 if($plastification == CartDetail::PLASTIFICATION_CHECKED){
  2906.                     $pricePlastificationHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  2907.                     $pricePlastificationTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  2908.                     $pricePlastificationHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  2909.                     $pricePlastificationTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_PLASTIFICATION;
  2910.                 }
  2911.                 if($plus_expert){
  2912.                     $prixHt  $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHt +$priceVerificationCheckedHt $priceBordsArrondisHt $pricePlastificationHt;
  2913.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtc $priceVerificationCheckedTtc $priceBordsArrondisTtc $pricePlastificationTtc;
  2914.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHtWithoutReduction +$priceVerificationCheckedHt $priceBordsArrondisHtWithoutReduction $pricePlastificationHtWithoutReduction;
  2915.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc $priceBordsArrondisTtcWithoutReduction $pricePlastificationTtcWithoutReduction;
  2916.                 }else {
  2917.                     $prixHt  $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())+$priceFinitonHt +$priceVerificationCheckedHt $priceBordsArrondisHt  $pricePlastificationHt;
  2918.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+$priceFinitonTtc $priceVerificationCheckedTtc $priceBordsArrondisTtc  $pricePlastificationTtc;
  2919.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())+$priceFinitonHtWithoutReduction +$priceVerificationCheckedHt $priceBordsArrondisHtWithoutReduction  $pricePlastificationHtWithoutReduction;
  2920.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+$priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc $priceBordsArrondisTtcWithoutReduction  $pricePlastificationTtcWithoutReduction;
  2921.                 }
  2922.                 if(($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or  ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  2923.                     if($isEnveloppe) {
  2924.                         $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $qty);
  2925.                         $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $qty);
  2926.                         $prixHtWithoutReduction $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT $qty);
  2927.                         $prixTtcWithoutReduction $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC $qty);
  2928.                     }
  2929.                 }
  2930.                 $cartDetail->setIsEnveloppe($isEnveloppe);
  2931.                 $cartDetail->setIsPlusExpert($plus_expert);
  2932.                 $cartDetail->setFinition($finition);
  2933.                 $cartDetail->setIsPlusVerification($verification);
  2934.                 $cartDetail->setIsPlusBordsArrondis($bordsArrondis);
  2935.                 $cartDetail->setIsPlusPlastification($plastification);
  2936.                 $cartDetail->setIsTrait($isTrait);
  2937.             }
  2938.         }
  2939.         $prixHt $this->cart_service->updatePriceByCountry($prixHt,$product);
  2940.         $prixTtc $this->cart_service->updatePriceByCountry($prixTtc,$product);
  2941.         $prixHtWithoutReduction $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
  2942.         $prixTtcWithoutReduction $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
  2943.         $cartDetail->setProductAttribute($productAttribute);
  2944.         $cartDetail->setPrixHt($prixHt);
  2945.         $cartDetail->setPrixTtc($prixTtc);
  2946.         $cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
  2947.         $cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
  2948.         // add carrier
  2949.         $imprimeurLivraison = isset($requestData['imprimeurLivraison'])? $requestData['imprimeurLivraison'] : null;
  2950.         $dateLivraison = isset($requestData['dateLivraison'])? $requestData['dateLivraison'] : null;
  2951.         $timeLivraison = isset($requestData['timeLivraison'])? $requestData['timeLivraison'] : null;
  2952.         $carrierId = isset($requestData['carrierId'])? $requestData['carrierId'] : null;
  2953.         $typeLivraisonNational = isset($requestData['typeLivraisonNational'])? $requestData['typeLivraisonNational'] : null;
  2954.         $typeLivraison30min = isset($requestData['typeLivraison30min'])? $requestData['typeLivraison30min'] : null;
  2955.         $lat = isset($requestData['latLiv'])? $requestData['latLiv'] : null;
  2956.         $long = isset($requestData['longLiv'])? $requestData['longLiv'] : null;
  2957.         $codePostal = isset($requestData['codePostalLiv'])? $requestData['codePostalLiv'] : null;
  2958.         $idServicePointNationInput = isset($requestData['idServicePointNationInput'])? $requestData['idServicePointNationInput'] : null;
  2959.         if($carrierId){
  2960.             $carrier $this->em->getRepository(Carrier::class)->find($carrierId);
  2961.             $cartDetail->setCarrier($carrier);
  2962.             $carrierNationalJ1 $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J1));
  2963.             $carrierNationalJ5 $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J5));
  2964.             $carrierNationalJ2 $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J2));
  2965.             $carrier30MIN $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::STUART));
  2966.             $carrierRetrait $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::RETRAIT));
  2967.             if($imprimeurLivraison){
  2968.                 $imprimeur $this->em->getRepository(Imprimeur::class)->find($imprimeurLivraison);
  2969.                 $cartDetail->setImprimeur($imprimeur);
  2970.                 $dataLocalisation = [
  2971.                     'lat' => $lat,
  2972.                     'longi' => $long,
  2973.                     'codePostal' =>$codePostal ,
  2974.                 ];
  2975.                 if($carrier == $carrier30MIN){
  2976.                     if($dateLivraison and $timeLivraison){
  2977.                         $time explode(' - '$timeLivraison);
  2978.                         if(isset($time[0]) and isset($time[1]) ){
  2979.                             $dateStart = new \DateTime($dateLivraison.' '.$time[0]);
  2980.                             $dateEnd = new \DateTime($dateLivraison.' '.$time[1]);
  2981.                             $cartDetail->setDateStart($dateStart);
  2982.                             $cartDetail->setDateEnd($dateEnd);
  2983.                         }
  2984.                     }
  2985.                     $typeLivraison30min $this->cart_service->getTypeLivraison30min($imprimeurLivraison,$dataLocalisation);
  2986.                     $cartDetail->setTypeLivraison30min($typeLivraison30min);
  2987.                 }else if($carrier == $carrierNationalJ1){
  2988.                     $cartDetail->setIdServicePointLivraison($idServicePointNationInput);
  2989.                     $cartDetail->setTypeLivraisonNational($typeLivraisonNational);
  2990.                     if($carrier->getNum() == Carrier::J1){
  2991.                         $cartDetail->setDateEstimeLivraisonNational($this->cart_service->checkdateLivraisonNational());
  2992.                     }else{
  2993.                         $cartDetail->setDateEstimeLivraisonNational(null);
  2994.                     }
  2995.                 }
  2996.             }
  2997.         }
  2998.         $this->em->persist($cartDetail);
  2999.         $this->em->flush();
  3000.         if($photosToken) {
  3001.             $this->addFilesInCartDetail($photosToken$cartDetail);
  3002.         }
  3003.         $this->cart_service->removeCartDetailPapierPoste($cart,$cartDetail,true); //remove Papier Poste
  3004.         $this->cart_service->updatePriceCart($cart);
  3005.         $isSaveCrelloImport = isset($requestData['isSaveCrelloImport'])? $requestData['isSaveCrelloImport'] : 0;
  3006.         $catSaveCrello = isset($requestData['catSaveCrello'])? $requestData['catSaveCrello'] : 0;
  3007.         if($isSaveCrelloImport != 0){
  3008.             $this->saveClientFiles($cartDetail->getToken(),$catSaveCrello,$user);
  3009.         }
  3010.         return array('token'=>$cartDetail->getToken(),'cartDetail'=>$cartDetail,'succes'=>true,'redirect'=> $this->generateUrl('checkout'),'erreur'=>false,'image'=>$filePapierFirstImage);
  3011.     }
  3012.     public function addToCartNewNbDesignerNosCrea($request,$user,$id)
  3013.     {
  3014.         $url $request->get('urlCrelloTemplate');
  3015.         $designId $request->get('idDesign');
  3016.         $crea $this->em->getRepository(NosCrea::class)->find($id);
  3017.         if(is_object($crea)) {
  3018.             $product $crea->getProduct();
  3019.             $qty $crea->getProductPrice()->getQty();
  3020.             $finition CartDetail::FINITION_GLACE;
  3021.             $isEnveloppe null;
  3022.             $verification CartDetail::VERIFICATION_CHECKED;
  3023.             $plus_expert null;
  3024.             $isTrait null;
  3025.             $isFontBlanc null;
  3026.             $productAttribute $crea->getProductAttribute();
  3027.             $cartDetail = new CartDetail();
  3028.             $token $this->generateToken(32);
  3029.             $dataPdf $this->downloadPdfCrello($request,$url,$token);
  3030.             $filePapier = isset($dataPdf['pdfName'])? $dataPdf['pdfName'] : false;
  3031.             $filePapierFirstImage = isset($dataPdf['firstImage'])? $dataPdf['firstImage'] : false;
  3032.             if(!$filePapier || !$filePapierFirstImage ){
  3033.                 return ['erreur'=> 'erreur convert pdf !'];
  3034.             }
  3035.             $cartDetail->setIsMaCrea(false);
  3036.             $cartDetail->setFilePapier($filePapier);
  3037.             $cartDetail->setFilePapierFirstImage($filePapierFirstImage);
  3038.             if($product->getTypeProduct() == Product::CARTE){
  3039.                 $name 'carte-visite';
  3040.             }else if($product->getTypeProduct() == Product::FLYERS){
  3041.                 $name 'flyrs';
  3042.             }else if($product->getTypeProduct() == Product::AFFICHE){
  3043.                 $name 'affiche';
  3044.             }else if($product->getTypeProduct() == Product::MENU){
  3045.                 $name 'menu';
  3046.             }else if($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
  3047.                 $name 'faire_naissance';
  3048.             }else if($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
  3049.                 $name 'faire_mariage';
  3050.             }else{
  3051.                 $name str_replace(' ','_',$product->getTitre());
  3052.             }
  3053.             $cartDetail->setFilePapierName($name.'-'.$filePapier);
  3054.             $cartDetail->setTemplateIdCrello($designId);
  3055.             $cart $this->cart_service->getCartCurrent();
  3056.             if (!$cart) {
  3057.                 $cart $this->cart_service->createCart(true);
  3058.             }
  3059.             $typeAbonnement $this->cart_service->getTypeAbonnementPro($user$cart->getId()); // get type abonnement
  3060.             $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
  3061.             $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
  3062.             $cartDetail->setTypeProduct($product->getTypeProduct());
  3063.             $cartDetail->setToken($token);
  3064.             $cartDetail->setProductAttribute($productAttribute);
  3065.             $cartDetail->setProduct($product);
  3066.             $cartDetail->setCart($cart);
  3067.             $cartDetail->setNbrPapier($qty);
  3068.             $cartDetail->setQty(0);
  3069.             $cartDetail->setQtyColor(0);
  3070.             $cartDetail->setQtyNoir(0);
  3071.             $cartDetail->setProductName($product->getTitre());
  3072.             $cartDetail->setMauvaisFormat($isFontBlanc);
  3073.             $priceFinitonHt 0;
  3074.             $priceFinitonTtc 0;
  3075.             $priceFinitonHtWithoutReduction 0;
  3076.             $priceFinitonTtcWithoutReduction 0;
  3077.             $pourcentageFinition 0;
  3078.             if($finition == CartDetail::FINITION_GLACE){
  3079.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  3080.             }else if($finition == CartDetail::FINITION_MATE){
  3081.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  3082.             }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  3083.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  3084.             }else if($finition == CartDetail::FINITION_TRANSPARENT){
  3085.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  3086.             }else if($finition == CartDetail::FINITION_SoftTouch){
  3087.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  3088.             }else if($finition == CartDetail::FINITION_Pelliculemat){
  3089.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  3090.             }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  3091.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  3092.             }
  3093.             $priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * $pourcentageFinition;
  3094.             $priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * $pourcentageFinition;
  3095.             $priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt())) * $pourcentageFinition;
  3096.             $priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc())) * $pourcentageFinition;
  3097.             $priceVerificationCheckedTtc 0;
  3098.             $priceVerificationCheckedHt 0;
  3099.             if ($verification == CartDetail::VERIFICATION_CHECKED) {
  3100.                 $priceVerificationCheckedTtc CartDetail::VERIFICATION_TTC;
  3101.                 $priceVerificationCheckedHt CartDetail::VERIFICATION_HT;
  3102.             }
  3103.             if ($plus_expert) {
  3104.                 $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT $priceFinitonHt $priceVerificationCheckedHt;
  3105.                 $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC $priceFinitonTtc $priceVerificationCheckedTtc;
  3106.                 $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT $priceFinitonHtWithoutReduction $priceVerificationCheckedHt;
  3107.                 $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC $priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc;
  3108.             } else {
  3109.                 $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt $priceVerificationCheckedHt;
  3110.                 $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + $priceFinitonTtc $priceVerificationCheckedTtc;
  3111.                 $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction $priceVerificationCheckedHt;
  3112.                 $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc()) + $priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc;
  3113.             }
  3114.             if (($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  3115.                 if ($isEnveloppe) {
  3116.                     $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $qty);
  3117.                     $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $qty);
  3118.                     $prixHtWithoutReduction $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT $qty);
  3119.                     $prixTtcWithoutReduction $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC $qty);
  3120.                 }
  3121.             }
  3122.             // update price by country
  3123.             $prixHt $this->cart_service->updatePriceByCountry($prixHt,$product);
  3124.             $prixTtc $this->cart_service->updatePriceByCountry($prixTtc,$product);
  3125.             $prixHtWithoutReduction $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
  3126.             $prixTtcWithoutReduction $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
  3127.             $cartDetail->setPrixHt($prixHt);
  3128.             $cartDetail->setPrixTtc($prixTtc);
  3129.             $cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
  3130.             $cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
  3131.             $cartDetail->setIsEnveloppe($isEnveloppe);
  3132.             $cartDetail->setIsPlusExpert($plus_expert);
  3133.             $cartDetail->setFinition($finition);
  3134.             $cartDetail->setIsPlusVerification($verification);
  3135.             $cartDetail->setIsTrait($isTrait);
  3136.             $this->em->persist($cartDetail);
  3137.             $this->em->flush();
  3138.             $this->cart_service->removeCartDetailPapierPoste($cart$cartDetailtrue); //remove Papier Poste
  3139.             $this->cart_service->updatePriceCart($cart);
  3140.             return $cartDetail;
  3141.         }
  3142.         return false;
  3143.     }
  3144.     public function addToCartNewNbDesignerTemplatePageNosCrea($request,$user,$id)
  3145.     {
  3146.         $url $request->get('urlCrelloTemplate');
  3147.         $designId $request->get('idDesign');
  3148.         $crea $this->em->getRepository(TemplatesPage::class)->find($id);
  3149.         if(is_object($crea)) {
  3150.             $product $crea->getProduct();
  3151.             $qty $crea->getProductPrice()->getQty();
  3152.             $finition CartDetail::FINITION_GLACE;
  3153.             $isEnveloppe null;
  3154.             $verification CartDetail::VERIFICATION_CHECKED;
  3155.             $plus_expert null;
  3156.             $isTrait null;
  3157.             $isFontBlanc null;
  3158.             $productAttribute $crea->getProductAttribute();
  3159.             $cartDetail = new CartDetail();
  3160.             $token $this->generateToken(32);
  3161.             $dataPdf $this->downloadPdfCrello($request,$url,$token);
  3162.             $filePapier = isset($dataPdf['pdfName'])? $dataPdf['pdfName'] : false;
  3163.             $filePapierFirstImage = isset($dataPdf['firstImage'])? $dataPdf['firstImage'] : false;
  3164.             if(!$filePapier || !$filePapierFirstImage ){
  3165.                 return ['erreur'=> 'erreur convert pdf !'];
  3166.             }
  3167.             $cartDetail->setIsMaCrea(false);
  3168.             $cartDetail->setFilePapier($filePapier);
  3169.             $cartDetail->setFilePapierFirstImage($filePapierFirstImage);
  3170.             if($product->getTypeProduct() == Product::CARTE){
  3171.                 $name 'carte-visite';
  3172.             }else if($product->getTypeProduct() == Product::FLYERS){
  3173.                 $name 'flyrs';
  3174.             }else if($product->getTypeProduct() == Product::AFFICHE){
  3175.                 $name 'affiche';
  3176.             }else if($product->getTypeProduct() == Product::MENU){
  3177.                 $name 'menu';
  3178.             }else if($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
  3179.                 $name 'faire_naissance';
  3180.             }else if($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
  3181.                 $name 'faire_mariage';
  3182.             }else{
  3183.                 $name str_replace(' ','_',$product->getTitre());
  3184.             }
  3185.             $cartDetail->setFilePapierName($name.'-'.$filePapier);
  3186.             $cartDetail->setTemplateIdCrello($designId);
  3187.             $cart $this->cart_service->getCartCurrent();
  3188.             if (!$cart) {
  3189.                 $cart $this->cart_service->createCart(true);
  3190.             }
  3191.             $typeAbonnement $this->cart_service->getTypeAbonnementPro($user$cart->getId()); // get type abonnement
  3192.             $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
  3193.             $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
  3194.             $cartDetail->setTypeProduct($product->getTypeProduct());
  3195.             $cartDetail->setToken($token);
  3196.             $cartDetail->setProductAttribute($productAttribute);
  3197.             $cartDetail->setProduct($product);
  3198.             $cartDetail->setCart($cart);
  3199.             $cartDetail->setNbrPapier($qty);
  3200.             $cartDetail->setQty(0);
  3201.             $cartDetail->setQtyColor(0);
  3202.             $cartDetail->setQtyNoir(0);
  3203.             $cartDetail->setProductName($product->getTitre());
  3204.             $cartDetail->setMauvaisFormat($isFontBlanc);
  3205.             $priceFinitonHt 0;
  3206.             $priceFinitonTtc 0;
  3207.             $priceFinitonHtWithoutReduction 0;
  3208.             $priceFinitonTtcWithoutReduction 0;
  3209.             $pourcentageFinition 0;
  3210.             if($finition == CartDetail::FINITION_GLACE){
  3211.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  3212.             }else if($finition == CartDetail::FINITION_MATE){
  3213.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  3214.             }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  3215.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  3216.             }else if($finition == CartDetail::FINITION_TRANSPARENT){
  3217.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  3218.             }else if($finition == CartDetail::FINITION_SoftTouch){
  3219.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  3220.             }else if($finition == CartDetail::FINITION_Pelliculemat){
  3221.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  3222.             }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  3223.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  3224.             }
  3225.             $priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * $pourcentageFinition;
  3226.             $priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * $pourcentageFinition;
  3227.             $priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt())) * $pourcentageFinition;
  3228.             $priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc())) * $pourcentageFinition;
  3229.             $priceVerificationCheckedTtc 0;
  3230.             $priceVerificationCheckedHt 0;
  3231.             if ($verification == CartDetail::VERIFICATION_CHECKED) {
  3232.                 $priceVerificationCheckedTtc CartDetail::VERIFICATION_TTC;
  3233.                 $priceVerificationCheckedHt CartDetail::VERIFICATION_HT;
  3234.             }
  3235.             if ($plus_expert) {
  3236.                 $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT $priceFinitonHt $priceVerificationCheckedHt;
  3237.                 $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC $priceFinitonTtc $priceVerificationCheckedTtc;
  3238.                 $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT $priceFinitonHtWithoutReduction $priceVerificationCheckedHt;
  3239.                 $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC $priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc;
  3240.             } else {
  3241.                 $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt $priceVerificationCheckedHt;
  3242.                 $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + $priceFinitonTtc $priceVerificationCheckedTtc;
  3243.                 $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction $priceVerificationCheckedHt;
  3244.                 $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc()) + $priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc;
  3245.             }
  3246.             if (($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  3247.                 if ($isEnveloppe) {
  3248.                     $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $qty);
  3249.                     $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $qty);
  3250.                     $prixHtWithoutReduction $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT $qty);
  3251.                     $prixTtcWithoutReduction $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC $qty);
  3252.                 }
  3253.             }
  3254.             $cartDetail->setPrixHt($prixHt);
  3255.             $cartDetail->setPrixTtc($prixTtc);
  3256.             $cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
  3257.             $cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
  3258.             $cartDetail->setIsEnveloppe($isEnveloppe);
  3259.             $cartDetail->setIsPlusExpert($plus_expert);
  3260.             $cartDetail->setFinition($finition);
  3261.             $cartDetail->setIsPlusVerification($verification);
  3262.             $cartDetail->setIsTrait($isTrait);
  3263.             $this->em->persist($cartDetail);
  3264.             $this->em->flush();
  3265.             $this->cart_service->removeCartDetailPapierPoste($cart$cartDetailtrue); //remove Papier Poste
  3266.             $this->cart_service->updatePriceCart($cart);
  3267.             return $cartDetail;
  3268.         }
  3269.         return false;
  3270.     }
  3271.     public function addToCartNewNbDesignerTemplatePageCategoryNosCrea($request,$user,$id)
  3272.     {
  3273.         $url $request->get('urlCrelloTemplate');
  3274.         $designId $request->get('idDesign');
  3275.         $crea $this->em->getRepository(TemplatesPageCategory::class)->find($id);
  3276.         if(is_object($crea)) {
  3277.             $product $crea->getProduct();
  3278.             $qty $crea->getProductPrice()->getQty();
  3279.             $finition CartDetail::FINITION_GLACE;
  3280.             $isEnveloppe null;
  3281.             $verification CartDetail::VERIFICATION_CHECKED;
  3282.             $plus_expert null;
  3283.             $isTrait null;
  3284.             $isFontBlanc null;
  3285.             $productAttribute $crea->getProductAttribute();
  3286.             $cartDetail = new CartDetail();
  3287.             $token $this->generateToken(32);
  3288.             $dataPdf $this->downloadPdfCrello($request,$url,$token);
  3289.             $filePapier = isset($dataPdf['pdfName'])? $dataPdf['pdfName'] : false;
  3290.             $filePapierFirstImage = isset($dataPdf['firstImage'])? $dataPdf['firstImage'] : false;
  3291.             if(!$filePapier || !$filePapierFirstImage ){
  3292.                 return ['erreur'=> 'erreur convert pdf !'];
  3293.             }
  3294.             $cartDetail->setIsMaCrea(false);
  3295.             $cartDetail->setFilePapier($filePapier);
  3296.             $cartDetail->setFilePapierFirstImage($filePapierFirstImage);
  3297.             if($product->getTypeProduct() == Product::CARTE){
  3298.                 $name 'carte-visite';
  3299.             }else if($product->getTypeProduct() == Product::FLYERS){
  3300.                 $name 'flyrs';
  3301.             }else if($product->getTypeProduct() == Product::AFFICHE){
  3302.                 $name 'affiche';
  3303.             }else if($product->getTypeProduct() == Product::MENU){
  3304.                 $name 'menu';
  3305.             }else if($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
  3306.                 $name 'faire_naissance';
  3307.             }else if($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
  3308.                 $name 'faire_mariage';
  3309.             }else{
  3310.                 $name str_replace(' ','_',$product->getTitre());
  3311.             }
  3312.             $cartDetail->setFilePapierName($name.'-'.$filePapier);
  3313.             $cartDetail->setTemplateIdCrello($designId);
  3314.             $cart $this->cart_service->getCartCurrent();
  3315.             if (!$cart) {
  3316.                 $cart $this->cart_service->createCart(true);
  3317.             }
  3318.             $typeAbonnement $this->cart_service->getTypeAbonnementPro($user$cart->getId()); // get type abonnement
  3319.             $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
  3320.             $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
  3321.             $cartDetail->setTypeProduct($product->getTypeProduct());
  3322.             $cartDetail->setToken($token);
  3323.             $cartDetail->setProductAttribute($productAttribute);
  3324.             $cartDetail->setProduct($product);
  3325.             $cartDetail->setCart($cart);
  3326.             $cartDetail->setNbrPapier($qty);
  3327.             $cartDetail->setQty(0);
  3328.             $cartDetail->setQtyColor(0);
  3329.             $cartDetail->setQtyNoir(0);
  3330.             $cartDetail->setProductName($product->getTitre());
  3331.             $cartDetail->setMauvaisFormat($isFontBlanc);
  3332.             $priceFinitonHt 0;
  3333.             $priceFinitonTtc 0;
  3334.             $priceFinitonHtWithoutReduction 0;
  3335.             $priceFinitonTtcWithoutReduction 0;
  3336.             $pourcentageFinition 0;
  3337.             if($finition == CartDetail::FINITION_GLACE){
  3338.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  3339.             }else if($finition == CartDetail::FINITION_MATE){
  3340.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  3341.             }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  3342.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  3343.             }else if($finition == CartDetail::FINITION_TRANSPARENT){
  3344.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  3345.             }else if($finition == CartDetail::FINITION_SoftTouch){
  3346.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  3347.             }else if($finition == CartDetail::FINITION_Pelliculemat){
  3348.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  3349.             }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  3350.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  3351.             }
  3352.             $priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * $pourcentageFinition;
  3353.             $priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * $pourcentageFinition;
  3354.             $priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt())) * $pourcentageFinition;
  3355.             $priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc())) * $pourcentageFinition;
  3356.             $priceVerificationCheckedTtc 0;
  3357.             $priceVerificationCheckedHt 0;
  3358.             if ($verification == CartDetail::VERIFICATION_CHECKED) {
  3359.                 $priceVerificationCheckedTtc CartDetail::VERIFICATION_TTC;
  3360.                 $priceVerificationCheckedHt CartDetail::VERIFICATION_HT;
  3361.             }
  3362.             if ($plus_expert) {
  3363.                 $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT $priceFinitonHt $priceVerificationCheckedHt;
  3364.                 $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC $priceFinitonTtc $priceVerificationCheckedTtc;
  3365.                 $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT $priceFinitonHtWithoutReduction $priceVerificationCheckedHt;
  3366.                 $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC $priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc;
  3367.             } else {
  3368.                 $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt $priceVerificationCheckedHt;
  3369.                 $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + $priceFinitonTtc $priceVerificationCheckedTtc;
  3370.                 $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction $priceVerificationCheckedHt;
  3371.                 $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc()) + $priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc;
  3372.             }
  3373.             if (($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  3374.                 if ($isEnveloppe) {
  3375.                     $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $qty);
  3376.                     $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $qty);
  3377.                     $prixHtWithoutReduction $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT $qty);
  3378.                     $prixTtcWithoutReduction $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC $qty);
  3379.                 }
  3380.             }
  3381.             $cartDetail->setPrixHt($prixHt);
  3382.             $cartDetail->setPrixTtc($prixTtc);
  3383.             $cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
  3384.             $cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
  3385.             $cartDetail->setIsEnveloppe($isEnveloppe);
  3386.             $cartDetail->setIsPlusExpert($plus_expert);
  3387.             $cartDetail->setFinition($finition);
  3388.             $cartDetail->setIsPlusVerification($verification);
  3389.             $cartDetail->setIsTrait($isTrait);
  3390.             $this->em->persist($cartDetail);
  3391.             $this->em->flush();
  3392.             $this->cart_service->removeCartDetailPapierPoste($cart$cartDetailtrue); //remove Papier Poste
  3393.             $this->cart_service->updatePriceCart($cart);
  3394.             return $cartDetail;
  3395.         }
  3396.         return false;
  3397.     }
  3398.     public function getBlocksTemplate20000Page($search=null){
  3399.         $array = [];
  3400.         $templates $this->em->getRepository(TemplatesPage::class)->getAllActiveBySearch($search);
  3401.         foreach ($templates as $item){
  3402.             if(array_key_exists($item->getCategory()->getId(),$array)){
  3403.                 $array[$item->getCategory()->getId()]['products'][] = $item;
  3404.             }else{
  3405.                 $array[$item->getCategory()->getId()]['sort'] =  $item->getCategory()->getSort()?$item->getCategory()->getSort():0;
  3406.                 $array[$item->getCategory()->getId()]['category'] =  $item->getCategory();
  3407.                 $array[$item->getCategory()->getId()]['products'][] =  $item;
  3408.             }
  3409.         }
  3410.         return $array;
  3411.     }
  3412.     public function getBlocksTemplate20000PagePlus($request){
  3413.         $catId $request->get('catId');
  3414.         $search $request->get('search');
  3415.         $templates $this->em->getRepository(TemplatesPage::class)->getAllActiveBySearchAndCat($catId,$search);
  3416.         return $templates;
  3417.     }
  3418.     public function searchTemplate20000Page($request,$search){
  3419.         $products $this->em->getRepository(TemplatesPage::class)->getAllActiveBySearch($search);
  3420.         $tabs = [];
  3421.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  3422.         foreach ($products as $product){
  3423.             $array = [];
  3424.             $array['img'] = $baseurl "/imageSite/" $product->getFileProduct();
  3425.             $array['designTypeSideBarCrello'] = $product->getDesignTypeSideBarCrello();
  3426.             $array['templateId'] = $product->getDesignTemplateId();
  3427.             $array['titre'] =  $product->getTitre();
  3428.             $array['nameTemplate'] =  $product->getNameTemplate();
  3429.             $array['baseUrl'] = $baseurl;
  3430.             $tabs[] = $array ;
  3431.         }
  3432.         return $tabs;
  3433.     }
  3434.     public function addToCartNewNbDesignerDocSaved($fileCrello,$user)
  3435.     {
  3436.         if(is_object($fileCrello)) {
  3437.             $product $fileCrello->getProduct();
  3438.             $qty $fileCrello->getQuantite();
  3439.             $finition $fileCrello->getFinition();
  3440.             $isEnveloppe $fileCrello->getIsEnveloppe();
  3441.             $verification $fileCrello->getIsPlusVerification();
  3442.             $plus_expert $fileCrello->getIsPlusExpert();
  3443.             $isTrait $fileCrello->getIsTrait();
  3444.             $isFontBlanc null;
  3445.             if (!$fileCrello->getFilePapier()) {
  3446.                 return false;
  3447.             }
  3448.             $cartDetail = new CartDetail();
  3449.             $token $this->generateToken(32);
  3450.             $newFile uniqid() . $fileCrello->getFilePapier();
  3451.             $dossier_frame $this->params->get('uploads_directory') . '/img_template_save/' $fileCrello->getFilePapier();
  3452.             $dossier_frame_new $this->params->get('uploads_directory') . '/tmp/' $newFile;
  3453.             copy($dossier_frame$dossier_frame_new);
  3454.             $newFileFirstImage null;
  3455.             if ($fileCrello->getFilePapierFirstImage()) {
  3456.                 $newFileFirstImage uniqid() . $fileCrello->getFilePapierFirstImage();
  3457.                 $dossier_frame_firstImage $this->params->get('uploads_directory') . '/img_template_save/' $fileCrello->getFilePapierFirstImage();
  3458.                 $dossier_frame_firstImage_new $this->params->get('uploads_directory') . '/tmp/' $newFileFirstImage;
  3459.                 copy($dossier_frame_firstImage$dossier_frame_firstImage_new);
  3460.             }
  3461.             $cartDetail->setIsMaCrea(true);
  3462.             $cartDetail->setFilePapier($newFile);
  3463.             $cartDetail->setFilePapierFirstImage($newFileFirstImage);
  3464.             if ($product->getTypeProduct() == Product::CARTE) {
  3465.                 $name 'carte-visite';
  3466.             } else if ($product->getTypeProduct() == Product::FLYERS) {
  3467.                 $name 'flyrs';
  3468.             } else if ($product->getTypeProduct() == Product::AFFICHE) {
  3469.                 $name 'affiche';
  3470.             } else if ($product->getTypeProduct() == Product::MENU) {
  3471.                 $name 'menu';
  3472.             } else if ($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) {
  3473.                 $name 'faire_naissance';
  3474.             } else if ($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE) {
  3475.                 $name 'faire_mariage';
  3476.             } else {
  3477.                 $name str_replace(' ''_'$product->getTitre());
  3478.             }
  3479.             $cartDetail->setFilePapierName($name '-' $newFile);
  3480.             $productAttribute $fileCrello->getProductAttribute();
  3481.             $cart $this->cart_service->getCartCurrent();
  3482.             if (!$cart) {
  3483.                 $cart $this->cart_service->createCart(true);
  3484.             }
  3485.             $typeAbonnement $this->cart_service->getTypeAbonnementPro($user$cart->getId()); // get type abonnement
  3486.             $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
  3487.             $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
  3488.             $cartDetail->setTypeProduct($product->getTypeProduct());
  3489.             $cartDetail->setToken($token);
  3490.             $cartDetail->setProductAttribute($productAttribute);
  3491.             $cartDetail->setProduct($product);
  3492.             $cartDetail->setCart($cart);
  3493.             $cartDetail->setNbrPapier($qty);
  3494.             $cartDetail->setQty(0);
  3495.             $cartDetail->setQtyColor(0);
  3496.             $cartDetail->setQtyNoir(0);
  3497.             $cartDetail->setProductName($product->getTitre());
  3498.             $cartDetail->setMauvaisFormat($isFontBlanc);
  3499.             $priceFinitonHt 0;
  3500.             $priceFinitonTtc 0;
  3501.             $priceFinitonHtWithoutReduction 0;
  3502.             $priceFinitonTtcWithoutReduction 0;
  3503.             $pourcentageFinition 0;
  3504.             if($finition == CartDetail::FINITION_GLACE){
  3505.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  3506.             }else if($finition == CartDetail::FINITION_MATE){
  3507.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  3508.             }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  3509.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  3510.             }else if($finition == CartDetail::FINITION_TRANSPARENT){
  3511.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  3512.             }else if($finition == CartDetail::FINITION_SoftTouch){
  3513.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  3514.             }else if($finition == CartDetail::FINITION_Pelliculemat){
  3515.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  3516.             }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  3517.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  3518.             }
  3519.             $priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * $pourcentageFinition;
  3520.             $priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * $pourcentageFinition;
  3521.             $priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt())) * $pourcentageFinition;
  3522.             $priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc())) * $pourcentageFinition;
  3523.             $priceVerificationCheckedTtc 0;
  3524.             $priceVerificationCheckedHt 0;
  3525.             if ($verification == CartDetail::VERIFICATION_CHECKED) {
  3526.                 $priceVerificationCheckedTtc CartDetail::VERIFICATION_TTC;
  3527.                 $priceVerificationCheckedHt CartDetail::VERIFICATION_HT;
  3528.             }
  3529.             if ($plus_expert) {
  3530.                 $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT $priceFinitonHt $priceVerificationCheckedHt;
  3531.                 $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC $priceFinitonTtc $priceVerificationCheckedTtc;
  3532.                 $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT $priceFinitonHtWithoutReduction $priceVerificationCheckedHt;
  3533.                 $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC $priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc;
  3534.             } else {
  3535.                 $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt $priceVerificationCheckedHt;
  3536.                 $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + $priceFinitonTtc $priceVerificationCheckedTtc;
  3537.                 $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction $priceVerificationCheckedHt;
  3538.                 $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr$priceProductAttr->getPrixTtc()) + $priceFinitonTtcWithoutReduction $priceVerificationCheckedTtc;
  3539.             }
  3540.             if (($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  3541.                 if ($isEnveloppe) {
  3542.                     $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $qty);
  3543.                     $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $qty);
  3544.                     $prixHtWithoutReduction $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT $qty);
  3545.                     $prixTtcWithoutReduction $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC $qty);
  3546.                 }
  3547.             }
  3548.             // update price by country
  3549.             $prixHt $this->cart_service->updatePriceByCountry($prixHt,$product);
  3550.             $prixTtc $this->cart_service->updatePriceByCountry($prixTtc,$product);
  3551.             $prixHtWithoutReduction $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
  3552.             $prixTtcWithoutReduction $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
  3553.             $cartDetail->setPrixHt($prixHt);
  3554.             $cartDetail->setPrixTtc($prixTtc);
  3555.             $cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
  3556.             $cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
  3557.             $cartDetail->setIsEnveloppe($isEnveloppe);
  3558.             $cartDetail->setIsPlusExpert($plus_expert);
  3559.             $cartDetail->setFinition($finition);
  3560.             $cartDetail->setIsPlusVerification($verification);
  3561.             $cartDetail->setIsTrait($isTrait);
  3562.             $this->em->persist($cartDetail);
  3563.             $this->em->flush();
  3564.             $this->cart_service->removeCartDetailPapierPoste($cart$cartDetailtrue); //remove Papier Poste
  3565.             $this->cart_service->updatePriceCart($cart);
  3566.             return $cartDetail;
  3567.         }
  3568.         return false;
  3569.     }
  3570.     public function saveClientFiles($tokenDetail,$catSaveCrello,$user){
  3571.        if(is_object($user)) {
  3572.            if ($catSaveCrello) {
  3573.                $detail $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
  3574.                if ($detail) {
  3575.                    $file $detail->getFilePapier();
  3576.                    $frame_0 $file;
  3577.                    $frame_0_new uniqid().'-'.$file;
  3578.                    $dossier_frame_0 $this->params->get('uploads_directory') . '/tmp/'.$frame_0;
  3579.                    $dossier_frame_0_new $this->params->get('uploads_directory'). '/img_template_save/' $frame_0_new;
  3580.                    if(file_exists($dossier_frame_0_new) )unlink($dossier_frame_0_new);
  3581.                    copy($dossier_frame_0 $dossier_frame_0_new);
  3582.                    $frame_firstImage_new null;
  3583.                    $frame_firstImage $detail->getFilePapierFirstImage();
  3584.                    if($frame_firstImage){
  3585.                        $frame_firstImage_new uniqid().'-'.$frame_firstImage;
  3586.                        $dossier_frame_firstImage $this->params->get('uploads_directory') . '/tmp/'.$frame_firstImage;
  3587.                        $dossier_frame_firstImage_new $this->params->get('uploads_directory'). '/img_template_save/' $frame_firstImage_new;
  3588.                        if(file_exists($dossier_frame_firstImage_new) )unlink($dossier_frame_firstImage_new);
  3589.                        copy($dossier_frame_firstImage $dossier_frame_firstImage_new);
  3590.                    }
  3591.                    $fileClient = new FilesClientCrello();
  3592.                    $fileClient->setUser($user);
  3593.                    $fileClient->setToken($this->generateToken(32));
  3594.                    $fileClient->setFinition($detail->getFinition());
  3595.                    $fileClient->setFormat($detail->getProductAttribute()->getFormat());
  3596.                    $fileClient->setGrammage($detail->getProductAttribute()->getGramage());
  3597.                    $fileClient->setIsEnveloppe($detail->getIsEnveloppe());
  3598.                    $fileClient->setIsPlusExpert($detail->getIsPlusExpert());
  3599.                    $fileClient->setIsTrait($detail->getIsTrait());
  3600.                    $fileClient->setName($detail->getFilePapierName());
  3601.                    $fileClient->setFilePapier($frame_0_new);
  3602.                    $fileClient->setFilePapierName($detail->getFilePapierName());
  3603.                    $fileClient->setIsPlusVerification($detail->getIsPlusVerification());
  3604.                    $fileClient->setProduct($detail->getProduct());
  3605.                    $fileClient->setProductAttribute($detail->getProductAttribute());
  3606.                    $fileClient->setQuantite($detail->getNbrPapier());
  3607.                    $fileClient->setRectoverso($detail->getProductAttribute()->getRectoverso());
  3608.                    $fileClient->setTypeProduct($detail->getTypeProduct());
  3609.                    $fileClient->setFilePapierFirstImage($frame_firstImage_new);
  3610.                    $cat $this->em->getRepository(FilesClientCrelloCategory::class)->find($catSaveCrello);
  3611.                    if($cat){
  3612.                        $fileClient->setCategory($cat);
  3613.                    }
  3614.                    $this->em->persist($fileClient);
  3615.                    $this->em->flush();
  3616.                }
  3617.            }
  3618.        }
  3619.     }
  3620.     public function getCatCrelloB2b($user,$isAdmin,$compteAbonnement,$search=null){
  3621.         $users = [];
  3622.         if($isAdmin){
  3623.             $users = [];
  3624.             $users[] = $compteAbonnement->getAdmin()->getUser()->getId();
  3625.             if (count($compteAbonnement->getUtilisateur()) > 0) {
  3626.                 foreach ($compteAbonnement->getUtilisateur() as $customer) {
  3627.                     $users[] = $customer->getUser()->getId();
  3628.                 }
  3629.             }
  3630.         }else{
  3631.             $users[] = $user->getId();
  3632.         }
  3633.         $docs $this->em->getRepository(FilesClientCrello::class)->findByUserAbo($users,$search) ;
  3634.         $categories = [];
  3635.         if(count($docs) > 0){
  3636.             foreach ($docs as $doc){
  3637.                 $categories[$doc->getCategory()->getId()]['name'] = $doc->getCategory()->getName();
  3638.                 $categories[$doc->getCategory()->getId()]['docs'][] = $doc;
  3639.                 $categories[$doc->getCategory()->getId()]['id']= $doc->getCategory()->getId();
  3640.             }
  3641.         }
  3642.         return $categories;
  3643.     }
  3644.     public function getCatImpressionB2b($user,$isAdmin,$compteAbonnement,$search=null){
  3645.         $users = [];
  3646.         if($isAdmin){
  3647.             $users = [];
  3648.             $users[] = $compteAbonnement->getAdmin()->getUser()->getId();
  3649.             if (count($compteAbonnement->getUtilisateur()) > 0) {
  3650.                 foreach ($compteAbonnement->getUtilisateur() as $customer) {
  3651.                     $users[] = $customer->getUser()->getId();
  3652.                 }
  3653.             }
  3654.         }else{
  3655.             $users[] = $user->getId();
  3656.         }
  3657.         $docs $this->em->getRepository(FilesClient::class)->findByUserAbo($users,$search) ;
  3658.         return $docs;
  3659.     }
  3660.     public function saveCustomCatCrello($user,$requestData){
  3661.         $catFileB2b = isset($requestData['catFileB2b'])? $requestData['catFileB2b'] : null;
  3662.         $isProductCat = isset($requestData['isProductCat'])? $requestData['isProductCat'] == false true false;
  3663.         $catFileCustomB2b = isset($requestData['catFileCustomB2b'])? $requestData['catFileCustomB2b'] : null;
  3664.         if($catFileCustomB2b){
  3665.             $cat = new FilesClientCrelloCategory();
  3666.             $cat->setName($catFileCustomB2b);
  3667.             $cat->setUser($user);
  3668.             $this->em->persist($cat);
  3669.             $this->em->flush();
  3670.             return $cat->getId();
  3671.         }else {
  3672.             if($isProductCat){
  3673.                 $catProduct $this->em->getRepository(Product::class)->find($catFileB2b);
  3674.                 if($catProduct){
  3675.                     $cat $this->em->getRepository(FilesClientCrelloCategory::class)->findOneBy(['user'=>$user->getId(),'product'=>$catProduct->getId()]);
  3676.                     if($cat){
  3677.                         return  $cat->getId();
  3678.                     }else{
  3679.                         $cat = new FilesClientCrelloCategory();
  3680.                         $cat->setName($catProduct->getTitre());
  3681.                         $cat->setProduct($catProduct);
  3682.                         $cat->setIsDefault(true);
  3683.                         $cat->setUser($user);
  3684.                         $this->em->persist($cat);
  3685.                         $this->em->flush();
  3686.                         return  $cat->getId();
  3687.                     }
  3688.                 }
  3689.             }else{
  3690.                 $cat $this->em->getRepository(FilesClientCrelloCategory::class)->find($catFileB2b);
  3691.                 if($cat){
  3692.                     return $cat->getId();
  3693.                 }
  3694.             }
  3695.         }
  3696.         return 0;
  3697.     }
  3698.     public function generateZipNewNbDesigner($array)
  3699.     {
  3700.         $zip = new \ZipArchive();
  3701.         $token $this->generateToken(10);
  3702.         $nameFichier 'ma_crea_' $token '.zip';
  3703.         $zipfile $this->params->get('uploads_directory') . '/tmp/' $nameFichier;
  3704.         if (file_exists($zipfile)) unlink($zipfile);
  3705.         if ($zip->open($zipfile, \ZipArchive::CREATE) === TRUE) {
  3706.             foreach ($array as $i => $item){
  3707.                 $zip->addFile($this->params->get('uploads_directory') . '/tmp/' $item['file'], $item['file']);
  3708.             }
  3709.             $zip->close();
  3710.         }
  3711.         return $nameFichier;
  3712.     }
  3713.     public function addImageCreaNewNbDesigner($images): array
  3714.     {
  3715.         $array = [];
  3716.         $file '';
  3717.         $firstImage '';
  3718.         $multiple 0;
  3719.         foreach ($images as $key => $image) {
  3720.             if ($image && in_array($image->guessExtension(), array('pdf''png''jpg''jpeg'))) {
  3721.                 $ext $image->guessExtension();
  3722.                 $token $this->generateToken(10);
  3723.                 $file $token '.' $ext;
  3724.                 $image->move($this->params->get('uploads_directory') . '/tmp'$file);
  3725.                 $array[]= [
  3726.                     'file' => $file,
  3727.                 ];
  3728.                 if($key == 0) {
  3729.                     if ($ext == 'pdf') {
  3730.                         $firstImage $this->convertPdfToFirstImage($file$token);
  3731.                         $nbrPage $this->getNumbrePage($file);
  3732.                         if($nbrPage == 1){
  3733.                             $multiple 1;
  3734.                         }elseif ($nbrPage == 2){
  3735.                             $multiple 2;
  3736.                         }elseif ($nbrPage 2){
  3737.                             $multiple 3;
  3738.                         }
  3739.                     } else {
  3740.                         $firstImage $file;
  3741.                     }
  3742.                 }
  3743.             }
  3744.         }
  3745.         if($array and $multiple 0){
  3746.             if($multiple == 1){
  3747.                 return  [
  3748.                     'file' => $array[0]['file'],
  3749.                     'image' => $firstImage,
  3750.                     'multiple' => 0
  3751.                 ];
  3752.             }else if($multiple == 2){
  3753.                 return  [
  3754.                     'file' => $array[0]['file'],
  3755.                     'image' => $firstImage,
  3756.                     'multiple' => 2
  3757.                 ];
  3758.             }else if($multiple 2){
  3759.                 return  [
  3760.                     'file' => $array[0]['file'],
  3761.                     'image' => $firstImage,
  3762.                     'multiple' => 3
  3763.                 ];
  3764.             }else{
  3765.                 return [
  3766.                     'file' => false
  3767.                 ];
  3768.             }
  3769.         }else{
  3770.             if( $array and count($array) == ){
  3771.                 return  [
  3772.                     'file' => $this->generateZipNewNbDesigner($array),
  3773.                     'image' => $firstImage,
  3774.                     'multiple' => 2
  3775.                 ];
  3776.             }elseif(count($array) > 2){
  3777.                 return  [
  3778.                     'file' => $this->generateZipNewNbDesigner($array),
  3779.                     'image' => $firstImage,
  3780.                     'multiple' => 3
  3781.                 ];
  3782.             }elseif(count($array) == 1){
  3783.                 return  [
  3784.                     'file' => $array[0]['file'],
  3785.                     'image' => $firstImage,
  3786.                     'multiple' => 0
  3787.                 ];
  3788.             }else{
  3789.                 return [
  3790.                     'file' => false
  3791.                 ];
  3792.             }
  3793.         }
  3794.     }
  3795.     // download pdf crello
  3796.     public function downloadPdfCrello($request,$url,$token){
  3797.         $response $this->httpClient->request('GET'$url, [
  3798.             // optional: if you don't want to buffer the response in memory
  3799.             'buffer' => false,
  3800.         ]);
  3801.         if (200 !== $response->getStatusCode()) {
  3802.             throw new \Exception('...');
  3803.         }
  3804.         $nameFichier $token.'.pdf';
  3805.         if(file_exists($this->params->get('uploads_directory') . '/tmp/' .$nameFichier)){
  3806.             unlink($this->params->get('uploads_directory') . '/tmp/' .$nameFichier);
  3807.         }
  3808.         if(file_exists($this->params->get('uploads_directory') . '/tmp/'.$token.'-recto.jpeg')){
  3809.             unlink($this->params->get('uploads_directory') . '/tmp/'.$token.'-recto.jpeg');
  3810.         }
  3811.         $fileHandler fopen($this->params->get('uploads_directory') . '/tmp/' .$nameFichier'w');
  3812.         foreach ($this->httpClient->stream($response) as $chunk) {
  3813.             fwrite($fileHandler$chunk->getContent());
  3814.         }
  3815.         $firstImage $this->convertPdfToFirstImage($nameFichier,$token);
  3816.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  3817.         return [
  3818.             'pdfUrl'=>  $baseurl.'/uploads/tmp/'.$nameFichier,
  3819.             'pdfName'=>  $nameFichier,
  3820.             'firstImageUrl'=>  $baseurl.'/uploads/tmp/'.$firstImage,
  3821.             'firstImage'=>  $firstImage,
  3822.         ];
  3823.     }
  3824.     // download pdf colorlab
  3825.     public function downloadPdfColorlab($request,$tokenProductColorLab,$idProductColorLab,$token){
  3826.         $idShop '62a6f09f014918001162c01d';
  3827.         $keyApi '24aa345985535be260e4c3298d50b06e';
  3828.         $keyApiSecret '16cec8b8-e8df-404e-9f87-83c1e556f506';
  3829.         $hashed hash_hmac('sha256'$idShop.$idProductColorLab.$tokenProductColorLab$keyApiSecretfalse);
  3830.         $headers = array(
  3831.             'X-Colorlab-Shop:' $idShop,
  3832.             'X-Colorlab-Api-Key:' $keyApi,
  3833.             'X-Colorlab-Api-Signature:' $hashed,
  3834.         );
  3835.         $nameFichier $token.'.pdf';
  3836.         if(file_exists($this->params->get('uploads_directory') . '/tmp/' .$nameFichier)){
  3837.             unlink($this->params->get('uploads_directory') . '/tmp/' .$nameFichier);
  3838.         }
  3839.         $curl curl_init();
  3840.         curl_setopt($curlCURLOPT_URL'https://api.colorlab.io/v1/configuration/'.$idProductColorLab.'/'.$tokenProductColorLab.'/export');
  3841.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  3842.         curl_setopt($curlCURLOPT_CUSTOMREQUEST'GET');
  3843.         curl_setopt($curlCURLOPT_HTTPHEADER$headers);
  3844.         $localFilename $this->params->get('uploads_directory') . '/tmp/' .$nameFichier;
  3845.         $fh fopen($localFilename"wb");
  3846.         curl_setopt($curlCURLOPT_FILE$fh);
  3847.         curl_exec($curl);
  3848.         curl_close($curl);
  3849.         $firstImage $this->convertPdfToFirstImage($nameFichier,$token);
  3850.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  3851.         return [
  3852.             'pdfUrl'=>  $baseurl.'/uploads/tmp/'.$nameFichier,
  3853.             'pdfName'=>  $nameFichier,
  3854.             'firstImageUrl'=>  $baseurl.'/uploads/tmp/'.$firstImage,
  3855.             'firstImage'=>  $firstImage,
  3856.         ];
  3857.     }
  3858.     public function convertPdfToFirstImage($file,$nameFile){
  3859.         $dir  $this->params->get('uploads_directory').'/tmp';
  3860.         exec('rm '.$dir.'/'.$nameFile.'-recto.jpeg');
  3861.         shell_exec('gs -sDEVICE=jpeg -o '.$dir.'/'.$nameFile.'-recto.jpeg -dFirstPage=1 -dLastPage=1 -dJPEGQ=30  '.$dir.'/'.$file); // save first page pdf
  3862. //        shell_exec('C:\\gs9.52\\bin\\gswin64c.exe -sDEVICE=jpeg -o '.$dir.'/'.$nameFile.'-recto.jpeg -dFirstPage=1 -dLastPage=1 -dJPEGQ=30  '.$dir.'/'.$file); // save first page pdf
  3863.         return $nameFile.'-recto.jpeg';
  3864.     }
  3865.     public function getNumbrePage($file){
  3866.         $dir  $this->params->get('uploads_directory').'/tmp';
  3867.         $token $this->generateToken(40);
  3868.         $dossier $dir.'/'.$token;
  3869.         $saveTo  $dossier.'/';
  3870.         mkdir($dossier);
  3871.         shell_exec"gs -sDEVICE=jpeg -o ".$saveTo."page-%d.jpeg  ".$dir."/".$file );
  3872. //        shell_exec( "C:\\gs9.52\\bin\\gswin64c.exe -sDEVICE=png16m -r10  -o ".$saveTo."page-%d.png  ".$dir."/".$file );
  3873.         $scanned_directory array_diffscandir$dossier ), array( '..''.''source' ) );
  3874.         $nbr 0;
  3875.         foreach ( $scanned_directory as $key => $value ) {
  3876.             $nbr++;
  3877.         }
  3878.         exec('rm -rf '.$dossier);
  3879.         return $nbr;
  3880.     }
  3881.     public function getCartDetail($request,$token){
  3882.         $cartDetail null;
  3883.         if($token){
  3884.             $cartDetail $this->em->getRepository(CartDetail::class)->findOneBy(array('token'=>$token));
  3885.         }
  3886.         return $cartDetail;
  3887.     }
  3888.     public function getProductByRequest($request){
  3889.         $productId $request->get('product');
  3890.         $productnull;
  3891.         if($productId){
  3892.             $product $this->em->getRepository(Product::class)->find($productId);
  3893.         }
  3894.         return $product;
  3895.     }
  3896.     // flayer && carte visite
  3897.     public function getGramage($id_product,$id_format,$rectoverso){
  3898.        $gramages =  $this->em->getRepository(ProductAttribute::class)->getAttrGramagePossible($id_product,$id_format,$rectoverso);
  3899.        return $gramages;
  3900.     }
  3901.     public function getQtyPosibleByGrammage($id_gramage,$id_format,$rectoverso,$finition,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
  3902.         $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_gramage,'rectoverso'=>$rectoverso,'isEnabled'=>true));
  3903.         $qtys false;
  3904.         if($productAttribute) {
  3905.             $data $this->getQtyFlyerCarteByProductAttribute($productAttribute->getId(),$finition,false,$isEnveloppe false,$bordsArrondis,$plastification);
  3906.             $dataAbonnementPlus $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_PRO,$productAttribute->getId(),false,$isEnveloppe false,$bordsArrondis,$plastification);
  3907.             $dataAbonnementTeam $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_TEAM,$productAttribute->getId(),false,$isEnveloppe false,$bordsArrondis,$plastification);
  3908.             $qtys $data['qtys'];
  3909.             $qtysPlus $dataAbonnementPlus['qtys'];
  3910.             $qtysTeam $dataAbonnementTeam['qtys'];
  3911.         }
  3912.         return ['qtys'=>$qtys,'qtysPlus'=>$qtysPlus,'qtysTeam'=>$qtysTeam];
  3913.     }
  3914.     // Affiche
  3915.     public function getTypeImpression($id_product,$id_format){
  3916.         $typeImpression =  $this->em->getRepository(ProductAttribute::class)->getAttrTypeImpressionPossible($id_product,$id_format);
  3917.         return $typeImpression;
  3918.     }
  3919.     public function getGrammageByTypeImpression($id_product,$id_format,$id_type_impression null){
  3920.         $garamages =  $this->em->getRepository(ProductAttribute::class)->getAttrGrammageByTypeImpressionPossible($id_product,$id_format,$id_type_impression);
  3921.         return $garamages;
  3922.     }
  3923.     public function getQtyPosibleByGrammageAndTypeImpression($id_gramage,$id_format,$typeImression,$plastificationn,$finition,$isEnveloppe=false,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
  3924.         if($typeImression) {
  3925.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format' => $id_format'gramage' => $id_gramage'typeImpression' => $typeImression'plastification' => $plastificationn'isEnabled' => true));
  3926.         }else{
  3927.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format' => $id_format'gramage' => $id_gramage'plastification' => $plastificationn'isEnabled' => true));
  3928.         }
  3929.         $qtys false;
  3930.         if($productAttribute) {
  3931.             $data $this->getQtyFlyerCarteByProductAttribute($productAttribute->getId(),$finition,false,$isEnveloppe false,$bordsArrondis,$plastification);
  3932.             $dataAbonnementPlus $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_PRO,$productAttribute->getId(),$finition,false,$isEnveloppe false,$bordsArrondis,$plastification);
  3933.             $dataAbonnementTeam $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_TEAM,$productAttribute->getId(),$finition,false,$isEnveloppe false,$bordsArrondis,$plastification);
  3934.             $qtys $data['qtys'];
  3935.             $qtysPlus $dataAbonnementPlus['qtys'];
  3936.             $qtysTeam $dataAbonnementTeam['qtys'];
  3937.         }
  3938.         return ['qtys'=>$qtys,'qtysPlus'=>$qtysPlus,'qtysTeam'=>$qtysTeam];
  3939.     }
  3940.     public function getQtyPosible($productId,$format=null,$gramage=null,$typeImpression=null,$typeFormat=null,$specificite=null,$typeCouleur=null,$taille=null,$zoneImpression=null,$nbrCouleur=null,$supportSuspension=null,$typeCarton=null,$oeille=null){
  3941.         $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(
  3942.             array(
  3943.                 'product'=>$productId,
  3944.                 'format'=>$formatis_object($format)?$format->getId():$format['id']:null,
  3945.                 'gramage'=>$gramage?is_object($gramage)?$gramage->getId():$gramage['id']:null,
  3946.                 'typeImpression'=>$typeImpression?is_object($typeImpression)?$typeImpression->getId():$typeImpression['id']:null,
  3947.                 'typeFormat'=>$typeFormat?is_object($typeFormat)?$typeFormat->getId():$typeFormat['id']:null,
  3948.                 'specificite'=>$specificite?is_object($specificite)?$specificite->getId():$specificite['id']:null,
  3949.                 'typeCouleur'=>$typeCouleur?is_object($typeCouleur)?$typeCouleur->getId():$typeCouleur['id']:null,
  3950.                 'taille'=>$taille?is_object($taille)?$taille->getId():$taille['id']:null,
  3951.                 'zoneImpression'=>$zoneImpression?is_object($zoneImpression)?$zoneImpression->getId():$zoneImpression['id']:null,
  3952.                 'nbrCouleur'=>$nbrCouleur?is_object($nbrCouleur)?$nbrCouleur->getId():$nbrCouleur['id']:null,
  3953.                 'supportSuspension'=>$supportSuspension?is_object($supportSuspension)?$supportSuspension->getId():$supportSuspension['id']:null,
  3954.                 'typeCarton'=>$typeCarton?is_object($typeCarton)?$typeCarton->getId():$typeCarton['id']:null,
  3955.                 'oeille'=>$oeille?is_object($oeille)?$oeille->getId():$oeille['id']:null,
  3956.                 'isEnabled'=>true
  3957.             )
  3958.         );
  3959.         $qtys false;
  3960.         $qtysPlus false;
  3961.         $qtysTeam false;
  3962.         if($productAttribute) {
  3963.             $data $this->getQtyFlyerCarteByProductAttribute($productAttribute->getId(),0,falsefalse);
  3964.             $dataAbonnementPlus $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_PRO,$productAttribute->getId(),0,falsefalse);
  3965.             $dataAbonnementTeam $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_TEAM,$productAttribute->getId(),0,falsefalse);
  3966.             $qtys $data['qtys'];
  3967.             $qtysPlus $dataAbonnementPlus['qtys'];
  3968.             $qtysTeam $dataAbonnementTeam['qtys'];
  3969.         }
  3970.         return ['qtys'=>$qtys,'qtysPlus'=>$qtysPlus,'qtysTeam'=>$qtysTeam];
  3971.     }
  3972.     public function getUserTemplate()
  3973.     {
  3974.         return $this->em->getRepository(NbUserTemplates::class)->findOneBy(array('token' => $this->session->get('nbToken')));
  3975.     }
  3976.     public function generateToken($nb)
  3977.     {
  3978.         return rtrim(strtr(base64_encode(random_bytes($nb)), '+/''-_'), '=');
  3979.     }
  3980.     public function importTextes(): void
  3981.     {
  3982.         $response $this->httpClient->request('GET''https://studio.cmsmart.net/v1/typo');
  3983.         $allTextes $response->toArray();
  3984.         foreach ($allTextes['data'] as $texte) {
  3985.             $response $this->httpClient->request('POST''https://studio.cmsmart.net/v1/typo', [
  3986.                 'body' => [
  3987.                     'action' => 'nbd_get_resource',
  3988.                     'type' => 'get_typo',
  3989.                     'folder' => $texte['folder'],
  3990.                 ]
  3991.             ]);
  3992.             $nbTexte = new NbTextes();
  3993.             $nbTexte->setName($texte['folder']);
  3994.             $nbTexte->setContent($response->toArray()['data']);
  3995.             $this->em->persist($nbTexte);
  3996.             $this->em->flush();
  3997.         }
  3998.     }
  3999.     public function importElements(): void
  4000.     {
  4001.         $response $this->httpClient->request('GET''https://studio.cmsmart.net/v1/clipart?limit=551&category=66');
  4002.         $allFiles $response->toArray();
  4003.         foreach ($allFiles['cliparts']['items'] as $file) {
  4004.             $nbFile = new NbElements();
  4005.             $nbFile->setName($file['name']);
  4006.             $nbFile->setAlias($file['alias']);
  4007.             $fileNameFromUrl explode('/'$file['file']);
  4008.             $fileNameFromUrl $fileNameFromUrl[(count($fileNameFromUrl) - 1)];
  4009.             $response $this->httpClient->request('GET''https:' $file['file'], [
  4010.                 // optional: if you don't want to buffer the response in memory
  4011.                 'buffer' => false,
  4012.             ]);
  4013.             if (200 !== $response->getStatusCode()) {
  4014.                 throw new \Exception('...');
  4015.             }
  4016.             $fileHandler fopen($this->params->get('uploads_directory') . '/nb_designer/' $fileNameFromUrl'w');
  4017.             foreach ($this->httpClient->stream($response) as $chunk) {
  4018.                 fwrite($fileHandler$chunk->getContent());
  4019.             }
  4020.             $nbFile->setPath($fileNameFromUrl);
  4021.             $nbFile->setCategory((int)$file['cate_id']);
  4022.             $this->em->persist($nbFile);
  4023.             $this->em->flush();
  4024.         }
  4025.         $response $this->httpClient->request('GET''https://studio.cmsmart.net/v1/clipart?limit=551&category=73');
  4026.         $allFiles $response->toArray();
  4027.         foreach ($allFiles['cliparts']['items'] as $file) {
  4028.             $nbFile = new NbElements();
  4029.             $nbFile->setName($file['name']);
  4030.             $nbFile->setAlias($file['alias']);
  4031.             $fileNameFromUrl explode('/'$file['file']);
  4032.             $fileNameFromUrl $fileNameFromUrl[(count($fileNameFromUrl) - 1)];
  4033.             $response $this->httpClient->request('GET''https:' $file['file'], [
  4034.                 // optional: if you don't want to buffer the response in memory
  4035.                 'buffer' => false,
  4036.             ]);
  4037.             if (200 !== $response->getStatusCode()) {
  4038.                 throw new \Exception('...');
  4039.             }
  4040.             $fileHandler fopen($this->params->get('uploads_directory') . '/nb_designer/' $fileNameFromUrl'w');
  4041.             foreach ($this->httpClient->stream($response) as $chunk) {
  4042.                 fwrite($fileHandler$chunk->getContent());
  4043.             }
  4044.             $nbFile->setPath($fileNameFromUrl);
  4045.             $nbFile->setCategory((int)$file['cate_id']);
  4046.             $this->em->persist($nbFile);
  4047.             $this->em->flush();
  4048.         }
  4049.         $response $this->httpClient->request('GET''https://studio.cmsmart.net/v1/clipart?limit=875&category=26');
  4050.         $allFiles $response->toArray();
  4051.         foreach ($allFiles['cliparts']['items'] as $file) {
  4052.             $nbFile = new NbElements();
  4053.             $nbFile->setName($file['name']);
  4054.             $nbFile->setAlias($file['alias']);
  4055.             $fileNameFromUrl explode('/'$file['file']);
  4056.             $fileNameFromUrl $fileNameFromUrl[(count($fileNameFromUrl) - 1)];
  4057.             $response $this->httpClient->request('GET''https:' $file['file'], [
  4058.                 // optional: if you don't want to buffer the response in memory
  4059.                 'buffer' => false,
  4060.             ]);
  4061.             if (200 !== $response->getStatusCode()) {
  4062.                 throw new \Exception('...');
  4063.             }
  4064.             $fileHandler fopen($this->params->get('uploads_directory') . '/nb_designer/' $fileNameFromUrl'w');
  4065.             foreach ($this->httpClient->stream($response) as $chunk) {
  4066.                 fwrite($fileHandler$chunk->getContent());
  4067.             }
  4068.             $nbFile->setPath($fileNameFromUrl);
  4069.             $nbFile->setCategory((int)$file['cate_id']);
  4070.             $this->em->persist($nbFile);
  4071.             $this->em->flush();
  4072.         }
  4073.     }
  4074.     public function getListDirectoriesToImport(): void
  4075.     {
  4076.         // carre
  4077.         $ch curl_init();
  4078.         curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  4079.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  4080.         curl_setopt($chCURLOPT_URL'https://clubvet.local/get_cv_carre.php');
  4081.         $result curl_exec($ch);
  4082.         curl_close($ch);
  4083.         $visitCardsCarre json_decode($result);
  4084.         //classique
  4085.         $ch curl_init();
  4086.         curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  4087.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  4088.         curl_setopt($chCURLOPT_URL'https://clubvet.local/get_cv.php');
  4089.         $result curl_exec($ch);
  4090.         curl_close($ch);
  4091.         $visitCardsClassique json_decode($result);
  4092.         //a5
  4093.         $ch curl_init();
  4094.         curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  4095.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  4096.         curl_setopt($chCURLOPT_URL'https://clubvet.local/get_flyers.php');
  4097.         $result curl_exec($ch);
  4098.         curl_close($ch);
  4099.         $flyersA5 json_decode($result);
  4100.         //a6
  4101.         $ch curl_init();
  4102.         curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
  4103.         curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
  4104.         curl_setopt($chCURLOPT_URL'https://clubvet.local/get_flyers_a6.php');
  4105.         $result curl_exec($ch);
  4106.         curl_close($ch);
  4107.         $flyersA6 json_decode($result);
  4108.         foreach ($visitCardsCarre as $cv) {
  4109.             $this->ftpGetDir('163.172.30.143''copees''IxI6uRC5oAMLnFIvwR7o''/www/wp-content/uploads/nbdesigner/designs/' $cv$this->params->get('uploads_directory') . '/designs/cv_carre/' $cv);
  4110.         }
  4111.         foreach ($visitCardsClassique as $cv)
  4112.             $this->ftpGetDir('163.172.30.143''copees''IxI6uRC5oAMLnFIvwR7o''/www/wp-content/uploads/nbdesigner/designs/' $cv$this->params->get('uploads_directory') . '/designs/cv_classique/' $cv);
  4113.         foreach ($flyersA5 as $flyer)
  4114.             $this->ftpGetDir('163.172.30.143''copees''IxI6uRC5oAMLnFIvwR7o''/www/wp-content/uploads/nbdesigner/designs/' $flyer$this->params->get('uploads_directory') . '/designs/flyer_a5/' $flyer);
  4115.         foreach ($flyersA6 as $flyer)
  4116.             $this->ftpGetDir('163.172.30.143''copees''IxI6uRC5oAMLnFIvwR7o''/www/wp-content/uploads/nbdesigner/designs/' $flyer$this->params->get('uploads_directory') . '/designs/flyer_a6/' $flyer);
  4117.     }
  4118.     public function importDossierByNBD($request,$type,$json,$isCopees,$scale=null): void
  4119.     {
  4120.         $json json_decode($json);
  4121.         foreach ($json as $item) {
  4122.             $template $this->em->getRepository(NbTemplates::class)->findOneBy(array('type' => $type'name' => $item));
  4123.             if (!$template) {
  4124.                 $template = new NbTemplates();
  4125.             }
  4126.             $template->setName($item);
  4127.             if ($type == 'cv_carre') {
  4128.                 $format $this->em->getRepository(Attribut::class)->find(2); //carre
  4129.                 $template->setFormat($format);
  4130.                 $format_id 2;
  4131.             }
  4132.             if ($type == 'cv_classique') {
  4133.                 $format $this->em->getRepository(Attribut::class)->find(3); //carre
  4134.                 $template->setFormat($format);
  4135.                 $format_id 3;
  4136.             }
  4137.             if ($type == 'flyer_a5') {
  4138.                 $format $this->em->getRepository(Attribut::class)->find(5); //a5
  4139.                 $template->setFormat($format);
  4140.                 $format_id 5;
  4141.             }
  4142.             if ($type == 'flyer_a6') {
  4143.                 $format $this->em->getRepository(Attribut::class)->find(6); //a6
  4144.                 $template->setFormat($format);
  4145.                 $format_id 6;
  4146.             }
  4147.             if ($type == 'affiche_a0') {
  4148.                 $format $this->em->getRepository(Attribut::class)->find(30); //a0
  4149.                 $template->setFormat($format);
  4150.                 $format_id 30;
  4151.             }
  4152.             if ($type == 'affiche_a1') {
  4153.                 $format $this->em->getRepository(Attribut::class)->find(31); //a1
  4154.                 $template->setFormat($format);
  4155.                 $format_id 31;
  4156.             }
  4157.             if ($type == 'affiche_a2') {
  4158.                 $format $this->em->getRepository(Attribut::class)->find(32); //a2
  4159.                 $template->setFormat($format);
  4160.                 $format_id 32;
  4161.             }
  4162.             if ($type == 'menu_a4') {
  4163.                 $format $this->em->getRepository(Attribut::class)->find(33); //a4
  4164.                 $template->setFormat($format);
  4165.                 $format_id 33;
  4166.             }
  4167.             if ($type == 'menu_a3') {
  4168.                 $format $this->em->getRepository(Attribut::class)->find(34); //a3
  4169.                 $template->setFormat($format);
  4170.                 $format_id 34;
  4171.             }
  4172.             if ($type == 'faire_mariage_14cm') {
  4173.                 $format $this->em->getRepository(Attribut::class)->findOneBy(array('typeProduct'=>Attribut::FAIRE_PART_MARIAGE,'typeAttribute'=>Attribut::FORMAT));
  4174. //                $format = $this->em->getRepository(Attribut::class)->find(105); //a3
  4175.                 $template->setFormat($format);
  4176.                 $format_id $format->getId();
  4177.             }
  4178.             if ($type == 'faire_naissance_105mm') {
  4179.                 $format $this->em->getRepository(Attribut::class)->findOneBy(array('typeProduct'=>Attribut::FAIRE_PART_NAISSANCE,'typeAttribute'=>Attribut::FORMAT));
  4180. //                $format = $this->em->getRepository(Attribut::class)->find(108); //a3
  4181.                 $template->setFormat($format);
  4182.                 $format_id $format->getId();
  4183.             }
  4184.             $template->setType($type);
  4185.             $template->setIsCopees($isCopees);
  4186.             $template->setIsPaysage($request->get('isPaysage'));
  4187.             $this->em->persist($template);
  4188.             $this->em->flush();
  4189.             $this->ftpGetDir('87.98.139.241''nbd''9H1_lne0''/httpdocs/wp-content/uploads/nbdesigner/designs/' $item$this->params->get('uploads_directory') . '/designs/' $type '/' $item);
  4190.             $this->importTemplatesCustome($request$type$template->getName());
  4191.         }
  4192.         $this->updateScaleById($format_id,$isCopees,$scale);
  4193.   }
  4194.     public function importDossierImage(): void
  4195.     {
  4196.         $visitCardsCarre $this->em->getRepository(NbTemplates::class)->findBy(array('type'=>'cv_carre'));
  4197.         $visitCardsClassique $this->em->getRepository(NbTemplates::class)->findBy(array('type'=>'cv_classique'));
  4198.         $flyersA5 $this->em->getRepository(NbTemplates::class)->findBy(array('type'=>'flyer_a5'));
  4199.         $flyersA6 $this->em->getRepository(NbTemplates::class)->findBy(array('type'=>'flyer_a6'));
  4200.         foreach ($visitCardsCarre as $cv) {
  4201.             $this->ftpGetDir('163.172.30.143''copees''IxI6uRC5oAMLnFIvwR7o''/www/wp-content/uploads/nbdesigner/designs/' $cv->getName().'/preview'$this->params->get('uploads_directory') . '/designs/cv_carre/' $cv->getName().'/preview');
  4202.         }
  4203.         foreach ($visitCardsClassique as $cv)
  4204.             $this->ftpGetDir('163.172.30.143''copees''IxI6uRC5oAMLnFIvwR7o''/www/wp-content/uploads/nbdesigner/designs/' .  $cv->getName().'/preview'$this->params->get('uploads_directory') . '/designs/cv_classique/' .  $cv->getName().'/preview');
  4205.         foreach ($flyersA5 as $flyer)
  4206.             $this->ftpGetDir('163.172.30.143''copees''IxI6uRC5oAMLnFIvwR7o''/www/wp-content/uploads/nbdesigner/designs/' $flyer->getName().'/preview'$this->params->get('uploads_directory') . '/designs/flyer_a5/' $flyer->getName().'/preview');
  4207.         foreach ($flyersA6 as $flyer)
  4208.             $this->ftpGetDir('163.172.30.143''copees''IxI6uRC5oAMLnFIvwR7o''/www/wp-content/uploads/nbdesigner/designs/' $flyer->getName().'/preview'$this->params->get('uploads_directory') . '/designs/flyer_a6/' $flyer->getName().'/preview');
  4209.    }
  4210.     public function importTemplatesCustome($request$dossier,$child): void
  4211.     {
  4212.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  4213.                 $path $this->params->get('uploads_directory') . '/designs/' $dossier '/' $child;
  4214.                 $design $this->nbd_get_data_from_json($path '/design.json');
  4215.                 $productConfig $this->nbd_get_data_from_json_serialise($path '/product.json');
  4216.                 if (is_dir($path) && isset($design)) {
  4217.                     $type $dossier;
  4218.                     $template $this->em->getRepository(NbTemplates::class)->findOneBy(array('type' => $type'name' => $child));
  4219.                     if (!$template) {
  4220.                         $template = new NbTemplates();
  4221.                     }
  4222.                     $template->setName($child);
  4223.                     foreach ($design as $key => $frame) {
  4224.                         foreach ($frame->objects as $j => $object) {
  4225.                             if ($object->type == 'image' && property_exists($object'src') && !$this->validBase64($object->src) && $this->doesUrlExists($object->src)) {
  4226.                                 $fileNameFromUrl explode('/'$object->src);
  4227.                                 $fileNameFromUrl $fileNameFromUrl[(count($fileNameFromUrl) - 1)];
  4228.                                 $response $this->httpClient->request('GET'$object->src, [
  4229.                                     // optional: if you don't want to buffer the response in memory
  4230.                                     'buffer' => false,
  4231.                                 ]);
  4232.                                 $fileHandler fopen($this->params->get('uploads_directory') . '/nb_designer/templates_images/' $fileNameFromUrl'w');
  4233.                                 foreach ($this->httpClient->stream($response) as $chunk) {
  4234.                                     fwrite($fileHandler$chunk->getContent());
  4235.                                 }
  4236.                                 $design->{$key}->objects[$j]->src $baseurl '/uploads/nb_designer/templates_images/' $fileNameFromUrl;
  4237.                             }
  4238.                         }
  4239.                     }
  4240.                     $productConfig $template->setProductConfig($productConfig) : $template->setProductConfig(null);
  4241.                     $template->setConfig((array)$this->nbd_get_data_from_json($path '/config.json'));
  4242.                     $template->setDesign((array)$design);
  4243.                     $template->setFonts((array)$this->nbd_get_data_from_json($path '/used_font.json'));
  4244.                     $template->setType($type);
  4245.                     if ($dossier == 'cv_carre') {
  4246.                         $format $this->em->getRepository(Attribut::class)->find(2); //carre
  4247.                         $template->setFormat($format);
  4248.                     }
  4249.                     if ($dossier == 'cv_classique') {
  4250.                         $format $this->em->getRepository(Attribut::class)->find(3); //carre
  4251.                         $template->setFormat($format);
  4252.                     }
  4253.                     if ($dossier == 'flyer_a5') {
  4254.                         $format $this->em->getRepository(Attribut::class)->find(5); //a5
  4255.                         $template->setFormat($format);
  4256.                     }
  4257.                     if ($dossier == 'flyer_a6') {
  4258.                         $format $this->em->getRepository(Attribut::class)->find(6); //a6
  4259.                         $template->setFormat($format);
  4260.                     }
  4261.                     if ($dossier == 'affiche_a0') {
  4262.                         $format $this->em->getRepository(Attribut::class)->find(30); //a0
  4263.                         $template->setFormat($format);
  4264.                     }
  4265.                     if ($dossier == 'affiche_a1') {
  4266.                         $format $this->em->getRepository(Attribut::class)->find(31); //a1
  4267.                         $template->setFormat($format);
  4268.                     }
  4269.                     if ($dossier == 'affiche_a2') {
  4270.                         $format $this->em->getRepository(Attribut::class)->find(32); //a2
  4271.                         $template->setFormat($format);
  4272.                     }
  4273.                     if ($dossier == 'menu_a3') {
  4274.                         $format $this->em->getRepository(Attribut::class)->find(34); //a2
  4275.                         $template->setFormat($format);
  4276.                     }
  4277.                     if ($dossier == 'menu_a4') {
  4278.                         $format $this->em->getRepository(Attribut::class)->find(33); //a2
  4279.                         $template->setFormat($format);
  4280.                     }
  4281.                     if ($type == 'faire_mariage_14cm') {
  4282.                         $format $this->em->getRepository(Attribut::class)->findOneBy(array('typeProduct'=>Attribut::FAIRE_PART_MARIAGE,'typeAttribute'=>Attribut::FORMAT));
  4283. //                        $format = $this->em->getRepository(Attribut::class)->find(105); //a3
  4284.                         $template->setFormat($format);
  4285.                     }
  4286.                     if ($type == 'faire_naissance_105mm') {
  4287.                         $format $this->em->getRepository(Attribut::class)->findOneBy(array('typeProduct'=>Attribut::FAIRE_PART_NAISSANCE,'typeAttribute'=>Attribut::FORMAT));
  4288. //                        $format = $this->em->getRepository(Attribut::class)->find(108); //a3
  4289.                         $template->setFormat($format);
  4290.                     }
  4291.                     $this->em->persist($template);
  4292.                     $this->em->flush();
  4293.                 }
  4294.     }
  4295.     public function importTemplates($request$dossier): void
  4296.     {
  4297.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  4298.         $finder = new Finder();
  4299.         $finder->directories()->in($this->params->get('uploads_directory') . '/designs/' $dossier '/');
  4300.         if ($finder->hasResults()) {
  4301.             foreach ($finder as $directory) {
  4302.                 $path $this->params->get('uploads_directory') . '/designs/' $dossier '/' $directory->getFilename();
  4303.                 $design $this->nbd_get_data_from_json($path '/design.json');
  4304.                 $productConfig $this->nbd_get_data_from_json_serialise($path '/product.json');
  4305.                 if (is_dir($path) && isset($design)) {
  4306.                     $type $dossier;
  4307.                     $template $this->em->getRepository(NbTemplates::class)->findOneBy(array('type' => $type'name' => $directory->getFilename()));
  4308.                     if (!$template) {
  4309.                         $template = new NbTemplates();
  4310.                     }
  4311.                     $template->setName($directory->getFilename());
  4312.                     foreach ($design as $key => $frame) {
  4313.                         foreach ($frame->objects as $j => $object) {
  4314.                             if ($object->type == 'image' && property_exists($object'src') && !$this->validBase64($object->src) && $this->doesUrlExists($object->src)) {
  4315.                                 $fileNameFromUrl explode('/'$object->src);
  4316.                                 $fileNameFromUrl $fileNameFromUrl[(count($fileNameFromUrl) - 1)];
  4317.                                 $response $this->httpClient->request('GET'$object->src, [
  4318.                                     // optional: if you don't want to buffer the response in memory
  4319.                                     'buffer' => false,
  4320.                                 ]);
  4321.                                 $fileHandler fopen($this->params->get('uploads_directory') . '/nb_designer/templates_images/' $fileNameFromUrl'w');
  4322.                                 foreach ($this->httpClient->stream($response) as $chunk) {
  4323.                                     fwrite($fileHandler$chunk->getContent());
  4324.                                 }
  4325.                                 $design->{$key}->objects[$j]->src $baseurl '/uploads/nb_designer/templates_images/' $fileNameFromUrl;
  4326.                             }
  4327.                         }
  4328.                     }
  4329.                     $productConfig $template->setProductConfig($productConfig) : $template->setProductConfig(null);
  4330.                     $template->setConfig((array)$this->nbd_get_data_from_json($path '/config.json'));
  4331.                     $template->setDesign((array)$design);
  4332.                     $template->setFonts((array)$this->nbd_get_data_from_json($path '/used_font.json'));
  4333.                     $template->setType($type);
  4334.                     if ($dossier == 'cv_carre') {
  4335.                         $format $this->em->getRepository(Attribut::class)->find(2); //carre
  4336.                         $template->setFormat($format);
  4337.                     }
  4338.                     if ($dossier == 'cv_classique') {
  4339.                         $format $this->em->getRepository(Attribut::class)->find(3); //carre
  4340.                         $template->setFormat($format);
  4341.                     }
  4342.                     if ($dossier == 'flyer_a5') {
  4343.                         $format $this->em->getRepository(Attribut::class)->find(5); //a5
  4344.                         $template->setFormat($format);
  4345.                     }
  4346.                     if ($dossier == 'flyer_a6') {
  4347.                         $format $this->em->getRepository(Attribut::class)->find(6); //a6
  4348.                         $template->setFormat($format);
  4349.                     }
  4350.                     $this->em->persist($template);
  4351.                 }
  4352.                 $this->em->flush();
  4353.             }
  4354.         }
  4355.     }
  4356.     public function doesUrlExists($url)
  4357.     {
  4358.         $ch curl_init($url);
  4359.         curl_setopt($chCURLOPT_NOBODYtrue);
  4360.         curl_exec($ch);
  4361.         $code curl_getinfo($chCURLINFO_HTTP_CODE);
  4362.         if ($code == 200) {
  4363.             $status true;
  4364.         } else {
  4365.             $status false;
  4366.         }
  4367.         curl_close($ch);
  4368.         return $status;
  4369.     }
  4370.     public function validBase64($string)
  4371.     {
  4372.         if (strpos($string'data:image/') !== false) {
  4373.             return true;
  4374.         }
  4375.         return false;
  4376.     }
  4377.     public function nbd_get_data_from_json($path '')
  4378.     {
  4379.         $content file_exists($path) ? file_get_contents($path) : '';
  4380.         return json_decode($content);
  4381.     }
  4382.     public function nbd_get_data_from_json_serialise($path '')
  4383.     {
  4384.         $content file_exists($path) ? file_get_contents($path) : '';
  4385.         return $content;
  4386.     }
  4387.     public function ftpGetDir($host$user$passwd$remotedir$localdir$port 21)
  4388.     {
  4389.         if (!file_exists($localdir)) {
  4390.             mkdir($localdir0777);
  4391.         }
  4392.         if (func_num_args() == 7) {
  4393.             $stream func_get_args(6);
  4394.         } else {
  4395.             $stream ftp_connect($host$port);
  4396.             if (!ftp_login($stream$user$passwd))
  4397.                 return FALSE;
  4398.             if (!ftp_chdir($stream$remotedir))
  4399.                 return FALSE;
  4400.         }
  4401.         if (!is_writable($localdir))
  4402.             return FALSE;
  4403.         $list ftp_nlist($stream'.');
  4404.         if (is_array($list)) {
  4405.             foreach ($list as $k => $v) {
  4406.                 if (@ftp_chdir($stream$v)) {
  4407.                     if (!file_exists("$localdir/$v"))
  4408.                         mkdir("$localdir/$v"0777);
  4409.                     $this->ftpGetDir($host$user$passwd"$remotedir/$v""$localdir/$v"$port);
  4410.                     ftp_cdup($stream);
  4411.                 } else {
  4412.                     $fp fopen("$localdir/$v"'w');
  4413.                     if (is_resource($fp))
  4414.                         ftp_fget($stream$fp$vFTP_BINARY);
  4415.                     fclose($fp);
  4416.                 }
  4417.             }
  4418.         }
  4419.     }
  4420.     public function updateElementsUserTemplate($request): array
  4421.     {
  4422.         $userTemplate $this->em->getRepository(NbUserTemplates::class)->findOneByToken($request->get('userTemplate'));
  4423.         $design $userTemplate->getDesign();
  4424.         $design['frame_0'] = json_decode($request->get('frame_0'));
  4425.         $design['frame_1'] = json_decode($request->get('frame_1'));
  4426.         $userTemplate->setDesign($design);
  4427.         $userTemplate->setIsCrea($request->get('isCrea'));
  4428.         $this->em->flush();
  4429.         return [
  4430.             'design' => $userTemplate->getDesign()
  4431.         ];
  4432.     }
  4433.     public function updateUserTemplate($request): array
  4434.     {
  4435.         switch ($request->get('type')) {
  4436.             case 'template' :
  4437.                 $data $this->getTemplate($request->get('folder'), $request->get('userTemplate'));
  4438.                 break;
  4439.             case 'text' :
  4440. //                $data = $data = $this->addText($request->get('folder'), $request->get('userTemplate'), $request->get('frame'));
  4441.                 $data $data $this->getText($request->get('folder'), $request->get('userTemplate'), $request->get('frame'));
  4442.                 break;
  4443.             case 'icone' :
  4444.                 $data $data $this->addIcone($request->get('folder'), $request->get('userTemplate'), $request);
  4445.                 break;
  4446.             case 'qrcode' :
  4447.                 $data $this->addQrCode($request->get('userTemplate'), $request);
  4448.                 break;
  4449.             case 'urlImage' :
  4450.                 $data $data $this->addUrlImage($request->get('urlImage'), $request->get('userTemplate'), $request);
  4451.                 break;
  4452.             case 'uploadImage' :
  4453.                 $data  $this->addImage($request->files->get('uploadImage'), $request->get('userTemplate'), $request);
  4454.                 break;
  4455.             case 'uploadCrea' :
  4456.                 $data  $this->addImageCrea($request->files->get('uploadCrea'), $request->get('userTemplate'), $request);
  4457.                 break;
  4458.             default :
  4459.                 $data  $this->getTemplate($request->get('folder'), $request->get('userTemplate'));
  4460.                 break;
  4461.         }
  4462.         return $data;
  4463.     }
  4464.     public function loadUserTemplate($request): array
  4465.     {
  4466.         $userTemplate $this->em->getRepository(NbUserTemplates::class)->findOneByToken($request->get('userTemplate'));
  4467.         if($userTemplate->getDesign()){
  4468.             $design $userTemplate->getDesign();
  4469.             $configProduct $userTemplate->getProductConfig();
  4470.             return [
  4471.                 'design' => $design,
  4472.                 'config' => $userTemplate->getConfig(),
  4473.                 'fonts' => $userTemplate->getFonts(),
  4474.                 'configProduct' => $configProduct,
  4475.             ];
  4476.         }else{
  4477.             return [
  4478.                 'design' => '',
  4479.                 'config' => '',
  4480.                 'fonts' => '',
  4481.                 'configProduct' => '',
  4482.             ];
  4483.         }
  4484.     }
  4485.     public function getTemplate($folder$userTemplate): array
  4486.     {
  4487.         $baseTemplate $this->em->getRepository(NbTemplates::class)->find($folder);
  4488.         $userTemplate $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
  4489.         $userTemplate->setFonts($baseTemplate->getFonts());
  4490.         $userTemplate->setConfig($baseTemplate->getConfig());
  4491.         $userTemplate->setDesign($baseTemplate->getDesign());
  4492.         $userTemplate->setProductConfig($baseTemplate->getProductConfig());
  4493.         $userTemplate->setIsPaysage($baseTemplate->getIsPaysage());
  4494.         $this->em->flush();
  4495.         $design $userTemplate->getDesign();
  4496.         $configProduct $userTemplate->getProductConfig();
  4497.         return [
  4498.             'design' => $design,
  4499.             'config' => $userTemplate->getConfig(),
  4500.             'configProduct' => $configProduct,
  4501.             'fonts' => $userTemplate->getFonts(),
  4502.         ];
  4503.     }
  4504.     public function addText($folder$userTemplate$frame): array
  4505.     {
  4506.         $text $this->em->getRepository(NbTextes::class)->findOneByName($folder);
  4507.         $userTemplate $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
  4508.         $textContent $text->getContent();
  4509.         $userTemplateFonts $userTemplate->getFonts();
  4510.         foreach ($textContent['font'] as $font) {
  4511.             $userTemplateFonts[] = $font;
  4512.         }
  4513.         $userTemplate->setFonts($userTemplateFonts);
  4514.         $userTemplateDesign $userTemplate->getDesign();
  4515.         $objects = [];
  4516.         foreach ($textContent['design']['frame_0']['objects'] as $design) {
  4517.             if(isset($userTemplateDesign['frame_'.$frame])){
  4518.                 $userTemplateDesign['frame_'.$frame]['objects'][] = $design;
  4519.             }else{
  4520.                 $json '{"version":"2.3.3","objects":[],"background":"#ffffff"}';
  4521.                 $userTemplateDesign['frame_'.$frame] = json_decode($json,true);
  4522.                 $userTemplateDesign['frame_'.$frame]['objects'][] = $design;
  4523.             }
  4524.             $objects[] = $design['itemId'];
  4525.         }
  4526.         $userTemplate->setDesign($userTemplateDesign);
  4527.         $this->em->flush();
  4528.         $design $userTemplate->getDesign();
  4529.         $configProduct $userTemplate->getProductConfig();
  4530.         return [
  4531.             'design' => $design,
  4532.             'config' => $userTemplate->getConfig(),
  4533.             'fonts' => $userTemplate->getFonts(),
  4534.             'configProduct' => $configProduct,
  4535.             'objects' => $objects
  4536.         ];
  4537.     }
  4538.     public function getText($folder$userTemplate$frame): array
  4539.     {
  4540.         $text $this->em->getRepository(NbTextes::class)->findOneByName($folder);
  4541.         $userTemplate $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
  4542.         $textContent $text->getContent();
  4543.         $userTemplateFonts $userTemplate->getFonts();
  4544.         foreach ($textContent['font'] as $font) {
  4545.             $userTemplateFonts[] = $font;
  4546.         }
  4547.         return [
  4548.             "font" => $userTemplateFonts,
  4549.             "object" => $textContent['design']['frame_0']
  4550.         ];
  4551.     }
  4552.     public function addIcone($folder$userTemplate$request): array
  4553.     {
  4554.         $icone $this->em->getRepository(NbElements::class)->find((int)$folder);
  4555.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  4556.         return [
  4557.             "src" => $baseurl "/uploads/nb_designer/" $icone->getPath()
  4558.         ];
  4559.     }
  4560.     public function addUrlImage($urlImage$userTemplate$request)
  4561.     {
  4562.         if (!empty($urlImage)) {
  4563.             $fileName $this->uploadImageFromUrl($urlImage);
  4564.             if($fileName) {
  4565.                 $nbFile = new NbFiles();
  4566.                 $nbFile->setToken($userTemplate);
  4567.                 $nbFile->setName($fileName);
  4568.                 $nbFile->setAlias($fileName);
  4569.                 $nbFile->setPath($fileName);
  4570.                 $this->em->persist($nbFile);
  4571.                 $this->em->flush();;
  4572.                 $icone $nbFile;
  4573.                 $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  4574.                 return [
  4575.                     "src" => $baseurl "/uploads/nb_designer/" $icone->getPath()
  4576.                 ];
  4577.             }else{
  4578.                 return ['src' => false];
  4579.             }
  4580.         } else {
  4581.             return ['src' => false];
  4582.         }
  4583.     }
  4584.     public function addImage($image$userTemplate$request): array
  4585.     {
  4586.         $width $request->get('maxWidth');
  4587.         if (in_array($image->guessExtension(), array('svg''png''jpg','jpeg'))) {
  4588.             $ext $image->guessExtension();
  4589.             $fileName $this->generateToken(10)  . '.' $ext;
  4590.             $image->move($this->params->get('uploads_directory'). '/nb_designer'$fileName);
  4591.             // resize image
  4592. //            $resize = new ImageResizeService($this->params->get('uploads_directory'). '/nb_designer/'. $fileName);
  4593. //            $resize->resizeTo($width, 500,'maxwidth');
  4594. //            $resize->saveImage($this->params->get('uploads_directory'). '/nb_designer/'. $fileName);
  4595.             $nbFile = new NbFiles();
  4596.             $nbFile->setToken($userTemplate);
  4597.             $nbFile->setName($image->getClientOriginalName());
  4598.             $nbFile->setAlias($image->getClientOriginalName());
  4599.             $nbFile->setIsCrea(false);
  4600.             $templateEntity $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
  4601.             if($templateEntity->getUser()){
  4602.                 $nbFile->setUser($templateEntity->getUser());
  4603.             }
  4604.             $nbFile->setPath($fileName);
  4605.             $this->em->persist($nbFile);
  4606.             $this->em->flush();;
  4607.             $icone $nbFile;
  4608.             $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  4609.             return [
  4610.                 "src" => $baseurl "/uploads/nb_designer/" $icone->getPath(),
  4611.                 'typeImage' =>$ext,
  4612.                 'images' => $this->getImageUploads($userTemplate),
  4613.                 'size' => getimagesize ($baseurl "/uploads/nb_designer/" $fileName),
  4614.             ];
  4615.         }else if (in_array($image->guessExtension(), array('pdf'))) {
  4616.             $ext $image->guessExtension();
  4617.             $token $this->generateToken(10);
  4618.             $fileName $token  '.' $ext;
  4619.             $image->move($this->params->get('uploads_directory'). '/nb_designer'$fileName);
  4620.             $images $this->convertPdfToImageNotCrea($fileName,$token);
  4621.             foreach ($images as $item){
  4622.                 $nbFile = new NbFiles();
  4623.                 $templateEntity $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
  4624.                 if($templateEntity->getUser()){
  4625.                     $nbFile->setUser($templateEntity->getUser());
  4626.                 }
  4627.                 $nbFile->setToken($userTemplate);
  4628.                 $nbFile->setName($item);
  4629.                 $nbFile->setAlias($item);
  4630.                 $nbFile->setIsCrea(false);
  4631.                 $nbFile->setPath($token.'/'.$item);
  4632.                 $this->em->persist($nbFile);
  4633.                 $this->em->flush();;
  4634.             }
  4635.             return [
  4636.                 'typeImage' =>$ext,
  4637.                 'images' => $this->getImageUploads($userTemplate),
  4638.             ];
  4639.         }else{
  4640.             return ['src' => false];
  4641.         }
  4642.     }
  4643.     public function addImageCrea($image$userTemplate$request): array
  4644.     {
  4645.         if (in_array($image->guessExtension(), array('svg''png''jpg','jpeg'))) {
  4646.             $ext $image->guessExtension();
  4647.             $fileName $this->generateToken(10)  . '.' $ext;
  4648.             $image->move($this->params->get('uploads_directory'). '/image_ma_crea'$fileName);
  4649.             $nbFile = new NbFiles();
  4650.             $nbFile->setToken($userTemplate);
  4651.             $nbFile->setIsCrea(true);
  4652.             $templateEntity $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
  4653.             if($templateEntity->getUser()){
  4654.                 $nbFile->setUser($templateEntity->getUser());
  4655.             }
  4656.             $nbFile->setName($image->getClientOriginalName());
  4657.             $nbFile->setAlias($image->getClientOriginalName());
  4658.             $nbFile->setPath($fileName);
  4659.             $this->em->persist($nbFile);
  4660.             $this->em->flush();;
  4661.             return [
  4662.                 'typeImage' =>$ext,
  4663.                 'images' => $this->getImageUploadsCrea($userTemplate),
  4664.             ];
  4665.         }else if (in_array($image->guessExtension(), array('pdf'))) {
  4666.             $ext $image->guessExtension();
  4667.             $token $this->generateToken(10);
  4668.             $fileName $token  '.' $ext;
  4669.             $image->move($this->params->get('uploads_directory'). '/image_ma_crea'$fileName);
  4670.             $images $this->convertPdfToImage($fileName,$token);
  4671.             foreach ($images as $item){
  4672.                 $nbFile = new NbFiles();
  4673.                 $templateEntity $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
  4674.                 if($templateEntity->getUser()){
  4675.                     $nbFile->setUser($templateEntity->getUser());
  4676.                 }
  4677.                 $nbFile->setToken($userTemplate);
  4678.                 $nbFile->setName($item);
  4679.                 $nbFile->setAlias($item);
  4680.                 $nbFile->setIsCrea(true);
  4681.                 $nbFile->setPath($token.'/'.$item);
  4682.                 $this->em->persist($nbFile);
  4683.                 $this->em->flush();;
  4684.             }
  4685.             return [
  4686.                 'typeImage' =>$ext,
  4687.                 'images' => $this->getImageUploadsCrea($userTemplate),
  4688.             ];
  4689.         }else{
  4690.             return ['src' => false];
  4691.         }
  4692.     }
  4693.     public function convertPdfToImage($file,$token){
  4694.         $dir  $this->params->get('uploads_directory').'/image_ma_crea';
  4695.         $dossier $this->params->get('uploads_directory').'/image_ma_crea/'.$token;
  4696.         $saveTo  $dossier.'/';
  4697.         mkdir($dossier);
  4698.         shell_exec"gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r600 -dUseCropBox -o  ".$saveTo."page-%d.png  ".$dir."/".$file );
  4699. //        shell_exec( "C:\\gs\\gs9.50\\bin\\gswin64c.exe -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r600 -dUseCropBox -o  ".$saveTo."page-%d.png  ".$dir."/".$file ); // save pdf to image
  4700.         $scanned_directory array_diffscandir$dossier ), array( '..''.''source' ) );
  4701.         $tab = array();
  4702.         foreach ( $scanned_directory as $key => $value ) {
  4703.             $tab[] = $value;
  4704.         }
  4705.         return $tab;
  4706.     }
  4707.     public function convertPdfToImageNotCrea($file,$token){
  4708.         $dir  $this->params->get('uploads_directory').'/nb_designer';
  4709.         $dossier $this->params->get('uploads_directory').'/nb_designer/'.$token;
  4710.         $saveTo  $dossier.'/';
  4711.         mkdir($dossier);
  4712.         shell_exec"gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r600 -dUseCropBox -o  ".$saveTo."page-%d.png  ".$dir."/".$file );
  4713. //        shell_exec( "C:\\gs\\gs9.50\\bin\\gswin64c.exe -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r600 -dUseCropBox -o  ".$saveTo."page-%d.png  ".$dir."/".$file ); // save pdf to image
  4714.         $scanned_directory array_diffscandir$dossier ), array( '..''.''source' ) );
  4715.         $tab = array();
  4716.         foreach ( $scanned_directory as $key => $value ) {
  4717.             $tab[] = $value;
  4718.         }
  4719.         return $tab;
  4720.     }
  4721.     public function uploadImageFromUrl($file)
  4722.     {
  4723.         $fileExtentionFromUrl explode('.'$file);
  4724.         $fileExtentionFromUrl $fileExtentionFromUrl[(count($fileExtentionFromUrl) - 1)];
  4725.         if (in_array($fileExtentionFromUrl, array('svg''png''jpg'))) {
  4726.             $response $this->httpClient->request('GET'$file, [
  4727.                 'buffer' => false,
  4728.             ]);
  4729.             if (200 !== $response->getStatusCode()) {
  4730.                 return false;
  4731.             }
  4732.             $fileNameFromUrl $this->generateToken(10) . '.' $fileExtentionFromUrl;
  4733.             $fileHandler fopen($this->params->get('uploads_directory') . '/nb_designer/' $fileNameFromUrl'w');
  4734.             foreach ($this->httpClient->stream($response) as $chunk) {
  4735.                 fwrite($fileHandler$chunk->getContent());
  4736.             }
  4737.             return $fileNameFromUrl;
  4738.         } else {
  4739.             return false;
  4740.         }
  4741.     }
  4742.     public function addQrCode($userTemplate$request)
  4743.     {
  4744.         $ext '.png';
  4745.         $fileName uniqid().$ext;
  4746.         $base64 str_replace('data:image/png;base64,'''$request->get('file'));
  4747.         $file fopen($this->params->get('uploads_directory').'/nb_designer/templates_images/'.$fileName'wb');
  4748.         fwrite($filebase64_decode($base64));
  4749.         fclose($file);
  4750.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  4751.         return [
  4752.             "src" => $baseurl "/uploads/nb_designer/templates_images/" $fileName
  4753.         ];
  4754.     }
  4755.     public function getTextDataByFolder($folder): array
  4756.     {
  4757.         $template $this->em->getRepository(NbTextes::class)->findOneByName($folder);
  4758.         return [
  4759.             'content' => $template->getContent(),
  4760.         ];
  4761.     }
  4762.     public function getCssFonts($request): array
  4763.     {
  4764.         $finder = new Finder();
  4765.         $finder->files()->in($this->params->get('uploads_directory') . '/nb_designer/fonts/');
  4766.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  4767.         $fonts = [];
  4768.         if ($finder->hasResults()) {
  4769.             foreach ($finder as $file) {
  4770.                 $fonts[] = [
  4771.                     'name' => str_replace('.ttf'''$file->getFilename()),
  4772.                     'url' => $baseurl '/uploads/nb_designer/fonts/' str_replace('\\''/'$file->getRelativePath()) . '/' $file->getFilename()
  4773.                 ];
  4774.             }
  4775.         }
  4776.         return $fonts;
  4777.     }
  4778.     public function getImageUploads($token){
  4779.         $images $this->em->getRepository(NbFiles::class)->findBy(array('token'=>$token,'isCrea'=>false));
  4780.         return $this->twig->render('nb_designer/imageUpload.html.twig',array('images'=>$images));
  4781.     }
  4782.     public function getImageUploadsCrea($token){
  4783.         $images $this->em->getRepository(NbFiles::class)->findBy(array('token'=>$token,'isCrea'=>true));
  4784.         return $this->twig->render('nb_designer/creaUpload.html.twig',array('images'=>$images));
  4785.     }
  4786.     public function importTextesPreviews() : void
  4787.     {
  4788.         $textes $this->em->getRepository(NbTextes::class)->findAll();
  4789.         foreach ($textes as $text) {
  4790.             $response $this->httpClient->request('GET''https://dpeuzbvf3y4lr.cloudfront.net/typography/'.$text->getName().'/preview.png', [
  4791.                 // optional: if you don't want to buffer the response in memory
  4792.                 'buffer' => false,
  4793.             ]);
  4794.             if (200 !== $response->getStatusCode()) {
  4795.                 throw new \Exception('...');
  4796.             }
  4797.             $fileHandler fopen($this->params->get('uploads_directory') . '/nb_designer/text_previews/' $text->getName().'.png''w');
  4798.             foreach ($this->httpClient->stream($response) as $chunk) {
  4799.                 fwrite($fileHandler$chunk->getContent());
  4800.             }
  4801.         }
  4802.     }
  4803.     public function updateScale() : void
  4804.     {
  4805.         $templates $this->em->getRepository(NbTemplates::class)->findBy(array('format' => 2,'isCopees' => true), array());
  4806.         foreach ($templates as $template) {
  4807.             $config $template->getConfig();
  4808.             $config['scale'] = 1.36;
  4809.             $template->setConfig($config);
  4810.         }
  4811.         $templates $this->em->getRepository(NbTemplates::class)->findBy(array('format' => 3,'isCopees' => true), array());
  4812.         foreach ($templates as $template) {
  4813.             $config $template->getConfig();
  4814.             $config['scale'] = 0.82;
  4815.             $template->setConfig($config);
  4816.         }
  4817.         $templates $this->em->getRepository(NbTemplates::class)->findBy(array('format' => 5,'isCopees' => true), array());
  4818.         foreach ($templates as $template) {
  4819.             $config $template->getConfig();
  4820.             $config['scale'] = 1.8;
  4821.             $template->setConfig($config);
  4822.         }
  4823.         $templates $this->em->getRepository(NbTemplates::class)->findBy(array('format' => 6,'isCopees' => true), array());
  4824.         foreach ($templates as $template) {
  4825.             $config $template->getConfig();
  4826.             $config['scale'] = 1.8;
  4827.             $template->setConfig($config);
  4828.         }
  4829.         $this->em->flush();
  4830.     }
  4831.     public function updateScaleById($format,$isCopees,$scale=null) : void
  4832.     {
  4833.         $templates $this->em->getRepository(NbTemplates::class)->findBy(array('format' => $format,'isCopees' => $isCopees), array());
  4834.         $oneTemplate $this->em->getRepository(NbTemplates::class)->findOneBy(array('format' => $format,'isCopees' => $isCopees), array());
  4835.         if($format == 2) { // carre
  4836.             if ($templates) {
  4837.                 foreach ($templates as $template) {
  4838.                     $config $template->getConfig();
  4839.                     $config['scale'] = $scale $scale 1.361;
  4840.                     $template->setConfig($config);
  4841.                 }
  4842.             }
  4843.         }
  4844.         if($format == 3) { // classique
  4845.             if ($templates) {
  4846.                 foreach ($templates as $template) {
  4847.                     $config $template->getConfig();
  4848.                     $config['scale'] =  $scale $scale :  0.821;
  4849.                     $template->setConfig($config);
  4850.                 }
  4851.             }
  4852.         }
  4853.         if($format == 5) { // a5
  4854.             if ($templates) {
  4855.                 foreach ($templates as $template) {
  4856.                     $config $template->getConfig();
  4857.                     $config['scale'] =  $scale $scale :  1.81;
  4858.                     $template->setConfig($config);
  4859.                 }
  4860.             }
  4861.         }
  4862.         if($format == 6) { // a6
  4863.             if ($templates) {
  4864.                 foreach ($templates as $template) {
  4865.                     $config $template->getConfig();
  4866.                     $config['scale'] = $scale $scale :  1.81;
  4867.                     $template->setConfig($config);
  4868.                 }
  4869.             }
  4870.         }
  4871.         if($format == 30) { // a0
  4872.             if ($templates) {
  4873.                 foreach ($templates as $template) {
  4874.                     $config $template->getConfig();
  4875.                     $config['scale'] = $scale $scale :  1.80;
  4876.                     $template->setConfig($config);
  4877.                 }
  4878.             }
  4879.         }
  4880.         if($format == 31) { // a1
  4881.             if ($templates) {
  4882.                 foreach ($templates as $template) {
  4883.                     $config $template->getConfig();
  4884.                     $config['scale'] =  $scale $scale 1.80;
  4885.                     $template->setConfig($config);
  4886.                 }
  4887.             }
  4888.         }
  4889.         if($format == 32) { // a1
  4890.             if ($templates) {
  4891.                 foreach ($templates as $template) {
  4892.                     $config $template->getConfig();
  4893.                     $config['scale'] =  $scale $scale 1.80;
  4894.                     $template->setConfig($config);
  4895.                 }
  4896.             }
  4897.         }
  4898.         if($format == 33) { // a4
  4899.             if ($templates) {
  4900.                 foreach ($templates as $template) {
  4901.                     $config $template->getConfig();
  4902.                     $config['scale'] =  $scale $scale 1.80;
  4903.                     $template->setConfig($config);
  4904.                 }
  4905.             }
  4906.         }
  4907.         if($format == 34) { // a3
  4908.             if ($templates) {
  4909.                 foreach ($templates as $template) {
  4910.                     $config $template->getConfig();
  4911.                     $config['scale'] =  $scale $scale 1.80;
  4912.                     $template->setConfig($config);
  4913.                 }
  4914.             }
  4915.         }
  4916.         if($oneTemplate->getType() == 'faire_mariage_14cm') { // faire part mariage
  4917.             if ($templates) {
  4918.                 foreach ($templates as $template) {
  4919.                     $config $template->getConfig();
  4920.                     $config['scale'] =  $scale $scale 1.80;
  4921.                     $template->setConfig($config);
  4922.                 }
  4923.             }
  4924.         }
  4925.         if($oneTemplate->getType() == 'faire_naissance_105mm') { // faire part naissance
  4926.             if ($templates) {
  4927.                 foreach ($templates as $template) {
  4928.                     $config $template->getConfig();
  4929.                     $config['scale'] =  $scale $scale 1.80;
  4930.                     $template->setConfig($config);
  4931.                 }
  4932.             }
  4933.         }
  4934.         $this->em->flush();
  4935.     }
  4936.     public function loadUserTemplateLayers($request) : array
  4937.     {
  4938.         $userTemplate $this->getUserTemplate();
  4939.         $design $userTemplate->getDesign();
  4940.         if(!isset( $design['frame_'.$request->get('active_frame')])){
  4941.             $json '{"version":"2.3.3","objects":[],"background":"#ffffff"}';
  4942.             $design['frame_'.$request->get('active_frame')] = json_decode($json,true);
  4943.         }
  4944.         return [
  4945.             'layers' => $design['frame_'.$request->get('active_frame')]['objects']
  4946.         ];
  4947.     }
  4948.     public function updateSelectableUserTemplateLayers($request) : void
  4949.     {
  4950.         $userTemplate $this->getUserTemplate();
  4951.         $design $userTemplate->getDesign();
  4952.         $design['frame_'.$request->get('active_frame')]['objects'][$request->get('index')]['selectable'] = $request->get('selectable') ? true false;
  4953.         $userTemplate->setDesign($design);
  4954.         $this->em->flush();
  4955.     }
  4956.     public function getImageRectoVerso($request){
  4957.         $userTemplate $this->getUserTemplate();
  4958.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  4959.         return [
  4960.             'recto'=> $userTemplate $baseurl.'/uploads/tmp/'.$userTemplate->getRecto():'',
  4961.             'verso'=> $userTemplate $baseurl.'/uploads/tmp/'.$userTemplate->getVerso():'',
  4962.         ];
  4963.     }
  4964.     public function generatePdf($request) : string
  4965.     {
  4966.         $userTemplate $this->getUserTemplate();
  4967.         $ext '.png';
  4968.         $frame_0 uniqid().$ext;
  4969.         $base64 str_replace('data:image/png;base64,'''$request->get('frame_0'));
  4970.         $file fopen($this->params->get('uploads_directory').'/tmp/'.$frame_0'wb');
  4971.         fwrite($filebase64_decode($base64));
  4972.         fclose($file);
  4973.         $userTemplate->setRecto($frame_0);
  4974.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  4975.         $frames[] = $baseurl "/uploads/tmp/" $frame_0;
  4976.         if($request->get('rectoverso')) {
  4977.             $frame_1 uniqid().$ext;
  4978.             $base64 str_replace('data:image/png;base64,'''$request->get('frame_1'));
  4979.             $file fopen($this->params->get('uploads_directory').'/tmp/'.$frame_1'wb');
  4980.             fwrite($filebase64_decode($base64));
  4981.             fclose($file);
  4982.             $userTemplate->setVerso($frame_1);
  4983.             $frames[] = $baseurl "/uploads/tmp/" $frame_1;
  4984.         }
  4985.         $attribute $this->em->getRepository(Attribut::class)->find($request->get('formatInput'));
  4986.         $format $attribute->getName();
  4987.         if($userTemplate->getIsTrait()){ //avec trait de coupe
  4988.             if($format == 'A5'){
  4989.                 $papier $userTemplate->getIsPaysage() ? array(210,148) : array(148,210) ;
  4990.                 $width $userTemplate->getIsPaysage() ? "793.7007874" :"559.37007874";
  4991.                 $height $userTemplate->getIsPaysage() ? "559.37007874" :"793.7007874";
  4992.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  4993.             }else if($format == 'A6'){
  4994.                 $papier $userTemplate->getIsPaysage() ? array(148,105) : array(105,148) ;
  4995.                 $width $userTemplate->getIsPaysage() ? "559.37007874" :"396.8503937";
  4996.                 $height $userTemplate->getIsPaysage() ? "396.8503937" :"559.37007874";
  4997.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  4998.             }else if($format == 'Carré'){
  4999.                 $papier = array(55,55);
  5000.                 $width "207.87401575";
  5001.                 $height "207.87401575";
  5002.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5003.             }else if($format == 'Classique') {
  5004.                 $papier $userTemplate->getIsPaysage() ? array(55,85) : array(85,55) ;
  5005.                 $width $userTemplate->getIsPaysage() ? "207.87401575" :"321.25984252";
  5006.                 $height $userTemplate->getIsPaysage() ? "321.25984252" :"207.87401575";
  5007.                 $oriontation $userTemplate->getIsPaysage() ? 'P':'L';
  5008.             }else if($format == 'A0') {
  5009.                 $papier $userTemplate->getIsPaysage() ? array(1189,841) : array(841,1189) ;
  5010.                 $width $userTemplate->getIsPaysage() ? "4493.8582677" :"3178.582677";
  5011.                 $height $userTemplate->getIsPaysage() ? "3178.582677" :"4493.8582677";
  5012.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5013.             }else if($format == 'A1') {
  5014.                 $papier $userTemplate->getIsPaysage() ? array(841,594) : array(594,841) ;
  5015.                 $width $userTemplate->getIsPaysage() ? "3178.582677" :"2245.0393701";
  5016.                 $height $userTemplate->getIsPaysage() ? "2245.0393701" :"3178.582677";
  5017.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5018.             }else if($format == 'A2') {
  5019.                 $papier $userTemplate->getIsPaysage() ? array(594,420) : array(420,594) ;
  5020.                 $width $userTemplate->getIsPaysage() ? "2245.0393701" :"1587.4015748";
  5021.                 $height $userTemplate->getIsPaysage() ? "1587.4015748" :"2245.0393701";
  5022.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5023.             }else if($format == 'A3') {
  5024.                 $papier $userTemplate->getIsPaysage() ? array(420,297) : array(297,420) ;
  5025.                 $width $userTemplate->getIsPaysage() ? "1587.4015748" :"1122.519685";
  5026.                 $height $userTemplate->getIsPaysage() ? "1122.519685" :"1587.4015748";
  5027.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5028.             }else if($format == 'A4') {
  5029.                 $papier $userTemplate->getIsPaysage() ? array(297,210) : array(210,297) ;
  5030.                 $width $userTemplate->getIsPaysage() ? "1122.519685" :"805.03937";
  5031.                 $height $userTemplate->getIsPaysage() ? "805.03937" :"1122.519685";
  5032.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5033.             }else{
  5034.                 if($attribute->getTypeProduct() == Attribut::FAIRE_PART_NAISSANCE){
  5035.                     $papier $userTemplate->getIsPaysage() ? array(148,105) : array(105,148) ;
  5036.                     $width $userTemplate->getIsPaysage() ? "559.37007874" :"396.8503937";
  5037.                     $height $userTemplate->getIsPaysage() ? "396.8503937" :"559.37007874";
  5038.                     $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5039.                 }else if($attribute->getTypeProduct() == Attribut::FAIRE_PART_MARIAGE){
  5040.                     $papier = array(140140);
  5041.                     $width "529.13385827";
  5042.                     $height "529.13385827";
  5043.                     $oriontation 'P';
  5044.                 }else {
  5045.                     $papier $userTemplate->getIsPaysage() ? array(210,148) : array(148,210) ;
  5046.                     $width $userTemplate->getIsPaysage() ? "793.7007874" :"559.37007874";
  5047.                     $height $userTemplate->getIsPaysage() ? "559.37007874" :"793.7007874";
  5048.                     $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5049.                 }
  5050.             }
  5051.             $html $this->twig->render('nb_designer/pdf_sans_trait_coupe.html.twig', [
  5052.                     'frames' => $frames,
  5053.                     'width' => $width,
  5054.                     'height' => $height
  5055.                 ]
  5056.             );
  5057.         }else {
  5058.             if ($format == 'A5') {
  5059.                 $papier $userTemplate->getIsPaysage() ? array(216,154) : array(154216) ;
  5060.                 $width $userTemplate->getIsPaysage() ? "808.818898" :"574.488189";
  5061.                 $height $userTemplate->getIsPaysage() ? "574.488189" :"808.818898";
  5062.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5063.             } else if ($format == 'A6') {
  5064.                 $papier $userTemplate->getIsPaysage() ? array(154,111) : array(111,154) ;
  5065.                 $width $userTemplate->getIsPaysage() ? "574.488189" :"411.968504";
  5066.                 $height $userTemplate->getIsPaysage() ? "411.968504" :"574.488189";
  5067.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5068.             } else if ($format == 'Carré') {
  5069.                 $papier = array(6161);
  5070.                 $width "222.992126"// 59 mm
  5071.                 $height "222.992126"// 59 mm
  5072.                 $oriontation 'P';
  5073.             } else if ($format == 'Classique') {
  5074.                 $papier $userTemplate->getIsPaysage() ? array(61,91) : array(91,61) ;
  5075.                 $width $userTemplate->getIsPaysage() ? "222.992126" :"336.377953";
  5076.                 $height $userTemplate->getIsPaysage() ? "336.377953" :"222.992126";
  5077.                 $oriontation $userTemplate->getIsPaysage() ? 'P':'L';
  5078.             } else if ($format == 'A0') {
  5079.                 $papier $userTemplate->getIsPaysage() ? array(1195,847) : array(847,1195) ;
  5080.                 $width $userTemplate->getIsPaysage() ? "4505.196851" :"3189.92126";
  5081.                 $height $userTemplate->getIsPaysage() ? "3189.92126" :"4505.196851";
  5082.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5083.             } else if ($format == 'A1') {
  5084.                 $papier $userTemplate->getIsPaysage() ? array(847,600) : array(600,847) ;
  5085.                 $width $userTemplate->getIsPaysage() ? "3189.92126" :"2256.377953";
  5086.                 $height $userTemplate->getIsPaysage() ? "2256.377953" :"3189.92126";
  5087.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5088.             } else if ($format == 'A2') {
  5089.                 $papier $userTemplate->getIsPaysage() ? array(600,426) : array(426,600) ;
  5090.                 $width $userTemplate->getIsPaysage() ? "2256.377953" :"1598.740158";
  5091.                 $height $userTemplate->getIsPaysage() ? "1598.740158" :"2256.377953";
  5092.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5093.             } else if ($format == 'A3') {
  5094.                 $papier $userTemplate->getIsPaysage() ? array(426,303) : array(303,426) ;
  5095.                 $width $userTemplate->getIsPaysage() ? "1598.740158" :"1133.858268";
  5096.                 $height $userTemplate->getIsPaysage() ? "1133.858268" :"1598.740158";
  5097.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5098.             } else if ($format == 'A4') {
  5099.                 $papier $userTemplate->getIsPaysage() ? array(303,216) : array(216,303) ;
  5100.                 $width $userTemplate->getIsPaysage() ? "1133.858268" :"805.03937";
  5101.                 $height $userTemplate->getIsPaysage() ? "805.03937" :"1133.858268";
  5102.                 $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5103.             } else {
  5104.                 if ($attribute->getTypeProduct() == Attribut::FAIRE_PART_NAISSANCE) {
  5105.                     $papier $userTemplate->getIsPaysage() ? array(154,111) : array(111,154) ;
  5106.                     $width $userTemplate->getIsPaysage() ? "574.488189" :"411.968504";
  5107.                     $height $userTemplate->getIsPaysage() ? "411.968504" :"574.488189";
  5108.                     $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5109.                 } else if ($attribute->getTypeProduct() == Attribut::FAIRE_PART_MARIAGE) {
  5110.                     $papier = array(146146);
  5111.                     $width "544.251968";
  5112.                     $height "544.251968";
  5113.                     $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5114.                 } else {
  5115.                     $papier $userTemplate->getIsPaysage() ? array(216,154) : array(154,216) ;
  5116.                     $width $userTemplate->getIsPaysage() ? "793.700785" :"559.370077";
  5117.                     $height $userTemplate->getIsPaysage() ? "559.370077" :"793.700785";
  5118.                     $oriontation $userTemplate->getIsPaysage() ? 'L':'P';
  5119.                 }
  5120.             }
  5121.             $html $this->twig->render('nb_designer/pdf.html.twig', [
  5122.                     'frames' => $frames,
  5123.                     'width' => $width,
  5124.                     'height' => $height
  5125.                 ]
  5126.             );
  5127.         }
  5128.         $html2pdf = new Html2Pdf($oriontation$papier'en'true'UTF-8', array('0','0','0','0'));
  5129. //        $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', array('5','5','5','5'));
  5130.         $html2pdf->pdf->SetAuthor('Copees');
  5131.         $html2pdf->pdf->SetTitle('Copees');
  5132.         $html2pdf->pdf->SetSubject('Copees');
  5133.         $html2pdf->pdf->SetKeywords('Copees');
  5134.         $html2pdf->pdf->SetDisplayMode('real');
  5135.         $html2pdf->WriteHTML($html);
  5136.         $nameFichier uniqid().'.pdf';
  5137.         $userTemplate->setPath($nameFichier);
  5138.         $this->em->flush();
  5139.         $path_pdf $this->params->get('uploads_directory').'/tmp/'.$nameFichier;
  5140.         $html2pdf->Output($path_pdf,'F');
  5141.         return $nameFichier;
  5142.     }
  5143.     public function convertImageToPdf($request,$userTemplate,$image1,$image2){
  5144.         if($image1) {
  5145.             $frame_0 $image1;
  5146.             $frame_0_new 'ma_crea_recto_' $userTemplate->getToken() . '.png';
  5147.             $dossier_frame_0 str_replace('/uploads'$this->params->get('uploads_directory'), $frame_0);
  5148.             $dossier_frame_0_new $this->params->get('uploads_directory') . '/tmp/' $frame_0_new;
  5149.             if (trim($dossier_frame_0) == trim($dossier_frame_0_new)) {
  5150.                 $frame_0_new 'ma_crea_recto_' $userTemplate->getToken() . '_1.png';
  5151.                 $dossier_frame_0_new $this->params->get('uploads_directory') . '/tmp/' $frame_0_new;
  5152.             }
  5153.             copy($dossier_frame_0$dossier_frame_0_new);
  5154.             $userTemplate->setRecto($frame_0_new);
  5155.             $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  5156.             $frames[] = $baseurl "/uploads/tmp/" $frame_0_new;
  5157.             if($image2){
  5158.                 $frame_1 $image2;
  5159.                 $frame_1_new 'ma_crea_verso_'.$userTemplate->getToken() .'.png';
  5160.                 $dossier_frame_1 str_replace ('/uploads',$this->params->get('uploads_directory'),$frame_1);
  5161.                 $dossier_frame_1_new $this->params->get('uploads_directory'). '/tmp/' $frame_1_new;
  5162.                 if(trim($dossier_frame_1) == trim($dossier_frame_1_new)){
  5163.                     $frame_1_new 'ma_crea_verso_'$userTemplate->getToken() .'_1.png';
  5164.                     $dossier_frame_1_new $this->params->get('uploads_directory'). '/tmp/' $frame_1_new;
  5165.                 }
  5166.                 copy($dossier_frame_1 $dossier_frame_1_new);
  5167.                 $userTemplate->setVerso($frame_1_new);
  5168.                 $frames[] = $baseurl "/uploads/tmp/" $frame_1_new;
  5169.             }else{
  5170.                 $userTemplate->setVerso(null);
  5171.             }
  5172.             $attribute $this->em->getRepository(Attribut::class)->find($request->get('formatInput'));
  5173.             $format $attribute->getName();
  5174.              if($format == 'A3') {
  5175.                 $papier = array(297,420 );
  5176.                 $width "1122";
  5177.                 $height "1587" ;
  5178.                 $oriontation 'P';
  5179.             }else if($format == 'A4') {
  5180.                 $papier = array(210,297 );
  5181.                 $width "793";
  5182.                 $height "1122" ;
  5183.                 $oriontation 'P';
  5184.             }else{
  5185.                 $papier = array(154216);
  5186.                 $width "559";
  5187.                 $height "793";
  5188.                 $oriontation 'P';
  5189.             }
  5190.             $html $this->twig->render('nb_designer/pdf2.html.twig', [
  5191.                     'frames' => $frames,
  5192.                     'width' => $width,
  5193.                     'height' => $height
  5194.                 ]
  5195.             );
  5196.             $html2pdf = new Html2Pdf($oriontation$papier'en'true'UTF-8', array('0','0','0','0'));
  5197.             $html2pdf->pdf->SetAuthor('Copees');
  5198.             $html2pdf->pdf->SetTitle('Copees');
  5199.             $html2pdf->pdf->SetSubject('Copees');
  5200.             $html2pdf->pdf->SetKeywords('Copees');
  5201.             $html2pdf->pdf->SetDisplayMode('real');
  5202.             $html2pdf->WriteHTML($html);
  5203.             $nameFichier uniqid().'.pdf';
  5204.             $userTemplate->setIsCrea(true);
  5205.             if($request->get('plus_expert') == 1)$userTemplate->setIsPlusExpert(true);
  5206.             else $userTemplate->setIsPlusExpert(false);
  5207.             $userTemplate->setPath($nameFichier);
  5208.             $this->em->flush();
  5209.             $path_pdf $this->params->get('uploads_directory').'/tmp/'.$nameFichier;
  5210.             $html2pdf->Output($path_pdf,'F');
  5211.             return 1;
  5212.         }
  5213.         return 0;
  5214.     }
  5215.     public function generateZip($request) : string
  5216.     {
  5217.         $userTemplate $this->em->getRepository(NbUserTemplates::class)->findOneBy(array('token'=>$request->get('user_template')));
  5218.         $product $this->em->getRepository(Product::class)->find($request->get('id_product'));
  5219.         if($product->getTypeProduct() == Product::MENU){
  5220.             $image1 $request->get('frame_0');
  5221.             $image2 null;
  5222.             if ($request->get('rectoverso')) {
  5223.                 $image2$request->get('frame_1');
  5224.             }
  5225.             return $this->convertImageToPdf($request,$userTemplate,$image1,$image2);
  5226.         }else {
  5227.             if ($request->get('frame_0')) {
  5228.                 $frame_0 $request->get('frame_0');
  5229.                 $frame_0_new 'ma_crea_recto_' $userTemplate->getToken() . '.png';
  5230.                 $dossier_frame_0 str_replace('/uploads'$this->params->get('uploads_directory'), $frame_0);
  5231.                 $dossier_frame_0_new $this->params->get('uploads_directory') . '/tmp/' $frame_0_new;
  5232.                 if (trim($dossier_frame_0) == trim($dossier_frame_0_new)) {
  5233.                     $frame_0_new 'ma_crea_recto_' $userTemplate->getToken() . '_1.png';
  5234.                     $dossier_frame_0_new $this->params->get('uploads_directory') . '/tmp/' $frame_0_new;
  5235.                 }
  5236.                 copy($dossier_frame_0$dossier_frame_0_new);
  5237.                 $userTemplate->setRecto($frame_0_new);
  5238.                 if ($request->get('rectoverso')) {
  5239.                     $frame_1 $request->get('frame_1');
  5240.                     $frame_1_new 'ma_crea_verso_' $userTemplate->getToken() . '.png';
  5241.                     $dossier_frame_1 str_replace('/uploads'$this->params->get('uploads_directory'), $frame_1);
  5242.                     $dossier_frame_1_new $this->params->get('uploads_directory') . '/tmp/' $frame_1_new;
  5243.                     if (trim($dossier_frame_1) == trim($dossier_frame_1_new)) {
  5244.                         $frame_1_new 'ma_crea_verso_' $userTemplate->getToken() . '_1.png';
  5245.                         $dossier_frame_1_new $this->params->get('uploads_directory') . '/tmp/' $frame_1_new;
  5246.                     }
  5247.                     copy($dossier_frame_1$dossier_frame_1_new);
  5248.                     $userTemplate->setVerso($frame_1_new);
  5249.                     if ($request->get('frame_1')) {
  5250.                         $zip = new \ZipArchive();
  5251.                         $nameFichier 'ma_crea_' $userTemplate->getToken() . '.zip';
  5252.                         $zipfile $this->params->get('uploads_directory') . '/tmp/' $nameFichier;
  5253.                         if (file_exists($zipfile)) unlink($zipfile);
  5254.                         if ($zip->open($zipfile, \ZipArchive::CREATE) === TRUE) {
  5255.                             $zip->addFile($this->params->get('uploads_directory') . '/tmp/' $frame_0_new'recto.png');
  5256.                             $zip->addFile($this->params->get('uploads_directory') . '/tmp/' $frame_1_new'verso.png');
  5257.                             $zip->close();
  5258.                         }
  5259.                     }
  5260.                 } else {
  5261.                     $userTemplate->setVerso(null);
  5262.                     $nameFichier $frame_0_new;
  5263.                 }
  5264.                 $userTemplate->setIsCrea(true);
  5265.                 if ($request->get('plus_expert') == 1$userTemplate->setIsPlusExpert(true);
  5266.                 else $userTemplate->setIsPlusExpert(false);
  5267.                 $userTemplate->setPath($nameFichier);
  5268.                 $this->em->flush();
  5269.                 return 1;
  5270.             } else {
  5271.                 return 0;
  5272.             }
  5273.         }
  5274.     }
  5275.     public function addToCart($request,$user) : array
  5276.     {
  5277.         $userTemplate $this->getUserTemplate();
  5278.         $arrayRedirect = [];
  5279.         if($userTemplate){
  5280.             $cart $this->cart_service->getCartCurrent();
  5281.             if(!$cart){
  5282.                 $cart $this->cart_service->createCart(true);
  5283.             }
  5284.             if($userTemplate->getToken()){
  5285.                 $typeAbonnement $this->cart_service->getTypeAbonnementPro($user,$cart->getId()); // get type abonnement
  5286.                 $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
  5287.                 $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($userTemplate->getProductAttribute()->getId(), $userTemplate->getQuantite());
  5288.                 $cartDetail $this->em->getRepository(CartDetail::class)->findOneBy(array('cart'=>$cart->getId(),'token'=>$userTemplate->getToken()));
  5289.                 if(!$cartDetail){
  5290.                     $cartDetail = new CartDetail();
  5291.                 }
  5292.                 $cartDetail->setTypeProduct($userTemplate->getTypeProduct());
  5293.                 $cartDetail->setToken($userTemplate->getToken());
  5294.                 $cartDetail->setProductAttribute($userTemplate->getProductAttribute());
  5295.                 $cartDetail->setProduct($userTemplate->getProduct());
  5296.                 $cartDetail->setCart($cart);
  5297.                 $cartDetail->setFilePapier($userTemplate->getPath());
  5298.                 $cartDetail->setFilePapierFirstImage($userTemplate->getRecto());
  5299.                 if($userTemplate->getProduct()->getTypeProduct() == Product::CARTE){
  5300.                     $name 'carte-visite';
  5301.                     $arrayRedirect = ['carteVisite'=>1,'displayProduct'=>1];
  5302.                 }else if($userTemplate->getProduct()->getTypeProduct() == Product::FLYERS){
  5303.                     $name 'flyrs';
  5304.                     $arrayRedirect = ['flyer'=>1,'displayProduct'=>1];
  5305.                 }else if($userTemplate->getProduct()->getTypeProduct() == Product::AFFICHE){
  5306.                     $name 'affiche';
  5307.                     $arrayRedirect = ['showcarteFlyer'=>1,'displayProduct'=>1,'affiche'=>1];
  5308.                 }else if($userTemplate->getProduct()->getTypeProduct() == Product::MENU){
  5309.                     $name 'menu';
  5310.                     $arrayRedirect = ['menu'=>1,'displayProduct'=>1];
  5311.                 }else if($userTemplate->getProduct()->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
  5312.                     $name 'faire_naissance';
  5313.                     $arrayRedirect = ['faire_naissance'=>1,'displayProduct'=>1];
  5314.                 }else if($userTemplate->getProduct()->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
  5315.                     $name 'faire_mariage';
  5316.                     $arrayRedirect = ['faire_mariage'=>1,'displayProduct'=>1];
  5317.                 }else{
  5318.                     $name '';
  5319.                 }
  5320.                 $cartDetail->setFilePapierName($name.'-'.$userTemplate->getPath());
  5321.                 $cartDetail->setNbrPapier($userTemplate->getQuantite());
  5322.                 $cartDetail->setQty(0);
  5323.                 $cartDetail->setQtyColor(0);
  5324.                 $cartDetail->setQtyNoir(0);
  5325.                 $cartDetail->setProductName($userTemplate->getProduct()->getTitre());
  5326.                 $priceFinitonHt  0;
  5327.                 $priceFinitonTtc  0;
  5328.                 $priceFinitonHtWithoutReduction  0;
  5329.                 $priceFinitonTtcWithoutReduction  0;
  5330.                 $pourcentageFinition 0;
  5331.                 if($userTemplate->getFinition() == CartDetail::FINITION_GLACE){
  5332.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  5333.                 }else if($userTemplate->getFinition() == CartDetail::FINITION_MATE){
  5334.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  5335.                 }else if($userTemplate->getFinition() == CartDetail::FINITION_REPOSITIONALBLE){
  5336.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  5337.                 }else if($userTemplate->getFinition() == CartDetail::FINITION_TRANSPARENT){
  5338.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  5339.                 }else if($userTemplate->getFinition() == CartDetail::FINITION_SoftTouch){
  5340.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  5341.                 }else if($userTemplate->getFinition() == CartDetail::FINITION_Pelliculemat){
  5342.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  5343.                 }else if($userTemplate->getFinition() == CartDetail::FINITION_PelliculeBrillant){
  5344.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  5345.                 }
  5346.                 $priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* $pourcentageFinition;
  5347.                 $priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
  5348.                 $priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
  5349.                 $priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
  5350.                 if($userTemplate->getIsPlusExpert()&& $userTemplate->getIsCrea()){
  5351.                     $prixHt  $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHt;
  5352.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtc;
  5353.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHtWithoutReduction;
  5354.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtcWithoutReduction;
  5355.                 }else {
  5356.                     $prixHt  $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())+$priceFinitonHt;
  5357.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+$priceFinitonTtc;
  5358.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())+$priceFinitonHtWithoutReduction;
  5359.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+$priceFinitonTtcWithoutReduction;
  5360.                 }
  5361.                 if(($userTemplate->getProduct() and $userTemplate->getProduct()->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or  ($userTemplate->getProduct() and $userTemplate->getProduct()->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  5362.                     if($userTemplate->getIsEnveloppe()) {
  5363.                         $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $userTemplate->getQuantite());
  5364.                         $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $userTemplate->getQuantite());
  5365.                         $prixHtWithoutReduction $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT $userTemplate->getQuantite());
  5366.                         $prixTtcWithoutReduction $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC $userTemplate->getQuantite());
  5367.                     }
  5368.                 }
  5369.                 // update price by country
  5370.                 $prixHt $this->cart_service->updatePriceByCountry($prixHt,$userTemplate->getProduct());
  5371.                 $prixTtc $this->cart_service->updatePriceByCountry($prixTtc,$userTemplate->getProduct());
  5372.                 $prixHtWithoutReduction $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$userTemplate->getProduct());
  5373.                 $prixTtcWithoutReduction $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$userTemplate->getProduct());
  5374.                 $cartDetail->setPrixHt($prixHt);
  5375.                 $cartDetail->setPrixTtc($prixTtc);
  5376.                 $cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
  5377.                 $cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
  5378.                 $cartDetail->setIsEnveloppe($userTemplate->getIsEnveloppe());
  5379.                 $cartDetail->setIsMaCrea($userTemplate->getIsCrea());
  5380.                 $cartDetail->setIsPlusExpert($userTemplate->getIsPlusExpert());
  5381.                 $cartDetail->setFinition($userTemplate->getFinition());
  5382.                 $cartDetail->setIsTrait($userTemplate->getIsTrait());
  5383.                 $this->em->persist($cartDetail);
  5384.                 $this->em->flush();
  5385.                 $this->cart_service->removeCartDetailPapierPoste($cart,$cartDetail,true); //remove Papier Poste
  5386.                 $this->cart_service->updatePriceCart($cart);
  5387.             }
  5388.         }
  5389.         $this->session->remove('nbToken');
  5390.         return $arrayRedirect;
  5391.     }
  5392.     public function updateUserTemplateOptions($request) : void
  5393.     {
  5394.         $userTemplate $this->getUserTemplate();
  5395.         switch ($request->get('field')) {
  5396.             case 'quantite' :
  5397.                 $userTemplate->setQuantite($request->get('valeur'));
  5398.                 $this->em->flush();
  5399.                 break;
  5400.             case 'grammage' :
  5401.                 $userTemplate->setGrammage($request->get('valeur'));
  5402.                 $this->em->flush();
  5403.                 break;
  5404.             case 'papier' :
  5405.                 $userTemplate->setPapier($request->get('valeur'));
  5406.                 $this->em->flush();
  5407.                 break;
  5408.         }
  5409.     }
  5410.     public function updateUserTemplateGetPrice($request,$cart,$user=false)
  5411.     {
  5412.         $prixHt null;
  5413.         $prixTtc null;
  5414.         $prixHtWithoutReduction 0;
  5415.         $prixTtcWithoutReduction 0;
  5416.         $userTemplate =  $this->em->getRepository(NbUserTemplates::class)->findOneByToken($request->get('userTemplate'));
  5417.         $typeImpression $request->get('typeImpression');
  5418.         $plastification $request->get('plastification');
  5419.         $id_product $request->get('productId');
  5420.         $id_format $request->get('formatInput');
  5421.         $rectoverso $request->get('rectoversoInput');
  5422.         $grammage $request->get('grammage');
  5423.         $quantite $request->get('quantite');
  5424.         $finition $request->get('finition');
  5425.         $plus_expert $request->get('plus_expert');
  5426.         $isEnveloppe $request->get('isEnveloppe');
  5427.         $isCrea $request->get('isCrea');
  5428.         $isTrait $request->get('isTrait');
  5429.         $product $this->em->getRepository(Product::class)->find($id_product);
  5430.         // update plus expert
  5431.         if($request->get('plus_expert') == 1)$userTemplate->setIsPlusExpert(true);
  5432.         else $userTemplate->setIsPlusExpert(false);
  5433.         $this->em->flush();
  5434.         // update is enveloppe
  5435.         if(($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or  ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  5436.             if ($request->get('isEnveloppe') == 1$userTemplate->setIsEnveloppe(true);
  5437.             else $userTemplate->setIsEnveloppe(false);
  5438.             $this->em->flush();
  5439.         }
  5440.         // check abonnementPro
  5441.         $abonnement  $this->cart_service->checkAbonnementToCartOrOrder($user,$cart->getId());
  5442.         $typeAbonnement null;
  5443.         if($abonnement){
  5444.             $typeAbonnement $abonnement['type'];
  5445.         }
  5446.         $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement);
  5447.         if($product and $product->getTypeProduct() == Product::AFFICHE){
  5448.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$grammage,'typeImpression'=>$typeImpression,'plastification'=>$plastification,'isEnabled'=>true));
  5449.         }else{
  5450.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$grammage,'rectoverso'=>$rectoverso,'isEnabled'=>true));
  5451.         }
  5452.         if($productAttribute) {
  5453.             $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $quantite);
  5454.             if ($priceProductAttr) {
  5455.                 $priceFinitonHt  0;
  5456.                 $priceFinitonTtc  0;
  5457.                 $priceFinitonHtWithoutReduction  0;
  5458.                 $priceFinitonTtcWithoutReduction  0;
  5459.                 $pourcentageFinition 0;
  5460.                 if($finition == CartDetail::FINITION_GLACE){
  5461.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  5462.                 }else if($finition == CartDetail::FINITION_MATE){
  5463.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  5464.                 }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  5465.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  5466.                 }else if($finition == CartDetail::FINITION_TRANSPARENT){
  5467.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  5468.                 }else if($finition == CartDetail::FINITION_SoftTouch){
  5469.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  5470.                 }else if($finition == CartDetail::FINITION_Pelliculemat){
  5471.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  5472.                 }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  5473.                     $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  5474.                 }
  5475.                 $priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) )* $pourcentageFinition;
  5476.                 $priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
  5477.                 $priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
  5478.                 $priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
  5479. //                if($plus_expert && $isCrea){
  5480.                 if($plus_expert){
  5481.                     $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())  + CartDetail::PLUS_EXPERT_HT +$priceFinitonHt;
  5482.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() ) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtc;
  5483.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())  + CartDetail::PLUS_EXPERT_HT +$priceFinitonHtWithoutReduction;
  5484.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtcWithoutReduction;
  5485.                 }else{
  5486.                     $prixHt $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt;
  5487.                     $prixTtc $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()  + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+ $priceFinitonTtc;
  5488.                     $prixHtWithoutReduction $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction;
  5489.                     $prixTtcWithoutReduction $priceProductAttr->getPrixTtc()  + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+ $priceFinitonTtcWithoutReduction;
  5490.                 }
  5491.                 if(($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or  ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  5492.                     if($isEnveloppe) {
  5493.                         $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $quantite);
  5494.                         $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $quantite);
  5495.                         $prixHtWithoutReduction $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT $quantite);
  5496.                         $prixTtcWithoutReduction $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC $quantite);
  5497.                     }
  5498.                 }
  5499.                 //update price by country
  5500.                 $prixHt $this->cart_service->updatePriceByCountry($prixHt,$product);
  5501.                 $prixTtc $this->cart_service->updatePriceByCountry($prixTtc,$product);
  5502.                 $prixHtWithoutReduction $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
  5503.                 $prixTtcWithoutReduction $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
  5504.                 $userTemplate->setGrammage($grammage);
  5505.                 $userTemplate->setFormat($id_format);
  5506.                 $userTemplate->setProduct($product);
  5507.                 $userTemplate->setProductAttribute($productAttribute);
  5508.                 $userTemplate->setTypeProduct($product->getTypeProduct());
  5509.                 $userTemplate->setQuantite($quantite);
  5510.                 $userTemplate->setFinition($finition);
  5511.                 $userTemplate->setRectoverso($rectoverso);
  5512.                 $userTemplate->setIsPlusExpert($plus_expert);
  5513.                 $userTemplate->setIsCrea($isCrea);
  5514.                 $userTemplate->setIsTrait($isTrait);
  5515.                 $this->em->persist($userTemplate);
  5516.                 $this->em->flush();
  5517.             }
  5518.         }
  5519.         return $this->getPriceAfterPromoAndAbonnement$prixHt,$prixTtc,$prixHtWithoutReduction,$prixTtcWithoutReduction,$abonnement);
  5520.     }
  5521.     function getPriceAfterPromoAndAbonnement($prixHt,$prixTtc,$prixHtWithoutReduction,$prixTTcWithoutReduction,$abonnementPro,$carrierId null,$typeLivraisonNational=null,$typeLivraison30min null,$priceAbonnement false,$dataLocalisation =array(),$imprimeur=null){
  5522.         $isPromo false;
  5523.         $abonnementStarter $this->em->getRepository(Abonnement::class)->findOneBy(array());
  5524.         $is_abonnementStarter $this->abonnementService->checkAbonnementByUser($abonnementStarter->getPlanId());
  5525.         // price carrier && surcharge
  5526.         if ($carrierId) {
  5527.             $carrier $this->em->getRepository(Carrier::class)->find($carrierId);
  5528.             $carrierNationalJ1 $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J1));
  5529.             $carrierNationalJ2 $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J2));
  5530.             $carrier30MIN $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::STUART));
  5531.             if ($carrier == $carrier30MIN || $carrier == $carrierNationalJ1 || $carrier == $carrierNationalJ2) {
  5532.                 if ($carrier == $carrierNationalJ1) {
  5533.                     if ($typeLivraisonNational == Cart::LIVRAISON_STANDARD_P) {
  5534.                         $priceExtraHT Cart::PRICE_LIVRAISON_STANDARD_P_HT;
  5535.                         $priceExtraTTC Cart::PRICE_LIVRAISON_STANDARD_P_TTC;
  5536.                     } else if ($typeLivraisonNational == Cart::LIVRAISON_EXPRESS_P) {
  5537.                         $priceExtraHT Cart::PRICE_LIVRAISON_EXPRESS_P_HT;
  5538.                         $priceExtraTTC Cart::PRICE_LIVRAISON_EXPRESS_P_TTC;
  5539.                     } else if ($typeLivraisonNational == Cart::LIVRAISON_EXPRESS_D) {
  5540.                         $priceExtraHT Cart::PRICE_LIVRAISON_EXPRESS_D_HT;
  5541.                         $priceExtraTTC Cart::PRICE_LIVRAISON_EXPRESS_D_TTC;
  5542.                     }
  5543.                     if ($prixTtc 12) {
  5544.                         $priceCarrierHT $priceExtraHT;
  5545.                         $priceCarrierTTC $priceExtraTTC;
  5546.                         $priceSurchargeHT Cart::SURCHARGE_HT;
  5547.                         $priceSurchargeTTC Cart::SURCHARGE_TTC;
  5548.                     } else if ($prixTtc 12 && $prixTtc 29) {
  5549.                         $priceCarrierHT $priceExtraHT;
  5550.                         $priceCarrierTTC $priceExtraTTC;
  5551.                         $priceSurchargeHT 0;
  5552.                         $priceSurchargeTTC 0;
  5553.                     } else {
  5554.                         $priceCarrierHT $priceCarrierTTC $priceSurchargeHT $priceSurchargeTTC 0;
  5555.                     }
  5556.                 } else {
  5557.                     $typeLivraison30min $this->cart_service->getTypeLivraison30min($imprimeur,$dataLocalisation);
  5558.                     $tabPriceLivraison30Min $this->cart_service->getPriceLivraison30MinByType($typeLivraison30min);
  5559.                     if ($prixTtc 12) {
  5560.                         $priceCarrierHT = isset($tabPriceLivraison30Min['priceHT']) ? $tabPriceLivraison30Min['priceHT'] : $carrier->getPrixHt();
  5561.                         $priceCarrierTTC = isset($tabPriceLivraison30Min['priceTTC']) ? $tabPriceLivraison30Min['priceTTC'] : $carrier->getPrixTtc();
  5562.                         $priceSurchargeHT Cart::SURCHARGE_HT;
  5563.                         $priceSurchargeTTC Cart::SURCHARGE_TTC;
  5564.                     } else if ($prixTtc 12 && $prixTtc 29) {
  5565.                         $priceCarrierHT = isset($tabPriceLivraison30Min['priceHT']) ? $tabPriceLivraison30Min['priceHT'] : $carrier->getPrixHt();
  5566.                         $priceCarrierTTC = isset($tabPriceLivraison30Min['priceTTC']) ? $tabPriceLivraison30Min['priceTTC'] : $carrier->getPrixTtc();
  5567.                         $priceSurchargeHT 0;
  5568.                         $priceSurchargeTTC 0;
  5569.                     } else {
  5570.                         $priceCarrierHT $priceCarrierTTC $priceSurchargeHT $priceSurchargeTTC 0;
  5571.                     }
  5572.                 }
  5573.             } else {
  5574.                 $priceCarrierHT $priceCarrierTTC $priceSurchargeHT $priceSurchargeTTC 0;
  5575.             }
  5576.         }
  5577.         else {
  5578.             $priceCarrierHT $priceCarrierTTC $priceSurchargeHT $priceSurchargeTTC 0;
  5579.         }
  5580.         if($abonnementPro){
  5581.             $priceCarrierHT $priceCarrierTTC $priceSurchargeHT $priceSurchargeTTC 0;
  5582.             $tokenCart $this->session->get('token_cart');
  5583.             $cart null;
  5584.             if ($tokenCart) {
  5585.                 $cart $this->em->getRepository(Cart::class)->findOneBy(array('token' => $tokenCart)); // cart
  5586.                 if($cart){
  5587.                     if ($cart->getIsPromo()) {
  5588.                         $promo $cart->getCodePromo();
  5589.                         $reduction $promo->getReduction();
  5590.                         if ($promo->getType() == CodePromo::EN_POURCENTAGE) {
  5591.                             if ($reduction <= 100) {
  5592.                                 $prixHt $prixHt - (($prixHt $reduction) / 100);
  5593.                                 $prixTtc $prixTtc- (($prixTtc $reduction) / 100);
  5594.                                 $isPromo true;
  5595.                             }
  5596.                         }
  5597.                     }
  5598.                 }
  5599.             }
  5600.         }else{
  5601.             if($is_abonnementStarter){
  5602.                 $reduction $abonnementStarter->getReduction();
  5603.                 if ($reduction 0) {
  5604.                     $priceCarrierHT $priceCarrierTTC 0;
  5605.                     $prixHt $prixHt +  $priceCarrierHT $priceSurchargeHT;
  5606.                     $prixTtc $prixTtc +  $priceCarrierTTC $priceSurchargeTTC;
  5607.                     $prixHtWithoutReduction $prixHtWithoutReduction +  $priceCarrierHT $priceSurchargeHT;
  5608.                     $prixTTcWithoutReduction $prixTTcWithoutReduction +  $priceCarrierTTC $priceSurchargeTTC;
  5609.                     $prixHt $prixHt - (($prixHt $reduction) / 100);
  5610.                     $prixTtc $prixTtc- (($prixTtc $reduction) / 100);
  5611.                 }
  5612.             }else {
  5613.                 $tokenCart $this->session->get('token_cart');
  5614.                 $cart null;
  5615.                 if ($tokenCart) {
  5616.                     $cart $this->em->getRepository(Cart::class)->findOneBy(array('token' => $tokenCart)); // cart
  5617.                     if($cart){
  5618.                         if ($cart->getIsPromo()) {
  5619.                             $promo $cart->getCodePromo();
  5620.                             $reduction $promo->getReduction();
  5621.                             if ($promo->getFreelivred()) {
  5622.                                 $priceCarrierHT $priceCarrierTTC $priceSurchargeHT $priceSurchargeTTC 0;
  5623.                             }
  5624.                             $prixHt $prixHt +  $priceCarrierHT $priceSurchargeHT;
  5625.                             $prixTtc $prixTtc +  $priceCarrierTTC $priceSurchargeTTC;
  5626.                             $prixHtWithoutReduction $prixHtWithoutReduction +  $priceCarrierHT $priceSurchargeHT;
  5627.                             $prixTTcWithoutReduction $prixTTcWithoutReduction +  $priceCarrierTTC $priceSurchargeTTC;
  5628.                             if ($promo->getType() == CodePromo::EN_POURCENTAGE) {
  5629.                                 if ($reduction <= 100) {
  5630.                                     $prixHt $prixHt - (($prixHt $reduction) / 100);
  5631.                                     $prixTtc $prixTtc- (($prixTtc $reduction) / 100);
  5632.                                     $isPromo true;
  5633.                                 }
  5634.                             }
  5635.                         }else{
  5636.                             $prixHt $prixHt +  $priceCarrierHT $priceSurchargeHT;
  5637.                             $prixTtc $prixTtc +  $priceCarrierTTC $priceSurchargeTTC;
  5638.                             $prixHtWithoutReduction $prixHtWithoutReduction +  $priceCarrierHT $priceSurchargeHT;
  5639.                             $prixTTcWithoutReduction $prixTTcWithoutReduction +  $priceCarrierTTC $priceSurchargeTTC;
  5640.                         }
  5641.                     }
  5642.                 }
  5643.             }
  5644.         }
  5645.         return [
  5646.             'prixHt' => $prixHt,
  5647.             'prixTtc' => $prixTtc,
  5648.             'is_abonnement'=>$is_abonnementStarter,
  5649.             'isPromo'=>$isPromo,
  5650.             'prixHtWithoutReduction' => $prixHtWithoutReduction,
  5651.             'prixTTcWithoutReduction' => $prixTTcWithoutReduction,
  5652.             'abonnementPro' => $abonnementPro,
  5653.             'priceCarrierHT' => (float)$priceCarrierHT + (float)$priceSurchargeHT,
  5654.             'priceCarrierTTC' => (float)$priceCarrierTTC + (float)$priceSurchargeTTC,
  5655.             'priceSurchargeHT' => (float)$priceSurchargeHT,
  5656.             'priceSurchargeTTC' => (float)$priceSurchargeTTC,
  5657.             'priceAbonnement' => $priceAbonnement
  5658.         ];
  5659.     }
  5660.     public function getListFonttyle()
  5661.     {
  5662.         $listFont$this->em->getRepository(NbTemplates::class)->findAll();
  5663.         $array = array();
  5664.         foreach ($listFont as $item){
  5665.             if($item->getFonts()){
  5666.                 foreach ($item->getFonts() as $font){
  5667.                     $array[$font['name']]['name'] = $font['name'];
  5668.                     $array[$font['name']]['alias'] = $font['alias'];
  5669.                 }
  5670.             }
  5671.         }
  5672.         $listFontText $this->em->getRepository(NbTextes::class)->findAll();
  5673.         foreach ($listFontText as $item){
  5674.             foreach ($item->getContent()['font'] as $font) {
  5675.                     $array[$font['name']]['name'] = $font['name'];
  5676.                     $array[$font['name']]['alias'] = $font['alias'];
  5677.             }
  5678.         }
  5679.         return $array;
  5680.     }
  5681.     public function getTemplateAjax($request)
  5682.     {
  5683.         $data $request->query->all();
  5684.         $is_scroll = isset($data['is_scroll']) ? $data['is_scroll'] : null;
  5685.         $format_id = isset($data['format']) ? $data['format'] : 2;
  5686.         $search= (isset($data['searchTag']) and !empty($data['searchTag'])) ? $data['searchTag'] :null;
  5687.         $offset = isset($data['offset']) ? $data['offset'] : 0;
  5688.         $isPaysage = (isset($data['isPaysage']) && $data['isPaysage'] == 1) ? 0;
  5689.         $templates $this->em->getRepository(NbTemplates::class)->getTemplates($format_id,'ASC',16,$offset,$search,$isPaysage);
  5690.         $is_search_empty false;
  5691.         if(!$is_scroll) {
  5692.             if ($search && count($templates) == 0) {
  5693.                 $templates $this->em->getRepository(NbTemplates::class)->getTemplates($format_id'ASC'16$offset,null,$isPaysage);
  5694.                 $is_search_empty true;
  5695.             }
  5696.         }
  5697.         return array(
  5698.             'templates' => $templates,
  5699.             'is_search_empty' => $is_search_empty,
  5700.         );
  5701.     }
  5702.     public function getQtyFlyerCarte($request)
  5703.     {
  5704.         $qtyExiste false;
  5705.         $prixQty false;
  5706.         $typeImpression$request->get('typeImpression');
  5707.         $plastification$request->get('plastification');
  5708.         $id_format$request->get('id_format');
  5709.         $id_product=  $request->get('id_product');
  5710.         $id_gramage$request->get('id_gramage');
  5711.         $rectoverso$request->get('rectoverso');
  5712.         $finition$request->get('finition');
  5713.         $quantite$request->get('quantite');
  5714.         $product $this->em->getRepository(Product::class)->find($id_product);
  5715.         if($product and $product->getTypeProduct() == Product::AFFICHE){
  5716.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_gramage,'typeImpression'=>$typeImpression,'plastification'=>$plastification,'isEnabled'=>true));
  5717.         }else{
  5718.             $productAttribute $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_gramage,'rectoverso'=>$rectoverso,'isEnabled'=>true));
  5719.         }
  5720.         $qtys false;
  5721.         if($productAttribute) {
  5722.             $data $this->getQtyFlyerCarteByProductAttribute($productAttribute->getId(),$finition,$quantite);
  5723.             $qtys $data['qtys'];
  5724.             $qtyExiste $data['qtyExiste'];
  5725.             $prixQty $data['prixQty'];
  5726.         }
  5727.         if($qtys){
  5728.             if($qtyExiste){
  5729.                 $quantite $quantite;
  5730.                 $prixQty $prixQty;
  5731.             }else{
  5732.                 $quantite $qtys[0]['qty'];
  5733.                 $prixQty $qtys[0]['prixTtc'];
  5734.             }
  5735.             return ['qtys' => $qtys,'quantiteFirst'=>$quantite,'prixQtyFirst'=>$prixQty];
  5736.         }else{
  5737.             return array();
  5738.         }
  5739.     }
  5740.     public function getGrammageAffichage($request)
  5741.     {
  5742.         $typeImpression$request->get('typeImpression');
  5743.         $id_product=  $request->get('id_product');
  5744.         $id_format$request->get('id_format');
  5745.         $grammages $this->getGrammageByTypeImpression($id_product,$id_format,$typeImpression);
  5746.         return ['gramages' =>$grammages];
  5747.     }
  5748.     public function getQtyFlyerCarteByProductAttribute($id,$finition,$quantite=false,$isEnveloppe=false,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
  5749.         $user $this->security->getUser();
  5750.         $cart $this->cart_service->createCart(true);
  5751.         $typeAbonnement $this->cart_service->getTypeAbonnementPro($user,$cart->getId()); // get type abonnement
  5752.         $qtys $this->em->getRepository(PriceProduct::class)->getQuantity($id);
  5753.         $qtyExiste false;
  5754.         $prixQty false;
  5755.         $prixQtyHt false;
  5756.         $priceFinitonTtc ;
  5757.         $priceFinitonHt ;
  5758.         foreach ($qtys as &$item){
  5759.             $priceProductAttr $this->em->getRepository(PriceProduct::class)->find($item['id']);
  5760.             $keyArrayPrice $this->getKeyArrayPrice($typeAbonnement,$priceProductAttr); // get key for prix
  5761.             $pourcentageFinition 0;
  5762.             if($finition == CartDetail::FINITION_GLACE){
  5763.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  5764.             }else if($finition == CartDetail::FINITION_MATE){
  5765.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  5766.             }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  5767.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  5768.             }else if($finition == CartDetail::FINITION_TRANSPARENT){
  5769.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  5770.             }else if($finition == CartDetail::FINITION_SoftTouch){
  5771.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  5772.             }else if($finition == CartDetail::FINITION_Pelliculemat){
  5773.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  5774.             }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  5775.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  5776.             }
  5777.             $priceFinitonTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* $pourcentageFinition;
  5778.             $priceFinitonHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* $pourcentageFinition;
  5779.             $priceFinitonTtcWithoutPromo = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* $pourcentageFinition;
  5780.             $priceFinitonHtWithoutPromo  = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* $pourcentageFinition;
  5781.             $priceBordsArrondisHt  0;
  5782.             $priceBordsArrondisTtc  0;
  5783.             $priceBordsArrondisHtWithoutPromo  0;
  5784.             $priceBordsArrondisTtcWithoutPromo  0;
  5785.             if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
  5786.                 $priceBordsArrondisHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  5787.                 $priceBordsArrondisTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  5788.                 $priceBordsArrondisHtWithoutPromo  = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  5789.                 $priceBordsArrondisTtcWithoutPromo  = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  5790.             }
  5791.             $pricePlastificationHt  0;
  5792.             $pricePlastificationTtc  0;
  5793.             $pricePlastificationHtWithoutPromo  0;
  5794.             $pricePlastificationTtcWithoutPromo  0;
  5795.             if($plastification == CartDetail::BORDS_ARRONDIS_CHECKED){
  5796.                 $pricePlastificationHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* CartDetail::POURCENTAGE_PLASTIFICATION;
  5797.                 $pricePlastificationTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* CartDetail::POURCENTAGE_PLASTIFICATION;
  5798.                 $pricePlastificationHtWithoutPromo  = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* CartDetail::POURCENTAGE_PLASTIFICATION;
  5799.                 $pricePlastificationTtcWithoutPromo  = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* CartDetail::POURCENTAGE_PLASTIFICATION;
  5800.             }
  5801.             $prixTtc $item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']])+$priceFinitonTtc+$priceBordsArrondisTtc +$pricePlastificationTtc;
  5802.             $prixHt $item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']])+$priceFinitonHt+$priceBordsArrondisHt +$pricePlastificationHt;
  5803.             $prixTtcWithoutPromo  $item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']])+$priceFinitonTtcWithoutPromo +$priceBordsArrondisTtcWithoutPromo  +$pricePlastificationTtcWithoutPromo;
  5804.             $prixHtWithoutPromo  $item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt'])+$priceFinitonHtWithoutPromo +$priceBordsArrondisHtWithoutPromo  +$pricePlastificationHtWithoutPromo;
  5805.             if(($priceProductAttr->getProductAttribute()->getProduct() and $priceProductAttr->getProductAttribute()->getProduct()->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or  ($priceProductAttr->getProductAttribute()->getProduct() and $priceProductAttr->getProductAttribute()->getProduct()->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  5806.                 if($isEnveloppe) {
  5807.                     $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $priceProductAttr->getQty());
  5808.                     $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $priceProductAttr->getQty());
  5809.                     $prixTtcWithoutPromo $prixTtcWithoutPromo + (CartDetail::IS_ENVELOPPE_TTC $priceProductAttr->getQty());
  5810.                     $prixHtWithoutPromo $prixHtWithoutPromo + (CartDetail::IS_ENVELOPPE_HT $priceProductAttr->getQty());
  5811.                 }
  5812.             }
  5813.             //update price by country
  5814.             $prixHt $this->cart_service->updatePriceByCountry($prixHt,$priceProductAttr->getProductAttribute()->getProduct());
  5815.             $prixTtc $this->cart_service->updatePriceByCountry($prixTtc,$priceProductAttr->getProductAttribute()->getProduct());
  5816.             $prixHtWithoutPromo $this->cart_service->updatePriceByCountry($prixHtWithoutPromo,$priceProductAttr->getProductAttribute()->getProduct());
  5817.             $prixTtcWithoutPromo $this->cart_service->updatePriceByCountry($prixTtcWithoutPromo,$priceProductAttr->getProductAttribute()->getProduct());
  5818.             $item['prixTtc'] = $prixTtc;
  5819.             $item['prixHt'] = $prixHt;
  5820.             $item['prixTtcWithoutPromo'] = $prixTtcWithoutPromo;
  5821.             $item['prixHtWithoutPromo'] = $prixHtWithoutPromo;
  5822.             $item['isPromoDetail'] = $keyArrayPrice['isPromoDetail'];
  5823.             $prixQtyWithoutPromo 0;
  5824.             $prixQtyHtWithoutPromo0;
  5825.             if($quantite){
  5826.                 if($item['qty'] == $quantite){
  5827.                     $qtyExiste true;
  5828.                     $prixQty $item['prixTtc'];
  5829.                     $prixQtyHt $item['prixHt'];
  5830.                     $prixQtyWithoutPromo $item['prixTtcWithoutPromo'];
  5831.                     $prixQtyHtWithoutPromo $item['prixHtWithoutPromo'];
  5832.                 }
  5833.             }
  5834.         }
  5835.         return ['qtys'=>$qtys,'qtyExiste'=>$qtyExiste,'prixQty'=>$prixQty,'prixQtyHt'=>$prixQtyHt,'prixQtyWithoutPromo'=>$prixQtyWithoutPromo,'prixQtyHtWithoutPromo'=>$prixQtyHtWithoutPromo];
  5836.     }
  5837.     public function getQtyFlyerCarteByProductAttributeByAbonnement($typeAbonnement,$id,$finition,$quantite=false,$isEnveloppe=false,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
  5838.         $qtys $this->em->getRepository(PriceProduct::class)->getQuantity($id);
  5839.         $qtyExiste false;
  5840.         $prixQty false;
  5841.         $prixQtyHt false;
  5842.         foreach ($qtys as &$item){
  5843.             $priceProductAttr $this->em->getRepository(PriceProduct::class)->find($item['id']);
  5844.             $keyArrayPrice $this->getKeyArrayPrice($typeAbonnement,$priceProductAttr); // get key for prix
  5845.             $pourcentageFinition 0;
  5846.             if($finition == CartDetail::FINITION_GLACE){
  5847.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_GLACE;
  5848.             }else if($finition == CartDetail::FINITION_MATE){
  5849.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_MATE;
  5850.             }else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
  5851.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
  5852.             }else if($finition == CartDetail::FINITION_TRANSPARENT){
  5853.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
  5854.             }else if($finition == CartDetail::FINITION_SoftTouch){
  5855.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_SoftTouch;
  5856.             }else if($finition == CartDetail::FINITION_Pelliculemat){
  5857.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_Pelliculemat;
  5858.             }else if($finition == CartDetail::FINITION_PelliculeBrillant){
  5859.                 $pourcentageFinition =  CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
  5860.             }
  5861.             $priceFinitonTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* $pourcentageFinition;
  5862.             $priceFinitonHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* $pourcentageFinition;
  5863.             $priceFinitonTtcWithoutPromo = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* $pourcentageFinition;
  5864.             $priceFinitonHtWithoutPromo  = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* $pourcentageFinition;
  5865.             $priceBordsArrondisHt  0;
  5866.             $priceBordsArrondisTtc  0;
  5867.             $priceBordsArrondisHtWithoutPromo  0;
  5868.             $priceBordsArrondisTtcWithoutPromo  0;
  5869.             if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
  5870.                 $priceBordsArrondisHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  5871.                 $priceBordsArrondisTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  5872.                 $priceBordsArrondisHtWithoutPromo  = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  5873.                 $priceBordsArrondisTtcWithoutPromo  = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
  5874.             }
  5875.             $pricePlastificationHt  0;
  5876.             $pricePlastificationTtc  0;
  5877.             $pricePlastificationHtWithoutPromo  0;
  5878.             $pricePlastificationTtcWithoutPromo  0;
  5879.             if($plastification == CartDetail::BORDS_ARRONDIS_CHECKED){
  5880.                 $pricePlastificationHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* CartDetail::POURCENTAGE_PLASTIFICATION;
  5881.                 $pricePlastificationTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* CartDetail::POURCENTAGE_PLASTIFICATION;
  5882.                 $pricePlastificationHtWithoutPromo  = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* CartDetail::POURCENTAGE_PLASTIFICATION;
  5883.                 $pricePlastificationTtcWithoutPromo  = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* CartDetail::POURCENTAGE_PLASTIFICATION;
  5884.             }
  5885.             $prixTtc $item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']])+$priceFinitonTtc+$priceBordsArrondisTtc +$pricePlastificationTtc;
  5886.             $prixHt $item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']])+$priceFinitonHt+$priceBordsArrondisHt +$pricePlastificationHt;
  5887.             $prixTtcWithoutPromo  $item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']])+$priceFinitonTtcWithoutPromo +$priceBordsArrondisTtcWithoutPromo  +$pricePlastificationTtcWithoutPromo;
  5888.             $prixHtWithoutPromo  $item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt'])+$priceFinitonHtWithoutPromo +$priceBordsArrondisHtWithoutPromo  +$pricePlastificationHtWithoutPromo;
  5889.             if(($priceProductAttr->getProductAttribute()->getProduct() and $priceProductAttr->getProductAttribute()->getProduct()->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or  ($priceProductAttr->getProductAttribute()->getProduct() and $priceProductAttr->getProductAttribute()->getProduct()->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
  5890.                 if($isEnveloppe) {
  5891.                     $prixTtc $prixTtc + (CartDetail::IS_ENVELOPPE_TTC $priceProductAttr->getQty());
  5892.                     $prixHt $prixHt + (CartDetail::IS_ENVELOPPE_HT $priceProductAttr->getQty());
  5893.                     $prixTtcWithoutPromo $prixTtcWithoutPromo + (CartDetail::IS_ENVELOPPE_TTC $priceProductAttr->getQty());
  5894.                     $prixHtWithoutPromo $prixHtWithoutPromo + (CartDetail::IS_ENVELOPPE_HT $priceProductAttr->getQty());
  5895.                 }
  5896.             }
  5897.             //update price by country
  5898.             $prixHt $this->cart_service->updatePriceByCountry($prixHt,$priceProductAttr->getProductAttribute()->getProduct());
  5899.             $prixTtc $this->cart_service->updatePriceByCountry($prixTtc,$priceProductAttr->getProductAttribute()->getProduct());
  5900.             $prixHtWithoutPromo $this->cart_service->updatePriceByCountry($prixHtWithoutPromo,$priceProductAttr->getProductAttribute()->getProduct());
  5901.             $prixTtcWithoutPromo $this->cart_service->updatePriceByCountry($prixTtcWithoutPromo,$priceProductAttr->getProductAttribute()->getProduct());
  5902.             $item['prixTtc'] = $prixTtc;
  5903.             $item['prixHt'] = $prixHt;
  5904.             $item['prixTtcWithoutPromo'] = $prixTtcWithoutPromo;
  5905.             $item['prixHtWithoutPromo'] = $prixHtWithoutPromo;
  5906.             $item['isPromoDetail'] = $keyArrayPrice['isPromoDetail'];
  5907.             $prixQtyWithoutPromo 0;
  5908.             $prixQtyHtWithoutPromo0;
  5909.             if($quantite){
  5910.                 if($item['qty'] == $quantite){
  5911.                     $qtyExiste true;
  5912.                     $prixQty $item['prixTtc'];
  5913.                     $prixQtyHt $item['prixHt'];
  5914.                     $prixQtyWithoutPromo $item['prixTtcWithoutPromo'];
  5915.                     $prixQtyHtWithoutPromo $item['prixHtWithoutPromo'];
  5916.                 }
  5917.             }
  5918.         }
  5919.         return ['qtys'=>$qtys,'qtyExiste'=>$qtyExiste,'prixQty'=>$prixQty,'prixQtyHt'=>$prixQtyHt,'prixQtyWithoutPromo'=>$prixQtyWithoutPromo,'prixQtyHtWithoutPromo'=>$prixQtyHtWithoutPromo];
  5920.     }
  5921.     public function getKeyArrayPrice($type null,$priceAttributeProduct false) {
  5922.         if(is_object($priceAttributeProduct)){
  5923.             if($priceAttributeProduct->getIsPromo()){
  5924.                 if($type == AbonnementPro::TYPE_PRO){
  5925.                     if($priceAttributeProduct->getPrixPromoTtcAbonnementPro() && $priceAttributeProduct->getPrixPromoTtcAbonnementPro() > ){
  5926.                         $stringTtc 'prixPromoTtcAbonnementPro';
  5927.                         $stringHt 'prixPromoHtAbonnementPro';
  5928.                         $isPromoDetail true;
  5929.                     }else{
  5930.                         $stringTtc 'prixTtcAbonnementPro';
  5931.                         $stringHt 'prixHtAbonnementPro';
  5932.                         $isPromoDetail false;
  5933.                     }
  5934.                 }else if($type == AbonnementPro::TYPE_TEAM){
  5935.                     if($priceAttributeProduct->getPrixPromoTtcAbonnementTeam() && $priceAttributeProduct->getPrixPromoTtcAbonnementTeam() > ){
  5936.                         $stringTtc 'prixPromoTtcAbonnementTeam';
  5937.                         $stringHt 'prixPromoHtAbonnementTeam';
  5938.                         $isPromoDetail true;
  5939.                     }else{
  5940.                         $stringTtc 'prixTtcAbonnementTeam';
  5941.                         $stringHt 'prixHtAbonnementTeam';
  5942.                         $isPromoDetail false;
  5943.                     }
  5944.                 }else if($type == AbonnementPro::TYPE_ENTREPRISE){
  5945.                     if($priceAttributeProduct->getPrixPromoTtcAbonnementEntreprise() && $priceAttributeProduct->getPrixPromoTtcAbonnementEntreprise() > ){
  5946.                         $stringTtc 'prixPromoTtcAbonnementEntreprise';
  5947.                         $stringHt 'prixPromoHtAbonnementEntreprise';
  5948.                         $isPromoDetail true;
  5949.                     }else{
  5950.                         $stringTtc 'prixTtcAbonnementEntreprise';
  5951.                         $stringHt 'prixHtAbonnementEntreprise';
  5952.                         $isPromoDetail false;
  5953.                     }
  5954.                 }else{
  5955.                     if($priceAttributeProduct->getPrixPromoTtc() && $priceAttributeProduct->getPrixPromoTtc() > ) {
  5956.                         $stringTtc 'prixPromoTtc';
  5957.                         $stringHt 'prixPromoHt';
  5958.                         $isPromoDetail true;
  5959.                     }else{
  5960.                         $stringTtc 'prixTtc';
  5961.                         $stringHt 'prixHt';
  5962.                         $isPromoDetail false;
  5963.                     }
  5964.                 }
  5965.                 return array(
  5966.                     'prixTtc'=> $stringTtc,
  5967.                     'prixHt'=> $stringHt,
  5968.                     'isPromoDetail'=> $isPromoDetail
  5969.                 );
  5970.             }
  5971.         }
  5972.         if($type == AbonnementPro::TYPE_PRO){
  5973.             $stringTtc 'prixTtcAbonnementPro';
  5974.             $stringHt 'prixHtAbonnementPro';
  5975.         }else if($type == AbonnementPro::TYPE_TEAM){
  5976.             $stringTtc 'prixTtcAbonnementTeam';
  5977.             $stringHt 'prixHtAbonnementTeam';
  5978.         }else if($type == AbonnementPro::TYPE_ENTREPRISE){
  5979.             $stringTtc 'prixTtcAbonnementEntreprise';
  5980.             $stringHt 'prixHtAbonnementEntreprise';
  5981.         }else{
  5982.             $stringTtc 'prixTtc';
  5983.             $stringHt 'prixHt';
  5984.         }
  5985.         return array(
  5986.             'prixTtc'=> $stringTtc,
  5987.             'prixHt'=> $stringHt,
  5988.             'isPromoDetail'=> false
  5989.         );
  5990.     }
  5991.     public function saveTemplateAbonnement($request,$user)
  5992.     {
  5993.         $isAbonnementPro false;
  5994.         if(is_object($user)){
  5995.             $abonnement $this->cart_service->checkIsAbonnementPro($user);
  5996.             // check abonnement in cart
  5997.             $cart $this->cart_service->getCartWithSession();
  5998.             $isAbonnementProInCart false;
  5999.             if($cart){
  6000.                 $isAbonnementProInCart $this->cart_service->checkIsAbonnementProCart($cart->getId());
  6001.             }
  6002.             if($abonnement['is_abonnemen_pro'] || $isAbonnementProInCart) { // check is admin in compte abonnement
  6003.                 $isAbonnementPro =  true;
  6004.             }
  6005.         }
  6006.         if($isAbonnementPro){
  6007.             $userTemplate $this->em->getRepository(NbUserTemplates::class)->findOneBy(array('token'=>$request->get('user_template')));
  6008.             if($request->get('isCrea') && $request->get('isCrea') == 1){
  6009.                 if($request->get('frame_0')) {
  6010.                     $frame_0 $request->get('frame_0');
  6011.                     $frame_0_new 'ma_crea_recto_'$userTemplate->getToken() .'.png';
  6012.                     $dossier_frame_0 str_replace ('/uploads',$this->params->get('uploads_directory'),$frame_0);
  6013.                     $dossier_frame_0_new $this->params->get('uploads_directory'). '/img_template_save/' $frame_0_new;
  6014.                     if(file_exists($dossier_frame_0_new) )unlink($dossier_frame_0_new);
  6015.                     if(trim($dossier_frame_0) == trim($dossier_frame_0_new)){
  6016.                         $frame_0_new 'ma_crea_recto_'$userTemplate->getToken() .'_1.png';
  6017.                         $dossier_frame_0_new $this->params->get('uploads_directory'). '/img_template_save/' $frame_0_new;
  6018.                     }
  6019.                     copy($dossier_frame_0 $dossier_frame_0_new);
  6020.                     $userTemplate->setRecto($frame_0_new);
  6021.                     if ($request->get('rectoverso')) {
  6022.                         $frame_1 $request->get('frame_1');
  6023.                         $frame_1_new 'ma_crea_verso_'.$userTemplate->getToken() .'.png';
  6024.                         $dossier_frame_1 str_replace ('/uploads',$this->params->get('uploads_directory'),$frame_1);
  6025.                         $dossier_frame_1_new $this->params->get('uploads_directory'). '/img_template_save/' $frame_1_new;
  6026.                         if(file_exists($dossier_frame_1_new) )unlink($dossier_frame_1_new);
  6027.                         if(trim($dossier_frame_1) == trim($dossier_frame_1_new)){
  6028.                             $frame_1_new 'ma_crea_verso_'$userTemplate->getToken() .'_1.png';
  6029.                             $dossier_frame_1_new $this->params->get('uploads_directory'). '/img_template_save/' $frame_1_new;
  6030.                         }
  6031.                         copy($dossier_frame_1 $dossier_frame_1_new);
  6032.                         $userTemplate->setVerso($frame_1_new);
  6033.                     }else{
  6034.                         $userTemplate->setVerso(null);
  6035.                     }
  6036.                     $userTemplate->setIsCrea(true);
  6037.                     if($request->get('plus_expert') == 1)$userTemplate->setIsPlusExpert(true);
  6038.                     else $userTemplate->setIsPlusExpert(false);
  6039.                     $userTemplate->setRectoverso($request->get('rectoverso') == 1);
  6040.                     $userTemplate->setUserAbonnement($user);
  6041.                     $this->em->flush();
  6042.                     return [
  6043.                         'myTemplates' => $this->cart_service->getListeTemplateSaved($this->security->getUser()),
  6044.                         'myDesign' => $this->em->getRepository(NbUserTemplates::class)->getTemplateNotEmpty($this->security->getUser())
  6045.                     ];
  6046.                 }else{
  6047.                     return 0;
  6048.                 }
  6049.             }else{
  6050.                 $ext '.png';
  6051.                 $frame_0 uniqid().$ext;
  6052.                 $base64 str_replace('data:image/png;base64,'''$request->get('frame_0'));
  6053.                 $file fopen($this->params->get('uploads_directory').'/img_template_save/'.$frame_0'wb');
  6054.                 fwrite($filebase64_decode($base64));
  6055.                 fclose($file);
  6056.                 $userTemplate->setRecto($frame_0);
  6057.                 $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  6058.                 $frames[] = $baseurl "/uploads/tmp/" $frame_0;
  6059.                 if($request->get('rectoverso')) {
  6060.                     $frame_1 uniqid().$ext;
  6061.                     $base64 str_replace('data:image/png;base64,'''$request->get('frame_1'));
  6062.                     $file fopen($this->params->get('uploads_directory').'/img_template_save/'.$frame_1'wb');
  6063.                     fwrite($filebase64_decode($base64));
  6064.                     fclose($file);
  6065.                     $userTemplate->setVerso($frame_1);
  6066.                     $frames[] = $baseurl "/uploads/tmp/" $frame_1;
  6067.                 }
  6068.                 $userTemplate->setRectoverso($request->get('rectoverso') == 1);
  6069.                 $userTemplate->setUserAbonnement($user);
  6070.                 $this->em->flush();
  6071.                 return [
  6072.                     'myTemplates' => $this->cart_service->getListeTemplateSaved($this->security->getUser()),
  6073.                     'myDesign' => $this->em->getRepository(NbUserTemplates::class)->getTemplateNotEmpty($this->security->getUser())
  6074.                 ];
  6075.             }
  6076.         }else{
  6077.             return 0;
  6078.         }
  6079.     }
  6080.     public function saveDesignImg($request,$user,$cart)
  6081.     {
  6082.         $this->updateUserTemplateGetPrice($request,$cart,$user);
  6083.         $isAbonnementPro false;
  6084.         if (is_object($user)) {
  6085.             $abonnement $this->cart_service->checkIsAbonnementPro($user);
  6086.             // check abonnement in cart
  6087.             $cart $this->cart_service->getCartWithSession();
  6088.             $isAbonnementProInCart false;
  6089.             if ($cart) {
  6090.                 $isAbonnementProInCart $this->cart_service->checkIsAbonnementProCart($cart->getId());
  6091.             }
  6092.             if ($abonnement['is_abonnemen_pro'] || $isAbonnementProInCart) { // check is admin in compte abonnement
  6093.                 $isAbonnementPro true;
  6094.             }
  6095.             if (!$isAbonnementPro) {
  6096.                 $userTemplate $this->em->getRepository(NbUserTemplates::class)->findOneBy(array('token' => $request->get('user_template')));
  6097.                 if ($request->get('isCrea') && $request->get('isCrea') == 1) {
  6098.                    $frame_0 $request->get('frame_0');
  6099.                     $frame_0_new 'ma_crea_recto_'$userTemplate->getToken() .'.png';
  6100.                     $dossier_frame_0 str_replace ('/uploads',$this->params->get('uploads_directory'),$frame_0);
  6101.                     $dossier_frame_0_new $this->params->get('uploads_directory'). '/img_template_save/' $frame_0_new;
  6102.                     if(file_exists($dossier_frame_0_new) )unlink($dossier_frame_0_new);
  6103.                     if(trim($dossier_frame_0) == trim($dossier_frame_0_new)){
  6104.                         $frame_0_new 'ma_crea_recto_'$userTemplate->getToken() .'_1.png';
  6105.                         $dossier_frame_0_new $this->params->get('uploads_directory'). '/img_template_save/' $frame_0_new;
  6106.                     }
  6107.                     copy($dossier_frame_0 $dossier_frame_0_new);
  6108.                     $userTemplate->setRecto($frame_0_new);
  6109.                     if ($request->get('rectoverso')) {
  6110.                         $frame_1 $request->get('frame_1');
  6111.                         $frame_1_new 'ma_crea_verso_'.$userTemplate->getToken() .'.png';
  6112.                         $dossier_frame_1 str_replace ('/uploads',$this->params->get('uploads_directory'),$frame_1);
  6113.                         $dossier_frame_1_new $this->params->get('uploads_directory'). '/img_template_save/' $frame_1_new;
  6114.                         if(file_exists($dossier_frame_1_new) )unlink($dossier_frame_1_new);
  6115.                         if(trim($dossier_frame_1) == trim($dossier_frame_1_new)){
  6116.                             $frame_1_new 'ma_crea_verso_'$userTemplate->getToken() .'_1.png';
  6117.                             $dossier_frame_1_new $this->params->get('uploads_directory'). '/img_template_save/' $frame_1_new;
  6118.                         }
  6119.                         copy($dossier_frame_1 $dossier_frame_1_new);
  6120.                         $userTemplate->setVerso($frame_1_new);
  6121.                     }else{
  6122.                         $userTemplate->setVerso(null);
  6123.                     }
  6124.                     $userTemplate->setIsCrea(true);
  6125.                     if($request->get('plus_expert') == 1)$userTemplate->setIsPlusExpert(true);
  6126.                     else $userTemplate->setIsPlusExpert(false);
  6127.                     $userTemplate->setRectoverso($request->get('rectoverso') == 1);
  6128.                     $userTemplate->setIsSave(true);
  6129.                     $this->em->flush();
  6130.                 } else {
  6131.                     $ext '.png';
  6132.                     $frame_0 uniqid() . $ext;
  6133.                     $base64 str_replace('data:image/png;base64,'''$request->get('frame_0'));
  6134.                     $file fopen($this->params->get('uploads_directory') . '/img_template_save/' $frame_0'wb');
  6135.                     fwrite($filebase64_decode($base64));
  6136.                     fclose($file);
  6137.                     $userTemplate->setRecto($frame_0);
  6138.                     $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  6139.                     $frames[] = $baseurl "/uploads/tmp/" $frame_0;
  6140.                     if ($request->get('rectoverso')) {
  6141.                         $frame_1 uniqid() . $ext;
  6142.                         $base64 str_replace('data:image/png;base64,'''$request->get('frame_1'));
  6143.                         $file fopen($this->params->get('uploads_directory') . '/img_template_save/' $frame_1'wb');
  6144.                         fwrite($filebase64_decode($base64));
  6145.                         fclose($file);
  6146.                         $userTemplate->setVerso($frame_1);
  6147.                         $frames[] = $baseurl "/uploads/tmp/" $frame_1;
  6148.                     }
  6149.                     $userTemplate->setRectoverso($request->get('rectoverso') == 1);
  6150.                     $userTemplate->setIsSave(true);
  6151.                     $this->em->flush();
  6152.                 }
  6153.                 return [
  6154.                     'myTemplates' => $this->cart_service->getListeTemplateSaved($this->security->getUser()),
  6155.                     'myDesign' => $this->em->getRepository(NbUserTemplates::class)->getTemplateNotEmpty($this->security->getUser())
  6156.                 ];
  6157.             }
  6158.         }
  6159.         return 0;
  6160.     }
  6161.     public function importDossierDesign(){
  6162.         $templates $this->em->getRepository(NbTemplates::class)->findAll();
  6163.         foreach ($templates as $template){
  6164.             $this->ftpGetDir('87.98.139.241''nbd''9H1_lne0''/httpdocs/wp-content/uploads/nbdesigner/designs/' $template->getName(), $this->params->get('uploads_directory') . '/designs/' $template->getType() . '/' $template->getName());
  6165.         }
  6166.     }
  6167.     public function searchProductOption($request,$search,$user){
  6168.         $products $this->em->getRepository(ProductAttribute::class)->getProductsBySearch($search);
  6169.         $tabs = [];
  6170.         foreach ($products as $product){
  6171.             if($product->getProduct()->getTypeProduct() == Product::STICKERS_AUTOCOLLANT){
  6172.                 if($product->getGramage()){
  6173.                     $tabs[$product->getFormat()->getId()][0] = $product;
  6174.                     $priceProduct =  $this->em->getRepository(PriceProduct::class)->getOneProductPriceByProductAttribute($product->getId());
  6175.                     $tabs[$product->getFormat()->getId()]['priceProduct'] = $priceProduct;
  6176.                 }
  6177.             }else {
  6178.                 if ($product->getFormat()) {
  6179.                     $tabs[$product->getFormat()->getId()][0] = $product;
  6180.                     $priceProduct $this->em->getRepository(PriceProduct::class)->getOneProductPriceByProductAttribute($product->getId());
  6181.                     $tabs[$product->getFormat()->getId()]['priceProduct'] = $priceProduct;
  6182.                 } else if ($product->getTypeFormat()) {
  6183.                     $tabs[$product->getTypeFormat()->getId()][0] = $product;
  6184.                     $priceProduct $this->em->getRepository(PriceProduct::class)->getOneProductPriceByProductAttribute($product->getId());
  6185.                     $tabs[$product->getTypeFormat()->getId()]['priceProduct'] = $priceProduct;
  6186.                 }
  6187.             }
  6188.         }
  6189.         $array = [];
  6190.         // check abonnementPro
  6191.         $cart $this->cart_service->createCart(true);
  6192.         $abonnement  $this->cart_service->checkAbonnementToCartOrOrder($user,$cart->getId());
  6193.         $typeAbonnement null;
  6194.         if($abonnement){
  6195.             $typeAbonnement $abonnement['type'];
  6196.         }
  6197.         $attributeEntityPriceProduct $this->cart_service->getAttributeEntityPrice($typeAbonnement);
  6198.         // check abonnement starter
  6199.         $is_abonnementStarter false;
  6200.         if($user) {
  6201.             $abonnementStarter $this->em->getRepository(Abonnement::class)->findOneBy(array());
  6202.             $is_abonnementStarter $this->abonnementService->checkAbonnementByUser($abonnementStarter->getPlanId());
  6203.         }
  6204.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  6205.         foreach ($tabs as $key => $item){
  6206.             $productPrice $item['priceProduct'];
  6207.             if($productPrice->getProductAttribute()->getProduct()->getTypeProduct() == Product::STICKERS_AUTOCOLLANT){
  6208.                 $array[$key]['titreModif'] = (string)$productPrice->getProductAttribute()->getGramage()->getTextSearch();
  6209.                 $array[$key]['titre1Modif'] = (string)$productPrice->getProductAttribute()->getGramage()->getTitreSearch();
  6210.                 $array[$key]['titreFormat'] = $productPrice->getProductAttribute()->getGramage()->getName();
  6211.                 $array[$key]['img'] = $baseurl "/imageSite/" $productPrice->getProductAttribute()->getGramage()->getFileSearch();
  6212.                 $array[$key]['idTypeFormat'] = $productPrice->getProductAttribute()->getGramage()->getId();
  6213.             }else {
  6214.                 if ($productPrice->getProductAttribute()->getFormat()) {
  6215.                     $array[$key]['titreModif'] = (string)$productPrice->getProductAttribute()->getFormat()->getTextSearch();
  6216.                     $array[$key]['titre1Modif'] = (string)$productPrice->getProductAttribute()->getFormat()->getTitreSearch();
  6217.                     $array[$key]['titreFormat'] = $productPrice->getProductAttribute()->getFormat()->getName();
  6218.                     $array[$key]['img'] = $baseurl "/imageSite/" $productPrice->getProductAttribute()->getFormat()->getFileSearch();
  6219.                     $array[$key]['idFormat'] = $productPrice->getProductAttribute()->getFormat()->getId();
  6220.                     if(in_array($productPrice->getProductAttribute()->getProduct()->getTypeProduct(),[Product::KAKEMONO,Product::PHOTOS,Product::PHOTOS_ENCADRE])){
  6221.                         $array[$key]['notFormat'] = true;
  6222.                     }
  6223.                 } else if ($productPrice->getProductAttribute()->getTypeFormat()) {
  6224.                     $array[$key]['titreModif'] = (string)$productPrice->getProductAttribute()->getTypeFormat()->getTextSearch();
  6225.                     $array[$key]['titre1Modif'] = (string)$productPrice->getProductAttribute()->getTypeFormat()->getTitreSearch();
  6226.                     $array[$key]['titreFormat'] = $productPrice->getProductAttribute()->getTypeFormat()->getName();
  6227.                     $array[$key]['img'] = $baseurl "/imageSite/" $productPrice->getProductAttribute()->getTypeFormat()->getFileSearch();
  6228.                     $array[$key]['idTypeFormat'] = $productPrice->getProductAttribute()->getTypeFormat()->getId();
  6229.                 }
  6230.             }
  6231.             $array[$key]['titre'] = $item[0]->getProduct()->getTitre();
  6232.             if($item[0]->getProduct()->getIsRectoVerso() or $item[0]->getProduct()->getIsRecto()) {
  6233.                 if ($item[0]->getProduct()->getIsRectoVerso()) {
  6234.                     $array[$key]['recto'] = $productPrice->getProductAttribute()->getRectoverso() == ' - recto' ' - recto/verso';
  6235.                 } else {
  6236.                     $array[$key]['recto'] = '';
  6237.                 }
  6238.             }else{
  6239.                 $array[$key]['recto'] = $productPrice->getProductAttribute()->getRectoverso() == ' - recto' ' - recto/verso';
  6240.             }
  6241.             if($item[0]->getProduct()->getTypeProduct() == Product::AFFICHE){
  6242.                 $array[$key]['recto'] = '';
  6243.             }
  6244.             $array[$key]['qty'] = $productPrice->getQty() .' '.$item[0]->getProduct()->getTitre();
  6245.             if($is_abonnementStarter) {
  6246.                 $reduction $abonnementStarter->getReduction();
  6247.                 if ($reduction 0) {
  6248.                     $array[$key]['priceHt'] = $productPrice->getPrixHt() - (($productPrice->getPrixHt() * $reduction) / 100);
  6249.                     $array[$key]['priceTtc'] = $productPrice->getPrixTtc() - (($productPrice->getPrixTtc() * $reduction) / 100);
  6250.                 }else{
  6251.                     $array[$key]['priceHt'] = $productPrice->getPrixHt();
  6252.                     $array[$key]['priceTtc'] = $productPrice->getPrixTtc();
  6253.                 }
  6254.             }else{
  6255.                 $array[$key]['priceHt'] = $productPrice->{$attributeEntityPriceProduct['prixHt']}();
  6256.                 $array[$key]['priceTtc'] = $productPrice->{$attributeEntityPriceProduct['prixTtc']}();
  6257.             }
  6258.             $array[$key]['idProduct'] = $item[0]->getProduct()->getId();
  6259.             $array[$key]['typeProduct'] = $item[0]->getProduct()->getTypeProduct();
  6260.             $array[$key]['baseUrl'] = $baseurl;
  6261.         }
  6262.         return $array;
  6263.     }
  6264.     public function uploadPhotos($image,$request)
  6265.     {
  6266.         $ext $image->guessExtension();
  6267.         $tokenName $this->generateToken(32);
  6268.         $fileName $tokenName  '.' $ext;
  6269.         $image->move($this->params->get('uploads_directory'). '/tmp'$fileName);
  6270.         $photo = new CartDetailPhotos();
  6271.         $photo->setFile($fileName);
  6272.         $result $this->generateThumbnail($tokenName,$this->params->get('uploads_directory'). '/tmp/'$fileName10050200);
  6273.         $photo->setFileThumb($result);
  6274.         $this->em->persist($photo);
  6275.         $this->em->flush();
  6276.         $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  6277.         return [
  6278.             'token' => $photo->getToken(),
  6279.             'thumb' => $result $baseurl.'/uploads/tmp/'.$result:null,
  6280.             'image' =>  $baseurl.'/uploads/tmp/'.$fileName
  6281.             ];
  6282.     }
  6283.     function generateThumbnail($tokenName,$img$width$height$quality 90)
  6284.     {
  6285.         if (is_file($img)) {
  6286.             $imagick = new \Imagick(realpath($img));
  6287.             $imagick->setImageFormat('jpeg');
  6288.             $imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
  6289.             $imagick->setImageCompressionQuality($quality);
  6290. //            $imagick->thumbnailImage($width, $height, false, false);
  6291.             $filename $tokenName '_thumb' '.jpg';
  6292.             if (file_put_contents($this->params->get('uploads_directory'). '/tmp/'.$filename$imagick) === false) {
  6293.                 return false;
  6294.             }
  6295.             return $filename;
  6296.         }
  6297.         else {
  6298.             return false;
  6299.         }
  6300.     }
  6301. }