src/Twig/AppExtension.php line 562

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use App\Entity\AbonnementPay;
  4. use App\Entity\AbonnementPro;
  5. use App\Entity\Accessoire;
  6. use App\Entity\AccueilElement;
  7. use App\Entity\Attribut;
  8. use App\Entity\AttributLang;
  9. use App\Entity\BandeauHomePage;
  10. use App\Entity\BandeauRose;
  11. use App\Entity\BesoinProductFavoris;
  12. use App\Entity\BesoinProductPage;
  13. use App\Entity\BesoinProductPageBannier;
  14. use App\Entity\BesoinProductPageCategory;
  15. use App\Entity\BesoinProductPageHeader;
  16. use App\Entity\BesoinProductPageHeaderLang;
  17. use App\Entity\BesoinProductPageHeaderMobile;
  18. use App\Entity\BesoinProductPagePreferenceCategory;
  19. use App\Entity\BesoinProductPagePreferenceCategorySous;
  20. use App\Entity\CaptchaCus;
  21. use App\Entity\CaptchaCus2;
  22. use App\Entity\Carrier;
  23. use App\Entity\Cart;
  24. use App\Entity\CartDetail;
  25. use App\Entity\CartDetailAccessoire;
  26. use App\Entity\CompteAbonnementPro;
  27. use App\Entity\CompteAbonnementProCommandes;
  28. use App\Entity\CompteAbonnementProCommandesFactures;
  29. use App\Entity\ConfigProductDescription;
  30. use App\Entity\ConfigWording;
  31. use App\Entity\Customer;
  32. use App\Entity\FavoriLiseuse;
  33. use App\Entity\FilesClientCrelloCategory;
  34. use App\Entity\FormatCatSouhaite;
  35. use App\Entity\LanguageCountry;
  36. use App\Entity\MenuBurger;
  37. use App\Entity\MenuVerticalAcceuil;
  38. use App\Entity\NbUserTemplates;
  39. use App\Entity\NosCrea;
  40. use App\Entity\OrderDetail;
  41. use App\Entity\Orders;
  42. use App\Entity\PriceProduct;
  43. use App\Entity\Product;
  44. use App\Entity\ProductAttribute;
  45. use App\Entity\ProductCountry;
  46. use App\Entity\ProductLang;
  47. use App\Entity\Seo;
  48. use App\Entity\Stats;
  49. use App\Entity\TabAbonnement;
  50. use App\Entity\TabAbonnementCategory;
  51. use App\Entity\TemplatesPage;
  52. use App\Entity\TemplatesPageCategory;
  53. use App\Form\AccueilElementType;
  54. use App\Form\CaptchaCus2Type;
  55. use App\Form\CaptchaCusType;
  56. use App\Services\CartService;
  57. use App\Services\Liseuse;
  58. use App\Services\MenuBurgerService;
  59. use App\Services\MerciFacteur;
  60. use App\Services\NbDesigner;
  61. use App\Services\OrderService;
  62. use App\Services\StripeConnect;
  63. use Symfony\Component\Form\FormFactoryInterface;
  64. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  65. use Symfony\Component\Routing\RouterInterface;
  66. use Symfony\Contracts\Translation\TranslatorInterface;
  67. use Twig\Extension\AbstractExtension;
  68. use Twig\TwigFilter;
  69. use Twig\TwigFunction;
  70. use Twig\Environment;
  71. use Doctrine\ORM\EntityManagerInterface;
  72. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  73. class AppExtension extends AbstractExtension
  74. {
  75.     private $twig;
  76.     private $liseuse_service;
  77.     private $nbDesigner;
  78.     private $merciFacteurService;
  79.     private $params;
  80.     private $order_service;
  81.     private $session;
  82.     private $router;
  83.     public function __construct(
  84.         Environment $twig,
  85.         Liseuse $liseuse_service,
  86.         EntityManagerInterface $em,
  87.         NbDesigner $nbDesigner,
  88.         MerciFacteur $merciFacteur,
  89.         ParameterBagInterface $params,
  90.         CartService $cart_service,
  91.         OrderService $order_service,
  92.         FormFactoryInterface $form,
  93.         MenuBurgerService $menuService,
  94.         SessionInterface $session,
  95.         RouterInterface $router,
  96.         StripeConnect $stripeConnect,
  97.         TranslatorInterface $trans
  98.     ) {
  99.         $this->twig $twig;
  100.         $this->em $em;
  101.         $this->liseuse_service $liseuse_service;
  102.         $this->nbDesigner $nbDesigner;
  103.         $this->merciFacteurService $merciFacteur;
  104.         $this->cart_service $cart_service;
  105.         $this->params $params;
  106.         $this->order_service $order_service;
  107.         $this->form $form;
  108.         $this->session $session;
  109.         $this->menuService $menuService;
  110.         $this->router $router;
  111.         $this->stripeConnect $stripeConnect;
  112.         $this->trans $trans;
  113.     }
  114.     public function getFunctions()
  115.     {
  116.         return [
  117.             new TwigFunction('getRestTemps', [$this'getRestTemps']),
  118.             new TwigFunction('getDetailProduct', [$this'getDetailProduct']),
  119.             new TwigFunction('getStatusString', [$this'getStatusString']),
  120.             new TwigFunction('getPourcentage', [$this'getPourcentage']),
  121.             new TwigFunction('getValByJson', [$this'getValByJson']),
  122.             new TwigFunction('getPriceTotalTtc', [$this'getPriceTotalTtc']),
  123.             new TwigFunction('getPriceTotalHt', [$this'getPriceTotalHt']),
  124.             new TwigFunction('checkColor', [$this'checkColor']),
  125.             new TwigFunction('getAccessoireReluire', [$this'getAccessoireReluire']),
  126.             new TwigFunction('displayColorD', [$this'displayColorD']),
  127.             new TwigFunction('displayColorR', [$this'displayColorR']),
  128.             new TwigFunction('getproductOptionPapier', [$this'getproductOptionPapier']),
  129.             new TwigFunction('getproductOptionCarteAndFlyer', [$this'getproductOptionCarteAndFlyer']),
  130.             new TwigFunction('getproductOptionDistribution', [$this'getproductOptionDistribution']),
  131.             new TwigFunction('getColor', [$this'getColor']),
  132.             new TwigFunction('number_format', [$this'number_format']),
  133.             new TwigFunction('getInfoOrder', [$this'getInfoOrder']),
  134.             new TwigFunction('getStatusCommande', [$this'getStatusCommande']),
  135.             new TwigFunction('isProductPoste', [$this'isProductPoste']),
  136.             new TwigFunction('getTitlePage', [$this'getTitlePage']),
  137.             new TwigFunction('getmetaDesciption', [$this'getmetaDesciption']),
  138.             new TwigFunction('listFont', [$this'listFont']),
  139.             new TwigFunction('getPriceDistribution', [$this'getPriceDistribution']),
  140.             new TwigFunction('getCurrentStatusMerciFacteur', [$this'getCurrentStatusMerciFacteur']),
  141.             new TwigFunction('getNameFormat', [$this'getNameFormat']),
  142.             new TwigFunction('displayErreurOptionNotSelect', [$this'displayErreurOptionNotSelect']),
  143.             new TwigFunction('getNamePapierGrammage', [$this'getNamePapierGrammage']),
  144.             new TwigFunction('getNameProduct', [$this'getNameProduct']),
  145.             new TwigFunction('getPrixTtcByQtyFinition', [$this'getPrixTtcByQtyFinition']),
  146.             new TwigFunction('getPrixTtcByUserTemplate', [$this'getPrixTtcByUserTemplate']),
  147.             new TwigFunction('getTitlePageS', [$this'getTitlePageS']),
  148.             new TwigFunction('getDesciptionS', [$this'getDesciptionS']),
  149.             new TwigFunction('getArticlesRss', [$this'getArticlesRss']),
  150.             new TwigFunction('getproductOptionAffiche', [$this'getproductOptionAffiche']),
  151.             new TwigFunction('imagePdfExist', [$this'imagePdfExist']),
  152.             new TwigFunction('productPdfImageExist', [$this'productPdfImageExist']),
  153.             new TwigFunction('facturedateDiff', [$this'facturedateDiff']),
  154.             new TwigFunction('formatPrixSpecifique', [$this'formatPrixSpecifique']),
  155.             new TwigFunction('getFactureAbonnementByItemCommande', [$this'getFactureAbonnementByItemCommande']),
  156.             new TwigFunction('getMenuAbonnement', [$this'getMenuAbonnement']),
  157.             new TwigFunction('checkIsAbonnementEntreprise', [$this'checkIsAbonnementEntreprise']),
  158.             new TwigFunction('checkIsAbonnementPro', [$this'checkIsAbonnementPro']),
  159.             new TwigFunction('checkIsAbonnementProCart', [$this'checkIsAbonnementProCart']),
  160.             new TwigFunction('getNameAbonnementPro', [$this'getNameAbonnementPro']),
  161.             new TwigFunction('getNameAbonnementProString', [$this'getNameAbonnementProString']),
  162.             new TwigFunction('getRetribution', [$this'getRetribution']),
  163.             new TwigFunction('getIntervalDate', [$this'getIntervalDate']),
  164.             new TwigFunction('getPriceDifference', [$this'getPriceDifference']),
  165.             new TwigFunction('checkAbonnementImpay', [$this'checkAbonnementImpay']),
  166.             new TwigFunction('getAfterPoucentage', [$this'getAfterPoucentage']),
  167.             new TwigFunction('getPriceProductAfterPoucentage', [$this'getPriceProductAfterPoucentage']),
  168.             new TwigFunction('checkabonnementPlus', [$this'checkabonnementPlus']),
  169.             new TwigFunction('getPriceLivraison30Min', [$this'getPriceLivraison30Min']),
  170.             new TwigFunction('getProductByType', [$this'getProductByType']),
  171.             new TwigFunction('getNbrOrderValide', [$this'getNbrOrderValide']),
  172.             new TwigFunction('getBrowser', [$this'getBrowser']),
  173.             new TwigFunction('getProductsWithoutPapier', [$this'getProductsWithoutPapier']),
  174.             new TwigFunction('getProductsWithoutPapierAndNotColorLab', [$this'getProductsWithoutPapierAndNotColorLab']),
  175.             new TwigFunction('getDistinctCarrierOrderDetail', [$this'getDistinctCarrierOrderDetail']),
  176.             new TwigFunction('getDistinctCarrierOrderDetailMultipleAdresse', [$this'getDistinctCarrierOrderDetailMultipleAdresse']),
  177.             new TwigFunction('getNbrCart', [$this'getNbrCart']),
  178.             new TwigFunction('getGramagePapier', [$this'getGramagePapier']),
  179.             new TwigFunction('getAbreviation', [$this'getAbreviation']),
  180.             new TwigFunction('getCharteGraphiqueB2bData', [$this'getCharteGraphiqueB2bData']),
  181.             new TwigFunction('getCommandesByUserAndByCompte', [$this'getCommandesByUserAndByCompte']),
  182.             new TwigFunction('getCategoryFileCrello', [$this'getCategoryFileCrello']),
  183.             new TwigFunction('getNotifOrderB2bNotRead', [$this'getNotifOrderB2bNotRead']),
  184.             new TwigFunction('getNotifB2bNotRead', [$this'getNotifB2bNotRead']),
  185.             new TwigFunction('fileDocClientExist', [$this'fileDocClientExist']),
  186.             new TwigFunction('checkIsComptableAboPro', [$this'checkIsComptableAboPro']),
  187.             new TwigFunction('captchaCus', [$this'captchaCus']),
  188.             new TwigFunction('captchaCus2', [$this'captchaCus2']),
  189.             new TwigFunction('getPrixDistribution', [$this'getPrixDistribution']),
  190.             new TwigFunction('gePriceCartWithAbonnementPro', [$this'gePriceCartWithAbonnementPro']),
  191.             new TwigFunction('gePriceCartWithOutAbonnementPro', [$this'gePriceCartWithOutAbonnementPro']),
  192.             new TwigFunction('checkIsAbonnementProIsActive', [$this'checkIsAbonnementProIsActive']),
  193.             new TwigFunction('getAllCompteAbonnementProDistinct', [$this'getAllCompteAbonnementProDistinct']),
  194.             new TwigFunction('getCompteAbonnementProByIds', [$this'getCompteAbonnementProByIds']),
  195.             new TwigFunction('getProductsPromo', [$this'getProductsPromo']),
  196.             new TwigFunction('getProductsNew', [$this'getProductsNew']),
  197.             new TwigFunction('getProductsLuxe', [$this'getProductsLuxe']),
  198.             new TwigFunction('getProductsPanier', [$this'getProductsPanier']),
  199.             new TwigFunction('getProductsMoment', [$this'getProductsMoment']),
  200.             new TwigFunction('getAttrSoon', [$this'getAttrSoon']),
  201.             new TwigFunction('getPriceTextByFormatAndProduct', [$this'getPriceTextByFormatAndProduct']),
  202.             new TwigFunction('getAttrbyFormatAndProduct', [$this'getAttrbyFormatAndProduct']),
  203.             new TwigFunction('getProductTypeById', [$this'getProductTypeById']),
  204.             new TwigFunction('getProductById', [$this'getProductById']),
  205.             new TwigFunction('getAttribute', [$this'getAttribute']),
  206.             new TwigFunction('getElemenTabAbonnement', [$this'getElemenTabAbonnement']),
  207.             new TwigFunction('configsLabelPopGabarit', [$this'configsLabelPopGabarit']),
  208.             new TwigFunction('getAllActiveByCategoryBesoinProduct', [$this'getAllActiveByCategoryBesoinProduct']),
  209.             new TwigFunction('getAllActiveByCategoryBesoinProductMerchPack', [$this'getAllActiveByCategoryBesoinProductMerchPack']),
  210.             new TwigFunction('getAllActiveByCategoryTemplatesPage', [$this'getAllActiveByCategoryTemplatesPage']),
  211.             new TwigFunction('getAllCategoryActiveTemplatesPage', [$this'getAllCategoryActiveTemplatesPage']),
  212.             new TwigFunction('getAllActiveByPreferenceCategorySousBesoinProduct', [$this'getAllActiveByPreferenceCategorySousBesoinProduct']),
  213.             new TwigFunction('getAllActiveByPreferenceCategoryBesoinProduct', [$this'getAllActiveByPreferenceCategoryBesoinProduct']),
  214.             new TwigFunction('getAllCategoryActiveBesoinProduct', [$this'getAllCategoryActiveBesoinProduct']),
  215.             new TwigFunction('getAllCategoryActiveBesoinProductMerchPack', [$this'getAllCategoryActiveBesoinProductMerchPack']),
  216.             new TwigFunction('getTypeUserAndAboTagGoogle', [$this'getTypeUserAndAboTagGoogle']),
  217.             new TwigFunction('getCustomerByUser', [$this'getCustomerByUser']),
  218.             new TwigFunction('getMerchPackByProductImage', [$this'getMerchPackByProductImage']),
  219.             new TwigFunction('getFavorisIcone', [$this'getFavorisIcone']),
  220.             new TwigFunction('getFavorisProduct', [$this'getFavorisProduct']),
  221.             new TwigFunction('getMenuBurgerFront', [$this'getMenuBurgerFront']),
  222.             new TwigFunction('getMenuVerticalFront', [$this'getMenuVerticalFront']),
  223.             new TwigFunction('getAccueilElement', [$this'getAccueilElement']),
  224.             new TwigFunction('getPourcentageParPaysAndProduct', [$this'getPourcentageParPaysAndProduct']),
  225.             new TwigFunction('getDisponibiliteParPaysAndProduct', [$this'getDisponibiliteParPaysAndProduct']),
  226.             new TwigFunction('getDisponibiliteProductPerCountrySession', [$this'getDisponibiliteProductPerCountrySession']),
  227.             new TwigFunction('getDisponibiliteProductPapierPerCountrySession', [$this'getDisponibiliteProductPapierPerCountrySession']),
  228.             new TwigFunction('getCountrySession', [$this'getCountrySession']),
  229.              new TwigFunction('routeExists', [$this'routeExists']),
  230.             new TwigFunction('getPourcentageRate', [$this'getPourcentageRate']),
  231.             new TwigFunction('checkAttributeNonAffiche', [$this'checkAttributeNonAffiche']),
  232.             new TwigFunction('getBandeauDescription', [$this'getBandeauDescription']),
  233.             new TwigFunction('getBandeauRoseBTC', [$this'getBandeauRoseBTC']),
  234.             new TwigFunction('getBandeauRoseBTB', [$this'getBandeauRoseBTB']),
  235.             new TwigFunction('getBandeauRoseABP', [$this'getBandeauRoseABP']),
  236.             new TwigFunction('getAllProduct', [$this'getAllProduct']),
  237.             new TwigFunction('getCompteB2cByIds', [$this'getCompteB2cByIds']),
  238.             new TwigFunction('getNotifB2cNotRead', [$this'getNotifB2cNotRead']),
  239.             new TwigFunction('getConfigWording', [$this'getConfigWording']),
  240.             new TwigFunction('checkWalletB2bCart', [$this'checkWalletB2bCart']),
  241.             new TwigFunction('besoinProductHeader', [$this'besoinProductHeader']),
  242.             new TwigFunction('besoinProductHeaderMobile', [$this'besoinProductHeaderMobile']),
  243.             new TwigFunction('getCardByPaiementIntent', [$this'getCardByPaiementIntent']),
  244.             new TwigFunction('getDetailFavoris', [$this'getDetailFavoris']),
  245.             new TwigFunction('getImagesBanniere', [$this'getImagesBanniere']),
  246.             new TwigFunction('getDescriptionAttributeLang', [$this'getDescriptionAttributeLang']),
  247.             new TwigFunction('getImageProductLang', [$this'getImageProductLang']),
  248.             new TwigFunction('getImageBesoinProductHeaderLang', [$this'getImageBesoinProductHeaderLang']),
  249.             new TwigFunction('ceilFunction', [$this'ceilFunction']),
  250.             new TwigFunction('catLiseuseConfig', [$this'catLiseuseConfig']),
  251.             new TwigFunction('getTotalPromoByVal', [$this'getTotalPromoByVal']),
  252.             new TwigFunction('triTableQuantity', [$this'triTableQuantity']),
  253.         ];
  254.     }
  255.     public function ceilFunction($number){
  256.         if($number){
  257.             return ceil($number);
  258.         }
  259.         return 0;
  260.     }
  261.     private function cmpDefault($a$b) {
  262.         return strcmp($a['isDefault'], $b['isDefault']);
  263.     }
  264.     private function cmpId($a$b) {
  265.         return ($a['id'] < $b['id']) ? -1;
  266.     }
  267.     public function triTableQuantity($qtys){
  268.         $isDefault false;
  269.         if($qtys){
  270. //            foreach ($qtys as $qty){
  271. //                if($qty['isDefault']){
  272. //                    $isDefault = true;
  273. //                    break;
  274. //                }
  275. //            }
  276. //            if($isDefault){
  277. //                usort($qtys, array($this, "cmpDefault"));
  278. //            }else{
  279. //                usort($qtys, array($this, "cmpId"));
  280. //            }
  281.             usort($qtys, array($this"cmpId"));
  282.         }
  283.         return $qtys;
  284.     }
  285.     public function getTotalPromoByVal($cart,$val){
  286.         $val $this->cart_service->getTotalPromoByVal($cart,$val);
  287.         return $val ;
  288.     }
  289.     public function catLiseuseConfig(){
  290.         $array = [];
  291.         $cat1 $this->liseuse_service->getConfigByCatIdsLiseuse(CartDetail::SOUHAITE_DOC);
  292.         $cat2 $this->liseuse_service->getConfigByCatIdsLiseuse(CartDetail::SOUHAITE_BROCHURE);
  293.         $cat3 $this->liseuse_service->getConfigByCatIdsLiseuse(CartDetail::SOUHAITE_lIVRES);
  294.         $cat4 $this->liseuse_service->getConfigByCatIdsLiseuse(CartDetail::SOUHAITE_CATALOGES);
  295.         $cat5 $this->liseuse_service->getConfigByCatIdsLiseuse(CartDetail::SOUHAITE_LIVRETS);
  296.         $cat6 $this->liseuse_service->getConfigByCatIdsLiseuse(CartDetail::SOUHAITE_RAPORT);
  297.         $array[CartDetail::SOUHAITE_DOC]['cat'] = CartDetail::SOUHAITE_DOC;
  298.         $array[CartDetail::SOUHAITE_DOC]['value'] = $cat1;
  299.         $array[CartDetail::SOUHAITE_BROCHURE]['cat'] = CartDetail::SOUHAITE_BROCHURE;
  300.         $array[CartDetail::SOUHAITE_BROCHURE]['value'] = $cat2;
  301.         $array[CartDetail::SOUHAITE_lIVRES]['cat'] = CartDetail::SOUHAITE_lIVRES;
  302.         $array[CartDetail::SOUHAITE_lIVRES]['value'] = $cat3;
  303.         $array[CartDetail::SOUHAITE_CATALOGES]['cat'] = CartDetail::SOUHAITE_CATALOGES;
  304.         $array[CartDetail::SOUHAITE_CATALOGES]['value'] = $cat4;
  305.         $array[CartDetail::SOUHAITE_LIVRETS]['cat'] = CartDetail::SOUHAITE_LIVRETS;
  306.         $array[CartDetail::SOUHAITE_LIVRETS]['value'] = $cat5;
  307.         $array[CartDetail::SOUHAITE_RAPORT]['cat'] = CartDetail::SOUHAITE_RAPORT;
  308.         $array[CartDetail::SOUHAITE_RAPORT]['value'] = $cat6;
  309.         return json_encode($array) ;
  310.     }
  311.     public function getImageBesoinProductHeaderLang($idBesoinProduct){
  312.         $attrLang null;
  313.         $countryCode $this->session->get('countryCodeCopees');
  314.         if(!$countryCode){
  315.             $countryCode 'FR';
  316.         }
  317.         $country $this->em->getRepository(LanguageCountry::class)->findOneBy(['countryCode'=>$countryCode]);
  318.         if($country){
  319.             $attrLang $this->em->getRepository(BesoinProductPageHeaderLang::class)->findOneBy(['besoinProductPageHeader'=>$idBesoinProduct,'language'=>$country->getId()]);
  320.         }
  321.         if(!$attrLang){
  322.             $attrLang $this->em->getRepository(BesoinProductPageHeader::class)->find($idBesoinProduct);
  323.         }
  324.         return $attrLang;
  325.     }
  326.     public function getImageProductLang($idProduct){
  327.         $attrLang null;
  328.         $countryCode $this->session->get('countryCodeCopees');
  329.         if(!$countryCode){
  330.             $countryCode 'FR';
  331.         }
  332.         $country $this->em->getRepository(LanguageCountry::class)->findOneBy(['countryCode'=>$countryCode]);
  333.         if($country){
  334.             $attrLang $this->em->getRepository(ProductLang::class)->findOneBy(['product'=>$idProduct,'language'=>$country->getId()]);
  335.         }
  336.         if(!$attrLang){
  337.             $attrLang $this->em->getRepository(Product::class)->find($idProduct);
  338.         }
  339.         return $attrLang;
  340.     }
  341.     public function getDescriptionAttributeLang($idAttribute){
  342.         $attrLang null;
  343.         $countryCode $this->session->get('countryCodeCopees');
  344.         if(!$countryCode){
  345.             $countryCode 'FR';
  346.         }
  347.         $country $this->em->getRepository(LanguageCountry::class)->findOneBy(['countryCode'=>$countryCode]);
  348.         if($country){
  349.             $attrLang $this->em->getRepository(AttributLang::class)->findOneBy(['attribute'=>$idAttribute,'language'=>$country->getId()]);
  350.         }
  351.         if(!$attrLang){
  352.             $attrLang $this->em->getRepository(Attribut::class)->find($idAttribute);
  353.         }
  354.         return $attrLang;
  355.     }
  356.     public function getImagesBanniere(){
  357.         $bannieres $this->em->getRepository(BesoinProductPageBannier::class)->findOneBy([]);
  358.         return $bannieres;
  359.     }
  360.     public function getDetailFavoris($token)
  361.     {
  362.         $favori $this->em->getRepository(FavoriLiseuse::class)->findOneBy(['token'=>$token]);
  363.         $product_attribute $favori->getProductAttribute();
  364.         $array = array();
  365.         $arrayReluire = array();
  366.         if($product_attribute) {
  367.             if ($product_attribute->getFormat()) {
  368.                 $array[] = $this->trans->trans($product_attribute->getFormat()->getName(), [], 'productTranslate') . ' ';
  369.             }
  370.             if ($favori->getIsReluire()) {
  371.                 $array[] = $this->trans->trans('Reliée', [], 'productTranslate') . ' ';
  372.             } else {
  373.                 $array[] = $this->trans->trans('Non reliée', [], 'productTranslate') . ' ';
  374.             }
  375.             if ($favori->getAccecoireColor()) {
  376.                 if ($favori->getAccecoireColor()->getTypeAccessoire() == Accessoire::COULEUR) {
  377.                     $array[] = $this->trans->trans($favori->getAccecoireColor()->getName(), [], 'productTranslate') . ' ';
  378.                 }
  379.             }
  380.             if ($product_attribute->getProduct()->getTypeProduct() == Product::PAPIER) {
  381.                 if ($product_attribute->getRectoverso()) {
  382.                     if ($product_attribute->getRectoverso() == ProductAttribute::RECTO) {
  383.                         $array[] = ' ' $this->trans->trans('Recto', [], 'adminTranslate') . ' ';
  384.                     } else {
  385.                         $array[] = ' ' $this->trans->trans('Recto-Verso', [], 'adminTranslate') . ' ';
  386.                     }
  387.                 }
  388.             }
  389.             if ($product_attribute->getGramage() && $product_attribute->getProduct()->getTypeProduct() == Product::PAPIER) {
  390.                 $array[] = $this->trans->trans($product_attribute->getGramage()->getNamePapier(), [], 'productTranslate'). ' ';
  391.             }
  392.         }
  393.         $str =implode(',',$array);
  394.         $strReluire = !empty($arrayReluire)? '('.implode(',',$arrayReluire).')':'';
  395.         return $str.$strReluire;
  396.     }
  397.     public function getCardByPaiementIntent($paymentIntentId){
  398.         $method $this->stripeConnect->getCardByPaiementIntent($paymentIntentId);
  399.         return $method;
  400.     }
  401.     public function getDisponibiliteProductPerCountrySession($product){
  402.         $countryCode $this->session->get('countryCodeCopees');
  403.         if(!$countryCode){
  404.             $countryCode 'FR';
  405.         }
  406.         $country $this->em->getRepository(LanguageCountry::class)->findOneBy(['countryCode'=>$countryCode]);
  407.         if($country){
  408.             $productCountry $this->em->getRepository(ProductCountry::class)->getProductCountryByTypeProductAndCountry($product$country->getId());
  409.             if ($productCountry) {
  410.                 if ($productCountry->getIsEnabled()) {
  411.                     return true;
  412.                 }
  413.             }
  414.         }
  415.         return false;
  416.     }
  417.     public function getDisponibiliteProductPapierPerCountrySession($typeProduct){
  418.         $product $this->em->getRepository(Product::class)->findOneBy(['typeProduct'=>$typeProduct]);
  419.         if($product) {
  420.             $countryCode $this->session->get('countryCodeCopees');
  421.             if (!$countryCode) {
  422.                 $countryCode 'FR';
  423.             }
  424.             $country $this->em->getRepository(LanguageCountry::class)->findOneBy(['countryCode' => $countryCode]);
  425.             if ($country) {
  426.                 $productCountry $this->em->getRepository(ProductCountry::class)->getProductCountryByTypeProductAndCountry($product$country->getId());
  427.                 if ($productCountry) {
  428.                     if ($productCountry->getIsEnabled()) {
  429.                         return true;
  430.                     }
  431.                 }
  432.             }
  433.         }
  434.         return false;
  435.     }
  436.     public function getCountrySession(){
  437.         $countryCode $this->session->get('countryCodeCopees');
  438.         if(!$countryCode){
  439.             $countryCode 'FR';
  440.         }
  441.         $country $this->em->getRepository(LanguageCountry::class)->findOneBy(['countryCode'=>$countryCode]);
  442.         if($country){
  443.            return $country->getCountryName();
  444.         }
  445.         return '';
  446.     }
  447.     public function getDisponibiliteParPaysAndProduct($productId,$countryId){
  448.         $product $this->em->getRepository(Product::class)->find($productId);
  449.         $country $this->em->getRepository(LanguageCountry::class)->find($countryId);
  450.         if($country && $product){
  451.             $productCountry $this->em->getRepository(ProductCountry::class)->findOneBy(['country'=>$countryId,'product'=>$productId]);
  452.             if($productCountry){
  453.                 return $productCountry->getIsEnabled();
  454.             }
  455.         }
  456.         return false;
  457.     }
  458.     public function getPourcentageParPaysAndProduct($productId,$countryId){
  459.         $product $this->em->getRepository(Product::class)->find($productId);
  460.         $country $this->em->getRepository(LanguageCountry::class)->find($countryId);
  461.         if($country && $product){
  462.             $productCountry $this->em->getRepository(ProductCountry::class)->findOneBy(['country'=>$countryId,'product'=>$productId]);
  463.             if($productCountry){
  464.                 return $productCountry->getPourcentagePrix();
  465.             }
  466.         }
  467.         return 0;
  468.     }
  469.     function besoinProductHeader()
  470.     {
  471.         $blocs $this->em->getRepository(BesoinProductPageHeader::class)->getAllActive();
  472.         return $blocs;
  473.     }
  474.     function besoinProductHeaderMobile()
  475.     {
  476.         $blocs $this->em->getRepository(BesoinProductPageHeaderMobile::class)->getAllActive();
  477.         return $blocs;
  478.     }
  479.     function checkWalletB2bCart($cart)
  480.     {
  481.         $walletsPrix $this->cart_service->checkWalletB2bCart($cart);
  482.         return $walletsPrix;
  483.     }
  484.     function getAllProduct()
  485.     {
  486.         $products $this->em->getRepository(Product::class)->findAllProductNotDelete();
  487.         return $products;
  488.     }
  489.     public function getConfigWording($typeW){
  490.         $configWording $this->em->getRepository(ConfigWording::class)->findOneBy(['typeW'=>$typeW]);
  491.         return $configWording;
  492.     }
  493.     public function getNotifB2cNotRead($user){
  494.         $notifs $this->cart_service->getNotifB2cNotRead($user);
  495.         return $notifs;
  496.     }
  497.     function getBandeauRoseABP()
  498.     {
  499.         $bandeau $this->em->getRepository(BandeauRose::class)->findOneBy(['numBandeau'=>BandeauRose::BANDEAU_ABP]);
  500.         return $bandeau;
  501.     }
  502.     function getBandeauRoseBTC()
  503.     {
  504.         $bandeau $this->em->getRepository(BandeauRose::class)->findOneBy(['numBandeau'=>BandeauRose::BANDEAU_B2C]);
  505.         return $bandeau;
  506.     }
  507.     function getBandeauRoseBTB()
  508.     {
  509.         $bandeau $this->em->getRepository(BandeauRose::class)->findOneBy(['numBandeau'=>BandeauRose::BANDEAU_B2B]);
  510.         return $bandeau;
  511.     }
  512.     function getBandeauDescription()
  513.     {
  514.         $bandeau $this->em->getRepository(BandeauHomePage::class)->findOneBy([]);
  515.         return $bandeau;
  516.     }
  517.     function checkAttributeNonAffiche($attrs)
  518.     {
  519.         $bool false;
  520.         foreach ($attrs as $attr){
  521.             if($attr && isset($attr['id'])){
  522.                 if($attr['isDisplayNone']){
  523.                     $bool true;
  524.                 }
  525.             }
  526.         }
  527.         return $bool;
  528.     }
  529.     function getPourcentageRate($rate)
  530.     {
  531.        if($rate 0){
  532.           return  $rate/*100 ;
  533.        }else{
  534.            return 0;
  535.        }
  536.     }
  537.     function routeExists($name)
  538.     {
  539.         return (null ===  $this->router->getRouteCollection()->get($name)) ? false true;
  540.     }
  541.     public function getMenuBurgerFront(){
  542.         $menuObjects $this->em->getRepository(MenuBurger::class)->findBy([],['sort'=>'asc']);
  543.         $menus = [];
  544.         if($menuObjects){
  545.             $menus $this->menuService->groupMenuTab($menuObjects);
  546.         }
  547.         return $menus ;
  548.     }
  549.     public function getMenuVerticalFront(){
  550.         $menuObjects $this->em->getRepository(MenuVerticalAcceuil::class)->findBy([],['sort'=>'asc']);
  551.         $menus = [];
  552.         if($menuObjects){
  553.             $menus $this->menuService->groupMenuVerticalTab($menuObjects);
  554.         }
  555.         return $menus ;
  556.     }
  557.     public function getAccueilElement(){
  558.         $objects $this->em->getRepository(AccueilElement::class)->findBy([],['sort'=>'asc']);
  559.         return $objects ;
  560.     }
  561.     public function getFavorisIcone($id,$user){
  562.         $product $this->em->getRepository(BesoinProductPage::class)->find($id);
  563.         if($product && $user){
  564.             $favoris $this->em->getRepository(BesoinProductFavoris::class)->findOneBy(['besoinProductPage'=>$product->getId(),'user'=>$user->getId()]) ;
  565.             if($favoris){
  566.                 return "<span class='infoBulleHeart' style='' data-id='".$product->getId()."'><i class='fa-solid fa-heart' style='color:red;'></i></span>";
  567.             }else{
  568.                 return "<span class='infoBulleHeart' style='' data-id='".$product->getId()."'><i class='fa-regular fa-heart'></i></span>";
  569.             }
  570.         }
  571.         return '';
  572.     }
  573.     public function getFavorisProduct($user){
  574.         if( $user){
  575.             $favoris $this->em->getRepository(BesoinProductFavoris::class)->findBy(['user'=>$user->getId()]) ;
  576.             return $favoris;
  577.         }
  578.         return false;
  579.     }
  580.     public function getMerchPackByProductImage($request,$id){
  581.         $product $this->em->getRepository(BesoinProductPage::class)->find($id);
  582.         $image null;
  583.         if($product){
  584.             $baseurl $request->getScheme() . '://' $request->getHttpHost() . $request->getBasePath();
  585.             $image $baseurl.'/imageSite/'.$product->getFileBesoinProduct();
  586.             $dataImage $this->session->get('dataImageMerchPack');
  587.             if(is_array($dataImage)){
  588.                 if(array_key_exists($product->getId(),$dataImage) && $product->getNbrMerchPack() && !empty($product->getNbrMerchPack())){
  589.                     $image $dataImage[$product->getId()];
  590.                 }
  591.             }
  592.         }
  593.         return $image;
  594.     }
  595.     public function getCustomerByUser($user){
  596.         $customer $this->em->getRepository(Customer::class)->findOneBy(['user'=>$user->getId()]);
  597.         return $customer;
  598.     }
  599.     public function getAllActiveByCategoryBesoinProduct($catId){
  600.         $products $this->em->getRepository(BesoinProductPage::class)->getAllActiveByCategory($catId);
  601.         return $products;
  602.     }
  603.     public function getAllActiveByCategoryTemplatesPage($catId){
  604.         $products $this->em->getRepository(TemplatesPage::class)->getAllActiveByCategory($catId);
  605.         return $products;
  606.     }
  607.     public function getAllCategoryActiveTemplatesPage(){
  608.         $categorys $this->em->getRepository(TemplatesPageCategory::class)->getAllActive();
  609.         return $categorys;
  610.     }
  611.     public function getAllActiveByCategoryBesoinProductMerchPack($catId){
  612.         $products $this->em->getRepository(BesoinProductPage::class)->getAllActiveByCategoryMerchPack($catId);
  613.         return $products;
  614.     }
  615.     public function getAllActiveByPreferenceCategorySousBesoinProduct($catId){
  616.         $products $this->em->getRepository(BesoinProductPagePreferenceCategorySous::class)->getAllActiveByCategory($catId);
  617.         return $products;
  618.     }
  619.     public function getAllActiveByPreferenceCategoryBesoinProduct(){
  620.         $products $this->em->getRepository(BesoinProductPagePreferenceCategory::class)->getAllActive();
  621.         return $products;
  622.     }
  623.     public function getAllCategoryActiveBesoinProduct(){
  624.         $categorys $this->em->getRepository(BesoinProductPageCategory::class)->getAllActive();
  625.         return $categorys;
  626.     }
  627.     public function getAllCategoryActiveBesoinProductMerchPack(){
  628.         $categorys $this->em->getRepository(BesoinProductPageCategory::class)->getAllActiveMerchPack();
  629.         return $categorys;
  630.     }
  631.     public function getElemenTabAbonnement(){
  632.         $category $this->em->getRepository(TabAbonnementCategory::class)->findBy([],['sort'=>'asc']);
  633.         $tabAbonnementWithoutCategory $this->em->getRepository(TabAbonnement::class)->getLigneWithoutCategory();
  634.         $response =
  635.             [
  636.                 'category' => $category,
  637.                 'tabAbonnementWithoutCategory' => $tabAbonnementWithoutCategory
  638.             ];
  639.         return $response;
  640.     }
  641.     public function getPriceTextByFormatAndProduct($typeProduit,$typeFormat){
  642.         $attr $this->em->getRepository(Attribut::class)->findOneBy(['typeFormat'=>$typeFormat,'typeProduct'=>$typeProduit]);
  643.         if($attr){
  644.             return $attr->getBesoinProductTextPrix();
  645.         }else{
  646.             return '';
  647.         }
  648.     }
  649.     public function getAttrbyFormatAndProduct($typeProduit,$typeFormat)
  650.     {
  651.         $attr $this->em->getRepository(Attribut::class)->findOneBy(['typeFormat'=>$typeFormat,'typeProduct'=>$typeProduit]);
  652.         return $attr;
  653.     }
  654.     public function getProductsPanier(){
  655.         $cart $this->cart_service->getCartWithSession();
  656.         if($cart && $cart->getCartDetail() && count($cart->getCartDetail())>0){
  657.             $result $cart->getCartDetail();
  658.         }else{
  659.             $result null;
  660.         }
  661.         return $this->twig->render('front/accueil/besoin-product-bloc/moment.html.twig', [
  662.             'products' => $result,
  663.         ]);
  664.     }
  665.     public function getAttrSoon($attrType,$productType){
  666.         $result $this->em->getRepository(Attribut::class)->getAttrSoon($attrType,$productType);
  667.         return $result;
  668.     }
  669.     public function getProductsMoment(){
  670.         $creas $this->em->getRepository(NosCrea::class)->findBy([]);
  671.         return $this->twig->render('front/accueil/besoin-product-bloc/moment.html.twig', [
  672.             'products' => $creas,
  673.         ]);
  674.     }
  675.     public function getProductsPromo(){
  676.         $result $this->em->getRepository(Product::class)->findBy(['besoinProductIsPromo'=>true]);
  677.         return $this->twig->render('front/accueil/besoin-product-bloc/promo.html.twig', [
  678.             'products' => $result,
  679.         ]);
  680.     }
  681.     public function getProductsNew(){
  682.         $result $this->em->getRepository(Product::class)->findBy(['besoinProductIsNew'=>true]);
  683.         return $this->twig->render('front/accueil/besoin-product-bloc/new.html.twig', [
  684.             'products' => $result,
  685.         ]);
  686.     }
  687.     public function getProductsLuxe(){
  688.         $result $this->em->getRepository(Product::class)->findBy(['besoinProductIsLuxe'=>true]);
  689.         return $this->twig->render('front/accueil/besoin-product-bloc/luxe.html.twig', [
  690.             'products' => $result,
  691.         ]);
  692.     }
  693.     public function getCompteAbonnementProByIds($ids){
  694.         $result $this->em->getRepository(CompteAbonnementPro::class)->findBy(['id'=>json_decode($ids)]);
  695.         return $result;
  696.     }
  697.     public function getCompteB2cByIds($ids){
  698.         $result $this->em->getRepository(Customer::class)->findBy(['id'=>json_decode($ids)]);
  699.         return $result;
  700.     }
  701.     public function getAllCompteAbonnementProDistinct(){
  702.         $result $this->em->getRepository(CompteAbonnementPro::class)->getAllCompteAbonnementProDistinct();
  703.         return $result;
  704.     }
  705.     public function checkIsAbonnementProIsActive($user){
  706.         $result $this->cart_service->checkIsAbonnementProIsActive($user);
  707.         return $result;
  708.     }
  709.     public function gePriceCartWithAbonnementPro($typeAbonnement,$cart){
  710.         $array $this->cart_service->gePriceCartWithAbonnementPro($typeAbonnement,$cart);
  711.         return $array;
  712.     }
  713.     public function gePriceCartWithOutAbonnementPro($cart){
  714.         $array $this->cart_service->gePriceCartWithOutAbonnementPro(0,$cart);
  715.         return $array;
  716.     }
  717.     public function getPrixDistribution($distribution){
  718.         $prix 0;
  719.         if(is_object($distribution)){
  720.             $persone = (int)$distribution->getNbrPersonne();
  721.             $prixQty $distribution->getQty()->getPrixTtc();
  722.             if($persone == 1){
  723.                 $prix $prixQty;
  724.             }else if($persone == 2){
  725.                 $prix $prixQty + ($prixQty 30)/100;
  726.             }else if($persone == 3){
  727.                 $prix $prixQty + ($prixQty 40)/100;
  728.             }else if($persone == 4){
  729.                 $prix $prixQty + ($prixQty 50)/100;
  730.             }else{
  731.                 $prix $prixQty;
  732.             }
  733.         }
  734.         return $prix  ;
  735.     }
  736.     public function captchaCus(){
  737.         $form $this->form->create(CaptchaCusType::class, new CaptchaCus());
  738.         return [
  739.             'formCaptcha' => $form->createView(),
  740.             ]
  741.         ;
  742.     }
  743.     public function captchaCus2(){
  744.         $form $this->form->create(CaptchaCus2Type::class, new CaptchaCus2());
  745.         return [
  746.             'formCaptcha' => $form->createView(),
  747.         ]
  748.             ;
  749.     }
  750.     public function checkIsComptableAboPro($user){
  751.         if(is_object($user)){
  752.             $abo $this->cart_service->checkAbonenementProSansAbonnementCopeesPlus($user);
  753.             if($abo) {
  754.                 $customer $this->em->getRepository(Customer::class)->findOneBy(['user' => $user->getId()]);
  755.                 if ($customer && $customer->getRolAbo() == Customer::role_abo_comptabilite) {
  756.                     return true;
  757.                 }
  758.             }
  759.         }
  760.         return false;
  761.     }
  762.     public function getNotifOrderB2bNotRead($user){
  763.         $notifs $this->cart_service->getNotifOrderB2bNotRead($user);
  764.         return $notifs;
  765.     }
  766.     public function getNotifB2bNotRead($user){
  767.         $notifs $this->cart_service->getNotifB2bNotRead($user);
  768.         return $notifs;
  769.     }
  770.     public function getCommandesByUserAndByCompte($id,$idCustomer){
  771.         $compte $this->em->getRepository(CompteAbonnementPro::class)->find($id);
  772.         $customer $this->em->getRepository(Customer::class)->find($idCustomer);
  773.         $commandes $this->em->getRepository(CompteAbonnementProCommandes::class)->getCommandesByUserAndByCompte($customer->getUser(),$compte);
  774.         return $commandes;
  775.     }
  776.     public function getCharteGraphiqueB2bData($user){
  777.         $data $this->cart_service->getCharteGraphiqueB2bData($user);
  778.         return $data;
  779.     }
  780.     public function getAbreviation($user=null,$email=null){
  781.         $name '';
  782.         $nameAB 'X';
  783.         $class '';
  784.         if($user){
  785.             $name ucwords($user->getFirstname()).' '.ucwords($user->getLastname());
  786.             $nameAB substr($user->getFirstname(), 01) ;
  787.             $class 'bg-light-primary';
  788.         }else{
  789.             if(!empty($email)) {
  790.                 $name $email;
  791.                 $nameAB substr($email01);
  792.                 $class 'bg-light-primary';
  793.             }
  794.         }
  795.         return ['name' => $name,'nameAB' => strtoupper($nameAB),'class' => $class];
  796.     }
  797.     public function getFilters()
  798.     {
  799.         return array(
  800.             new \Twig_SimpleFilter('convertPrice', array($this'convertPrice')),
  801.             new \Twig_SimpleFilter('sortArrayByField', array($this'sortArrayByField')),
  802.             new \Twig_SimpleFilter('addslashes''addslashes'),
  803.         );
  804.     }
  805.     public function getNbrCart(){
  806.         $cart $this->cart_service->getCartWithSession();
  807.         if($cart){
  808.             $nbr count($cart->getCartDetail()) + count($cart->getDistributionCart());
  809.         }else{
  810.             $nbr 0;
  811.         }
  812.         return $nbr;
  813.     }
  814.     public function getGramagePapier(){
  815.         $gramage $this->cart_service->getGramagePapier();
  816.         return $gramage;
  817.     }
  818.     public function getProductsWithoutPapier(){
  819.         $products  $this->em->getRepository(Product::class)->getProductsWithoutPapier();
  820.         return $products;
  821.     }
  822.     public function getProductsWithoutPapierAndNotColorLab(){
  823.         $products  $this->em->getRepository(Product::class)->getProductsWithoutPapierAndNotColorLab();
  824.         return $products;
  825.     }
  826.     public function getCategoryFileCrello($user){
  827.         $cat = [];
  828.         if(is_object($user)){
  829.             $cat  $this->em->getRepository(FilesClientCrelloCategory::class)->findBy(['user'=>$user->getId(),'isDefault'=> null]);
  830.         }
  831.         return $cat;
  832.     }
  833.     public function configsLabelPopGabarit($tag){
  834.         $config  $this->em->getRepository(ConfigProductDescription::class)->findOneBy(array('tagId'=>$tag));
  835.         if ($config){
  836.            $text =  $config->getDescription();
  837.         }else{
  838.             $text =  '';
  839.         }
  840.         return $text;
  841.     }
  842.     public function getDistinctCarrierOrderDetail($order){
  843.         $distinctCarrierOrderDetail $this->order_service->getDistinctCarrierOrderDetail($order);
  844.         return $distinctCarrierOrderDetail;
  845.     }
  846.     public function getDistinctCarrierOrderDetailMultipleAdresse($order){
  847.         $distinctCarrierOrderDetail $this->order_service->getDistinctCarrierOrderDetailMultipleAdresse($order);
  848.         return $distinctCarrierOrderDetail;
  849.     }
  850.     public function getBrowser($request){
  851.         $user_agent $request->headers->get('User-Agent');
  852.         $t strtolower($user_agent);
  853.         $t " " $t;
  854.         if     (strpos($t'opera'     ) || strpos($t'opr/')     ) return 'Opera'     ;
  855.         elseif (strpos($t'edge'      )                           ) return 'Edge'             ;
  856.         elseif (strpos($t'chrome'    )                           ) return 'Chrome'           ;
  857.         elseif (strpos($t'safari'    )                           ) return 'Safari'           ;
  858.         elseif (strpos($t'firefox'   )                           ) return 'Firefox'          ;
  859.         elseif (strpos($t'msie'      ) || strpos($t'trident/7')) return 'Internet Explorer';
  860.         else 'Unkown';
  861.     }
  862.     public function getNbrOrderValide(){
  863.         $result $this->em->getRepository(Orders::class)->getOrderValide();
  864.         return ['nembre_space' => $this->space(count($result)-139513true),'nembre'=>count($result)-13951];
  865.     }
  866.     private function space($str$step$reverse false) {
  867.         if ($reverse)
  868.             return strrev(chunk_split(strrev($str), $step' '));
  869.         return chunk_split($str$step' ');
  870.     }
  871.     public function getProductByType($typeProduct){
  872.         $result $this->em->getRepository(Product::class)->findOneBy(array('typeProduct'=>$typeProduct));
  873.         return $result;
  874.     }
  875.     public function getPriceLivraison30Min($idImprimeur,$data){
  876.         $result $this->cart_service->getPriceLivraison30Min($idImprimeur,$data);
  877.         return $result;
  878.     }
  879.     public function checkabonnementPlus($user){
  880.         if(is_object($user) ){
  881.             $subscription $this->em->getRepository(AbonnementPay::class)->getActive($user);
  882.             return $subscription true:false;
  883.         }
  884.         return false;
  885.     }
  886.     public function getAfterPoucentage($id,$price){
  887.         $productPrice $this->em->getRepository(PriceProduct::class)->find($id);
  888.         $val =   $this->cart_service->getPricePourcentageAdd($productPrice,$price);
  889.         return $val $price;
  890.     }
  891.     public function getPriceProductAfterPoucentage($product,$price){
  892.         $val =   $this->cart_service->getPriceProductPourcentageAdd($product,$price);
  893.         return $val $price;
  894.     }
  895.     public function checkAbonnementImpay($user){
  896.         return  $this->cart_service->checkFactureImpayeByCompte($user);
  897.     }
  898.     public function getPriceDifference($myAbonnementId,$typeAbonnement,$typeCompteAbonnement){
  899.        $tab =  $this->cart_service->getPriceDifference($myAbonnementId,$typeAbonnement,$typeCompteAbonnement);
  900.        $prix explode('.',$tab['newPriceTtc']);
  901.        $oldPrix =$tab['oldPriceTtc'];
  902.        return[
  903.            'prix1'=>$prix[0],
  904.            'prix2'=>isset($prix[1])? $prix[1] :'00',
  905.            'oldPrix'=>str_replace('.',',',$oldPrix)
  906.        ];
  907.     }
  908.     public function getIntervalDate($origin ,$target ){
  909.         $mois 0;
  910.         if(is_object($origin) && is_object($target)){
  911.             $interval $origin->diff($target);
  912.             $mois $interval->;
  913.             $mois $interval->20 $mois $mois;
  914.             $years $interval->y;
  915.             if($years 0){
  916.                 $mois $years *12 +$mois;
  917.             }
  918.         }
  919.         return $mois;
  920.     }
  921.     public function getRetribution($order){
  922.         if(is_object($order)){
  923.             if($order->getRetributionPourcentage()){
  924.                 return $order->getRetributionPourcentage();
  925.             }else{
  926.                 return round($order->getPrixTransfer() * 100 /  $order->getPrixTtc());
  927.             }
  928.         }
  929.         return '-';
  930.     }
  931.     public function checkIsAbonnementPro($user){
  932.         if(is_object($user)){
  933.             return $this->cart_service->checkAbonenementProSansAbonnementCopeesPlus($user);
  934.         }
  935.         return false;
  936.     }
  937.     public function checkIsAbonnementProCart(){
  938.         $cart $this->cart_service->getCartWithSession();
  939.         if($cart){
  940.            return  $this->cart_service->checkIsAbonnementProCart($cart->getId());
  941.         }
  942.         return false;
  943.     }
  944.     public function getMenuAbonnement($user,$route){
  945.         if(is_object($user)){
  946.             $abonnement $this->cart_service->checkIsAbonnementPro($user);
  947.             // check abonnement in cart
  948.             $cart $this->cart_service->getCartWithSession();
  949.             $isAbonnementProInCart false;
  950.             if($cart){
  951.                 $isAbonnementProInCart $this->cart_service->checkIsAbonnementProCart($cart->getId());
  952.             }
  953.             if($abonnement['is_abonnemen_pro'] || $isAbonnementProInCart) { // check is admin in compte abonnement
  954.                 $compteAbonnement $abonnement['compte_abonnement_object'];
  955.                 return $this->twig->render('front/abonnement-pro/account/menu.html.twig', [
  956.                     'compteAbonnement' => $compteAbonnement,
  957.                     'is_admin' => isset($abonnement['is_admin'])?$abonnement['is_admin']:$isAbonnementProInCart?true:false,
  958.                     'route' => $route,
  959.                     'user' => $user,
  960.                     'isAbonnementProInCart' => $isAbonnementProInCart,
  961.                     'cart' => $cart
  962.                 ]);
  963.             }
  964.         }
  965.         return '';
  966.     }
  967.     public function getNameAbonnementPro($user){
  968.         if(is_object($user)){
  969.             $abonnement $this->cart_service->checkIsAbonnementPro($user);
  970.             // check abonnement in cart
  971.             $cart $this->cart_service->getCartWithSession();
  972.             $isAbonnementProInCart false;
  973.             if($cart){
  974.                 $isAbonnementProInCart $this->cart_service->checkIsAbonnementProCart($cart->getId());
  975.             }
  976.             if($abonnement['is_abonnemen_pro'] || $isAbonnementProInCart) { // check is admin in compte abonnement
  977.                 $compteAbonnement $abonnement['compte_abonnement_object'];
  978.                 return $this->twig->render('front/abonnement-pro/account/name-abos.html.twig', [
  979.                     'compteAbonnement' => $compteAbonnement,
  980.                     'isAbonnementProInCart' => $isAbonnementProInCart,
  981.                     'cart' => $cart
  982.                 ]);
  983.             }else{
  984.                 return $user->getFirstname();
  985.             }
  986.         }
  987.         return '';
  988.     }
  989.     public function getNameAbonnementProString($user){
  990.         if(is_object($user)){
  991.             $abonnement $this->cart_service->checkIsAbonnementPro($user);
  992.             // check abonnement in cart
  993.             $cart $this->cart_service->getCartWithSession();
  994.             $isAbonnementProInCart false;
  995.             if($cart){
  996.                 $isAbonnementProInCart $this->cart_service->checkIsAbonnementProCart($cart->getId());
  997.             }
  998.             if($abonnement['is_abonnemen_pro'] || $isAbonnementProInCart) { // check is admin in compte abonnement
  999.                 $compteAbonnement $abonnement['compte_abonnement_object'];
  1000.                 if($isAbonnementProInCart){
  1001.                     return $cart->getAbonnementProCart()->getAbonnement()->getName();
  1002.                 }else{
  1003.                     return $compteAbonnement->getAbonnement()->getName();
  1004.                 }
  1005.             }
  1006.         }
  1007.         return '';
  1008.     }
  1009.     public function getTypeUserAndAboTagGoogle($user){
  1010.         $data = [
  1011.             'user_type' => 'btoc',
  1012.             'subscription_type' => '',
  1013.         ];
  1014.         if(is_object($user)){
  1015.             $abonnement $this->cart_service->checkIsAbonnementPro($user);
  1016.             // check abonnement in cart
  1017.             $cart $this->cart_service->getCartWithSession();
  1018.             $isAbonnementProInCart false;
  1019.             if($cart){
  1020.                 $isAbonnementProInCart $this->cart_service->checkIsAbonnementProCart($cart->getId());
  1021.             }
  1022.             if($abonnement['is_abonnemen_pro'] || $isAbonnementProInCart) { // check is admin in compte abonnement
  1023.                 $compteAbonnement $abonnement['compte_abonnement_object'];
  1024.                 $data['user_type'] = 'btob';
  1025.                 if($isAbonnementProInCart){
  1026.                     if($cart->getAbonnementProCart()->getAbonnement()) {
  1027.                         if ($cart->getAbonnementProCart()->getAbonnement()->getTypeAbonnement() == AbonnementPro::TYPE_ENTREPRISE or $cart->getAbonnementProCart()->getAbonnement()->getTypeAbonnement() == AbonnementPro::TYPE_TEAM) {
  1028.                             $data['subscription_type'] = 'business';
  1029.                         } else {
  1030.                             $data['subscription_type'] = 'plus';
  1031.                         }
  1032.                     }
  1033.                 }else{
  1034.                     if($compteAbonnement->getAbonnement()->getTypeAbonnement() == AbonnementPro::TYPE_ENTREPRISE or $compteAbonnement->getAbonnement()->getTypeAbonnement() == AbonnementPro::TYPE_TEAM){
  1035.                         $data['subscription_type'] = 'business';
  1036.                     }else{
  1037.                         $data['subscription_type'] = 'plus';
  1038.                     }
  1039.                 }
  1040.             }
  1041.         }
  1042.         return $data;
  1043.     }
  1044.     public function checkIsAbonnementEntreprise($user){
  1045.         if(is_object($user)){
  1046.             $abonnement $this->cart_service->checkIsAbonnementPro($user);
  1047.             if($abonnement['is_abonnemen_pro']) { // check is admin in compte abonnement
  1048.                 $compteAbonnement $abonnement['compte_abonnement_object'];
  1049.                 if($compteAbonnement->getAbonnement()->getTypeAbonnement() == AbonnementPro::TYPE_ENTREPRISE){
  1050.                     return true;
  1051.                 }
  1052.             }
  1053.         }
  1054.         return false;
  1055.     }
  1056.     public function getFactureAbonnementByItemCommande($commande){
  1057.         $facture $this->em->getRepository(CompteAbonnementProCommandesFactures::class)->findByCommande($commande);
  1058.         return $facture;
  1059.     }
  1060.     public function formatPrixSpecifique($prix=0.00){
  1061.         $prix number_format((float)$prix,2);
  1062.         $tab explode('.',$prix);
  1063.         return $tab;
  1064.     }
  1065.     public function facturedateDiff($dateFirst,$dateLast){
  1066.         $array = array();
  1067.         if($dateFirst && $dateFirst && is_object($dateFirst->getStartAt())&& is_object($dateLast->getStartAt())){
  1068.             $date1 $dateFirst->getStartAt();
  1069.             $date2 $dateLast->getStartAt();
  1070.             $iterval $date2->diff($date1);
  1071.             $array = array();
  1072.             $beginYears =  (int)$date1->format('Y');
  1073.             $beginMounth =  (int)$date1->format('m');
  1074.             $mounthDiff = (int)$iterval->format('%m') + ((int)$iterval->format('%d') > 0) + ((int)$iterval->format('%y') * 12)  +  $beginMounth;
  1075.             $intl = new \IntlDateFormatter('fr', \IntlDateFormatter::LONG, \IntlDateFormatter::NONEnullnull'MMMM YYYY');
  1076.             for ($i=$beginMounth$i<=$mounthDiff;$i++){
  1077.                 $date = new \DateTime($beginYears.'-'.$beginMounth.'-01');
  1078.                 $array[$beginYears.'-'.$beginMounth.'-01'] = ucfirst($intl->format($date));
  1079.                 if($beginMounth 12 >=1){
  1080.                     $beginMounth 1;
  1081.                     $beginYears $beginYears 1;
  1082.                 }else{
  1083.                     $beginMounth++;
  1084.                 }
  1085.             }
  1086.             $array array_reverse($array);
  1087.         }
  1088.         return $this->twig->render('front/abonnement-pro/account/consommation/factureDateDiff.html.twig', [
  1089.             'dateFacture'=>$array
  1090.         ]);
  1091.     }
  1092.     public function getArticlesRss(){
  1093.         $arrContextOptions=array(
  1094.             "ssl"=>array(
  1095.                 "verify_peer"=>false,
  1096.                 "verify_peer_name"=>false,
  1097.             ),
  1098.         );
  1099.         $xml file_get_contents('http://blog.copees.com/category/articles/feed/',falsestream_context_create($arrContextOptions));
  1100.         $array= array();
  1101.         if($xml){
  1102.             libxml_use_internal_errors(true);
  1103.             $sxe simplexml_load_string($xml);
  1104.             if (!$sxe) {
  1105.                 return $array;
  1106.             }
  1107.             $feed = new \SimpleXMLElement($xml);
  1108.             if(isset($feed->channel->item)){
  1109.                 foreach ($feed->channel->item as $item){
  1110.                     $array[] = array(
  1111.                         'title' => $item->title,
  1112.                         'link' => $item->link,
  1113.                         'image' => isset($item->post_thumbnail->url)? $item->post_thumbnail->url :'',
  1114.                         'description' => substr ($item->description,0,strpos($item->description'<p>'1))
  1115.                     );
  1116.                 }
  1117.             }
  1118.         }
  1119.         return $array;
  1120.     }
  1121.     public function imagePdfExist($file){
  1122.         if(file_exists$this->params->get('fileImage_directory').'/'.$file)){
  1123.            return true;
  1124.         }
  1125.         return false;
  1126.     }
  1127.     public function productPdfImageExist($file){
  1128.         if(file_exists$this->params->get('productPdf_directory').'/'.$file)){
  1129.             return true;
  1130.         }
  1131.         return false;
  1132.     }
  1133.     public function fileDocClientExist($file){
  1134.         if(file_exists$this->params->get('uploads_directory').'/docClient/'.$file)){
  1135.             return true;
  1136.         }
  1137.         return false;
  1138.     }
  1139.     public function displayErreurOptionNotSelect(){
  1140.         $data $this->cart_service->checkOptionSelectReluire();
  1141.         $html '';
  1142.         if(!empty($data)){
  1143.             foreach ($data as $key => $item){
  1144.                 if(isset($item['valueReluire'])){
  1145.                     $html "<p>".$item['valueReluire'] ." ".$item['key']." </p>";
  1146.                 }else{
  1147.                     $html "<p>".$item['value'] ." ".$item['key']." </p>";
  1148.                 }
  1149.             }
  1150.         }
  1151.         return $html;
  1152.     }
  1153.     public function getNameFormat($id_format)
  1154.     {
  1155.         $format $this->em->getRepository(Attribut::class)->find($id_format);
  1156.         $string '';
  1157.         if($format){
  1158.             if(in_array($id_format,array(2,3))){
  1159.                 $string =  lcfirst($format->getName());
  1160.             }else{
  1161.                 $string =  $format->getName();
  1162.             }
  1163.         }
  1164.         return $string;
  1165.     }
  1166.     // nb_desiner
  1167.     public function getNamePapierGrammage($id_grammage)
  1168.     {
  1169.         $grammage $this->em->getRepository(Attribut::class)->find($id_grammage);
  1170.         $string '';
  1171.         if($grammage){
  1172.             $string =  $grammage->getNamePapier();
  1173.         }
  1174.         return $string;
  1175.     }
  1176.     public function getNameProduct($idProduct)
  1177.     {
  1178.         $product $this->em->getRepository(Product::class)->find((int)$idProduct);
  1179.         $string '';
  1180.         if($product){
  1181.             $string =  $product->getTypeProductName();
  1182.         }
  1183.         return $string;
  1184.     }
  1185.     public function getProductTypeById($idProduct)
  1186.     {
  1187.         $product $this->em->getRepository(Product::class)->find((int)$idProduct);
  1188.         $type '';
  1189.         if($product){
  1190.             $type =  $product->getTypeProduct();
  1191.         }
  1192.         return $type;
  1193.     }
  1194.     public function getProductById($idProduct)
  1195.     {
  1196.         $product $this->em->getRepository(Product::class)->find((int)$idProduct);
  1197.         return $product;
  1198.     }
  1199.     public function getAttribute($idAttr)
  1200.     {
  1201.         $attr $this->em->getRepository(Attribut::class)->find((int)$idAttr);
  1202.         return $attr;
  1203.     }
  1204.     public function getPrixTtcByQtyFinition($price,$finition)
  1205.     {
  1206.         if($finition== CartDetail::FINITION_GLACE){
  1207.             $price $price + ($priceCartDetail::POURCENTAGE_FINITION_GLACE);
  1208.         }else if ($finition== CartDetail::FINITION_MATE){
  1209.             $price $price + ($priceCartDetail::POURCENTAGE_FINITION_MATE);
  1210.         }else if ($finition== CartDetail::FINITION_REPOSITIONALBLE){
  1211.             $price $price + ($priceCartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE);
  1212.         }else if ($finition== CartDetail::FINITION_TRANSPARENT){
  1213.             $price $price + ($priceCartDetail::POURCENTAGE_FINITION_TRANSPARENT);
  1214.         }else if ($finition== CartDetail::FINITION_SoftTouch){
  1215.             $price $price + ($priceCartDetail::POURCENTAGE_FINITION_SoftTouch);
  1216.         }else if ($finition== CartDetail::FINITION_Pelliculemat){
  1217.             $price $price + ($priceCartDetail::POURCENTAGE_FINITION_Pelliculemat);
  1218.         }else if ($finition== CartDetail::FINITION_PelliculeBrillant){
  1219.             $price $price + ($priceCartDetail::POURCENTAGE_FINITION_PelliculeBrillant);
  1220.         }
  1221.         return $price;
  1222.     }
  1223.     public function getPrixTtcByUserTemplate($id)
  1224.     {
  1225.         $userTemplate $this->em->getRepository(NbUserTemplates::class)->find($id);
  1226.         $priceProductAttr $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($userTemplate->getProductAttribute()->getId(), $userTemplate->getQuantite());
  1227.         if($userTemplate->getFinition() == CartDetail::FINITION_GLACE){
  1228.             $price $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + (($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_FINITION_GLACE);
  1229.         }else if($userTemplate->getFinition() == CartDetail::FINITION_MATE){
  1230.             $price $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + (($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_FINITION_MATE);
  1231.         }
  1232.         return $price;
  1233.     }
  1234.     // nb_desiner
  1235.     public function sortArrayByField($content$sort_by)
  1236.     {
  1237.         $array = array();
  1238.         if (is_a($content'Doctrine\ORM\PersistentCollection')) {
  1239.             $content $content->toArray();
  1240.         }
  1241.         if (!is_array($content)) {
  1242.             throw new \InvalidArgumentException('Variable passed to the sortByField filter is not an array');
  1243.         }else{
  1244.             foreach ($content as $item){
  1245.                 $array[$item[$sort_by]] = $item;
  1246.             }
  1247.         }
  1248.         if(empty($array))
  1249.             $array $content;
  1250.         uksort($array"strnatcmp");
  1251.         return $array;
  1252.     }
  1253.     public function getTitlePage($pathname){
  1254.         $pageMeta  $this->em->getRepository(Seo::class)->findOneByNameRoute($pathname);
  1255.         if($pageMeta){
  1256.             $str = !empty($pageMeta->getMetaTitle())?$pageMeta->getMetaTitle():'Copees';
  1257.         }else{
  1258.             $str 'Copees';
  1259.         }
  1260.         return $str;
  1261.     }
  1262.     public function getmetaDesciption($pathname){
  1263.         $pageMeta  $this->em->getRepository(Seo::class)->findOneByNameRoute($pathname);
  1264.         if($pageMeta){
  1265.             $str = !empty($pageMeta->getMetaDescription())?$pageMeta->getMetaDescription():'';
  1266.         }else{
  1267.             $str '';
  1268.         }
  1269.         return $str;
  1270.     }
  1271.     public function number_format($number){
  1272.         return number_format((float)$number,2);
  1273.     }
  1274.     public function getStatusCommande($status)
  1275.     {
  1276.         $string '';
  1277.         $color '';
  1278.         if($status == Stats::TERMINER){
  1279.             $string 'Terminé';
  1280.             $color 'color-green';
  1281.         }
  1282.         if($status == Stats::ENCOURT){
  1283.             $string 'En cours de préparation';
  1284.             $color 'color-orange';
  1285.         }
  1286.         if($status == Stats::TRAITEMENT_SAV){
  1287.             $string 'Traitement SAV';
  1288.             $color 'color-red';
  1289.         }
  1290.         return $string;
  1291.     }
  1292.     public function getCurrentStatusMerciFacteur($idSend)
  1293.     {
  1294.         $trakingMerciFacteur $this->merciFacteurService->currentStatusMerciFacteur($idSend);
  1295.         if($trakingMerciFacteur) {
  1296.             if (array_key_exists('statutPrintEnvoi'$trakingMerciFacteur)) {
  1297.                 return $trakingMerciFacteur['statutPrintEnvoi'];
  1298.             }
  1299.         }
  1300.     }
  1301.     public function getStatusString($status)
  1302.     {
  1303.         $string '';
  1304.         $color '';
  1305.         if($status == Stats::TERMINER){
  1306.             $string 'Payé';
  1307.             $color 'color-green';
  1308.         }
  1309.         if($status == Stats::ENCOURT){
  1310.             $string 'En cours de traitement';
  1311.             $color 'color-orange';
  1312.         }
  1313.         if($status == Stats::TRAITEMENT_SAV){
  1314.             $string 'Traitement SAV';
  1315.             $color 'color-red';
  1316.         }
  1317.         return "<span class='".$color."'>".$string."</span>";
  1318.     }
  1319.     public function getRestTemps($dateEnd,$order)
  1320.     {
  1321.         if($order->getCarrier()){
  1322.             if($order->getCarrier()->getNum() == Carrier::STUART){
  1323.                 $dateDebut = new \DateTime('now');
  1324.                 $diff $dateEnd->getTimestamp() - $dateDebut->getTimestamp();
  1325.                 if($diff ) {
  1326.                     $heurs 60 60;
  1327.                     if ($diff 60) {
  1328.                         $temps $diff 's';
  1329.                         $color 'color-red';
  1330.                     } else if ($diff $heurs) {
  1331.                         $min $diff 60;
  1332.                         if ($min 11) {
  1333.                             $color 'color-red';
  1334.                         } elseif ($min 10 && $min 45) {
  1335.                             $color 'color-orange';
  1336.                         } else {
  1337.                             $color 'color-green';
  1338.                         }
  1339.                         $temps = (int)$min 'min';
  1340.                     } else {
  1341.                         $h $diff $heurs;
  1342.                         $diffH $diff $heurs;
  1343.                         $min $diffH 60;
  1344.                         $temps = (int)$h 'h' . (($min 0) ? (int)$min '');
  1345.                         $color 'color-green';
  1346.                     }
  1347.                 }else{
  1348.                     $color =  'color-green';
  1349.                     $temps 0;
  1350.                 }
  1351.                 return "<span class='".$color."'>".$temps."</span>";
  1352.             }else{
  1353.                 return '';
  1354.             }
  1355.         }
  1356.         return '';
  1357.     }
  1358.     public function getDetailProduct($id_detail_product)
  1359.     {
  1360.         $orderrDetail $this->em->getRepository(OrderDetail::class)->find($id_detail_product);
  1361.         $product_attribute $orderrDetail->getProductAttribute();
  1362.         $array = array();
  1363.         $arrayReluire = array();
  1364.         if($product_attribute){
  1365.             if(in_array($orderrDetail->getTypeProduct(),array(Product::SIMPLE,Product::PAPIER,Product::PAPIER_POSTE))) {
  1366.                 if ($orderrDetail->getSouhaiteStr()) {
  1367.                     $array[] = $this->trans->trans('Type',[],'adminTranslate') .' '$this->trans->trans($this->cart_service->getSouhaiteStr($orderrDetail->getSouhaiteStr()),[],'productTranslate') . ' ';
  1368.                 }
  1369.             }else{
  1370. //                if ($orderrDetail->getIsTrait()) {
  1371. //                    $array[] = 'Document avec traits de coupe ' ;
  1372. //                }else{
  1373. //                    $array[] = 'Document sans traits de coupe ' ;
  1374. //                }
  1375.             }
  1376.             if($product_attribute->getFormat()){
  1377.                 if ($product_attribute->getProduct()->getTypeProduct() == Product::STICKERS_AUTOCOLLANT) {
  1378.                     $array[] = ' '.$this->trans->trans('Coupe',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getFormat()->getName(),[],'productTranslate').' ';
  1379.                 }else{
  1380.                     $array[] = ' '.$this->trans->trans('Format',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getFormat()->getName(),[],'productTranslate').' ';
  1381.                 }
  1382.             }
  1383.             if(in_array($orderrDetail->getProduct()->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
  1384.                 $array[] = ' '.$this->trans->trans('Format',[],'adminTranslate').' '$orderrDetail->getFormatLargeur() . $this->trans->trans('cm (Largeur)',[],'adminTranslate').' | '.$orderrDetail->getFormatHauteur() .' '.$this->trans->trans('cm (Hauteur)',[],'adminTranslate'). ' ';
  1385.             }
  1386.             if($product_attribute->getGramage() && $product_attribute->getProduct()->getTypeProduct() == Product::PAPIER)
  1387.                 $array[] = ' '.$this->trans->trans('Gramage',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getGramage()->getNamePapier(),[],'productTranslate').' '.$this->trans->trans($product_attribute->getGramage()->getName(),[],'productTranslate').' ';
  1388.             else if($product_attribute->getGramage() && ($product_attribute->getProduct()->getTypeProduct() == Product::KAKEMONO or $product_attribute->getProduct()->getTypeProduct() == Product::PHOTOS  or $product_attribute->getProduct()->getTypeProduct() == Product::PHOTOS_ENCADRE))
  1389.                 $array[] = ' '.$this->trans->trans('Papier',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getGramage()->getName(),[],'productTranslate').' '.$this->trans->trans($product_attribute->getGramage()->getNamePapier(),[],'productTranslate').' ';
  1390.             else if($product_attribute->getGramage()) {
  1391.                 if ($product_attribute->getProduct()->getTypeProduct() == Product::STICKERS_AUTOCOLLANT) {
  1392.                     $array[] = ' '.$this->trans->trans('Format',[],'adminTranslate').' ' $this->trans->trans($product_attribute->getGramage()->getName(),[],'productTranslate') . ' ';
  1393.                 }else{
  1394.                     $array[] = ' '.$this->trans->trans('Gramage',[],'adminTranslate').' ' $this->trans->trans($product_attribute->getGramage()->getName(),[],'productTranslate') . ' ';
  1395.                 }
  1396.             }
  1397.             if(in_array($orderrDetail->getProduct()->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
  1398.                 if ($product_attribute->getTypeFormat())
  1399.                     $array[] = ' '.$this->trans->trans('Coupe',[],'adminTranslate').' ' $this->trans->trans($product_attribute->getTypeFormat()->getName(),[],'productTranslate') . ' ';
  1400.             }else {
  1401.                 if ($product_attribute->getTypeFormat())
  1402.                     $array[] = ' '.$this->trans->trans('Composition',[],'adminTranslate').' ' $this->trans->trans($product_attribute->getTypeFormat()->getName(),[],'productTranslate') . ' ';
  1403.             }
  1404.             if($product_attribute->getSpecificite())
  1405.                 $array[] = ' '.$this->trans->trans('Coupe',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getSpecificite()->getName(),[],'productTranslate').' ';
  1406.             if($product_attribute->getTypeCouleur()) {
  1407.                 if (in_array($orderrDetail->getTypeProduct(), [Product::PHOTOS_ENCADRE])) {
  1408.                     $array[] = ' '.$this->trans->trans('Couleur du cadre',[],'adminTranslate').' ' $this->trans->trans($product_attribute->getTypeCouleur()->getName(),[],'productTranslate') . ' ';
  1409.                 } else {
  1410.                     $array[] = ' '.$this->trans->trans('Couleur',[],'adminTranslate').' ' $this->trans->trans($product_attribute->getTypeCouleur()->getName(),[],'productTranslate') . ' ';
  1411.                 }
  1412.             }
  1413.             if($product_attribute->getTaille())
  1414.                 $array[] = ' '.$this->trans->trans('Taille',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getTaille()->getName(),[],'productTranslate').' ';
  1415.             if($product_attribute->getZoneImpression())
  1416.                 $array[] = ' '.$this->trans->trans('Zone d’impression',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getZoneImpression()->getName(),[],'productTranslate').' ';
  1417.             if($product_attribute->getNbrCouleur()) {
  1418.                 if (in_array($orderrDetail->getTypeProduct(), [Product::PHOTOS_ENCADRE])) {
  1419.                     $array[] = ' '.$this->trans->trans('Effets',[],'adminTranslate').' ' $this->trans->trans($product_attribute->getNbrCouleur()->getName(),[],'productTranslate') . ' ';
  1420.                 } else {
  1421.                     $array[] = ' '.$this->trans->trans('Nombre de couleur du design',[],'adminTranslate').' ' $this->trans->trans($product_attribute->getNbrCouleur()->getName(),[],'productTranslate') . ' ';
  1422.                 }
  1423.             }
  1424.             if($product_attribute->getTypeImpression())
  1425.                 $array[] = ' '.$this->trans->trans('Type d\'impression',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getTypeImpression()->getName(),[],'productTranslate').' ';
  1426.             if($product_attribute->getSupportSuspension())
  1427.                 $array[] = ' '.$this->trans->trans('Support de suspension',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getSupportSuspension()->getName(),[],'productTranslate').' ';
  1428.             if($product_attribute->getTypeCarton())
  1429.                 $array[] =' '.$this->trans->trans('Type carton :',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getTypeCarton()->getName(),[],'productTranslate').' ';
  1430.             if($product_attribute->getOeille())
  1431.                 $array[] = ' '.$this->trans->trans('Oeille :',[],'adminTranslate').' '.$this->trans->trans($product_attribute->getOeille()->getName(),[],'productTranslate').' ';
  1432.             if ($orderrDetail->getIsPlusVerification()) {
  1433.                 $array[] = ' '.$this->trans->trans('Avec option de vérification',[],'adminTranslate').' ';
  1434.             }
  1435.             if ($orderrDetail->getIsPlusBordsArrondis()) {
  1436.                 $array[] = ' '.$this->trans->trans('Bords arrondis',[],'adminTranslate').' ';
  1437.             }
  1438.             if ($orderrDetail->getIsPlusPlastification()) {
  1439.                 $array[] = ' '.$this->trans->trans('Avec Plastification',[],'adminTranslate').' ';
  1440.             }
  1441.             if ($orderrDetail->getIsEnveloppe()) {
  1442.                 $array[] = ' '.$this->trans->trans('Avec Enveloppe',[],'adminTranslate').' ';
  1443.             }
  1444.             if (!in_array($orderrDetail->getTypeProduct(), array(Product::SIMPLEProduct::PAPIERProduct::PAPIER_POSTE))) {
  1445.                 if ($orderrDetail->getFinition() == CartDetail::FINITION_GLACE) {
  1446.                     $array[] = ' '.$this->trans->trans('Finition glacée',[],'adminTranslate').' ';
  1447.                 }
  1448.                 if ($orderrDetail->getFinition() == CartDetail::FINITION_MATE) {
  1449.                     $array[] = ' '.$this->trans->trans('Finition mate',[],'adminTranslate').' ';
  1450.                 }
  1451.                 if ($orderrDetail->getFinition() == CartDetail::FINITION_REPOSITIONALBLE) {
  1452.                     $array[] = ' '.$this->trans->trans('Finition Repositionnable',[],'adminTranslate').' ';
  1453.                 }
  1454.                 if ($orderrDetail->getFinition() == CartDetail::FINITION_TRANSPARENT) {
  1455.                     $array[] = ' '.$this->trans->trans('Finition Transparent',[],'adminTranslate').' ';
  1456.                 }
  1457.                 if ($orderrDetail->getFinition() == CartDetail::FINITION_SoftTouch) {
  1458.                     $array[] = ' '.$this->trans->trans('Finition Soft Touch',[],'adminTranslate').' ';
  1459.                 }
  1460.                 if ($orderrDetail->getFinition() == CartDetail::FINITION_Pelliculemat) {
  1461.                     $array[] = ' '.$this->trans->trans('Finition Pelliculé mat',[],'adminTranslate').' ';
  1462.                 }
  1463.                 if ($orderrDetail->getFinition() == CartDetail::FINITION_PelliculeBrillant) {
  1464.                     $array[] = ' '.$this->trans->trans('Finition Pelliculé Brillant',[],'adminTranslate').' ';
  1465.                 }
  1466.             }
  1467.             if($orderrDetail->getProduct()->getIsColorLab()){
  1468.             }else {
  1469.                 if ($orderrDetail->getAccessoires()) {
  1470.                     foreach ($orderrDetail->getAccessoires() as $item) {
  1471.                         if ($item->getAccessoire()) {
  1472.                             if ($item->getAccessoire()->getTypeAccessoire() == Accessoire::COULEUR) {
  1473.                                 $array[] = $this->trans->trans($item->getAccessoire()->getName(),[],'productTranslate') . ' ';
  1474.                             }
  1475.                         }
  1476.                     }
  1477.                 }
  1478.                 if ($product_attribute->getProduct()->getTypeProduct() != Product::AFFICHE) {
  1479.                     if ($product_attribute->getRectoverso()) {
  1480.                         if ($product_attribute->getRectoverso() == ProductAttribute::RECTO) {
  1481.                             $array[] = ' '.$this->trans->trans('Recto',[],'adminTranslate').' ';
  1482.                         } else {
  1483.                             $array[] = ' '.$this->trans->trans('Recto & Verso',[],'adminTranslate').' ';
  1484.                         }
  1485.                     }
  1486.                 }
  1487.                 if ($orderrDetail->getPetitCote()) {
  1488.                     $array[] = ' '.$this->trans->trans('Petit côté',[],'adminTranslate').' ';
  1489.                 }
  1490.                 if ($orderrDetail->getGrandCote()) {
  1491.                     $array[] = ' '.$this->trans->trans('Grand côté',[],'adminTranslate').' ';
  1492.                 }
  1493.                 if ($orderrDetail->getIsReluire()) {
  1494.                     $array[] = ' '.$this->trans->trans('Reliure',[],'adminTranslate').' ';
  1495.                 }
  1496.                 if ($orderrDetail->getImprimSansMarge()) {
  1497.                     $array[] = ' '.$this->trans->trans('Imprimer sans marges',[],'adminTranslate').' ';
  1498.                 }
  1499.                 if ($orderrDetail->getIsDecoupeDoc()) {
  1500.                     $array[] = ' '.$this->trans->trans('Document avec coupe',[],'adminTranslate').' ';
  1501.                 }
  1502.                 if ($orderrDetail->getIsPlusExpert()) {
  1503.                     $array[] = ' '.$this->trans->trans('Avec Expert Copees',[],'adminTranslate').' ';
  1504.                 }
  1505.                 if ($orderrDetail->getMauvaisFormat() == '1') {
  1506.                     $array[] = ' '.$this->trans->trans('le doc sera imprimer avec un bord blancs de 5mm.',[],'adminTranslate').' ';
  1507.                 }
  1508.                 if (!in_array($orderrDetail->getTypeProduct(), array(Product::SIMPLEProduct::PAPIERProduct::PAPIER_POSTE))) {
  1509.                     if ($orderrDetail->getIsMaCrea()) {
  1510.                         $array[] = ' '.$this->trans->trans('Document importé',[],'adminTranslate').' ';
  1511.                     } else {
  1512.                         $array[] = ' '.$this->trans->trans('Document crée',[],'adminTranslate').' ';
  1513.                     }
  1514.                 }
  1515.             }
  1516.         }
  1517.         if($orderrDetail->getAccessoires()){
  1518.             foreach ($orderrDetail->getAccessoires() as $item){
  1519.                 if($item->getAccessoire()->getTypeAccessoire() == Accessoire::RELUIRE){
  1520.                     $arrayReluire[] = $this->trans->trans($item->getAccessoire()->getName(),[],'productTranslate');
  1521.                     if($item->getPetitCote()){
  1522.                         $arrayReluire[] = ' '.$this->trans->trans('Petit côté',[],'adminTranslate').' ';
  1523.                     }
  1524.                     if($item->getGrandCote()){
  1525.                         $arrayReluire[] = ' '.$this->trans->trans('Grand côté',[],'adminTranslate').' ';
  1526.                     }
  1527.                     if($item->getPapierCovertureMat()){
  1528.                         if($item->getAccessoire()->getTypeReluire() == Accessoire::TYPE_RELUIRE_POINT_METAL){
  1529.                             $arrayReluire[] = ' '.$this->trans->trans('Papier Mat 160g',[],'adminTranslate').' ';
  1530.                         }elseif($item->getAccessoire()->getTypeReluire() == Accessoire::TYPE_RELUIRE_DOS_PIQUEE){
  1531.                             $arrayReluire[] = ' '.$this->trans->trans('Papier Mat 160g',[],'adminTranslate').' ';
  1532.                         }else{
  1533.                             $arrayReluire[] = ' '.$this->trans->trans('Papier 300G Mat',[],'adminTranslate').' ';
  1534.                         }
  1535.                     }
  1536.                     if($item->getPapierCovertureBrillant()){
  1537.                         if($item->getAccessoire()->getTypeReluire() == Accessoire::TYPE_RELUIRE_POINT_METAL) {
  1538.                             $arrayReluire[] = ' '.$this->trans->trans('Papier brillant 160g',[],'adminTranslate').' ';
  1539.                         }elseif($item->getAccessoire()->getTypeReluire() == Accessoire::TYPE_RELUIRE_DOS_PIQUEE) {
  1540.                             $arrayReluire[] = ' '.$this->trans->trans('Papier brillant 160g',[],'adminTranslate').' ';
  1541.                         }else{
  1542.                             $arrayReluire[] = ' '.$this->trans->trans('Papier 300G brillant',[],'adminTranslate').' ';
  1543.                         }
  1544.                     }
  1545.                     if($item->getCouleur()){
  1546.                         $arrayReluire[] =' '.$this->trans->trans('Couleur',[],'adminTranslate').' '$this->trans->trans($item->getAccessoire()->getName(),[],'productTranslate').': '.$this->trans->trans($this->getColor($item->getCouleur()),[],'productTranslate');
  1547.                     }
  1548.                     if($item->getCouleurDos()){
  1549.                         $arrayReluire[] = ' '.$this->trans->trans('Couleur dos:',[],'adminTranslate').' '.$this->getColor($item->getCouleurDos());
  1550.                     }
  1551.                 }
  1552.             }
  1553.         }
  1554.         $str =implode(',',$array);
  1555.         $strReluire = !empty($arrayReluire)? '('.implode(',',$arrayReluire).')':'';
  1556.         return $str.$strReluire;
  1557.     }
  1558.     public function getPourcentage($a,$total){
  1559.         if($a== 0){
  1560.             return 0;
  1561.         }else{
  1562.             $poucentage $total $a ;
  1563.             return round((100 $poucentage),2);
  1564.         }
  1565.     }
  1566.     public function getValByJson($json,$key=null){
  1567.         if(!$key)
  1568.             return json_decode($json,true);
  1569.         $couleur = [];
  1570.         if($json){
  1571.             $couleur json_decode($json,true);
  1572.         }
  1573.         return (isset($couleur[$key]))?$couleur[$key]:null;
  1574.     }
  1575.     public function getPriceTotalTtc($cartId){
  1576.         $cart $this->em->getRepository(Cart::class)->find($cartId);
  1577.         $priceTtc 0;
  1578.         if($cart){
  1579.             if($cart->getIsPromo()){
  1580.                 $priceTtc ="<strike>".number_format((float)$cart->getPrixTtc(),2)."€</strike>".  number_format((float)$cart->getPrixTtcReduction(),2)." €";
  1581.              }else{
  1582.                 $priceTtc =number_format((float)$cart->getPrixTtc(),2) ." €";
  1583.             }
  1584.         }
  1585.         return  $priceTtc;
  1586.     }
  1587.     public function getPriceTotalHt($cartId){
  1588.         $cart $this->em->getRepository(Cart::class)->find($cartId);
  1589.         $priceHt 0;
  1590.         if($cart){
  1591.             if($cart->getIsPromo()){
  1592.                 $priceHt ="<strike>".number_format((float)$cart->getPrixHt(),2)."€</strike>".  number_format((float)$cart->getPrixHtReduction(),2)." €";
  1593.             }else{
  1594.                 $priceHt =number_format((float)$cart->getPrixHt(),2) ." €";
  1595.             }
  1596.         }
  1597.         return $priceHt;
  1598.     }
  1599.     public function checkColor($arrayAcc,$idAcc){
  1600.         foreach ($arrayAcc as $item){
  1601.             if($item->getAccessoire()) {
  1602.                 if ($item->getAccessoire()->getId() == $idAcc && $item->getAccessoire()->getTypeAccessoire() == Accessoire::COULEUR) {
  1603.                     return true;
  1604.                 }
  1605.             }
  1606.         }
  1607.         return false;
  1608.     }
  1609.     public function getAccessoireReluire($cartDetailId){
  1610.         $accReluire $this->em->getRepository(CartDetailAccessoire::class)->getAccessoire(Accessoire::RELUIRE,$cartDetailId);
  1611.         return $accReluire ;
  1612.     }
  1613.     public function displayColorD($cartDetailId ,$id_accessoire,$stringColor){
  1614.         $accReluire $this->em->getRepository(CartDetailAccessoire::class)->getAccessoire(Accessoire::RELUIRE,$cartDetailId);
  1615.         if($accReluire){
  1616.             if($accReluire->getAccessoire()->getId() == $id_accessoire && $accReluire->getCouleurDos() == $stringColor){
  1617.                 return true;
  1618.             }
  1619.         }
  1620.         return false ;
  1621.     }
  1622.     public function displayColorR($cartDetailId ,$id_accessoire,$stringColor){
  1623.         $accReluire $this->em->getRepository(CartDetailAccessoire::class)->getAccessoire(Accessoire::RELUIRE,$cartDetailId);
  1624.         if($accReluire){
  1625.             if($accReluire->getAccessoire()->getId() == $id_accessoire && $accReluire->getCouleur() == $stringColor){
  1626.                 return true;
  1627.             }
  1628.         }
  1629.         return false ;
  1630.     }
  1631.     public function getColor($color){
  1632.         switch ($color){
  1633.             case 'colorBlackDos':
  1634.                 $colorSting 'Noir';
  1635.                 break;
  1636.             case 'colorBlancDos':
  1637.                 $colorSting 'Blanc';
  1638.                 break;
  1639.             case 'colorBlueDos':
  1640.                 $colorSting 'Blue';
  1641.                 break;
  1642.             case 'colorGreenDos':
  1643.                 $colorSting 'Vert';
  1644.                 break;
  1645.             case 'colorRedDos':
  1646.                 $colorSting 'Rouge';
  1647.                 break;
  1648.             case 'colorYellowDos':
  1649.                 $colorSting 'Jaune';
  1650.                 break;
  1651.             case 'colorTransDos':
  1652.                 $colorSting 'Transparent';
  1653.                 break;
  1654.             case 'colorBlackR':
  1655.                 $colorSting 'Noir';
  1656.                 break;
  1657.             case 'colorBlancR':
  1658.                 $colorSting 'Blanc';
  1659.                 break;
  1660.             case 'colorBlueR':
  1661.                 $colorSting 'Blue';
  1662.                 break;
  1663.             case 'colorGreenR':
  1664.                 $colorSting 'Vert';
  1665.                 break;
  1666.             case 'colorRedR':
  1667.                 $colorSting 'Rouge';
  1668.                 break;
  1669.             case 'colorYellowR':
  1670.                 $colorSting 'Jaune';
  1671.                 break;
  1672.             case 'colorTransR':
  1673.                 $colorSting 'Transparent';
  1674.                 break;
  1675.             default:
  1676.                 $colorSting =  "";
  1677.         }
  1678.         return $colorSting ;
  1679.     }
  1680.     public function getproductOptionPapier($cartDetailId ){
  1681.         $cartDetail $this->em->getRepository(CartDetail::class)->find($cartDetailId);
  1682.         if($cartDetail){
  1683.             return $this->twig->render('front/panier/block_option_papier.html.twig', [
  1684.                 'cartDetail' => $cartDetail,
  1685.             ]);
  1686.         }
  1687.         return false ;
  1688.     }
  1689.     public function getproductOptionCarteAndFlyer($cartDetailId ){
  1690.         $cartDetail $this->em->getRepository(CartDetail::class)->find($cartDetailId);
  1691.         if($cartDetail){
  1692.             return $this->twig->render('front/panier/block_option_carte_flyer.html.twig', [
  1693.                 'cartDetail' => $cartDetail,
  1694.             ]);
  1695.         }
  1696.         return false ;
  1697.     }
  1698.     public function getproductOptionAffiche($cartDetailId ){
  1699.         $cartDetail $this->em->getRepository(CartDetail::class)->find($cartDetailId);
  1700.         if($cartDetail){
  1701.             return $this->twig->render('front/panier/block_option_affiche.html.twig', [
  1702.                 'cartDetail' => $cartDetail,
  1703.             ]);
  1704.         }
  1705.         return false ;
  1706.     }
  1707.     public function getproductOptionDistribution($distribution ){
  1708.         if(is_object($distribution)){
  1709.             return $this->twig->render('front/panier/block_distribution.html.twig', [
  1710.                 'distribution' => $distribution,
  1711.             ]);
  1712.         }
  1713.         return false ;
  1714.     }
  1715.     public function getPriceDistribution($id){
  1716.         $cart $this->em->getRepository(Cart::class)->find($id);
  1717.         $prixHt 0;
  1718.         $prixTtc 0;
  1719.         if($cart){
  1720.             if (count($cart->getDistributionCart()) > 0) {
  1721.                 foreach ($cart->getDistributionCart() as $detail) {
  1722.                     $prixHt += $detail->getPrixHt();
  1723.                     $prixTtc += $detail->getPrixTtc();
  1724.                 }
  1725.             }
  1726.         }
  1727.         return array(
  1728.             'prixHt' => $prixHt,
  1729.             'prixTtc' => $prixTtc
  1730.         ) ;
  1731.     }
  1732.     public function getInfoOrder($id){
  1733.         $order $this->em->getRepository(Orders::class)->find($id);
  1734.         if($order){
  1735.             return $this->twig->render('front/myaccount/infoOrder.html.twig', [
  1736.                 'order' => $order,
  1737.             ]);
  1738.         }
  1739.         return false ;
  1740.     }
  1741.     public function isProductPoste($id){
  1742.         $cart $this->em->getRepository(Cart::class)->find($id);
  1743.         if($cart){
  1744.             if (count($cart->getCartDetail()) > 0) {
  1745.                 foreach ($cart->getCartDetail() as $detail) {
  1746.                     if($detail->getTypeProduct() == Product::PAPIER_POSTE){
  1747.                         return true;
  1748.                     }
  1749.                 }
  1750.             }
  1751.         }
  1752.         return false ;
  1753.     }
  1754.     public function listFont(){
  1755.         $listFont $this->nbDesigner->getListFonttyle();
  1756.         ksort ($listFont);
  1757.         return $listFont;
  1758.     }
  1759.     public function getTitlePageS($pathname){
  1760.         $pageMeta  $this->em->getRepository(Seo::class)->findOneByNameRoute($pathname);
  1761.         if($pageMeta){
  1762.             $str = !empty($pageMeta->getTitre())?$pageMeta->getTitre():null;
  1763.         }else{
  1764.             $str null;
  1765.         }
  1766.         return $str;
  1767.     }
  1768.     public function getDesciptionS($pathname){
  1769.         $pageMeta  $this->em->getRepository(Seo::class)->findOneByNameRoute($pathname);
  1770.         if($pageMeta){
  1771.             $str = !empty($pageMeta->getContent())?$pageMeta->getContent():null;
  1772.         }else{
  1773.             $str null;
  1774.         }
  1775.         return $str;
  1776.     }
  1777. }
  1778.