<?php
namespace App\Services;
use App\Entity\Abonnement;
use App\Entity\AbonnementPro;
use App\Entity\Attribut;
use App\Entity\Carrier;
use App\Entity\Cart;
use App\Entity\CartDetail;
use App\Entity\CartDetailPhotos;
use App\Entity\CodePromo;
use App\Entity\FilesClient;
use App\Entity\FilesClientCrello;
use App\Entity\FilesClientCrelloCategory;
use App\Entity\Imprimeur;
use App\Entity\NbElements;
use App\Entity\NbFiles;
use App\Entity\NbTemplates;
use App\Entity\NbTextes;
use App\Entity\NbUserTemplates;
use App\Entity\NosCrea;
use App\Entity\PriceProduct;
use App\Entity\Product;
use App\Entity\ProductAttribute;
use App\Entity\TemplatesPage;
use App\Entity\TemplatesPageCategory;
use Spipu\Html2Pdf\Html2Pdf;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Component\Finder\Finder;
use Twig\Environment;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use App\Services\CartService;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use App\Services\AbonnementService;
use Imagick;
class NbDesigner extends AbstractController
{
private $em;
private $flashBag;
private $trans;
private $params;
private $security;
private $session;
private $httpClient;
private $twig;
private $cart_service;
private $abonnementService;
public function __construct(AbonnementService $abonnementService,CartService $cart_service ,Environment $twig,HttpClientInterface $httpClient, ParameterBagInterface $params, Security $security, EntityManagerInterface $em, FlashBagInterface $flashBag, TranslatorInterface $trans, SessionInterface $session)
{
$this->security = $security;
$this->em = $em;
$this->flashBag = $flashBag;
$this->trans = $trans;
$this->params = $params;
$this->session = $session;
$this->httpClient = $httpClient;
$this->twig = $twig;
$this->cart_service = $cart_service;
$this->abonnementService = $abonnementService;
}
public function init($request,$token): array
{
$data = $request->query->all();
$format_id = isset($data['format']) ? $data['format'] : 2;
$product_id = isset($data['product']) ? $data['product'] : 2;
$isPaysage = (isset($data['isPaysage']) && $data['isPaysage'] == 1) ? 1 : 0;
$templates = $this->em->getRepository(NbTemplates::class)->getTemplates($format_id,'ASC',16,0,null,$isPaysage);
$textes = $this->em->getRepository(NbTextes::class)->findBy(array(), array(), 200);
$files = $this->security->getUser() ? $this->em->getRepository(NbFiles::class)->findAll() : array();
$elementShapes = $this->em->getRepository(NbElements::class)->findBy(array('category' => 66), array(), 100);
$elementIcones = $this->em->getRepository(NbElements::class)->findBy(array('category' => 73), array(), 100);
if($token){
$this->session->set('nbToken', $token);
$userTemplate = $this->em->getRepository(NbUserTemplates::class)->findOneBy(array('token' => $this->session->get('nbToken')));
$new =false;
}else {
$userTemplate = new NbUserTemplates();
if ($this->security->getUser())
$userTemplate->setUser($this->security->getUser());
$userTemplate->setToken($this->generateToken(32));
$userTemplate->setName($this->generateToken(10));
$this->em->persist($userTemplate);
$this->session->set('nbToken', $userTemplate->getToken());
$new =true;
}
if($request->get('rectoverso', false)){
$rectoverso = ProductAttribute::VERSO;
$userTemplate->setRectoverso($rectoverso);
} else{
$rectoverso = ProductAttribute::RECTO;
$userTemplate->setRectoverso($rectoverso);
}
$product = $this->em->getRepository(Product::class)->find($product_id);
if($product && $product->getTypeProduct()== Product::AFFICHE){
$typeImpression = $this->getTypeImpression($product_id,$format_id);
$gramage = $this->getGrammageByTypeImpression($product_id,$format_id,isset($typeImpression[0]['id'])?$typeImpression[0]['id']:null);
$qtys = isset($gramage[0]['id']) ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage[0]['id'],$format_id,isset($typeImpression[0]['id'])?$typeImpression[0]['id']:null,ProductAttribute::SANS_PLASTIFICATION,$userTemplate->getFinition()):array();
}else{
$gramage = $this->getGramage($product_id,$format_id,$rectoverso);
$qtys = isset($gramage[0]['id'])?$this->getQtyPosibleByGrammage($gramage[0]['id'],$format_id,$rectoverso,$userTemplate->getFinition()):array();
$typeImpression = false;
}
$this->em->flush();
return array(
'templates' => $templates,
'format_id' => $format_id,
'isPaysage' => $isPaysage,
'gramage' => $gramage,
'typeImpression' => $typeImpression,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'textes' => $textes,
'files' => $files,
'shapes' => $elementShapes,
'icones' => $elementIcones,
'userTemplate' => $userTemplate,
'product_id' => $product_id,
'product' => $product,
'isNew' => $new,
'myTemplates' => $this->cart_service->getListeTemplateSaved($this->security->getUser()),
'myDesign' => $this->em->getRepository(NbUserTemplates::class)->getTemplateNotEmpty($this->security->getUser()),
'rectoverso' => $request->get('rectoverso'),
'imagesCrea' => $images = $this->em->getRepository(NbFiles::class)->findBy(array('token'=>$this->session->get('nbToken'),'isCrea'=>true)),
'images' => $images = $this->em->getRepository(NbFiles::class)->findBy(array('token'=>$this->session->get('nbToken'),'isCrea'=>false))
);
}
public function getQantityVitrophonies($product,$qtys,$formatL=100,$formatH=100){
$surface = $formatL * $formatH;
if(in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
if($surface < 10000 ){
$surface = 10000;
}
foreach ($qtys as &$item){
$item['prixTtc'] = $this->cart_service->updatePriceByCountry( (float)$item['prixTtc'],$product) * $surface;
$item['prixHt'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHt'],$product) * $surface;
$item['prixTtcAbonnementPro'] = $this->cart_service->updatePriceByCountry( (float)$item['prixTtcAbonnementPro'],$product) * $surface;
$item['prixHtAbonnementPro'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHtAbonnementPro'],$product) * $surface;
$item['prixTtcAbonnementTeam'] = $this->cart_service->updatePriceByCountry( (float)$item['prixTtcAbonnementTeam'],$product) * $surface;
$item['prixHtAbonnementTeam'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHtAbonnementTeam'],$product) * $surface;
$item['prixTtcAbonnementEntreprise'] = $this->cart_service->updatePriceByCountry( (float)$item['prixTtcAbonnementEntreprise'],$product) * $surface;
$item['prixHtAbonnementEntreprise'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHtAbonnementEntreprise'],$product) * $surface;
$item['prixPromoTtc'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoTtc'],$product) * $surface;
$item['prixPromoHt'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoHt'],$product) * $surface;
$item['prixPromoTtcAbonnementPro'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoTtcAbonnementPro'],$product) * $surface;
$item['prixPromoHtAbonnementPro'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoHtAbonnementPro'],$product) * $surface;
$item['prixHtAbonnementEntreprise'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHtAbonnementEntreprise'],$product) * $surface;
$item['prixPromoTtcAbonnementTeam'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoTtcAbonnementTeam'],$product) * $surface;
$item['prixPromoHtAbonnementTeam'] = $this->cart_service->updatePriceByCountry( (float)$item['prixPromoHtAbonnementTeam'],$product) * $surface;
$item['prixTtcWithoutPromo'] = $this->cart_service->updatePriceByCountry( (float)$item['prixTtcWithoutPromo'],$product) * $surface;
$item['prixHtWithoutPromo'] = $this->cart_service->updatePriceByCountry( (float)$item['prixHtWithoutPromo'],$product) * $surface;
}
}
return $qtys;
}
// get option and price by product new nb_designer
public function getOptionByProduct($request,$id_product){
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product){
if($product->getIsColorLab()){
$productAttributeDefault = $this->em->getRepository(ProductAttribute::class)->findOneBy(['product'=>$product->getId(),'isDefault'=>1]);
$types = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_FORMAT,null,null,null,null,null,null,null,null,null);
$type = null;
$qtys = $qty = null;
$specificites = $specificite = null;
$typeImpression = $typeImpressions = null ;
$formats = $format = null;
$couleurs = $couleur = null;
$supportSuspensions = $supportSuspension = null;
$typeCartons = $typeCarton = null;
$oeilles = $oeille = null;
$tailles = $taille = null;
$zoneImpressions = $zoneImpression = null;
$nbrCouleurs = $nbrCouleur = null;
$gramages = $gramage = null;
$finition = null;
$isFinitionGlace = null;
$isFinitionMate = null;
$isFinitionTransparent = null;
$isFinitionRepositionalble = null;
$isFinitionSoftTouch = null;
$isFinitionPelliculemat = null;
$isFinitionPelliculeBrillant = null;
$verification = null;
$bordsArrondis = null;
$plastification = null;
$formatL = 100;
$formatH = 100;
if($types){
if($productAttributeDefault){
$type = $productAttributeDefault->getTypeFormat()->getId();
}else {
$type = $types[0];
}
$formats = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,$type['id'],null,null,null,null,null);
$specificites = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SPECIFICITE,null,null,null,$type['id'],null,null,null,null,null);
if($types && in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
$isFinitionGlace = $type['isFinitionGlasse'];
$isFinitionMate = $type['isFinitionMate'];
$isFinitionRepositionalble = $type['isFinitionRepositionalble'];
$isFinitionTransparent = $type['isFinitionTransparent'];
$isFinitionSoftTouch = $type['isFinitionSoftTouch'];
$isFinitionPelliculemat = $type['isFinitionPelliculemat'];
$isFinitionPelliculeBrillant = $type['isFinitionPelliculeBrillant'];
if( $isFinitionGlace ){
$finition = CartDetail::FINITION_GLACE;
}elseif ($isFinitionMate){
$finition = CartDetail::FINITION_MATE;
}elseif ($isFinitionRepositionalble){
$finition = CartDetail::FINITION_REPOSITIONALBLE;
}elseif ($isFinitionTransparent){
$finition = CartDetail::FINITION_TRANSPARENT;
}elseif ($isFinitionSoftTouch){
$finition = CartDetail::FINITION_SoftTouch;
}elseif ($isFinitionPelliculemat){
$finition = CartDetail::FINITION_Pelliculemat;
}elseif ($isFinitionTransparent){
$finition = CartDetail::FINITION_TRANSPARENT;
}else{
$finition = null;
}
$verification = CartDetail::VERIFICATION_CHECKED;
$bordsArrondis = CartDetail::BORDS_ARRONDIS_NOT_CHECKED;
$plastification = CartDetail::PLASTIFICATION_NOT_CHECKED;
}else{
if($formats){
if($productAttributeDefault){
$format = $productAttributeDefault->getFormat()->getId();
}else {
$format = $formats[0];
}
$isFinitionGlace = $format['isFinitionGlasse'];
$isFinitionMate = $format['isFinitionMate'];
$isFinitionRepositionalble = $format['isFinitionRepositionalble'];
$isFinitionTransparent = $format['isFinitionTransparent'];
$isFinitionSoftTouch = $format['isFinitionSoftTouch'];
$isFinitionPelliculemat = $format['isFinitionPelliculemat'];
$isFinitionPelliculeBrillant = $format['isFinitionPelliculeBrillant'];
if( $isFinitionGlace ){
$finition = CartDetail::FINITION_GLACE;
}elseif ($isFinitionMate){
$finition = CartDetail::FINITION_MATE;
}elseif ($isFinitionRepositionalble){
$finition = CartDetail::FINITION_REPOSITIONALBLE;
}elseif ($isFinitionTransparent){
$finition = CartDetail::FINITION_TRANSPARENT;
}elseif ($isFinitionSoftTouch){
$finition = CartDetail::FINITION_SoftTouch;
}elseif ($isFinitionPelliculemat){
$finition = CartDetail::FINITION_Pelliculemat;
}elseif ($isFinitionTransparent){
$finition = CartDetail::FINITION_TRANSPARENT;
}else{
$finition = null;
}
$verification = CartDetail::VERIFICATION_CHECKED;
$bordsArrondis = CartDetail::BORDS_ARRONDIS_NOT_CHECKED;
$plastification = CartDetail::PLASTIFICATION_NOT_CHECKED;
}
}
if($specificites){
if($productAttributeDefault){
$specificite = $productAttributeDefault->getSpecificite()->getId();
}else {
$specificite = $specificites[0];
}
}
$couleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format['id']:null,null,null,$type['id'],$specificite?$specificite['id']:null,null,null,null,null);
if($couleurs){
if($productAttributeDefault){
$couleur = $productAttributeDefault->getTypeCouleur()->getId();
}else {
$couleur = $couleurs[0];
}
}
$tailles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format['id']:null,null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,null,null,null);
if($tailles){
if($productAttributeDefault){
$taille = $productAttributeDefault->getTaille()->getId();
}else {
$taille = $tailles[0];
}
}
$zoneImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format['id']:null,null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,null,null);
if($zoneImpressions){
if($productAttributeDefault){
$zoneImpression = $productAttributeDefault->getZoneImpression()->getId();
}else {
$zoneImpression = $zoneImpressions[0];
}
}
$nbrCouleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format['id']:null,null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,null);
if($nbrCouleurs){
if($productAttributeDefault){
$nbrCouleur = $productAttributeDefault->getNbrCouleur()->getId();
}else {
$nbrCouleur = $nbrCouleurs[0];
}
}
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format['id']:null,null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($gramages){
if($productAttributeDefault){
$gramage = $productAttributeDefault->getGramage()->getId();
}else {
$gramage = $gramages[0];
}
}
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format['id']:null,$gramage?$gramage['id']:null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($supportSuspensions){
if($productAttributeDefault){
$supportSuspension = $productAttributeDefault->getSupportSuspension()->getId();
}else {
$supportSuspension = $supportSuspensions[0];
}
}
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format['id']:null,$gramage?$gramage['id']:null,null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeImpressions){
if($productAttributeDefault){
$typeImpression = $productAttributeDefault->getTypeImpression()->getId();
}else {
$typeImpression = $typeImpressions[0];
}
}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeCartons){
if($productAttributeDefault){
$typeCarton = $productAttributeDefault->gettypeCarton()->getId();
}else {
$typeCarton = $typeCartons[0];
}
}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type['id'],$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
if($oeilles){
if($productAttributeDefault){
$oeille = $productAttributeDefault->getOeille()->getId();
}else {
$oeille = $oeilles[0];
}
}
$qtys1 = $this->getQtyPosible($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
$qty = isset($qtys1['qtys'][0]['qty'])?$qtys1['qtys'][0]['qty']:null;
$qtys = $this->getQantityVitrophonies($product,$qtys1['qtys'],$formatL,$formatH);
$qtysPlus = $this->getQantityVitrophonies($product,$qtys1['qtysPlus'],$formatL,$formatH);
$qtysTeam = $this->getQantityVitrophonies($product,$qtys1['qtysTeam'],$formatL,$formatH);
}
return array(
'product' => $product,
'types' => $types,
'type' => $type,
'formats' => $formats,
'format' => $format,
'specificites' => $specificites,
'specificite' => $specificite,
'couleurs' => $couleurs,
'couleur' => $couleur,
'tailles' => $tailles,
'taille' => $taille,
'zoneImpressions' => $zoneImpressions,
'zoneImpression' => $zoneImpression,
'nbrCouleurs' => $nbrCouleurs,
'nbrCouleur' => $nbrCouleur,
'typeImpressions' => $typeImpressions,
'typeImpression' => $typeImpression,
'supportSuspensions' => $supportSuspensions,
'supportSuspension' => $supportSuspension,
'typeCartons' => $typeCartons,
'typeCarton' => $typeCarton,
'oeilles' => $oeilles,
'oeille' => $oeille,
'gramages' => $gramages,
'gramage' => $gramage,
'isFinitionGlace' => $isFinitionGlace,
'isFinitionMate' => $isFinitionMate,
'isFinitionRepositionalble' => $isFinitionRepositionalble,
'isFinitionTransparent' => $isFinitionTransparent,
'isFinitionSoftTouch' => $isFinitionSoftTouch,
'isFinitionPelliculemat' => $isFinitionPelliculemat,
'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
'finition' => $finition,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'formatL' => $formatL,
'formatH' => $formatH,
'qtys' => $qtys,
'qtysPlus' => $qtysPlus,
'qtysTeam' => $qtysTeam,
'qty' => $qty,
'price' => $this->getPriceColorLab($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$qty,null,null,null,null,null,null,null,$supportSuspension,$formatL,$formatH,$typeCarton,$oeille),
);
}
else{
$typeImpression_id = null;
$productAttributeDefault = $this->em->getRepository(ProductAttribute::class)->findOneBy(['product'=>$product->getId(),'isDefault'=>1]);
$formats = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,null,null,null,null,null,null);
if($productAttributeDefault){
$format_id = $productAttributeDefault->getFormat()->getId();
foreach ($formats as $formatItem){
if($formatItem['id'] == $format_id){
$format = $formatItem;
}
}
$rectoverso = $productAttributeDefault->getRectoverso();
}else{
if($product->getTypeProduct() == Product::CARTE){
$format = isset($formats[1]) ? $formats[1] : $formats[0] ;
}else{
$format = $formats[0];
}
$format_id = $format['id'];
if($product->getIsRecto()){
$rectoverso = ProductAttribute::RECTO;
}elseif ($product->getIsRectoVerso()){
$rectoverso = ProductAttribute::VERSO;
}else{
$rectoverso = ProductAttribute::RECTO;
}
}
$isFinitionGlace = $format['isFinitionGlasse'];
$isFinitionMate = $format['isFinitionMate'];
$isFinitionRepositionalble = $format['isFinitionRepositionalble'];
$isFinitionTransparent = $format['isFinitionTransparent'];
$isFinitionSoftTouch = $format['isFinitionSoftTouch'];
$isFinitionPelliculemat = $format['isFinitionPelliculemat'];
$isFinitionPelliculeBrillant = $format['isFinitionPelliculeBrillant'];
if( $isFinitionGlace ){
$finition = CartDetail::FINITION_GLACE;
}elseif ($isFinitionMate){
$finition = CartDetail::FINITION_MATE;
}elseif ($isFinitionRepositionalble){
$finition = CartDetail::FINITION_REPOSITIONALBLE;
}elseif ($isFinitionTransparent){
$finition = CartDetail::FINITION_TRANSPARENT;
}elseif ($isFinitionSoftTouch){
$finition = CartDetail::FINITION_SoftTouch;
}elseif ($isFinitionPelliculemat){
$finition = CartDetail::FINITION_Pelliculemat;
}elseif ($isFinitionPelliculeBrillant){
$finition = CartDetail::FINITION_PelliculeBrillant;
}else{
$finition = null;
}
if($product && $product->getTypeProduct()== Product::AFFICHE){
$typeImpression = $this->getTypeImpression($id_product,$format_id);
$typeImpression_id = isset($typeImpression[0]['id'])?$typeImpression[0]['id']:null;
$gramage = $this->getGrammageByTypeImpression($id_product,$format_id,$typeImpression_id);
if($productAttributeDefault) {
$gramage_id = $productAttributeDefault->getGramage()->getId();
}else{
$gramage_id = isset($gramage[0]['id']) ? $gramage[0]['id'] : null;
}
$qtys = isset($gramage[0]['id']) ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id,$format_id,$typeImpression_id,ProductAttribute::SANS_PLASTIFICATION,$finition):array();
}else{
$gramage = $this->getGramage($id_product,$format_id,$rectoverso);
if($productAttributeDefault) {
$gramage_id = $productAttributeDefault->getGramage()->getId();
}else{
$gramage_id = isset($gramage[0]['id']) ? $gramage[0]['id'] : null;
}
$qtys = isset($gramage[0]['id'])?$this->getQtyPosibleByGrammage($gramage_id,$format_id,$rectoverso,$finition):array();
$typeImpression = false;
}
$qty = isset($qtys['qtys'][0]['qty'])?$qtys['qtys'][0]['qty']:null;
$isEnveloppe = false;
$verification = CartDetail::VERIFICATION_CHECKED;
$bordsArrondis = CartDetail::BORDS_ARRONDIS_NOT_CHECKED;
$plastification = CartDetail::PLASTIFICATION_NOT_CHECKED;
return array(
'isFinitionGlace' => $isFinitionGlace,
'isFinitionMate' => $isFinitionMate,
'isFinitionTransparent' => $isFinitionTransparent,
'isFinitionRepositionalble' => $isFinitionRepositionalble,
'isFinitionSoftTouch' => $isFinitionSoftTouch,
'isFinitionPelliculemat' => $isFinitionPelliculemat,
'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
'formats' => $formats,
'format_id' => $format_id,
'format' => $format,
'gramage' => $gramage,
'gramage_id' => $gramage_id,
'typeImpression' => $typeImpression,
'typeImpression_id' => $typeImpression_id,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'id_product' => $id_product,
'product' => $product,
'rectoverso' => $rectoverso,
'finition' => $finition,
'isEnveloppe' => $isEnveloppe,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'price' => $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,$isEnveloppe,false,false,ProductAttribute::SANS_PLASTIFICATION,null,null,null,null,null,null,null,$verification,$bordsArrondis,$plastification),
);
}
}
return array();
}
// get next option and price by product colorLab
public function getNextOptionByProduct($request,$idProduct,$typeAttribute,$valueAttribute){
$product = $this->em->getRepository(Product::class)->find($idProduct);
$requestData = $request->request->all();
$typeFormatId = isset($requestData['typeFormat'])? $requestData['typeFormat'] : null;
$formatId = isset($requestData['format'])? $requestData['format'] : null;
$specificiteId = isset($requestData['specificite'])? $requestData['specificite'] : null;
$couleurId = isset($requestData['couleur'])? $requestData['couleur'] : null;
$tailleId = isset($requestData['taille'])? $requestData['taille'] : null;
$zoneImpressionId = isset($requestData['zoneImpression'])? $requestData['zoneImpression'] : null;
$nbrCouleurId = isset($requestData['nbrCouleur'])? $requestData['nbrCouleur'] : null;
$supportSuspensionId = isset($requestData['supportSuspension'])? $requestData['supportSuspension'] : null;
$typeCartonId = isset($requestData['typeCarton'])? $requestData['typeCarton'] : null;
$oeilleId = isset($requestData['oeille'])? $requestData['oeille'] : null;
$typeImpressionId = isset($requestData['typeImpression'])? $requestData['typeImpression'] : null;
$gramageId = isset($requestData['gramage'])? $requestData['gramage'] : null;
$verification = isset($requestData['verification'])? $requestData['verification'] : null;
$bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : null;
$plastification = isset($requestData['plastification'])? $requestData['plastification'] : null;
$finition = isset($requestData['finition'])? $requestData['finition'] : null;
$formatL = isset($requestData['formatL'])? $requestData['formatL'] : 100;
$formatH = isset($requestData['formatH'])? $requestData['formatH'] : 100;
$isFinitionGlace = null;
$isFinitionMate = null;
$isFinitionTransparent = null;
$isFinitionRepositionalble = null;
$isFinitionSoftTouch = null;
$isFinitionPelliculemat = null;
$isFinitionPelliculeBrillant = null;
if($product){
if($product->getIsColorLab()){
$blockdescriptionProduct = null;
$type = $types = null;
$specificites = $specificite = null;
$formats = $format = null;
$couleurs = $couleur = null;
$tailles = $taille = null;
$zoneImpressions = $zoneImpression = null;
$nbrCouleurs = $nbrCouleur = null;
$typeImpressions = $typeImpression = null;
$supportSuspensions = $supportSuspension = null;
$typeCartons = $typeCarton = null;
$oeilles = $oeille = null;
$gramages = $gramage = null;
$isFinitionGlace = null;
$isFinitionMate = null;
if($typeAttribute == Attribut::TYPE_FORMAT){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
$formats = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,$type?$type->getId():null,null,null,null,null,null);
$specificites = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SPECIFICITE,null,null,null,$type?$type->getId():null,null,null,null,null,null);
if($type && in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
$isFinitionGlace = $type->getIsFinitionGlasse();
$isFinitionMate = $type->getIsFinitionMate();
$isFinitionTransparent = $type->getIsFinitionTransparent();
$isFinitionRepositionalble = $type->getIsFinitionRepositionalble();
$isFinitionSoftTouch = $type->getIsFinitionSoftTouch();
$isFinitionPelliculemat = $type->getIsFinitionPelliculemat();
$isFinitionPelliculeBrillant = $type->getIsFinitionPelliculeBrillant();
}else {
if ($formats) {
$format = $formats[0];
$isFinitionGlace = $format['isFinitionGlasse'];
$isFinitionMate = $format['isFinitionMate'];
$isFinitionRepositionalble = $format['isFinitionRepositionalble'];
$isFinitionTransparent = $format['isFinitionTransparent'];
$isFinitionSoftTouch = $format['isFinitionSoftTouch'];
$isFinitionPelliculemat = $format['isFinitionPelliculemat'];
$isFinitionPelliculeBrillant = $format['isFinitionPelliculeBrillant'];
}
}
if($specificites){$specificite = $specificites[0];}
$couleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format['id']:null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,null,null,null,null);
if($couleurs){$couleur = $couleurs[0];}
$tailles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format['id']:null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,null,null,null);
if($tailles){$taille = $tailles[0];}
$zoneImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format['id']:null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,null,null);
if($zoneImpressions){$zoneImpression = $zoneImpressions[0];}
$nbrCouleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format['id']:null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,null);
if($nbrCouleurs){$nbrCouleur = $nbrCouleurs[0];}
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format['id']:null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($gramages){$gramage = $gramages[0];}
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($supportSuspensions){$supportSuspension = $supportSuspensions[0];}
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeImpressions){$typeImpression = $typeImpressions[0];}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeCartons){$typeCarton = $typeCartons[0];}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format['id']:null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
if($oeilles){$oeille = $oeilles[0];}
$blockdescriptionProduct = 1;
}
if($typeAttribute == Attribut::FORMAT){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
$isFinitionRepositionalble = $format->getIsFinitionRepositionalble();
$isFinitionTransparent = $format->getIsFinitionTransparent();
$isFinitionSoftTouch = $format->getIsFinitionSoftTouch();
$isFinitionPelliculemat = $format->getIsFinitionPelliculemat();
$isFinitionPelliculeBrillant = $format->getIsFinitionPelliculeBrillant();
}
$specificites = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SPECIFICITE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null);
if($specificites){$specificite = $specificites[0];}
$couleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,null,null,null,null);
if($couleurs){$couleur = $couleurs[0];}
$tailles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,null,null,null);
if($tailles){$taille = $tailles[0];}
$zoneImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,null,null);
if($zoneImpressions){$zoneImpression = $zoneImpressions[0];}
$nbrCouleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,null);
if($nbrCouleurs){$nbrCouleur = $nbrCouleurs[0];}
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($gramages){$gramage = $gramages[0];}
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($supportSuspensions){$supportSuspension = $supportSuspensions[0];}
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeImpressions){$typeImpression = $typeImpressions[0];}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeCartons){$typeCarton = $typeCartons[0];}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite['id']:null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
if($oeilles){$oeille = $oeilles[0];}
}
if($typeAttribute == Attribut::SPECIFICITE){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$specificite = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
}
$couleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,null,null,null,null);
if($couleurs){$couleur = $couleurs[0];}
$tailles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,null,null,null);
if($tailles){$taille = $tailles[0];}
$zoneImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,null,null);
if($zoneImpressions){$zoneImpression = $zoneImpressions[0];}
$nbrCouleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,null);
if($nbrCouleurs){$nbrCouleur = $nbrCouleurs[0];}
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($gramages){$gramage = $gramages[0];}
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($supportSuspensions){$supportSuspension = $supportSuspensions[0];}
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeImpressions){$typeImpression = $typeImpressions[0];}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeCartons){$typeCarton = $typeCartons[0];}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur['id']:null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
if($oeilles){$oeille = $oeilles[0];}
}
if($typeAttribute == Attribut::TYPE_COULEUR){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
}
$specificite = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
$couleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
$tailles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,null,null,null);
if($tailles){$taille = $tailles[0];}
$zoneImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,null,null);
if($zoneImpressions){$zoneImpression = $zoneImpressions[0];}
$nbrCouleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,null);
if($nbrCouleurs){$nbrCouleur = $nbrCouleurs[0];}
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($gramages){$gramage = $gramages[0];}
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($supportSuspensions){$supportSuspension = $supportSuspensions[0];}
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeImpressions){$typeImpression = $typeImpressions[0];}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeImpression?$typeImpression['id']:null);
if($typeCartons){$typeCarton = $typeCartons[0];}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille['id']:null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeImpression?$typeImpression['id']:null,$typeCarton?$typeCarton['id']:null);
if($oeilles){$oeille = $oeilles[0];}
}
if($typeAttribute == Attribut::TAILLE){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
}
$specificite = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
$couleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
$taille = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
$zoneImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,null,null);
if($zoneImpressions){$zoneImpression = $zoneImpressions[0];}
$nbrCouleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,null);
if($nbrCouleurs){$nbrCouleur = $nbrCouleurs[0];}
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($gramages){$gramage = $gramages[0];}
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null);
if($supportSuspensions){$supportSuspension = $supportSuspensions[0];}
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeImpressions){$typeImpression = $typeImpressions[0];}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeCartons){$typeCarton = $typeCartons[0];}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression['id']:null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
if($oeilles){$oeille = $oeilles[0];}
}
if($typeAttribute == Attribut::ZONE_IMPRESSION){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
}
$specificite = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
$couleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
$taille = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
$zoneImpression = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
$nbrCouleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,null);
if($nbrCouleurs){$nbrCouleur = $nbrCouleurs[0];}
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur['id']:null);
if($gramages){$gramage = $gramages[0];}
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur['id']:null);
if($supportSuspensions){$supportSuspension = $supportSuspensions[0];}
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeImpressions){$typeImpression = $typeImpressions[0];}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null);
if($typeCartons){$typeCarton = $typeCartons[0];}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur['id']:null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
if($oeilles){$oeille = $oeilles[0];}
}
if($typeAttribute == Attribut::NBR_COULEUR){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
}
$specificite = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
$couleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
$taille = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
$zoneImpression = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
$nbrCouleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$valueAttribute]);
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
if($gramages){$gramage = $gramages[0];}
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
if($supportSuspensions){$supportSuspension = $supportSuspensions[0];}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension['id']:null);
if($typeCartons){$typeCarton = $typeCartons[0];}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage['id']:null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
if($oeilles){$oeille = $oeilles[0];}
}
if($typeAttribute == Attribut::GRAMMAGE){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
}
$specificite = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
$couleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
$taille = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
$zoneImpression = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
$nbrCouleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$nbrCouleurId]);
$gramage = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=> $gramageId]);
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
if($supportSuspensions){$supportSuspension = $supportSuspensions[0];}
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension['id']:null);
if($typeImpressions){$typeImpression = $typeImpressions[0];}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension['id']:null);
if($typeCartons){$typeCarton = $typeCartons[0];}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension['id']:null,$typeCarton?$typeCarton['id']:null);
if($oeilles){$oeille = $oeilles[0];}
}
if($typeAttribute == Attribut::SUPPORT_SUSPENSION){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
}
$specificite = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
$couleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
$taille = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
$zoneImpression = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
$nbrCouleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$nbrCouleurId]);
$gramage = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$gramageId]);
$supportSuspension = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$supportSuspensionId]);
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
if($typeImpressions){$typeImpression = $typeImpressions[0];}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
if($typeCartons){$typeCarton = $typeCartons[0];}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression['id']:null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null,$typeCarton?$typeCarton['id']:null);
if($oeilles){$oeille = $oeilles[0];}
}
if($typeAttribute == Attribut::TYPE_IMPRESSION){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
}
$specificite = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
$couleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
$taille = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
$zoneImpression = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
$nbrCouleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$nbrCouleurId]);
$gramage = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$gramageId]);
$supportSuspension = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$supportSuspensionId]);
$typeImpression = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeImpressionId]);
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
if($typeCartons){$typeCarton = $typeCartons[0];}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null,$typeCarton?$typeCarton['id']:null);
if($oeilles){$oeille = $oeilles[0];}
}
if($typeAttribute == Attribut::TYPE_CARTON){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
}
$specificite = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
$couleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
$taille = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
$zoneImpression = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
$nbrCouleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$nbrCouleurId]);
$gramage = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$gramageId]);
$supportSuspension = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$supportSuspensionId]);
$typeImpression = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeImpressionId]);
$typeCarton = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeCartonId]);
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type?$type->getId():null:null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null,$typeCarton?$typeCarton->getId():null);
if($oeilles){$oeille = $oeilles[0];}
}
if($typeAttribute == Attribut::OEILLE){
$type = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeFormatId]);
$format = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$formatId]);
if($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
}
$specificite = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$specificiteId]);
$couleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$couleurId]);
$taille = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$tailleId]);
$zoneImpression = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$zoneImpressionId]);
$nbrCouleur = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$nbrCouleurId]);
$gramage = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$gramageId]);
$supportSuspension = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$supportSuspensionId]);
$typeImpression = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeImpressionId]);
$typeCarton = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$typeCartonId]);
$oeille = $this->em->getRepository(Attribut::class)->findOneBy(['typeProduct'=>$product->getTypeProduct(),'id'=>$oeilleId]);
}
$qtys1 = $this->getQtyPosible($idProduct,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
$qty = isset($qtys1['qtys'][0]['qty'])?$qtys1['qtys'][0]['qty']:null;
$qtys = $this->getQantityVitrophonies($product,$qtys1['qtys'],$formatL,$formatH);
$qtysPlus = $this->getQantityVitrophonies($product,$qtys1['qtysPlus'],$formatL,$formatH);
$qtysTeam = $this->getQantityVitrophonies($product,$qtys1['qtysTeam'],$formatL,$formatH);
return array(
'product' => $product,
'types' => $types,
'type' => $type,
'formats' => $formats,
'format' => $format,
'specificites' => $specificites,
'specificite' => $specificite,
'couleurs' => $couleurs,
'couleur' => $couleur,
'tailles' => $tailles,
'taille' => $taille,
'zoneImpressions' => $zoneImpressions,
'zoneImpression' => $zoneImpression,
'nbrCouleurs' => $nbrCouleurs,
'nbrCouleur' => $nbrCouleur,
'supportSuspensions' => $supportSuspensions,
'supportSuspension' => $supportSuspension,
'typeCartons' => $typeCartons,
'typeCarton' => $typeCarton,
'typeImpressions' => $typeImpressions,
'typeImpression' => $typeImpression,
'oeilles' => $oeilles,
'oeille' => $oeille,
'gramages' => $gramages,
'gramage' => $gramage,
'qtys' => $qtys,
'qtysPlus' => $qtysPlus,
'qtysTeam' => $qtysTeam,
'qty' => $qty,
'isFinitionGlace' => $isFinitionGlace,
'isFinitionMate' => $isFinitionMate,
'isFinitionRepositionalble' => $isFinitionRepositionalble,
'isFinitionTransparent' => $isFinitionTransparent,
'isFinitionSoftTouch' => $isFinitionSoftTouch,
'isFinitionPelliculemat' => $isFinitionPelliculemat,
'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
'finition' => $finition,
'verification' => $verification ,
'bordsArrondis' => $bordsArrondis ,
'plastification' => $plastification ,
'formatL' => $formatL,
'formatH' => $formatH,
'blockdescriptionProduct' => $blockdescriptionProduct,
'price' => $this->getPriceColorLab($idProduct,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$qty,null,null,null,null,null,null,null,$supportSuspension,$formatL,$formatH,$typeCarton,$oeille),
);
}
}
return array();
}
// get option and price by product new nb_designer
public function optionByProductAndFormat($request,$id_product,$format_id){
$product = $this->em->getRepository(Product::class)->find($id_product);
$formats = array();
if($product){
$formats = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,null,null,null,null,null,null);
$format = $this->em->getRepository(Attribut::class)->find($format_id);
$typeImpression_id = null;
if($product->getIsRecto()){
$rectoverso = ProductAttribute::RECTO;
}elseif ($product->getIsRectoVerso()){
$rectoverso = ProductAttribute::VERSO;
}else{
$rectoverso = ProductAttribute::RECTO;
}
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
$isFinitionTransparent = $format->getIsFinitionTransparent();
$isFinitionRepositionalble = $format->getIsFinitionRepositionalble();
$isFinitionSoftTouch = $format->getIsFinitionSoftTouch();
$isFinitionPelliculemat = $format->getIsFinitionPelliculemat();
$isFinitionPelliculeBrillant = $format->getIsFinitionPelliculeBrillant();
if( $isFinitionGlace ){
$finition = CartDetail::FINITION_GLACE;
}elseif ($isFinitionMate){
$finition = CartDetail::FINITION_MATE;
}elseif ($isFinitionTransparent){
$finition = CartDetail::FINITION_TRANSPARENT;
}elseif ($isFinitionRepositionalble){
$finition = CartDetail::FINITION_REPOSITIONALBLE;
}elseif ($isFinitionSoftTouch){
$finition = CartDetail::FINITION_SoftTouch;
}elseif ($isFinitionPelliculemat){
$finition = CartDetail::FINITION_Pelliculemat;
}elseif ($isFinitionPelliculeBrillant){
$finition = CartDetail::FINITION_PelliculeBrillant;
}
else{
$finition = null;
}
$bordsArrondis = CartDetail::BORDS_ARRONDIS_NOT_CHECKED;
$plastification = CartDetail::PLASTIFICATION_NOT_CHECKED;
if($product && $product->getTypeProduct()== Product::AFFICHE){
$typeImpression = $this->getTypeImpression($id_product,$format_id);
$typeImpression_id = isset($typeImpression[0]['id'])?$typeImpression[0]['id']:null;
$gramage = $this->getGrammageByTypeImpression($id_product,$format_id,$typeImpression_id);
$gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
$qtys = isset($gramage[0]['id']) ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id,$format_id,$typeImpression_id,ProductAttribute::SANS_PLASTIFICATION,$finition,false,$bordsArrondis,$plastification):array();
}else{
$gramage = $this->getGramage($id_product,$format_id,$rectoverso);
$gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
$qtys = isset($gramage[0]['id'])?$this->getQtyPosibleByGrammage($gramage_id,$format_id,$rectoverso,$finition,$bordsArrondis,$plastification):array();
$typeImpression = false;
}
$qty = isset($qtys['qtys'][0]['qty'])?$qtys['qtys'][0]['qty']:null;
}
$isEnveloppe = false;
$verification = CartDetail::VERIFICATION_CHECKED;
return array(
'isFinitionGlace' => $isFinitionGlace,
'isFinitionMate' => $isFinitionMate,
'isFinitionRepositionalble' => $isFinitionRepositionalble,
'isFinitionTransparent' => $isFinitionTransparent,
'isFinitionSoftTouch' => $isFinitionSoftTouch,
'isFinitionPelliculemat' => $isFinitionPelliculemat,
'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
'formats' => $formats,
'format_id' => $format_id,
'format' => $format,
'gramage' => $gramage,
'gramage_id' => $gramage_id,
'typeImpression' => $typeImpression,
'typeImpression_id' => $typeImpression_id,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'id_product' => $id_product,
'product' => $product,
'rectoverso' => $rectoverso,
'finition' => $finition,
'isEnveloppe' => $isEnveloppe,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'price' => $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,$isEnveloppe,false,false,ProductAttribute::SANS_PLASTIFICATION,null,null,null,null,null,null,null,$verification,$bordsArrondis,$plastification),
);
}
// get option and price by token new nb_designer
public function getOptionByToken($request,$token){
$cartDetail = $this->em->getRepository(CartDetail::class)->findOneBy(array('token'=>$token));
if($cartDetail){
$product = $cartDetail->getProduct();
if($product->getIsColorLab()){
$types = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_FORMAT,null,null,null,null,null,null,null,null,null);
$type = $cartDetail->getProductAttribute()->getTypeFormat();
$formats = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,$type?$type->getId():null,null,null,null,null,null);
$format = $cartDetail->getProductAttribute()->getFormat();
$specificites = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SPECIFICITE,null,null,null,$type?$type->getId():null,null,null,null,null,null);
$specificite = $cartDetail->getProductAttribute()->getSpecificite();
$finition = $cartDetail->getFinition();
$bordsArrondis = $cartDetail->getIsPlusBordsArrondis();
$plastification = $cartDetail->getIsPlusPlastification();
$isFinitionGlace = null;
$isFinitionMate = null;
$isFinitionRepositionalble = null;
$isFinitionTransparent = null;
$isFinitionSoftTouch = null;
$isFinitionPelliculemat = null;
$isFinitionPelliculeBrillant = null;
$verification = null;
$couleur = null;
$taille = null;
$nbrCouleur = null;
$typeImpression = null;
$gramage = null;
$supportSuspension = null;
$typeCarton = null;
$oeille = null;
$formatL = $cartDetail->getFormatLargeur();
$formatH = $cartDetail->getFormatHauteur();
if($types && in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
$isFinitionGlace = $type->getIsFinitionGlasse();
$isFinitionMate = $type->getIsFinitionMate();
$isFinitionTransparent = $type->getIsFinitionTransparent();
$isFinitionRepositionalble = $type->getIsFinitionRepositionalble();
$isFinitionSoftTouch = $type->getIsFinitionSoftTouch();
$isFinitionPelliculemat = $type->getIsFinitionPelliculemat();
$isFinitionPelliculeBrillant = $type->getIsFinitionPelliculeBrillant();
$verification = $cartDetail->getIsPlusVerification();
}else {
if ($formats) {
$format = $cartDetail->getProductAttribute()->getFormat();
if ($format) {
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
$isFinitionTransparent = $format->getIsFinitionTransparent();
$isFinitionRepositionalble = $format->getIsFinitionRepositionalble();
$isFinitionSoftTouch = $format->getIsFinitionSoftTouch();
$isFinitionPelliculemat = $format->getIsFinitionPelliculemat();
$isFinitionPelliculeBrillant = $format->getIsFinitionPelliculeBrillant();
$verification = $cartDetail->getIsPlusVerification();
}
}
}
if($specificites){$specificite = $cartDetail->getProductAttribute()->getSpecificite();}
$couleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,null,null,null,null);
if($couleurs){$couleur = $cartDetail->getProductAttribute()->getTypeCouleur();}
$tailles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,null,null,null);
if($tailles){$taille = $cartDetail->getProductAttribute()->getTaille();}
$zoneImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,null,null);
if($zoneImpressions){$zoneImpression = $cartDetail->getProductAttribute()->getZoneImpression();}
$nbrCouleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,null);
if($nbrCouleurs){$nbrCouleur = $cartDetail->getProductAttribute()->getNbrCouleur();}
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
if($gramages){$gramage = $cartDetail->getProductAttribute()->getGramage();}
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
if($supportSuspensions){$supportSuspension = $cartDetail->getProductAttribute()->getSupportSuspension();}
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
if($typeImpressions){$typeImpression = $cartDetail->getProductAttribute()->getTypeImpression();}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
if($typeCartons){$typeCarton = $cartDetail->getProductAttribute()->getTypeCarton();}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null,$typeCarton?$typeCarton->getId():null);
if($oeilles){$oeille = $cartDetail->getProductAttribute()->getOeille();}
$qtys1 = $this->getQtyPosible($product->getId(),$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
$qtys = $this->getQantityVitrophonies($product,$qtys1['qtys'],$formatL,$formatH);
$qtysPlus = $this->getQantityVitrophonies($product,$qtys1['qtysPlus'],$formatL,$formatH);
$qtysTeam = $this->getQantityVitrophonies($product,$qtys1['qtysTeam'],$formatL,$formatH);
return array(
'product' => $product,
'types' => $types,
'type' => $type,
'formats' => $formats,
'format' => $format,
'specificites' => $specificites,
'specificite' => $specificite,
'couleurs' => $couleurs,
'couleur' => $couleur,
'tailles' => $tailles,
'taille' => $taille,
'zoneImpressions' => $zoneImpressions,
'zoneImpression' => $zoneImpression,
'nbrCouleurs' => $nbrCouleurs,
'nbrCouleur' => $nbrCouleur,
'gramages' => $gramages,
'gramage' => $gramage,
'supportSuspensions' => $supportSuspensions,
'supportSuspension' => $supportSuspension,
'typeCartons' => $typeCartons,
'typeCarton' => $typeCarton,
'oeilles' => $oeilles,
'oeille' => $oeille,
'typeImpressions' => $typeImpressions,
'typeImpression' => $typeImpression,
'isFinitionGlace' => $isFinitionGlace,
'isFinitionMate' => $isFinitionMate,
'isFinitionRepositionalble' => $isFinitionRepositionalble,
'isFinitionTransparent' => $isFinitionTransparent,
'isFinitionSoftTouch' => $isFinitionSoftTouch,
'isFinitionPelliculemat' => $isFinitionPelliculemat,
'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
'finition' => $finition,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis ,
'plastification' => $plastification ,
'formatL' => $formatL,
'formatH' => $formatH,
'qtys' => $qtys,
'qtysPlus' => $qtysPlus,
'qtysTeam' => $qtysTeam,
'qty' => $cartDetail->getNbrPapier(),
'price' => $this->getPriceColorLab($product->getId(),$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$cartDetail->getNbrPapier(),null,null,null,null,null,null,null,$supportSuspension,$formatL,$formatH,$typeCarton,$oeille),
);
}
else {
$id_product = $product->getId();
$formats = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,null,null,null,null,null,null);;
$format = $cartDetail->getProductAttribute()->getFormat();
$format_id = $cartDetail->getProductAttribute()->getFormat()->getId();
$rectoverso = $cartDetail->getProductAttribute()->getRectoverso();
$finition = $cartDetail->getFinition();
$bordsArrondis = $cartDetail->getIsPlusBordsArrondis();
$plastification = $cartDetail->getIsPlusPlastification();
$verification = $cartDetail->getIsPlusVerification();
$gramage_id = $cartDetail->getProductAttribute()->getGramage()->getId();
if ($product && $product->getTypeProduct() == Product::AFFICHE) {
$typeImpression_id = $cartDetail->getProductAttribute()->getTypeImpression()->getId();
$typeImpression = $this->getTypeImpression($id_product, $format_id);
$gramage = $this->getGrammageByTypeImpression($id_product, $format_id, $typeImpression_id);
$qtys = $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id, $format_id, $typeImpression_id, $cartDetail->getProductAttribute()->getPlastification(), $finition,false,$bordsArrondis,$plastification);
} else {
$gramage = $this->getGramage($id_product, $format_id, $rectoverso);
$qtys = $this->getQtyPosibleByGrammage($gramage_id, $format_id, $rectoverso, $finition,$bordsArrondis,$plastification);
$typeImpression = false;
$typeImpression_id = false;
}
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
$isFinitionTransparent = $format->getIsFinitionTransparent();
$isFinitionRepositionalble = $format->getIsFinitionRepositionalble();
$isFinitionSoftTouch = $format->getIsFinitionSoftTouch();
$isFinitionPelliculemat = $format->getIsFinitionPelliculemat();
$isFinitionPelliculeBrillant = $format->getIsFinitionPelliculeBrillant();
$qty = $cartDetail->getNbrPapier();
$isEnveloppe = $cartDetail->getIsEnveloppe();
return array(
'isFinitionGlace' => $isFinitionGlace,
'isFinitionMate' => $isFinitionMate,
'isFinitionRepositionalble' => $isFinitionRepositionalble,
'isFinitionTransparent' => $isFinitionTransparent,
'isFinitionSoftTouch' => $isFinitionSoftTouch,
'isFinitionPelliculemat' => $isFinitionPelliculemat,
'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
'formats' => $formats,
'format_id' => $format_id,
'format' => $format,
'gramage' => $gramage,
'gramage_id' => $gramage_id,
'typeImpression' => $typeImpression,
'typeImpression_id' => $typeImpression_id,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'id_product' => $id_product,
'product' => $product,
'rectoverso' => $rectoverso,
'finition' => $finition,
'isEnveloppe' => $isEnveloppe,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'price' => $this->getPrice($id_product, $format_id, $gramage_id, $typeImpression_id, $rectoverso, $qty, $finition, $isEnveloppe, false, false, $cartDetail->getProductAttribute()->getPlastification(), null, null, null, null, null, null, null, $verification,$bordsArrondis,$plastification),
);
}
}
return [];
}
// get option and price by format new nb_designer
public function getOptionByformat($request,$id_product,$format_id,$isEnveloppe=false,$rectoverso=null,$typeImpression_id=null){
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product){
$formats = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,null,null,null,null,null,null);
if($rectoverso){
}else {
if ($product->getIsRecto()) {
$rectoverso = ProductAttribute::RECTO;
} elseif ($product->getIsRectoVerso()) {
$rectoverso = ProductAttribute::VERSO;
} else {
$rectoverso = ProductAttribute::RECTO;
}
}
$format = $this->em->getRepository(Attribut::class)->find($format_id);
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
$isFinitionTransparent = $format->getIsFinitionTransparent();
$isFinitionRepositionalble = $format->getIsFinitionRepositionalble();
$isFinitionSoftTouch = $format->getIsFinitionSoftTouch();
$isFinitionPelliculemat = $format->getIsFinitionPelliculemat();
$isFinitionPelliculeBrillant = $format->getIsFinitionPelliculeBrillant();
if( $isFinitionGlace ){
$finition = CartDetail::FINITION_GLACE;
}elseif ($isFinitionMate){
$finition = CartDetail::FINITION_MATE;
}elseif ($isFinitionTransparent){
$finition = CartDetail::FINITION_TRANSPARENT;
}elseif ($isFinitionRepositionalble){
$finition = CartDetail::FINITION_REPOSITIONALBLE;
}elseif ($isFinitionSoftTouch){
$finition = CartDetail::FINITION_SoftTouch;
}elseif ($isFinitionPelliculemat){
$finition = CartDetail::FINITION_Pelliculemat;
}elseif ($isFinitionPelliculeBrillant){
$finition = CartDetail::FINITION_PelliculeBrillant;
}else{
$finition = null;
}
$bordsArrondis = CartDetail::BORDS_ARRONDIS_NOT_CHECKED;
$plastification = CartDetail::PLASTIFICATION_NOT_CHECKED;
if($product && $product->getTypeProduct()== Product::AFFICHE){
$typeImpression = $this->em->getRepository(Attribut::class)->find($typeImpression_id);
$gramage = $this->getGrammageByTypeImpression($id_product,$format_id,$typeImpression_id);
$gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
$qtys = isset($gramage[0]['id']) ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id,$format_id,$typeImpression_id,ProductAttribute::SANS_PLASTIFICATION,$finition,false,$bordsArrondis):array();
}else{
$gramage = $this->getGramage($id_product,$format_id,$rectoverso);
$gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
$qtys = isset($gramage[0]['id'])?$this->getQtyPosibleByGrammage($gramage_id,$format_id,$rectoverso,$finition,$bordsArrondis,$plastification):array();
$typeImpression = false;
}
$qty = isset($qtys['qtys'][0]['qty'])?$qtys['qtys'][0]['qty']:null;
}
$verification = CartDetail::VERIFICATION_CHECKED;
return array(
'isFinitionGlace' => $isFinitionGlace,
'isFinitionMate' => $isFinitionMate,
'isFinitionRepositionalble' => $isFinitionRepositionalble,
'isFinitionTransparent' => $isFinitionTransparent,
'isFinitionSoftTouch' => $isFinitionSoftTouch,
'isFinitionPelliculemat' => $isFinitionPelliculemat,
'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
'format_id' => $format_id,
'formats' => $formats,
'format' => $format,
'gramage' => $gramage,
'gramage_id' => $gramage_id,
'typeImpression' => $typeImpression,
'typeImpression_id' => $typeImpression_id,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'id_product' => $id_product,
'product' => $product,
'rectoverso' => $rectoverso,
'finition' => $finition,
'isEnveloppe' => $isEnveloppe,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'price' => $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,$isEnveloppe,false,false,ProductAttribute::SANS_PLASTIFICATION,null,null,null,null,null,null,null,$verification,$bordsArrondis,$plastification),
);
}
// get grammage and price by TypeImpression RectoVerso new nb_designer
public function getGramgeByTypeImpressionOrRectoVerso($request,$id_product,$format_id,$rectoverso,$finition,$typeImpression_id=null,$isEnveloppe=false,$verification=CartDetail::VERIFICATION_NOT_CHECKED,$bordsArrondis= CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification = CartDetail::PLASTIFICATION_NOT_CHECKED){
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product){
if($product && $product->getTypeProduct()== Product::AFFICHE){
$gramage = $this->getGrammageByTypeImpression($id_product,$format_id,$typeImpression_id);
$gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
$qtys = isset($gramage[0]['id']) ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id,$format_id,$typeImpression_id,ProductAttribute::SANS_PLASTIFICATION,$finition):array();
}else{
$gramage = $this->getGramage($id_product,$format_id,$rectoverso);
$gramage_id = isset($gramage[0]['id'])?$gramage[0]['id']:null;
$qtys = isset($gramage[0]['id'])?$this->getQtyPosibleByGrammage($gramage_id,$format_id,$rectoverso,$finition):array();
}
$qty = isset($qtys['qtys'][0]['qty'])?$qtys['qtys'][0]['qty']:null;
}
return array(
'format_id' => $format_id,
'format' => $this->em->getRepository(Attribut::class)->find($format_id),
'gramage' => $gramage,
'gramage_id' => $gramage_id,
'typeImpression_id' => $typeImpression_id,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'id_product' => $id_product,
'product' => $product,
'rectoverso' => $rectoverso,
'finition' => $finition,
'isEnveloppe' => $isEnveloppe,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'price' => $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,false,false,false,ProductAttribute::SANS_PLASTIFICATION,null,null,null,null,null,null,null,$verification,$bordsArrondis,$plastification),
);
}
public function getDetailLivraison($carrierId,$typeLivraisonNational = null,$typeLivraison30min = null,$adresseCarrier = null,$imprimeurLivraison,$dateLivraison = null,$timeLivraison = null){
$data = [];
if($carrierId && $imprimeurLivraison){
$carrier = $this->em->getRepository(Carrier::class)->find($carrierId);
$imprimeur = $this->em->getRepository(Imprimeur::class)->find($imprimeurLivraison);
$carrierNationalJ1 = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J1));
$carrierNationalJ2 = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J2));
$carrierNationalJ5 = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J5));
$carrier30MIN = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::STUART));
$carrierRetrait = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::RETRAIT));
$data['num'] = $carrier->getNum();
if($carrier == $carrierRetrait){
$data['name'] = $carrier->getName();
$data['adresse'] = $imprimeur->getName().' '.$imprimeur->getAddress();
}else if($carrier == $carrier30MIN){
$data['name'] = $carrier->getName();
$data['adresse'] = $adresseCarrier;
if($timeLivraison && $dateLivraison){
$date = new \DateTime($dateLivraison);
$time = explode(' - ', $timeLivraison);
$dateNow = new \DateTime('now', new \DateTimeZone('Europe/Paris'));
if($date){
$dayJourDispo = $date->format('d');
if($dateNow->format('d') == $dayJourDispo){
$dayName = 'Aujourd’hui';
}else if($dateNow->modify('+1 day')->format('d') == $dayJourDispo){
$dayName = 'Demain';
}else if($dateNow->modify('+1 day')->format('d') == $dayJourDispo){
$dayName = 'Après-demain';
}else{
$dayNameFormat = new \IntlDateFormatter('fr', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE, null, null, 'EEEE');
$dayName = $dayNameFormat->format($date);
}
}
$data['livraisonJour'] = $dayName .' entre '.$time[0].' et '.$time[0];
$data['livraisonJour2'] = $date->format('d/m/Y') .', '.$time[0].'-'.$time[0];
}
}else if($carrier == $carrierNationalJ1 || $carrier == $carrierNationalJ2){
$data['name'] = $carrier->getName();
$data['adresse'] = $adresseCarrier;
}else if($carrier == $carrierNationalJ5){
$data['name'] = $carrier->getName();
$data['adresse'] = $adresseCarrier;
}
}
return $this->twig->render('front/product-option/detail-livraison.html.twig',$data);
}
public function getJourLivraison($carrierId,$typeLivraisonNational = null,$typeLivraison30min = null,$adresseCarrier = null,$imprimeurLivraison,$dateLivraison = null,$timeLivraison = null){
$data = [];
if($carrierId && $imprimeurLivraison){
$carrier = $this->em->getRepository(Carrier::class)->find($carrierId);
$imprimeur = $this->em->getRepository(Imprimeur::class)->find($imprimeurLivraison);
$carrierNationalJ1 = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J1));
$carrierNationalJ2 = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J2));
$carrier30MIN = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::STUART));
$carrierRetrait = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::RETRAIT));
if($carrier == $carrierRetrait){
$data['date'] = null;
$data['time'] = null;
}else if($carrier == $carrier30MIN){
$data['name'] = $carrier->getName();
$data['adresse'] = $adresseCarrier;
if($timeLivraison && $dateLivraison){
$date = new \DateTime($dateLivraison);
$time = explode(' - ', $timeLivraison);
$dateFormat = new \IntlDateFormatter('fr', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE, null, null, 'EEEE d MMMM');
$dateName = $dateFormat->format($date);
$data['date'] = $dateName;
$data['time'] = isset($time[0])?$time[0]:null;
}
}else if($carrier == $carrierNationalJ1 || $carrier == $carrierNationalJ2){
$data['date'] = null;
$data['time'] = null;
}
}
return $data;
}
// get price and qty new nb_designer
public function getPriceAndQuantity($request,$id_product,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id=null,$isEnveloppe=false,$plus_expert=false,$isTrait=false,$carrierId = null,$typeLivraisonNational = null,$typeLivraison30min = null,$adresseCarrier = null,$imprimeurLivraison = null,$dateLivraison = null,$timeLivraison = null,$lat=null,$long=null,$codePostal=null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product){
if($product->getIsColorLab()){
$requestData = $request->request->all();
$typeFormatId = isset($requestData['typeFormat'])? $requestData['typeFormat'] : null;
$formatId = isset($requestData['format'])? $requestData['format'] : null;
$specificiteId = isset($requestData['specificite'])? $requestData['specificite'] : null;
$couleurId = isset($requestData['couleur'])? $requestData['couleur'] : null;
$tailleId = isset($requestData['taille'])? $requestData['taille'] : null;
$zoneImpressionId = isset($requestData['zoneImpression'])? $requestData['zoneImpression'] : null;
$nbrCouleurId = isset($requestData['nbrCouleur'])? $requestData['nbrCouleur'] : null;
$gramageId = isset($requestData['gramage'])? $requestData['gramage'] : null;
$supportSuspensionId = isset($requestData['supportSuspension'])? $requestData['supportSuspension'] : null;
$typeCartonId = isset($requestData['typeCarton'])? $requestData['typeCarton'] : null;
$oeilleId = isset($requestData['oeille'])? $requestData['oeille'] : null;
$typeImpressionId = isset($requestData['typeImpression'])? $requestData['typeImpression'] : null;
$formatL = isset($requestData['formatL'])? $requestData['formatL'] : 100;
$formatH = isset($requestData['formatH'])? $requestData['formatH'] : 100;
$format = $formatId ? $this->em->getRepository(Attribut::class)->find($formatId):null;
$gramage = $gramageId ? $this->em->getRepository(Attribut::class)->find($gramageId):null;
$type = $typeFormatId ? $this->em->getRepository(Attribut::class)->find($typeFormatId):null;
$specificite = $specificiteId ? $this->em->getRepository(Attribut::class)->find($specificiteId):null;
$couleur = $couleurId ? $this->em->getRepository(Attribut::class)->find($couleurId):null;
$taille = $tailleId ? $this->em->getRepository(Attribut::class)->find($tailleId):null;
$zoneImpression = $zoneImpressionId ? $this->em->getRepository(Attribut::class)->find($zoneImpressionId):null;
$supportSuspension = $supportSuspensionId ? $this->em->getRepository(Attribut::class)->find($supportSuspensionId):null;
$typeCarton = $typeCartonId ? $this->em->getRepository(Attribut::class)->find($typeCartonId):null;
$oeille = $oeilleId ? $this->em->getRepository(Attribut::class)->find($oeilleId):null;
$typeImpression = $typeImpressionId ? $this->em->getRepository(Attribut::class)->find($typeImpressionId):null;
$nbrCouleur = $nbrCouleurId ? $this->em->getRepository(Attribut::class)->find($nbrCouleurId):null;
$qtys1 = $this->getQtyPosible($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$supportSuspension,$typeCarton,$oeille);
$qtys = $this->getQantityVitrophonies($product,$qtys1['qtys'],$formatL,$formatH);
$qtysPlus = $this->getQantityVitrophonies($product,$qtys1['qtysPlus'],$formatL,$formatH);
$qtysTeam = $this->getQantityVitrophonies($product,$qtys1['qtysTeam'],$formatL,$formatH);
$blockLivraison = null;
$jourLivraison = null;
$livraisonPrice = null;
if ($carrierId && $imprimeurLivraison) {
$blockLivraison = $this->getDetailLivraison($carrierId, $typeLivraisonNational, $typeLivraison30min, $adresseCarrier, $imprimeurLivraison, $dateLivraison, $timeLivraison);
$jourLivraison = $this->getJourLivraison($carrierId, $typeLivraisonNational, $typeLivraison30min, $adresseCarrier, $imprimeurLivraison, $dateLivraison, $timeLivraison);
$priceBloc = $this->getPriceColorLab($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$qty,$carrierId,$typeLivraisonNational,$typeLivraison30min,$lat,$long,$codePostal,$imprimeurLivraison,$supportSuspension,$formatL,$formatH,$typeCarton,$oeille);
$livraisonPrice = $this->cart_service->getPriceCarrier($priceBloc['prixHt'],$carrierId,$typeLivraison30min,$typeLivraisonNational);
}
return array(
'product' => $product,
'type' => $type,
'format' => $format,
'specificite' => $specificite,
'couleur' => $couleur,
'taille' => $taille,
'zoneImpression' => $zoneImpression,
'nbrCouleur' => $nbrCouleur,
'gramage' => $gramage,
'supportSuspension' => $supportSuspension,
'typeCarton' => $typeCarton,
'oeille' => $oeille,
'typeImpression' => $typeImpression,
'finition' => $finition,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'formatL' => $formatL,
'formatH' => $formatH,
'qtys' => $qtys,
'qtysPlus' => $qtysPlus,
'qtysTeam' => $qtysTeam,
'qty' => $qty,
'blockLivraison' => $blockLivraison,
'livraisonPrice' => $livraisonPrice,
'jourLivraison' => $jourLivraison,
'price' => $this->getPriceColorLab($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$qty,$carrierId,$typeLivraisonNational,$typeLivraison30min,$lat,$long,$codePostal,$imprimeurLivraison,$supportSuspension,$formatL,$formatH,$typeCarton,$oeille),
);
}
else {
if ($product && $product->getTypeProduct() == Product::AFFICHE) {
$qtys = $gramage_id ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id, $format_id, $typeImpression_id, ProductAttribute::SANS_PLASTIFICATION, $finition,false,$bordsArrondis,$plastification) : array();
} else {
$qtys = $gramage_id ? $this->getQtyPosibleByGrammage($gramage_id, $format_id, $rectoverso, $finition,$bordsArrondis,$plastification) : array();
}
$blockLivraison = null;
$jourLivraison = null;
$livraisonPrice = null;
if ($carrierId && $imprimeurLivraison) {
$blockLivraison = $this->getDetailLivraison($carrierId, $typeLivraisonNational, $typeLivraison30min, $adresseCarrier, $imprimeurLivraison, $dateLivraison, $timeLivraison);
$jourLivraison = $this->getJourLivraison($carrierId, $typeLivraisonNational, $typeLivraison30min, $adresseCarrier, $imprimeurLivraison, $dateLivraison, $timeLivraison);
$priceBloc = $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,$isEnveloppe,$plus_expert,$isTrait,ProductAttribute::SANS_PLASTIFICATION,$carrierId,$typeLivraisonNational,$typeLivraison30min,$lat,$long,$codePostal,$imprimeurLivraison,$verification,$bordsArrondis,$plastification);
$livraisonPrice = $this->cart_service->getPriceCarrier($priceBloc['prixHt'],$carrierId,$typeLivraison30min,$typeLivraisonNational);
}
return array(
'id_product' => $id_product,
'product' => $product,
'qty' => $qty,
'format_id' => $format_id,
'format' => $this->em->getRepository(Attribut::class)->find($format_id),
'rectoverso' => $rectoverso,
'finition' => $finition,
'gramage_id' => $gramage_id,
'gramage' => $this->em->getRepository(Attribut::class)->find($gramage_id),
'typeImpression_id' => $typeImpression_id,
'typeImpression' => ($typeImpression_id)?$this->em->getRepository(Attribut::class)->find($typeImpression_id):null,
'isEnveloppe' => $isEnveloppe,
'plus_expert' => $plus_expert,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'isTrait' => $isTrait,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'blockLivraison' => $blockLivraison,
'livraisonPrice' => $livraisonPrice,
'jourLivraison' => $jourLivraison,
'price' => $this->getPrice($id_product,$format_id,$gramage_id,$typeImpression_id,$rectoverso,$qty,$finition,$isEnveloppe,$plus_expert,$isTrait,ProductAttribute::SANS_PLASTIFICATION,$carrierId,$typeLivraisonNational,$typeLivraison30min,$lat,$long,$codePostal,$imprimeurLivraison,$verification,$bordsArrondis,$plastification),
);
}
}
return array();
}
// get detail product new nb_designer
public function getDetailProduct($request,$id_product,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id=null,$isEnveloppe=false,$plus_expert=false,$isTrait=false,$carrierId = null,$typeLivraisonNational = null,$typeLivraison30min = null,$tokenDetail=null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product) {
if ($product->getIsColorLab()) {
$requestData = $request->request->all();
$typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
$formatId = isset($requestData['format']) ? $requestData['format'] : null;
$specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
$couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
$tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
$zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
$nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
$gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
$supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
$typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
$oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
$typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
$format = $formatId ? $this->em->getRepository(Attribut::class)->find($formatId) : null;
$gramage = $gramageId ? $this->em->getRepository(Attribut::class)->find($gramageId) : null;
$type = $typeFormatId ? $this->em->getRepository(Attribut::class)->find($typeFormatId) : null;
$specificite = $specificiteId ? $this->em->getRepository(Attribut::class)->find($specificiteId) : null;
$couleur = $couleurId ? $this->em->getRepository(Attribut::class)->find($couleurId) : null;
$taille = $tailleId ? $this->em->getRepository(Attribut::class)->find($tailleId) : null;
$zoneImpression = $zoneImpressionId ? $this->em->getRepository(Attribut::class)->find($zoneImpressionId) : null;
$nbrCouleur = $nbrCouleurId ? $this->em->getRepository(Attribut::class)->find($nbrCouleurId) : null;
$supportSuspension = $supportSuspensionId ? $this->em->getRepository(Attribut::class)->find($supportSuspensionId) : null;
$typeCarton = $typeCartonId ? $this->em->getRepository(Attribut::class)->find($typeCartonId) : null;
$oeille = $oeilleId ? $this->em->getRepository(Attribut::class)->find($oeilleId) : null;
$typeImpression = $typeImpressionId ? $this->em->getRepository(Attribut::class)->find($typeImpressionId) : null;
$qtys = $this->getQtyPosible($id_product, $format, $gramage, $typeImpression, $type, $specificite, $couleur, $taille, $zoneImpression, $nbrCouleur,$supportSuspension,$typeCarton,$oeille);
if($product->getTypeProduct() == Product::PHOTOS){
$filesToken = isset($requestData['photosToken']) ? $requestData['photosToken'] : null;
$qty = $this->getFilePhotoQuantiy($filesToken);
}
$cartDetail = null;
if ($tokenDetail) {
$cartDetail = $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
}
$data = array(
'product' => $product,
'type' => $type,
'format' => $format,
'specificite' => $specificite,
'couleur' => $couleur,
'taille' => $taille,
'zoneImpression' => $zoneImpression,
'nbrCouleur' => $nbrCouleur,
'gramage' => $gramage,
'supportSuspension' => $supportSuspension,
'typeCarton' => $typeCarton,
'oeille' => $oeille,
'typeImpression' => $typeImpression,
'cartDetail' => $cartDetail,
'finition' => $finition,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'price' => $this->getPriceColorLab($id_product, $format, $gramage, $typeImpression, $type, $specificite, $couleur, $taille, $zoneImpression, $nbrCouleur, $qty, $carrierId, $typeLivraisonNational, $typeLivraison30min, null, null, null, null,$supportSuspension,null,null,$typeCarton,$oeille),
);
} else {
if ($product && $product->getTypeProduct() == Product::AFFICHE) {
$qtys = $gramage_id ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id, $format_id, $typeImpression_id, ProductAttribute::SANS_PLASTIFICATION, $finition,false,$bordsArrondis,$plastification) : array();
} else {
$qtys = $gramage_id ? $this->getQtyPosibleByGrammage($gramage_id, $format_id, $rectoverso, $finition,$bordsArrondis,$plastification) : array();
}
$cartDetail = null;
if ($tokenDetail) {
$cartDetail = $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
}
$data = array(
'id_product' => $id_product,
'product' => $product,
'qty' => $qty,
'format_id' => $format_id,
'format' => $this->em->getRepository(Attribut::class)->find($format_id),
'rectoverso' => $rectoverso,
'finition' => $finition,
'gramage_id' => $gramage_id,
'gramage' => $this->em->getRepository(Attribut::class)->find($gramage_id),
'typeImpression_id' => $typeImpression_id,
'typeImpression' => ($typeImpression_id) ? $this->em->getRepository(Attribut::class)->find($typeImpression_id) : null,
'isEnveloppe' => $isEnveloppe,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'plus_expert' => $plus_expert,
'isTrait' => $isTrait,
'cartDetail' => $cartDetail,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'price' => $this->getPrice($id_product, $format_id, $gramage_id, $typeImpression_id, $rectoverso, $qty, $finition, $isEnveloppe, $plus_expert, $isTrait, ProductAttribute::SANS_PLASTIFICATION, $carrierId, $typeLivraisonNational, $typeLivraison30min, null, null, null, null, $verification,$bordsArrondis,$plastification),
);
}
return $this->twig->render('front/product-option/detail-block.html.twig', $data);
}
return array();
}
// get detail product photos new nb_designer
public function getDetailProductPhotos($request,$id_product,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id=null,$isEnveloppe=false,$plus_expert=false,$isTrait=false,$carrierId = null,$typeLivraisonNational = null,$typeLivraison30min = null,$tokenDetail=null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product) {
if ($product->getIsColorLab()) {
$requestData = $request->request->all();
$typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
$formatId = isset($requestData['format']) ? $requestData['format'] : null;
$specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
$couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
$tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
$zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
$nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
$gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
$supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
$typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
$oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
$typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
$format = $formatId ? $this->em->getRepository(Attribut::class)->find($formatId) : null;
$gramage = $gramageId ? $this->em->getRepository(Attribut::class)->find($gramageId) : null;
$type = $typeFormatId ? $this->em->getRepository(Attribut::class)->find($typeFormatId) : null;
$specificite = $specificiteId ? $this->em->getRepository(Attribut::class)->find($specificiteId) : null;
$couleur = $couleurId ? $this->em->getRepository(Attribut::class)->find($couleurId) : null;
$taille = $tailleId ? $this->em->getRepository(Attribut::class)->find($tailleId) : null;
$zoneImpression = $zoneImpressionId ? $this->em->getRepository(Attribut::class)->find($zoneImpressionId) : null;
$nbrCouleur = $nbrCouleurId ? $this->em->getRepository(Attribut::class)->find($nbrCouleurId) : null;
$supportSuspension = $supportSuspensionId ? $this->em->getRepository(Attribut::class)->find($supportSuspensionId) : null;
$typeCarton = $typeCartonId ? $this->em->getRepository(Attribut::class)->find($typeCartonId) : null;
$oeille = $oeilleId ? $this->em->getRepository(Attribut::class)->find($oeilleId) : null;
$typeImpression = $typeImpressionId ? $this->em->getRepository(Attribut::class)->find($typeImpressionId) : null;
$qtys = $this->getQtyPosible($id_product, $format, $gramage, $typeImpression, $type, $specificite, $couleur, $taille, $zoneImpression, $nbrCouleur,$supportSuspension,$typeCarton,$oeille);
if($product->getTypeProduct() == Product::PHOTOS){
$filesToken = isset($requestData['photosToken']) ? $requestData['photosToken'] : null;
$qty = $this->getFilePhotoQuantiy($filesToken);
}
$cartDetail = null;
if ($tokenDetail) {
$cartDetail = $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
}
$data = array(
'product' => $product,
'type' => $type,
'format' => $format,
'specificite' => $specificite,
'couleur' => $couleur,
'taille' => $taille,
'zoneImpression' => $zoneImpression,
'nbrCouleur' => $nbrCouleur,
'gramage' => $gramage,
'supportSuspension' => $supportSuspension,
'typeCarton' => $typeCarton,
'oeille' => $oeille,
'typeImpression' => $typeImpression,
'cartDetail' => $cartDetail,
'finition' => $finition,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'price' => $this->getPriceColorLab($id_product, $format, $gramage, $typeImpression, $type, $specificite, $couleur, $taille, $zoneImpression, $nbrCouleur, $qty, $carrierId, $typeLivraisonNational, $typeLivraison30min, null, null, null, null,$supportSuspension,null,null,$typeCarton,$oeille),
);
return $data;
}
}
return array();
}
// get detail product new nb_designer mobile
public function getDetailProductMobile($request,$id_product,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id=null,$isEnveloppe=false,$plus_expert=false,$isTrait=false,$carrierId = null,$typeLivraisonNational = null,$typeLivraison30min = null,$tokenDetail=null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product) {
if ($product->getIsColorLab()) {
$requestData = $request->request->all();
$typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
$formatId = isset($requestData['format']) ? $requestData['format'] : null;
$specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
$couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
$tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
$zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
$nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
$gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
$supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
$typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
$oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
$typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
$format = $formatId ? $this->em->getRepository(Attribut::class)->find($formatId) : null;
$gramage = $gramageId ? $this->em->getRepository(Attribut::class)->find($gramageId) : null;
$type = $typeFormatId ? $this->em->getRepository(Attribut::class)->find($typeFormatId) : null;
$specificite = $specificiteId ? $this->em->getRepository(Attribut::class)->find($specificiteId) : null;
$couleur = $couleurId ? $this->em->getRepository(Attribut::class)->find($couleurId) : null;
$taille = $tailleId ? $this->em->getRepository(Attribut::class)->find($tailleId) : null;
$zoneImpression = $zoneImpressionId ? $this->em->getRepository(Attribut::class)->find($zoneImpressionId) : null;
$nbrCouleur = $nbrCouleurId ? $this->em->getRepository(Attribut::class)->find($nbrCouleurId) : null;
$supportSuspension = $supportSuspensionId ? $this->em->getRepository(Attribut::class)->find($supportSuspensionId) : null;
$typeCarton = $typeCartonId ? $this->em->getRepository(Attribut::class)->find($typeCartonId) : null;
$oeille = $oeilleId ? $this->em->getRepository(Attribut::class)->find($oeilleId) : null;
$typeImpression = $typeImpressionId ? $this->em->getRepository(Attribut::class)->find($typeImpressionId) : null;
$qtys = $this->getQtyPosible($id_product, $format, $gramage, $typeImpression, $type, $specificite, $couleur, $taille, $zoneImpression, $nbrCouleur,$supportSuspension,$typeCarton,$oeille);
$cartDetail = null;
if ($tokenDetail) {
$cartDetail = $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
}
$data = array(
'product' => $product,
'type' => $type,
'format' => $format,
'specificite' => $specificite,
'couleur' => $couleur,
'taille' => $taille,
'zoneImpression' => $zoneImpression,
'nbrCouleur' => $nbrCouleur,
'gramage' => $gramage,
'supportSuspension' => $supportSuspension,
'typeCarton' => $typeCarton,
'oeille' => $oeille,
'typeImpression' => $typeImpression,
'cartDetail' => $cartDetail,
'finition' => $finition,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'price' => $this->getPriceColorLab($id_product, $format, $gramage, $typeImpression, $type, $specificite, $couleur, $taille, $zoneImpression, $nbrCouleur, $qty, $carrierId, $typeLivraisonNational, $typeLivraison30min, null, null, null, null,$supportSuspension,null,null,$typeCarton,$oeille),
);
} else {
if ($product && $product->getTypeProduct() == Product::AFFICHE) {
$qtys = $gramage_id ? $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id, $format_id, $typeImpression_id, ProductAttribute::SANS_PLASTIFICATION, $finition,false,$bordsArrondis,$plastification) : array();
} else {
$qtys = $gramage_id ? $this->getQtyPosibleByGrammage($gramage_id, $format_id, $rectoverso, $finition,$bordsArrondis,$plastification) : array();
}
$cartDetail = null;
if ($tokenDetail) {
$cartDetail = $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
}
$data = array(
'id_product' => $id_product,
'product' => $product,
'qty' => $qty,
'format_id' => $format_id,
'format' => $this->em->getRepository(Attribut::class)->find($format_id),
'rectoverso' => $rectoverso,
'finition' => $finition,
'gramage_id' => $gramage_id,
'gramage' => $this->em->getRepository(Attribut::class)->find($gramage_id),
'typeImpression_id' => $typeImpression_id,
'typeImpression' => ($typeImpression_id) ? $this->em->getRepository(Attribut::class)->find($typeImpression_id) : null,
'isEnveloppe' => $isEnveloppe,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'plus_expert' => $plus_expert,
'isTrait' => $isTrait,
'cartDetail' => $cartDetail,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'price' => $this->getPrice($id_product, $format_id, $gramage_id, $typeImpression_id, $rectoverso, $qty, $finition, $isEnveloppe, $plus_expert, $isTrait, ProductAttribute::SANS_PLASTIFICATION, $carrierId, $typeLivraisonNational, $typeLivraison30min, null, null, null, null, $verification,$bordsArrondis,$plastification),
);
}
return $this->twig->render('front/product-option/detail-block-mobile.html.twig', $data);
}
return array();
}
public function getDetailProductTagGoogle($request,$id_product,$qty,$format_id,$rectoverso,$finition,$gramage_id,$typeImpression_id=null,$isEnveloppe=false,$plus_expert=false,$isTrait=false,$carrierId = null,$typeLivraisonNational = null,$typeLivraison30min = null,$tokenDetail=null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product) {
if ($product->getIsColorLab()) {
$requestData = $request->request->all();
$typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
$formatId = isset($requestData['format']) ? $requestData['format'] : null;
$specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
$couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
$tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
$zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
$nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
$gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
$supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
$typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
$oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
$typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
$format = $formatId ? $this->em->getRepository(Attribut::class)->find($formatId) : null;
$gramage = $gramageId ? $this->em->getRepository(Attribut::class)->find($gramageId) : null;
$type = $typeFormatId ? $this->em->getRepository(Attribut::class)->find($typeFormatId) : null;
$specificite = $specificiteId ? $this->em->getRepository(Attribut::class)->find($specificiteId) : null;
$couleur = $couleurId ? $this->em->getRepository(Attribut::class)->find($couleurId) : null;
$taille = $tailleId ? $this->em->getRepository(Attribut::class)->find($tailleId) : null;
$zoneImpression = $zoneImpressionId ? $this->em->getRepository(Attribut::class)->find($zoneImpressionId) : null;
$nbrCouleur = $nbrCouleurId ? $this->em->getRepository(Attribut::class)->find($nbrCouleurId) : null;
$supportSuspension = $supportSuspensionId ? $this->em->getRepository(Attribut::class)->find($supportSuspensionId) : null;
$typeCarton = $typeCartonId ? $this->em->getRepository(Attribut::class)->find($typeCartonId) : null;
$oeille = $oeilleId ? $this->em->getRepository(Attribut::class)->find($oeilleId) : null;
$typeImpression = $typeImpressionId ? $this->em->getRepository(Attribut::class)->find($typeImpressionId) : null;
$price = $this->getPriceColorLab($id_product, $format, $gramage, $typeImpression, $type, $specificite, $couleur, $taille, $zoneImpression, $nbrCouleur, $qty, $carrierId, $typeLivraisonNational, $typeLivraison30min, null, null, null, null,$supportSuspension,null,null,$typeCarton,$oeille);
} else {
$format = $this->em->getRepository(Attribut::class)->find($format_id);
$price = $this->getPrice($id_product, $format_id, $gramage_id, $typeImpression_id, $rectoverso, $qty, $finition, $isEnveloppe, $plus_expert, $isTrait, ProductAttribute::SANS_PLASTIFICATION, $carrierId, $typeLivraisonNational, $typeLivraison30min, null, null, null, null, $verification,$bordsArrondis,$plastification);
}
if($product->getIsColorLab()){
if($type && $type->getName()){$name = $product->getTitre().' '.$type->getName();}
else{$name = $product->getTitre();}
}else{
if($format && $format->getName()){$name = $product->getTitre().' '.$format->getName();}
else{$name = $product->getTitre().' '.$format->getName();}
}
$array = [
'id' => $id_product,
'name' => $name,
'category' => 'articles',
'price' => $price['prixTtc'] ,
'quantity' => $qty,
];
return $array;
}
return array();
}
public function getListProductsBy($products,$num = null){
$arrays = [];
if($products){
foreach ($products as $product){
if(is_null($num)){
if($product->getProduct() && $product->getProduct()->getId()){
$id = $product->getProduct()->getId();
}else{
$id = '00'.$product->getId();
}
$array = [
'item_id' => $id,
'item_name' => $product->getBesoinProductTextPrix(),
'item_category' => 'articles',
];
}elseif ($num == 1){
$array = [
'item_id' => $product->getProduct()->getId(),
'item_name' => $product->getProductTextPrix(),
'item_category' => 'articles',
];
}elseif(in_array($num ,[2,3,4])){
$array = [
'item_id' => $product->getId(),
'item_name' => $product->getBesoinProductTextTitre(),
'item_category' => 'articles',
];
}
$arrays[] = $array;
}
}
return $arrays;
}
// get product Attribute new nb_designer
public function getProductAttributeNewNbDesigner($request,$id_product,$id_format,$id_grammage,$typeImpression,$rectoverso,$plastificationn=ProductAttribute::SANS_PLASTIFICATION)
{
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product->getIsColorLab()){
$requestData = $request->request->all();
$typeFormatId = isset($requestData['typeFormat'])? $requestData['typeFormat'] : null;
$formatId = isset($requestData['format'])? $requestData['format'] : null;
$specificiteId = isset($requestData['specificite'])? $requestData['specificite'] : null;
$couleurId = isset($requestData['couleur'])? $requestData['couleur'] : null;
$tailleId = isset($requestData['taille'])? $requestData['taille'] : null;
$zoneImpressionId = isset($requestData['zoneImpression'])? $requestData['zoneImpression'] : null;
$nbrCouleurId = isset($requestData['nbrCouleur'])? $requestData['nbrCouleur'] : null;
$gramageId = isset($requestData['gramage'])? $requestData['gramage'] : null;
$supportSuspensionId = isset($requestData['supportSuspension'])? $requestData['supportSuspension'] : null;
$typeCartonId = isset($requestData['typeCarton'])? $requestData['typeCarton'] : null;
$oeilleId = isset($requestData['oeille'])? $requestData['oeille'] : null;
$typeImpressionId = isset($requestData['typeImpression'])? $requestData['typeImpression'] : null;
$format = $formatId ? $this->em->getRepository(Attribut::class)->find($formatId):null;
$gramage = $gramageId ? $this->em->getRepository(Attribut::class)->find($gramageId):null;
$type = $typeFormatId ? $this->em->getRepository(Attribut::class)->find($typeFormatId):null;
$specificite = $specificiteId ? $this->em->getRepository(Attribut::class)->find($specificiteId):null;
$couleur = $couleurId ? $this->em->getRepository(Attribut::class)->find($couleurId):null;
$taille = $tailleId ? $this->em->getRepository(Attribut::class)->find($tailleId):null;
$zoneImpression = $zoneImpressionId ? $this->em->getRepository(Attribut::class)->find($zoneImpressionId):null;
$nbrCouleur = $nbrCouleurId ? $this->em->getRepository(Attribut::class)->find($nbrCouleurId):null;
$supportSuspension = $supportSuspensionId ? $this->em->getRepository(Attribut::class)->find($supportSuspensionId):null;
$typeCarton = $typeCartonId ? $this->em->getRepository(Attribut::class)->find($typeCartonId):null;
$oeille = $oeilleId ? $this->em->getRepository(Attribut::class)->find($oeilleId):null;
$typeImpression = $typeImpressionId ? $this->em->getRepository(Attribut::class)->find($typeImpressionId):null;
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(
array(
'product'=>$id_product,
'format'=>$format? is_object($format)?$format->getId():$format['id']:null,
'gramage'=>$gramage?is_object($gramage)?$gramage->getId():$gramage['id']:null,
'typeImpression'=>$typeImpression?is_object($typeImpression)?$typeImpression->getId():$typeImpression['id']:null,
'typeFormat'=>$type?is_object($type)?$type->getId():$type['id']:null,
'specificite'=>$specificite?is_object($specificite)?$specificite->getId():$specificite['id']:null,
'typeCouleur'=>$couleur?is_object($couleur)?$couleur->getId():$couleur['id']:null,
'taille'=>$taille?is_object($taille)?$taille->getId():$taille['id']:null,
'zoneImpression'=>$zoneImpression?is_object($zoneImpression)?$zoneImpression->getId():$zoneImpression['id']:null,
'nbrCouleur'=>$nbrCouleur?is_object($nbrCouleur)?$nbrCouleur->getId():$nbrCouleur['id']:null,
'supportSuspension'=>$supportSuspension?is_object($supportSuspension)?$supportSuspension->getId():$supportSuspension['id']:null,
'oeille'=>$oeille?is_object($oeille)?$oeille->getId():$oeille['id']:null,
'typeCarton'=>$typeCarton?is_object($typeCarton)?$typeCarton->getId():$typeCarton['id']:null,
'isEnabled'=>true
)
);
}
else {
if ($product and $product->getTypeProduct() == Product::AFFICHE) {
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format' => $id_format, 'gramage' => $id_grammage, 'typeImpression' => $typeImpression, 'plastification' => $plastificationn, 'isEnabled' => true));
} else {
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format' => $id_format, 'gramage' => $id_grammage, 'rectoverso' => $rectoverso, 'isEnabled' => true));
}
}
return $productAttribute;
}
// get price new nb_designer
public function getPrice($id_product,$id_format,$id_grammage,$typeImpression,$rectoverso,$quantite,$finition,$isEnveloppe,$plus_expert=false,$isTrait=false,$plastificationn=ProductAttribute::SANS_PLASTIFICATION,$carrierId = null,$typeLivraisonNational = null,$typeLivraison30min = null,$lat = null,$long = null,$codePostal = null,$imprimeur = null,$verification,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED)
{
$prixHt = null;
$prixTtc = null;
$prixHtWithoutReduction = 0;
$prixTtcWithoutReduction = 0;
$user = $this->security->getUser();
$cart = $this->cart_service->createCart(true);
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product && $product->getIsDeleted()){
return ['productDesabled' => true];
}
// check abonnementPro
$abonnement = $this->cart_service->checkAbonnementToCartOrOrder($user,$cart->getId());
$typeAbonnement = null;
if($abonnement){
$typeAbonnement = $abonnement['type'];
}
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement);
if($product and $product->getTypeProduct() == Product::AFFICHE){
$typeImpression = null;
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_grammage,'typeImpression'=>$typeImpression,'plastification'=>$plastificationn,'isEnabled'=>true));
}else{
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_grammage,'rectoverso'=>$rectoverso,'isEnabled'=>true));
}
if($productAttribute) {
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $quantite);
if ($priceProductAttr) {
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) )* $pourcentageFinition;
$priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
$priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
$priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
$priceVerificationCheckedTtc = 0;
$priceVerificationCheckedHt = 0;
if($verification == CartDetail::VERIFICATION_CHECKED){
$priceVerificationCheckedTtc = CartDetail::VERIFICATION_TTC;
$priceVerificationCheckedHt = CartDetail::VERIFICATION_HT;
}
$priceBordsArrondisHt = 0;
$priceBordsArrondisTtc = 0;
$priceBordsArrondisHtWithoutReduction = 0;
$priceBordsArrondisTtcWithoutReduction = 0;
if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
$priceBordsArrondisHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
}
$pricePlastificationHt = 0;
$pricePlastificationTtc = 0;
$pricePlastificationHtWithoutReduction = 0;
$pricePlastificationTtcWithoutReduction = 0;
if($plastification == CartDetail::PLASTIFICATION_CHECKED){
$pricePlastificationHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_PLASTIFICATION;
}
if($plus_expert){
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHt +$priceVerificationCheckedHt+$priceBordsArrondisHt+$pricePlastificationHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() ) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtc +$priceVerificationCheckedTtc+$priceBordsArrondisTtc+$pricePlastificationTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHtWithoutReduction +$priceVerificationCheckedHt+$priceBordsArrondisHtWithoutReduction+$pricePlastificationHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtcWithoutReduction +$priceVerificationCheckedTtc+$priceBordsArrondisTtcWithoutReduction+$pricePlastificationTtcWithoutReduction;
}else{
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt +$priceVerificationCheckedHt+$priceBordsArrondisHt+$pricePlastificationHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+ $priceFinitonTtc +$priceVerificationCheckedTtc+$priceBordsArrondisTtc+$pricePlastificationTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction +$priceVerificationCheckedHt+$priceBordsArrondisHtWithoutReduction+$pricePlastificationHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+ $priceFinitonTtcWithoutReduction +$priceVerificationCheckedTtc+$priceBordsArrondisTtcWithoutReduction+$pricePlastificationTtcWithoutReduction;
}
if(($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if($isEnveloppe) {
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $quantite);
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $quantite);
$prixHtWithoutReduction = $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT * $quantite);
$prixTtcWithoutReduction = $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC * $quantite);
}
}
$prixHt = $this->cart_service->updatePriceByCountry($prixHt,$product);
$prixTtc = $this->cart_service->updatePriceByCountry($prixTtc,$product);
$prixHtWithoutReduction = $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
$prixTtcWithoutReduction = $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
}
}
$priceAbonnement = [
'pricePro' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_PRO,$product,$productAttribute,$quantite,$finition,$plus_expert,$isEnveloppe,$bordsArrondis,100,100,$plastification),
'priceTeam' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_TEAM,$product,$productAttribute,$quantite,$finition,$plus_expert,$isEnveloppe,$bordsArrondis,100,100,$plastification),
'priceEntreprise' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_ENTREPRISE,$product,$productAttribute,$quantite,$finition,$plus_expert,$isEnveloppe,$bordsArrondis,100,100,$plastification)
];
$dataLocalisation = [
'lat' => $lat,
'longi' => $long,
'codePostal' =>$codePostal ,
];
return $this->getPriceAfterPromoAndAbonnement( $prixHt,$prixTtc,$prixHtWithoutReduction,$prixTtcWithoutReduction,$abonnement,$carrierId,$typeLivraisonNational,$typeLivraison30min,$priceAbonnement,$dataLocalisation,$imprimeur);
}
public function getPriceColorLab($id_product,$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$quantite,$carrierId = null,$typeLivraisonNational = null,$typeLivraison30min = null,$lat = null,$long = null,$codePostal = null,$imprimeur = null,$supportSuspension=null,$formatL=100,$formatH=100,$typeCarton=null,$oeille=null)
{
$prixHt = null;
$prixTtc = null;
$prixHtWithoutReduction = 0;
$prixTtcWithoutReduction = 0;
$user = $this->security->getUser();
$cart = $this->cart_service->createCart(true);
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product && $product->getIsDeleted()){
return ['productDesabled' => true];
}
// check abonnementPro
$abonnement = $this->cart_service->checkAbonnementToCartOrOrder($user,$cart->getId());
$typeAbonnement = null;
if($abonnement){
$typeAbonnement = $abonnement['type'];
}
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement);
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(
array(
'product'=>$id_product,
'format'=>$format? is_object($format)?$format->getId():$format['id']:null,
'gramage'=>$gramage?is_object($gramage)?$gramage->getId():$gramage['id']:null,
'typeImpression'=>$typeImpression?is_object($typeImpression)?$typeImpression->getId():$typeImpression['id']:null,
'typeFormat'=>$type?is_object($type)?$type->getId():$type['id']:null,
'specificite'=>$specificite?is_object($specificite)?$specificite->getId():$specificite['id']:null,
'typeCouleur'=>$couleur?is_object($couleur)?$couleur->getId():$couleur['id']:null,
'taille'=>$taille?is_object($taille)?$taille->getId():$taille['id']:null,
'zoneImpression'=>$zoneImpression?is_object($zoneImpression)?$zoneImpression->getId():$zoneImpression['id']:null,
'nbrCouleur'=>$nbrCouleur?is_object($nbrCouleur)?$nbrCouleur->getId():$nbrCouleur['id']:null,
'supportSuspension'=>$supportSuspension?is_object($supportSuspension)?$supportSuspension->getId():$supportSuspension['id']:null,
'typeCarton'=>$typeCarton?is_object($typeCarton)?$typeCarton->getId():$typeCarton['id']:null,
'oeille'=>$oeille?is_object($oeille)?$oeille->getId():$oeille['id']:null,
'isEnabled'=>true
)
);
if($productAttribute) {
if(in_array($product->getTypeProduct(),[Product::PHOTOS])){
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $quantite);
if ($priceProductAttr) {
$prixHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * $quantite;
$prixTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * $quantite;
$prixHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())) * $quantite;
$prixTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())) * $quantite;
}
}else{
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $quantite);
if ($priceProductAttr) {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}());
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}());
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt());
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc());
}
}
}
//update price by country
$prixHt = $this->cart_service->updatePriceByCountry($prixHt,$product);
$prixTtc = $this->cart_service->updatePriceByCountry($prixTtc,$product);
$prixHtWithoutReduction = $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
$prixTtcWithoutReduction = $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
$priceAbonnement = [
'pricePro' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_PRO,$product,$productAttribute,$quantite,null,null,null,CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$formatL,$formatH),
'priceTeam' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_TEAM,$product,$productAttribute,$quantite,null,null,null,CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$formatL,$formatH),
'priceEntreprise' => $this->gePriceCartWithAbonnementProAndWithTypeProduct(AbonnementPro::TYPE_ENTREPRISE,$product,$productAttribute,$quantite,null,null,null,CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$formatL,$formatH)
];
if(in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
$surface = $formatH * $formatL;
if($surface < 10000){
$surface = 10000;
}
$prixHt *= $surface;
$prixTtc *= $surface;
$prixHtWithoutReduction *= $surface;
$prixTtcWithoutReduction *= $surface;
}
$dataLocalisation = [
'lat' => $lat,
'longi' => $long,
'codePostal' =>$codePostal ,
];
return $this->getPriceAfterPromoAndAbonnement( $prixHt,$prixTtc,$prixHtWithoutReduction,$prixTtcWithoutReduction,$abonnement,$carrierId,$typeLivraisonNational,$typeLivraison30min,$priceAbonnement,$dataLocalisation,$imprimeur);
}
// get btn crello new nb_designer
public function getBtnCrello($request,$format_id){
$requestData = $request->request->all();
$idProduct = isset($requestData['idProduct'])? $requestData['idProduct'] : null;
$product = $this->em->getRepository(Product::class)->find($idProduct);
if($product && $product->getIsColorLab()) {
$typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
$formatId = isset($requestData['format']) ? $requestData['format'] : null;
$specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
$couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
$tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
$zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
$nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
$gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
$supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
$typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
$oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
$typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
$qty = isset($requestData['qty']) ? $requestData['qty'] : null;
$isMobileInterface = isset($requestData['isMobileInterface']) ? $requestData['isMobileInterface'] : null;
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(
array(
'product'=>$idProduct,
'format'=>$formatId,
'gramage'=>$gramageId,
'typeImpression'=>$typeImpressionId,
'typeFormat'=>$typeFormatId,
'specificite'=>$specificiteId,
'typeCouleur'=>$couleurId,
'taille'=>$tailleId,
'zoneImpression'=>$zoneImpressionId,
'nbrCouleur'=>$nbrCouleurId,
'supportSuspension'=>$supportSuspensionId,
'typeCarton'=>$typeCartonId,
'oeille'=>$oeilleId,
'isEnabled'=>true
)
);
$designType = null;
if($productAttribute){
if(!$qty){
$qty = 1;
}
if($productAttribute->getDesignTypeColorLab() and !empty($productAttribute->getDesignTypeColorLab())){
$designType = $productAttribute->getDesignTypeColorLab();
}else{
$resultPrice = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(),$qty);
$designType = $resultPrice->getDesignTypeColorLab();
}
}
return $this->twig->render('front/product-option/btn-crello-new.html.twig', ['isMobileInterface'=>$isMobileInterface,'product'=>$product,'isColorLab' => true,'designType' => $designType,'format'=> $productAttribute->getFormat(),'type'=>$productAttribute->getTypeFormat()]);
}else {
if ($format_id) {
$gramge_id = isset($requestData['gramageVista']) ? $requestData['gramageVista'] : null;
$gramage =$gramge_id ? $this->em->getRepository(Attribut::class)->find($gramge_id):null;
$format = $this->em->getRepository(Attribut::class)->find($format_id);
if($product && !$product->getIsColorLab() && !in_array($product->getTypeProduct(),[Product::PAPIER,Product::PAPIER_POSTE]) ){
return $this->twig->render('front/product-option/btn-crello-new.html.twig', ['product'=>$product,'format' => $format,'gramage'=>$gramage]);
}else{
return $this->twig->render('front/product-option/btn-crello.html.twig', ['product'=>$product,'format' => $format,'gramage'=>$gramage]);
}
}
}
return 1;
}
public function getBtnByProductAttribute($request)
{
$requestData = $request->request->all();
$idProductAttribute = isset($requestData['idProductAttribute']) ? $requestData['idProductAttribute'] : null;
$qty = isset($requestData['qty']) ? $requestData['qty'] : null;
$productAttribute = $this->em->getRepository(ProductAttribute::class)->find($idProductAttribute);
if ($productAttribute) {
if ($productAttribute->getProduct() && $productAttribute->getProduct()->getIsColorLab()) {
if (!$qty) {
$qty = 1;
}
if ($productAttribute->getDesignTypeColorLab() and !empty($productAttribute->getDesignTypeColorLab())) {
$designType = $productAttribute->getDesignTypeColorLab();
} else {
$resultPrice = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
$designType = $resultPrice->getDesignTypeColorLab();
}
return $this->twig->render('front/product-option/btn-select-product-attribute.html.twig', ['product' => $productAttribute->getProduct(), 'isColorLab' => true, 'designType' => $designType]);
} else {
if ($productAttribute->getFormat()) {
$format = $this->em->getRepository(Attribut::class)->find($productAttribute->getFormat()->getId());
return $this->twig->render('front/product-option/btn-select-product-attribute.html.twig', ['product' => $productAttribute->getProduct(), 'format' => $format]);
}
}
}
return 1;
}
public function getOptionByProductAttributeAndFinitionAndQty($request){
$requestData = $request->request->all();
$idProductAttribute = isset($requestData['idProductAttribute']) ? $requestData['idProductAttribute'] : null;
$qty = isset($requestData['qty']) ? $requestData['qty'] : null;
$finition = isset($requestData['finition']) ? $requestData['finition'] : null;
$verification = isset($requestData['verification']) ? $requestData['verification'] : null;
$bordsArrondis = isset($requestData['bordsArrondis']) ? $requestData['bordsArrondis'] : null;
$plastification = isset($requestData['plastification']) ? $requestData['$plastification'] : null;
$productAttribute = $this->em->getRepository(ProductAttribute::class)->find($idProductAttribute);
if ($productAttribute) {
$product = $productAttribute->getProduct();
if($product->getIsColorLab()){
$types = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_FORMAT,null,null,null,null,null,null,null,null,null);
$type = $productAttribute->getTypeFormat();
$formats = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::FORMAT,null,null,null,$type?$type->getId():null,null,null,null,null,null);
$specificites = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SPECIFICITE,null,null,null,$type?$type->getId():null,null,null,null,null,null);
$isFinitionGlace = null;
$isFinitionMate = null;
$isFinitionRepositionalble = null;
$isFinitionTransparent = null;
$isFinitionSoftTouch = null;
$isFinitionPelliculemat = null;
$isFinitionPelliculeBrillant = null;
$couleur = null;
$taille = null;
$nbrCouleur = null;
$gramage = null;
$supportSuspension = null;
$typeCarton = null;
$oeille = null;
$typeImpression = null;
if($formats){
$format = $productAttribute->getFormat();
if($format){
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
$isFinitionTransparent = $format->getIsFinitionTransparent();
$isFinitionRepositionalble = $format->getIsFinitionRepositionalble();
$isFinitionSoftTouch = $format->getIsFinitionSoftTouch();
$isFinitionPelliculemat = $format->getIsFinitionPelliculemat();
$isFinitionPelliculeBrillant = $format->getIsFinitionPelliculeBrillant();
}
}
if($specificites){$specificite = $productAttribute->getSpecificite();}
$couleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,null,null,null,null);
if($couleurs){$couleur = $productAttribute->getTypeCouleur();}
$tailles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TAILLE,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,null,null,null);
if($tailles){$taille = $productAttribute->getTaille();}
$zoneImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::ZONE_IMPRESSION,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,null,null);
if($zoneImpressions){$zoneImpression = $productAttribute->getZoneImpression();}
$nbrCouleurs = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::NBR_COULEUR,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,null);
if($nbrCouleurs){$nbrCouleur = $productAttribute->getNbrCouleur();}
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::GRAMMAGE,$format?$format->getId():null,null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
if($gramages){$gramage = $productAttribute->getGramage();}
$supportSuspensions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::SUPPORT_SUSPENSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null);
if($supportSuspensions){$supportSuspension = $productAttribute->getSupportSuspension();}
$typeImpressions = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_IMPRESSION,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
if($typeImpressions){$typeImpression = $productAttribute->getTypeImpression();}
$typeCartons = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::TYPE_CARTON,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null);
if($typeCartons){$typeCarton = $productAttribute->getTypeCarton();}
$oeilles = $this->em->getRepository(ProductAttribute::class)->getAttrPossibleColorLab($product->getId(),Attribut::OEILLE,$format?$format->getId():null,$gramage?$gramage->getId():null,$typeImpression?$typeImpression->getId():null,$type?$type->getId():null,$specificite?$specificite->getId():null,$couleur?$couleur->getId():null,$taille?$taille->getId():null,$zoneImpression?$zoneImpression->getId():null,$nbrCouleur?$nbrCouleur->getId():null,$supportSuspension?$supportSuspension->getId():null,$typeCarton?$typeCarton->getId():null);
if($oeilles){$oeille = $productAttribute->getOeille();}
$qtys = $this->getQtyPosible($product->getId(),$format,$gramage,$typeImpression,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$supportSuspension,$supportSuspension,$typeCarton,$oeille);
return array(
'product' => $product,
'types' => $types,
'type' => $type,
'formats' => $formats,
'format' => $format,
'specificites' => $specificites,
'specificite' => $specificite,
'couleurs' => $couleurs,
'couleur' => $couleur,
'tailles' => $tailles,
'taille' => $taille,
'zoneImpressions' => $zoneImpressions,
'zoneImpression' => $zoneImpression,
'nbrCouleurs' => $nbrCouleurs,
'nbrCouleur' => $nbrCouleur,
'gramages' => $gramages,
'gramage' => $gramage,
'supportSuspensions' => $supportSuspensions,
'supportSuspension' => $supportSuspension,
'typeCartons' => $typeCartons,
'typeCarton' => $typeCarton,
'oeilles' => $oeilles,
'oeille' => $oeille,
'typeImpressions' => $typeImpressions,
'typeImpression' => $typeImpression,
'isFinitionGlace' => $isFinitionGlace,
'isFinitionMate' => $isFinitionMate,
'isFinitionRepositionalble' => $isFinitionRepositionalble,
'isFinitionTransparent' => $isFinitionTransparent,
'isFinitionSoftTouch' => $isFinitionSoftTouch,
'isFinitionPelliculemat' => $isFinitionPelliculemat,
'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
'finition' => $finition,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'price' => $this->getPriceColorLab($product->getId(),$format,$gramage,null,$type,$specificite,$couleur,$taille,$zoneImpression,$nbrCouleur,$qty,null,null,null,null,null,null,null,$supportSuspension,100,100,$typeCarton,$oeille),
);
}
else {
$id_product = $product->getId();
$formats = $this->em->getRepository(Attribut::class)->getFormatByProduct($product);
$format = $productAttribute->getFormat();
$format_id = $productAttribute->getFormat()->getId();
$rectoverso = $productAttribute->getRectoverso();
$gramage_id = $productAttribute->getGramage()->getId();
if ($product && $product->getTypeProduct() == Product::AFFICHE) {
$typeImpression_id = $productAttribute->getTypeImpression()->getId();
$typeImpression = $this->getTypeImpression($id_product, $format_id);
$gramage = $this->getGrammageByTypeImpression($id_product, $format_id, $typeImpression_id);
$qtys = $this->getQtyPosibleByGrammageAndTypeImpression($gramage_id, $format_id, $typeImpression_id, $productAttribute->getPlastification(), $finition);
} else {
$gramage = $this->getGramage($id_product, $format_id, $rectoverso);
$qtys = $this->getQtyPosibleByGrammage($gramage_id, $format_id, $rectoverso, $finition);
$typeImpression = false;
$typeImpression_id = false;
}
$isFinitionGlace = $format->getIsFinitionGlasse();
$isFinitionMate = $format->getIsFinitionMate();
$isFinitionTransparent = $format->getIsFinitionTransparent();
$isFinitionRepositionalble = $format->getIsFinitionRepositionalble();
$isFinitionSoftTouch = $format->getIsFinitionSoftTouch();
$isFinitionPelliculemat = $format->getIsFinitionPelliculemat();
$isFinitionPelliculeBrillant = $format->getIsFinitionPelliculeBrillant();
$isEnveloppe = 0;
return array(
'isFinitionGlace' => $isFinitionGlace,
'isFinitionMate' => $isFinitionMate,
'isFinitionRepositionalble' => $isFinitionRepositionalble,
'isFinitionSoftTouch' => $isFinitionSoftTouch,
'isFinitionPelliculemat' => $isFinitionPelliculemat,
'isFinitionPelliculeBrillant' => $isFinitionPelliculeBrillant,
'isFinitionTransparent' => $isFinitionTransparent,
'formats' => $formats,
'format_id' => $format_id,
'format' => $format,
'gramage' => $gramage,
'gramage_id' => $gramage_id,
'typeImpression' => $typeImpression,
'typeImpression_id' => $typeImpression_id,
'qtys' => $qtys['qtys'],
'qtysPlus' => $qtys['qtysPlus'],
'qtysTeam' => $qtys['qtysTeam'],
'qty' => $qty,
'id_product' => $id_product,
'product' => $product,
'rectoverso' => $rectoverso,
'finition' => $finition,
'isEnveloppe' => $isEnveloppe,
'verification' => $verification,
'bordsArrondis' => $bordsArrondis,
'plastification' => $plastification,
'price' => $this->getPrice($id_product, $format_id, $gramage_id, $typeImpression_id, $rectoverso, $qty, $finition, $isEnveloppe, false, false, $productAttribute->getPlastification(), null, null, null, null, null, null, null, $verification,$bordsArrondis,$plastification),
);
}
}
return [];
}
public function gePriceCartWithAbonnementProAndWithTypeProduct($typeAbonnement,$product,$productAttribute,$quantite,$finition,$plus_expert,$isEnveloppe,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$formatL=100,$formatH=100,$plastification = CartDetail::PLASTIFICATION_NOT_CHECKED){
if($productAttribute) {
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement);
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $quantite);
if ($priceProductAttr) {
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) )* $pourcentageFinition;
$priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
$priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
$priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
$priceBordsArrondisHt = 0;
$priceBordsArrondisTtc = 0;
$priceBordsArrondisHtWithoutReduction = 0;
$priceBordsArrondisTtcWithoutReduction = 0;
if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
$priceBordsArrondisHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
}
$pricePlastificationHt = 0;
$pricePlastificationTtc = 0;
$pricePlastificationHtWithoutReduction = 0;
$pricePlastificationTtcWithoutReduction = 0;
if($plastification == CartDetail::PLASTIFICATION_CHECKED){
$pricePlastificationHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_PLASTIFICATION;
}
// if($plus_expert && $isCrea){
if($plus_expert){
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHt + $priceBordsArrondisHt + $pricePlastificationHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() ) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtc + $priceBordsArrondisTtc + $pricePlastificationTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHtWithoutReduction + $priceBordsArrondisHtWithoutReduction + $pricePlastificationHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtcWithoutReduction + $priceBordsArrondisTtcWithoutReduction + $pricePlastificationTtcWithoutReduction;
}else{
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt + $priceBordsArrondisHt + $pricePlastificationHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+ $priceFinitonTtc + $priceBordsArrondisTtc + $pricePlastificationTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction + $priceBordsArrondisHtWithoutReduction + $pricePlastificationHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+ $priceFinitonTtcWithoutReduction + $priceBordsArrondisTtcWithoutReduction + $pricePlastificationTtcWithoutReduction;
}
if(($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if($isEnveloppe) {
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $quantite);
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $quantite);
$prixHtWithoutReduction = $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT * $quantite);
$prixTtcWithoutReduction = $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC * $quantite);
}
}
$surface = 1;
if(in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
$surface = $formatL * $formatH;
if($surface <10000){
$surface = 10000;
}
}
$prixHt = $this->cart_service->updatePriceByCountry($prixHt,$product);
$prixTtc = $this->cart_service->updatePriceByCountry($prixTtc,$product);
$prixHtWithoutReduction = $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
$prixTtcWithoutReduction = $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
return [
'prixHtTotal' => number_format((float)$prixHt * $surface,2),
'prixTtcTotal' => number_format((float)$prixTtc * $surface,2),
'prixHtWithoutReductionTotal' => number_format((float)$prixHtWithoutReduction * $surface,2),
'prixTtcWithoutReductionTotal' => number_format((float)$prixTtcWithoutReduction * $surface,2)
];
}
}
return [
'prixHtTotal' => 0,
'prixTtcTotal' => 0,
'prixHtWithoutReductionTotal' => 0,
'prixTtcWithoutReductionTotal' => 0
];
}
// add to cart new nb_designer
private function getFilePhotoQuantiy($filesToken){
if($filesToken){
$array = explode(',',$filesToken);
return count($array);
}
return 0;
}
private function addFilesInCartDetail($filesToken,$cartDetail){
if($filesToken){
$array = explode(',',$filesToken);
foreach ($array as $item) {
$file = $this->em->getRepository(CartDetailPhotos::class)->findOneBy(['token' => $item]);
if ($file) {
$file->setCartDetail($cartDetail);
$this->em->persist($file);
$this->em->flush();
}
}
}
}
private function addFilesPhotoInZip($filesToken,$token){
$array = [];
if($filesToken){
$zip = new \ZipArchive();
$nameFichier = 'ma_crea_' . $token . '.zip';
$zipfile = $this->params->get('uploads_directory') . '/tmp/' . $nameFichier;
if (file_exists($zipfile)) unlink($zipfile);
if ($zip->open($zipfile, \ZipArchive::CREATE) === TRUE) {
$arrayToken = explode(',', $filesToken);
$filePapierFirstImage = null;
foreach ($arrayToken as $key => $item) {
$file = $this->em->getRepository(CartDetailPhotos::class)->findOneBy(['token' => $item]);
if ($file) {
if($key == 0){
$filePapierFirstImage = $file->getFile();
}
$zip->addFile($this->params->get('uploads_directory') . '/tmp/' . $file->getFile(), $file->getFile());
}
}
$zip->close();
$array['fileZipe'] = $nameFichier;
$array['filePapierFirstImage'] = $filePapierFirstImage;
}
}
return $array;
}
public function addToCartNewNbDesigner($request,$user) : array
{
$requestData = $request->request->all();
$productId = isset($requestData['idProduct'])? $requestData['idProduct'] : null;
$qty = isset($requestData['qty'])? $requestData['qty'] : null;
$id_format = isset($requestData['format_id'])? $requestData['format_id'] : null;
$rectoverso = isset($requestData['rectoverso'])? $requestData['rectoverso'] : null;
$finition = isset($requestData['finition'])? $requestData['finition'] : null;
$id_grammage = isset($requestData['gramage_id'])? $requestData['gramage_id'] : null;
$typeImpression = isset($requestData['typeImpression_id'])? $requestData['typeImpression_id'] : null;
$isEnveloppe = isset($requestData['isEnveloppe'])? $requestData['isEnveloppe'] : false;
$verification = isset($requestData['verification'])? $requestData['verification'] : false;
$bordsArrondis = isset($requestData['bordsArrondis'])? $requestData['bordsArrondis'] : false;
$plastification = isset($requestData['plastification'])? $requestData['plastification'] : false;
$plus_expert = isset($requestData['plus_expert'])? $requestData['plus_expert'] : false;
$isTrait = isset($requestData['isTrait'])? $requestData['isTrait'] : false;
$isFontBlanc = isset($requestData['isFontBlanc'])? $requestData['isFontBlanc'] : 0;
$tokenDetail = isset($requestData['tokenDetail'])? $requestData['tokenDetail'] : null;
$designUrl = isset($requestData['designUrl'])? $requestData['designUrl'] : null;
$designId = isset($requestData['designId'])? $requestData['designId'] : null;
$fileDesignUrl = isset($requestData['fileDesignUrl'])? $requestData['fileDesignUrl'] : null;
$fileDesignFirstImage = isset($requestData['fileDesignFirstImage'])? $requestData['fileDesignFirstImage'] : null;
$typeFormatId = isset($requestData['typeFormat']) ? $requestData['typeFormat'] : null;
$formatId = isset($requestData['format']) ? $requestData['format'] : null;
$specificiteId = isset($requestData['specificite']) ? $requestData['specificite'] : null;
$couleurId = isset($requestData['couleur']) ? $requestData['couleur'] : null;
$tailleId = isset($requestData['taille']) ? $requestData['taille'] : null;
$zoneImpressionId = isset($requestData['zoneImpression']) ? $requestData['zoneImpression'] : null;
$nbrCouleurId = isset($requestData['nbrCouleur']) ? $requestData['nbrCouleur'] : null;
$gramageId = isset($requestData['gramage']) ? $requestData['gramage'] : null;
$supportSuspensionId = isset($requestData['supportSuspension']) ? $requestData['supportSuspension'] : null;
$typeCartonId = isset($requestData['typeCarton']) ? $requestData['typeCarton'] : null;
$oeilleId = isset($requestData['oeille']) ? $requestData['oeille'] : null;
$typeImpressionId = isset($requestData['typeImpression']) ? $requestData['typeImpression'] : null;
$formatL = isset($requestData['formatL'])? $requestData['formatL'] : 100;
$formatH = isset($requestData['formatH'])? $requestData['formatH'] : 100;
$photosToken = isset($requestData['photosToken']) ? $requestData['photosToken'] : null;
$product = $this->em->getRepository(Product::class)->find($productId);
if($tokenDetail){
$cartDetail = $this->em->getRepository(CartDetail::class)->findOneBy(['token'=>$tokenDetail]);
if(!$cartDetail){
return ['erreur'=> 'erreur !'];
}
$token = $cartDetail->getToken();
}else{
$cartDetail = new CartDetail();
$token = $this->generateToken(32);
}
$cart = $this->cart_service->getCartCurrent();
if(!$cart){
$cart = $this->cart_service->createCart(true);
}
$typeAbonnement = $this->cart_service->getTypeAbonnementPro($user,$cart->getId()); // get type abonnement
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
$cartDetail->setTypeProduct($product->getTypeProduct());
$cartDetail->setToken($token);
$cartDetail->setProduct($product);
$cartDetail->setCart($cart);
if($photosToken){
$qty = $this->getFilePhotoQuantiy($photosToken);
$cartDetail->setNbrPapier($qty);
}else{
$cartDetail->setNbrPapier($qty);
}
$cartDetail->setQty(0);
$cartDetail->setQtyColor(0);
$cartDetail->setQtyNoir(0);
$cartDetail->setProductName($product->getTitre());
if(in_array($product->getTypeProduct(),[Product::PHOTOS])){
if($photosToken){
$arrayFiles = $this->addFilesPhotoInZip($photosToken,$token);
}else{
return ['erreur'=> 'il faut uploader les photos'];
}
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(
array(
'product'=>$productId,
'format'=>$formatId,
'gramage'=>$gramageId,
'typeImpression'=>$typeImpressionId,
'typeFormat'=>$typeFormatId,
'specificite'=>$specificiteId,
'typeCouleur'=>$couleurId,
'taille'=>$tailleId,
'zoneImpression'=>$zoneImpressionId,
'nbrCouleur'=>$nbrCouleurId,
'supportSuspension'=>$supportSuspensionId,
'typeCarton'=>$typeCartonId,
'oeille'=>$oeilleId,
'isEnabled'=>true
)
);
if(!$productAttribute ){
return ['erreur'=> 'il faut choisr un produit'];
}
$cartDetail->setIsMaCrea(true);
if($arrayFiles && isset($arrayFiles['fileZipe']) && isset($arrayFiles['filePapierFirstImage'])){
$fileDesignUrl = $arrayFiles['fileZipe'];
$filePapierFirstImage = $arrayFiles['filePapierFirstImage'];
$cartDetail->setFilePapier($fileDesignUrl);
$cartDetail->setFilePapierFirstImage($filePapierFirstImage);
$name = str_replace(' ','_',$product->getTitre());
$cartDetail->setFilePapierName($name.'-'.$fileDesignUrl);
}
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), (int)$qty);;
if($priceProductAttr->getIsExaprint()){
$cartDetail->setIsExaprint(true);
}else{
$cartDetail->setIsExaprint(false);
}
$cartDetail->setMauvaisFormat($isFontBlanc);
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = (($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* $pourcentageFinition) * (int)$qty;
$priceFinitonTtc = (($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))*$pourcentageFinition) * (int)$qty;
$priceFinitonHtWithoutReduction = (($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition) * (int)$qty;
$priceFinitonTtcWithoutReduction = (($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition) * (int)$qty;
$priceVerificationCheckedTtc = 0;
$priceVerificationCheckedHt = 0;
if($verification == CartDetail::VERIFICATION_CHECKED){
$priceVerificationCheckedTtc = CartDetail::VERIFICATION_TTC;
$priceVerificationCheckedHt = CartDetail::VERIFICATION_HT;
}
$priceBordsArrondisHt = 0;
$priceBordsArrondisTtc = 0;
$priceBordsArrondisHtWithoutReduction = 0;
$priceBordsArrondisTtcWithoutReduction = 0;
if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
$priceBordsArrondisHt = (($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())))* CartDetail::POURCENTAGE_BORDS_ARRONDIS* (int)$qty;
$priceBordsArrondisTtc = (($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())))* CartDetail::POURCENTAGE_BORDS_ARRONDIS* (int)$qty;
$priceBordsArrondisHtWithoutReduction = (($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())))* CartDetail::POURCENTAGE_BORDS_ARRONDIS* (int)$qty;
$priceBordsArrondisTtcWithoutReduction = (($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())))* CartDetail::POURCENTAGE_BORDS_ARRONDIS* (int)$qty;
}
$pricePlastificationHt = 0;
$pricePlastificationTtc = 0;
$pricePlastificationHtWithoutReduction = 0;
$pricePlastificationTtcWithoutReduction = 0;
if($plastification == CartDetail::PLASTIFICATION_CHECKED){
$pricePlastificationHt = (($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())))* CartDetail::POURCENTAGE_PLASTIFICATION* (int)$qty;
$pricePlastificationTtc = (($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())))* CartDetail::POURCENTAGE_PLASTIFICATION* (int)$qty;
$pricePlastificationHtWithoutReduction = (($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())))* CartDetail::POURCENTAGE_PLASTIFICATION* (int)$qty;
$pricePlastificationTtcWithoutReduction = (($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())))* CartDetail::POURCENTAGE_PLASTIFICATION* (int)$qty;
}
$prixHt = (($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * (int)$qty)+$priceFinitonHt +$priceVerificationCheckedHt + $priceBordsArrondisHt + $pricePlastificationHt;
$prixTtc = (($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * (int)$qty)+$priceFinitonTtc + $priceVerificationCheckedTtc + $priceBordsArrondisTtc + $pricePlastificationTtc;
$prixHtWithoutReduction = (($priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())) * (int)$qty)+$priceFinitonHtWithoutReduction +$priceVerificationCheckedHt + $priceBordsArrondisHtWithoutReduction + $pricePlastificationHtWithoutReduction;
$prixTtcWithoutReduction = (($priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())) * (int)$qty)+$priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc + $priceBordsArrondisTtcWithoutReduction + $pricePlastificationTtcWithoutReduction;
$cartDetail->setIsEnveloppe($isEnveloppe);
$cartDetail->setIsPlusExpert($plus_expert);
$cartDetail->setFinition($finition);
$cartDetail->setIsPlusVerification($verification);
$cartDetail->setIsPlusBordsArrondis($bordsArrondis);
$cartDetail->setIsPlusPlastification($plastification);
$cartDetail->setIsTrait($isTrait);
}else{
if($product->getIsColorLab()){
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(
array(
'product'=>$productId,
'format'=>$formatId,
'gramage'=>$gramageId,
'typeImpression'=>$typeImpressionId,
'typeFormat'=>$typeFormatId,
'specificite'=>$specificiteId,
'typeCouleur'=>$couleurId,
'taille'=>$tailleId,
'zoneImpression'=>$zoneImpressionId,
'nbrCouleur'=>$nbrCouleurId,
'supportSuspension'=>$supportSuspensionId,
'oeille'=>$oeilleId,
'typeCarton'=>$typeCartonId,
'isEnabled'=>true
)
);
if(!$productAttribute ){
return ['erreur'=> 'il faut choisr un produit'];
}
$designColorLabTokenProduct = isset($requestData['designColorLabTokenProduct']) ? $requestData['designColorLabTokenProduct'] : null;
$designColorLabIdProduct = isset($requestData['designColorLabIdProduct']) ? $requestData['designColorLabIdProduct'] : null;
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
if($priceProductAttr->getIsExaprint()){
$cartDetail->setIsExaprint(true);
}else{
$cartDetail->setIsExaprint(false);
}
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* $pourcentageFinition;
$priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
$priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
$priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())+$priceFinitonHt ;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+$priceFinitonTtc ;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())+$priceFinitonHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+$priceFinitonTtcWithoutReduction;
$surface = 1;
if(in_array($product->getTypeProduct(), [ Product::VITROPHANIE,Product::PAPIER_CADEAU,Product::ETIQUETTE_ROULEAU])){
$surface = $formatL * $formatH;
if($surface < 10000){
$surface = 10000;
}
$prixHt *= $surface;
$prixTtc *= $surface;
$prixHtWithoutReduction *= $surface;
$prixTtcWithoutReduction *= $surface;
$cartDetail->setFormatHauteur($formatH);
$cartDetail->setFormatLargeur($formatL);
}
$filePapierFirstImage = null;
if($designColorLabTokenProduct && $designColorLabIdProduct){
$dataPdf = $this->downloadPdfColorlab($request,$designColorLabTokenProduct,$designColorLabIdProduct,$token);
$filePapier = isset($dataPdf['pdfName'])? $dataPdf['pdfName'] : false;
$filePapierFirstImage = isset($dataPdf['firstImage'])? $dataPdf['firstImage'] : false;
if(!$filePapier || !$filePapierFirstImage ){
return ['erreur'=> 'erreur convert pdf !'];
}
$cartDetail->setIsMaCrea(false);
$cartDetail->setFilePapier($filePapier);
$cartDetail->setFilePapierFirstImage($filePapierFirstImage);
$name = str_replace(' ','_',$product->getTitre());
$cartDetail->setFilePapierName($name.'-'.$filePapier);
$cartDetail->setColorLabTokenProduct($designColorLabTokenProduct);
$cartDetail->setColorLabIdProduct($designColorLabIdProduct);
}else if($fileDesignUrl){
$filePapierFirstImage = $fileDesignFirstImage;
$cartDetail->setIsMaCrea(true);
$cartDetail->setFilePapier($fileDesignUrl);
$cartDetail->setFilePapierFirstImage($filePapierFirstImage);
$name = str_replace(' ','_',$product->getTitre());
$cartDetail->setFilePapierName($name.'-'.$fileDesignUrl);
}else if($tokenDetail ){
$filePapierFirstImage = $cartDetail->getFilePapierFirstImage();
}
}
else{
if(!$productId || !$qty || !$id_format ){
return ['erreur'=> 'il faut choisr un produit'];
}
if($designUrl){
$dataPdf = $this->downloadPdfCrello($request,$designUrl,$token);
$filePapier = isset($dataPdf['pdfName'])? $dataPdf['pdfName'] : false;
$filePapierFirstImage = isset($dataPdf['firstImage'])? $dataPdf['firstImage'] : false;
if(!$filePapier || !$filePapierFirstImage ){
return ['erreur'=> 'erreur convert pdf !'];
}
$cartDetail->setIsMaCrea(false);
$cartDetail->setFilePapier($filePapier);
$cartDetail->setFilePapierFirstImage($filePapierFirstImage);
if($product->getTypeProduct() == Product::CARTE){
$name = 'carte-visite';
}else if($product->getTypeProduct() == Product::FLYERS){
$name = 'flyrs';
}else if($product->getTypeProduct() == Product::AFFICHE){
$name = 'affiche';
}else if($product->getTypeProduct() == Product::MENU){
$name = 'menu';
}else if($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
$name = 'faire_naissance';
}else if($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
$name = 'faire_mariage';
}else{
$name = str_replace(' ','_',$product->getTitre());
}
$cartDetail->setFilePapierName($name.'-'.$filePapier);
$cartDetail->setTemplateIdCrello($designId);
}else if($fileDesignUrl){
$filePapierFirstImage = $fileDesignFirstImage;
$cartDetail->setIsMaCrea(true);
$cartDetail->setFilePapier($fileDesignUrl);
$cartDetail->setFilePapierFirstImage($filePapierFirstImage);
if($product->getTypeProduct() == Product::CARTE){
$name = 'carte-visite';
}else if($product->getTypeProduct() == Product::FLYERS){
$name = 'flyrs';
}else if($product->getTypeProduct() == Product::AFFICHE){
$name = 'affiche';
}else if($product->getTypeProduct() == Product::MENU){
$name = 'menu';
}else if($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
$name = 'faire_naissance';
}else if($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
$name = 'faire_mariage';
}else{
$name = str_replace(' ','_',$product->getTitre());
}
$cartDetail->setFilePapierName($name.'-'.$fileDesignUrl);
}else if($tokenDetail ){
$filePapierFirstImage = $cartDetail->getFilePapierFirstImage();
}else if($designId){
return ['erreur'=> 'Vous n\'avez pas choisi votre modéle'];
}
if($product and $product->getTypeProduct() == Product::AFFICHE){
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_grammage,'typeImpression'=>$typeImpression,'plastification'=>ProductAttribute::SANS_PLASTIFICATION,'isEnabled'=>true));
}else{
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_grammage,'rectoverso'=>$rectoverso,'isEnabled'=>true));
}
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
if($priceProductAttr->getIsExaprint()){
$cartDetail->setIsExaprint(true);
}else{
$cartDetail->setIsExaprint(false);
}
$cartDetail->setMauvaisFormat($isFontBlanc);
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* $pourcentageFinition;
$priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
$priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
$priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
$priceVerificationCheckedTtc = 0;
$priceVerificationCheckedHt = 0;
if($verification == CartDetail::VERIFICATION_CHECKED){
$priceVerificationCheckedTtc = CartDetail::VERIFICATION_TTC;
$priceVerificationCheckedHt = CartDetail::VERIFICATION_HT;
}
$priceBordsArrondisHt = 0;
$priceBordsArrondisTtc = 0;
$priceBordsArrondisHtWithoutReduction = 0;
$priceBordsArrondisTtcWithoutReduction = 0;
if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
$priceBordsArrondisHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
}
$pricePlastificationHt = 0;
$pricePlastificationTtc = 0;
$pricePlastificationHtWithoutReduction = 0;
$pricePlastificationTtcWithoutReduction = 0;
if($plastification == CartDetail::PLASTIFICATION_CHECKED){
$pricePlastificationHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* CartDetail::POURCENTAGE_PLASTIFICATION;
}
if($plus_expert){
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHt +$priceVerificationCheckedHt + $priceBordsArrondisHt + $pricePlastificationHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtc + $priceVerificationCheckedTtc + $priceBordsArrondisTtc + $pricePlastificationTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHtWithoutReduction +$priceVerificationCheckedHt + $priceBordsArrondisHtWithoutReduction + $pricePlastificationHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc + $priceBordsArrondisTtcWithoutReduction + $pricePlastificationTtcWithoutReduction;
}else {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())+$priceFinitonHt +$priceVerificationCheckedHt + $priceBordsArrondisHt + $pricePlastificationHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+$priceFinitonTtc + $priceVerificationCheckedTtc + $priceBordsArrondisTtc + $pricePlastificationTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())+$priceFinitonHtWithoutReduction +$priceVerificationCheckedHt + $priceBordsArrondisHtWithoutReduction + $pricePlastificationHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+$priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc + $priceBordsArrondisTtcWithoutReduction + $pricePlastificationTtcWithoutReduction;
}
if(($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if($isEnveloppe) {
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $qty);
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $qty);
$prixHtWithoutReduction = $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT * $qty);
$prixTtcWithoutReduction = $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC * $qty);
}
}
$cartDetail->setIsEnveloppe($isEnveloppe);
$cartDetail->setIsPlusExpert($plus_expert);
$cartDetail->setFinition($finition);
$cartDetail->setIsPlusVerification($verification);
$cartDetail->setIsPlusBordsArrondis($bordsArrondis);
$cartDetail->setIsPlusPlastification($plastification);
$cartDetail->setIsTrait($isTrait);
}
}
$prixHt = $this->cart_service->updatePriceByCountry($prixHt,$product);
$prixTtc = $this->cart_service->updatePriceByCountry($prixTtc,$product);
$prixHtWithoutReduction = $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
$prixTtcWithoutReduction = $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
$cartDetail->setProductAttribute($productAttribute);
$cartDetail->setPrixHt($prixHt);
$cartDetail->setPrixTtc($prixTtc);
$cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
$cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
// add carrier
$imprimeurLivraison = isset($requestData['imprimeurLivraison'])? $requestData['imprimeurLivraison'] : null;
$dateLivraison = isset($requestData['dateLivraison'])? $requestData['dateLivraison'] : null;
$timeLivraison = isset($requestData['timeLivraison'])? $requestData['timeLivraison'] : null;
$carrierId = isset($requestData['carrierId'])? $requestData['carrierId'] : null;
$typeLivraisonNational = isset($requestData['typeLivraisonNational'])? $requestData['typeLivraisonNational'] : null;
$typeLivraison30min = isset($requestData['typeLivraison30min'])? $requestData['typeLivraison30min'] : null;
$lat = isset($requestData['latLiv'])? $requestData['latLiv'] : null;
$long = isset($requestData['longLiv'])? $requestData['longLiv'] : null;
$codePostal = isset($requestData['codePostalLiv'])? $requestData['codePostalLiv'] : null;
$idServicePointNationInput = isset($requestData['idServicePointNationInput'])? $requestData['idServicePointNationInput'] : null;
if($carrierId){
$carrier = $this->em->getRepository(Carrier::class)->find($carrierId);
$cartDetail->setCarrier($carrier);
$carrierNationalJ1 = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J1));
$carrierNationalJ5 = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J5));
$carrierNationalJ2 = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J2));
$carrier30MIN = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::STUART));
$carrierRetrait = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::RETRAIT));
if($imprimeurLivraison){
$imprimeur = $this->em->getRepository(Imprimeur::class)->find($imprimeurLivraison);
$cartDetail->setImprimeur($imprimeur);
$dataLocalisation = [
'lat' => $lat,
'longi' => $long,
'codePostal' =>$codePostal ,
];
if($carrier == $carrier30MIN){
if($dateLivraison and $timeLivraison){
$time = explode(' - ', $timeLivraison);
if(isset($time[0]) and isset($time[1]) ){
$dateStart = new \DateTime($dateLivraison.' '.$time[0]);
$dateEnd = new \DateTime($dateLivraison.' '.$time[1]);
$cartDetail->setDateStart($dateStart);
$cartDetail->setDateEnd($dateEnd);
}
}
$typeLivraison30min = $this->cart_service->getTypeLivraison30min($imprimeurLivraison,$dataLocalisation);
$cartDetail->setTypeLivraison30min($typeLivraison30min);
}else if($carrier == $carrierNationalJ1){
$cartDetail->setIdServicePointLivraison($idServicePointNationInput);
$cartDetail->setTypeLivraisonNational($typeLivraisonNational);
if($carrier->getNum() == Carrier::J1){
$cartDetail->setDateEstimeLivraisonNational($this->cart_service->checkdateLivraisonNational());
}else{
$cartDetail->setDateEstimeLivraisonNational(null);
}
}
}
}
$this->em->persist($cartDetail);
$this->em->flush();
if($photosToken) {
$this->addFilesInCartDetail($photosToken, $cartDetail);
}
$this->cart_service->removeCartDetailPapierPoste($cart,$cartDetail,true); //remove Papier Poste
$this->cart_service->updatePriceCart($cart);
$isSaveCrelloImport = isset($requestData['isSaveCrelloImport'])? $requestData['isSaveCrelloImport'] : 0;
$catSaveCrello = isset($requestData['catSaveCrello'])? $requestData['catSaveCrello'] : 0;
if($isSaveCrelloImport != 0){
$this->saveClientFiles($cartDetail->getToken(),$catSaveCrello,$user);
}
return array('token'=>$cartDetail->getToken(),'cartDetail'=>$cartDetail,'succes'=>true,'redirect'=> $this->generateUrl('checkout'),'erreur'=>false,'image'=>$filePapierFirstImage);
}
public function addToCartNewNbDesignerNosCrea($request,$user,$id)
{
$url = $request->get('urlCrelloTemplate');
$designId = $request->get('idDesign');
$crea = $this->em->getRepository(NosCrea::class)->find($id);
if(is_object($crea)) {
$product = $crea->getProduct();
$qty = $crea->getProductPrice()->getQty();
$finition = CartDetail::FINITION_GLACE;
$isEnveloppe = null;
$verification = CartDetail::VERIFICATION_CHECKED;
$plus_expert = null;
$isTrait = null;
$isFontBlanc = null;
$productAttribute = $crea->getProductAttribute();
$cartDetail = new CartDetail();
$token = $this->generateToken(32);
$dataPdf = $this->downloadPdfCrello($request,$url,$token);
$filePapier = isset($dataPdf['pdfName'])? $dataPdf['pdfName'] : false;
$filePapierFirstImage = isset($dataPdf['firstImage'])? $dataPdf['firstImage'] : false;
if(!$filePapier || !$filePapierFirstImage ){
return ['erreur'=> 'erreur convert pdf !'];
}
$cartDetail->setIsMaCrea(false);
$cartDetail->setFilePapier($filePapier);
$cartDetail->setFilePapierFirstImage($filePapierFirstImage);
if($product->getTypeProduct() == Product::CARTE){
$name = 'carte-visite';
}else if($product->getTypeProduct() == Product::FLYERS){
$name = 'flyrs';
}else if($product->getTypeProduct() == Product::AFFICHE){
$name = 'affiche';
}else if($product->getTypeProduct() == Product::MENU){
$name = 'menu';
}else if($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
$name = 'faire_naissance';
}else if($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
$name = 'faire_mariage';
}else{
$name = str_replace(' ','_',$product->getTitre());
}
$cartDetail->setFilePapierName($name.'-'.$filePapier);
$cartDetail->setTemplateIdCrello($designId);
$cart = $this->cart_service->getCartCurrent();
if (!$cart) {
$cart = $this->cart_service->createCart(true);
}
$typeAbonnement = $this->cart_service->getTypeAbonnementPro($user, $cart->getId()); // get type abonnement
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
$cartDetail->setTypeProduct($product->getTypeProduct());
$cartDetail->setToken($token);
$cartDetail->setProductAttribute($productAttribute);
$cartDetail->setProduct($product);
$cartDetail->setCart($cart);
$cartDetail->setNbrPapier($qty);
$cartDetail->setQty(0);
$cartDetail->setQtyColor(0);
$cartDetail->setQtyNoir(0);
$cartDetail->setProductName($product->getTitre());
$cartDetail->setMauvaisFormat($isFontBlanc);
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * $pourcentageFinition;
$priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * $pourcentageFinition;
$priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt())) * $pourcentageFinition;
$priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc())) * $pourcentageFinition;
$priceVerificationCheckedTtc = 0;
$priceVerificationCheckedHt = 0;
if ($verification == CartDetail::VERIFICATION_CHECKED) {
$priceVerificationCheckedTtc = CartDetail::VERIFICATION_TTC;
$priceVerificationCheckedHt = CartDetail::VERIFICATION_HT;
}
if ($plus_expert) {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT + $priceFinitonHt + $priceVerificationCheckedHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC + $priceFinitonTtc + $priceVerificationCheckedTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT + $priceFinitonHtWithoutReduction + $priceVerificationCheckedHt;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC + $priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc;
} else {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt + $priceVerificationCheckedHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + $priceFinitonTtc + $priceVerificationCheckedTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction + $priceVerificationCheckedHt;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc()) + $priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc;
}
if (($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if ($isEnveloppe) {
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $qty);
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $qty);
$prixHtWithoutReduction = $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT * $qty);
$prixTtcWithoutReduction = $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC * $qty);
}
}
// update price by country
$prixHt = $this->cart_service->updatePriceByCountry($prixHt,$product);
$prixTtc = $this->cart_service->updatePriceByCountry($prixTtc,$product);
$prixHtWithoutReduction = $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
$prixTtcWithoutReduction = $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
$cartDetail->setPrixHt($prixHt);
$cartDetail->setPrixTtc($prixTtc);
$cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
$cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
$cartDetail->setIsEnveloppe($isEnveloppe);
$cartDetail->setIsPlusExpert($plus_expert);
$cartDetail->setFinition($finition);
$cartDetail->setIsPlusVerification($verification);
$cartDetail->setIsTrait($isTrait);
$this->em->persist($cartDetail);
$this->em->flush();
$this->cart_service->removeCartDetailPapierPoste($cart, $cartDetail, true); //remove Papier Poste
$this->cart_service->updatePriceCart($cart);
return $cartDetail;
}
return false;
}
public function addToCartNewNbDesignerTemplatePageNosCrea($request,$user,$id)
{
$url = $request->get('urlCrelloTemplate');
$designId = $request->get('idDesign');
$crea = $this->em->getRepository(TemplatesPage::class)->find($id);
if(is_object($crea)) {
$product = $crea->getProduct();
$qty = $crea->getProductPrice()->getQty();
$finition = CartDetail::FINITION_GLACE;
$isEnveloppe = null;
$verification = CartDetail::VERIFICATION_CHECKED;
$plus_expert = null;
$isTrait = null;
$isFontBlanc = null;
$productAttribute = $crea->getProductAttribute();
$cartDetail = new CartDetail();
$token = $this->generateToken(32);
$dataPdf = $this->downloadPdfCrello($request,$url,$token);
$filePapier = isset($dataPdf['pdfName'])? $dataPdf['pdfName'] : false;
$filePapierFirstImage = isset($dataPdf['firstImage'])? $dataPdf['firstImage'] : false;
if(!$filePapier || !$filePapierFirstImage ){
return ['erreur'=> 'erreur convert pdf !'];
}
$cartDetail->setIsMaCrea(false);
$cartDetail->setFilePapier($filePapier);
$cartDetail->setFilePapierFirstImage($filePapierFirstImage);
if($product->getTypeProduct() == Product::CARTE){
$name = 'carte-visite';
}else if($product->getTypeProduct() == Product::FLYERS){
$name = 'flyrs';
}else if($product->getTypeProduct() == Product::AFFICHE){
$name = 'affiche';
}else if($product->getTypeProduct() == Product::MENU){
$name = 'menu';
}else if($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
$name = 'faire_naissance';
}else if($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
$name = 'faire_mariage';
}else{
$name = str_replace(' ','_',$product->getTitre());
}
$cartDetail->setFilePapierName($name.'-'.$filePapier);
$cartDetail->setTemplateIdCrello($designId);
$cart = $this->cart_service->getCartCurrent();
if (!$cart) {
$cart = $this->cart_service->createCart(true);
}
$typeAbonnement = $this->cart_service->getTypeAbonnementPro($user, $cart->getId()); // get type abonnement
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
$cartDetail->setTypeProduct($product->getTypeProduct());
$cartDetail->setToken($token);
$cartDetail->setProductAttribute($productAttribute);
$cartDetail->setProduct($product);
$cartDetail->setCart($cart);
$cartDetail->setNbrPapier($qty);
$cartDetail->setQty(0);
$cartDetail->setQtyColor(0);
$cartDetail->setQtyNoir(0);
$cartDetail->setProductName($product->getTitre());
$cartDetail->setMauvaisFormat($isFontBlanc);
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * $pourcentageFinition;
$priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * $pourcentageFinition;
$priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt())) * $pourcentageFinition;
$priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc())) * $pourcentageFinition;
$priceVerificationCheckedTtc = 0;
$priceVerificationCheckedHt = 0;
if ($verification == CartDetail::VERIFICATION_CHECKED) {
$priceVerificationCheckedTtc = CartDetail::VERIFICATION_TTC;
$priceVerificationCheckedHt = CartDetail::VERIFICATION_HT;
}
if ($plus_expert) {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT + $priceFinitonHt + $priceVerificationCheckedHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC + $priceFinitonTtc + $priceVerificationCheckedTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT + $priceFinitonHtWithoutReduction + $priceVerificationCheckedHt;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC + $priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc;
} else {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt + $priceVerificationCheckedHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + $priceFinitonTtc + $priceVerificationCheckedTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction + $priceVerificationCheckedHt;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc()) + $priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc;
}
if (($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if ($isEnveloppe) {
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $qty);
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $qty);
$prixHtWithoutReduction = $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT * $qty);
$prixTtcWithoutReduction = $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC * $qty);
}
}
$cartDetail->setPrixHt($prixHt);
$cartDetail->setPrixTtc($prixTtc);
$cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
$cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
$cartDetail->setIsEnveloppe($isEnveloppe);
$cartDetail->setIsPlusExpert($plus_expert);
$cartDetail->setFinition($finition);
$cartDetail->setIsPlusVerification($verification);
$cartDetail->setIsTrait($isTrait);
$this->em->persist($cartDetail);
$this->em->flush();
$this->cart_service->removeCartDetailPapierPoste($cart, $cartDetail, true); //remove Papier Poste
$this->cart_service->updatePriceCart($cart);
return $cartDetail;
}
return false;
}
public function addToCartNewNbDesignerTemplatePageCategoryNosCrea($request,$user,$id)
{
$url = $request->get('urlCrelloTemplate');
$designId = $request->get('idDesign');
$crea = $this->em->getRepository(TemplatesPageCategory::class)->find($id);
if(is_object($crea)) {
$product = $crea->getProduct();
$qty = $crea->getProductPrice()->getQty();
$finition = CartDetail::FINITION_GLACE;
$isEnveloppe = null;
$verification = CartDetail::VERIFICATION_CHECKED;
$plus_expert = null;
$isTrait = null;
$isFontBlanc = null;
$productAttribute = $crea->getProductAttribute();
$cartDetail = new CartDetail();
$token = $this->generateToken(32);
$dataPdf = $this->downloadPdfCrello($request,$url,$token);
$filePapier = isset($dataPdf['pdfName'])? $dataPdf['pdfName'] : false;
$filePapierFirstImage = isset($dataPdf['firstImage'])? $dataPdf['firstImage'] : false;
if(!$filePapier || !$filePapierFirstImage ){
return ['erreur'=> 'erreur convert pdf !'];
}
$cartDetail->setIsMaCrea(false);
$cartDetail->setFilePapier($filePapier);
$cartDetail->setFilePapierFirstImage($filePapierFirstImage);
if($product->getTypeProduct() == Product::CARTE){
$name = 'carte-visite';
}else if($product->getTypeProduct() == Product::FLYERS){
$name = 'flyrs';
}else if($product->getTypeProduct() == Product::AFFICHE){
$name = 'affiche';
}else if($product->getTypeProduct() == Product::MENU){
$name = 'menu';
}else if($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
$name = 'faire_naissance';
}else if($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
$name = 'faire_mariage';
}else{
$name = str_replace(' ','_',$product->getTitre());
}
$cartDetail->setFilePapierName($name.'-'.$filePapier);
$cartDetail->setTemplateIdCrello($designId);
$cart = $this->cart_service->getCartCurrent();
if (!$cart) {
$cart = $this->cart_service->createCart(true);
}
$typeAbonnement = $this->cart_service->getTypeAbonnementPro($user, $cart->getId()); // get type abonnement
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
$cartDetail->setTypeProduct($product->getTypeProduct());
$cartDetail->setToken($token);
$cartDetail->setProductAttribute($productAttribute);
$cartDetail->setProduct($product);
$cartDetail->setCart($cart);
$cartDetail->setNbrPapier($qty);
$cartDetail->setQty(0);
$cartDetail->setQtyColor(0);
$cartDetail->setQtyNoir(0);
$cartDetail->setProductName($product->getTitre());
$cartDetail->setMauvaisFormat($isFontBlanc);
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * $pourcentageFinition;
$priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * $pourcentageFinition;
$priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt())) * $pourcentageFinition;
$priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc())) * $pourcentageFinition;
$priceVerificationCheckedTtc = 0;
$priceVerificationCheckedHt = 0;
if ($verification == CartDetail::VERIFICATION_CHECKED) {
$priceVerificationCheckedTtc = CartDetail::VERIFICATION_TTC;
$priceVerificationCheckedHt = CartDetail::VERIFICATION_HT;
}
if ($plus_expert) {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT + $priceFinitonHt + $priceVerificationCheckedHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC + $priceFinitonTtc + $priceVerificationCheckedTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT + $priceFinitonHtWithoutReduction + $priceVerificationCheckedHt;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC + $priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc;
} else {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt + $priceVerificationCheckedHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + $priceFinitonTtc + $priceVerificationCheckedTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction + $priceVerificationCheckedHt;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc()) + $priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc;
}
if (($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if ($isEnveloppe) {
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $qty);
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $qty);
$prixHtWithoutReduction = $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT * $qty);
$prixTtcWithoutReduction = $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC * $qty);
}
}
$cartDetail->setPrixHt($prixHt);
$cartDetail->setPrixTtc($prixTtc);
$cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
$cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
$cartDetail->setIsEnveloppe($isEnveloppe);
$cartDetail->setIsPlusExpert($plus_expert);
$cartDetail->setFinition($finition);
$cartDetail->setIsPlusVerification($verification);
$cartDetail->setIsTrait($isTrait);
$this->em->persist($cartDetail);
$this->em->flush();
$this->cart_service->removeCartDetailPapierPoste($cart, $cartDetail, true); //remove Papier Poste
$this->cart_service->updatePriceCart($cart);
return $cartDetail;
}
return false;
}
public function getBlocksTemplate20000Page($search=null){
$array = [];
$templates = $this->em->getRepository(TemplatesPage::class)->getAllActiveBySearch($search);
foreach ($templates as $item){
if(array_key_exists($item->getCategory()->getId(),$array)){
$array[$item->getCategory()->getId()]['products'][] = $item;
}else{
$array[$item->getCategory()->getId()]['sort'] = $item->getCategory()->getSort()?$item->getCategory()->getSort():0;
$array[$item->getCategory()->getId()]['category'] = $item->getCategory();
$array[$item->getCategory()->getId()]['products'][] = $item;
}
}
return $array;
}
public function getBlocksTemplate20000PagePlus($request){
$catId = $request->get('catId');
$search = $request->get('search');
$templates = $this->em->getRepository(TemplatesPage::class)->getAllActiveBySearchAndCat($catId,$search);
return $templates;
}
public function searchTemplate20000Page($request,$search){
$products = $this->em->getRepository(TemplatesPage::class)->getAllActiveBySearch($search);
$tabs = [];
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
foreach ($products as $product){
$array = [];
$array['img'] = $baseurl . "/imageSite/" . $product->getFileProduct();
$array['designTypeSideBarCrello'] = $product->getDesignTypeSideBarCrello();
$array['templateId'] = $product->getDesignTemplateId();
$array['titre'] = $product->getTitre();
$array['nameTemplate'] = $product->getNameTemplate();
$array['baseUrl'] = $baseurl;
$tabs[] = $array ;
}
return $tabs;
}
public function addToCartNewNbDesignerDocSaved($fileCrello,$user)
{
if(is_object($fileCrello)) {
$product = $fileCrello->getProduct();
$qty = $fileCrello->getQuantite();
$finition = $fileCrello->getFinition();
$isEnveloppe = $fileCrello->getIsEnveloppe();
$verification = $fileCrello->getIsPlusVerification();
$plus_expert = $fileCrello->getIsPlusExpert();
$isTrait = $fileCrello->getIsTrait();
$isFontBlanc = null;
if (!$fileCrello->getFilePapier()) {
return false;
}
$cartDetail = new CartDetail();
$token = $this->generateToken(32);
$newFile = uniqid() . $fileCrello->getFilePapier();
$dossier_frame = $this->params->get('uploads_directory') . '/img_template_save/' . $fileCrello->getFilePapier();
$dossier_frame_new = $this->params->get('uploads_directory') . '/tmp/' . $newFile;
copy($dossier_frame, $dossier_frame_new);
$newFileFirstImage = null;
if ($fileCrello->getFilePapierFirstImage()) {
$newFileFirstImage = uniqid() . $fileCrello->getFilePapierFirstImage();
$dossier_frame_firstImage = $this->params->get('uploads_directory') . '/img_template_save/' . $fileCrello->getFilePapierFirstImage();
$dossier_frame_firstImage_new = $this->params->get('uploads_directory') . '/tmp/' . $newFileFirstImage;
copy($dossier_frame_firstImage, $dossier_frame_firstImage_new);
}
$cartDetail->setIsMaCrea(true);
$cartDetail->setFilePapier($newFile);
$cartDetail->setFilePapierFirstImage($newFileFirstImage);
if ($product->getTypeProduct() == Product::CARTE) {
$name = 'carte-visite';
} else if ($product->getTypeProduct() == Product::FLYERS) {
$name = 'flyrs';
} else if ($product->getTypeProduct() == Product::AFFICHE) {
$name = 'affiche';
} else if ($product->getTypeProduct() == Product::MENU) {
$name = 'menu';
} else if ($product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) {
$name = 'faire_naissance';
} else if ($product->getTypeProduct() == Product::FAIRE_PART_MARIAGE) {
$name = 'faire_mariage';
} else {
$name = str_replace(' ', '_', $product->getTitre());
}
$cartDetail->setFilePapierName($name . '-' . $newFile);
$productAttribute = $fileCrello->getProductAttribute();
$cart = $this->cart_service->getCartCurrent();
if (!$cart) {
$cart = $this->cart_service->createCart(true);
}
$typeAbonnement = $this->cart_service->getTypeAbonnementPro($user, $cart->getId()); // get type abonnement
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $qty);
$cartDetail->setTypeProduct($product->getTypeProduct());
$cartDetail->setToken($token);
$cartDetail->setProductAttribute($productAttribute);
$cartDetail->setProduct($product);
$cartDetail->setCart($cart);
$cartDetail->setNbrPapier($qty);
$cartDetail->setQty(0);
$cartDetail->setQtyColor(0);
$cartDetail->setQtyNoir(0);
$cartDetail->setProductName($product->getTitre());
$cartDetail->setMauvaisFormat($isFontBlanc);
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())) * $pourcentageFinition;
$priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())) * $pourcentageFinition;
$priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt())) * $pourcentageFinition;
$priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc())) * $pourcentageFinition;
$priceVerificationCheckedTtc = 0;
$priceVerificationCheckedHt = 0;
if ($verification == CartDetail::VERIFICATION_CHECKED) {
$priceVerificationCheckedTtc = CartDetail::VERIFICATION_TTC;
$priceVerificationCheckedHt = CartDetail::VERIFICATION_HT;
}
if ($plus_expert) {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT + $priceFinitonHt + $priceVerificationCheckedHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC + $priceFinitonTtc + $priceVerificationCheckedTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT + $priceFinitonHtWithoutReduction + $priceVerificationCheckedHt;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC + $priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc;
} else {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt + $priceVerificationCheckedHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + $priceFinitonTtc + $priceVerificationCheckedTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction + $priceVerificationCheckedHt;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr, $priceProductAttr->getPrixTtc()) + $priceFinitonTtcWithoutReduction + $priceVerificationCheckedTtc;
}
if (($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if ($isEnveloppe) {
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $qty);
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $qty);
$prixHtWithoutReduction = $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT * $qty);
$prixTtcWithoutReduction = $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC * $qty);
}
}
// update price by country
$prixHt = $this->cart_service->updatePriceByCountry($prixHt,$product);
$prixTtc = $this->cart_service->updatePriceByCountry($prixTtc,$product);
$prixHtWithoutReduction = $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
$prixTtcWithoutReduction = $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
$cartDetail->setPrixHt($prixHt);
$cartDetail->setPrixTtc($prixTtc);
$cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
$cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
$cartDetail->setIsEnveloppe($isEnveloppe);
$cartDetail->setIsPlusExpert($plus_expert);
$cartDetail->setFinition($finition);
$cartDetail->setIsPlusVerification($verification);
$cartDetail->setIsTrait($isTrait);
$this->em->persist($cartDetail);
$this->em->flush();
$this->cart_service->removeCartDetailPapierPoste($cart, $cartDetail, true); //remove Papier Poste
$this->cart_service->updatePriceCart($cart);
return $cartDetail;
}
return false;
}
public function saveClientFiles($tokenDetail,$catSaveCrello,$user){
if(is_object($user)) {
if ($catSaveCrello) {
$detail = $this->em->getRepository(CartDetail::class)->findOneBy(['token' => $tokenDetail]);
if ($detail) {
$file = $detail->getFilePapier();
$frame_0 = $file;
$frame_0_new = uniqid().'-'.$file;
$dossier_frame_0 = $this->params->get('uploads_directory') . '/tmp/'.$frame_0;
$dossier_frame_0_new = $this->params->get('uploads_directory'). '/img_template_save/' . $frame_0_new;
if(file_exists($dossier_frame_0_new) )unlink($dossier_frame_0_new);
copy($dossier_frame_0 , $dossier_frame_0_new);
$frame_firstImage_new = null;
$frame_firstImage = $detail->getFilePapierFirstImage();
if($frame_firstImage){
$frame_firstImage_new = uniqid().'-'.$frame_firstImage;
$dossier_frame_firstImage = $this->params->get('uploads_directory') . '/tmp/'.$frame_firstImage;
$dossier_frame_firstImage_new = $this->params->get('uploads_directory'). '/img_template_save/' . $frame_firstImage_new;
if(file_exists($dossier_frame_firstImage_new) )unlink($dossier_frame_firstImage_new);
copy($dossier_frame_firstImage , $dossier_frame_firstImage_new);
}
$fileClient = new FilesClientCrello();
$fileClient->setUser($user);
$fileClient->setToken($this->generateToken(32));
$fileClient->setFinition($detail->getFinition());
$fileClient->setFormat($detail->getProductAttribute()->getFormat());
$fileClient->setGrammage($detail->getProductAttribute()->getGramage());
$fileClient->setIsEnveloppe($detail->getIsEnveloppe());
$fileClient->setIsPlusExpert($detail->getIsPlusExpert());
$fileClient->setIsTrait($detail->getIsTrait());
$fileClient->setName($detail->getFilePapierName());
$fileClient->setFilePapier($frame_0_new);
$fileClient->setFilePapierName($detail->getFilePapierName());
$fileClient->setIsPlusVerification($detail->getIsPlusVerification());
$fileClient->setProduct($detail->getProduct());
$fileClient->setProductAttribute($detail->getProductAttribute());
$fileClient->setQuantite($detail->getNbrPapier());
$fileClient->setRectoverso($detail->getProductAttribute()->getRectoverso());
$fileClient->setTypeProduct($detail->getTypeProduct());
$fileClient->setFilePapierFirstImage($frame_firstImage_new);
$cat = $this->em->getRepository(FilesClientCrelloCategory::class)->find($catSaveCrello);
if($cat){
$fileClient->setCategory($cat);
}
$this->em->persist($fileClient);
$this->em->flush();
}
}
}
}
public function getCatCrelloB2b($user,$isAdmin,$compteAbonnement,$search=null){
$users = [];
if($isAdmin){
$users = [];
$users[] = $compteAbonnement->getAdmin()->getUser()->getId();
if (count($compteAbonnement->getUtilisateur()) > 0) {
foreach ($compteAbonnement->getUtilisateur() as $customer) {
$users[] = $customer->getUser()->getId();
}
}
}else{
$users[] = $user->getId();
}
$docs = $this->em->getRepository(FilesClientCrello::class)->findByUserAbo($users,$search) ;
$categories = [];
if(count($docs) > 0){
foreach ($docs as $doc){
$categories[$doc->getCategory()->getId()]['name'] = $doc->getCategory()->getName();
$categories[$doc->getCategory()->getId()]['docs'][] = $doc;
$categories[$doc->getCategory()->getId()]['id']= $doc->getCategory()->getId();
}
}
return $categories;
}
public function getCatImpressionB2b($user,$isAdmin,$compteAbonnement,$search=null){
$users = [];
if($isAdmin){
$users = [];
$users[] = $compteAbonnement->getAdmin()->getUser()->getId();
if (count($compteAbonnement->getUtilisateur()) > 0) {
foreach ($compteAbonnement->getUtilisateur() as $customer) {
$users[] = $customer->getUser()->getId();
}
}
}else{
$users[] = $user->getId();
}
$docs = $this->em->getRepository(FilesClient::class)->findByUserAbo($users,$search) ;
return $docs;
}
public function saveCustomCatCrello($user,$requestData){
$catFileB2b = isset($requestData['catFileB2b'])? $requestData['catFileB2b'] : null;
$isProductCat = isset($requestData['isProductCat'])? $requestData['isProductCat'] == 0 ? false : true : false;
$catFileCustomB2b = isset($requestData['catFileCustomB2b'])? $requestData['catFileCustomB2b'] : null;
if($catFileCustomB2b){
$cat = new FilesClientCrelloCategory();
$cat->setName($catFileCustomB2b);
$cat->setUser($user);
$this->em->persist($cat);
$this->em->flush();
return $cat->getId();
}else {
if($isProductCat){
$catProduct = $this->em->getRepository(Product::class)->find($catFileB2b);
if($catProduct){
$cat = $this->em->getRepository(FilesClientCrelloCategory::class)->findOneBy(['user'=>$user->getId(),'product'=>$catProduct->getId()]);
if($cat){
return $cat->getId();
}else{
$cat = new FilesClientCrelloCategory();
$cat->setName($catProduct->getTitre());
$cat->setProduct($catProduct);
$cat->setIsDefault(true);
$cat->setUser($user);
$this->em->persist($cat);
$this->em->flush();
return $cat->getId();
}
}
}else{
$cat = $this->em->getRepository(FilesClientCrelloCategory::class)->find($catFileB2b);
if($cat){
return $cat->getId();
}
}
}
return 0;
}
public function generateZipNewNbDesigner($array)
{
$zip = new \ZipArchive();
$token = $this->generateToken(10);
$nameFichier = 'ma_crea_' . $token . '.zip';
$zipfile = $this->params->get('uploads_directory') . '/tmp/' . $nameFichier;
if (file_exists($zipfile)) unlink($zipfile);
if ($zip->open($zipfile, \ZipArchive::CREATE) === TRUE) {
foreach ($array as $i => $item){
$zip->addFile($this->params->get('uploads_directory') . '/tmp/' . $item['file'], $item['file']);
}
$zip->close();
}
return $nameFichier;
}
public function addImageCreaNewNbDesigner($images): array
{
$array = [];
$file = '';
$firstImage = '';
$multiple = 0;
foreach ($images as $key => $image) {
if ($image && in_array($image->guessExtension(), array('pdf', 'png', 'jpg', 'jpeg'))) {
$ext = $image->guessExtension();
$token = $this->generateToken(10);
$file = $token . '.' . $ext;
$image->move($this->params->get('uploads_directory') . '/tmp', $file);
$array[]= [
'file' => $file,
];
if($key == 0) {
if ($ext == 'pdf') {
$firstImage = $this->convertPdfToFirstImage($file, $token);
$nbrPage = $this->getNumbrePage($file);
if($nbrPage == 1){
$multiple = 1;
}elseif ($nbrPage == 2){
$multiple = 2;
}elseif ($nbrPage > 2){
$multiple = 3;
}
} else {
$firstImage = $file;
}
}
}
}
if($array and $multiple > 0){
if($multiple == 1){
return [
'file' => $array[0]['file'],
'image' => $firstImage,
'multiple' => 0
];
}else if($multiple == 2){
return [
'file' => $array[0]['file'],
'image' => $firstImage,
'multiple' => 2
];
}else if($multiple > 2){
return [
'file' => $array[0]['file'],
'image' => $firstImage,
'multiple' => 3
];
}else{
return [
'file' => false
];
}
}else{
if( $array and count($array) == 2 ){
return [
'file' => $this->generateZipNewNbDesigner($array),
'image' => $firstImage,
'multiple' => 2
];
}elseif(count($array) > 2){
return [
'file' => $this->generateZipNewNbDesigner($array),
'image' => $firstImage,
'multiple' => 3
];
}elseif(count($array) == 1){
return [
'file' => $array[0]['file'],
'image' => $firstImage,
'multiple' => 0
];
}else{
return [
'file' => false
];
}
}
}
// download pdf crello
public function downloadPdfCrello($request,$url,$token){
$response = $this->httpClient->request('GET', $url, [
// optional: if you don't want to buffer the response in memory
'buffer' => false,
]);
if (200 !== $response->getStatusCode()) {
throw new \Exception('...');
}
$nameFichier = $token.'.pdf';
if(file_exists($this->params->get('uploads_directory') . '/tmp/' .$nameFichier)){
unlink($this->params->get('uploads_directory') . '/tmp/' .$nameFichier);
}
if(file_exists($this->params->get('uploads_directory') . '/tmp/'.$token.'-recto.jpeg')){
unlink($this->params->get('uploads_directory') . '/tmp/'.$token.'-recto.jpeg');
}
$fileHandler = fopen($this->params->get('uploads_directory') . '/tmp/' .$nameFichier, 'w');
foreach ($this->httpClient->stream($response) as $chunk) {
fwrite($fileHandler, $chunk->getContent());
}
$firstImage = $this->convertPdfToFirstImage($nameFichier,$token);
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
return [
'pdfUrl'=> $baseurl.'/uploads/tmp/'.$nameFichier,
'pdfName'=> $nameFichier,
'firstImageUrl'=> $baseurl.'/uploads/tmp/'.$firstImage,
'firstImage'=> $firstImage,
];
}
// download pdf colorlab
public function downloadPdfColorlab($request,$tokenProductColorLab,$idProductColorLab,$token){
$idShop = '62a6f09f014918001162c01d';
$keyApi = '24aa345985535be260e4c3298d50b06e';
$keyApiSecret = '16cec8b8-e8df-404e-9f87-83c1e556f506';
$hashed = hash_hmac('sha256', $idShop.$idProductColorLab.$tokenProductColorLab, $keyApiSecret, false);
$headers = array(
'X-Colorlab-Shop:' . $idShop,
'X-Colorlab-Api-Key:' . $keyApi,
'X-Colorlab-Api-Signature:' . $hashed,
);
$nameFichier = $token.'.pdf';
if(file_exists($this->params->get('uploads_directory') . '/tmp/' .$nameFichier)){
unlink($this->params->get('uploads_directory') . '/tmp/' .$nameFichier);
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.colorlab.io/v1/configuration/'.$idProductColorLab.'/'.$tokenProductColorLab.'/export');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$localFilename = $this->params->get('uploads_directory') . '/tmp/' .$nameFichier;
$fh = fopen($localFilename, "wb");
curl_setopt($curl, CURLOPT_FILE, $fh);
curl_exec($curl);
curl_close($curl);
$firstImage = $this->convertPdfToFirstImage($nameFichier,$token);
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
return [
'pdfUrl'=> $baseurl.'/uploads/tmp/'.$nameFichier,
'pdfName'=> $nameFichier,
'firstImageUrl'=> $baseurl.'/uploads/tmp/'.$firstImage,
'firstImage'=> $firstImage,
];
}
public function convertPdfToFirstImage($file,$nameFile){
$dir = $this->params->get('uploads_directory').'/tmp';
exec('rm '.$dir.'/'.$nameFile.'-recto.jpeg');
shell_exec('gs -sDEVICE=jpeg -o '.$dir.'/'.$nameFile.'-recto.jpeg -dFirstPage=1 -dLastPage=1 -dJPEGQ=30 '.$dir.'/'.$file); // save first page pdf
// shell_exec('C:\\gs9.52\\bin\\gswin64c.exe -sDEVICE=jpeg -o '.$dir.'/'.$nameFile.'-recto.jpeg -dFirstPage=1 -dLastPage=1 -dJPEGQ=30 '.$dir.'/'.$file); // save first page pdf
return $nameFile.'-recto.jpeg';
}
public function getNumbrePage($file){
$dir = $this->params->get('uploads_directory').'/tmp';
$token = $this->generateToken(40);
$dossier = $dir.'/'.$token;
$saveTo = $dossier.'/';
mkdir($dossier);
shell_exec( "gs -sDEVICE=jpeg -o ".$saveTo."page-%d.jpeg ".$dir."/".$file );
// shell_exec( "C:\\gs9.52\\bin\\gswin64c.exe -sDEVICE=png16m -r10 -o ".$saveTo."page-%d.png ".$dir."/".$file );
$scanned_directory = array_diff( scandir( $dossier ), array( '..', '.', 'source' ) );
$nbr = 0;
foreach ( $scanned_directory as $key => $value ) {
$nbr++;
}
exec('rm -rf '.$dossier);
return $nbr;
}
public function getCartDetail($request,$token){
$cartDetail = null;
if($token){
$cartDetail = $this->em->getRepository(CartDetail::class)->findOneBy(array('token'=>$token));
}
return $cartDetail;
}
public function getProductByRequest($request){
$productId = $request->get('product');
$product= null;
if($productId){
$product = $this->em->getRepository(Product::class)->find($productId);
}
return $product;
}
// flayer && carte visite
public function getGramage($id_product,$id_format,$rectoverso){
$gramages = $this->em->getRepository(ProductAttribute::class)->getAttrGramagePossible($id_product,$id_format,$rectoverso);
return $gramages;
}
public function getQtyPosibleByGrammage($id_gramage,$id_format,$rectoverso,$finition,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_gramage,'rectoverso'=>$rectoverso,'isEnabled'=>true));
$qtys = false;
if($productAttribute) {
$data = $this->getQtyFlyerCarteByProductAttribute($productAttribute->getId(),$finition,false,$isEnveloppe = false,$bordsArrondis,$plastification);
$dataAbonnementPlus = $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_PRO,$productAttribute->getId(),false,$isEnveloppe = false,$bordsArrondis,$plastification);
$dataAbonnementTeam = $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_TEAM,$productAttribute->getId(),false,$isEnveloppe = false,$bordsArrondis,$plastification);
$qtys = $data['qtys'];
$qtysPlus = $dataAbonnementPlus['qtys'];
$qtysTeam = $dataAbonnementTeam['qtys'];
}
return ['qtys'=>$qtys,'qtysPlus'=>$qtysPlus,'qtysTeam'=>$qtysTeam];
}
// Affiche
public function getTypeImpression($id_product,$id_format){
$typeImpression = $this->em->getRepository(ProductAttribute::class)->getAttrTypeImpressionPossible($id_product,$id_format);
return $typeImpression;
}
public function getGrammageByTypeImpression($id_product,$id_format,$id_type_impression = null){
$garamages = $this->em->getRepository(ProductAttribute::class)->getAttrGrammageByTypeImpressionPossible($id_product,$id_format,$id_type_impression);
return $garamages;
}
public function getQtyPosibleByGrammageAndTypeImpression($id_gramage,$id_format,$typeImression,$plastificationn,$finition,$isEnveloppe=false,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
if($typeImression) {
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format' => $id_format, 'gramage' => $id_gramage, 'typeImpression' => $typeImression, 'plastification' => $plastificationn, 'isEnabled' => true));
}else{
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format' => $id_format, 'gramage' => $id_gramage, 'plastification' => $plastificationn, 'isEnabled' => true));
}
$qtys = false;
if($productAttribute) {
$data = $this->getQtyFlyerCarteByProductAttribute($productAttribute->getId(),$finition,false,$isEnveloppe = false,$bordsArrondis,$plastification);
$dataAbonnementPlus = $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_PRO,$productAttribute->getId(),$finition,false,$isEnveloppe = false,$bordsArrondis,$plastification);
$dataAbonnementTeam = $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_TEAM,$productAttribute->getId(),$finition,false,$isEnveloppe = false,$bordsArrondis,$plastification);
$qtys = $data['qtys'];
$qtysPlus = $dataAbonnementPlus['qtys'];
$qtysTeam = $dataAbonnementTeam['qtys'];
}
return ['qtys'=>$qtys,'qtysPlus'=>$qtysPlus,'qtysTeam'=>$qtysTeam];
}
public function getQtyPosible($productId,$format=null,$gramage=null,$typeImpression=null,$typeFormat=null,$specificite=null,$typeCouleur=null,$taille=null,$zoneImpression=null,$nbrCouleur=null,$supportSuspension=null,$typeCarton=null,$oeille=null){
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(
array(
'product'=>$productId,
'format'=>$format? is_object($format)?$format->getId():$format['id']:null,
'gramage'=>$gramage?is_object($gramage)?$gramage->getId():$gramage['id']:null,
'typeImpression'=>$typeImpression?is_object($typeImpression)?$typeImpression->getId():$typeImpression['id']:null,
'typeFormat'=>$typeFormat?is_object($typeFormat)?$typeFormat->getId():$typeFormat['id']:null,
'specificite'=>$specificite?is_object($specificite)?$specificite->getId():$specificite['id']:null,
'typeCouleur'=>$typeCouleur?is_object($typeCouleur)?$typeCouleur->getId():$typeCouleur['id']:null,
'taille'=>$taille?is_object($taille)?$taille->getId():$taille['id']:null,
'zoneImpression'=>$zoneImpression?is_object($zoneImpression)?$zoneImpression->getId():$zoneImpression['id']:null,
'nbrCouleur'=>$nbrCouleur?is_object($nbrCouleur)?$nbrCouleur->getId():$nbrCouleur['id']:null,
'supportSuspension'=>$supportSuspension?is_object($supportSuspension)?$supportSuspension->getId():$supportSuspension['id']:null,
'typeCarton'=>$typeCarton?is_object($typeCarton)?$typeCarton->getId():$typeCarton['id']:null,
'oeille'=>$oeille?is_object($oeille)?$oeille->getId():$oeille['id']:null,
'isEnabled'=>true
)
);
$qtys = false;
$qtysPlus = false;
$qtysTeam = false;
if($productAttribute) {
$data = $this->getQtyFlyerCarteByProductAttribute($productAttribute->getId(),0,false, false);
$dataAbonnementPlus = $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_PRO,$productAttribute->getId(),0,false, false);
$dataAbonnementTeam = $this->getQtyFlyerCarteByProductAttributeByAbonnement(AbonnementPro::TYPE_TEAM,$productAttribute->getId(),0,false, false);
$qtys = $data['qtys'];
$qtysPlus = $dataAbonnementPlus['qtys'];
$qtysTeam = $dataAbonnementTeam['qtys'];
}
return ['qtys'=>$qtys,'qtysPlus'=>$qtysPlus,'qtysTeam'=>$qtysTeam];
}
public function getUserTemplate()
{
return $this->em->getRepository(NbUserTemplates::class)->findOneBy(array('token' => $this->session->get('nbToken')));
}
public function generateToken($nb)
{
return rtrim(strtr(base64_encode(random_bytes($nb)), '+/', '-_'), '=');
}
public function importTextes(): void
{
$response = $this->httpClient->request('GET', 'https://studio.cmsmart.net/v1/typo');
$allTextes = $response->toArray();
foreach ($allTextes['data'] as $texte) {
$response = $this->httpClient->request('POST', 'https://studio.cmsmart.net/v1/typo', [
'body' => [
'action' => 'nbd_get_resource',
'type' => 'get_typo',
'folder' => $texte['folder'],
]
]);
$nbTexte = new NbTextes();
$nbTexte->setName($texte['folder']);
$nbTexte->setContent($response->toArray()['data']);
$this->em->persist($nbTexte);
$this->em->flush();
}
}
public function importElements(): void
{
$response = $this->httpClient->request('GET', 'https://studio.cmsmart.net/v1/clipart?limit=551&category=66');
$allFiles = $response->toArray();
foreach ($allFiles['cliparts']['items'] as $file) {
$nbFile = new NbElements();
$nbFile->setName($file['name']);
$nbFile->setAlias($file['alias']);
$fileNameFromUrl = explode('/', $file['file']);
$fileNameFromUrl = $fileNameFromUrl[(count($fileNameFromUrl) - 1)];
$response = $this->httpClient->request('GET', 'https:' . $file['file'], [
// optional: if you don't want to buffer the response in memory
'buffer' => false,
]);
if (200 !== $response->getStatusCode()) {
throw new \Exception('...');
}
$fileHandler = fopen($this->params->get('uploads_directory') . '/nb_designer/' . $fileNameFromUrl, 'w');
foreach ($this->httpClient->stream($response) as $chunk) {
fwrite($fileHandler, $chunk->getContent());
}
$nbFile->setPath($fileNameFromUrl);
$nbFile->setCategory((int)$file['cate_id']);
$this->em->persist($nbFile);
$this->em->flush();
}
$response = $this->httpClient->request('GET', 'https://studio.cmsmart.net/v1/clipart?limit=551&category=73');
$allFiles = $response->toArray();
foreach ($allFiles['cliparts']['items'] as $file) {
$nbFile = new NbElements();
$nbFile->setName($file['name']);
$nbFile->setAlias($file['alias']);
$fileNameFromUrl = explode('/', $file['file']);
$fileNameFromUrl = $fileNameFromUrl[(count($fileNameFromUrl) - 1)];
$response = $this->httpClient->request('GET', 'https:' . $file['file'], [
// optional: if you don't want to buffer the response in memory
'buffer' => false,
]);
if (200 !== $response->getStatusCode()) {
throw new \Exception('...');
}
$fileHandler = fopen($this->params->get('uploads_directory') . '/nb_designer/' . $fileNameFromUrl, 'w');
foreach ($this->httpClient->stream($response) as $chunk) {
fwrite($fileHandler, $chunk->getContent());
}
$nbFile->setPath($fileNameFromUrl);
$nbFile->setCategory((int)$file['cate_id']);
$this->em->persist($nbFile);
$this->em->flush();
}
$response = $this->httpClient->request('GET', 'https://studio.cmsmart.net/v1/clipart?limit=875&category=26');
$allFiles = $response->toArray();
foreach ($allFiles['cliparts']['items'] as $file) {
$nbFile = new NbElements();
$nbFile->setName($file['name']);
$nbFile->setAlias($file['alias']);
$fileNameFromUrl = explode('/', $file['file']);
$fileNameFromUrl = $fileNameFromUrl[(count($fileNameFromUrl) - 1)];
$response = $this->httpClient->request('GET', 'https:' . $file['file'], [
// optional: if you don't want to buffer the response in memory
'buffer' => false,
]);
if (200 !== $response->getStatusCode()) {
throw new \Exception('...');
}
$fileHandler = fopen($this->params->get('uploads_directory') . '/nb_designer/' . $fileNameFromUrl, 'w');
foreach ($this->httpClient->stream($response) as $chunk) {
fwrite($fileHandler, $chunk->getContent());
}
$nbFile->setPath($fileNameFromUrl);
$nbFile->setCategory((int)$file['cate_id']);
$this->em->persist($nbFile);
$this->em->flush();
}
}
public function getListDirectoriesToImport(): void
{
// carre
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://clubvet.local/get_cv_carre.php');
$result = curl_exec($ch);
curl_close($ch);
$visitCardsCarre = json_decode($result);
//classique
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://clubvet.local/get_cv.php');
$result = curl_exec($ch);
curl_close($ch);
$visitCardsClassique = json_decode($result);
//a5
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://clubvet.local/get_flyers.php');
$result = curl_exec($ch);
curl_close($ch);
$flyersA5 = json_decode($result);
//a6
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://clubvet.local/get_flyers_a6.php');
$result = curl_exec($ch);
curl_close($ch);
$flyersA6 = json_decode($result);
foreach ($visitCardsCarre as $cv) {
$this->ftpGetDir('163.172.30.143', 'copees', 'IxI6uRC5oAMLnFIvwR7o', '/www/wp-content/uploads/nbdesigner/designs/' . $cv, $this->params->get('uploads_directory') . '/designs/cv_carre/' . $cv);
}
foreach ($visitCardsClassique as $cv)
$this->ftpGetDir('163.172.30.143', 'copees', 'IxI6uRC5oAMLnFIvwR7o', '/www/wp-content/uploads/nbdesigner/designs/' . $cv, $this->params->get('uploads_directory') . '/designs/cv_classique/' . $cv);
foreach ($flyersA5 as $flyer)
$this->ftpGetDir('163.172.30.143', 'copees', 'IxI6uRC5oAMLnFIvwR7o', '/www/wp-content/uploads/nbdesigner/designs/' . $flyer, $this->params->get('uploads_directory') . '/designs/flyer_a5/' . $flyer);
foreach ($flyersA6 as $flyer)
$this->ftpGetDir('163.172.30.143', 'copees', 'IxI6uRC5oAMLnFIvwR7o', '/www/wp-content/uploads/nbdesigner/designs/' . $flyer, $this->params->get('uploads_directory') . '/designs/flyer_a6/' . $flyer);
}
public function importDossierByNBD($request,$type,$json,$isCopees,$scale=null): void
{
$json = json_decode($json);
foreach ($json as $item) {
$template = $this->em->getRepository(NbTemplates::class)->findOneBy(array('type' => $type, 'name' => $item));
if (!$template) {
$template = new NbTemplates();
}
$template->setName($item);
if ($type == 'cv_carre') {
$format = $this->em->getRepository(Attribut::class)->find(2); //carre
$template->setFormat($format);
$format_id = 2;
}
if ($type == 'cv_classique') {
$format = $this->em->getRepository(Attribut::class)->find(3); //carre
$template->setFormat($format);
$format_id = 3;
}
if ($type == 'flyer_a5') {
$format = $this->em->getRepository(Attribut::class)->find(5); //a5
$template->setFormat($format);
$format_id = 5;
}
if ($type == 'flyer_a6') {
$format = $this->em->getRepository(Attribut::class)->find(6); //a6
$template->setFormat($format);
$format_id = 6;
}
if ($type == 'affiche_a0') {
$format = $this->em->getRepository(Attribut::class)->find(30); //a0
$template->setFormat($format);
$format_id = 30;
}
if ($type == 'affiche_a1') {
$format = $this->em->getRepository(Attribut::class)->find(31); //a1
$template->setFormat($format);
$format_id = 31;
}
if ($type == 'affiche_a2') {
$format = $this->em->getRepository(Attribut::class)->find(32); //a2
$template->setFormat($format);
$format_id = 32;
}
if ($type == 'menu_a4') {
$format = $this->em->getRepository(Attribut::class)->find(33); //a4
$template->setFormat($format);
$format_id = 33;
}
if ($type == 'menu_a3') {
$format = $this->em->getRepository(Attribut::class)->find(34); //a3
$template->setFormat($format);
$format_id = 34;
}
if ($type == 'faire_mariage_14cm') {
$format = $this->em->getRepository(Attribut::class)->findOneBy(array('typeProduct'=>Attribut::FAIRE_PART_MARIAGE,'typeAttribute'=>Attribut::FORMAT));
// $format = $this->em->getRepository(Attribut::class)->find(105); //a3
$template->setFormat($format);
$format_id = $format->getId();
}
if ($type == 'faire_naissance_105mm') {
$format = $this->em->getRepository(Attribut::class)->findOneBy(array('typeProduct'=>Attribut::FAIRE_PART_NAISSANCE,'typeAttribute'=>Attribut::FORMAT));
// $format = $this->em->getRepository(Attribut::class)->find(108); //a3
$template->setFormat($format);
$format_id = $format->getId();
}
$template->setType($type);
$template->setIsCopees($isCopees);
$template->setIsPaysage($request->get('isPaysage'));
$this->em->persist($template);
$this->em->flush();
$this->ftpGetDir('87.98.139.241', 'nbd', '9H1_lne0', '/httpdocs/wp-content/uploads/nbdesigner/designs/' . $item, $this->params->get('uploads_directory') . '/designs/' . $type . '/' . $item);
$this->importTemplatesCustome($request, $type, $template->getName());
}
$this->updateScaleById($format_id,$isCopees,$scale);
}
public function importDossierImage(): void
{
$visitCardsCarre = $this->em->getRepository(NbTemplates::class)->findBy(array('type'=>'cv_carre'));
$visitCardsClassique = $this->em->getRepository(NbTemplates::class)->findBy(array('type'=>'cv_classique'));
$flyersA5 = $this->em->getRepository(NbTemplates::class)->findBy(array('type'=>'flyer_a5'));
$flyersA6 = $this->em->getRepository(NbTemplates::class)->findBy(array('type'=>'flyer_a6'));
foreach ($visitCardsCarre as $cv) {
$this->ftpGetDir('163.172.30.143', 'copees', 'IxI6uRC5oAMLnFIvwR7o', '/www/wp-content/uploads/nbdesigner/designs/' . $cv->getName().'/preview', $this->params->get('uploads_directory') . '/designs/cv_carre/' . $cv->getName().'/preview');
}
foreach ($visitCardsClassique as $cv)
$this->ftpGetDir('163.172.30.143', 'copees', 'IxI6uRC5oAMLnFIvwR7o', '/www/wp-content/uploads/nbdesigner/designs/' . $cv->getName().'/preview', $this->params->get('uploads_directory') . '/designs/cv_classique/' . $cv->getName().'/preview');
foreach ($flyersA5 as $flyer)
$this->ftpGetDir('163.172.30.143', 'copees', 'IxI6uRC5oAMLnFIvwR7o', '/www/wp-content/uploads/nbdesigner/designs/' . $flyer->getName().'/preview', $this->params->get('uploads_directory') . '/designs/flyer_a5/' . $flyer->getName().'/preview');
foreach ($flyersA6 as $flyer)
$this->ftpGetDir('163.172.30.143', 'copees', 'IxI6uRC5oAMLnFIvwR7o', '/www/wp-content/uploads/nbdesigner/designs/' . $flyer->getName().'/preview', $this->params->get('uploads_directory') . '/designs/flyer_a6/' . $flyer->getName().'/preview');
}
public function importTemplatesCustome($request, $dossier,$child): void
{
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$path = $this->params->get('uploads_directory') . '/designs/' . $dossier . '/' . $child;
$design = $this->nbd_get_data_from_json($path . '/design.json');
$productConfig = $this->nbd_get_data_from_json_serialise($path . '/product.json');
if (is_dir($path) && isset($design)) {
$type = $dossier;
$template = $this->em->getRepository(NbTemplates::class)->findOneBy(array('type' => $type, 'name' => $child));
if (!$template) {
$template = new NbTemplates();
}
$template->setName($child);
foreach ($design as $key => $frame) {
foreach ($frame->objects as $j => $object) {
if ($object->type == 'image' && property_exists($object, 'src') && !$this->validBase64($object->src) && $this->doesUrlExists($object->src)) {
$fileNameFromUrl = explode('/', $object->src);
$fileNameFromUrl = $fileNameFromUrl[(count($fileNameFromUrl) - 1)];
$response = $this->httpClient->request('GET', $object->src, [
// optional: if you don't want to buffer the response in memory
'buffer' => false,
]);
$fileHandler = fopen($this->params->get('uploads_directory') . '/nb_designer/templates_images/' . $fileNameFromUrl, 'w');
foreach ($this->httpClient->stream($response) as $chunk) {
fwrite($fileHandler, $chunk->getContent());
}
$design->{$key}->objects[$j]->src = $baseurl . '/uploads/nb_designer/templates_images/' . $fileNameFromUrl;
}
}
}
$productConfig ? $template->setProductConfig($productConfig) : $template->setProductConfig(null);
$template->setConfig((array)$this->nbd_get_data_from_json($path . '/config.json'));
$template->setDesign((array)$design);
$template->setFonts((array)$this->nbd_get_data_from_json($path . '/used_font.json'));
$template->setType($type);
if ($dossier == 'cv_carre') {
$format = $this->em->getRepository(Attribut::class)->find(2); //carre
$template->setFormat($format);
}
if ($dossier == 'cv_classique') {
$format = $this->em->getRepository(Attribut::class)->find(3); //carre
$template->setFormat($format);
}
if ($dossier == 'flyer_a5') {
$format = $this->em->getRepository(Attribut::class)->find(5); //a5
$template->setFormat($format);
}
if ($dossier == 'flyer_a6') {
$format = $this->em->getRepository(Attribut::class)->find(6); //a6
$template->setFormat($format);
}
if ($dossier == 'affiche_a0') {
$format = $this->em->getRepository(Attribut::class)->find(30); //a0
$template->setFormat($format);
}
if ($dossier == 'affiche_a1') {
$format = $this->em->getRepository(Attribut::class)->find(31); //a1
$template->setFormat($format);
}
if ($dossier == 'affiche_a2') {
$format = $this->em->getRepository(Attribut::class)->find(32); //a2
$template->setFormat($format);
}
if ($dossier == 'menu_a3') {
$format = $this->em->getRepository(Attribut::class)->find(34); //a2
$template->setFormat($format);
}
if ($dossier == 'menu_a4') {
$format = $this->em->getRepository(Attribut::class)->find(33); //a2
$template->setFormat($format);
}
if ($type == 'faire_mariage_14cm') {
$format = $this->em->getRepository(Attribut::class)->findOneBy(array('typeProduct'=>Attribut::FAIRE_PART_MARIAGE,'typeAttribute'=>Attribut::FORMAT));
// $format = $this->em->getRepository(Attribut::class)->find(105); //a3
$template->setFormat($format);
}
if ($type == 'faire_naissance_105mm') {
$format = $this->em->getRepository(Attribut::class)->findOneBy(array('typeProduct'=>Attribut::FAIRE_PART_NAISSANCE,'typeAttribute'=>Attribut::FORMAT));
// $format = $this->em->getRepository(Attribut::class)->find(108); //a3
$template->setFormat($format);
}
$this->em->persist($template);
$this->em->flush();
}
}
public function importTemplates($request, $dossier): void
{
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$finder = new Finder();
$finder->directories()->in($this->params->get('uploads_directory') . '/designs/' . $dossier . '/');
if ($finder->hasResults()) {
foreach ($finder as $directory) {
$path = $this->params->get('uploads_directory') . '/designs/' . $dossier . '/' . $directory->getFilename();
$design = $this->nbd_get_data_from_json($path . '/design.json');
$productConfig = $this->nbd_get_data_from_json_serialise($path . '/product.json');
if (is_dir($path) && isset($design)) {
$type = $dossier;
$template = $this->em->getRepository(NbTemplates::class)->findOneBy(array('type' => $type, 'name' => $directory->getFilename()));
if (!$template) {
$template = new NbTemplates();
}
$template->setName($directory->getFilename());
foreach ($design as $key => $frame) {
foreach ($frame->objects as $j => $object) {
if ($object->type == 'image' && property_exists($object, 'src') && !$this->validBase64($object->src) && $this->doesUrlExists($object->src)) {
$fileNameFromUrl = explode('/', $object->src);
$fileNameFromUrl = $fileNameFromUrl[(count($fileNameFromUrl) - 1)];
$response = $this->httpClient->request('GET', $object->src, [
// optional: if you don't want to buffer the response in memory
'buffer' => false,
]);
$fileHandler = fopen($this->params->get('uploads_directory') . '/nb_designer/templates_images/' . $fileNameFromUrl, 'w');
foreach ($this->httpClient->stream($response) as $chunk) {
fwrite($fileHandler, $chunk->getContent());
}
$design->{$key}->objects[$j]->src = $baseurl . '/uploads/nb_designer/templates_images/' . $fileNameFromUrl;
}
}
}
$productConfig ? $template->setProductConfig($productConfig) : $template->setProductConfig(null);
$template->setConfig((array)$this->nbd_get_data_from_json($path . '/config.json'));
$template->setDesign((array)$design);
$template->setFonts((array)$this->nbd_get_data_from_json($path . '/used_font.json'));
$template->setType($type);
if ($dossier == 'cv_carre') {
$format = $this->em->getRepository(Attribut::class)->find(2); //carre
$template->setFormat($format);
}
if ($dossier == 'cv_classique') {
$format = $this->em->getRepository(Attribut::class)->find(3); //carre
$template->setFormat($format);
}
if ($dossier == 'flyer_a5') {
$format = $this->em->getRepository(Attribut::class)->find(5); //a5
$template->setFormat($format);
}
if ($dossier == 'flyer_a6') {
$format = $this->em->getRepository(Attribut::class)->find(6); //a6
$template->setFormat($format);
}
$this->em->persist($template);
}
$this->em->flush();
}
}
}
public function doesUrlExists($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($code == 200) {
$status = true;
} else {
$status = false;
}
curl_close($ch);
return $status;
}
public function validBase64($string)
{
if (strpos($string, 'data:image/') !== false) {
return true;
}
return false;
}
public function nbd_get_data_from_json($path = '')
{
$content = file_exists($path) ? file_get_contents($path) : '';
return json_decode($content);
}
public function nbd_get_data_from_json_serialise($path = '')
{
$content = file_exists($path) ? file_get_contents($path) : '';
return $content;
}
public function ftpGetDir($host, $user, $passwd, $remotedir, $localdir, $port = 21)
{
if (!file_exists($localdir)) {
mkdir($localdir, 0777);
}
if (func_num_args() == 7) {
$stream = func_get_args(6);
} else {
$stream = ftp_connect($host, $port);
if (!ftp_login($stream, $user, $passwd))
return FALSE;
if (!ftp_chdir($stream, $remotedir))
return FALSE;
}
if (!is_writable($localdir))
return FALSE;
$list = ftp_nlist($stream, '.');
if (is_array($list)) {
foreach ($list as $k => $v) {
if (@ftp_chdir($stream, $v)) {
if (!file_exists("$localdir/$v"))
mkdir("$localdir/$v", 0777);
$this->ftpGetDir($host, $user, $passwd, "$remotedir/$v", "$localdir/$v", $port);
ftp_cdup($stream);
} else {
$fp = fopen("$localdir/$v", 'w');
if (is_resource($fp))
ftp_fget($stream, $fp, $v, FTP_BINARY);
fclose($fp);
}
}
}
}
public function updateElementsUserTemplate($request): array
{
$userTemplate = $this->em->getRepository(NbUserTemplates::class)->findOneByToken($request->get('userTemplate'));
$design = $userTemplate->getDesign();
$design['frame_0'] = json_decode($request->get('frame_0'));
$design['frame_1'] = json_decode($request->get('frame_1'));
$userTemplate->setDesign($design);
$userTemplate->setIsCrea($request->get('isCrea'));
$this->em->flush();
return [
'design' => $userTemplate->getDesign()
];
}
public function updateUserTemplate($request): array
{
switch ($request->get('type')) {
case 'template' :
$data = $this->getTemplate($request->get('folder'), $request->get('userTemplate'));
break;
case 'text' :
// $data = $data = $this->addText($request->get('folder'), $request->get('userTemplate'), $request->get('frame'));
$data = $data = $this->getText($request->get('folder'), $request->get('userTemplate'), $request->get('frame'));
break;
case 'icone' :
$data = $data = $this->addIcone($request->get('folder'), $request->get('userTemplate'), $request);
break;
case 'qrcode' :
$data = $this->addQrCode($request->get('userTemplate'), $request);
break;
case 'urlImage' :
$data = $data = $this->addUrlImage($request->get('urlImage'), $request->get('userTemplate'), $request);
break;
case 'uploadImage' :
$data = $this->addImage($request->files->get('uploadImage'), $request->get('userTemplate'), $request);
break;
case 'uploadCrea' :
$data = $this->addImageCrea($request->files->get('uploadCrea'), $request->get('userTemplate'), $request);
break;
default :
$data = $this->getTemplate($request->get('folder'), $request->get('userTemplate'));
break;
}
return $data;
}
public function loadUserTemplate($request): array
{
$userTemplate = $this->em->getRepository(NbUserTemplates::class)->findOneByToken($request->get('userTemplate'));
if($userTemplate->getDesign()){
$design = $userTemplate->getDesign();
$configProduct = $userTemplate->getProductConfig();
return [
'design' => $design,
'config' => $userTemplate->getConfig(),
'fonts' => $userTemplate->getFonts(),
'configProduct' => $configProduct,
];
}else{
return [
'design' => '',
'config' => '',
'fonts' => '',
'configProduct' => '',
];
}
}
public function getTemplate($folder, $userTemplate): array
{
$baseTemplate = $this->em->getRepository(NbTemplates::class)->find($folder);
$userTemplate = $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
$userTemplate->setFonts($baseTemplate->getFonts());
$userTemplate->setConfig($baseTemplate->getConfig());
$userTemplate->setDesign($baseTemplate->getDesign());
$userTemplate->setProductConfig($baseTemplate->getProductConfig());
$userTemplate->setIsPaysage($baseTemplate->getIsPaysage());
$this->em->flush();
$design = $userTemplate->getDesign();
$configProduct = $userTemplate->getProductConfig();
return [
'design' => $design,
'config' => $userTemplate->getConfig(),
'configProduct' => $configProduct,
'fonts' => $userTemplate->getFonts(),
];
}
public function addText($folder, $userTemplate, $frame): array
{
$text = $this->em->getRepository(NbTextes::class)->findOneByName($folder);
$userTemplate = $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
$textContent = $text->getContent();
$userTemplateFonts = $userTemplate->getFonts();
foreach ($textContent['font'] as $font) {
$userTemplateFonts[] = $font;
}
$userTemplate->setFonts($userTemplateFonts);
$userTemplateDesign = $userTemplate->getDesign();
$objects = [];
foreach ($textContent['design']['frame_0']['objects'] as $design) {
if(isset($userTemplateDesign['frame_'.$frame])){
$userTemplateDesign['frame_'.$frame]['objects'][] = $design;
}else{
$json = '{"version":"2.3.3","objects":[],"background":"#ffffff"}';
$userTemplateDesign['frame_'.$frame] = json_decode($json,true);
$userTemplateDesign['frame_'.$frame]['objects'][] = $design;
}
$objects[] = $design['itemId'];
}
$userTemplate->setDesign($userTemplateDesign);
$this->em->flush();
$design = $userTemplate->getDesign();
$configProduct = $userTemplate->getProductConfig();
return [
'design' => $design,
'config' => $userTemplate->getConfig(),
'fonts' => $userTemplate->getFonts(),
'configProduct' => $configProduct,
'objects' => $objects
];
}
public function getText($folder, $userTemplate, $frame): array
{
$text = $this->em->getRepository(NbTextes::class)->findOneByName($folder);
$userTemplate = $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
$textContent = $text->getContent();
$userTemplateFonts = $userTemplate->getFonts();
foreach ($textContent['font'] as $font) {
$userTemplateFonts[] = $font;
}
return [
"font" => $userTemplateFonts,
"object" => $textContent['design']['frame_0']
];
}
public function addIcone($folder, $userTemplate, $request): array
{
$icone = $this->em->getRepository(NbElements::class)->find((int)$folder);
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
return [
"src" => $baseurl . "/uploads/nb_designer/" . $icone->getPath()
];
}
public function addUrlImage($urlImage, $userTemplate, $request)
{
if (!empty($urlImage)) {
$fileName = $this->uploadImageFromUrl($urlImage);
if($fileName) {
$nbFile = new NbFiles();
$nbFile->setToken($userTemplate);
$nbFile->setName($fileName);
$nbFile->setAlias($fileName);
$nbFile->setPath($fileName);
$this->em->persist($nbFile);
$this->em->flush();;
$icone = $nbFile;
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
return [
"src" => $baseurl . "/uploads/nb_designer/" . $icone->getPath()
];
}else{
return ['src' => false];
}
} else {
return ['src' => false];
}
}
public function addImage($image, $userTemplate, $request): array
{
$width = $request->get('maxWidth');
if (in_array($image->guessExtension(), array('svg', 'png', 'jpg','jpeg'))) {
$ext = $image->guessExtension();
$fileName = $this->generateToken(10) . '.' . $ext;
$image->move($this->params->get('uploads_directory'). '/nb_designer', $fileName);
// resize image
// $resize = new ImageResizeService($this->params->get('uploads_directory'). '/nb_designer/'. $fileName);
// $resize->resizeTo($width, 500,'maxwidth');
// $resize->saveImage($this->params->get('uploads_directory'). '/nb_designer/'. $fileName);
$nbFile = new NbFiles();
$nbFile->setToken($userTemplate);
$nbFile->setName($image->getClientOriginalName());
$nbFile->setAlias($image->getClientOriginalName());
$nbFile->setIsCrea(false);
$templateEntity = $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
if($templateEntity->getUser()){
$nbFile->setUser($templateEntity->getUser());
}
$nbFile->setPath($fileName);
$this->em->persist($nbFile);
$this->em->flush();;
$icone = $nbFile;
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
return [
"src" => $baseurl . "/uploads/nb_designer/" . $icone->getPath(),
'typeImage' =>$ext,
'images' => $this->getImageUploads($userTemplate),
'size' => getimagesize ($baseurl . "/uploads/nb_designer/" . $fileName),
];
}else if (in_array($image->guessExtension(), array('pdf'))) {
$ext = $image->guessExtension();
$token = $this->generateToken(10);
$fileName = $token . '.' . $ext;
$image->move($this->params->get('uploads_directory'). '/nb_designer', $fileName);
$images = $this->convertPdfToImageNotCrea($fileName,$token);
foreach ($images as $item){
$nbFile = new NbFiles();
$templateEntity = $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
if($templateEntity->getUser()){
$nbFile->setUser($templateEntity->getUser());
}
$nbFile->setToken($userTemplate);
$nbFile->setName($item);
$nbFile->setAlias($item);
$nbFile->setIsCrea(false);
$nbFile->setPath($token.'/'.$item);
$this->em->persist($nbFile);
$this->em->flush();;
}
return [
'typeImage' =>$ext,
'images' => $this->getImageUploads($userTemplate),
];
}else{
return ['src' => false];
}
}
public function addImageCrea($image, $userTemplate, $request): array
{
if (in_array($image->guessExtension(), array('svg', 'png', 'jpg','jpeg'))) {
$ext = $image->guessExtension();
$fileName = $this->generateToken(10) . '.' . $ext;
$image->move($this->params->get('uploads_directory'). '/image_ma_crea', $fileName);
$nbFile = new NbFiles();
$nbFile->setToken($userTemplate);
$nbFile->setIsCrea(true);
$templateEntity = $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
if($templateEntity->getUser()){
$nbFile->setUser($templateEntity->getUser());
}
$nbFile->setName($image->getClientOriginalName());
$nbFile->setAlias($image->getClientOriginalName());
$nbFile->setPath($fileName);
$this->em->persist($nbFile);
$this->em->flush();;
return [
'typeImage' =>$ext,
'images' => $this->getImageUploadsCrea($userTemplate),
];
}else if (in_array($image->guessExtension(), array('pdf'))) {
$ext = $image->guessExtension();
$token = $this->generateToken(10);
$fileName = $token . '.' . $ext;
$image->move($this->params->get('uploads_directory'). '/image_ma_crea', $fileName);
$images = $this->convertPdfToImage($fileName,$token);
foreach ($images as $item){
$nbFile = new NbFiles();
$templateEntity = $this->em->getRepository(NbUserTemplates::class)->findOneByToken($userTemplate);
if($templateEntity->getUser()){
$nbFile->setUser($templateEntity->getUser());
}
$nbFile->setToken($userTemplate);
$nbFile->setName($item);
$nbFile->setAlias($item);
$nbFile->setIsCrea(true);
$nbFile->setPath($token.'/'.$item);
$this->em->persist($nbFile);
$this->em->flush();;
}
return [
'typeImage' =>$ext,
'images' => $this->getImageUploadsCrea($userTemplate),
];
}else{
return ['src' => false];
}
}
public function convertPdfToImage($file,$token){
$dir = $this->params->get('uploads_directory').'/image_ma_crea';
$dossier = $this->params->get('uploads_directory').'/image_ma_crea/'.$token;
$saveTo = $dossier.'/';
mkdir($dossier);
shell_exec( "gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r600 -dUseCropBox -o ".$saveTo."page-%d.png ".$dir."/".$file );
// shell_exec( "C:\\gs\\gs9.50\\bin\\gswin64c.exe -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r600 -dUseCropBox -o ".$saveTo."page-%d.png ".$dir."/".$file ); // save pdf to image
$scanned_directory = array_diff( scandir( $dossier ), array( '..', '.', 'source' ) );
$tab = array();
foreach ( $scanned_directory as $key => $value ) {
$tab[] = $value;
}
return $tab;
}
public function convertPdfToImageNotCrea($file,$token){
$dir = $this->params->get('uploads_directory').'/nb_designer';
$dossier = $this->params->get('uploads_directory').'/nb_designer/'.$token;
$saveTo = $dossier.'/';
mkdir($dossier);
shell_exec( "gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r600 -dUseCropBox -o ".$saveTo."page-%d.png ".$dir."/".$file );
// shell_exec( "C:\\gs\\gs9.50\\bin\\gswin64c.exe -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r600 -dUseCropBox -o ".$saveTo."page-%d.png ".$dir."/".$file ); // save pdf to image
$scanned_directory = array_diff( scandir( $dossier ), array( '..', '.', 'source' ) );
$tab = array();
foreach ( $scanned_directory as $key => $value ) {
$tab[] = $value;
}
return $tab;
}
public function uploadImageFromUrl($file)
{
$fileExtentionFromUrl = explode('.', $file);
$fileExtentionFromUrl = $fileExtentionFromUrl[(count($fileExtentionFromUrl) - 1)];
if (in_array($fileExtentionFromUrl, array('svg', 'png', 'jpg'))) {
$response = $this->httpClient->request('GET', $file, [
'buffer' => false,
]);
if (200 !== $response->getStatusCode()) {
return false;
}
$fileNameFromUrl = $this->generateToken(10) . '.' . $fileExtentionFromUrl;
$fileHandler = fopen($this->params->get('uploads_directory') . '/nb_designer/' . $fileNameFromUrl, 'w');
foreach ($this->httpClient->stream($response) as $chunk) {
fwrite($fileHandler, $chunk->getContent());
}
return $fileNameFromUrl;
} else {
return false;
}
}
public function addQrCode($userTemplate, $request)
{
$ext = '.png';
$fileName = uniqid().$ext;
$base64 = str_replace('data:image/png;base64,', '', $request->get('file'));
$file = fopen($this->params->get('uploads_directory').'/nb_designer/templates_images/'.$fileName, 'wb');
fwrite($file, base64_decode($base64));
fclose($file);
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
return [
"src" => $baseurl . "/uploads/nb_designer/templates_images/" . $fileName
];
}
public function getTextDataByFolder($folder): array
{
$template = $this->em->getRepository(NbTextes::class)->findOneByName($folder);
return [
'content' => $template->getContent(),
];
}
public function getCssFonts($request): array
{
$finder = new Finder();
$finder->files()->in($this->params->get('uploads_directory') . '/nb_designer/fonts/');
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$fonts = [];
if ($finder->hasResults()) {
foreach ($finder as $file) {
$fonts[] = [
'name' => str_replace('.ttf', '', $file->getFilename()),
'url' => $baseurl . '/uploads/nb_designer/fonts/' . str_replace('\\', '/', $file->getRelativePath()) . '/' . $file->getFilename()
];
}
}
return $fonts;
}
public function getImageUploads($token){
$images = $this->em->getRepository(NbFiles::class)->findBy(array('token'=>$token,'isCrea'=>false));
return $this->twig->render('nb_designer/imageUpload.html.twig',array('images'=>$images));
}
public function getImageUploadsCrea($token){
$images = $this->em->getRepository(NbFiles::class)->findBy(array('token'=>$token,'isCrea'=>true));
return $this->twig->render('nb_designer/creaUpload.html.twig',array('images'=>$images));
}
public function importTextesPreviews() : void
{
$textes = $this->em->getRepository(NbTextes::class)->findAll();
foreach ($textes as $text) {
$response = $this->httpClient->request('GET', 'https://dpeuzbvf3y4lr.cloudfront.net/typography/'.$text->getName().'/preview.png', [
// optional: if you don't want to buffer the response in memory
'buffer' => false,
]);
if (200 !== $response->getStatusCode()) {
throw new \Exception('...');
}
$fileHandler = fopen($this->params->get('uploads_directory') . '/nb_designer/text_previews/' . $text->getName().'.png', 'w');
foreach ($this->httpClient->stream($response) as $chunk) {
fwrite($fileHandler, $chunk->getContent());
}
}
}
public function updateScale() : void
{
$templates = $this->em->getRepository(NbTemplates::class)->findBy(array('format' => 2,'isCopees' => true), array());
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = 1.36;
$template->setConfig($config);
}
$templates = $this->em->getRepository(NbTemplates::class)->findBy(array('format' => 3,'isCopees' => true), array());
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = 0.82;
$template->setConfig($config);
}
$templates = $this->em->getRepository(NbTemplates::class)->findBy(array('format' => 5,'isCopees' => true), array());
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = 1.8;
$template->setConfig($config);
}
$templates = $this->em->getRepository(NbTemplates::class)->findBy(array('format' => 6,'isCopees' => true), array());
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = 1.8;
$template->setConfig($config);
}
$this->em->flush();
}
public function updateScaleById($format,$isCopees,$scale=null) : void
{
$templates = $this->em->getRepository(NbTemplates::class)->findBy(array('format' => $format,'isCopees' => $isCopees), array());
$oneTemplate = $this->em->getRepository(NbTemplates::class)->findOneBy(array('format' => $format,'isCopees' => $isCopees), array());
if($format == 2) { // carre
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 1.361;
$template->setConfig($config);
}
}
}
if($format == 3) { // classique
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 0.821;
$template->setConfig($config);
}
}
}
if($format == 5) { // a5
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 1.81;
$template->setConfig($config);
}
}
}
if($format == 6) { // a6
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 1.81;
$template->setConfig($config);
}
}
}
if($format == 30) { // a0
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 1.80;
$template->setConfig($config);
}
}
}
if($format == 31) { // a1
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 1.80;
$template->setConfig($config);
}
}
}
if($format == 32) { // a1
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 1.80;
$template->setConfig($config);
}
}
}
if($format == 33) { // a4
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 1.80;
$template->setConfig($config);
}
}
}
if($format == 34) { // a3
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 1.80;
$template->setConfig($config);
}
}
}
if($oneTemplate->getType() == 'faire_mariage_14cm') { // faire part mariage
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 1.80;
$template->setConfig($config);
}
}
}
if($oneTemplate->getType() == 'faire_naissance_105mm') { // faire part naissance
if ($templates) {
foreach ($templates as $template) {
$config = $template->getConfig();
$config['scale'] = $scale ? $scale : 1.80;
$template->setConfig($config);
}
}
}
$this->em->flush();
}
public function loadUserTemplateLayers($request) : array
{
$userTemplate = $this->getUserTemplate();
$design = $userTemplate->getDesign();
if(!isset( $design['frame_'.$request->get('active_frame')])){
$json = '{"version":"2.3.3","objects":[],"background":"#ffffff"}';
$design['frame_'.$request->get('active_frame')] = json_decode($json,true);
}
return [
'layers' => $design['frame_'.$request->get('active_frame')]['objects']
];
}
public function updateSelectableUserTemplateLayers($request) : void
{
$userTemplate = $this->getUserTemplate();
$design = $userTemplate->getDesign();
$design['frame_'.$request->get('active_frame')]['objects'][$request->get('index')]['selectable'] = $request->get('selectable') ? true : false;
$userTemplate->setDesign($design);
$this->em->flush();
}
public function getImageRectoVerso($request){
$userTemplate = $this->getUserTemplate();
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
return [
'recto'=> $userTemplate ? $baseurl.'/uploads/tmp/'.$userTemplate->getRecto():'',
'verso'=> $userTemplate ? $baseurl.'/uploads/tmp/'.$userTemplate->getVerso():'',
];
}
public function generatePdf($request) : string
{
$userTemplate = $this->getUserTemplate();
$ext = '.png';
$frame_0 = uniqid().$ext;
$base64 = str_replace('data:image/png;base64,', '', $request->get('frame_0'));
$file = fopen($this->params->get('uploads_directory').'/tmp/'.$frame_0, 'wb');
fwrite($file, base64_decode($base64));
fclose($file);
$userTemplate->setRecto($frame_0);
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$frames[] = $baseurl . "/uploads/tmp/" . $frame_0;
if($request->get('rectoverso')) {
$frame_1 = uniqid().$ext;
$base64 = str_replace('data:image/png;base64,', '', $request->get('frame_1'));
$file = fopen($this->params->get('uploads_directory').'/tmp/'.$frame_1, 'wb');
fwrite($file, base64_decode($base64));
fclose($file);
$userTemplate->setVerso($frame_1);
$frames[] = $baseurl . "/uploads/tmp/" . $frame_1;
}
$attribute = $this->em->getRepository(Attribut::class)->find($request->get('formatInput'));
$format = $attribute->getName();
if($userTemplate->getIsTrait()){ //avec trait de coupe
if($format == 'A5'){
$papier = $userTemplate->getIsPaysage() ? array(210,148) : array(148,210) ;
$width = $userTemplate->getIsPaysage() ? "793.7007874" :"559.37007874";
$height = $userTemplate->getIsPaysage() ? "559.37007874" :"793.7007874";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}else if($format == 'A6'){
$papier = $userTemplate->getIsPaysage() ? array(148,105) : array(105,148) ;
$width = $userTemplate->getIsPaysage() ? "559.37007874" :"396.8503937";
$height = $userTemplate->getIsPaysage() ? "396.8503937" :"559.37007874";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}else if($format == 'Carré'){
$papier = array(55,55);
$width = "207.87401575";
$height = "207.87401575";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}else if($format == 'Classique') {
$papier = $userTemplate->getIsPaysage() ? array(55,85) : array(85,55) ;
$width = $userTemplate->getIsPaysage() ? "207.87401575" :"321.25984252";
$height = $userTemplate->getIsPaysage() ? "321.25984252" :"207.87401575";
$oriontation = $userTemplate->getIsPaysage() ? 'P':'L';
}else if($format == 'A0') {
$papier = $userTemplate->getIsPaysage() ? array(1189,841) : array(841,1189) ;
$width = $userTemplate->getIsPaysage() ? "4493.8582677" :"3178.582677";
$height = $userTemplate->getIsPaysage() ? "3178.582677" :"4493.8582677";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}else if($format == 'A1') {
$papier = $userTemplate->getIsPaysage() ? array(841,594) : array(594,841) ;
$width = $userTemplate->getIsPaysage() ? "3178.582677" :"2245.0393701";
$height = $userTemplate->getIsPaysage() ? "2245.0393701" :"3178.582677";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}else if($format == 'A2') {
$papier = $userTemplate->getIsPaysage() ? array(594,420) : array(420,594) ;
$width = $userTemplate->getIsPaysage() ? "2245.0393701" :"1587.4015748";
$height = $userTemplate->getIsPaysage() ? "1587.4015748" :"2245.0393701";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}else if($format == 'A3') {
$papier = $userTemplate->getIsPaysage() ? array(420,297) : array(297,420) ;
$width = $userTemplate->getIsPaysage() ? "1587.4015748" :"1122.519685";
$height = $userTemplate->getIsPaysage() ? "1122.519685" :"1587.4015748";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}else if($format == 'A4') {
$papier = $userTemplate->getIsPaysage() ? array(297,210) : array(210,297) ;
$width = $userTemplate->getIsPaysage() ? "1122.519685" :"805.03937";
$height = $userTemplate->getIsPaysage() ? "805.03937" :"1122.519685";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}else{
if($attribute->getTypeProduct() == Attribut::FAIRE_PART_NAISSANCE){
$papier = $userTemplate->getIsPaysage() ? array(148,105) : array(105,148) ;
$width = $userTemplate->getIsPaysage() ? "559.37007874" :"396.8503937";
$height = $userTemplate->getIsPaysage() ? "396.8503937" :"559.37007874";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}else if($attribute->getTypeProduct() == Attribut::FAIRE_PART_MARIAGE){
$papier = array(140, 140);
$width = "529.13385827";
$height = "529.13385827";
$oriontation = 'P';
}else {
$papier = $userTemplate->getIsPaysage() ? array(210,148) : array(148,210) ;
$width = $userTemplate->getIsPaysage() ? "793.7007874" :"559.37007874";
$height = $userTemplate->getIsPaysage() ? "559.37007874" :"793.7007874";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}
}
$html = $this->twig->render('nb_designer/pdf_sans_trait_coupe.html.twig', [
'frames' => $frames,
'width' => $width,
'height' => $height
]
);
}else {
if ($format == 'A5') {
$papier = $userTemplate->getIsPaysage() ? array(216,154) : array(154, 216) ;
$width = $userTemplate->getIsPaysage() ? "808.818898" :"574.488189";
$height = $userTemplate->getIsPaysage() ? "574.488189" :"808.818898";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
} else if ($format == 'A6') {
$papier = $userTemplate->getIsPaysage() ? array(154,111) : array(111,154) ;
$width = $userTemplate->getIsPaysage() ? "574.488189" :"411.968504";
$height = $userTemplate->getIsPaysage() ? "411.968504" :"574.488189";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
} else if ($format == 'Carré') {
$papier = array(61, 61);
$width = "222.992126"; // 59 mm
$height = "222.992126"; // 59 mm
$oriontation = 'P';
} else if ($format == 'Classique') {
$papier = $userTemplate->getIsPaysage() ? array(61,91) : array(91,61) ;
$width = $userTemplate->getIsPaysage() ? "222.992126" :"336.377953";
$height = $userTemplate->getIsPaysage() ? "336.377953" :"222.992126";
$oriontation = $userTemplate->getIsPaysage() ? 'P':'L';
} else if ($format == 'A0') {
$papier = $userTemplate->getIsPaysage() ? array(1195,847) : array(847,1195) ;
$width = $userTemplate->getIsPaysage() ? "4505.196851" :"3189.92126";
$height = $userTemplate->getIsPaysage() ? "3189.92126" :"4505.196851";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
} else if ($format == 'A1') {
$papier = $userTemplate->getIsPaysage() ? array(847,600) : array(600,847) ;
$width = $userTemplate->getIsPaysage() ? "3189.92126" :"2256.377953";
$height = $userTemplate->getIsPaysage() ? "2256.377953" :"3189.92126";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
} else if ($format == 'A2') {
$papier = $userTemplate->getIsPaysage() ? array(600,426) : array(426,600) ;
$width = $userTemplate->getIsPaysage() ? "2256.377953" :"1598.740158";
$height = $userTemplate->getIsPaysage() ? "1598.740158" :"2256.377953";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
} else if ($format == 'A3') {
$papier = $userTemplate->getIsPaysage() ? array(426,303) : array(303,426) ;
$width = $userTemplate->getIsPaysage() ? "1598.740158" :"1133.858268";
$height = $userTemplate->getIsPaysage() ? "1133.858268" :"1598.740158";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
} else if ($format == 'A4') {
$papier = $userTemplate->getIsPaysage() ? array(303,216) : array(216,303) ;
$width = $userTemplate->getIsPaysage() ? "1133.858268" :"805.03937";
$height = $userTemplate->getIsPaysage() ? "805.03937" :"1133.858268";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
} else {
if ($attribute->getTypeProduct() == Attribut::FAIRE_PART_NAISSANCE) {
$papier = $userTemplate->getIsPaysage() ? array(154,111) : array(111,154) ;
$width = $userTemplate->getIsPaysage() ? "574.488189" :"411.968504";
$height = $userTemplate->getIsPaysage() ? "411.968504" :"574.488189";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
} else if ($attribute->getTypeProduct() == Attribut::FAIRE_PART_MARIAGE) {
$papier = array(146, 146);
$width = "544.251968";
$height = "544.251968";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
} else {
$papier = $userTemplate->getIsPaysage() ? array(216,154) : array(154,216) ;
$width = $userTemplate->getIsPaysage() ? "793.700785" :"559.370077";
$height = $userTemplate->getIsPaysage() ? "559.370077" :"793.700785";
$oriontation = $userTemplate->getIsPaysage() ? 'L':'P';
}
}
$html = $this->twig->render('nb_designer/pdf.html.twig', [
'frames' => $frames,
'width' => $width,
'height' => $height
]
);
}
$html2pdf = new Html2Pdf($oriontation, $papier, 'en', true, 'UTF-8', array('0','0','0','0'));
// $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', array('5','5','5','5'));
$html2pdf->pdf->SetAuthor('Copees');
$html2pdf->pdf->SetTitle('Copees');
$html2pdf->pdf->SetSubject('Copees');
$html2pdf->pdf->SetKeywords('Copees');
$html2pdf->pdf->SetDisplayMode('real');
$html2pdf->WriteHTML($html);
$nameFichier = uniqid().'.pdf';
$userTemplate->setPath($nameFichier);
$this->em->flush();
$path_pdf = $this->params->get('uploads_directory').'/tmp/'.$nameFichier;
$html2pdf->Output($path_pdf,'F');
return $nameFichier;
}
public function convertImageToPdf($request,$userTemplate,$image1,$image2){
if($image1) {
$frame_0 = $image1;
$frame_0_new = 'ma_crea_recto_' . $userTemplate->getToken() . '.png';
$dossier_frame_0 = str_replace('/uploads', $this->params->get('uploads_directory'), $frame_0);
$dossier_frame_0_new = $this->params->get('uploads_directory') . '/tmp/' . $frame_0_new;
if (trim($dossier_frame_0) == trim($dossier_frame_0_new)) {
$frame_0_new = 'ma_crea_recto_' . $userTemplate->getToken() . '_1.png';
$dossier_frame_0_new = $this->params->get('uploads_directory') . '/tmp/' . $frame_0_new;
}
copy($dossier_frame_0, $dossier_frame_0_new);
$userTemplate->setRecto($frame_0_new);
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$frames[] = $baseurl . "/uploads/tmp/" . $frame_0_new;
if($image2){
$frame_1 = $image2;
$frame_1_new = 'ma_crea_verso_'.$userTemplate->getToken() .'.png';
$dossier_frame_1 = str_replace ('/uploads',$this->params->get('uploads_directory'),$frame_1);
$dossier_frame_1_new = $this->params->get('uploads_directory'). '/tmp/' . $frame_1_new;
if(trim($dossier_frame_1) == trim($dossier_frame_1_new)){
$frame_1_new = 'ma_crea_verso_'. $userTemplate->getToken() .'_1.png';
$dossier_frame_1_new = $this->params->get('uploads_directory'). '/tmp/' . $frame_1_new;
}
copy($dossier_frame_1 , $dossier_frame_1_new);
$userTemplate->setVerso($frame_1_new);
$frames[] = $baseurl . "/uploads/tmp/" . $frame_1_new;
}else{
$userTemplate->setVerso(null);
}
$attribute = $this->em->getRepository(Attribut::class)->find($request->get('formatInput'));
$format = $attribute->getName();
if($format == 'A3') {
$papier = array(297,420 );
$width = "1122";
$height = "1587" ;
$oriontation = 'P';
}else if($format == 'A4') {
$papier = array(210,297 );
$width = "793";
$height = "1122" ;
$oriontation = 'P';
}else{
$papier = array(154, 216);
$width = "559";
$height = "793";
$oriontation = 'P';
}
$html = $this->twig->render('nb_designer/pdf2.html.twig', [
'frames' => $frames,
'width' => $width,
'height' => $height
]
);
$html2pdf = new Html2Pdf($oriontation, $papier, 'en', true, 'UTF-8', array('0','0','0','0'));
$html2pdf->pdf->SetAuthor('Copees');
$html2pdf->pdf->SetTitle('Copees');
$html2pdf->pdf->SetSubject('Copees');
$html2pdf->pdf->SetKeywords('Copees');
$html2pdf->pdf->SetDisplayMode('real');
$html2pdf->WriteHTML($html);
$nameFichier = uniqid().'.pdf';
$userTemplate->setIsCrea(true);
if($request->get('plus_expert') == 1)$userTemplate->setIsPlusExpert(true);
else $userTemplate->setIsPlusExpert(false);
$userTemplate->setPath($nameFichier);
$this->em->flush();
$path_pdf = $this->params->get('uploads_directory').'/tmp/'.$nameFichier;
$html2pdf->Output($path_pdf,'F');
return 1;
}
return 0;
}
public function generateZip($request) : string
{
$userTemplate = $this->em->getRepository(NbUserTemplates::class)->findOneBy(array('token'=>$request->get('user_template')));
$product = $this->em->getRepository(Product::class)->find($request->get('id_product'));
if($product->getTypeProduct() == Product::MENU){
$image1 = $request->get('frame_0');
$image2 = null;
if ($request->get('rectoverso')) {
$image2= $request->get('frame_1');
}
return $this->convertImageToPdf($request,$userTemplate,$image1,$image2);
}else {
if ($request->get('frame_0')) {
$frame_0 = $request->get('frame_0');
$frame_0_new = 'ma_crea_recto_' . $userTemplate->getToken() . '.png';
$dossier_frame_0 = str_replace('/uploads', $this->params->get('uploads_directory'), $frame_0);
$dossier_frame_0_new = $this->params->get('uploads_directory') . '/tmp/' . $frame_0_new;
if (trim($dossier_frame_0) == trim($dossier_frame_0_new)) {
$frame_0_new = 'ma_crea_recto_' . $userTemplate->getToken() . '_1.png';
$dossier_frame_0_new = $this->params->get('uploads_directory') . '/tmp/' . $frame_0_new;
}
copy($dossier_frame_0, $dossier_frame_0_new);
$userTemplate->setRecto($frame_0_new);
if ($request->get('rectoverso')) {
$frame_1 = $request->get('frame_1');
$frame_1_new = 'ma_crea_verso_' . $userTemplate->getToken() . '.png';
$dossier_frame_1 = str_replace('/uploads', $this->params->get('uploads_directory'), $frame_1);
$dossier_frame_1_new = $this->params->get('uploads_directory') . '/tmp/' . $frame_1_new;
if (trim($dossier_frame_1) == trim($dossier_frame_1_new)) {
$frame_1_new = 'ma_crea_verso_' . $userTemplate->getToken() . '_1.png';
$dossier_frame_1_new = $this->params->get('uploads_directory') . '/tmp/' . $frame_1_new;
}
copy($dossier_frame_1, $dossier_frame_1_new);
$userTemplate->setVerso($frame_1_new);
if ($request->get('frame_1')) {
$zip = new \ZipArchive();
$nameFichier = 'ma_crea_' . $userTemplate->getToken() . '.zip';
$zipfile = $this->params->get('uploads_directory') . '/tmp/' . $nameFichier;
if (file_exists($zipfile)) unlink($zipfile);
if ($zip->open($zipfile, \ZipArchive::CREATE) === TRUE) {
$zip->addFile($this->params->get('uploads_directory') . '/tmp/' . $frame_0_new, 'recto.png');
$zip->addFile($this->params->get('uploads_directory') . '/tmp/' . $frame_1_new, 'verso.png');
$zip->close();
}
}
} else {
$userTemplate->setVerso(null);
$nameFichier = $frame_0_new;
}
$userTemplate->setIsCrea(true);
if ($request->get('plus_expert') == 1) $userTemplate->setIsPlusExpert(true);
else $userTemplate->setIsPlusExpert(false);
$userTemplate->setPath($nameFichier);
$this->em->flush();
return 1;
} else {
return 0;
}
}
}
public function addToCart($request,$user) : array
{
$userTemplate = $this->getUserTemplate();
$arrayRedirect = [];
if($userTemplate){
$cart = $this->cart_service->getCartCurrent();
if(!$cart){
$cart = $this->cart_service->createCart(true);
}
if($userTemplate->getToken()){
$typeAbonnement = $this->cart_service->getTypeAbonnementPro($user,$cart->getId()); // get type abonnement
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement); // get attribute price string
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($userTemplate->getProductAttribute()->getId(), $userTemplate->getQuantite());
$cartDetail = $this->em->getRepository(CartDetail::class)->findOneBy(array('cart'=>$cart->getId(),'token'=>$userTemplate->getToken()));
if(!$cartDetail){
$cartDetail = new CartDetail();
}
$cartDetail->setTypeProduct($userTemplate->getTypeProduct());
$cartDetail->setToken($userTemplate->getToken());
$cartDetail->setProductAttribute($userTemplate->getProductAttribute());
$cartDetail->setProduct($userTemplate->getProduct());
$cartDetail->setCart($cart);
$cartDetail->setFilePapier($userTemplate->getPath());
$cartDetail->setFilePapierFirstImage($userTemplate->getRecto());
if($userTemplate->getProduct()->getTypeProduct() == Product::CARTE){
$name = 'carte-visite';
$arrayRedirect = ['carteVisite'=>1,'displayProduct'=>1];
}else if($userTemplate->getProduct()->getTypeProduct() == Product::FLYERS){
$name = 'flyrs';
$arrayRedirect = ['flyer'=>1,'displayProduct'=>1];
}else if($userTemplate->getProduct()->getTypeProduct() == Product::AFFICHE){
$name = 'affiche';
$arrayRedirect = ['showcarteFlyer'=>1,'displayProduct'=>1,'affiche'=>1];
}else if($userTemplate->getProduct()->getTypeProduct() == Product::MENU){
$name = 'menu';
$arrayRedirect = ['menu'=>1,'displayProduct'=>1];
}else if($userTemplate->getProduct()->getTypeProduct() == Product::FAIRE_PART_NAISSANCE){
$name = 'faire_naissance';
$arrayRedirect = ['faire_naissance'=>1,'displayProduct'=>1];
}else if($userTemplate->getProduct()->getTypeProduct() == Product::FAIRE_PART_MARIAGE){
$name = 'faire_mariage';
$arrayRedirect = ['faire_mariage'=>1,'displayProduct'=>1];
}else{
$name = '';
}
$cartDetail->setFilePapierName($name.'-'.$userTemplate->getPath());
$cartDetail->setNbrPapier($userTemplate->getQuantite());
$cartDetail->setQty(0);
$cartDetail->setQtyColor(0);
$cartDetail->setQtyNoir(0);
$cartDetail->setProductName($userTemplate->getProduct()->getTitre());
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($userTemplate->getFinition() == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($userTemplate->getFinition() == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($userTemplate->getFinition() == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($userTemplate->getFinition() == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($userTemplate->getFinition() == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($userTemplate->getFinition() == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($userTemplate->getFinition() == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()))* $pourcentageFinition;
$priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
$priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
$priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
if($userTemplate->getIsPlusExpert()&& $userTemplate->getIsCrea()){
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtcWithoutReduction;
}else {
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}())+$priceFinitonHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+$priceFinitonTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt())+$priceFinitonHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc()+ $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+$priceFinitonTtcWithoutReduction;
}
if(($userTemplate->getProduct() and $userTemplate->getProduct()->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($userTemplate->getProduct() and $userTemplate->getProduct()->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if($userTemplate->getIsEnveloppe()) {
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $userTemplate->getQuantite());
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $userTemplate->getQuantite());
$prixHtWithoutReduction = $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT * $userTemplate->getQuantite());
$prixTtcWithoutReduction = $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC * $userTemplate->getQuantite());
}
}
// update price by country
$prixHt = $this->cart_service->updatePriceByCountry($prixHt,$userTemplate->getProduct());
$prixTtc = $this->cart_service->updatePriceByCountry($prixTtc,$userTemplate->getProduct());
$prixHtWithoutReduction = $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$userTemplate->getProduct());
$prixTtcWithoutReduction = $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$userTemplate->getProduct());
$cartDetail->setPrixHt($prixHt);
$cartDetail->setPrixTtc($prixTtc);
$cartDetail->setPrixHtWithoutReduction($prixHtWithoutReduction);
$cartDetail->setPrixTtcWithoutReduction($prixTtcWithoutReduction);
$cartDetail->setIsEnveloppe($userTemplate->getIsEnveloppe());
$cartDetail->setIsMaCrea($userTemplate->getIsCrea());
$cartDetail->setIsPlusExpert($userTemplate->getIsPlusExpert());
$cartDetail->setFinition($userTemplate->getFinition());
$cartDetail->setIsTrait($userTemplate->getIsTrait());
$this->em->persist($cartDetail);
$this->em->flush();
$this->cart_service->removeCartDetailPapierPoste($cart,$cartDetail,true); //remove Papier Poste
$this->cart_service->updatePriceCart($cart);
}
}
$this->session->remove('nbToken');
return $arrayRedirect;
}
public function updateUserTemplateOptions($request) : void
{
$userTemplate = $this->getUserTemplate();
switch ($request->get('field')) {
case 'quantite' :
$userTemplate->setQuantite($request->get('valeur'));
$this->em->flush();
break;
case 'grammage' :
$userTemplate->setGrammage($request->get('valeur'));
$this->em->flush();
break;
case 'papier' :
$userTemplate->setPapier($request->get('valeur'));
$this->em->flush();
break;
}
}
public function updateUserTemplateGetPrice($request,$cart,$user=false)
{
$prixHt = null;
$prixTtc = null;
$prixHtWithoutReduction = 0;
$prixTtcWithoutReduction = 0;
$userTemplate = $this->em->getRepository(NbUserTemplates::class)->findOneByToken($request->get('userTemplate'));
$typeImpression = $request->get('typeImpression');
$plastification = $request->get('plastification');
$id_product = $request->get('productId');
$id_format = $request->get('formatInput');
$rectoverso = $request->get('rectoversoInput');
$grammage = $request->get('grammage');
$quantite = $request->get('quantite');
$finition = $request->get('finition');
$plus_expert = $request->get('plus_expert');
$isEnveloppe = $request->get('isEnveloppe');
$isCrea = $request->get('isCrea');
$isTrait = $request->get('isTrait');
$product = $this->em->getRepository(Product::class)->find($id_product);
// update plus expert
if($request->get('plus_expert') == 1)$userTemplate->setIsPlusExpert(true);
else $userTemplate->setIsPlusExpert(false);
$this->em->flush();
// update is enveloppe
if(($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if ($request->get('isEnveloppe') == 1) $userTemplate->setIsEnveloppe(true);
else $userTemplate->setIsEnveloppe(false);
$this->em->flush();
}
// check abonnementPro
$abonnement = $this->cart_service->checkAbonnementToCartOrOrder($user,$cart->getId());
$typeAbonnement = null;
if($abonnement){
$typeAbonnement = $abonnement['type'];
}
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement);
if($product and $product->getTypeProduct() == Product::AFFICHE){
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$grammage,'typeImpression'=>$typeImpression,'plastification'=>$plastification,'isEnabled'=>true));
}else{
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$grammage,'rectoverso'=>$rectoverso,'isEnabled'=>true));
}
if($productAttribute) {
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->getProductAttributePriceByIdAndQty($productAttribute->getId(), $quantite);
if ($priceProductAttr) {
$priceFinitonHt = 0;
$priceFinitonTtc = 0;
$priceFinitonHtWithoutReduction = 0;
$priceFinitonTtcWithoutReduction = 0;
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonHt = ($priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) )* $pourcentageFinition;
$priceFinitonTtc = ($priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}()))* $pourcentageFinition;
$priceFinitonHtWithoutReduction = ($priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()))* $pourcentageFinition;
$priceFinitonTtcWithoutReduction = ($priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()))* $pourcentageFinition;
// if($plus_expert && $isCrea){
if($plus_expert){
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() ) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + CartDetail::PLUS_EXPERT_HT +$priceFinitonHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc()) + CartDetail::PLUS_EXPERT_TTC +$priceFinitonTtcWithoutReduction;
}else{
$prixHt = $priceProductAttr->{$attributeEntityPriceProduct['prixHt']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixHt']}()) + $priceFinitonHt;
$prixTtc = $priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->{$attributeEntityPriceProduct['prixTtc']}())+ $priceFinitonTtc;
$prixHtWithoutReduction = $priceProductAttr->getPrixHt() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixHt()) + $priceFinitonHtWithoutReduction;
$prixTtcWithoutReduction = $priceProductAttr->getPrixTtc() + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$priceProductAttr->getPrixTtc())+ $priceFinitonTtcWithoutReduction;
}
if(($product and $product->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($product and $product->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if($isEnveloppe) {
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $quantite);
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $quantite);
$prixHtWithoutReduction = $prixHtWithoutReduction + (CartDetail::IS_ENVELOPPE_HT * $quantite);
$prixTtcWithoutReduction = $prixTtcWithoutReduction + (CartDetail::IS_ENVELOPPE_TTC * $quantite);
}
}
//update price by country
$prixHt = $this->cart_service->updatePriceByCountry($prixHt,$product);
$prixTtc = $this->cart_service->updatePriceByCountry($prixTtc,$product);
$prixHtWithoutReduction = $this->cart_service->updatePriceByCountry($prixHtWithoutReduction,$product);
$prixTtcWithoutReduction = $this->cart_service->updatePriceByCountry($prixTtcWithoutReduction,$product);
$userTemplate->setGrammage($grammage);
$userTemplate->setFormat($id_format);
$userTemplate->setProduct($product);
$userTemplate->setProductAttribute($productAttribute);
$userTemplate->setTypeProduct($product->getTypeProduct());
$userTemplate->setQuantite($quantite);
$userTemplate->setFinition($finition);
$userTemplate->setRectoverso($rectoverso);
$userTemplate->setIsPlusExpert($plus_expert);
$userTemplate->setIsCrea($isCrea);
$userTemplate->setIsTrait($isTrait);
$this->em->persist($userTemplate);
$this->em->flush();
}
}
return $this->getPriceAfterPromoAndAbonnement( $prixHt,$prixTtc,$prixHtWithoutReduction,$prixTtcWithoutReduction,$abonnement);
}
function getPriceAfterPromoAndAbonnement($prixHt,$prixTtc,$prixHtWithoutReduction,$prixTTcWithoutReduction,$abonnementPro,$carrierId = null,$typeLivraisonNational=null,$typeLivraison30min = null,$priceAbonnement = false,$dataLocalisation =array(),$imprimeur=null){
$isPromo = false;
$abonnementStarter = $this->em->getRepository(Abonnement::class)->findOneBy(array());
$is_abonnementStarter = $this->abonnementService->checkAbonnementByUser($abonnementStarter->getPlanId());
// price carrier && surcharge
if ($carrierId) {
$carrier = $this->em->getRepository(Carrier::class)->find($carrierId);
$carrierNationalJ1 = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J1));
$carrierNationalJ2 = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::J2));
$carrier30MIN = $this->em->getRepository(Carrier::class)->findOneBy(array('num' => Carrier::STUART));
if ($carrier == $carrier30MIN || $carrier == $carrierNationalJ1 || $carrier == $carrierNationalJ2) {
if ($carrier == $carrierNationalJ1) {
if ($typeLivraisonNational == Cart::LIVRAISON_STANDARD_P) {
$priceExtraHT = Cart::PRICE_LIVRAISON_STANDARD_P_HT;
$priceExtraTTC = Cart::PRICE_LIVRAISON_STANDARD_P_TTC;
} else if ($typeLivraisonNational == Cart::LIVRAISON_EXPRESS_P) {
$priceExtraHT = Cart::PRICE_LIVRAISON_EXPRESS_P_HT;
$priceExtraTTC = Cart::PRICE_LIVRAISON_EXPRESS_P_TTC;
} else if ($typeLivraisonNational == Cart::LIVRAISON_EXPRESS_D) {
$priceExtraHT = Cart::PRICE_LIVRAISON_EXPRESS_D_HT;
$priceExtraTTC = Cart::PRICE_LIVRAISON_EXPRESS_D_TTC;
}
if ($prixTtc < 12) {
$priceCarrierHT = $priceExtraHT;
$priceCarrierTTC = $priceExtraTTC;
$priceSurchargeHT = Cart::SURCHARGE_HT;
$priceSurchargeTTC = Cart::SURCHARGE_TTC;
} else if ($prixTtc > 12 && $prixTtc < 29) {
$priceCarrierHT = $priceExtraHT;
$priceCarrierTTC = $priceExtraTTC;
$priceSurchargeHT = 0;
$priceSurchargeTTC = 0;
} else {
$priceCarrierHT = $priceCarrierTTC = $priceSurchargeHT = $priceSurchargeTTC = 0;
}
} else {
$typeLivraison30min = $this->cart_service->getTypeLivraison30min($imprimeur,$dataLocalisation);
$tabPriceLivraison30Min = $this->cart_service->getPriceLivraison30MinByType($typeLivraison30min);
if ($prixTtc < 12) {
$priceCarrierHT = isset($tabPriceLivraison30Min['priceHT']) ? $tabPriceLivraison30Min['priceHT'] : $carrier->getPrixHt();
$priceCarrierTTC = isset($tabPriceLivraison30Min['priceTTC']) ? $tabPriceLivraison30Min['priceTTC'] : $carrier->getPrixTtc();
$priceSurchargeHT = Cart::SURCHARGE_HT;
$priceSurchargeTTC = Cart::SURCHARGE_TTC;
} else if ($prixTtc > 12 && $prixTtc < 29) {
$priceCarrierHT = isset($tabPriceLivraison30Min['priceHT']) ? $tabPriceLivraison30Min['priceHT'] : $carrier->getPrixHt();
$priceCarrierTTC = isset($tabPriceLivraison30Min['priceTTC']) ? $tabPriceLivraison30Min['priceTTC'] : $carrier->getPrixTtc();
$priceSurchargeHT = 0;
$priceSurchargeTTC = 0;
} else {
$priceCarrierHT = $priceCarrierTTC = $priceSurchargeHT = $priceSurchargeTTC = 0;
}
}
} else {
$priceCarrierHT = $priceCarrierTTC = $priceSurchargeHT = $priceSurchargeTTC = 0;
}
}
else {
$priceCarrierHT = $priceCarrierTTC = $priceSurchargeHT = $priceSurchargeTTC = 0;
}
if($abonnementPro){
$priceCarrierHT = $priceCarrierTTC = $priceSurchargeHT = $priceSurchargeTTC = 0;
$tokenCart = $this->session->get('token_cart');
$cart = null;
if ($tokenCart) {
$cart = $this->em->getRepository(Cart::class)->findOneBy(array('token' => $tokenCart)); // cart
if($cart){
if ($cart->getIsPromo()) {
$promo = $cart->getCodePromo();
$reduction = $promo->getReduction();
if ($promo->getType() == CodePromo::EN_POURCENTAGE) {
if ($reduction <= 100) {
$prixHt = $prixHt - (($prixHt * $reduction) / 100);
$prixTtc = $prixTtc- (($prixTtc * $reduction) / 100);
$isPromo = true;
}
}
}
}
}
}else{
if($is_abonnementStarter){
$reduction = $abonnementStarter->getReduction();
if ($reduction > 0) {
$priceCarrierHT = $priceCarrierTTC = 0;
$prixHt = $prixHt + $priceCarrierHT + $priceSurchargeHT;
$prixTtc = $prixTtc + $priceCarrierTTC + $priceSurchargeTTC;
$prixHtWithoutReduction = $prixHtWithoutReduction + $priceCarrierHT + $priceSurchargeHT;
$prixTTcWithoutReduction = $prixTTcWithoutReduction + $priceCarrierTTC + $priceSurchargeTTC;
$prixHt = $prixHt - (($prixHt * $reduction) / 100);
$prixTtc = $prixTtc- (($prixTtc * $reduction) / 100);
}
}else {
$tokenCart = $this->session->get('token_cart');
$cart = null;
if ($tokenCart) {
$cart = $this->em->getRepository(Cart::class)->findOneBy(array('token' => $tokenCart)); // cart
if($cart){
if ($cart->getIsPromo()) {
$promo = $cart->getCodePromo();
$reduction = $promo->getReduction();
if ($promo->getFreelivred()) {
$priceCarrierHT = $priceCarrierTTC = $priceSurchargeHT = $priceSurchargeTTC = 0;
}
$prixHt = $prixHt + $priceCarrierHT + $priceSurchargeHT;
$prixTtc = $prixTtc + $priceCarrierTTC + $priceSurchargeTTC;
$prixHtWithoutReduction = $prixHtWithoutReduction + $priceCarrierHT + $priceSurchargeHT;
$prixTTcWithoutReduction = $prixTTcWithoutReduction + $priceCarrierTTC + $priceSurchargeTTC;
if ($promo->getType() == CodePromo::EN_POURCENTAGE) {
if ($reduction <= 100) {
$prixHt = $prixHt - (($prixHt * $reduction) / 100);
$prixTtc = $prixTtc- (($prixTtc * $reduction) / 100);
$isPromo = true;
}
}
}else{
$prixHt = $prixHt + $priceCarrierHT + $priceSurchargeHT;
$prixTtc = $prixTtc + $priceCarrierTTC + $priceSurchargeTTC;
$prixHtWithoutReduction = $prixHtWithoutReduction + $priceCarrierHT + $priceSurchargeHT;
$prixTTcWithoutReduction = $prixTTcWithoutReduction + $priceCarrierTTC + $priceSurchargeTTC;
}
}
}
}
}
return [
'prixHt' => $prixHt,
'prixTtc' => $prixTtc,
'is_abonnement'=>$is_abonnementStarter,
'isPromo'=>$isPromo,
'prixHtWithoutReduction' => $prixHtWithoutReduction,
'prixTTcWithoutReduction' => $prixTTcWithoutReduction,
'abonnementPro' => $abonnementPro,
'priceCarrierHT' => (float)$priceCarrierHT + (float)$priceSurchargeHT,
'priceCarrierTTC' => (float)$priceCarrierTTC + (float)$priceSurchargeTTC,
'priceSurchargeHT' => (float)$priceSurchargeHT,
'priceSurchargeTTC' => (float)$priceSurchargeTTC,
'priceAbonnement' => $priceAbonnement
];
}
public function getListFonttyle()
{
$listFont= $this->em->getRepository(NbTemplates::class)->findAll();
$array = array();
foreach ($listFont as $item){
if($item->getFonts()){
foreach ($item->getFonts() as $font){
$array[$font['name']]['name'] = $font['name'];
$array[$font['name']]['alias'] = $font['alias'];
}
}
}
$listFontText = $this->em->getRepository(NbTextes::class)->findAll();
foreach ($listFontText as $item){
foreach ($item->getContent()['font'] as $font) {
$array[$font['name']]['name'] = $font['name'];
$array[$font['name']]['alias'] = $font['alias'];
}
}
return $array;
}
public function getTemplateAjax($request)
{
$data = $request->query->all();
$is_scroll = isset($data['is_scroll']) ? $data['is_scroll'] : null;
$format_id = isset($data['format']) ? $data['format'] : 2;
$search= (isset($data['searchTag']) and !empty($data['searchTag'])) ? $data['searchTag'] :null;
$offset = isset($data['offset']) ? $data['offset'] : 0;
$isPaysage = (isset($data['isPaysage']) && $data['isPaysage'] == 1) ? 1 : 0;
$templates = $this->em->getRepository(NbTemplates::class)->getTemplates($format_id,'ASC',16,$offset,$search,$isPaysage);
$is_search_empty = false;
if(!$is_scroll) {
if ($search && count($templates) == 0) {
$templates = $this->em->getRepository(NbTemplates::class)->getTemplates($format_id, 'ASC', 16, $offset,null,$isPaysage);
$is_search_empty = true;
}
}
return array(
'templates' => $templates,
'is_search_empty' => $is_search_empty,
);
}
public function getQtyFlyerCarte($request)
{
$qtyExiste = false;
$prixQty = false;
$typeImpression= $request->get('typeImpression');
$plastification= $request->get('plastification');
$id_format= $request->get('id_format');
$id_product= $request->get('id_product');
$id_gramage= $request->get('id_gramage');
$rectoverso= $request->get('rectoverso');
$finition= $request->get('finition');
$quantite= $request->get('quantite');
$product = $this->em->getRepository(Product::class)->find($id_product);
if($product and $product->getTypeProduct() == Product::AFFICHE){
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_gramage,'typeImpression'=>$typeImpression,'plastification'=>$plastification,'isEnabled'=>true));
}else{
$productAttribute = $this->em->getRepository(ProductAttribute::class)->findOneBy(array('format'=>$id_format,'gramage'=>$id_gramage,'rectoverso'=>$rectoverso,'isEnabled'=>true));
}
$qtys = false;
if($productAttribute) {
$data = $this->getQtyFlyerCarteByProductAttribute($productAttribute->getId(),$finition,$quantite);
$qtys = $data['qtys'];
$qtyExiste = $data['qtyExiste'];
$prixQty = $data['prixQty'];
}
if($qtys){
if($qtyExiste){
$quantite = $quantite;
$prixQty = $prixQty;
}else{
$quantite = $qtys[0]['qty'];
$prixQty = $qtys[0]['prixTtc'];
}
return ['qtys' => $qtys,'quantiteFirst'=>$quantite,'prixQtyFirst'=>$prixQty];
}else{
return array();
}
}
public function getGrammageAffichage($request)
{
$typeImpression= $request->get('typeImpression');
$id_product= $request->get('id_product');
$id_format= $request->get('id_format');
$grammages = $this->getGrammageByTypeImpression($id_product,$id_format,$typeImpression);
return ['gramages' =>$grammages];
}
public function getQtyFlyerCarteByProductAttribute($id,$finition,$quantite=false,$isEnveloppe=false,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
$user = $this->security->getUser();
$cart = $this->cart_service->createCart(true);
$typeAbonnement = $this->cart_service->getTypeAbonnementPro($user,$cart->getId()); // get type abonnement
$qtys = $this->em->getRepository(PriceProduct::class)->getQuantity($id);
$qtyExiste = false;
$prixQty = false;
$prixQtyHt = false;
$priceFinitonTtc = 0 ;
$priceFinitonHt = 0 ;
foreach ($qtys as &$item){
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->find($item['id']);
$keyArrayPrice = $this->getKeyArrayPrice($typeAbonnement,$priceProductAttr); // get key for prix
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* $pourcentageFinition;
$priceFinitonHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* $pourcentageFinition;
$priceFinitonTtcWithoutPromo = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* $pourcentageFinition;
$priceFinitonHtWithoutPromo = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* $pourcentageFinition;
$priceBordsArrondisHt = 0;
$priceBordsArrondisTtc = 0;
$priceBordsArrondisHtWithoutPromo = 0;
$priceBordsArrondisTtcWithoutPromo = 0;
if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
$priceBordsArrondisHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisHtWithoutPromo = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisTtcWithoutPromo = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
}
$pricePlastificationHt = 0;
$pricePlastificationTtc = 0;
$pricePlastificationHtWithoutPromo = 0;
$pricePlastificationTtcWithoutPromo = 0;
if($plastification == CartDetail::BORDS_ARRONDIS_CHECKED){
$pricePlastificationHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationHtWithoutPromo = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationTtcWithoutPromo = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* CartDetail::POURCENTAGE_PLASTIFICATION;
}
$prixTtc = $item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']])+$priceFinitonTtc+$priceBordsArrondisTtc +$pricePlastificationTtc;
$prixHt = $item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']])+$priceFinitonHt+$priceBordsArrondisHt +$pricePlastificationHt;
$prixTtcWithoutPromo = $item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']])+$priceFinitonTtcWithoutPromo +$priceBordsArrondisTtcWithoutPromo +$pricePlastificationTtcWithoutPromo;
$prixHtWithoutPromo = $item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt'])+$priceFinitonHtWithoutPromo +$priceBordsArrondisHtWithoutPromo +$pricePlastificationHtWithoutPromo;
if(($priceProductAttr->getProductAttribute()->getProduct() and $priceProductAttr->getProductAttribute()->getProduct()->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($priceProductAttr->getProductAttribute()->getProduct() and $priceProductAttr->getProductAttribute()->getProduct()->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if($isEnveloppe) {
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $priceProductAttr->getQty());
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $priceProductAttr->getQty());
$prixTtcWithoutPromo = $prixTtcWithoutPromo + (CartDetail::IS_ENVELOPPE_TTC * $priceProductAttr->getQty());
$prixHtWithoutPromo = $prixHtWithoutPromo + (CartDetail::IS_ENVELOPPE_HT * $priceProductAttr->getQty());
}
}
//update price by country
$prixHt = $this->cart_service->updatePriceByCountry($prixHt,$priceProductAttr->getProductAttribute()->getProduct());
$prixTtc = $this->cart_service->updatePriceByCountry($prixTtc,$priceProductAttr->getProductAttribute()->getProduct());
$prixHtWithoutPromo = $this->cart_service->updatePriceByCountry($prixHtWithoutPromo,$priceProductAttr->getProductAttribute()->getProduct());
$prixTtcWithoutPromo = $this->cart_service->updatePriceByCountry($prixTtcWithoutPromo,$priceProductAttr->getProductAttribute()->getProduct());
$item['prixTtc'] = $prixTtc;
$item['prixHt'] = $prixHt;
$item['prixTtcWithoutPromo'] = $prixTtcWithoutPromo;
$item['prixHtWithoutPromo'] = $prixHtWithoutPromo;
$item['isPromoDetail'] = $keyArrayPrice['isPromoDetail'];
$prixQtyWithoutPromo = 0;
$prixQtyHtWithoutPromo= 0;
if($quantite){
if($item['qty'] == $quantite){
$qtyExiste = true;
$prixQty = $item['prixTtc'];
$prixQtyHt = $item['prixHt'];
$prixQtyWithoutPromo = $item['prixTtcWithoutPromo'];
$prixQtyHtWithoutPromo = $item['prixHtWithoutPromo'];
}
}
}
return ['qtys'=>$qtys,'qtyExiste'=>$qtyExiste,'prixQty'=>$prixQty,'prixQtyHt'=>$prixQtyHt,'prixQtyWithoutPromo'=>$prixQtyWithoutPromo,'prixQtyHtWithoutPromo'=>$prixQtyHtWithoutPromo];
}
public function getQtyFlyerCarteByProductAttributeByAbonnement($typeAbonnement,$id,$finition,$quantite=false,$isEnveloppe=false,$bordsArrondis=CartDetail::BORDS_ARRONDIS_NOT_CHECKED,$plastification=CartDetail::PLASTIFICATION_NOT_CHECKED){
$qtys = $this->em->getRepository(PriceProduct::class)->getQuantity($id);
$qtyExiste = false;
$prixQty = false;
$prixQtyHt = false;
foreach ($qtys as &$item){
$priceProductAttr = $this->em->getRepository(PriceProduct::class)->find($item['id']);
$keyArrayPrice = $this->getKeyArrayPrice($typeAbonnement,$priceProductAttr); // get key for prix
$pourcentageFinition = 0;
if($finition == CartDetail::FINITION_GLACE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_GLACE;
}else if($finition == CartDetail::FINITION_MATE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_MATE;
}else if($finition == CartDetail::FINITION_REPOSITIONALBLE){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_REPOSITIONALBLE;
}else if($finition == CartDetail::FINITION_TRANSPARENT){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_TRANSPARENT;
}else if($finition == CartDetail::FINITION_SoftTouch){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_SoftTouch;
}else if($finition == CartDetail::FINITION_Pelliculemat){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_Pelliculemat;
}else if($finition == CartDetail::FINITION_PelliculeBrillant){
$pourcentageFinition = CartDetail::POURCENTAGE_FINITION_PelliculeBrillant;
}
$priceFinitonTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* $pourcentageFinition;
$priceFinitonHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* $pourcentageFinition;
$priceFinitonTtcWithoutPromo = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* $pourcentageFinition;
$priceFinitonHtWithoutPromo = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* $pourcentageFinition;
$priceBordsArrondisHt = 0;
$priceBordsArrondisTtc = 0;
$priceBordsArrondisHtWithoutPromo = 0;
$priceBordsArrondisTtcWithoutPromo = 0;
if($bordsArrondis == CartDetail::BORDS_ARRONDIS_CHECKED){
$priceBordsArrondisHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisHtWithoutPromo = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
$priceBordsArrondisTtcWithoutPromo = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* CartDetail::POURCENTAGE_BORDS_ARRONDIS;
}
$pricePlastificationHt = 0;
$pricePlastificationTtc = 0;
$pricePlastificationHtWithoutPromo = 0;
$pricePlastificationTtcWithoutPromo = 0;
if($plastification == CartDetail::BORDS_ARRONDIS_CHECKED){
$pricePlastificationHt = ($item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']]))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationTtc = ($item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']]))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationHtWithoutPromo = ($item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt']))* CartDetail::POURCENTAGE_PLASTIFICATION;
$pricePlastificationTtcWithoutPromo = ($item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixTtc']))* CartDetail::POURCENTAGE_PLASTIFICATION;
}
$prixTtc = $item[$keyArrayPrice['prixTtc']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']])+$priceFinitonTtc+$priceBordsArrondisTtc +$pricePlastificationTtc;
$prixHt = $item[$keyArrayPrice['prixHt']] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixHt']])+$priceFinitonHt+$priceBordsArrondisHt +$pricePlastificationHt;
$prixTtcWithoutPromo = $item['prixTtc'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item[$keyArrayPrice['prixTtc']])+$priceFinitonTtcWithoutPromo +$priceBordsArrondisTtcWithoutPromo +$pricePlastificationTtcWithoutPromo;
$prixHtWithoutPromo = $item['prixHt'] + $this->cart_service->getPricePourcentageAdd($priceProductAttr,$item['prixHt'])+$priceFinitonHtWithoutPromo +$priceBordsArrondisHtWithoutPromo +$pricePlastificationHtWithoutPromo;
if(($priceProductAttr->getProductAttribute()->getProduct() and $priceProductAttr->getProductAttribute()->getProduct()->getTypeProduct() == Product::FAIRE_PART_NAISSANCE) or ($priceProductAttr->getProductAttribute()->getProduct() and $priceProductAttr->getProductAttribute()->getProduct()->getTypeProduct() == Product::FAIRE_PART_MARIAGE)) {
if($isEnveloppe) {
$prixTtc = $prixTtc + (CartDetail::IS_ENVELOPPE_TTC * $priceProductAttr->getQty());
$prixHt = $prixHt + (CartDetail::IS_ENVELOPPE_HT * $priceProductAttr->getQty());
$prixTtcWithoutPromo = $prixTtcWithoutPromo + (CartDetail::IS_ENVELOPPE_TTC * $priceProductAttr->getQty());
$prixHtWithoutPromo = $prixHtWithoutPromo + (CartDetail::IS_ENVELOPPE_HT * $priceProductAttr->getQty());
}
}
//update price by country
$prixHt = $this->cart_service->updatePriceByCountry($prixHt,$priceProductAttr->getProductAttribute()->getProduct());
$prixTtc = $this->cart_service->updatePriceByCountry($prixTtc,$priceProductAttr->getProductAttribute()->getProduct());
$prixHtWithoutPromo = $this->cart_service->updatePriceByCountry($prixHtWithoutPromo,$priceProductAttr->getProductAttribute()->getProduct());
$prixTtcWithoutPromo = $this->cart_service->updatePriceByCountry($prixTtcWithoutPromo,$priceProductAttr->getProductAttribute()->getProduct());
$item['prixTtc'] = $prixTtc;
$item['prixHt'] = $prixHt;
$item['prixTtcWithoutPromo'] = $prixTtcWithoutPromo;
$item['prixHtWithoutPromo'] = $prixHtWithoutPromo;
$item['isPromoDetail'] = $keyArrayPrice['isPromoDetail'];
$prixQtyWithoutPromo = 0;
$prixQtyHtWithoutPromo= 0;
if($quantite){
if($item['qty'] == $quantite){
$qtyExiste = true;
$prixQty = $item['prixTtc'];
$prixQtyHt = $item['prixHt'];
$prixQtyWithoutPromo = $item['prixTtcWithoutPromo'];
$prixQtyHtWithoutPromo = $item['prixHtWithoutPromo'];
}
}
}
return ['qtys'=>$qtys,'qtyExiste'=>$qtyExiste,'prixQty'=>$prixQty,'prixQtyHt'=>$prixQtyHt,'prixQtyWithoutPromo'=>$prixQtyWithoutPromo,'prixQtyHtWithoutPromo'=>$prixQtyHtWithoutPromo];
}
public function getKeyArrayPrice($type = null,$priceAttributeProduct = false) {
if(is_object($priceAttributeProduct)){
if($priceAttributeProduct->getIsPromo()){
if($type == AbonnementPro::TYPE_PRO){
if($priceAttributeProduct->getPrixPromoTtcAbonnementPro() && $priceAttributeProduct->getPrixPromoTtcAbonnementPro() > 0 ){
$stringTtc = 'prixPromoTtcAbonnementPro';
$stringHt = 'prixPromoHtAbonnementPro';
$isPromoDetail = true;
}else{
$stringTtc = 'prixTtcAbonnementPro';
$stringHt = 'prixHtAbonnementPro';
$isPromoDetail = false;
}
}else if($type == AbonnementPro::TYPE_TEAM){
if($priceAttributeProduct->getPrixPromoTtcAbonnementTeam() && $priceAttributeProduct->getPrixPromoTtcAbonnementTeam() > 0 ){
$stringTtc = 'prixPromoTtcAbonnementTeam';
$stringHt = 'prixPromoHtAbonnementTeam';
$isPromoDetail = true;
}else{
$stringTtc = 'prixTtcAbonnementTeam';
$stringHt = 'prixHtAbonnementTeam';
$isPromoDetail = false;
}
}else if($type == AbonnementPro::TYPE_ENTREPRISE){
if($priceAttributeProduct->getPrixPromoTtcAbonnementEntreprise() && $priceAttributeProduct->getPrixPromoTtcAbonnementEntreprise() > 0 ){
$stringTtc = 'prixPromoTtcAbonnementEntreprise';
$stringHt = 'prixPromoHtAbonnementEntreprise';
$isPromoDetail = true;
}else{
$stringTtc = 'prixTtcAbonnementEntreprise';
$stringHt = 'prixHtAbonnementEntreprise';
$isPromoDetail = false;
}
}else{
if($priceAttributeProduct->getPrixPromoTtc() && $priceAttributeProduct->getPrixPromoTtc() > 0 ) {
$stringTtc = 'prixPromoTtc';
$stringHt = 'prixPromoHt';
$isPromoDetail = true;
}else{
$stringTtc = 'prixTtc';
$stringHt = 'prixHt';
$isPromoDetail = false;
}
}
return array(
'prixTtc'=> $stringTtc,
'prixHt'=> $stringHt,
'isPromoDetail'=> $isPromoDetail
);
}
}
if($type == AbonnementPro::TYPE_PRO){
$stringTtc = 'prixTtcAbonnementPro';
$stringHt = 'prixHtAbonnementPro';
}else if($type == AbonnementPro::TYPE_TEAM){
$stringTtc = 'prixTtcAbonnementTeam';
$stringHt = 'prixHtAbonnementTeam';
}else if($type == AbonnementPro::TYPE_ENTREPRISE){
$stringTtc = 'prixTtcAbonnementEntreprise';
$stringHt = 'prixHtAbonnementEntreprise';
}else{
$stringTtc = 'prixTtc';
$stringHt = 'prixHt';
}
return array(
'prixTtc'=> $stringTtc,
'prixHt'=> $stringHt,
'isPromoDetail'=> false
);
}
public function saveTemplateAbonnement($request,$user)
{
$isAbonnementPro = false;
if(is_object($user)){
$abonnement = $this->cart_service->checkIsAbonnementPro($user);
// check abonnement in cart
$cart = $this->cart_service->getCartWithSession();
$isAbonnementProInCart = false;
if($cart){
$isAbonnementProInCart = $this->cart_service->checkIsAbonnementProCart($cart->getId());
}
if($abonnement['is_abonnemen_pro'] || $isAbonnementProInCart) { // check is admin in compte abonnement
$isAbonnementPro = true;
}
}
if($isAbonnementPro){
$userTemplate = $this->em->getRepository(NbUserTemplates::class)->findOneBy(array('token'=>$request->get('user_template')));
if($request->get('isCrea') && $request->get('isCrea') == 1){
if($request->get('frame_0')) {
$frame_0 = $request->get('frame_0');
$frame_0_new = 'ma_crea_recto_'. $userTemplate->getToken() .'.png';
$dossier_frame_0 = str_replace ('/uploads',$this->params->get('uploads_directory'),$frame_0);
$dossier_frame_0_new = $this->params->get('uploads_directory'). '/img_template_save/' . $frame_0_new;
if(file_exists($dossier_frame_0_new) )unlink($dossier_frame_0_new);
if(trim($dossier_frame_0) == trim($dossier_frame_0_new)){
$frame_0_new = 'ma_crea_recto_'. $userTemplate->getToken() .'_1.png';
$dossier_frame_0_new = $this->params->get('uploads_directory'). '/img_template_save/' . $frame_0_new;
}
copy($dossier_frame_0 , $dossier_frame_0_new);
$userTemplate->setRecto($frame_0_new);
if ($request->get('rectoverso')) {
$frame_1 = $request->get('frame_1');
$frame_1_new = 'ma_crea_verso_'.$userTemplate->getToken() .'.png';
$dossier_frame_1 = str_replace ('/uploads',$this->params->get('uploads_directory'),$frame_1);
$dossier_frame_1_new = $this->params->get('uploads_directory'). '/img_template_save/' . $frame_1_new;
if(file_exists($dossier_frame_1_new) )unlink($dossier_frame_1_new);
if(trim($dossier_frame_1) == trim($dossier_frame_1_new)){
$frame_1_new = 'ma_crea_verso_'. $userTemplate->getToken() .'_1.png';
$dossier_frame_1_new = $this->params->get('uploads_directory'). '/img_template_save/' . $frame_1_new;
}
copy($dossier_frame_1 , $dossier_frame_1_new);
$userTemplate->setVerso($frame_1_new);
}else{
$userTemplate->setVerso(null);
}
$userTemplate->setIsCrea(true);
if($request->get('plus_expert') == 1)$userTemplate->setIsPlusExpert(true);
else $userTemplate->setIsPlusExpert(false);
$userTemplate->setRectoverso($request->get('rectoverso') == 1 ? 2 : 1);
$userTemplate->setUserAbonnement($user);
$this->em->flush();
return [
'myTemplates' => $this->cart_service->getListeTemplateSaved($this->security->getUser()),
'myDesign' => $this->em->getRepository(NbUserTemplates::class)->getTemplateNotEmpty($this->security->getUser())
];
}else{
return 0;
}
}else{
$ext = '.png';
$frame_0 = uniqid().$ext;
$base64 = str_replace('data:image/png;base64,', '', $request->get('frame_0'));
$file = fopen($this->params->get('uploads_directory').'/img_template_save/'.$frame_0, 'wb');
fwrite($file, base64_decode($base64));
fclose($file);
$userTemplate->setRecto($frame_0);
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$frames[] = $baseurl . "/uploads/tmp/" . $frame_0;
if($request->get('rectoverso')) {
$frame_1 = uniqid().$ext;
$base64 = str_replace('data:image/png;base64,', '', $request->get('frame_1'));
$file = fopen($this->params->get('uploads_directory').'/img_template_save/'.$frame_1, 'wb');
fwrite($file, base64_decode($base64));
fclose($file);
$userTemplate->setVerso($frame_1);
$frames[] = $baseurl . "/uploads/tmp/" . $frame_1;
}
$userTemplate->setRectoverso($request->get('rectoverso') == 1 ? 2 : 1);
$userTemplate->setUserAbonnement($user);
$this->em->flush();
return [
'myTemplates' => $this->cart_service->getListeTemplateSaved($this->security->getUser()),
'myDesign' => $this->em->getRepository(NbUserTemplates::class)->getTemplateNotEmpty($this->security->getUser())
];
}
}else{
return 0;
}
}
public function saveDesignImg($request,$user,$cart)
{
$this->updateUserTemplateGetPrice($request,$cart,$user);
$isAbonnementPro = false;
if (is_object($user)) {
$abonnement = $this->cart_service->checkIsAbonnementPro($user);
// check abonnement in cart
$cart = $this->cart_service->getCartWithSession();
$isAbonnementProInCart = false;
if ($cart) {
$isAbonnementProInCart = $this->cart_service->checkIsAbonnementProCart($cart->getId());
}
if ($abonnement['is_abonnemen_pro'] || $isAbonnementProInCart) { // check is admin in compte abonnement
$isAbonnementPro = true;
}
if (!$isAbonnementPro) {
$userTemplate = $this->em->getRepository(NbUserTemplates::class)->findOneBy(array('token' => $request->get('user_template')));
if ($request->get('isCrea') && $request->get('isCrea') == 1) {
$frame_0 = $request->get('frame_0');
$frame_0_new = 'ma_crea_recto_'. $userTemplate->getToken() .'.png';
$dossier_frame_0 = str_replace ('/uploads',$this->params->get('uploads_directory'),$frame_0);
$dossier_frame_0_new = $this->params->get('uploads_directory'). '/img_template_save/' . $frame_0_new;
if(file_exists($dossier_frame_0_new) )unlink($dossier_frame_0_new);
if(trim($dossier_frame_0) == trim($dossier_frame_0_new)){
$frame_0_new = 'ma_crea_recto_'. $userTemplate->getToken() .'_1.png';
$dossier_frame_0_new = $this->params->get('uploads_directory'). '/img_template_save/' . $frame_0_new;
}
copy($dossier_frame_0 , $dossier_frame_0_new);
$userTemplate->setRecto($frame_0_new);
if ($request->get('rectoverso')) {
$frame_1 = $request->get('frame_1');
$frame_1_new = 'ma_crea_verso_'.$userTemplate->getToken() .'.png';
$dossier_frame_1 = str_replace ('/uploads',$this->params->get('uploads_directory'),$frame_1);
$dossier_frame_1_new = $this->params->get('uploads_directory'). '/img_template_save/' . $frame_1_new;
if(file_exists($dossier_frame_1_new) )unlink($dossier_frame_1_new);
if(trim($dossier_frame_1) == trim($dossier_frame_1_new)){
$frame_1_new = 'ma_crea_verso_'. $userTemplate->getToken() .'_1.png';
$dossier_frame_1_new = $this->params->get('uploads_directory'). '/img_template_save/' . $frame_1_new;
}
copy($dossier_frame_1 , $dossier_frame_1_new);
$userTemplate->setVerso($frame_1_new);
}else{
$userTemplate->setVerso(null);
}
$userTemplate->setIsCrea(true);
if($request->get('plus_expert') == 1)$userTemplate->setIsPlusExpert(true);
else $userTemplate->setIsPlusExpert(false);
$userTemplate->setRectoverso($request->get('rectoverso') == 1 ? 2 : 1);
$userTemplate->setIsSave(true);
$this->em->flush();
} else {
$ext = '.png';
$frame_0 = uniqid() . $ext;
$base64 = str_replace('data:image/png;base64,', '', $request->get('frame_0'));
$file = fopen($this->params->get('uploads_directory') . '/img_template_save/' . $frame_0, 'wb');
fwrite($file, base64_decode($base64));
fclose($file);
$userTemplate->setRecto($frame_0);
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$frames[] = $baseurl . "/uploads/tmp/" . $frame_0;
if ($request->get('rectoverso')) {
$frame_1 = uniqid() . $ext;
$base64 = str_replace('data:image/png;base64,', '', $request->get('frame_1'));
$file = fopen($this->params->get('uploads_directory') . '/img_template_save/' . $frame_1, 'wb');
fwrite($file, base64_decode($base64));
fclose($file);
$userTemplate->setVerso($frame_1);
$frames[] = $baseurl . "/uploads/tmp/" . $frame_1;
}
$userTemplate->setRectoverso($request->get('rectoverso') == 1 ? 2 : 1);
$userTemplate->setIsSave(true);
$this->em->flush();
}
return [
'myTemplates' => $this->cart_service->getListeTemplateSaved($this->security->getUser()),
'myDesign' => $this->em->getRepository(NbUserTemplates::class)->getTemplateNotEmpty($this->security->getUser())
];
}
}
return 0;
}
public function importDossierDesign(){
$templates = $this->em->getRepository(NbTemplates::class)->findAll();
foreach ($templates as $template){
$this->ftpGetDir('87.98.139.241', 'nbd', '9H1_lne0', '/httpdocs/wp-content/uploads/nbdesigner/designs/' . $template->getName(), $this->params->get('uploads_directory') . '/designs/' . $template->getType() . '/' . $template->getName());
}
}
public function searchProductOption($request,$search,$user){
$products = $this->em->getRepository(ProductAttribute::class)->getProductsBySearch($search);
$tabs = [];
foreach ($products as $product){
if($product->getProduct()->getTypeProduct() == Product::STICKERS_AUTOCOLLANT){
if($product->getGramage()){
$tabs[$product->getFormat()->getId()][0] = $product;
$priceProduct = $this->em->getRepository(PriceProduct::class)->getOneProductPriceByProductAttribute($product->getId());
$tabs[$product->getFormat()->getId()]['priceProduct'] = $priceProduct;
}
}else {
if ($product->getFormat()) {
$tabs[$product->getFormat()->getId()][0] = $product;
$priceProduct = $this->em->getRepository(PriceProduct::class)->getOneProductPriceByProductAttribute($product->getId());
$tabs[$product->getFormat()->getId()]['priceProduct'] = $priceProduct;
} else if ($product->getTypeFormat()) {
$tabs[$product->getTypeFormat()->getId()][0] = $product;
$priceProduct = $this->em->getRepository(PriceProduct::class)->getOneProductPriceByProductAttribute($product->getId());
$tabs[$product->getTypeFormat()->getId()]['priceProduct'] = $priceProduct;
}
}
}
$array = [];
// check abonnementPro
$cart = $this->cart_service->createCart(true);
$abonnement = $this->cart_service->checkAbonnementToCartOrOrder($user,$cart->getId());
$typeAbonnement = null;
if($abonnement){
$typeAbonnement = $abonnement['type'];
}
$attributeEntityPriceProduct = $this->cart_service->getAttributeEntityPrice($typeAbonnement);
// check abonnement starter
$is_abonnementStarter = false;
if($user) {
$abonnementStarter = $this->em->getRepository(Abonnement::class)->findOneBy(array());
$is_abonnementStarter = $this->abonnementService->checkAbonnementByUser($abonnementStarter->getPlanId());
}
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
foreach ($tabs as $key => $item){
$productPrice = $item['priceProduct'];
if($productPrice->getProductAttribute()->getProduct()->getTypeProduct() == Product::STICKERS_AUTOCOLLANT){
$array[$key]['titreModif'] = (string)$productPrice->getProductAttribute()->getGramage()->getTextSearch();
$array[$key]['titre1Modif'] = (string)$productPrice->getProductAttribute()->getGramage()->getTitreSearch();
$array[$key]['titreFormat'] = $productPrice->getProductAttribute()->getGramage()->getName();
$array[$key]['img'] = $baseurl . "/imageSite/" . $productPrice->getProductAttribute()->getGramage()->getFileSearch();
$array[$key]['idTypeFormat'] = $productPrice->getProductAttribute()->getGramage()->getId();
}else {
if ($productPrice->getProductAttribute()->getFormat()) {
$array[$key]['titreModif'] = (string)$productPrice->getProductAttribute()->getFormat()->getTextSearch();
$array[$key]['titre1Modif'] = (string)$productPrice->getProductAttribute()->getFormat()->getTitreSearch();
$array[$key]['titreFormat'] = $productPrice->getProductAttribute()->getFormat()->getName();
$array[$key]['img'] = $baseurl . "/imageSite/" . $productPrice->getProductAttribute()->getFormat()->getFileSearch();
$array[$key]['idFormat'] = $productPrice->getProductAttribute()->getFormat()->getId();
if(in_array($productPrice->getProductAttribute()->getProduct()->getTypeProduct(),[Product::KAKEMONO,Product::PHOTOS,Product::PHOTOS_ENCADRE])){
$array[$key]['notFormat'] = true;
}
} else if ($productPrice->getProductAttribute()->getTypeFormat()) {
$array[$key]['titreModif'] = (string)$productPrice->getProductAttribute()->getTypeFormat()->getTextSearch();
$array[$key]['titre1Modif'] = (string)$productPrice->getProductAttribute()->getTypeFormat()->getTitreSearch();
$array[$key]['titreFormat'] = $productPrice->getProductAttribute()->getTypeFormat()->getName();
$array[$key]['img'] = $baseurl . "/imageSite/" . $productPrice->getProductAttribute()->getTypeFormat()->getFileSearch();
$array[$key]['idTypeFormat'] = $productPrice->getProductAttribute()->getTypeFormat()->getId();
}
}
$array[$key]['titre'] = $item[0]->getProduct()->getTitre();
if($item[0]->getProduct()->getIsRectoVerso() or $item[0]->getProduct()->getIsRecto()) {
if ($item[0]->getProduct()->getIsRectoVerso()) {
$array[$key]['recto'] = $productPrice->getProductAttribute()->getRectoverso() == 1 ? ' - recto' : ' - recto/verso';
} else {
$array[$key]['recto'] = '';
}
}else{
$array[$key]['recto'] = $productPrice->getProductAttribute()->getRectoverso() == 1 ? ' - recto' : ' - recto/verso';
}
if($item[0]->getProduct()->getTypeProduct() == Product::AFFICHE){
$array[$key]['recto'] = '';
}
$array[$key]['qty'] = $productPrice->getQty() .' '.$item[0]->getProduct()->getTitre();
if($is_abonnementStarter) {
$reduction = $abonnementStarter->getReduction();
if ($reduction > 0) {
$array[$key]['priceHt'] = $productPrice->getPrixHt() - (($productPrice->getPrixHt() * $reduction) / 100);
$array[$key]['priceTtc'] = $productPrice->getPrixTtc() - (($productPrice->getPrixTtc() * $reduction) / 100);
}else{
$array[$key]['priceHt'] = $productPrice->getPrixHt();
$array[$key]['priceTtc'] = $productPrice->getPrixTtc();
}
}else{
$array[$key]['priceHt'] = $productPrice->{$attributeEntityPriceProduct['prixHt']}();
$array[$key]['priceTtc'] = $productPrice->{$attributeEntityPriceProduct['prixTtc']}();
}
$array[$key]['idProduct'] = $item[0]->getProduct()->getId();
$array[$key]['typeProduct'] = $item[0]->getProduct()->getTypeProduct();
$array[$key]['baseUrl'] = $baseurl;
}
return $array;
}
public function uploadPhotos($image,$request)
{
$ext = $image->guessExtension();
$tokenName = $this->generateToken(32);
$fileName = $tokenName . '.' . $ext;
$image->move($this->params->get('uploads_directory'). '/tmp', $fileName);
$photo = new CartDetailPhotos();
$photo->setFile($fileName);
$result = $this->generateThumbnail($tokenName,$this->params->get('uploads_directory'). '/tmp/'. $fileName, 100, 50, 200);
$photo->setFileThumb($result);
$this->em->persist($photo);
$this->em->flush();
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
return [
'token' => $photo->getToken(),
'thumb' => $result ? $baseurl.'/uploads/tmp/'.$result:null,
'image' => $baseurl.'/uploads/tmp/'.$fileName
];
}
function generateThumbnail($tokenName,$img, $width, $height, $quality = 90)
{
if (is_file($img)) {
$imagick = new \Imagick(realpath($img));
$imagick->setImageFormat('jpeg');
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
$imagick->setImageCompressionQuality($quality);
// $imagick->thumbnailImage($width, $height, false, false);
$filename = $tokenName . '_thumb' . '.jpg';
if (file_put_contents($this->params->get('uploads_directory'). '/tmp/'.$filename, $imagick) === false) {
return false;
}
return $filename;
}
else {
return false;
}
}
}