src/Controller/EspaceParentController.php line 5805

Open in your IDE?
  1. <?php
  2. /*
  3.  * To change this license header, choose License Headers in Project Properties.
  4.  * To change this template file, choose Tools | Templates
  5.  * and open the template in the editor.
  6.  */
  7. namespace App\Controller;
  8. use Symfony\Component\Mailer\MailerInterface;
  9. use Swift_Message;
  10. use Symfony\Component\Mime\Email;
  11. use Unirest;
  12. use Swift_Image;
  13. use Dompdf\Dompdf;
  14. use App\Entity\Ref;
  15. use Dompdf\Options;
  16. use App\Entity\Page;
  17. use App\Entity\User;
  18. use Twig\Environment;
  19. use App\Entity\Panier;
  20. use App\Entity\Sejour;
  21. use App\Entity\Clipart;
  22. use App\Entity\Produit;
  23. use App\Entity\CommandeNumerique;
  24. use App\Entity\Typeref;
  25. use App\Entity\Commande;
  26. use App\Entity\Emailing;
  27. use App\Entity\Typeproduit;
  28. use App\Entity\ParentSejour;
  29. use App\Entity\PanierProduit;
  30. use App\Service\JetonService;
  31. use App\Entity\ComandeProduit;
  32. use App\Entity\SejourAttachment;
  33. use App\Service\PrinterService;
  34. use App\Entity\Likephoto;
  35. use App\Entity\Attachment;
  36. use App\Service\EmailsCmdService;
  37. use App\Entity\TypeProduitConditionnement;
  38. use App\Service\AttachementService;
  39. use App\Service\CarteService;
  40. use App\Service\ComandeService;
  41. use App\Service\EtablissementService;
  42. use App\Service\PayementService;
  43. use App\Service\PhotosFavorisService;
  44. use App\Service\SejourService;
  45. use App\Service\TypeProduiteService;
  46. use App\Service\UserService;
  47. use Doctrine\Persistence\ManagerRegistry;
  48. use Psr\Log\LoggerInterface;
  49. use Qipsius\TCPDFBundle\Controller\TCPDFController;
  50. use SebastianBergmann\Environment\Console;
  51. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  52. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  53. use Symfony\Component\HttpFoundation\Request;
  54. use Symfony\Component\HttpFoundation\Response;
  55. use Symfony\Component\Routing\Annotation\Route;
  56. use Symfony\Component\HttpFoundation\JsonResponse;
  57. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  58. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  59. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  60. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  61. use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
  62. use setasign\Fpdi\Fpdi;
  63. use setasign\Fpdi\PdfReader;
  64. class EspaceParentController extends AbstractController
  65. {
  66.     private $em;
  67.     private $session;
  68.     private $templating;
  69.     private $mailer;
  70.     private $symfonyMailer;
  71.     private $EmailServie;
  72.     private $urlGenerator;
  73.     private $commandeService;
  74.     private $printerService;
  75.     private $emailsCmdService;
  76.     private $userService;
  77.     private $typeProduiteService;
  78.     private $sejourService;
  79.     private $attachementService;
  80.     private $etablissementService;
  81.     private $payementService;
  82.     private $carteService;
  83.     private $photosFavorisService;
  84.     private $params;
  85.     private $tcpdf;
  86.     private $logger;
  87.     public function __construct(UrlGeneratorInterface $urlGeneratorManagerRegistry $emSessionInterface $session\Swift_Mailer $mailerMailerInterface $symfonyMailerEnvironment $templatingEmailsCmdService $EmailCommandeServiceComandeService $commandeServiceUserService $userServiceTypeProduiteService $typeProduiteServiceSejourService $sejourServiceAttachementService $attachementServiceEtablissementService $etablissementServicePayementService $payementServiceCarteService $carteServicePhotosFavorisService $photosFavorisServiceParameterBagInterface $paramsTCPDFController $tcpdfLoggerInterface $loggerPrinterService $printerServiceEmailsCmdService $emailsCmdService)
  88.     {
  89.         $this->em $em;
  90.         $this->session $session;
  91.         $this->templating $templating;
  92.         $this->mailer $mailer;
  93.         $this->symfonyMailer $symfonyMailer;
  94.         $this->EmailServie $EmailCommandeService;
  95.         $this->urlGenerator $urlGenerator;
  96.         $this->commandeService $commandeService;
  97.         $this->emailsCmdService $emailsCmdService;
  98.         $this->userService $userService;
  99.         $this->typeProduiteService $typeProduiteService;
  100.         $this->sejourService $sejourService;
  101.         $this->attachementService $attachementService;
  102.         $this->etablissementService $etablissementService;
  103.         $this->payementService $payementService;
  104.         $this->carteService $carteService;
  105.         $this->photosFavorisService $photosFavorisService;
  106.         $this->params $params;
  107.         $this->tcpdf $tcpdf;
  108.         $this->logger $logger;
  109.         $this->printerService $printerService;
  110.     }
  111.     /**
  112.      * @Route("/Parent/CreerAlbumSejourTest", name="CreerAlbumSejourTest")
  113.      */
  114.     public function CreerAlbumSejourTest(Request $request)
  115.     {
  116.         $serviceuser $this->etablissementService;
  117.         $page $request->get("pages");
  118.         $idsejour $request->get("id_du_sejour");
  119.         $prodid $request->get('idProd');
  120.         $nomprod $request->get('nomprod');
  121.         $stat $request->get('stat');
  122.         $version $request->get('new');
  123.         $user $this->getUser();
  124.         $Album $serviceuser->savealbumAcc($page$user$idsejour$prodid$stat$nomprod$version);
  125.         //Envoi des mails aux parents 
  126.         // Envoi SMS aux parents 
  127.         // Envoi mail proposition achat groupĂ© au accompagnateur 
  128.         //YOSRA HERE
  129.         $PrentsConnextees $this->em->getRepository(ParentSejour::class)->findBy(array('idSejour' =>  $idsejour));
  130.         dd($PrentsConnextees);
  131.         return new response('done');
  132.     }
  133.     /**
  134.      * @Route("/Parent/DirectAchatAlbumm", name="DirectAchatAlbumm")
  135.      */
  136.     public function DirectAchatAlbumm(Request $request)
  137.     {
  138.         $session $this->session;
  139.         $serviceuser $this->etablissementService;
  140.         $page $request->get("pages");
  141.         $sejour $request->get("sejour");
  142.         $prodid $request->get('idProd');
  143.         $nomprod $request->get('nomprod');
  144.         $versionalbm $request->get('new');
  145.         $user $this->getUser();
  146.         $dateNow = new \Datetime();
  147.         $produit $session->get("produittype");
  148.         $produitcondi $session->get("produit");
  149.         $Album $serviceuser->savealbumParent($page$user$sejour$prodid$produit$produitcondi$nomprod$versionalbm);
  150.         $inser false;
  151.         $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  152.         $em $this->em;
  153.         $user $this->getUser();
  154.         $typeref $em->getRepository(Typeref::class)->find(8);
  155.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "achatdirect""typeref" => $typeref));
  156.         $panierTrace = new Panier();
  157.         $dateNow = new \Datetime();
  158.         $panierTrace->setDateCreation($dateNow);
  159.         $panierTrace->setCreerPar($user);
  160.         $panierTrace->setStatut($statutPanier);
  161.         $em->getManager()->persist($panierTrace);
  162.         $em->getManager()->flush();
  163.         $panierProduit = new PanierProduit();
  164.         $panierProduit->setIdProduit($Album);
  165.         $panierProduit->setIdPanier($panierTrace);
  166.         $em->getManager()->persist($panierProduit);
  167.         $em->getManager()->flush();
  168.         $panierProduit->setQuantite(1);
  169.         $panierProduit->setPrixTotal($Album->getIdConditionnement()->getMontantTTC());
  170.         $this->em->getManager()->persist($panierProduit);
  171.         $this->em->getManager()->flush();
  172.         return new response('achat direct done');
  173.     }
  174.     /**
  175.      * @Route("/Parent/Achat_direct", name="Achat_direct")
  176.      */
  177.     public function Achat_direct()
  178.     {
  179.         $em $this->em;
  180.         $session $this->session;
  181.         $idSejour $session->get("Sejour");
  182.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  183.         $typeref $em->getRepository(Typeref::class)->find(8);
  184.         $user $this->getUser();
  185.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "achatdirect""typeref" => $typeref));
  186.         $panier $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  187.         return $this->render('Parent/achatdirect.html.twig', ["user" => $user"sejour" => $sejour"panier" => $panier]);
  188.     }
  189.     /**
  190.      * @Route("/Parent/AccueilParent", name="AccueilParent")
  191.      */
  192.     public function AccueilParent(Request $requestLoggerInterface $loggerInterface): Response
  193.     {
  194.         $session $this->session;
  195.         /** @var \App\Entity\User $user */
  196.         $user $this->getUser();
  197.         $userId $user->getId();
  198.         $code $request->get("codeSejour");
  199.         $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  200.         if (isset($code)) {
  201.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  202.             if ($sejour == null) {
  203.                 $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  204.                 if ($sejour == null) {
  205.                     $this->session->set('rout''code');
  206.                     return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  207.                 }
  208.             } else {
  209.                 $this->session->set('Sejour'$sejour->getId());
  210.             }
  211.         }
  212.         if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
  213.             $code $session->get("Sejour");
  214.             $sejour $this->em->getRepository(Sejour::class)->find($code);
  215.         } else {
  216.             $code $request->get("codeSejour");
  217.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  218.         }
  219.         if ($sejour == null) {
  220.             $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  221.         }
  222.         if ($sejour == null) {
  223.             $this->session->set('rout''code');
  224.             return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  225.         }
  226.         $idSejour $sejour->getId();
  227.         $SEjourService $this->sejourService;
  228.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  229.         $this->session->set('Sejour'$idSejour);
  230.         $dateCreationArch = clone $sejour->getDateFinCode();
  231.         if ($dateCreationArch <= new \DateTime()) {
  232.             return $this->render('Parent/SejourDepassee.html.twig');
  233.         }
  234.         $session->set('pageMenu''MonSejour');
  235.         $AllAttachements $SEjourService->getphotosVideosSejour($idSejour'watermark'$userId);
  236.         $nbImages count($AllAttachements);
  237.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  238.         $positions $SEjourService->getsejourposition($idSejour);
  239.         $em $this->em;
  240.         $idAcc $sejour->getIdAcommp();
  241.         //VERIFICATION DE L EXISTANCE DE LIVRE OU D ALBUM SEJOUR 
  242.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  243.         if ($albumAcc == null) {
  244.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  245.         }
  246.         $label "Livre_sejour" $sejour->getCodeSejour();
  247.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  248.         $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  249.         if ($albumAcc == null) {
  250.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  251.         }
  252.         if ($livreSej == null) {
  253.             $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  254.         }
  255.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  256.         if ($parentsejour == NULL) {
  257.             $parentsejour $SEjourService->inserparentsejour($userId$idSejour);
  258.         }
  259.         if ($AllAttachements == null && $messages == null) {
  260.             $this->session->set('rout''rout');
  261.             return $this->render('Parent/Aucunphoto.html.twig', [
  262.                 "sejour" => $sejour,
  263.                 "parentsejour" => $parentsejour
  264.             ]);
  265.         } else {
  266.             $attachementsCount $AllAttachements['total'];
  267.             unset($AllAttachements['total']);
  268.             if ($sejour->getPaym() == 0) {
  269.                 $produits $this->typeProduiteService;
  270.                 $liste $produits->produitlistTypeConditionnement();
  271.                 $pubProd $user->getShowpubprod();
  272.                 $em $this->em;
  273.                 $idAcc $sejour->getIdAcommp();
  274.                 $nbmessages count($messages);
  275.                 $nblikes =  count($listeattachlikephoto);
  276.                 return $this->render('Parent/DetailsSejour.html.twig', [
  277.                     "sejour" => $sejour,
  278.                     'albumAcc' => $albumAcc,
  279.                     'favoritesCount' => $nblikes,
  280.                     "livreSejour" => $livreSejour,
  281.                     'listeattach' => $AllAttachements,
  282.                     'nbmessages' => $nbmessages,
  283.                     'attachementsCount' => $attachementsCount,
  284.                     'prod' => $liste,
  285.                     'nbImages' => $nbImages,
  286.                     'positions' => $positions,
  287.                     'messages' => $messages,
  288.                     'nblikes' => $nblikes,
  289.                     'likes' => $listeattachlikephoto,
  290.                     "parentsejour" => $parentsejour,
  291.                     'smsnotif' => $parentsejour->getSmsnotif(),
  292.                     'showpub' => $pubProd
  293.                 ]);
  294.             }
  295.             if ($sejour->getPaym() == 1) {
  296.                 if ($parentsejour->getPayment() == 0) {
  297.                     $this->session->set('rout''rout');
  298.                     $ses_id session_id();
  299.                     return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  300.                 }
  301.                 if ($parentsejour->getPayment() == 1) {
  302.                     $produits $this->typeProduiteService;
  303.                     $liste $produits->produitlistTypeConditionnement();
  304.                     $pubProd $user->getShowpubprod();
  305.                     return $this->render('Parent/DetailsSejour.html.twig', [
  306.                         "sejour" => $sejour,
  307.                         'favoritesCount' => count($listeattachlikephoto),
  308.                         'listeattach' => $AllAttachements,
  309.                         'attachementsCount' => $attachementsCount,
  310.                         'prod' => $liste,
  311.                         'albumAcc' => $albumAcc,
  312.                         "livreSejour" => $livreSejour,
  313.                         'nbImages' => $nbImages,
  314.                         'positions' => $positions,
  315.                         'messages' => $messages,
  316.                         'like' => $listeattachlikephoto,
  317.                         "parentsejour" => $parentsejour,
  318.                         'smsnotif' => $parentsejour->getSmsnotif(),
  319.                         'showpub' => $pubProd
  320.                     ]);
  321.                 }
  322.             }
  323.         }
  324.     }
  325.     /**
  326.      * @Route("/Parent/MessagesVocaux", name="MessagesVocaux")
  327.      */
  328.     public function MessagesVocaux_Accueil(Request $requestLoggerInterface $loggerInterface): Response
  329.     {
  330.         $session $this->session;
  331.         $session->set('pageMenu''MessagesVocaux');
  332.         /** @var \App\Entity\User $user */
  333.         $user $this->getUser();
  334.         $userId $user->getId();
  335.         $code $request->get("codeSejour");
  336.         $SEjourService $this->sejourService;
  337.         if (isset($code)) {
  338.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  339.             if ($sejour == null) {
  340.                 $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  341.                 if ($sejour == null) {
  342.                     $this->session->set('rout''code');
  343.                     return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  344.                 }
  345.             } else {
  346.                 $this->session->set('Sejour'$sejour->getId());
  347.             }
  348.         }
  349.         if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
  350.             $code $session->get("Sejour");
  351.             $sejour $this->em->getRepository(Sejour::class)->find($code);
  352.         } else {
  353.             $code $request->get("codeSejour");
  354.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  355.         }
  356.         if ($sejour == null) {
  357.             $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  358.         }
  359.         if ($sejour == null) {
  360.             $this->session->set('rout''code');
  361.             return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  362.         }
  363.         $idSejour $sejour->getId();
  364.         $this->session->set('Sejour'$idSejour);
  365.         $dateCreationArch = clone $sejour->getDateFinCode();
  366.         if ($dateCreationArch <= new \DateTime()) {
  367.             return $this->render('Parent/SejourDepassee.html.twig');
  368.         }
  369.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  370.         $nbImages count($AllAttachements);
  371.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  372.         $positions $SEjourService->getsejourposition($idSejour);
  373.         $em $this->em;
  374.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => "1"'statut' => 'saved'], ['id' => 'DESC']);
  375.         if ($albumAcc == null) {
  376.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  377.         }
  378.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  379.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  380.         if ($parentsejour == NULL) {
  381.             $parentsejour $SEjourService->inserparentsejour($userId$idSejour);
  382.         }
  383.         if ($AllAttachements == null && $messages == null) {
  384.             $this->session->set('rout''rout');
  385.             return $this->render('Parent/Aucunphoto.html.twig', [
  386.                 "sejour" => $sejour,
  387.                 "parentsejour" => $parentsejour
  388.             ]);
  389.         } else {
  390.             $attachementsCount $AllAttachements['total'];
  391.             unset($AllAttachements['total']);
  392.             if ($sejour->getPaym() == 0) {
  393.                 $produits $this->typeProduiteService;
  394.                 $liste $produits->produitlistTypeConditionnement();
  395.                 $pubProd $user->getShowpubprod();
  396.                 return $this->render('Parent/DetailsSejour.html.twig', [
  397.                     "sejour" => $sejour,
  398.                     'albumAcc' =>  $albumAcc,
  399.                     'listeattach' => $AllAttachements,
  400.                     'attachementsCount' => $attachementsCount,
  401.                     'prod' => $liste,
  402.                     'nbImages' => $nbImages,
  403.                     'positions' => $positions,
  404.                     'messages' => $messages,
  405.                     'like' => $listeattachlikephoto,
  406.                     "parentsejour" => $parentsejour,
  407.                     'smsnotif' => $parentsejour->getSmsnotif(),
  408.                     'showpub' => $pubProd
  409.                 ]);
  410.             }
  411.             if ($sejour->getPaym() == 1) {
  412.                 if ($parentsejour->getPayment() == 0) {
  413.                     $this->session->set('rout''rout');
  414.                     $ses_id session_id();
  415.                     return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  416.                 }
  417.                 if ($parentsejour->getPayment() == 1) {
  418.                     $produits $this->typeProduiteService;
  419.                     $liste $produits->produitlistTypeConditionnement();
  420.                     $pubProd $user->getShowpubprod();
  421.                     return $this->render('Parent/DetailsSejour.html.twig', [
  422.                         "sejour" => $sejour,
  423.                         'favoritesCount' => count($listeattachlikephoto),
  424.                         'listeattach' => $AllAttachements,
  425.                         'attachementsCount' => $attachementsCount,
  426.                         'prod' => $liste,
  427.                         'nbImages' => $nbImages,
  428.                         'albumAcc' =>  $albumAcc,
  429.                         'positions' => $positions,
  430.                         'messages' => $messages,
  431.                         'like' => $listeattachlikephoto,
  432.                         "parentsejour" => $parentsejour,
  433.                         'smsnotif' => $parentsejour->getSmsnotif(),
  434.                         'showpub' => $pubProd
  435.                     ]);
  436.                 }
  437.             }
  438.         }
  439.     }
  440.     /**
  441.      * @Route("/Parent/MesFavoris_Accueil", name="MesFavoris_Accueil")
  442.      */
  443.     public function MesFavoris_Accueil(Request $requestLoggerInterface $loggerInterface): Response
  444.     {
  445.         $session $this->session;
  446.         $session->set('pageMenu''MesFavoris');
  447.         /** @var \App\Entity\User $user */
  448.         $user $this->getUser();
  449.         $userId $user->getId();
  450.         $code $request->get("codeSejour");
  451.         $SEjourService $this->sejourService;
  452.         if (isset($code)) {
  453.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  454.             if ($sejour == null) {
  455.                 $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  456.                 if ($sejour == null) {
  457.                     $this->session->set('rout''code');
  458.                     return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  459.                 }
  460.             } else {
  461.                 $this->session->set('Sejour'$sejour->getId());
  462.             }
  463.         }
  464.         if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
  465.             $code $session->get("Sejour");
  466.             $sejour $this->em->getRepository(Sejour::class)->find($code);
  467.         } else {
  468.             $code $request->get("codeSejour");
  469.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  470.         }
  471.         if ($sejour == null) {
  472.             $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  473.         }
  474.         if ($sejour == null) {
  475.             $this->session->set('rout''code');
  476.             return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  477.         }
  478.         $idSejour $sejour->getId();
  479.         $this->session->set('Sejour'$idSejour);
  480.         $dateCreationArch = clone $sejour->getDateFinCode();
  481.         $em $this->em;
  482.         $idAcc $sejour->getIdAcommp();
  483.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  484.         $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  485.         if ($albumAcc == null) {
  486.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  487.         }
  488.         if ($dateCreationArch <= new \DateTime()) {
  489.             return $this->render('Parent/SejourDepassee.html.twig');
  490.         }
  491.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  492.         $nbImages count($AllAttachements);
  493.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  494.         $positions $SEjourService->getsejourposition($idSejour);
  495.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  496.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  497.         if ($parentsejour == NULL) {
  498.             $parentsejour $SEjourService->inserparentsejour($userId$idSejour);
  499.         }
  500.         if ($AllAttachements == null && $messages == null) {
  501.             $this->session->set('rout''rout');
  502.             return $this->render('Parent/Aucunphoto.html.twig', [
  503.                 "sejour" => $sejour,
  504.                 "parentsejour" => $parentsejour
  505.             ]);
  506.         } else {
  507.             $attachementsCount $AllAttachements['total'];
  508.             unset($AllAttachements['total']);
  509.             if ($sejour->getPaym() == 0) {
  510.                 $produits $this->typeProduiteService;
  511.                 $liste $produits->produitlistTypeConditionnement();
  512.                 $pubProd $user->getShowpubprod();
  513.                 $em $this->em;
  514.                 $idAcc $sejour->getIdAcommp();
  515.                 $label "Livre_sejour" $sejour->getCodeSejour();
  516.                 $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  517.                 $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  518.                 if ($albumAcc == null) {
  519.                     $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  520.                 }
  521.                 if ($livreSej == null) {
  522.                     $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  523.                 }
  524.                 return $this->render('Parent/DetailsSejour.html.twig', [
  525.                     "sejour" => $sejour,
  526.                     "livreSejour" => $livreSejour,
  527.                     "sejour" => $sejour,
  528.                     'listeattach' => $AllAttachements,
  529.                     'attachementsCount' => $attachementsCount,
  530.                     'prod' => $liste,
  531.                     'nbImages' => $nbImages,
  532.                     'positions' => $positions,
  533.                     'messages' => $messages,
  534.                     'like' => $listeattachlikephoto,
  535.                     "parentsejour" => $parentsejour,
  536.                     'smsnotif' => $parentsejour->getSmsnotif(),
  537.                     'showpub' => $pubProd,
  538.                     'albumAcc' => $albumAcc,
  539.                 ]);
  540.             }
  541.             if ($sejour->getPaym() == 1) {
  542.                 if ($parentsejour->getPayment() == 0) {
  543.                     $this->session->set('rout''rout');
  544.                     $ses_id session_id();
  545.                     return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  546.                 }
  547.                 if ($parentsejour->getPayment() == 1) {
  548.                     $produits $this->typeProduiteService;
  549.                     $liste $produits->produitlistTypeConditionnement();
  550.                     $pubProd $user->getShowpubprod();
  551.                     return $this->render('Parent/DetailsSejour.html.twig', [
  552.                         "sejour" => $sejour,
  553.                         'favoritesCount' => count($listeattachlikephoto),
  554.                         'listeattach' => $AllAttachements,
  555.                         'attachementsCount' => $attachementsCount,
  556.                         'prod' => $liste,
  557.                         'nbImages' => $nbImages,
  558.                         'positions' => $positions,
  559.                         'messages' => $messages,
  560.                         'like' => $listeattachlikephoto,
  561.                         "parentsejour" => $parentsejour,
  562.                         'smsnotif' => $parentsejour->getSmsnotif(),
  563.                         'showpub' => $pubProd
  564.                     ]);
  565.                 }
  566.             }
  567.         }
  568.     }
  569.     /**
  570.      * @Route("/Parent/DetailsSejour", name="DetailsSejour")
  571.      */
  572.     public function ModifierSejour()
  573.     {
  574.         $SEjourService $this->sejourService;
  575.         $sejour $SEjourService->getsejour(3);
  576.         $listeattach $SEjourService->getatachmentsejour(3);
  577.         $positions $SEjourService->getsejourposition(3);
  578.         $messages $SEjourService->getsejourmessage(3);
  579.         //dd($messages);
  580.         $produits $this->typeProduiteService;
  581.         $liste $produits->produitlistTypeConditionnement();
  582.         return $this->render('Parent/DetailsSejour.html.twig', [
  583.             'prod' => $liste,
  584.             'sejour' => $sejour,
  585.             'listeattach' => $listeattach,
  586.             'positions' => $positions,
  587.             'messages' => $messages,
  588.         ]);
  589.     }
  590.     /**
  591.      * @Route("/Parent/listefavorie", name="listefavorie")
  592.      */
  593.     public function listefavorie()
  594.     {
  595.         $SEjourService $this->sejourService;
  596.         /** @var \App\Entity\User $user */
  597.         $user $this->getUser();
  598.         $userId $user->getId();
  599.         $session $this->session;
  600.         $session->set('pageMenu''');
  601.         $idSejour $session->get("Sejour");
  602.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  603.         dd($listeattachlikephoto);
  604.         return ('yoopii');
  605.     }
  606.     /**
  607.      * @Route("/Parent/Store", name="boutique5sur5")
  608.      */
  609.     public function boutique5sur5()
  610.     {
  611.         $SEjourService $this->sejourService;
  612.         /** @var \App\Entity\User $userId */
  613.         $userId $this->getUser();
  614.         $userId $userId->getId();
  615.         $session $this->session;
  616.         $session->set('pageMenu''boutique5su5');
  617.         $idSejour $session->get("Sejour");
  618.         $sejour $SEjourService->getsejourpourparent($idSejour);
  619.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  620.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  621.         $messages $SEjourService->getsejourmessage($idSejour);
  622.         $nbImages count($listeattach);
  623.         $nbmessages count($messages);
  624.         $produit $this->typeProduiteService;
  625.         $liste $produit->produitlistTypeConditionnement();
  626.         $idAcc $sejour->getIdAcommp();
  627.         $em $this->em;
  628.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  629.         $nbLikes count($listeattachlikephoto);
  630.         // dd($liste);
  631.         return $this->render('Parent/boutique_5sur5.html.twig', [
  632.             "sejour" => $sejour,
  633.             'like' => $listeattachlikephoto,
  634.             'produit' => $liste,
  635.             'albumAcc' => $albumAcc,
  636.             'nbImages' => $nbImages,
  637.             'nbmessages' => $nbmessages,
  638.             'nbLikes' => $nbLikes
  639.         ]);
  640.     }
  641.     /*public function maSelection()
  642.     {
  643.         $SEjourService = $this->sejourService;
  644.         $user = $this->getUser();        
  645.         $userId = $user->getId();
  646.         $user = $this->getUser();
  647.         $session = $this->session;
  648.         $session->set('pageMenu', '');
  649.         $idSejour = $session->get("Sejour");
  650.         $sejour = $SEjourService->getsejourpourparent($idSejour);
  651.         $listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
  652.         $produit = $this->typeProduiteService;
  653.         $liste = $produit->produitlistTypeConditionnement();
  654.         $idAcc = $sejour->getIdAcommp();
  655.         $em = $this->em;
  656.         $albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
  657.         // dd($liste);
  658.         return $this->render('Parent/VoirMaSelection.html.twig', [
  659.             "sejour" => $sejour,
  660.             'like' => $listeattachlikephoto, 'produit' => $liste, 'albumAcc' => $albumAcc
  661.         ]);
  662.     }*/
  663.     /**
  664.      * @Route("/Parent/MaSelection", name="maSelection")
  665.      */
  666.     public function maSelection()
  667.     {
  668.         //Yosra
  669.         $nbLikes 0;
  670.         $SEjourService $this->sejourService;
  671.         $session $this->session;
  672.         $session->set('pageMenu''Meselection');
  673.         $idSejour $session->get("Sejour");
  674.         /** @var \App\Entity\User $user */
  675.         $user $this->getUser();
  676.         $iduser $user->getId();
  677.         $SEjourService $this->sejourService;
  678.         $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  679.         $sejour $SEjourService->getsejour($idSejour);
  680.         $positions $SEjourService->getsejourposition($idSejour);
  681.         //$messages = $SEjourService->getsejourmessage($idSejour);
  682.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  683.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  684.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  685.         $nbLikes count($listeattachlikephoto);
  686.         /* $listeattach = $SEjourService->getatachmentsejour($idSejour);
  687.         $listeVideo = $SEjourService->getVideosejour($idSejour);
  688.         $AllAttachements = array_merge_recursive($listeattach, $listeVideo); */
  689.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  690.         $attachementsCount $AllAttachements['total'];
  691.         unset($AllAttachements['total']);
  692.         $produits $this->typeProduiteService;
  693.         $liste $produits->produitlistTypeConditionnement();
  694.         $pubProd $user->getShowpubprod();
  695.         return $this->render('Parent/DetailsSejour.html.twig', [
  696.             "sejour" => $sejour,
  697.             "listeattach" => $AllAttachements,
  698.             'attachementsCount' => $attachementsCount,
  699.             'positions' => $positions,
  700.             'messages' => $messages,
  701.             'likes' => $listeattachlikephoto,
  702.             'like' => $listeattachlikephoto,
  703.             'nblikes' => $nbLikes,
  704.             'nbImages' =>   $attachementsCount,
  705.             "parentsejour" => $parentsejour,
  706.             'prod' => $liste,
  707.             'smsnotif' => $parentsejour->getSmsnotif(),
  708.             'showpub' => $pubProd
  709.         ]);
  710.     }
  711.     /**
  712.      * @Route("/Parent/MesPhotosPerso", name="mesPhotosperso")
  713.      */
  714.     public function mesPhotosperso()
  715.     {  //Yosra
  716.         $SEjourService $this->sejourService;
  717.         $session $this->session;
  718.         $session->set('pageMenu''Meselection');
  719.         $idSejour $session->get("Sejour");
  720.         /** @var \App\Entity\User $user */
  721.         $user $this->getUser();
  722.         $iduser $user->getId();
  723.         $SEjourService $this->sejourService;
  724.         $sejour $SEjourService->getsejour($idSejour);
  725.         $positions $SEjourService->getsejourposition($idSejour);
  726.         $messages $SEjourService->getsejourmessage($idSejour);
  727.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  728.         $listeattachlikephoto $this->em->getRepository(SejourAttachment::class)->findBy(['idParent' => $iduser'statut' => "private"'idSejour' => $sejour]);
  729.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  730.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  731.         $listeVideo $SEjourService->getVideosejour($idSejour);
  732.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  733.         $attachementsCount count($listeattach);
  734.         $nbImages count($listeattachlikephoto);
  735.         $produits $this->typeProduiteService;
  736.         $liste $produits->produitlistTypeConditionnement();
  737.         return $this->render('Parent/MesPhotosPerso.html.twig', [
  738.             "sejour" => $sejour,
  739.             'attachementsCount' => $attachementsCount,
  740.             'listeattach' => $AllAttachements,
  741.             'positions' => $positions,
  742.             'nbImages' => $nbImages,
  743.             'messages' => $messages,
  744.             'likes' => $listeattachlikephoto,
  745.             "parentsejour" => $parentsejour,
  746.             'prod' => $liste,
  747.             'smsnotif' => $parentsejour->getSmsnotif()
  748.         ]);
  749.     }
  750.     /**
  751.      * @Route("/Parent/achatBoiteVocale", name="achatBoiteVocale")
  752.      */
  753.     public function achatBoiteVocale()
  754.     {
  755.         $this->session->set('rout''rout');
  756.         $session $this->session;
  757.         /** @var \App\Entity\User $user */
  758.         $user $this->getUser();
  759.         $iduser $user->getId();
  760.         $idSejour $session->get("Sejour");
  761.         $ses_id session_id();
  762.         $SEjourService $this->sejourService;
  763.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  764.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  765.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  766.         return $this->render('Parent/achatBoiteVocale.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  767.     }
  768.     /**
  769.      * @Route("/Parent/achatsejour", name="achatsejour")
  770.      */
  771.     public function achatsejour()
  772.     {
  773.         $this->session->set('rout''rout');
  774.         $session $this->session;
  775.         /** @var \App\Entity\User $user */
  776.         $user $this->getUser();
  777.         $iduser $user->getId();
  778.         $idSejour $session->get("Sejour");
  779.         $ses_id session_id();
  780.         $SEjourService $this->sejourService;
  781.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  782.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  783.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  784.         return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  785.     }
  786.     /**
  787.      * @Route("/Parent/CodeSejour", name="CodeSejour")
  788.      */
  789.     public function CodeSejour()
  790.     {
  791.         /** @var \App\Entity\User $user */
  792.         $user $this->getUser();
  793.         $userId $user->getId();
  794.         $this->session->set('rout''code');
  795.         return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 0'smsnotif' => $user->getSmsnotif()]);
  796.     }
  797.     /** @Route("/Parent/produits", name="produit_parent")
  798.      */
  799.     public function produitsparent()
  800.     {
  801.         $SEjourService $this->sejourService;
  802.         $produitparent $this->typeProduiteService;
  803.         /** @var \App\Entity\User $user */
  804.         $user $this->getUser();
  805.         $userId $user->getId();
  806.         $session $this->session;
  807.         $session->set('pageMenu''');
  808.         $idSejour $session->get("Sejour");
  809.         $listproduit $produitparent->produitparent();
  810.         return ('yoopii');
  811.     }
  812.     /**
  813.      * @Route("/Parent/AucunePhoto", name="AucunePhoto")
  814.      * */
  815.     public function premiercnx()
  816.     {
  817.         $this->session->set('rout''rout');
  818.         return $this->render('Parent/Aucunphoto.html.twig');
  819.     }
  820.     /**
  821.      * @Route("/Parent/notif", name="notif_parent",methods={"POST","GET"})
  822.      */
  823.     public function notif_parent(Request $request)
  824.     {
  825.         $UserService $this->userService;
  826.         $session $this->session;
  827.         $session->set('pageMenu''');
  828.         $idSejour $session->get("Sejour");
  829.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  830.         /** @var \App\Entity\User $user */
  831.         $user $this->getUser();
  832.         $iduser $user->getId();
  833.         $sms $request->get("sms");
  834.         $mail $request->get('mail');
  835.         $refaverti $request->get('refaverti');
  836.         //$ville = $request->get("nonnotif");
  837.         $parentsejour $UserService->notifparentsejour($mail$sms$idSejour$iduser$refaverti);
  838.         return new JsonResponse('done');
  839.     }
  840.     /**
  841.      * @Route("/Parent/passerconnxion", name="notif_parenpasserconnxion",methods={"POST","GET"})
  842.      */
  843.     public function passerconnxion(Request $request)
  844.     {
  845.         $UserService $this->userService;
  846.         $session $this->session;
  847.         $session->set('pageMenu''');
  848.         $idSejour $session->get("Sejour");
  849.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  850.         /** @var \App\Entity\User $user */
  851.         $user $this->getUser();
  852.         $iduser $user->getId();
  853.         $SEjourService $this->sejourService;
  854.         $setparentsejour $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  855.         $sejour $SEjourService->getsejour($idSejour);
  856.         $positions $SEjourService->getsejourposition($idSejour);
  857.         $messages $SEjourService->getsejourmessage($idSejour);
  858.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  859.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  860.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  861.         if (sizeof($sejour->getAttachements()) == 0) {
  862.             return new JsonResponse('0');
  863.         } else {
  864.             return new JsonResponse('1');
  865.         }
  866.     }
  867.     /**
  868.      * @Route("/Parent/sejourParent", name="sejourParent_5sur5")
  869.      * */
  870.     public function sejourParent()
  871.     {
  872.         $SEjourService $this->sejourService;
  873.         $UserService $this->userService;
  874.         $session $this->session;
  875.         $session->set('pageMenu''');
  876.         $idSejour $session->get("Sejour");
  877.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  878.         /** @var \App\Entity\User $user */
  879.         $user $this->getUser();
  880.         $iduser $user->getId();
  881.         $SEjourService $this->sejourService;
  882.         $setparentsejour $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  883.         $sejour $SEjourService->getsejour($idSejour);
  884.         $positions $SEjourService->getsejourposition($idSejour);
  885.         $messages $SEjourService->getsejourmessage($idSejour);
  886.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  887.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  888.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  889.         $nbImages count($listeattach);
  890.         $listeVideo $SEjourService->getVideosejour($idSejour);
  891.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  892.         $produits $this->typeProduiteService;
  893.         $liste $produits->produitlistTypeConditionnement();
  894.         $pubProd $user->getShowpubprod();
  895.         return $this->render('Parent/DetailsSejour.html.twig', [
  896.             "sejour" => $sejour,
  897.             'listeattach' => $AllAttachements,
  898.             'positions' => $positions,
  899.             'nbImages' => $nbImages,
  900.             'messages' => $messages,
  901.             'like' => $listeattachlikephoto,
  902.             "parentsejour" => $parentsejour,
  903.             'prod' => $liste,
  904.             'smsnotif' => $parentsejour->getSmsnotif(),
  905.             'showpub' => $pubProd
  906.         ]);
  907.     }
  908.     /**
  909.      * @Route("/Parent/sejourVide", name="sejourvideee")
  910.      * */
  911.     public function sejourvide()
  912.     {
  913.         $this->session->set('rout''code');
  914.         $SEjourService $this->sejourService;
  915.         $UserService $this->userService;
  916.         $session $this->session;
  917.         $session->set('pageMenu''');
  918.         $idSejour $session->get("Sejour");
  919.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  920.         /** @var \App\Entity\User $user */
  921.         $user $this->getUser();
  922.         $iduser $user->getId();
  923.         $SEjourService $this->sejourService;
  924.         $setparentsejour $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  925.         $sejour $SEjourService->getsejour($idSejour);
  926.         $positions $SEjourService->getsejourposition($idSejour);
  927.         $messages $SEjourService->getsejourmessage($idSejour);
  928.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  929.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  930.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  931.         return $this->render('Parent/Aucunphoto.html.twig', [
  932.             "sejour" => $sejour,
  933.             "parentsejour" => $parentsejour
  934.         ]);
  935.     }
  936.     /**
  937.      * @Route("Parent/EditContenuPage", name="EditContenuPage")
  938.      */
  939.     public function EditContenuPageParent()
  940.     {
  941.         $em $this->em;
  942.         $Albumproduct $em->getRepository(Produit::class)->findBy(['idConditionnement' => 4]);
  943.         foreach ($Albumproduct as $album) {
  944.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $album]);
  945.             foreach ($AllPages as $p) {
  946.                 $arrayexploded $p->getCouleurbordure();
  947.                 $arrayexploded1 str_replace("font-size""fontSize"$arrayexploded);
  948.                 $p->setCouleurbordure($arrayexploded1);
  949.                 $em->getManager()->persist($p);
  950.                 $em->getManager()->flush();
  951.             }
  952.         }
  953.         return new Response('ok');
  954.     }
  955.     /**
  956.      * @Route("Parent/AjoutAlbum", name="EditionAlbum")
  957.      */
  958.     public function EditionAlbumParent()
  959.     {
  960.         $SEjourService $this->sejourService;
  961.         $em $this->em;
  962.         /** @var \App\Entity\User $user */
  963.         $user $this->getUser();
  964.         $userId $user->getId();
  965.         $session $this->session;
  966.         $session->set('pageMenu''AlbumSejour');
  967.         $idSejour $session->get("Sejour");
  968.         $clipart null;
  969.         $random true;
  970.         $sejour $SEjourService->getsejourpourparent($idSejour);
  971.         $idAcc $sejour->getIdAcommp();
  972.         $part $sejour->getIdPartenaire();
  973.         $nompart $part->getUsername();
  974.         $logopart $part->getLogourl();
  975.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  976.         $nbLikes count($listeattachlikephoto);
  977.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  978.         $listerandom $listeattach;
  979.         $nbPhoto count($listeattach);
  980.         $AllPagesAcc null;
  981.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
  982.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  983.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  984.         if ($albumAcc) {
  985.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  986.         }
  987.         $allpagesResult = array();
  988.         $tabacc = array();
  989.         $tabacc1 = array();
  990.         if ($random == true) {
  991.             foreach ($AllPages as $p) {
  992.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  993.                 $rr "";
  994.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  995.                     if ($i sizeof($arrayexploded)) {
  996.                         if (sizeof($listerandom) == 0) {
  997.                             //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  998.                             $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  999.                         }
  1000.                         if ($nbLikes != 0) {
  1001.                             $listerandom $SEjourService->getlikephotosejour($userId$idSejour);
  1002.                             $arrayRsRandom $this->random_function($listerandom);
  1003.                         }
  1004.                         if ($nbLikes == 0) {
  1005.                             $arrayRsRandom $this->random_functionNolikes($listerandom);
  1006.                         }
  1007.                         array_push($tabacc$arrayRsRandom['idelem']);
  1008.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1009.                         unset($listerandom[$arrayRsRandom['elem']]);
  1010.                     } else {
  1011.                         $rr $rr $arrayexploded[$i];
  1012.                     }
  1013.                     $listerandom $listerandom;
  1014.                 }
  1015.                 $resultFinal $rr;
  1016.                 $p->setCouleurbordure($resultFinal);
  1017.                 array_push($allpagesResult$p);
  1018.             }
  1019.             $AllPages $allpagesResult;
  1020.         }
  1021.         $tabacc1 array_count_values($tabacc);
  1022.         if ($nbLikes  == 0) {
  1023.             return $this->render('Parent/NewAlbumLikes.html.twig', ["listeattach" => $listeattach"tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes'nbPhoto' => $nbPhoto]);
  1024.         }
  1025.         if ($nbLikes  != 0) {
  1026.             return $this->render('Parent/NewAlbumLikes.html.twig', ["tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes'nbPhoto' => $nbPhoto]);
  1027.         }
  1028.     }
  1029.     /**
  1030.      * @Route("Parent/AjoutPochettePhotos_Sejour/{nbr}", name="AjoutPochettePhotos_Sejour")
  1031.      */
  1032.     public function AjoutPochettePhotosParent_Sejour($nbr)
  1033.     {
  1034.         $SEjourService $this->sejourService;
  1035.         $userId $this->getUser()->getId();
  1036.         $user $this->getUser();
  1037.         $session $this->get('session');
  1038.         $session->set('pageMenu''');
  1039.         $idSejour $session->get("Sejour");
  1040.         $produitcondition $session->get("produit");
  1041.         $produit $session->get("produittype");
  1042.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1043.         $em $this->getDoctrine()->getManager();
  1044.         $clipart $em->getRepository(Clipart::class)->findAll();
  1045.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1046.         $listerandom =  $listeattach;
  1047.         $AllPagesAcc null;
  1048.         //        $random = false;
  1049.         //        $Albumproduct = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $userId], ['id' => 'DESC']);
  1050.         //        if ($Albumproduct == null || $Albumproduct == "") {
  1051.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1052.         $random true;
  1053.         //        }
  1054.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1055.         $idAcc $sejour->getIdAcommp();
  1056.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1057.         $part $sejour->getIdPartenaire();
  1058.         //$part = $em->getRepository(Etablisment::class)->findOneBy(['id' => $idpart->getId()]);
  1059.         //dd($part);
  1060.         $nompart $part->getUsername();
  1061.         $logopart $part->getLogourl();
  1062.         // dd($Albumproduct);  
  1063.         if ($albumAcc != null and $albumAcc != "") {
  1064.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1065.         }
  1066.         //        dd($albumAcc);
  1067.         $allpagesResult = array();
  1068.         $j 0;
  1069.         if ($random == true) {
  1070.             foreach ($AllPages as $p) {
  1071.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1072.                 //                var_dump($arrayexploded);
  1073.                 $rr "";
  1074.                 $elemPath "";
  1075.                 $elemId "";
  1076.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1077.                     if ($i sizeof($arrayexploded)) {
  1078.                         if (sizeof($listerandom) == 0) {
  1079.                             $listerandom =  $listeattach;
  1080.                         }
  1081.                         $arrayRsRandom $this->random_functionPhotoNolIKES($listerandom$j);
  1082.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1083.                         unset($listerandom[$arrayRsRandom['elem']]);
  1084.                     } else {
  1085.                         $rr $rr $arrayexploded[$i];
  1086.                     }
  1087.                     $listerandom $listerandom;
  1088.                 }
  1089.                 $resultFinal $rr;
  1090.                 $p->setCouleurbordure($resultFinal);
  1091.                 array_push($allpagesResult$p);
  1092.                 if ($j sizeof($listeattach) - 1) {
  1093.                     $j $j 1;
  1094.                 } else {
  1095.                     $j 0;
  1096.                 }
  1097.             }
  1098.             $AllPages $allpagesResult;
  1099.         }
  1100.         // die();
  1101.         $nbAttach count($listeattach);
  1102.         return $this->render('Parent/PochettePhotos.html.twig', ["nbr" => $nbr"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'photosSejour' => $listeattach'nbAttach' => $nbAttach]);
  1103.     }
  1104.     /**
  1105.      * @Route("Parent/AjoutPochettePhotos_Fav/{nbr}", name="AjoutPochettePhotos_Favoris")
  1106.      */
  1107.     public function EnregistrerPochettePhoto($nbr)
  1108.     {
  1109.         $SEjourService $this->sejourService;
  1110.         $user $this->getUser();
  1111.         $userId $this->getUser()->getId();
  1112.         $session $this->get('session');
  1113.         $session->set('pageMenu''');
  1114.         $idSejour $session->get("Sejour");
  1115.         $produitcondition $session->get("produit");
  1116.         $produit $session->get("produittype");
  1117.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1118.         $em $this->getDoctrine()->getManager();
  1119.         $clipart $em->getRepository(Clipart::class)->findAll();
  1120.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1121.         $listerandom $listeattachlikephoto;
  1122.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1123.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1124.         $allpagesResult = array();
  1125.         $j 0;
  1126.         foreach ($AllPages as $p) {
  1127.             $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1128.             //                var_dump($arrayexploded);
  1129.             $rr "";
  1130.             $elemPath "";
  1131.             $elemId "";
  1132.             for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1133.                 if ($i sizeof($arrayexploded)) {
  1134.                     if (sizeof($listerandom) == 0) {
  1135.                         $listerandom $listeattachlikephoto;
  1136.                     }
  1137.                     $arrayRsRandom $this->random_functionPhoto($listerandom);
  1138.                     $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1139.                     unset($listerandom[$arrayRsRandom['elem']]);
  1140.                 } else {
  1141.                     $rr $rr $arrayexploded[$i];
  1142.                 }
  1143.                 $listerandom $listerandom;
  1144.             }
  1145.             $resultFinal $rr;
  1146.             $p->setCouleurbordure($resultFinal);
  1147.             array_push($allpagesResult$p);
  1148.             if ($j sizeof($listeattachlikephoto) - 1) {
  1149.                 $j $j 1;
  1150.             } else {
  1151.                 $j 0;
  1152.             }
  1153.         }
  1154.         $AllPages $allpagesResult;
  1155.         // die();
  1156.         return new JsonResponse('done');
  1157.     }
  1158.     /**
  1159.      * @Route("Parent/AjoutPochettePhotos_Fav/{nbr}", name="AjoutPochettePhotos_Favoris")
  1160.      */
  1161.     public function AjoutPochettePhotosParent_Fav($nbr)
  1162.     {
  1163.         $SEjourService $this->sejourService;
  1164.         $user $this->getUser();
  1165.         $userId $this->getUser()->getId();
  1166.         $session $this->get('session');
  1167.         $session->set('pageMenu''');
  1168.         $idSejour $session->get("Sejour");
  1169.         $produitcondition $session->get("produit");
  1170.         $produit $session->get("produittype");
  1171.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1172.         $em $this->getDoctrine()->getManager();
  1173.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' =>  $userId'idSejour' =>  $idSejour]);
  1174.         foreach ($listeattachlikephoto as $photo) {
  1175.             $idattach $photo->getIdSejourAttchment();
  1176.             $SejattachPhoto  $photo->getIdSejourAttchment();
  1177.             $urlPhoto  =   $SejattachPhoto->getIdAttchment()->getPath();
  1178.             //$urlPhoto =   $attachPhoto->getPath();
  1179.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/',  $urlPhoto);
  1180.             $photosData[] = [
  1181.                 'id' => $photo->getId(),
  1182.                 'url' =>    $new_url,
  1183.                 'caption' => "",
  1184.             ];
  1185.         }
  1186.         $nbLikes count($listeattachlikephoto);
  1187.         // Convertir le tableau PHP en JSON
  1188.         $photosDataJSON json_encode($photosData);
  1189.         return $this->render('Parent/PochettePhotosLikes.html.twig', ["nbr" => $nbr"sejour" => $sejour,  "nbLikes" => $nbLikes'photosFav' =>    $photosDataJSON]);
  1190.     }
  1191.     /**
  1192.      * @Route("Parent/AjoutRetroPhotos_Fav/{nbr}", name="AjoutRetroPhotos_Favoris")
  1193.      */
  1194.     public function AjoutRetroPhotosParent_Fav($nbr)
  1195.     {
  1196.         $SEjourService $this->sejourService;
  1197.         $user $this->getUser();
  1198.         $userId $this->getUser()->getId();
  1199.         $session $this->get('session');
  1200.         $session->set('pageMenu''');
  1201.         $idSejour $session->get("Sejour");
  1202.         $produitcondition $session->get("produit");
  1203.         $produit $session->get("produittype");
  1204.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1205.         $em $this->getDoctrine()->getManager();
  1206.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' =>  $userId'idSejour' =>  $idSejour]);
  1207.         foreach ($listeattachlikephoto as $photo) {
  1208.             $idattach $photo->getIdSejourAttchment();
  1209.             $SejattachPhoto  $photo->getIdSejourAttchment();
  1210.             $urlPhoto  =   $SejattachPhoto->getIdAttchment()->getPath();
  1211.             //$urlPhoto =   $attachPhoto->getPath();
  1212.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/',  $urlPhoto);
  1213.             $photosData[] = [
  1214.                 'id' => $photo->getId(),
  1215.                 'url' =>    $new_url,
  1216.                 'caption' => "",
  1217.             ];
  1218.         }
  1219.         $nbLikes count($listeattachlikephoto);
  1220.         // Convertir le tableau PHP en JSON
  1221.         $photosDataJSON json_encode($photosData);
  1222.         return $this->render('Parent/RetroRefonte.html.twig', ["nbr" => $nbr"sejour" => $sejour,  "nbLikes" => $nbLikes'photosFav' =>    $photosDataJSON]);
  1223.     }
  1224.     function random_function($listerandom)
  1225.     {
  1226.         $elem array_rand($listerandom);
  1227.         $photo $listerandom[$elem];
  1228.         $idelem $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1229.         $pathelem $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
  1230.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1231.     }
  1232.     function random_functionNolikes($listerandom)
  1233.     {
  1234.         //dd(array_keys($listerandom));
  1235.         $elem array_rand($listerandom);
  1236.         $photo $listerandom[$elem];
  1237.         $idelem $photo["id"];
  1238.         $pathelem $photo["path"];
  1239.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1240.     }
  1241.     function random_functionPhoto($listerandom)
  1242.     {
  1243.         $elem array_rand($listerandom);
  1244.         $photo $listerandom[$elem];
  1245.         $idelem $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1246.         $pathelem $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
  1247.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1248.     }
  1249.     function random_functionPhotosSejour($listerandom$elem)
  1250.     {
  1251.         $elem array_rand($listerandom);
  1252.         $photo $listerandom[$elem];
  1253.         $idelem $photo->getId();
  1254.         $pathelem $photo->getPath();
  1255.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1256.     }
  1257.     function random_functionPhotoNolIKES($listerandom$elem)
  1258.     {
  1259.         $elem array_rand($listerandom);
  1260.         $photo $listerandom[$elem];
  1261.         $idelem $photo['id'];
  1262.         $pathelem $photo['path'];
  1263.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1264.     }
  1265.     /**
  1266.      * đźš€ Smart Distribution Algorithm BASÉ SUR LES IDS RÉELS DES PHOTOS
  1267.      * Expert PHP Senior Implementation - Garantit l'unicitĂ© et la distribution correcte
  1268.      * LIMITE: Max 3 rĂ©pĂ©titions par photo ID pour Ă©viter la monotonie
  1269.      */
  1270.     private function calculateOptimalDistribution($favoritePhotos$totalSlots)
  1271.     {
  1272.         if (empty($favoritePhotos) || $totalSlots === 0) {
  1273.             return [];
  1274.         }
  1275.         $nbFavorites count($favoritePhotos);
  1276.         $MAX_REPETITIONS 3// đźš€ LIMITE ANTI-MONOTONIE
  1277.         // Extraire les IDs rĂ©els des photos pour tracking prĂ©cis
  1278.         $photoIds = [];
  1279.         foreach ($favoritePhotos as $index => $photo) {
  1280.             if (is_object($photo)) {
  1281.                 $photoIds[$index] = $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1282.             } else {
  1283.                 $photoIds[$index] = $photo['id'];
  1284.             }
  1285.         }
  1286.         $distribution = [];
  1287.         $photoUsageCount = []; // Tracking des utilisations par ID rĂ©el
  1288.         if ($nbFavorites >= $totalSlots) {
  1289.             // Plus de favoris que de slots â†’ 1 photo par slot, pas de rĂ©pĂ©tition
  1290.             for ($i 0$i $totalSlots$i++) {
  1291.                 $photoIndex $i $nbFavorites;
  1292.                 $photoId $photoIds[$photoIndex];
  1293.                 $distribution[] = $photoIndex;
  1294.                 $photoUsageCount[$photoId] = ($photoUsageCount[$photoId] ?? 0) + 1;
  1295.             }
  1296.         } else {
  1297.             // đźŽŻ LOGIQUE SENIOR: Toutes les photos favorites d'abord, puis rĂ©pĂ©titions contrĂ´lĂ©es
  1298.             // Ă‰tape 1: GARANTIR que chaque photo favorite apparaĂ®t au moins une fois
  1299.             for ($i 0$i $nbFavorites$i++) {
  1300.                 $photoId $photoIds[$i];
  1301.                 $distribution[] = $i;
  1302.                 $photoUsageCount[$photoId] = 1;
  1303.             }
  1304.             // Ă‰tape 2: Distribuer les slots restants avec contrĂ´le strict
  1305.             $remainingSlots $totalSlots $nbFavorites;
  1306.             if ($remainingSlots 0) {
  1307.                 // VĂ©rifier si on peut respecter la limite MAX_REPETITIONS
  1308.                 $maxPossibleRepetitions $nbFavorites * ($MAX_REPETITIONS 1);
  1309.                 if ($remainingSlots $maxPossibleRepetitions) {
  1310.                     // Fallback vers distribution mixte
  1311.                     return $this->calculateMixedDistribution($favoritePhotos$totalSlots$MAX_REPETITIONS);
  1312.                 }
  1313.                 // Distribution Ă©quitable des rĂ©pĂ©titions avec contrĂ´le par ID
  1314.                 $slotsToDistribute $remainingSlots;
  1315.                 $round 0;
  1316.                 while ($slotsToDistribute && $round $MAX_REPETITIONS 1) {
  1317.                     for ($i 0$i $nbFavorites && $slotsToDistribute 0$i++) {
  1318.                         $photoId $photoIds[$i];
  1319.                         // VĂ©rifier que cette photo n'a pas atteint la limite
  1320.                         if ($photoUsageCount[$photoId] < $MAX_REPETITIONS) {
  1321.                             $distribution[] = $i;
  1322.                             $photoUsageCount[$photoId]++;
  1323.                             $slotsToDistribute--;
  1324.                         }
  1325.                     }
  1326.                     $round++;
  1327.                 }
  1328.             }
  1329.             // MĂ©lange intelligent prĂ©servant la règle "toutes les favorites d'abord"
  1330.             $this->smartShufflePreservingFirst($distribution$nbFavorites);
  1331.         }
  1332.         // đź§Ş Validation stricte avec IDs rĂ©els
  1333.         if (!$this->validateDistributionWithIds($distribution$photoIds$MAX_REPETITIONS)) {
  1334.             error_log("⚠️ ALGORITHME PHOTO: Distribution invalide dĂ©tectĂ©e avec IDs rĂ©els");
  1335.             error_log("Distribution: " json_encode($distribution));
  1336.             error_log("Photo Usage: " json_encode($photoUsageCount));
  1337.         }
  1338.         return $distribution;
  1339.     }
  1340.     /**
  1341.      * Distribution mixte quand il y a trop peu de favoris
  1342.      * Combine favoris + meilleures photos du sĂ©jour
  1343.      */
  1344.     private function calculateMixedDistribution($favoritePhotos$totalSlots$maxRepetitions)
  1345.     {
  1346.         if (empty($favoritePhotos)) {
  1347.             // Aucun favori, retourner des marqueurs pour photos du sĂ©jour
  1348.             return array_fill(0$totalSlots, -1);
  1349.         }
  1350.         $nbFavorites count($favoritePhotos);
  1351.         $distribution = [];
  1352.         // Extraire les IDs pour tracking
  1353.         $photoIds = [];
  1354.         foreach ($favoritePhotos as $index => $photo) {
  1355.             if (is_object($photo)) {
  1356.                 $photoIds[$index] = $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1357.             } else {
  1358.                 $photoIds[$index] = $photo['id'];
  1359.             }
  1360.         }
  1361.         $photoUsageCount = [];
  1362.         // Ă‰tape 1: S'assurer que chaque favori apparaĂ®t au moins une fois
  1363.         for ($i 0$i $nbFavorites && count($distribution) < $totalSlots$i++) {
  1364.             $distribution[] = $i;
  1365.             $photoUsageCount[$photoIds[$i]] = 1;
  1366.         }
  1367.         // Ă‰tape 2: Ajouter des rĂ©pĂ©titions jusqu'Ă  la limite
  1368.         $round 1;
  1369.         while (count($distribution) < $totalSlots && $round $maxRepetitions) {
  1370.             for ($i 0$i $nbFavorites && count($distribution) < $totalSlots$i++) {
  1371.                 $photoId $photoIds[$i];
  1372.                 if ($photoUsageCount[$photoId] < $maxRepetitions) {
  1373.                     $distribution[] = $i;
  1374.                     $photoUsageCount[$photoId]++;
  1375.                 }
  1376.             }
  1377.             $round++;
  1378.         }
  1379.         // Ă‰tape 3: ComplĂ©ter avec des marqueurs pour photos du sĂ©jour
  1380.         while (count($distribution) < $totalSlots) {
  1381.             $distribution[] = -1// Marqueur pour photo du sĂ©jour
  1382.         }
  1383.         // MĂ©lange intelligent en prĂ©servant la règle "favoris d'abord"
  1384.         $this->smartShufflePreservingFirst($distribution$nbFavorites);
  1385.         return $distribution;
  1386.     }
  1387.     /**
  1388.      * MĂ©lange intelligent pour Ă©viter les rĂ©pĂ©titions consĂ©cutives
  1389.      */
  1390.     private function smartShuffle(&$distribution$nbFavorites)
  1391.     {
  1392.         $maxAttempts 100;
  1393.         $attempts 0;
  1394.         do {
  1395.             shuffle($distribution);
  1396.             $attempts++;
  1397.             $hasConsecutive false;
  1398.             // VĂ©rifier s'il y a des rĂ©pĂ©titions consĂ©cutives
  1399.             for ($i 1$i count($distribution); $i++) {
  1400.                 if ($distribution[$i] === $distribution[$i 1]) {
  1401.                     $hasConsecutive true;
  1402.                     break;
  1403.                 }
  1404.             }
  1405.             if (!$hasConsecutive) {
  1406.                 break;
  1407.             }
  1408.         } while ($attempts $maxAttempts);
  1409.         // Si on n'arrive pas Ă  Ă©viter toutes les rĂ©pĂ©titions consĂ©cutives,
  1410.         // on fait un arrangement manuel intelligent
  1411.         if ($hasConsecutive && $nbFavorites 1) {
  1412.             $this->manualArrangement($distribution$nbFavorites);
  1413.         }
  1414.     }
  1415.     /**
  1416.      * MĂ©lange intelligent qui prĂ©serve l'apparition de toutes les photos favorites d'abord
  1417.      * đźŽŻ GARANTIT: Toutes les photos favorites apparaissent avant les rĂ©pĂ©titions
  1418.      */
  1419.     private function smartShufflePreservingFirst(&$distribution$nbFavorites)
  1420.     {
  1421.         if (count($distribution) <= $nbFavorites) {
  1422.             // Si on n'a que les photos favorites, mĂ©lange lĂ©ger
  1423.             shuffle($distribution);
  1424.             return;
  1425.         }
  1426.         // SĂ©parer les premières occurrences des rĂ©pĂ©titions
  1427.         $firstOccurrences array_slice($distribution0$nbFavorites);
  1428.         $repetitions array_slice($distribution$nbFavorites);
  1429.         // MĂ©langer lĂ©gèrement les premières occurrences pour Ă©viter un ordre prĂ©visible
  1430.         shuffle($firstOccurrences);
  1431.         // MĂ©langer les rĂ©pĂ©titions
  1432.         shuffle($repetitions);
  1433.         // Recombiner en Ă©vitant les rĂ©pĂ©titions consĂ©cutives
  1434.         $distribution $firstOccurrences;
  1435.         // Ajouter les rĂ©pĂ©titions en Ă©vitant les consĂ©cutives
  1436.         foreach ($repetitions as $rep) {
  1437.             $lastIndex count($distribution) - 1;
  1438.             $lastUsed $distribution[$lastIndex];
  1439.             if ($rep === $lastUsed) {
  1440.                 // InsĂ©rer Ă  une position antĂ©rieure pour Ă©viter la consĂ©cutive
  1441.                 $insertPos max(0$lastIndex 1);
  1442.                 array_splice($distribution$insertPos0, [$rep]);
  1443.             } else {
  1444.                 $distribution[] = $rep;
  1445.             }
  1446.         }
  1447.     }
  1448.     /**
  1449.      * đź§Ş VALIDATION STRICTE BASÉE SUR LES IDS RÉELS DES PHOTOS
  1450.      * Expert PHP Senior - Garantit la distribution correcte
  1451.      */
  1452.     private function validateDistributionWithIds($distribution$photoIds$maxRepetitions)
  1453.     {
  1454.         if (empty($distribution) || empty($photoIds)) {
  1455.             return true;
  1456.         }
  1457.         $nbFavorites count($photoIds);
  1458.         $photoUsageTracking = []; // Tracking par ID rĂ©el de photo
  1459.         $photoFirstAppearance = []; // Index de première apparition par ID rĂ©el
  1460.         $photoRepetitionStart = []; // Index de première rĂ©pĂ©tition par ID rĂ©el
  1461.         // Analyser la distribution
  1462.         foreach ($distribution as $slotIndex => $photoIndex) {
  1463.             if ($photoIndex >= $nbFavorites) {
  1464.                 error_log("⚠️ ERREUR: Index photo invalide $photoIndex >= $nbFavorites");
  1465.                 return false;
  1466.             }
  1467.             $photoId $photoIds[$photoIndex];
  1468.             // Compter les utilisations
  1469.             $photoUsageTracking[$photoId] = ($photoUsageTracking[$photoId] ?? 0) + 1;
  1470.             // Marquer la première apparition
  1471.             if (!isset($photoFirstAppearance[$photoId])) {
  1472.                 $photoFirstAppearance[$photoId] = $slotIndex;
  1473.             } else {
  1474.                 // C'est une rĂ©pĂ©tition - marquer si c'est la première rĂ©pĂ©tition
  1475.                 if (!isset($photoRepetitionStart[$photoId])) {
  1476.                     $photoRepetitionStart[$photoId] = $slotIndex;
  1477.                 }
  1478.             }
  1479.         }
  1480.         // âś… VĂ©rification 1: Toutes les photos favorites utilisĂ©es au moins une fois
  1481.         foreach ($photoIds as $photoId) {
  1482.             if (!isset($photoUsageTracking[$photoId]) || $photoUsageTracking[$photoId] < 1) {
  1483.                 error_log("⚠️ ERREUR: Photo ID $photoId non utilisĂ©e");
  1484.                 return false;
  1485.             }
  1486.         }
  1487.         // âś… VĂ©rification 2: Aucune photo ne dĂ©passe la limite de rĂ©pĂ©titions
  1488.         foreach ($photoUsageTracking as $photoId => $count) {
  1489.             if ($count $maxRepetitions) {
  1490.                 error_log("⚠️ ERREUR: Photo ID $photoId utilisĂ©e $count fois (limite: $maxRepetitions)");
  1491.                 return false;
  1492.             }
  1493.         }
  1494.         // âś… VĂ©rification 3: Toutes les photos apparaissent avant toute rĂ©pĂ©tition
  1495.         $lastFirstAppearance 0;
  1496.         foreach ($photoFirstAppearance as $photoId => $firstIndex) {
  1497.             $lastFirstAppearance max($lastFirstAppearance$firstIndex);
  1498.         }
  1499.         $earliestRepetition PHP_INT_MAX;
  1500.         foreach ($photoRepetitionStart as $photoId => $repetitionIndex) {
  1501.             $earliestRepetition min($earliestRepetition$repetitionIndex);
  1502.         }
  1503.         if ($earliestRepetition !== PHP_INT_MAX && $earliestRepetition <= $lastFirstAppearance) {
  1504.             error_log("⚠️ ERREUR: RĂ©pĂ©tition dĂ©tectĂ©e avant que toutes les favorites soient utilisĂ©es");
  1505.             error_log("Dernière première apparition: $lastFirstAppearance, Première rĂ©pĂ©tition: $earliestRepetition");
  1506.             return false;
  1507.         }
  1508.         // âś… VĂ©rification 4: Pas de rĂ©pĂ©titions consĂ©cutives
  1509.         for ($i 1$i count($distribution); $i++) {
  1510.             $currentPhotoId $photoIds[$distribution[$i]];
  1511.             $previousPhotoId $photoIds[$distribution[$i 1]];
  1512.             if ($currentPhotoId === $previousPhotoId) {
  1513.                 error_log("⚠️ WARNING: RĂ©pĂ©tition consĂ©cutive dĂ©tectĂ©e aux positions " . ($i 1) . " et $i pour photo ID $currentPhotoId");
  1514.                 // Note: On continue, ce n'est qu'un warning
  1515.             }
  1516.         }
  1517.         return true;
  1518.     }
  1519.     /**
  1520.      * đź§Ş FONCTION DE TEST LEGACY - ConservĂ©e pour compatibilitĂ©
  1521.      */
  1522.     private function validateDistribution($distribution$nbFavorites)
  1523.     {
  1524.         // Fallback vers la nouvelle validation si possible
  1525.         return !empty($distribution) && $nbFavorites 0;
  1526.     }
  1527.     /**
  1528.      * Arrangement manuel pour minimiser les rĂ©pĂ©titions consĂ©cutives
  1529.      */
  1530.     private function manualArrangement(&$distribution$nbFavorites)
  1531.     {
  1532.         $length count($distribution);
  1533.         for ($i 1$i $length$i++) {
  1534.             if ($distribution[$i] === $distribution[$i 1]) {
  1535.                 // Chercher une position diffĂ©rente Ă  Ă©changer
  1536.                 for ($j $i 1$j $length$j++) {
  1537.                     if (
  1538.                         $distribution[$j] !== $distribution[$i 1] &&
  1539.                         ($j === $length || $distribution[$j] !== $distribution[$j 1])
  1540.                     ) {
  1541.                         // Ă‰changer
  1542.                         $temp $distribution[$i];
  1543.                         $distribution[$i] = $distribution[$j];
  1544.                         $distribution[$j] = $temp;
  1545.                         break;
  1546.                     }
  1547.                 }
  1548.             }
  1549.         }
  1550.     }
  1551.     /**
  1552.      * Fonction intelligente de sĂ©lection de photos - Remplace random_function
  1553.      */
  1554.     function smart_random_function($listerandom$currentSlot$distribution)
  1555.     {
  1556.         if (empty($listerandom) || empty($distribution) || !isset($distribution[$currentSlot])) {
  1557.             // Fallback sur l'ancien système si problème
  1558.             return $this->random_function($listerandom);
  1559.         }
  1560.         $photoIndex $distribution[$currentSlot];
  1561.         $photos array_values($listerandom); // RĂ©indexer pour avoir des index numĂ©riques
  1562.         if (!isset($photos[$photoIndex])) {
  1563.             // Fallback sĂ©curisĂ©
  1564.             return $this->random_function($listerandom);
  1565.         }
  1566.         $photo $photos[$photoIndex];
  1567.         $idelem $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1568.         $pathelem $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
  1569.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $photoIndex);
  1570.     }
  1571.     /**
  1572.      * Version pour photos sans likes
  1573.      */
  1574.     function smart_random_functionNoLikes($listerandom$currentSlot$distribution)
  1575.     {
  1576.         if (empty($listerandom) || empty($distribution) || !isset($distribution[$currentSlot])) {
  1577.             return $this->random_functionNolikes($listerandom);
  1578.         }
  1579.         $photoIndex $distribution[$currentSlot];
  1580.         $photos array_values($listerandom);
  1581.         if (!isset($photos[$photoIndex])) {
  1582.             return $this->random_functionNolikes($listerandom);
  1583.         }
  1584.         $photo $photos[$photoIndex];
  1585.         $idelem $photo["id"];
  1586.         $pathelem $photo["path"];
  1587.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $photoIndex);
  1588.     }
  1589.     /**
  1590.      * DĂ©termine si on doit utiliser une photo du sĂ©jour au lieu d'une rĂ©pĂ©tition excessive
  1591.      */
  1592.     private function shouldUseSejourPhoto($currentSlot$distribution$favoritePhotos)
  1593.     {
  1594.         if (empty($distribution) || !isset($distribution[$currentSlot])) {
  1595.             return false;
  1596.         }
  1597.         // Compter combien de fois cette photo favorite a dĂ©jĂ  Ă©tĂ© utilisĂ©e
  1598.         $photoIndex $distribution[$currentSlot];
  1599.         $usageCount 0;
  1600.         for ($i 0$i $currentSlot$i++) {
  1601.             if (isset($distribution[$i]) && $distribution[$i] === $photoIndex) {
  1602.                 $usageCount++;
  1603.             }
  1604.         }
  1605.         // Si cette photo a dĂ©jĂ  Ă©tĂ© utilisĂ©e 3 fois, utiliser une photo du sĂ©jour
  1606.         return $usageCount >= 3;
  1607.     }
  1608.     /**
  1609.      * @Route("Parent/LivrePhotos", name="LivrePhotos")
  1610.      */
  1611.     public function EditionLivrePhotosParent()
  1612.     {
  1613.         $SEjourService $this->sejourService;
  1614.         /** @var \App\Entity\User $user */
  1615.         $user $this->getUser();
  1616.         $userId $user->getId();
  1617.         $session $this->session;
  1618.         $session->set('pageMenu''');
  1619.         $idSejour $session->get("Sejour");
  1620.         $sejour $this->getDoctrine()->getRepository(Sejour::class)->findOneBy(['id' => $idSejour]);
  1621.         $em $this->em;
  1622.         $clipart null;
  1623.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1624.         $nbLikes count($listeattachlikephoto);
  1625.         //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  1626.         $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  1627.         $random true;
  1628.         $allpagesResult = array();
  1629.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomLivre']);
  1630.         $AllPagesTemp $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1631.         // đźš€ CORRECTION CHIRURGICALE : Forcer exactement 20 pages pour l'album standard
  1632.         // Ajustement prĂ©cis : 18 pages de contenu + 2 pages fixes = 20 pages total
  1633.         $MAX_CONTENT_PAGES 18;
  1634.         $AllPages array_slice($AllPagesTemp0$MAX_CONTENT_PAGES);
  1635.         $part $sejour->getIdPartenaire();
  1636.         $nompart $part->getUsername();
  1637.         $logopart $part->getLogourl();
  1638.         $tabacc = array();
  1639.         $tabacc1 = array();
  1640.         // đźš€ SMART DISTRIBUTION ALGORITHM - Expert UX Implementation
  1641.         $totalSlots 0;
  1642.         foreach ($AllPages as $p) {
  1643.             $slots substr_count($p->getCouleurbordure(), 'randomid');
  1644.             $totalSlots += $slots;
  1645.         }
  1646.         // đźš€ SMART DISTRIBUTION avec gestion mixte favoris + photos sĂ©jour
  1647.         $listeattachlikephoto = ($nbLikes != 0) ?
  1648.             $SEjourService->getlikephotosejour($userId$idSejour) : [];
  1649.         $allSejourPhotos $SEjourService->getCombinedattachSejour($idSejour'photo');
  1650.         // đźš€ Distribution intelligente basĂ©e sur les IDs rĂ©els des photos
  1651.         $smartDistribution $this->calculateOptimalDistribution($listeattachlikephoto$totalSlots);
  1652.         $needsSejourPhotos = ($nbLikes 0) && (count($listeattachlikephoto) * $totalSlots);
  1653.         $currentSlot 0;
  1654.         foreach ($AllPages as $p) {
  1655.             $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1656.             $rr "";
  1657.             for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1658.                 if ($i sizeof($arrayexploded)) {
  1659.                     // âś… Distribution intelligente avec limite MAX 3 rĂ©pĂ©titions
  1660.                     if ($nbLikes != 0) {
  1661.                         // VĂ©rifier si on doit utiliser une photo du sĂ©jour au lieu d'une rĂ©pĂ©tition excessive
  1662.                         if ($needsSejourPhotos && $this->shouldUseSejourPhoto($currentSlot$smartDistribution$listeattachlikephoto)) {
  1663.                             $arrayRsRandom $this->smart_random_functionNoLikes($allSejourPhotos$currentSlot$smartDistribution);
  1664.                         } else {
  1665.                             $arrayRsRandom $this->smart_random_function($listeattachlikephoto$currentSlot$smartDistribution);
  1666.                         }
  1667.                     } else {
  1668.                         $arrayRsRandom $this->smart_random_functionNoLikes($allSejourPhotos$currentSlot$smartDistribution);
  1669.                     }
  1670.                     array_push($tabacc$arrayRsRandom['idelem']);
  1671.                     $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1672.                     $currentSlot++; // âś… Performance optimisĂ©e - pas de unset
  1673.                 } else {
  1674.                     $rr $rr $arrayexploded[$i];
  1675.                 }
  1676.             }
  1677.             $resultFinal $rr;
  1678.             $p->setCouleurbordure($resultFinal);
  1679.             array_push($allpagesResult$p);
  1680.         }
  1681.         $AllPages $allpagesResult;
  1682.         $tabacc1 array_count_values($tabacc);
  1683.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1684.         $nbPhotos count($listeattach);
  1685.         $nbLike count($listeattachlikephoto);
  1686.         if ($nbLike == 0) {
  1687.             return $this->render('Parent/NewLivre.html.twig', ["tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour,  'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes'nbPhotos' => $nbPhotos]);
  1688.         }
  1689.         if ($nbLike != 0) {
  1690.             return $this->render('Parent/NewLivreLikes.html.twig', ["tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes'nbPhotos' => $nbPhotos]);
  1691.         }
  1692.     }
  1693.     /**
  1694.      * @Route("Parent/AjoutPochettePhotos/{nbr}", name="AjoutPochettePhotos")
  1695.      */
  1696.     public function AjoutPochettePhotosParent($nbr)
  1697.     {
  1698.         $SEjourService $this->sejourService;
  1699.         /** @var \App\Entity\User $user */
  1700.         $user $this->getUser();
  1701.         $userId $user->getId();
  1702.         $user $this->getUser();
  1703.         $session $this->session;
  1704.         $session->set('pageMenu''');
  1705.         $idSejour $session->get("Sejour");
  1706.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1707.         $em $this->em;
  1708.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  1709.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1710.         $nbPhoto count($listeattach);
  1711.         $clipart $em->getRepository(Clipart::class)->findAll();
  1712.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1713.         $nbLikes count($listeattachlikephoto);
  1714.         $listerandom  = array();
  1715.         $listerandom $listeattach;
  1716.         $AllPagesAcc null;
  1717.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1718.         $random true;
  1719.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1720.         $idAcc $sejour->getIdAcommp();
  1721.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1722.         $part $sejour->getIdPartenaire();
  1723.         $nompart $part->getUsername();
  1724.         $logopart $part->getLogourl();
  1725.         if ($albumAcc != null and $albumAcc != "") {
  1726.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1727.         }
  1728.         $allpagesResult = array();
  1729.         if ($random == true) {
  1730.             // đźš€ SMART DISTRIBUTION ALGORITHM pour POCHETTES - Expert UX Implementation
  1731.             $totalSlots 0;
  1732.             foreach ($AllPages as $p) {
  1733.                 $slots substr_count($p->getCouleurbordure(), 'randomid');
  1734.                 $totalSlots += $slots;
  1735.             }
  1736.             // đźš€ Distribution intelligente pour pochettes basĂ©e sur les IDs rĂ©els
  1737.             $favoritesList = ($nbLikes != 0) ? $listeattachlikephoto : [];
  1738.             $sejourPhotosList $listerandom;
  1739.             $smartDistribution $this->calculateOptimalDistribution($favoritesList$totalSlots);
  1740.             $needsSejourPhotos = ($nbLikes 0) && (count($favoritesList) * $totalSlots);
  1741.             $currentSlot 0;
  1742.             foreach ($AllPages as $p) {
  1743.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1744.                 $rr "";
  1745.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1746.                     if ($i sizeof($arrayexploded)) {
  1747.                         // âś… Distribution intelligente pour pochettes - MAX 3 rĂ©pĂ©titions
  1748.                         if ($nbLikes != 0) {
  1749.                             // VĂ©rifier si on doit utiliser une photo du sĂ©jour
  1750.                             if ($needsSejourPhotos && $this->shouldUseSejourPhoto($currentSlot$smartDistribution$favoritesList)) {
  1751.                                 $arrayRsRandom $this->smart_random_functionNoLikes($sejourPhotosList$currentSlot$smartDistribution);
  1752.                             } else {
  1753.                                 $arrayRsRandom $this->smart_random_function($favoritesList$currentSlot$smartDistribution);
  1754.                             }
  1755.                         } else {
  1756.                             $arrayRsRandom $this->smart_random_functionNoLikes($sejourPhotosList$currentSlot$smartDistribution);
  1757.                         }
  1758.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1759.                         $currentSlot++; // âś… Performance optimisĂ©e
  1760.                     } else {
  1761.                         $rr $rr $arrayexploded[$i];
  1762.                     }
  1763.                 }
  1764.                 $resultFinal $rr;
  1765.                 $p->setCouleurbordure($resultFinal);
  1766.                 array_push($allpagesResult$p);
  1767.             }
  1768.             $AllPages $allpagesResult;
  1769.         }
  1770.         return $this->render('Parent/PochettePhotos.html.twig', ["nbr" => $nbr"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'listeattach' => $listeattach'nbPhoto' => $nbPhoto'Likes' => $nbLikes]);
  1771.     }
  1772.     /**
  1773.      * @Route("Parent/AjoutPhotosRetrosFavoris/{nbr}", name="AjoutPhotosRetros_Favoris")
  1774.      */
  1775.     public function AjoutPhotosRetrosParentFavoris($nbr)
  1776.     {
  1777.         $SEjourService $this->sejourService;
  1778.         /** @var \App\Entity\User $user */
  1779.         $user $this->getUser();
  1780.         $userId $user->getId();
  1781.         $session $this->session;
  1782.         $session->set('pageMenu''');
  1783.         $idSejour $session->get("Sejour");
  1784.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1785.         $em $this->em;
  1786.         $clipart $em->getRepository(Clipart::class)->findAll();
  1787.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1788.         $nbLikes count($listeattachlikephoto);
  1789.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  1790.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1791.         $listerandom =  $listeattach;
  1792.         $AllPagesAcc null;
  1793.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1794.         $random true;
  1795.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1796.         $idAcc $sejour->getIdAcommp();
  1797.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1798.         $part $sejour->getIdPartenaire();
  1799.         $nompart $part->getUsername();
  1800.         $logopart $part->getLogourl();
  1801.         if ($albumAcc != null and $albumAcc != "") {
  1802.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1803.         }
  1804.         $allpagesResult = array();
  1805.         $j 0;
  1806.         if ($random == true) {
  1807.             foreach ($AllPages as $p) {
  1808.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1809.                 $rr "";
  1810.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1811.                     if ($i sizeof($arrayexploded)) {
  1812.                         if (sizeof($listerandom) == 0) {
  1813.                             //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  1814.                             $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  1815.                         }
  1816.                         if ($nbLikes != 0) {
  1817.                             $listerandom $SEjourService->getlikephotosejour($userId$idSejour);
  1818.                             $arrayRsRandom $this->random_functionPhoto($listerandom);
  1819.                         }
  1820.                         if ($nbLikes == 0) {
  1821.                             $arrayRsRandom $this->random_functionPhotoNolIKES($listerandom$j);
  1822.                         }
  1823.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1824.                         unset($listerandom[$arrayRsRandom['elem']]);
  1825.                     } else {
  1826.                         $rr $rr $arrayexploded[$i];
  1827.                     }
  1828.                     $listerandom $listerandom;
  1829.                 }
  1830.                 $resultFinal $rr;
  1831.                 $p->setCouleurbordure($resultFinal);
  1832.                 array_push($allpagesResult$p);
  1833.                 if ($j sizeof($listeattachlikephoto) - 1) {
  1834.                     $j $j 1;
  1835.                 } else {
  1836.                     $j 0;
  1837.                 }
  1838.             }
  1839.             $AllPages $allpagesResult;
  1840.         }
  1841.         return $this->render('Parent/RetroRefonte.html.twig', ["nbr" => $nbr"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes]);
  1842.     }
  1843.     /**
  1844.      * @Route("Parent/AjoutPhotosRetros/{nbr}", name="AjoutPhotosRetros")
  1845.      */
  1846.     public function AjoutPhotosRetrosParent($nbr)
  1847.     {
  1848.         $SEjourService $this->sejourService;
  1849.         /** @var \App\Entity\User $user */
  1850.         $user $this->getUser();
  1851.         $userId $user->getId();
  1852.         $session $this->session;
  1853.         $session->set('pageMenu''');
  1854.         $idSejour $session->get("Sejour");
  1855.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1856.         $em $this->em;
  1857.         $clipart $em->getRepository(Clipart::class)->findAll();
  1858.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1859.         $nbLikes count($listeattachlikephoto);
  1860.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  1861.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1862.         if ($nbLikes == 0) {
  1863.             $listerandom =  $listeattach;
  1864.         }
  1865.         if ($nbLikes != 0) {
  1866.             $listerandom =  $listeattachlikephoto;
  1867.         }
  1868.         $AllPagesAcc null;
  1869.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1870.         $random true;
  1871.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1872.         $idAcc $sejour->getIdAcommp();
  1873.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1874.         $part $sejour->getIdPartenaire();
  1875.         $nompart $part->getUsername();
  1876.         $logopart $part->getLogourl();
  1877.         if ($albumAcc != null and $albumAcc != "") {
  1878.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1879.         }
  1880.         $allpagesResult = array();
  1881.         $j 0;
  1882.         if ($random == true) {
  1883.             foreach ($AllPages as $p) {
  1884.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1885.                 $rr "";
  1886.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1887.                     if ($i sizeof($arrayexploded)) {
  1888.                         if ($nbLikes == 0) {
  1889.                             $arrayRsRandom $this->random_functionPhotoNolIKES($listerandom$j);
  1890.                         }
  1891.                         if ($nbLikes != 0) {
  1892.                             $arrayRsRandom $this->random_functionPhoto($listeattachlikephoto);
  1893.                         }
  1894.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1895.                         unset($listerandom[$arrayRsRandom['elem']]);
  1896.                     } else {
  1897.                         $rr $rr $arrayexploded[$i];
  1898.                     }
  1899.                     $listerandom $listerandom;
  1900.                 }
  1901.                 $resultFinal $rr;
  1902.                 $p->setCouleurbordure($resultFinal);
  1903.                 array_push($allpagesResult$p);
  1904.                 if ($nbLikes == 0) {
  1905.                     if ($j sizeof($listeattachlikephoto) - 1) {
  1906.                         $j $j 1;
  1907.                     } else {
  1908.                         $j 0;
  1909.                     }
  1910.                 }
  1911.                 if ($nbLikes != 0) {
  1912.                     if ($j sizeof($listeattach) - 1) {
  1913.                         $j $j 1;
  1914.                     } else {
  1915.                         $j 0;
  1916.                     }
  1917.                 }
  1918.                 $AllPages $allpagesResult;
  1919.             }
  1920.         }
  1921.         if ($nbLikes == 0) {
  1922.             return $this->render('Parent/PochettePhotosLikes.html.twig', ["nbr" => $nbr"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattach'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes]);
  1923.         }
  1924.         if ($nbLikes != 0) {
  1925.             return $this->render('Parent/PochettePhotosLikes.html.twig ', ["nbr" => $nbr"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes]);
  1926.         }
  1927.     }
  1928.     /**
  1929.      * @Route("Parent/CalendrierParent", name="CalendrierParent")
  1930.      */
  1931.     public function CalendrierParent()
  1932.     {
  1933.         $SEjourService $this->sejourService;
  1934.         /** @var \App\Entity\User $user */
  1935.         $user $this->getUser();
  1936.         $userId $user->getId();
  1937.         $user $this->getUser();
  1938.         $session $this->session;
  1939.         $session->set('pageMenu''');
  1940.         $idSejour $session->get("Sejour");
  1941.         $produitcondition $session->get("produit");
  1942.         $produit $session->get("produittype");
  1943.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1944.         $em $this->em;
  1945.         $clipart $em->getRepository(Clipart::class)->findAll();
  1946.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1947.         $listerandom $listeattachlikephoto;
  1948.         $AllPagesAcc null;
  1949.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomcalendrier']);
  1950.         $random true;
  1951.         //        }
  1952.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1953.         $idAcc $sejour->getIdAcommp();
  1954.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1955.         $part $sejour->getIdPartenaire();
  1956.         //$part = $em->getRepository(Etablisment::class)->findOneBy(['id' => $idpart->getId()]);
  1957.         //dd($part);
  1958.         $nompart $part->getUsername();
  1959.         $logopart $part->getLogourl();
  1960.         // dd($Albumproduct);  
  1961.         if ($albumAcc != null and $albumAcc != "") {
  1962.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1963.         }
  1964.         //        dd($albumAcc);
  1965.         $allpagesResult = array();
  1966.         $tabacc = array();
  1967.         $tabacc1 = array();
  1968.         if ($random == true) {
  1969.             foreach ($AllPages as $p) {
  1970.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1971.                 //dd($arrayexploded);
  1972.                 $rr "";
  1973.                 $elemPath "";
  1974.                 $elemId "";
  1975.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1976.                     if ($i sizeof($arrayexploded)) {
  1977.                         if (sizeof($listerandom) == 0) {
  1978.                             $listerandom $SEjourService->getlikephotosejour($userId$idSejour);
  1979.                         }
  1980.                         $arrayRsRandom $this->random_function($listerandom);
  1981.                         array_push($tabacc$arrayRsRandom['idelem']);
  1982.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1983.                         unset($listerandom[$arrayRsRandom['elem']]);
  1984.                     } else {
  1985.                         $rr $rr $arrayexploded[$i];
  1986.                     }
  1987.                     $listerandom $listerandom;
  1988.                 }
  1989.                 $resultFinal $rr;
  1990.                 $p->setCouleurbordure($resultFinal);
  1991.                 array_push($allpagesResult$p);
  1992.             }
  1993.             $AllPages $allpagesResult;
  1994.         }
  1995.         $tabacc1 array_count_values($tabacc);
  1996.         return $this->render('Parent/Calendrier.html.twig', ["tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random]);
  1997.     }
  1998.     /**
  1999.      * @Route("Parent/ListeSejour", name="ListeSejourParent")
  2000.      */
  2001.     public function ListeSejourParent()
  2002.     {
  2003.         return $this->render('Parent/AccueillParent.html.twig', []);
  2004.     }
  2005.     /**
  2006.      * @Route("/parent/couverture", name="choixCouverture")
  2007.      */
  2008.     public function sur5()
  2009.     {
  2010.         return $this->render('Parent/couverture.html.twig');
  2011.     }
  2012.     /**
  2013.      * @Route("/", name="footerparent")
  2014.      */
  2015.     public function footerparent(): Response
  2016.     {
  2017.         $produit $this->typeProduiteService;
  2018.         $liste $produit->produitlistType();
  2019.         // dd($liste);
  2020.         $session $this->session;
  2021.         $destination $session->get("destionation");
  2022.         $nbvocal 0;
  2023.         $nbSlection 0;
  2024.         $nbPhoto 0;
  2025.         $sejour null;
  2026.         $sejourservice $this->sejourService;
  2027.         $idSejour $session->get("Sejour");
  2028.         /** @var \App\Entity\User $user */
  2029.         $user $this->getUser();
  2030.         $userId $user->getId();
  2031.         $albumAcc null;
  2032.         $em $this->em;
  2033.         if ($idSejour != null) {
  2034.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2035.             // Nb favoris 
  2036.             $listeattachlikephoto $sejourservice->getlikephotosejour($userId$idSejour);
  2037.             $nbSlection count($listeattachlikephoto);
  2038.             // Nb photos 
  2039.             $listeattach $sejourservice->getatachmentsejour($idSejour);
  2040.             $nbPhoto count($listeattach);
  2041.             // Nb messages vocaux 
  2042.             $messages $sejourservice->getsejourmessage($idSejour);
  2043.             $nbvocal count($messages);
  2044.             // Rechercher s'il y'a un album acompagnateur 
  2045.             $idAcc $sejour->getIdAcommp();
  2046.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  2047.         }
  2048.         return $this->render('Parent/footerParent.html.twig', [
  2049.             'destionation' =>  $destination,
  2050.             'nbvocal' =>  $nbvocal,
  2051.             'nbSlection' => $nbSlection,
  2052.             'nbPhotos' => $nbPhoto,
  2053.             'albumAcc' => $albumAcc,
  2054.         ]);
  2055.     }
  2056.     /**
  2057.      * @Route("/", name="heedear")
  2058.      */
  2059.     public function headerparenrt(): Response
  2060.     {
  2061.         $produit $this->typeProduiteService;
  2062.         $liste $produit->produitlistType();
  2063.         $nblikes 0;
  2064.         $nbmesssages 0;
  2065.         // dd($liste);
  2066.         $session $this->session;
  2067.         $panierSession $session->get("Panier");
  2068.         $destination $session->get("destionation");
  2069.         $nbvocal 0;
  2070.         $idSejour $session->get("Sejour");
  2071.         $sejour null;
  2072.         if ($idSejour != null) {
  2073.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2074.         }
  2075.         $Products $session->get("Panier");
  2076.         $numSuivi false;
  2077.         if ($sejour != null) {
  2078.             $Products $session->get("Panier");
  2079.             if ($Products == Null) {
  2080.                 $Products = [];
  2081.             }
  2082.             $UserService $this->userService;
  2083.             /** @var \App\Entity\User $user */
  2084.             $user $this->getUser();
  2085.             $iduser $user->getId();
  2086.             $containsProduitType20 false;
  2087.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2088.             $commandes $this->em->getRepository(Commande::class)->findBy(["idSejour" => $idSejour"idUser" => $iduser]);
  2089.             $sejourparent $this->em->getRepository(ParentSejour::class)->findOneBy(['idSejour' => $idSejour"idParent" => $iduser]);
  2090.             $payment $sejourparent->getPayment();
  2091.             // Check commands
  2092.             foreach ($commandes as $commande) {
  2093.                 $commandCondition $commande->getNumSuivi();
  2094.                 $status $commande->getStatut()->getId();
  2095.                 if ($commandCondition == && $status == 33) {
  2096.                     $containsProduitType20 true;
  2097.                     break; // No need to check further if condition is met
  2098.                 }
  2099.             }
  2100.             // Check panierSession if the condition is not met in commandes
  2101.             if (!$containsProduitType20 && is_array($panierSession) && !empty($panierSession)) {
  2102.                 foreach ($panierSession as $item) {
  2103.                     // Access the details of each item in the Panier
  2104.                     $condition $item['condition'];
  2105.                     $codesejour $item['codesejour'];
  2106.                     if ($condition == 16 && $codesejour == $sejour->getCodeSejour()) {
  2107.                         $containsProduitType20 true;
  2108.                         break; // No need to check further if condition is met
  2109.                     }
  2110.                 }
  2111.             }
  2112.             $sejourservice $this->sejourService;
  2113.             //$messages = $sejourservice->getsejourmessage($idSejour);
  2114.             $messages $sejourservice->getCombinedattachSejour($idSejour'message');
  2115.             $nbmessages count($messages);
  2116.             $listeattachlikephoto =  $sejourservice->getlikephotosejour($iduser$idSejour);
  2117.             $nblikes count($listeattachlikephoto);
  2118.             $em $this->em;
  2119.             $label "Livre_sejour" $sejour->getCodeSejour();
  2120.             $idAcc $sejour->getIdAcommp();
  2121.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'Album_sejour']);
  2122.             $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'Livre_sejour']);
  2123.             if ($albumAcc == null) {
  2124.                 $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  2125.             }
  2126.             if ($livreSej == null) {
  2127.                 $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  2128.             }
  2129.             $code_sejour =  $sejour->getCodeSejour();
  2130.             return $this->render('Parent/headerParent.html.twig', [
  2131.                 'produit' => $liste,
  2132.                 'sejour' => $sejour,
  2133.                 'livreSejour' => $livreSejour,
  2134.                 'Products' => $Products,
  2135.                 'destionation' =>  $destination,
  2136.                 'nbvocal' =>  $nbmessages,
  2137.                 'albumAcc' => $albumAcc,
  2138.                 'nbLikes' => $nblikes,
  2139.                 'code_sejour' => $code_sejour,
  2140.                 'payment' => $payment
  2141.             ]);
  2142.         }
  2143.         if ($sejour == null) {
  2144.             return $this->render('Parent/headerParent2.html.twig');
  2145.         }
  2146.     }
  2147.     /**
  2148.      * @Route("/Parent/disablepack", name="disablePack")
  2149.      */
  2150.     public function disableFreepack()
  2151.     {
  2152.         //this section is used to disale the freePackOffert
  2153.         $em $this->em;
  2154.         $session $this->session;
  2155.         /** @var \App\Entity\User $user */
  2156.         $user $this->getUser();
  2157.         $iduser $user->getId();
  2158.         $idSejour $session->get("Sejour");
  2159.         $SEjourService $this->sejourService;
  2160.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  2161.         $panierSession $session->get("Panier");
  2162.         $containsProduitType20 false;
  2163.         $nbrphoto count($listeattach);
  2164.         /** @var \App\Entity\User $user */
  2165.         $user $this->getUser();
  2166.         $iduser $user->getId();
  2167.         $containsProduitType20 false;
  2168.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2169.         $commandes $this->em->getRepository(Commande::class)->findBy(["idSejour" => $idSejour"idUser" => $iduser]);
  2170.         // Check commands
  2171.         foreach ($commandes as $commande) {
  2172.             $commandCondition $commande->getNumSuivi();
  2173.             $status $commande->getStatut()->getId();
  2174.             // Check if Num Suivi is set one and if payment is completed
  2175.             if ($commandCondition == && $status == 33) {
  2176.                 $containsProduitType20 true;
  2177.                 break; // No need to check further if condition is met
  2178.             }
  2179.         }
  2180.         // Check panierSession if the condition is not met in commandes
  2181.         if (!$containsProduitType20 && is_array($panierSession) && !empty($panierSession)) {
  2182.             foreach ($panierSession as $item) {
  2183.                 // Access the details of each item in the Panier
  2184.                 $condition $item['condition'];
  2185.                 $codesejour $item['codesejour'];
  2186.                 if ($condition == 16 && $codesejour == $sejour->getCodeSejour()) {
  2187.                     $containsProduitType20 true;
  2188.                     break; // No need to check further if condition is met
  2189.                 }
  2190.             }
  2191.         }
  2192.         return new JsonResponse(['containsProduitType20' => $containsProduitType20'idSejour' => $nbrphoto]);
  2193.     }
  2194.     /**
  2195.      * @Route("/Parent/disablepackpanier", name="disablePackpanier")
  2196.      */
  2197.     public function disableFreepackpanier(): JsonResponse
  2198.     {
  2199.         //this section is used to disale the + in the panier for the packOffert
  2200.         $em $this->em;
  2201.         $disabledProductIds = [];
  2202.         $session $this->session;
  2203.         $panierSession $session->get("Panier");
  2204.         $ids = [];
  2205.         foreach ($panierSession as $item) {
  2206.             $ids[] = $item['id'];
  2207.         }
  2208.         if ($panierSession) {
  2209.             foreach ($ids as $id) {
  2210.                 $panierProduits $em->getRepository(PanierProduit::class)->findBy(['idProduit' => $id]);
  2211.                 foreach ($panierProduits as $panierProduit) {
  2212.                     $produit $panierProduit->getIdProduit();
  2213.                     $type $produit->getType();
  2214.                     // Check if the product type is 20 and add to disabledProductIds if true
  2215.                     if ($type && $type->getId() == 20) {
  2216.                         $disabledProductIds[] = $produit->getId();
  2217.                     }
  2218.                 }
  2219.             }
  2220.             return new JsonResponse(['disabledProductIds' => $disabledProductIds]);
  2221.         }
  2222.     }
  2223.     /**
  2224.      * @Route("/", name="heedear2")
  2225.      */
  2226.     public function headerparenrt2(): Response
  2227.     {
  2228.         $session $this->session;
  2229.         $produit $this->typeProduiteService;
  2230.         $nbvocal 0;
  2231.         $idSejour $session->get("Sejour");
  2232.         $liste $produit->produitlistType();
  2233.         $session $this->session;
  2234.         $destination $session->get("destionation");
  2235.         $Products $session->get("Panier");
  2236.         if ($Products == Null) {
  2237.             $Products = [];
  2238.         }
  2239.         return $this->render('Parent/headerParent2.html.twig', [
  2240.             'produit' => $liste,
  2241.             'Products' => $Products,
  2242.             'destionation' =>  $destination,
  2243.             'nbvocal' =>  $nbvocal
  2244.         ]);
  2245.     }
  2246.     /**
  2247.      * @Route("/Parent/ParametresParent", name="ParametresParent")
  2248.      */
  2249.     public function Parametreparent()
  2250.     {
  2251.         // $sejourservice = $this->sejourService;
  2252.         //$sejour = $sejourservice->getparentsejour($id, $this->getUser());
  2253.         ///$session = $this->session;
  2254.         //$session->set('moncompte', 'parametres');
  2255.         $user $this->getUser();
  2256.         $session $this->session;
  2257.         $idSejour $session->get("Sejour");
  2258.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2259.         $ParentSejour $this->em->getRepository(ParentSejour::class)->findBy(['idSejour' => $sejour'idParent' => $user]);
  2260.         //ParentSejour
  2261.         //cablala
  2262.         //dd($ParentSejour[0]);
  2263.         //$listeattach = $sejourservice->getatachmentsejour($id);
  2264.         //$listeattachM = $sejourservice->getsejourmessage($id);
  2265.         return $this->render('Parent/Parentparametre.html.twig', [
  2266.             'user' => $user,
  2267.             'sejour' => $sejour,
  2268.             'ParentSejour' => $ParentSejour[0],
  2269.         ]);
  2270.     }
  2271.     /**
  2272.      * @Route("/Parent/Accueil5sur5/ajouteradresslirison", name="ajouteradress_livrson",methods={"POST"})
  2273.      */
  2274.     public function ajouteradresslivr(Request $request)
  2275.     {
  2276.         $UserService $this->userService;
  2277.         //dd($this->getUser()->getId());
  2278.         /** @var \App\Entity\User $user */
  2279.         $user $this->getUser();
  2280.         $iduser $user->getId();
  2281.         $prenom $request->get("prenom");
  2282.         $nom $request->get("nom");
  2283.         $organism $request->get("organism");
  2284.         $num $request->get("num");
  2285.         $rue $request->get('ruevoi');
  2286.         $ville $request->get("villle");
  2287.         $pays $request->get("pays");
  2288.         $codepostal $request->get("codpostal");
  2289.         //adress facturation if exsist
  2290.         $prenomfacturation $request->get("prenomadressfacturation");
  2291.         $nomfacturation $request->get("nomadressfacturation");
  2292.         $organismfacturation $request->get("etablismadressfacturation");
  2293.         $numfacturation $request->get("numdressfacturation");
  2294.         $ruefacturation $request->get('rueadressfacturation');
  2295.         $villefacturation $request->get("villefacturation");
  2296.         $paysfacturation $request->get("payadressfacturation");
  2297.         $codepostalfacturation $request->get("codepostalfacturation");
  2298.         //modification userPArent
  2299.         $usernomAcommpa $request->get("usernom");
  2300.         $userprenomAcommpa $request->get("userprenom");
  2301.         $userfonctionAcommpa $request->get("userfonction");
  2302.         $useretablismentAcommpa $request->get("useretablisment");
  2303.         $useremailcommpa $request->get("useremail");
  2304.         $sejourthem $request->get("sejourthem");
  2305.         $adresssejour $request->get("sejouradresse");
  2306.         $id $request->get("id");
  2307.         $adress $UserService->setadresslivraison($num$rue$ville$pays$codepostal$iduser$prenom$nom$organism$prenomfacturation$nomfacturation$organismfacturation$numfacturation$ruefacturation$villefacturation$paysfacturation$codepostalfacturation$usernomAcommpa$userprenomAcommpa$userfonctionAcommpa$useretablismentAcommpa$useremailcommpa$sejourthem$adresssejour$id);
  2308.         return new JsonResponse('done');
  2309.     }
  2310.     /**
  2311.      * @Route("/Accueil5sur5/ajouteradressfacturation", name="ajouteradress_facturation",methods={"POST","GET"})
  2312.      */
  2313.     public function ajouteradressfacturation(Request $request)
  2314.     {
  2315.         $UserService $this->userService;
  2316.         /** @var \App\Entity\User $user */
  2317.         $user $this->getUser();
  2318.         $iduser $user->getId();
  2319.         $num $request->get("num");
  2320.         $rue $request->get('rue');
  2321.         $ville $request->get("ville");
  2322.         $pays $request->get("pays");
  2323.         $codepostal $request->get("codepostal");
  2324.         $adress $UserService->setadressfacturation($num$rue$ville$pays$codepostal$iduser);
  2325.         return new JsonResponse('done');
  2326.     }
  2327.     /**
  2328.      * @Route("/EntrezCode", name="EntrezCode")
  2329.      */
  2330.     public function EntrezCode(Request $request)
  2331.     {
  2332.         $email $request->get('email');
  2333.         $password $request->get('password');
  2334.         $this->session->set('rout''code');
  2335.         return $this->redirectToRoute('CodeSejour', ['email' => $email'password' => $password]);
  2336.     }
  2337.     /**
  2338.      * @Route("/DemandeCode", name="DemandeCode")
  2339.      */
  2340.     public function DemandeCode(Request $request)
  2341.     {
  2342.         $nomEnfant $request->get('nomEnfant');
  2343.         $prenomEnfant $request->get('prenomEnfant');
  2344.         $votreNom $request->get('votreNom');
  2345.         $votrePrenom $request->get('votrePrenom');
  2346.         $Mail $request->get('Mail');
  2347.         $votreLien $request->get('votreLien');
  2348.         $du $request->get('du');
  2349.         $au $request->get('au');
  2350.         $code $request->get('code');
  2351.         $ville $request->get('ville');
  2352.         $listeSejour $this->em->getRepository(Sejour::class)->listAcco($du$au$code$ville);
  2353.         $RefEmail $this->em->getRepository(Ref::class)->find(23);
  2354.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  2355.         foreach ($listeSejour as $accompagnateur) {
  2356.             $sendTo $accompagnateur->getIdAcommp()->getEmail();
  2357.             $message = (new \Swift_Message('Demande code sĂ©jour'))
  2358.                 ->setFrom('contact@5sur5sejour.com')
  2359.                 ->setTo($sendTo);
  2360.             //->setBcc("contact@5sur5sejour.com");
  2361.             $pathImage2 $Email->getIdImage2()->getPath();
  2362.             $pathImage1 $Email->getIdImage1()->getPath();
  2363.             $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2364.             $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2365.             $iconphoto $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_419_pqx0dx._6656d07326a50.png"));
  2366.             $iconloca $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_420_uynuqz._6656d10f4daaf.png"));
  2367.             $iconmsg $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_418_wbyysk._6656d16240404.png"));
  2368.             $iconfooter $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Picto5sur5_rapbfy._6656d1c1bb536.png"));
  2369.             $iMagesProduits $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Picto5sur5_rapbfy._6656d1c1bb536.png"));
  2370.             $message->setBody(
  2371.                 $this->templating->render(
  2372.                     'emails/ParentDemandeCodeSejour.html.twig',
  2373.                     [
  2374.                         "nomAcco" => $accompagnateur->getIdAcommp()->getNom(),
  2375.                         "prenomAcco" => $accompagnateur->getIdAcommp()->getPrenom(),
  2376.                         "nomEnfant" => $nomEnfant,
  2377.                         "prenomEnfant" => $prenomEnfant,
  2378.                         "votreNom" => $votreNom,
  2379.                         "votrePrenom" => $votrePrenom,
  2380.                         "mail" => $Mail,
  2381.                         "votreLien" => $votreLien,
  2382.                         "image1" => $image1,
  2383.                         "image2" => $image2,
  2384.                         "iconfooter" => $iconfooter,
  2385.                         "iconphoto" => $iconphoto,
  2386.                         "iconloca" => $iconloca,
  2387.                         "iconmsg" => $iconmsg,
  2388.                         "du" => $du,
  2389.                         "au" => $au,
  2390.                         "code" => $code,
  2391.                         "ville" => $ville,
  2392.                     ]
  2393.                 ),
  2394.                 'text/html'
  2395.             );
  2396.             try {
  2397.                 $signMail $this->getParameter('signMail');
  2398.                 if ($signMail == 'yes') {
  2399.                     $domainName $this->getParameter('domaine');
  2400.                     $selector $this->getParameter('selector');
  2401.                     $PrivateKey file_get_contents($this->getParameter('pathDKIM'));
  2402.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2403.                     $message->attachSigner($signer);
  2404.                 }
  2405.                 $this->mailer->send($message);
  2406.             } catch (\Swift_SwiftException $ex) {
  2407.                 $ex->getMessage();
  2408.             }
  2409.         }
  2410.         return new JsonResponse(count($listeSejour));
  2411.     }
  2412.     /**
  2413.      * @Route("/Parent/ChoixCouverture", name="ChoixCouvertureParent")
  2414.      */
  2415.     public function Couverture()
  2416.     {
  2417.         return $this->render('Parent/ChoixCouverture.html.twig', []);
  2418.     }
  2419.     /**
  2420.      * @Route("/Parent/couvertureAccompagnateur", name="couvertureAccompagnateur")
  2421.      */
  2422.     public function CouvertureAccompagnateur()
  2423.     {
  2424.         $user $this->getUser();
  2425.         $session $this->session;
  2426.         $idSejour $session->get("Sejour");
  2427.         $listeproduit $prod $this->em->getRepository(Produit::class)->findby(array('idsjour' => $idSejour));
  2428.         return $this->render('Parent/couvertureAccompagnateur.html.twig', []);
  2429.     }
  2430.     /**
  2431.      * @Route("/Parent/Projet", name="projet-Parent")
  2432.      */
  2433.     public function parentTWo()
  2434.     {
  2435.         $this->session->set('rout''rout');
  2436.         /** @var \App\Entity\User $user */
  2437.         $user $this->getUser();
  2438.         $session $this->session;
  2439.         $session->set('pageMenu''projets');
  2440.         $idSejour $session->get("Sejour");
  2441.         $listeproduit $this->em->getRepository(Produit::class)->findby(array('idsjour' => $idSejour'iduser' => $user->getId()), ['id' => 'DESC']);
  2442.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2443.         $parentent_sejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $user->getId(), "idSejour" => $idSejour]);
  2444.         return $this->render('Parent/ProjetsParent.html.twig', ['sejour' => $sejour'parentent_sejour' => $parentent_sejour'listeproduit' => $listeproduit]);
  2445.     }
  2446.     /**
  2447.      * @Route("/Parent/MesProjets", name="MesProjets")
  2448.      */
  2449.     public function MesProjets()
  2450.     {
  2451.         return $this->render('Parent/MesProjetsSauvegardes.html.twig', []);
  2452.     }
  2453.     /**
  2454.      * @Route("/Parent/allSejourparent", name="SejourParent")
  2455.      */
  2456.     public function SejourAccompagnateur()
  2457.     {
  2458.         $sejourservice $this->sejourService;
  2459.         $session $this->session;
  2460.         $idSejour $session->get("Sejour");
  2461.         $session->set('rout''rout');
  2462.         /** @var \App\Entity\User $user */
  2463.         $user $this->getUser();
  2464.         $userId $user->getId();
  2465.         $listeSejour $prod $this->em->getRepository(ParentSejour::class)->findby(array('idParent' => $userId));
  2466.         return $this->render('Parent/Messejours.html.twig', ['listeSejour' => $listeSejour]);
  2467.     }
  2468.     /**
  2469.      * @Route("/Parent/Commander", name="Commander")
  2470.      */
  2471.     public function Commander()
  2472.     {
  2473.         $session $this->session;
  2474.         $idSejour $session->get("Sejour");
  2475.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2476.         $user $this->getUser();
  2477.         $comande $session->get("comande");
  2478.         $panier $session->get("Panier");
  2479.         $nbrprodpromo 0;
  2480.         $nbralbum 0;
  2481.         $nbrlivre 0;
  2482.         $nbrphoto12 0;
  2483.         $nbrphoto24 0;
  2484.         $nbrphoto36 0;
  2485.         $nbrcal 0;
  2486.         $nbrretro12 0;
  2487.         $nbrretro24 0;
  2488.         $nbrretro36 0;
  2489.         $detailsprod = array();
  2490.         $prixalbum 0.0;
  2491.         $prixphoto12 0.0;
  2492.         $prixphoto24 0.0;
  2493.         $prixphoto36 0.0;
  2494.         $prixcal 0.0;
  2495.         $prixalbum 0.0;
  2496.         $prixretro12 0.0;
  2497.         $prixretro24 0.0;
  2498.         $prixretro36 0.0;
  2499.         $prodpanierpromo = array();
  2500.         $promo = array();
  2501.         foreach ($panier as $key => $p) {
  2502.             if ($p['condition'] != 11 && $p['condition'] != 6) {
  2503.                 $promo['condition'] = $p['condition'];
  2504.                 $nbrprodpromo $nbrprodpromo $p['qte'];
  2505.                 array_push($prodpanierpromo$promo);
  2506.                 if ($p['condition'] == 4) {
  2507.                     $nbralbum $nbralbum $p['qte'];
  2508.                     $prixalbum $p['mnt'];
  2509.                 } elseif ($p['condition'] == 1) {
  2510.                     $nbrphoto12 $nbrphoto12 $p['qte'];
  2511.                     $prixphoto12 $p['mnt'];
  2512.                 } elseif ($p['condition'] == 2) {
  2513.                     $nbrphoto24 $nbrphoto24 $p['qte'];
  2514.                     $prixphoto24 $p['mnt'];
  2515.                 } elseif ($p['condition'] == 3) {
  2516.                     $nbrphoto36 $nbrphoto36 $p['qte'];
  2517.                     $prixphoto36  $p['mnt'];
  2518.                 } elseif ($p['condition'] == 5) {
  2519.                     $nbrlivre $nbrlivre $p['qte'];
  2520.                     $prixlivre $p['mnt'];
  2521.                 } elseif ($p['condition'] == 7) {
  2522.                     $nbrcal $nbrcal $p['qte'];
  2523.                     $prixcal $p['mnt'];
  2524.                 } elseif ($p['condition'] == 8) {
  2525.                     $nbrretro36 $nbrretro36 $p['qte'];
  2526.                     $prixretro36 $p['mnt'];
  2527.                 } elseif ($p['condition'] == 9) {
  2528.                     $nbrretro12 $nbrretro12 $p['qte'];
  2529.                     $prixretro12 $p['mnt'];
  2530.                 } elseif ($p['condition'] == 10) {
  2531.                     $nbrretro24 $nbrretro24 $p['qte'];
  2532.                     $prixretro24 $p['mnt'];
  2533.                 }
  2534.             }
  2535.         }
  2536.         $detailsprod['album']['qt'] = $nbralbum;
  2537.         $detailsprod['album']['prix'] = $prixalbum;
  2538.         $detailsprod['photo12']['qt'] = $nbrphoto12;
  2539.         $detailsprod['photo12']['prix'] = $prixphoto12;
  2540.         $detailsprod['photo24']['qt'] = $nbrphoto24;
  2541.         $detailsprod['photo24']['prix'] = $prixphoto24;
  2542.         $detailsprod['photo36']['qt'] = $nbrphoto36;
  2543.         $detailsprod['photo36']['prix'] = $prixphoto36;
  2544.         $detailsprod['cal']['qt'] = $nbrcal;
  2545.         $detailsprod['cal']['prix'] = $prixcal;
  2546.         $detailsprod['livre']['qt'] = $nbrlivre;
  2547.         $detailsprod['livre']['prix'] = $prixalbum;
  2548.         $detailsprod['retro12']['qt'] = $nbrretro12;
  2549.         $detailsprod['retro12']['prix'] = $prixretro12;
  2550.         $detailsprod['retro24']['qt'] = $nbrretro24;
  2551.         $detailsprod['retro24']['prix'] = $prixretro24;
  2552.         $detailsprod['retro36']['qt'] = $nbrretro36;
  2553.         $detailsprod['retro36']['prix'] = $prixretro36;
  2554.         $Panier $session->get("Panier");
  2555.         return $this->render('Parent/commande.html.twig', ["detailsprod" => $detailsprod"nbrprodpromo" => $nbrprodpromo"prodpanierpromo" => $prodpanierpromo"user" => $user"sejour" => $sejour"x" => $panier'Panier' => $Panier]);
  2556.     }
  2557.     /**
  2558.      * @Route("/Parent/MonPanier", name="MonPanier")
  2559.      */
  2560.     public function MonPanier()
  2561.     {
  2562.         /** @var \App\Entity\User $user */
  2563.         $user $this->getUser();
  2564.         $session $this->session;
  2565.         $idSejour $session->get("Sejour");
  2566.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2567.         $listeproduit $prod $this->em->getRepository(Produit::class)->findby(array('iduser' => $user->getId()));
  2568.         $parentent_sejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $user->getId(), "idSejour" => $idSejour]);
  2569.         $Panier $session->get("Panier");
  2570.         //dd($Panier);
  2571.         $prodpanier = array();
  2572.         $nbrprodpromo 0;
  2573.         $nbralbum 0;
  2574.         $nbrlivre 0;
  2575.         $nbrphoto12 0;
  2576.         $nbrphoto24 0;
  2577.         $nbrphoto36 0;
  2578.         $nbrcal 0;
  2579.         $nbrretro12 0;
  2580.         $nbrretro24 0;
  2581.         $nbrretro36 0;
  2582.         $detailsprod = array();
  2583.         $prixalbum 0.0;
  2584.         $prixphoto12 0.0;
  2585.         $prixphoto24 0.0;
  2586.         $prixphoto36 0.0;
  2587.         $prixcal 0.0;
  2588.         $prixalbum 0.0;
  2589.         $prixretro12 0.0;
  2590.         $prixretro24 0.0;
  2591.         $prixretro36 0.0;
  2592.         $prodpanierpromo = array();
  2593.         $promo = array();
  2594.         foreach ($Panier as $key => $p) {
  2595.             if ($p['condition'] != null) {
  2596.                 array_push($prodpanier$p['condition']);
  2597.             }
  2598.             if ($p['condition'] != 11 && $p['condition'] != 6) {
  2599.                 $promo['condition'] = $p['condition'];
  2600.                 $nbrprodpromo $nbrprodpromo $p['qte'];
  2601.                 array_push($prodpanierpromo$promo);
  2602.                 if ($p['condition'] == 4) {
  2603.                     $nbralbum $nbralbum $p['qte'];
  2604.                     $prixalbum $p['mnt'];
  2605.                 } elseif ($p['condition'] == 1) {
  2606.                     $nbrphoto12 $nbrphoto12 $p['qte'];
  2607.                     $prixphoto12 $p['mnt'];
  2608.                 } elseif ($p['condition'] == 2) {
  2609.                     $nbrphoto24 $nbrphoto24 $p['qte'];
  2610.                     $prixphoto24 $p['mnt'];
  2611.                 } elseif ($p['condition'] == 3) {
  2612.                     $nbrphoto36 $nbrphoto36 $p['qte'];
  2613.                     $prixphoto36  $p['mnt'];
  2614.                 } elseif ($p['condition'] == 5) {
  2615.                     $nbrlivre $nbrlivre $p['qte'];
  2616.                     $prixlivre $p['mnt'];
  2617.                 } elseif ($p['condition'] == 7) {
  2618.                     $nbrcal $nbrcal $p['qte'];
  2619.                     $prixcal $p['mnt'];
  2620.                 } elseif ($p['condition'] == 8) {
  2621.                     $nbrretro36 $nbrretro36 $p['qte'];
  2622.                     $prixretro36 $p['mnt'];
  2623.                 } elseif ($p['condition'] == 9) {
  2624.                     $nbrretro12 $nbrretro12 $p['qte'];
  2625.                     $prixretro12 $p['mnt'];
  2626.                 } elseif ($p['condition'] == 10) {
  2627.                     $nbrretro24 $nbrretro24 $p['qte'];
  2628.                     $prixretro24 $p['mnt'];
  2629.                 }
  2630.             }
  2631.         }
  2632.         $detailsprod['album']['qt'] = $nbralbum;
  2633.         $detailsprod['album']['prix'] = $prixalbum;
  2634.         $detailsprod['photo12']['qt'] = $nbrphoto12;
  2635.         $detailsprod['photo12']['prix'] = $prixphoto12;
  2636.         $detailsprod['photo24']['qt'] = $nbrphoto24;
  2637.         $detailsprod['photo24']['prix'] = $prixphoto24;
  2638.         $detailsprod['photo36']['qt'] = $nbrphoto36;
  2639.         $detailsprod['photo36']['prix'] = $prixphoto36;
  2640.         $detailsprod['cal']['qt'] = $nbrcal;
  2641.         $detailsprod['cal']['prix'] = $prixcal;
  2642.         $detailsprod['livre']['qt'] = $nbrlivre;
  2643.         $detailsprod['livre']['prix'] = $prixalbum;
  2644.         $detailsprod['retro12']['qt'] = $nbrretro12;
  2645.         $detailsprod['retro12']['prix'] = $prixretro12;
  2646.         $detailsprod['retro24']['qt'] = $nbrretro24;
  2647.         $detailsprod['retro24']['prix'] = $prixretro24;
  2648.         $detailsprod['retro36']['qt'] = $nbrretro36;
  2649.         $detailsprod['retro36']['prix'] = $prixretro36;
  2650.         $produit $this->typeProduiteService;
  2651.         $produitlist $produit->produitlistTypeConditionnement();
  2652.         //dd( $detailsprod);
  2653.         $this->session->set('rout''rout');
  2654.         return $this->render('Parent/monpanier.html.twig', ['detailsprod' => $detailsprod'nbrprodpromo' => $nbrprodpromo'prodpanierpromo' => $prodpanierpromo'prodpanier' => $prodpanier'parentent_sejour' => $parentent_sejour'user' => $user'Sejour' => $idSejour"sejour" => $sejour'listeproduit' => $listeproduit'Panier' => $Panier'produitlist' => $produitlist]);
  2655.     }
  2656.     /**
  2657.      * @Route("/Parent/mail", name="mail")
  2658.      */
  2659.     public function mail()
  2660.     {
  2661.         return $this->render('emails/Inscriptionparent.html.twig', []);
  2662.     }
  2663.     /**
  2664.      * @Route("/Parent/AlbummsavealbumParent", name="AlbummsavealbumParent")
  2665.      */
  2666.     public function Albummsavealbum(Request $request)
  2667.     {
  2668.         $session $this->session;
  2669.         $serviceuser $this->etablissementService;
  2670.         $page $request->get("pages");
  2671.         $sejour $request->get("sejour");
  2672.         $prodid $request->get('idProd');
  2673.         $nomprod $request->get('nomprod');
  2674.         $versionalbm $request->get('new');
  2675.         $user $this->getUser();
  2676.         $produittype $session->get("produit");
  2677.         $produit $session->get("produittype");
  2678.         /** @var \App\Entity\User $user */
  2679.         $user $this->getUser();
  2680.         $userEmail $user->getEmail();
  2681.         $Album $serviceuser->savealbumParent($page$user$sejour$prodid$produit$produittype$nomprod$versionalbm);
  2682.         //dd($etablissementDetail);
  2683.         $dateNow = new \Datetime();
  2684.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2685.         // $this->EmailServie->MailRelancePanier($userEmail);
  2686.         return new response();
  2687.     }
  2688.     /**
  2689.      * @Route("/Parent/saveLivrePhotosParent", name="saveLivrePhotosParent")
  2690.      */
  2691.     public function saveLivrePhotos(Request $request)
  2692.     {
  2693.         $session $this->session;
  2694.         $serviceuser $this->etablissementService;
  2695.         $page $request->get("pages");
  2696.         $sejour $request->get("sejour");
  2697.         $prodid $request->get('idProd');
  2698.         $nomprod $request->get('nomprod');
  2699.         $versionalbm $request->get('new');
  2700.         $user $this->getUser();
  2701.         $produitcondition $session->get("produit");
  2702.         $produit $session->get("produittype");
  2703.         $produitcondss $session->get('produitconditionAlbum');
  2704.         $Album $serviceuser->savelivreParent($page$user$sejour$prodid$produitcondss$nomprod$versionalbm);
  2705.         //dd($etablissementDetail);
  2706.         //sendmail_parent
  2707.         $dateNow = new \Datetime();
  2708.         /** @var \App\Entity\User $user */
  2709.         $user $this->getUser();
  2710.         $userEmail $user->getEmail();
  2711.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2712.         // $this->EmailServie->MailRelancePanier($userEmail);
  2713.         return new response('done');
  2714.     }
  2715.     /**
  2716.      * @Route("/Parent/SavePhotosPochette", name="SavePhotosPochetteParent")
  2717.      */
  2718.     public function SavePhotosPochetteParent(Request $request)
  2719.     {
  2720.         $session $this->session;
  2721.         $serviceuser $this->etablissementService;
  2722.         $page $request->get("pages");
  2723.         $sejour $request->get("sejour");
  2724.         $prodid $request->get('idProd');
  2725.         $nomprod $request->get('nomprod');
  2726.         $nbr $request->get('nbr');
  2727.         $user $this->getUser();
  2728.         $nbr strval($nbr);
  2729.         $produittype $session->get("produit");
  2730.         $produit $session->get("produittype");
  2731.         $Album $serviceuser->SavePhotosPochetteParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  2732.         //sendmailparent
  2733.         $dateNow = new \Datetime();
  2734.         /** @var \App\Entity\User $user */
  2735.         $user $this->getUser();
  2736.         $userEmail $user->getEmail();
  2737.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2738.         //$this->EmailServie->MailRelancePanier($userEmail);
  2739.         return new response('done');
  2740.     }
  2741.     /**
  2742.      * @Route("/Parent/RetrosComandeSaveRetros", name="PochettePhotosComandeSave")
  2743.      */
  2744.     public function PochettePhotosComandeSave(Request $request)
  2745.     {
  2746.         $em $this->em;
  2747.         $session $this->session;
  2748.         $serviceuser $this->etablissementService;
  2749.         $page $request->get("pages");
  2750.         $sejour $request->get("sejour");
  2751.         $prodid $request->get('idProd');
  2752.         $nomprod $request->get('nomprod');
  2753.         $nbr $request->get('nbr');
  2754.         $user $this->getUser();
  2755.         $nbr strval($nbr);
  2756.         $produittype $session->get("produit");
  2757.         $produit $session->get("produittype");
  2758.         $Album $serviceuser->SavePhotosRetrosParents($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  2759.         $inser false;
  2760.         $Products $session->get("Panier");
  2761.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  2762.         //Touhemi  03-07-2020 :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  2763.         $user $this->getUser();
  2764.         $typeref $em->getRepository(Typeref::class)->find(8);
  2765.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  2766.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  2767.         //fin
  2768.         if ($panierTrace == null) {
  2769.             $panierTrace = new Panier();
  2770.             $dateNow = new \Datetime();
  2771.             $panierTrace->setDateCreation($dateNow);
  2772.             $panierTrace->setCreerPar($user);
  2773.             $panierTrace->setStatut($statutPanier);
  2774.             $em->getManager()->persist($panierTrace);
  2775.             $em->getManager()->flush();
  2776.         }
  2777.         //Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on Ă©crit un produit
  2778.         if ($Products == null) {
  2779.             $Products = [];
  2780.         }
  2781.         foreach ($Products as $key => $p) {
  2782.             if ($p['id'] == $produit->getId()) {
  2783.                 $inser true;
  2784.                 $Products[$key]['qte'] = $p['qte'] + 1;
  2785.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  2786.             }
  2787.         }
  2788.         //Touhemi 03-07-2020 :Rechercher  si le produti existe dĂ©ja ds panierProduit
  2789.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  2790.         if ($panierProduit == null) {
  2791.             $panierProduit = new PanierProduit();
  2792.             $panierProduit->setIdProduit($produit);
  2793.             $panierProduit->setIdPanier($panierTrace);
  2794.             $em->getManager()->persist($panierProduit);
  2795.             $em->getManager()->flush();
  2796.         }
  2797.         //fin
  2798.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  2799.         $oldQte $panierProduit->getQuantite();
  2800.         $newQte $oldQte 1;
  2801.         $panierProduit->setQuantite($newQte);
  2802.         $oldTotal $panierProduit->getPrixTotal();
  2803.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  2804.         $panierProduit->setPrixTotal($newTotal);
  2805.         $em->getManager()->persist($panierProduit);
  2806.         $em->getManager()->flush();
  2807.         //fin
  2808.         if ($inser === false) {
  2809.             $p = [];
  2810.             $p["id"] = $produit->getId();
  2811.             $p["nom"] = $produit->getType()->getLabeletype();
  2812.             $p["ident"] = $produit->getLabele();
  2813.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  2814.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  2815.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  2816.             $p["condition"] = $produit->getIdConditionnement()->getId();
  2817.             $p["qte"] = 1;
  2818.             array_push($Products$p);
  2819.         }
  2820.         $session->set('Panier'$Products);
  2821.         //sendmail_parent
  2822.         $dateNow = new \Datetime();
  2823.         /** @var \App\Entity\User $user */
  2824.         $user $this->getUser();
  2825.         $userEmail $user->getEmail();
  2826.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2827.         //$this->EmailServie->MailRelancePanier($userEmail);
  2828.         return new response('done');
  2829.     }
  2830.     //fonction pour pochett photo comande direct au panier 
  2831.     /**
  2832.      * @Route("/Parent/PochetcomdComandeSave", name="PochettePhotosComandeSave_pochet_panier")
  2833.      */
  2834.     public function PochettePhotosComandeSave_pochet_panier(Request $request)
  2835.     {
  2836.         $em $this->em;
  2837.         $session $this->session;
  2838.         $serviceuser $this->etablissementService;
  2839.         $page $request->get("pages");
  2840.         $sejour $request->get("sejour");
  2841.         $prodid $request->get('idProd');
  2842.         $nomprod $request->get('nomprod');
  2843.         $nbr $request->get('nbr');
  2844.         $user $this->getUser();
  2845.         $nbr strval($nbr);
  2846.         $produittype $session->get("produit");
  2847.         $produit $session->get("produittype");
  2848.         $Album $serviceuser->SavePhotosPochetteParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  2849.         $inser false;
  2850.         $Products $session->get("Panier");
  2851.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  2852.         //Touhemi  03-07-2020 :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  2853.         $user $this->getUser();
  2854.         $typeref $em->getRepository(Typeref::class)->find(8);
  2855.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  2856.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  2857.         //fin
  2858.         if ($panierTrace == null) {
  2859.             $panierTrace = new Panier();
  2860.             $dateNow = new \Datetime();
  2861.             $panierTrace->setDateCreation($dateNow);
  2862.             $panierTrace->setCreerPar($user);
  2863.             $panierTrace->setStatut($statutPanier);
  2864.             $em->getManager()->persist($panierTrace);
  2865.             $em->getManager()->flush();
  2866.         }
  2867.         //Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on Ă©crit un produit
  2868.         if ($Products == null) {
  2869.             $Products = [];
  2870.         }
  2871.         foreach ($Products as $key => $p) {
  2872.             if ($p['id'] == $produit->getId()) {
  2873.                 $inser true;
  2874.                 $Products[$key]['qte'] = $p['qte'] + 1;
  2875.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  2876.             }
  2877.         }
  2878.         //Touhemi 03-07-2020 :Rechercher  si le produti existe dĂ©ja ds panierProduit
  2879.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  2880.         if ($panierProduit == null) {
  2881.             $panierProduit = new PanierProduit();
  2882.             $panierProduit->setIdProduit($produit);
  2883.             $panierProduit->setIdPanier($panierTrace);
  2884.             $em->getManager()->persist($panierProduit);
  2885.             $em->getManager()->flush();
  2886.         }
  2887.         //fin
  2888.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  2889.         $oldQte $panierProduit->getQuantite();
  2890.         $newQte $oldQte 1;
  2891.         $panierProduit->setQuantite($newQte);
  2892.         $oldTotal $panierProduit->getPrixTotal();
  2893.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  2894.         $panierProduit->setPrixTotal($newTotal);
  2895.         $em->getManager()->persist($panierProduit);
  2896.         $em->getManager()->flush();
  2897.         //fin
  2898.         if ($inser === false) {
  2899.             $p = [];
  2900.             $p["id"] = $produit->getId();
  2901.             $p["nom"] = $produit->getType()->getLabeletype();
  2902.             $p["ident"] = $produit->getLabele();
  2903.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  2904.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  2905.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  2906.             $p["condition"] = $produit->getIdConditionnement()->getId();
  2907.             $p["qte"] = 1;
  2908.             array_push($Products$p);
  2909.         }
  2910.         $session->set('Panier'$Products);
  2911.         //sendmail_parent
  2912.         $dateNow = new \Datetime();
  2913.         /** @var \App\Entity\User $user */
  2914.         $user $this->getUser();
  2915.         $userEmail $user->getEmail();
  2916.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2917.         // $this->EmailServie->MailRelancePanier($userEmail);
  2918.         return new response('done');
  2919.     }
  2920.     //Nouvelle fonction ajout pochette
  2921.     /**
  2922.      * @Route("/Parent/TestcreateFilePhotosNew", name="TestcreateFilePhotosNew")
  2923.      */
  2924.     function TestcreateFilePhotosNew(Request $request)
  2925.     {
  2926.         $prdt $request->get("produit");
  2927.         $printerSer $this->printerService;
  2928.         $pages $this->em->getRepository(Page::class)->findBy(array("idproduit" => $prdt));
  2929.         $this->logger->notice('Generating File for Pack photos');
  2930.         $name =  $printerSer->CreerTcpPhotosPochette_Parent($prdt'NumCmd_963''Photo'$pages);
  2931.         dump($name);
  2932.         die();
  2933.         return ("ok");
  2934.     }
  2935.     //Nouvelle fonction ajout pochette
  2936.     /**
  2937.      * @Route("/Parent/AddPochetteAuPanier", name="AddPochetteAuPanier")
  2938.      */
  2939.     public function AddPochetteAuPanier(Request $request)
  2940.     {
  2941.         $em $this->em;
  2942.         $session $this->session;
  2943.         $serviceuser $this->etablissementService;
  2944.         $page $request->get("photos");
  2945.         $sejour $request->get("sejour");
  2946.         $nbr $request->get('nbr');
  2947.         $user $this->getUser();
  2948.         $nbr strval($nbr);
  2949.         //Enregistrement des infos de la pochette dans un produit et les photos dans des pages avec JSON
  2950.         $Pochette_photos $serviceuser->photosPochette_Nouvelle($page$user$sejour$nbr);
  2951.         $produit $em->getRepository(Produit::class)->find($Pochette_photos->getId());
  2952.         // $zipFileName = $this->printerService->CreerTcpPhotosPochette_Parent($Pochette_photos->getId(), "9999999", "pochette_photo");
  2953.         $inser false;
  2954.         $Products $session->get("Panier");
  2955.         $produit $em->getRepository(Produit::class)->find($Pochette_photos->getId());
  2956.         //Touhemi  03-07-2020 :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  2957.         $typeref $em->getRepository(Typeref::class)->find(8);
  2958.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  2959.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  2960.         //fin
  2961.         if ($panierTrace == null) {
  2962.             $panierTrace = new Panier();
  2963.             $dateNow = new \Datetime();
  2964.             $panierTrace->setDateCreation($dateNow);
  2965.             $panierTrace->setCreerPar($user);
  2966.             $panierTrace->setStatut($statutPanier);
  2967.             $em->getManager()->persist($panierTrace);
  2968.             $em->getManager()->flush();
  2969.         }
  2970.         //Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on Ă©crit un produit
  2971.         if ($Products == null) {
  2972.             $Products = [];
  2973.         }
  2974.         foreach ($Products as $key => $p) {
  2975.             if ($p['id'] == $produit->getId()) {
  2976.                 $inser true;
  2977.                 $Products[$key]['qte'] = $p['qte'] + 1;
  2978.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  2979.             }
  2980.         }
  2981.         //Touhemi 03-07-2020 :Rechercher  si le produti existe dĂ©ja ds panierProduit
  2982.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  2983.         if ($panierProduit == null) {
  2984.             $panierProduit = new PanierProduit();
  2985.             $panierProduit->setIdProduit($produit);
  2986.             $panierProduit->setIdPanier($panierTrace);
  2987.             $em->getManager()->persist($panierProduit);
  2988.             $em->getManager()->flush();
  2989.         }
  2990.         //fin
  2991.         $oldQte $panierProduit->getQuantite();
  2992.         $newQte $oldQte 1;
  2993.         $panierProduit->setQuantite($newQte);
  2994.         $oldTotal $panierProduit->getPrixTotal();
  2995.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  2996.         $panierProduit->setPrixTotal($newTotal);
  2997.         $em->getManager()->persist($panierProduit);
  2998.         $em->getManager()->flush();
  2999.         // Test creation du fichier zip pdf pochette
  3000.         if ($inser === false) {
  3001.             $p = [];
  3002.             $p["id"] = $produit->getId();
  3003.             $p["nom"] = $produit->getType()->getLabeletype();
  3004.             $p["ident"] = $produit->getLabele();
  3005.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3006.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3007.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3008.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3009.             $p["qte"] = 1;
  3010.             array_push($Products$p);
  3011.         }
  3012.         $session->set('Panier'$Products);
  3013.         //sendmail_parent
  3014.         $dateNow = new \Datetime();
  3015.         /** @var \App\Entity\User $user */
  3016.         $user $this->getUser();
  3017.         $userEmail $user->getEmail();
  3018.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3019.         // $this->EmailServie->MailRelancePanier($userEmail);
  3020.         //   $this->TestcreateFilePhotosNew($produit);
  3021.         return new response('done');
  3022.     }
  3023.     /**
  3024.      * @Route("/Parent/AddRetroAuPanier", name="AddRetroAuPanier", methods={"POST"})
  3025.      */
  3026.     public function AddRetroAuPanier(Request $request)
  3027.     {
  3028.         $em       $this->em;        // or getDoctrine()->getManager()
  3029.         $session  $this->session;
  3030.         $user $this->getUser();
  3031.         $service  $this->etablissementService// Same service that had photosPochette_Nouvelle
  3032.         $photos   $request->get('photos');     // base64 data, widths, heights, etc.
  3033.         $sejourId $request->get('sejour');
  3034.         $nbr      strval($request->get('nbr'));
  3035.         // 1) Let the service create the new "Retro" product + store pages
  3036.         //    We’ll define photosRetro_Nouvelle similar to photosPochette_Nouvelle
  3037.         $RetroProduit $service->photosRetro_Nouvelle($photos$user$sejourId$nbr);
  3038.         // 2) Same logic to insert that new product in the user’s Panier
  3039.         //    (Essentially the same as your AddPochetteAuPanier code)
  3040.         $inser false;
  3041.         $Products $session->get("Panier");
  3042.         if (!$Products) {
  3043.             $Products = [];
  3044.         }
  3045.         // The newly created product
  3046.         $produit $em->getRepository(Produit::class)->find($RetroProduit->getId());
  3047.         // A) Check if a "Panier" with status "creer" for this user exists,
  3048.         //    or create one if needed
  3049.         $typeref $em->getRepository(Typeref::class)->find(8);
  3050.         $statutPanier $em->getRepository(Ref::class)->findOneBy([
  3051.             "libiller" => "creer",
  3052.             "typeref" => $typeref
  3053.         ]);
  3054.         $panierTrace $em->getRepository(Panier::class)->findOneBy([
  3055.             "creerPar" => $user,
  3056.             "statut"   => $statutPanier
  3057.         ]);
  3058.         if (!$panierTrace) {
  3059.             $panierTrace = new Panier();
  3060.             $panierTrace->setDateCreation(new \DateTime());
  3061.             $panierTrace->setCreerPar($user);
  3062.             $panierTrace->setStatut($statutPanier);
  3063.             $em->getManager()->persist($panierTrace);
  3064.             $em->getManager()->flush();
  3065.         }
  3066.         // B) Check if this product already exists in $Products
  3067.         foreach ($Products as $key => $p) {
  3068.             if ($p['id'] == $produit->getId()) {
  3069.                 $inser true;
  3070.                 $Products[$key]['qte'] += 1;
  3071.                 $Products[$key]['mnt'] += $produit->getIdConditionnement()->getMontantTTC();
  3072.             }
  3073.         }
  3074.         // C) Check if it also exists in PanierProduit table
  3075.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy([
  3076.             "idProduit" => $produit,
  3077.             "idPanier"  => $panierTrace
  3078.         ]);
  3079.         if (!$panierProduit) {
  3080.             $panierProduit = new PanierProduit();
  3081.             $panierProduit->setIdProduit($produit);
  3082.             $panierProduit->setIdPanier($panierTrace);
  3083.             $em->getManager()->persist($panierProduit);
  3084.             $em->getManager()->flush();
  3085.         }
  3086.         // D) Increase quantity & total
  3087.         $oldQte $panierProduit->getQuantite();
  3088.         $panierProduit->setQuantite($oldQte 1);
  3089.         $oldTotal $panierProduit->getPrixTotal();
  3090.         $panierProduit->setPrixTotal($oldTotal $produit->getIdConditionnement()->getMontantTTC());
  3091.         $em->getManager()->persist($panierProduit);
  3092.         $em->getManager()->flush();
  3093.         // E) If not inserted in $Products above, push new array item
  3094.         if (!$inser) {
  3095.             $p = [
  3096.                 "id"         => $produit->getId(),
  3097.                 "nom"        => $produit->getType()->getLabeletype(),
  3098.                 "ident"      => $produit->getLabele(),
  3099.                 "codesejour" => $produit->getIdsjour()->getcodeSejour(),
  3100.                 "mnt"        => $produit->getIdConditionnement()->getMontantTTC(),
  3101.                 "path"       => $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  3102.                 "condition"  => $produit->getIdConditionnement()->getId(),
  3103.                 "qte"        => 1
  3104.             ];
  3105.             $Products[] = $p;
  3106.         }
  3107.         $session->set('Panier'$Products);
  3108.         /** @var \App\Entity\User $user */
  3109.         $user $this->getUser();
  3110.         $userEmail $user->getEmail();
  3111.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3112.         return new Response('done');
  3113.     }
  3114.     /**
  3115.      * @Route("/Parent/SavePhotosRetros", name="SavePhotosRetrosParent")
  3116.      */
  3117.     public function SavePhotosRetrosParent(Request $request)
  3118.     {
  3119.         $em $this->em;
  3120.         $session $this->session;
  3121.         $serviceuser $this->etablissementService;
  3122.         $page $request->get("pages");
  3123.         $sejour $request->get("sejour");
  3124.         $prodid $request->get('idProd');
  3125.         $nomprod $request->get('nomprod');
  3126.         $nbr $request->get('nbr');
  3127.         $comandePanier $request->get('comandePanier');
  3128.         $user $this->getUser();
  3129.         $nbr strval($nbr);
  3130.         $produittype $session->get("produit");
  3131.         $produit $session->get("produittype");
  3132.         $Album $serviceuser->SavePhotosRetrosParents($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3133.         //dd($etablissementDetail);
  3134.         if ($comandePanier == "comandePanier") {
  3135.             $inser false;
  3136.             $Products $session->get("Panier");
  3137.             $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  3138.             //Touhemi  03-07-2020 :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  3139.             $user $this->getUser();
  3140.             $typeref $em->getRepository(Typeref::class)->find(8);
  3141.             $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3142.             $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3143.             //fin
  3144.             if ($panierTrace == null) {
  3145.                 $panierTrace = new Panier();
  3146.                 $dateNow = new \Datetime();
  3147.                 $panierTrace->setDateCreation($dateNow);
  3148.                 $panierTrace->setCreerPar($user);
  3149.                 $panierTrace->setStatut($statutPanier);
  3150.                 $em->getManager()->persist($panierTrace);
  3151.                 $em->getManager()->flush();
  3152.             }
  3153.             //Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on Ă©crit un produit
  3154.             if ($Products == null) {
  3155.                 $Products = [];
  3156.             }
  3157.             foreach ($Products as $key => $p) {
  3158.                 if ($p['id'] == $produit->getId()) {
  3159.                     $inser true;
  3160.                     $Products[$key]['qte'] = $p['qte'] + 1;
  3161.                     $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3162.                 }
  3163.             }
  3164.             //Touhemi 03-07-2020 :Rechercher  si le produti existe dĂ©ja ds panierProduit
  3165.             $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3166.             if ($panierProduit == null) {
  3167.                 $panierProduit = new PanierProduit();
  3168.                 $panierProduit->setIdProduit($produit);
  3169.                 $panierProduit->setIdPanier($panierTrace);
  3170.                 $em->getManager()->persist($panierProduit);
  3171.                 $em->getManager()->flush();
  3172.             }
  3173.             //fin
  3174.             //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  3175.             $oldQte $panierProduit->getQuantite();
  3176.             $newQte $oldQte 1;
  3177.             $panierProduit->setQuantite($newQte);
  3178.             $oldTotal $panierProduit->getPrixTotal();
  3179.             $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3180.             $panierProduit->setPrixTotal($newTotal);
  3181.             $em->getManager()->persist($panierProduit);
  3182.             $em->getManager()->flush();
  3183.             //fin
  3184.             if ($inser === false) {
  3185.                 $p = [];
  3186.                 $p["id"] = $produit->getId();
  3187.                 $p["nom"] = $produit->getType()->getLabeletype();
  3188.                 $p["ident"] = $produit->getLabele();
  3189.                 $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3190.                 $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3191.                 $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3192.                 $p["condition"] = $produit->getIdConditionnement()->getId();
  3193.                 $p["qte"] = 1;
  3194.                 array_push($Products$p);
  3195.             }
  3196.             $session->set('Panier'$Products);
  3197.         }
  3198.         //sendmail_parent
  3199.         $dateNow = new \Datetime();
  3200.         /** @var \App\Entity\User $user */
  3201.         $user $this->getUser();
  3202.         $userEmail $user->getEmail();
  3203.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3204.         // $this->EmailServie->MailRelancePanier($userEmail);
  3205.         return new response($Album->getId());
  3206.     }
  3207.     /**
  3208.      * @Route("/Parent/SaveCalendrierParent", name="SaveCalendrierParent")
  3209.      */
  3210.     public function SaveCalendrierParent(Request $request)
  3211.     {
  3212.         $session $this->session;
  3213.         $serviceuser $this->etablissementService;
  3214.         $page $request->get("pages");
  3215.         $sejour $request->get("sejour");
  3216.         $prodid $request->get('idProd');
  3217.         $nomprod $request->get('nomprod');
  3218.         $nbr $request->get('nbr');
  3219.         $user $this->getUser();
  3220.         $nbr strval($nbr);
  3221.         $produittype $session->get("produit");
  3222.         $produit $session->get("produittype");
  3223.         $Album $serviceuser->SaveCalendrierParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3224.         //sendmail_parent
  3225.         $dateNow = new \Datetime();
  3226.         /** @var \App\Entity\User $user */
  3227.         $user $this->getUser();
  3228.         $userEmail $user->getEmail();
  3229.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3230.         //$this->EmailServie->MailRelancePanier($userEmail);
  3231.         return new response('done');
  3232.     }
  3233.     /**
  3234.      * @Route("/Parent/SaveCommandeCalendrierParent", name="SaveCommandeCalendrierParent")
  3235.      */
  3236.     public function SaveCommandeCalendrierParent(Request $request)
  3237.     {
  3238.         $em $this->em;
  3239.         $session $this->session;
  3240.         $serviceuser $this->etablissementService;
  3241.         $page $request->get("pages");
  3242.         $sejour $request->get("sejour");
  3243.         $prodid $request->get('idProd');
  3244.         $nomprod $request->get('nomprod');
  3245.         $nbr $request->get('nbr');
  3246.         $user $this->getUser();
  3247.         $nbr strval($nbr);
  3248.         $produittype $session->get("produit");
  3249.         $produit $session->get("produittype");
  3250.         $Album $serviceuser->SaveCalendrierParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3251.         $inser false;
  3252.         $Products $session->get("Panier");
  3253.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  3254.         //Touhemi  03-07-2020 :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  3255.         $user $this->getUser();
  3256.         $typeref $em->getRepository(Typeref::class)->find(8);
  3257.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3258.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3259.         //fin
  3260.         if ($panierTrace == null) {
  3261.             $panierTrace = new Panier();
  3262.             $dateNow = new \Datetime();
  3263.             $panierTrace->setDateCreation($dateNow);
  3264.             $panierTrace->setCreerPar($user);
  3265.             $panierTrace->setStatut($statutPanier);
  3266.             $em->getManager()->persist($panierTrace);
  3267.             $em->getManager()->flush();
  3268.         }
  3269.         //Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on Ă©crit un produit
  3270.         if ($Products == null) {
  3271.             $Products = [];
  3272.         }
  3273.         foreach ($Products as $key => $p) {
  3274.             if ($p['id'] == $produit->getId()) {
  3275.                 $inser true;
  3276.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3277.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3278.             }
  3279.         }
  3280.         //Touhemi 03-07-2020 :Rechercher  si le produti existe dĂ©ja ds panierProduit
  3281.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3282.         if ($panierProduit == null) {
  3283.             $panierProduit = new PanierProduit();
  3284.             $panierProduit->setIdProduit($produit);
  3285.             $panierProduit->setIdPanier($panierTrace);
  3286.             $em->getManager()->persist($panierProduit);
  3287.             $em->getManager()->flush();
  3288.         }
  3289.         //fin
  3290.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  3291.         $oldQte $panierProduit->getQuantite();
  3292.         $newQte $oldQte 1;
  3293.         $panierProduit->setQuantite($newQte);
  3294.         $oldTotal $panierProduit->getPrixTotal();
  3295.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3296.         $panierProduit->setPrixTotal($newTotal);
  3297.         $em->getManager()->persist($panierProduit);
  3298.         $em->getManager()->flush();
  3299.         //fin
  3300.         if ($inser === false) {
  3301.             $p = [];
  3302.             $p["id"] = $produit->getId();
  3303.             $p["nom"] = $produit->getType()->getLabeletype();
  3304.             $p["ident"] = $produit->getLabele();
  3305.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3306.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3307.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3308.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3309.             $p["qte"] = 1;
  3310.             array_push($Products$p);
  3311.         }
  3312.         $session->set('Panier'$Products);
  3313.         //sendmail_parent
  3314.         $dateNow = new \Datetime();
  3315.         /** @var \App\Entity\User $user */
  3316.         $user $this->getUser();
  3317.         $userEmail $user->getEmail();
  3318.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3319.         // $this->EmailServie->MailRelancePanier($userEmail);
  3320.         return new response('done');
  3321.     }
  3322.     /**
  3323.      * @Route("/Parent/SavePdfParent", name="SavePdfParent")
  3324.      */
  3325.     public function SavePdfParent(Request $request)
  3326.     {
  3327.         //        $blob = $request->get("blob");
  3328.         if (!empty($_POST['blob'])) {
  3329.             $data $_POST['blob'];
  3330.             $fname "test.pdf"// name the file
  3331.             $file fopen("pdf/" $fname'w'); // open the file path
  3332.             fwrite($file$data); //save data
  3333.             fclose($file);
  3334.         } else {
  3335.             echo "No Data Sent";
  3336.         }
  3337.         return new response('ok');
  3338.     }
  3339.     /**
  3340.      * @Route("/Parent/infosphp", name="infos")
  3341.      */
  3342.     public function infos()
  3343.     {
  3344.         echo phpinfo();
  3345.     }
  3346.     /**
  3347.      * @Route("/Parent/RetrosComandeSaveRetros", name="RetrosComandeSaveRetros")
  3348.      */
  3349.     public function RetrosComandeSaveRetros(Request $request)
  3350.     {
  3351.         $em $this->em;
  3352.         $session $this->session;
  3353.         $serviceuser $this->etablissementService;
  3354.         $page $request->get("pages");
  3355.         $sejour $request->get("sejour");
  3356.         $prodid $request->get('idProd');
  3357.         $nomprod $request->get('nomprod');
  3358.         $nbr $request->get('nbr');
  3359.         $user $this->getUser();
  3360.         $nbr strval($nbr);
  3361.         $produittype $session->get("produit");
  3362.         $produit $session->get("produittype");
  3363.         $Album $serviceuser->SavePhotosRetrosParents($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3364.         $inser false;
  3365.         $Products $session->get("Panier");
  3366.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  3367.         //Touhemi  03-07-2020 :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  3368.         $user $this->getUser();
  3369.         $typeref $em->getRepository(Typeref::class)->find(8);
  3370.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3371.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3372.         //fin
  3373.         if ($panierTrace == null) {
  3374.             $panierTrace = new Panier();
  3375.             $dateNow = new \Datetime();
  3376.             $panierTrace->setDateCreation($dateNow);
  3377.             $panierTrace->setCreerPar($user);
  3378.             $panierTrace->setStatut($statutPanier);
  3379.             $em->getManager()->persist($panierTrace);
  3380.             $em->getManager()->flush();
  3381.         }
  3382.         //Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on Ă©crit un produit
  3383.         if ($Products == null) {
  3384.             $Products = [];
  3385.         }
  3386.         foreach ($Products as $key => $p) {
  3387.             if ($p['id'] == $produit->getId()) {
  3388.                 $inser true;
  3389.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3390.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3391.             }
  3392.         }
  3393.         //Touhemi 03-07-2020 :Rechercher  si le produti existe dĂ©ja ds panierProduit
  3394.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3395.         if ($panierProduit == null) {
  3396.             $panierProduit = new PanierProduit();
  3397.             $panierProduit->setIdProduit($produit);
  3398.             $panierProduit->setIdPanier($panierTrace);
  3399.             $em->getManager()->persist($panierProduit);
  3400.             $em->getManager()->flush();
  3401.         }
  3402.         //fin
  3403.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  3404.         $oldQte $panierProduit->getQuantite();
  3405.         $newQte $oldQte 1;
  3406.         $panierProduit->setQuantite($newQte);
  3407.         $oldTotal $panierProduit->getPrixTotal();
  3408.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3409.         $panierProduit->setPrixTotal($newTotal);
  3410.         $em->getManager()->persist($panierProduit);
  3411.         $em->getManager()->flush();
  3412.         //fin
  3413.         if ($inser === false) {
  3414.             $p = [];
  3415.             $p["id"] = $produit->getId();
  3416.             $p["nom"] = $produit->getType()->getLabeletype();
  3417.             $p["ident"] = $produit->getLabele();
  3418.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3419.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3420.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3421.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3422.             $p["qte"] = 1;
  3423.             array_push($Products$p);
  3424.         }
  3425.         $session->set('Panier'$Products);
  3426.         return new response('done');
  3427.     }
  3428.     /**
  3429.      * @Route("/Parent/nbvisite", name="nbvisite",methods={"POST","GET"})
  3430.      */
  3431.     public function ajouternombrevisite(Request $request)
  3432.     {
  3433.         $SejourService $this->sejourService;
  3434.         $CarteService $this->carteService;
  3435.         $typevisite $request->get("typevisite");
  3436.         $idsejour $request->get("idsejour");
  3437.         $idattach $request->get("idattachement");
  3438.         if ($typevisite == "carte") {
  3439.             $nbvisite $CarteService->carteVisite($idsejour);
  3440.         } else {
  3441.             $nbvisite $SejourService->affectationnbvisiteattachement($idsejour$idattach);
  3442.         }
  3443.         return new JsonResponse('done');
  3444.     }
  3445.     /**
  3446.      * @Route("/Parent/ajouterauPanier_Parent", name="Ajouter_MonPanier")
  3447.      */
  3448.     public function Ajouter_MonPanier(Request $request)
  3449.     {
  3450.         $inser false;
  3451.         $session $this->session;
  3452.         $em $this->em;
  3453.         $Products $session->get("Panier");
  3454.         $id $request->get("id");
  3455.         //Touhemi :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  3456.         $user $this->getUser();
  3457.         $typeref $em->getRepository(Typeref::class)->find(8);
  3458.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3459.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3460.         //fin
  3461.         if ($panierTrace == null) {
  3462.             $panierTrace = new Panier();
  3463.             $dateNow = new \Datetime();
  3464.             $panierTrace->setDateCreation($dateNow);
  3465.             $panierTrace->setCreerPar($user);
  3466.             $panierTrace->setStatut($statutPanier);
  3467.             $em->getManager()->persist($panierTrace);
  3468.             $em->getManager()->flush();
  3469.         }
  3470.         $produit $this->em->getRepository(Produit::class)->find($id);
  3471.         if ($Products == null) {
  3472.             $Products = [];
  3473.         }
  3474.         //Touhemi :Rechercher  si le produti existe dĂ©ja ds panierProduit
  3475.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3476.         if ($panierProduit == null) {
  3477.             $panierProduit = new PanierProduit();
  3478.             $panierProduit->setIdProduit($produit);
  3479.             $panierProduit->setIdPanier($panierTrace);
  3480.             $em->getManager()->persist($panierProduit);
  3481.             $em->getManager()->flush();
  3482.         }
  3483.         //fin
  3484.         foreach ($Products as $key => $p) {
  3485.             if ($p['id'] == $produit->getId()) {
  3486.                 $inser true;
  3487.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3488.             }
  3489.         }
  3490.         //Touhemi ajouter plus un au produit et modifier prixTotal
  3491.         $oldQte $panierProduit->getQuantite();
  3492.         $newQte $oldQte 1;
  3493.         $panierProduit->setQuantite($newQte);
  3494.         $oldTotal $panierProduit->getPrixTotal();
  3495.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3496.         $panierProduit->setPrixTotal($newTotal);
  3497.         $this->em->getManager()->persist($panierProduit);
  3498.         $this->em->getManager()->flush();
  3499.         //fin
  3500.         if ($inser === false) {
  3501.             //get nessaisire element
  3502.             $p = [];
  3503.             $p["id"] = $produit->getId();
  3504.             $p["nom"] = $produit->getType()->getLabeletype();
  3505.             $p["ident"] = $produit->getLabele();
  3506.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3507.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3508.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3509.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3510.             $p["qte"] = 1;
  3511.             array_push($Products$p);
  3512.         }
  3513.         $session->set('Panier'$Products);
  3514.         return new JsonResponse('done');
  3515.     }
  3516.     /**
  3517.      * @Route("/Parent/Ajouter_Album_Parent", name="Ajouter_Album_Parent_Alb")
  3518.      */
  3519.     public function Ajouter_Album(Request $request)
  3520.     {
  3521.         $session $this->session;
  3522.         $id $request->get("id");
  3523.         $typeProdcondition $this->em->getRepository(TypeProduitConditionnement::class)->find($id);
  3524.         $typeprod $typeProdcondition->getIdTypeProduit()->getId();
  3525.         $session->set('produit'$id);
  3526.         $session->set('produitconditionAlbum'$id);
  3527.         $session->set('produittype'$typeprod);
  3528.         return new JsonResponse('done');
  3529.     }
  3530.     /**
  3531.      * @Route("/Parent/ComandeParent", name="ComandeParent")
  3532.      */
  3533.     public function comande_Parent(Request $request)
  3534.     {
  3535.         $session $this->session;
  3536.         // $comande = $request->get("p");
  3537.         $Panier $session->get("Panier");
  3538.         $session->set('comande'$Panier);
  3539.         return new JsonResponse('done');
  3540.     }
  3541.     /**
  3542.      * @Route("/Parent/Accueil5sur5/adresse_comande", name="adresse_comande",methods={"POST"})
  3543.      */
  3544.     public function adresse_comande(Request $request)
  3545.     {
  3546.         $UserService $this->userService;
  3547.         /** @var \App\Entity\User $user */
  3548.         $user $this->getUser();
  3549.         $iduser $user->getId();
  3550.         $idCommande $request->get("idCommande");
  3551.         $prenom $request->get("prenom");
  3552.         $nom $request->get("nom");
  3553.         $organism $request->get("organism");
  3554.         $rue $request->get('ruevoi');
  3555.         $ville $request->get("villle");
  3556.         $pays $request->get("pays");
  3557.         $codepostal $request->get("codpostal");
  3558.         //adress facturation if exsist
  3559.         $prenomfacturation $request->get("prenomadressfacturation");
  3560.         $nomfacturation $request->get("nomadressfacturation");
  3561.         $organismfacturation $request->get("etablismadressfacturation");
  3562.         $ruefacturation $request->get('rueadressfacturation');
  3563.         $villefacturation $request->get("villefacturation");
  3564.         $paysfacturation $request->get("payadressfacturation");
  3565.         $codepostalfacturation $request->get("codepostalfacturation");
  3566.         //modification userPArent
  3567.         $em $this->em;
  3568.         $adress $UserService->modifieradress_comande($rue$ville$pays$codepostal$iduser$prenom$nom$organism$prenomfacturation$nomfacturation$organismfacturation$ruefacturation$villefacturation$paysfacturation$codepostalfacturation);
  3569.         $commande $em->getRepository(Commande::class)->findOneBy(array("id" => $idCommande));
  3570.         $commande->setAdresslivraison($adress);
  3571.         $commande->setAddresseLivraison($ville);
  3572.         $commande->setAdressfactoration($adress);
  3573.         $em->getManager()->persist($commande);
  3574.         $em->getManager()->flush();
  3575.         return new JsonResponse('Adresse EnregitrĂ©e');
  3576.     }
  3577.     /**
  3578.      * @Route("/Parent/Accueil5sur5/codesecuriter", name="codesecuriter",methods={"POST"})
  3579.      */
  3580.     public function codesecuriter(Request $request)
  3581.     {
  3582.         $UserService $this->userService;
  3583.         /** @var \App\Entity\User $user */
  3584.         $user $this->getUser();
  3585.         $iduser $user->getId();
  3586.         $code1 $request->get("code1");
  3587.         $code2 $request->get("code2");
  3588.         $code3 $request->get("code3");
  3589.         $set1 $request->get("set");
  3590.         if ($set1 == 1) {
  3591.             if ($code1 == "") {
  3592.                 return new Response('erore');
  3593.             }
  3594.             $adress $UserService->codesecuriter($code1$iduser);
  3595.         }
  3596.         if ($set1 == 2) {
  3597.             if ($code2 == "") {
  3598.                 return new Response('erore');
  3599.             }
  3600.             $adress $UserService->codesecuriter($code2$iduser);
  3601.         }
  3602.         if ($set1 == 3) {
  3603.             if ($code3 == "") {
  3604.                 return new Response('erore');
  3605.             }
  3606.             $adress $UserService->codesecuriter($code3$iduser);
  3607.         }
  3608.         return new Response('done');
  3609.     }
  3610.     /**
  3611.      * @Route("/Parent/Accueil5sur5/suprimer_Album_panier", name="suprimer_Album_panier",methods={"POST"})
  3612.      */
  3613.     public function suprimer_Album_panier(Request $request)
  3614.     {
  3615.         $session $this->session;
  3616.         $Products $session->get("Panier");
  3617.         $id $request->get("p");
  3618.         foreach ($Products as $key => $p) {
  3619.             if ($p['id'] == $id) {
  3620.                 unset($Products[$key]);
  3621.             }
  3622.         }
  3623.         $session->set('Panier'$Products);
  3624.         $em $this->em;
  3625.         $user $this->getUser();
  3626.         $produit $em->getRepository(Produit::class)->find($id);
  3627.         $typeref $em->getRepository(Typeref::class)->find(8);
  3628.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3629.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3630.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3631.         $em->getManager()->remove($panierProduit);
  3632.         $em->getManager()->flush();
  3633.         return new Response('done');
  3634.     }
  3635.     /**
  3636.      * @Route("/Parent/Accueil5sur5/additiondproduit_parent", name="additiondproduit_parent",methods={"POST"})
  3637.      */
  3638.     public function additiondproduit_parent(Request $request)
  3639.     {
  3640.         $session $this->session;
  3641.         $Products $session->get("Panier");
  3642.         $id $request->get("p");
  3643.         foreach ($Products as $key => $p) {
  3644.             if ($p['id'] == $id) {
  3645.                 $qte_dans_panier $Products[$key]['qte'];
  3646.                 $mnt_dans_panier $Products[$key]['mnt'] / $qte_dans_panier;
  3647.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3648.                 // $Products[$key]['mnt']=$p['mnt']+$mnt_dans_panier;
  3649.             }
  3650.         }
  3651.         $session->set('Panier'$Products);
  3652.         //Touhemi addition au panier produit ds bd
  3653.         $em $this->em;
  3654.         $user $this->getUser();
  3655.         $produit $em->getRepository(Produit::class)->find($id);
  3656.         $typeref $em->getRepository(Typeref::class)->find(8);
  3657.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3658.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3659.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3660.         if ($panierProduit != null) {
  3661.             $oldQte $panierProduit->getQuantite();
  3662.             $newQte $oldQte 1;
  3663.             $panierProduit->setQuantite($newQte);
  3664.             $oldTotal $panierProduit->getPrixTotal();
  3665.             $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3666.             $panierProduit->setPrixTotal($newTotal);
  3667.             $em->getManager()->persist($panierProduit);
  3668.             $em->getManager()->flush();
  3669.         }
  3670.         return new Response('done');
  3671.     }
  3672.     /**
  3673.      * @Route("/Parent/Accueil5sur5/sousstractionproduit_parent", name="sousstractionproduit_parent",methods={"POST"})
  3674.      */
  3675.     public function sousstractionproduit_parent(Request $request)
  3676.     {
  3677.         $session $this->session;
  3678.         $Products $session->get("Panier");
  3679.         $id $request->get("p");
  3680.         foreach ($Products as $key => $p) {
  3681.             if ($p['id'] == $id) {
  3682.                 $qte_dans_panier $Products[$key]['qte'];
  3683.                 $mnt_dans_panier $Products[$key]['mnt'] / $qte_dans_panier;
  3684.                 $Products[$key]['qte'] = $p['qte'] - 1;
  3685.                 // $Products[$key]['mnt']=$p['mnt']-$mnt_dans_panier;
  3686.                 $set $Products[$key];
  3687.             }
  3688.             if ($Products[$key]['qte'] == 0) {
  3689.                 unset($Products[$key]);
  3690.             }
  3691.         }
  3692.         $session->set('Panier'$Products);
  3693.         $em $this->em;
  3694.         $user $this->getUser();
  3695.         $produit $em->getRepository(Produit::class)->find($id);
  3696.         $typeref $em->getRepository(Typeref::class)->find(8);
  3697.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3698.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3699.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3700.         if ($panierProduit != null) {
  3701.             $oldQte $panierProduit->getQuantite();
  3702.             $newQte $oldQte 1;
  3703.             if ($newQte 0) {
  3704.                 $panierProduit->setQuantite($newQte);
  3705.                 $oldTotal $panierProduit->getPrixTotal();
  3706.                 $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3707.                 $panierProduit->setPrixTotal($newTotal);
  3708.                 $em->getManager()->persist($panierProduit);
  3709.                 $em->getManager()->flush();
  3710.             }
  3711.             if ($newQte == 0) {
  3712.                 $em->getManager()->remove($panierProduit);
  3713.                 $em->getManager()->flush();
  3714.             }
  3715.         }
  3716.         return new Response('done');
  3717.     }
  3718.     /**
  3719.      * @Route("Parent/AjoutAlbum_parent/{idAlbm}", name="EditionAlbumfrompanier")
  3720.      */
  3721.     public function EditionAlbumParent_panier($idAlbm)
  3722.     {
  3723.         $SEjourService $this->sejourService;
  3724.         /** @var \App\Entity\User $user */
  3725.         $user $this->getUser();
  3726.         $userId $user->getId();
  3727.         $user $this->getUser();
  3728.         $session $this->session;
  3729.         $session->set('pageMenu''');
  3730.         $idSejour $session->get("Sejour");
  3731.         $produitcondition $session->get("produit");
  3732.         $produit $session->get("produittype");
  3733.         $sejour $SEjourService->getsejourpourparent($idSejour);
  3734.         $em $this->em;
  3735.         $clipart null;
  3736.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  3737.         $nbLikes 0;
  3738.         if ($listeattachlikephoto) {
  3739.             $nbLikes count($listeattachlikephoto);
  3740.         }
  3741.         $AllPages null;
  3742.         $Albumproduct null;
  3743.         $AllPagesAcc null;
  3744.         $random false;
  3745.         $Albumproduct $em->getRepository(Produit::class)->find($idAlbm);
  3746.         if ($Albumproduct == null || $Albumproduct == "") {
  3747.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
  3748.             $random true;
  3749.         }
  3750.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  3751.         $idAcc $sejour->getIdAcommp();
  3752.         $albumAcc null;
  3753.         $allpagesResult = array();
  3754.         $tabacc = array();
  3755.         $tabacc1 = array();
  3756.         foreach ($AllPages as $page) {
  3757.             $pageJ json_decode($page->getCouleurbordure());
  3758.             $pageDec json_decode($pageJ[0]);
  3759.             $attache json_decode($pageDec->attache);
  3760.             foreach ($attache as $att) {
  3761.                 $attachDec json_decode($att);
  3762.                 if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  3763.                     $idAttach json_decode($attachDec->id);
  3764.                     array_push($tabacc$idAttach);
  3765.                 }
  3766.             }
  3767.         }
  3768.         $tabacc1 array_count_values($tabacc);
  3769.         $part $sejour->getIdPartenaire();
  3770.         $nompart $part->getUsername();
  3771.         $logopart $part->getLogourl();
  3772.         $session->set('produit'$Albumproduct->gettype());
  3773.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  3774.         $nbphoto count($listeattach);
  3775.         if ($Albumproduct->getVersion() === 'new') {
  3776.             if ($nbLikes != 0) {
  3777.                 return $this->render('Parent/NewAlbumLikes.html.twig', ["tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes'nbPhoto' => $nbphoto]);
  3778.             }
  3779.             return $this->render('Parent/NewAlbumLikes.html.twig', ["listeattach" => $listeattach"tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'nbLikes' => $nbLikes'nbPhoto' => $nbphoto]);
  3780.         } else {
  3781.             return $this->render('Parent/NewAlbumLikes.html.twig', ["tabacc" => $tabacc1"listeattach" => $listeattach"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'nbLikes' => $nbLikes'nbPhoto' => $nbphoto]);
  3782.         }
  3783.     }
  3784.     /**
  3785.      * @Route("/Parent/Accueil5sur5/modifierLabel_produit_parent", name="modifierLabel_produit_parent",methods={"POST"})
  3786.      */
  3787.     public function modifierLabel_produit_parent(Request $request)
  3788.     {
  3789.         $SEjourService $this->sejourService;
  3790.         /** @var \App\Entity\User $user */
  3791.         $user $this->getUser();
  3792.         $userId $user->getId();
  3793.         $session $this->session;
  3794.         $idPrd $request->get("id");
  3795.         $description $request->get("description");
  3796.         $SEjourService->modif_lbel_Produit($idPrd$description);
  3797.         $Products $session->get("Panier");
  3798.         if ($Products != null) {
  3799.             foreach ($Products as $key => $p) {
  3800.                 if ($idPrd == $p['id']) {
  3801.                     $Products[$key]["ident"] = $description;
  3802.                 }
  3803.             }
  3804.         }
  3805.         $session->set('Panier'$Products);
  3806.         return new Response('done');
  3807.     }
  3808.     /**
  3809.      * @Route("/Parent/checkCodePromoParents", name="checkCodePromoParents")
  3810.      */
  3811.     public function checkCodePromoParents(Request $request)
  3812.     {
  3813.         $em $this->em;
  3814.         $SejourService $this->sejourService;
  3815.         $session $this->get('session');
  3816.         $code $request->get('code');
  3817.         $idUser $request->get('idUser');
  3818.         $user $em->getRepository(User::class)->findOneBy(['id' => $idUser]);
  3819.         $CodePromoUtilisse "";
  3820.         $totalpanier  $request->get('totalPanier');
  3821.         $infosPromo $SejourService->checkCodePromoPrents($code$user);
  3822.         $remise 0;
  3823.         $pourcentage 0;
  3824.         if (isset($infosPromo['remise'])) {
  3825.             $remise =  $infosPromo['remise'];
  3826.         }
  3827.         if (isset($infosPromo['pourcentage'])) {
  3828.             $pourcentage =  $infosPromo['pourcentage'];
  3829.         }
  3830.         $totalRemise $totalpanier $pourcentage;
  3831.         $totalRemise = ($totalRemise) / 100;
  3832.         $totalpanierNew $totalpanier $totalRemise;
  3833.         $tvaTotalRemise =   ($totalpanierNew 20) / 100;
  3834.         $user->setShowdetailsphotos("4");
  3835.         $em->getManager()->persist($user);
  3836.         $em->getManager()->flush();
  3837.         return new JsonResponse(array('message' =>  $infosPromo['test'], 'pourcentage' => intval($infosPromo['pourcentage']), 'remise' => $remise'totalDupanier' => $totalpanierNew'totalRemise' => $totalRemise"tvaTotalRemise" => $tvaTotalRemise"CodePromoUtilisse" => $CodePromoUtilisse), 200);
  3838.     }
  3839.     /**
  3840.      * @Route("/Parent/Accueil5sur5/ParentcomandeProduit", name="ParentcomandeProduit",methods={"POST"})
  3841.      */
  3842.     public function ParentcomandeProduit(Request $request)
  3843.     {
  3844.         $em $this->em;
  3845.         $comandeservice $this->commandeService;
  3846.         $sejourService $this->sejourService;
  3847.         /** @var \App\Entity\User $user */
  3848.         $user $this->getUser();
  3849.         $userId $user->getId();
  3850.         $session $this->session;
  3851.         $frais $request->get("fraiEnvoi");
  3852.         $Products $session->get("Panier");
  3853.         $totalepanier $request->get("totalepanier");
  3854.         $envoipost $request->get("envoipost");
  3855.         $remise $request->get("remise");
  3856.         $totalBlackFriday $request->get("totalBlackFriday");
  3857.         $session->set('envoipost'$envoipost);
  3858.         $containsProduitType20 false;
  3859.         $comand $comandeservice->addcomande_parent($Products$userId$frais$totalepanier$envoipost$remise$containsProduitType20);
  3860.         $codePromo $request->get('codePromo');
  3861.         $test $sejourService->checkCodePromo($codePromo);
  3862.         if (isset($test['test'])) {
  3863.             if ($test['test'] == true) {
  3864.                 $promotion $sejourService->findPromotionByCode($codePromo);
  3865.                 if ($promotion) {
  3866.                     $listeProduitsCommande $em->getRepository(ComandeProduit::class)->findBy(array('idComande' => $comand->getId()));
  3867.                     $pourcentage intval($promotion->getPourcentage());
  3868.                     if ($promotion->getNbreApplicable() == 1) {
  3869.                         foreach ($listeProduitsCommande as $cmdProduit) {
  3870.                             $cmdProduit->setPourcentage($pourcentage);
  3871.                             $em->getManager()->persist($cmdProduit);
  3872.                             $em->getManager()->flush();
  3873.                         }
  3874.                     } else {
  3875.                         foreach ($listeProduitsCommande as $cmdProduit) {
  3876.                             $qte $cmdProduit->getQuantiter();
  3877.                             for ($i 0$i $qte$i++) {
  3878.                                 $ligneCmdProd = new ComandeProduit();
  3879.                                 $ligneCmdProd->setQuantiter(1);
  3880.                                 $ligneCmdProd->setIdProduit($cmdProduit->getIdProduit());
  3881.                                 $ligneCmdProd->setIdComande($cmdProduit->getIdComande());
  3882.                                 $ligneCmdProd->setDate($cmdProduit->getDate());
  3883.                                 $em->getManager()->persist($ligneCmdProd);
  3884.                                 $em->getManager()->remove($cmdProduit);
  3885.                             }
  3886.                             $em->getManager()->flush();
  3887.                         }
  3888.                         $listeProduitsCommande $em->getRepository(ComandeProduit::class)->findBy(array('idComande' => $comand->getId()));
  3889.                         $qte 0;
  3890.                         $tabPrices = [];
  3891.                         foreach ($listeProduitsCommande as $cmdProduit) {
  3892.                             $ligne = array('idCmdProduit' => $cmdProduit->getId(), 'price' => $cmdProduit->getIdProduit()->getIdConditionnement()->getMontantTTC());
  3893.                             $qte += $cmdProduit->getQuantiter();
  3894.                             array_push($tabPrices$ligne);
  3895.                         }
  3896.                         $x intval($qte $promotion->getNbreApplicable());
  3897.                         $this->aasort($tabPrices"price");
  3898.                         $tabPricesPromo =   array_slice($tabPrices, -$x$xtrue);
  3899.                         foreach ($tabPricesPromo as $item) {
  3900.                             $cp $em->getRepository(ComandeProduit::class)->find($item['idCmdProduit']);
  3901.                             $cp->setPourcentage($pourcentage);
  3902.                             $em->getManager()->persist($cp);
  3903.                             $em->getManager()->flush();
  3904.                         }
  3905.                     }
  3906.                     $comand->setIdPromotion($promotion);
  3907.                 }
  3908.             }
  3909.         }
  3910.         $session->set('commandeActual'$comand->getId());
  3911.         return new Response($comand->getId());
  3912.     }
  3913.     function aasort(&$array$key)
  3914.     {
  3915.         $sorter = array();
  3916.         $ret = array();
  3917.         reset($array);
  3918.         foreach ($array as $ii => $va) {
  3919.             $sorter[$ii] = $va[$key];
  3920.         }
  3921.         arsort($sorter);
  3922.         foreach ($sorter as $ii => $va) {
  3923.             $ret[$ii] = $array[$ii];
  3924.         }
  3925.         $array $ret;
  3926.     }
  3927.     /**
  3928.      * @Route("Parent/LivreSejourParent", name="Livre_du_Sejour")
  3929.      */
  3930.     public function LivreSejourParent()
  3931.     {
  3932.         $SEjourService $this->sejourService;
  3933.         /** @var \App\Entity\User $user */
  3934.         $user $this->getUser();
  3935.         $userId $user->getId();
  3936.         $user $this->getUser();
  3937.         $session $this->session;
  3938.         $idSejour $session->get("Sejour");
  3939.         $session->set('LivreSejour''LivreSejour');
  3940.         $sejour $SEjourService->getsejourpourparent($idSejour);
  3941.         $em $this->em;
  3942.         $clipart null;
  3943.         $AllPages null;
  3944.         $AllPagesAcc null;
  3945.         $random false;
  3946.         $codeSejour $sejour->getCodeSejour();
  3947.         $nomprod "Livre_Sejour" $codeSejour;
  3948.         $sejour $em->getRepository(Sejour::class)->findOneBy(['id' => $idSejour]);
  3949.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['version' => 'Livre_Sejour_Admin''labele' => $nomprod'idsjour' => $idSejour]);
  3950.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  3951.         $tabacc = array();
  3952.         $tabacc1 = array();
  3953.         foreach ($AllPages as $page) {
  3954.             $pageJ json_decode($page->getCouleurbordure());
  3955.             $pageDec json_decode($pageJ[0]);
  3956.             $attache json_decode($pageDec->attache);
  3957.             foreach ($attache as $att) {
  3958.                 $attachDec json_decode($att);
  3959.                 if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  3960.                     $idAttach json_decode($attachDec->id);
  3961.                     array_push($tabacc$idAttach);
  3962.                 }
  3963.             }
  3964.         }
  3965.         $tabacc1 array_count_values($tabacc);
  3966.         $part $sejour->getIdPartenaire();
  3967.         $nompart $part->getUsername();
  3968.         $logopart $part->getLogourl();
  3969.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  3970.         $nbPhoto count($listeattach);
  3971.         //  $session->set('produit', $Albumproduct->gettype());
  3972.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  3973.         $nbLikes count($listeattachlikephoto);
  3974.         return $this->render('Parent/LivreSejour.html.twig', ["tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => null'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes'nbPhotos' => $nbPhoto]);
  3975.     }
  3976.     /**
  3977.      * @Route("Parent/LivrePhotos_Parent/{idAlbm}", name="Editionlivrefrompanier")
  3978.      */
  3979.     public function EditionLivrePhotosParentparId($idAlbm)
  3980.     {
  3981.         $SEjourService $this->sejourService;
  3982.         /** @var \App\Entity\User $user */
  3983.         $user $this->getUser();
  3984.         $userId $user->getId();
  3985.         $user $this->getUser();
  3986.         $session $this->session;
  3987.         $session->set('pageMenu''');
  3988.         $idSejour $session->get("Sejour");
  3989.         $produit $session->get("produit");
  3990.         // $sejour = $SEjourService->getsejourpourparent($idSejour);
  3991.         $sejour $this->em->getRepository(Sejour::class)->findOneBy(["id" => $idSejour]);
  3992.         $em $this->em;
  3993.         $clipart null;
  3994.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  3995.         $nbLikes count($listeattachlikephoto);
  3996.         $AllPages null;
  3997.         $Albumproduct null;
  3998.         $AllPagesAcc null;
  3999.         $random false;
  4000.         $Albumproduct $em->getRepository(Produit::class)->find($idAlbm);
  4001.         if ($Albumproduct == null || $Albumproduct == "") {
  4002.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
  4003.             $random true;
  4004.         }
  4005.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4006.         $idAcc $sejour->getIdAcommp();
  4007.         $albumAcc null;
  4008.         $allpagesResult = array();
  4009.         $tabacc = array();
  4010.         $tabacc1 = array();
  4011.         foreach ($AllPages as $page) {
  4012.             $pageJ json_decode($page->getCouleurbordure());
  4013.             $pageDec json_decode($pageJ[0]);
  4014.             $attache json_decode($pageDec->attache);
  4015.             foreach ($attache as $att) {
  4016.                 $attachDec json_decode($att);
  4017.                 if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  4018.                     $idAttach json_decode($attachDec->id);
  4019.                     array_push($tabacc$idAttach);
  4020.                 }
  4021.             }
  4022.         }
  4023.         $tabacc1 array_count_values($tabacc);
  4024.         $part $sejour->getIdPartenaire();
  4025.         $nompart $part->getUsername();
  4026.         $logopart $part->getLogourl();
  4027.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4028.         $nbPhoto count($listeattach);
  4029.         $session->set('produit'$Albumproduct->gettype());
  4030.         return $this->render('Parent/NewLivreLikes.html.twig', ["tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'random' => $random'listeattach' => $listeattach'nbPhotos' => $nbPhoto'nbLikes' => $nbLikes]);
  4031.     }
  4032.     /**
  4033.      * @Route("Parent/ModificationPochettePhotos/{nbr}/{id}", name="EditionPochettefrompanier")
  4034.      */
  4035.     public function EditionPochetteParentfrompanier($nbr$id)
  4036.     {
  4037.         $SEjourService $this->sejourService;
  4038.         /** @var \App\Entity\User $user */
  4039.         $user $this->getUser();
  4040.         $userId $user->getId();
  4041.         $user $this->getUser();
  4042.         $session $this->session;
  4043.         $session->set('pageMenu''');
  4044.         $idSejour $session->get("Sejour");
  4045.         $produitcondition $session->get("produit");
  4046.         $produit $session->get("produittype");
  4047.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4048.         $em $this->em;
  4049.         $clipart $em->getRepository(Clipart::class)->findAll();
  4050.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4051.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4052.         $nbLikes count($listeattachlikephoto);
  4053.         //Stella
  4054.         $AllPagesAcc null;
  4055.         $random false;
  4056.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  4057.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4058.         $idAcc $sejour->getIdAcommp();
  4059.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4060.         $part $sejour->getIdPartenaire();
  4061.         $nompart $part->getUsername();
  4062.         $logopart $part->getLogourl();
  4063.         $nomProjet $Albumproduct->getLabele();
  4064.         $nbPhoto count($listeattach);
  4065.         $nbLikes count($listeattachlikephoto);
  4066.         if ($nbLikes $nbr) {
  4067.             return $this->render('Parent/PochettePhotosEdit.html.twig', ["nbr" => $nbr"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $Albumproduct'AllPagesAcc' => $AllPagesAcc'random' => $random'photosSejour' => $listeattach'nbLikes' => $nbLikes'nbAttach' => $nbPhoto'nomProjet' => $nomProjet]);
  4068.         }
  4069.         if ($nbLikes >= $nbr) {
  4070.             return $this->render('Parent/PochettePhotosEditLikes.html.twig', ["nbr" => $nbr"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $Albumproduct'AllPagesAcc' => $AllPagesAcc'random' => $random'photosSejour' => $listeattach'nbLikes' => $nbLikes'nbAttach' => $nbPhoto'nomProjet' => $nomProjet]);
  4071.         }
  4072.     }
  4073.     /**
  4074.      * @Route("Parent/ModificationCalendrier/{id}", name="EditionCalendrierParentfrompanier")
  4075.      */
  4076.     public function EditionCalendrierParentfrompanier($id)
  4077.     {
  4078.         $SEjourService $this->sejourService;
  4079.         /** @var \App\Entity\User $user */
  4080.         $user $this->getUser();
  4081.         $userId $user->getId();
  4082.         $user $this->getUser();
  4083.         $session $this->session;
  4084.         $session->set('pageMenu''');
  4085.         $idSejour $session->get("Sejour");
  4086.         $produitcondition $session->get("produit");
  4087.         $produit $session->get("produittype");
  4088.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4089.         $em $this->em;
  4090.         $clipart $em->getRepository(Clipart::class)->findAll();
  4091.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4092.         $random false;
  4093.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  4094.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4095.         $part $sejour->getIdPartenaire();
  4096.         $nompart $part->getUsername();
  4097.         $logopart $part->getLogourl();
  4098.         return $this->render('Parent/Calendrier.html.twig', ["nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'random' => $random]);
  4099.     }
  4100.     /**
  4101.      * @Route("Parent/ModificationPhotosRetros/{nbr}/{id}", name="EditionRetrofrompanier")
  4102.      */
  4103.     public function EditionRetroParentfrompanier($nbr$id)
  4104.     {
  4105.         $SEjourService $this->sejourService;
  4106.         /** @var \App\Entity\User $user */
  4107.         $user $this->getUser();
  4108.         $userId $user->getId();
  4109.         $user $this->getUser();
  4110.         $session $this->session;
  4111.         $session->set('pageMenu''');
  4112.         $idSejour $session->get("Sejour");
  4113.         $produitcondition $session->get("produit");
  4114.         $produit $session->get("produittype");
  4115.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4116.         $em $this->em;
  4117.         $clipart $em->getRepository(Clipart::class)->findAll();
  4118.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4119.         $listerandom $listeattachlikephoto;
  4120.         $nbLikes count($listeattachlikephoto);
  4121.         $AllPagesAcc null;
  4122.         $random false;
  4123.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  4124.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4125.         $idAcc $sejour->getIdAcommp();
  4126.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4127.         $part $sejour->getIdPartenaire();
  4128.         $nompart $part->getUsername();
  4129.         $logopart $part->getLogourl();
  4130.         //Liste des photos public
  4131.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4132.         $nbPhoto =  $listeattach;
  4133.         if ($nbLikes == 0) {
  4134.             return $this->render('Parent/PhotosRetros.html.twig', ["nbr" => $nbr" nbPhoto" => $nbPhoto"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattach'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes]);
  4135.         }
  4136.         if ($nbLikes != 0) {
  4137.             return $this->render('Parent/PhotosRetrosLikes.html.twig', ["nbr" => $nbr" nbPhoto" => $nbPhoto"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'listeattach' => $listeattach'nbLikes' => $nbLikes]);
  4138.         }
  4139.     }
  4140.     //CommanderalbumSejour
  4141.     /**
  4142.      * @Route("/Parent/CommanderalbumSejour", name="CommanderalbumSejour")
  4143.      */
  4144.     public function CommanderalbumSejour(Request $request)
  4145.     {
  4146.         $session $this->session;
  4147.         $serviceuser $this->etablissementService;
  4148.         $page $request->get("pages");
  4149.         $sejour $request->get("sejour");
  4150.         $prodid $request->get('idProd');
  4151.         $nomprod $request->get('nomprod');
  4152.         $versionalbm $request->get('new');
  4153.         $user $this->getUser();
  4154.         $em $this->em;
  4155.         //  $AlbumSejour  = $em->getRepository(Produit::class)->findOneBy(array("id" =>$prodid));
  4156.         $produit $session->get("produittype");
  4157.         $produitcondi $session->get("produit");
  4158.         $Album $serviceuser->saveCopyalbumParent($page$user$sejour$prodid$produit$produitcondi$nomprod$versionalbm);
  4159.         $inser false;
  4160.         $session $this->session;
  4161.         $Products $session->get("Panier");
  4162.         $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  4163.         $user $this->getUser();
  4164.         $typeref $em->getRepository(Typeref::class)->find(8);
  4165.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4166.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4167.         //fin
  4168.         if ($panierTrace == null) {
  4169.             $panierTrace = new Panier();
  4170.             $dateNow = new \Datetime();
  4171.             $panierTrace->setDateCreation($dateNow);
  4172.             $panierTrace->setCreerPar($user);
  4173.             $panierTrace->setStatut($statutPanier);
  4174.             $em->getManager()->persist($panierTrace);
  4175.             $em->getManager()->flush();
  4176.         }
  4177.         if ($Products == null) {
  4178.             $Products = [];
  4179.         }
  4180.         foreach ($Products as $key => $p) {
  4181.             if ($p['id'] == $produit->getId()) {
  4182.                 $inser true;
  4183.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4184.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  4185.             }
  4186.         }
  4187.         //Touhemi :Rechercher  si le produti existe dĂ©ja ds panierProduit
  4188.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $Album"idPanier" => $panierTrace));
  4189.         if ($panierProduit == null) {
  4190.             $panierProduit = new PanierProduit();
  4191.             $panierProduit->setIdProduit($Album);
  4192.             $panierProduit->setIdPanier($panierTrace);
  4193.             $em->getManager()->persist($panierProduit);
  4194.             $em->getManager()->flush();
  4195.         }
  4196.         //fin
  4197.         //Touhemi ajouter plus un au produit et modifier prixTotal
  4198.         $oldQte $panierProduit->getQuantite();
  4199.         $newQte $oldQte 1;
  4200.         $panierProduit->setQuantite($newQte);
  4201.         $oldTotal $panierProduit->getPrixTotal();
  4202.         $newTotal $oldTotal $Album->getIdConditionnement()->getMontantTTC();
  4203.         $panierProduit->setPrixTotal($newTotal);
  4204.         $this->em->getManager()->persist($panierProduit);
  4205.         $this->em->getManager()->flush();
  4206.         //fin
  4207.         if ($inser === false) {
  4208.             //get nessaisire element
  4209.             $p = [];
  4210.             $p["id"] = $produit->getId();
  4211.             $p["nom"] = $produit->getType()->getLabeletype();
  4212.             $p["ident"] = $produit->getLabele();
  4213.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4214.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4215.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4216.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4217.             $p["qte"] = 1;
  4218.             array_push($Products$p);
  4219.         }
  4220.         $session->set('Panier'$Products);
  4221.         //sendemail_parent
  4222.         $dateNow = new \Datetime();
  4223.         /** @var \App\Entity\User $user */
  4224.         $user $this->getUser();
  4225.         $userEmail $user->getEmail();
  4226.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4227.         //$this->EmailServie->MailRelancePanier($userEmail);
  4228.         //dd($etablissementDetail);
  4229.         return new response('done');
  4230.     }
  4231.     /**
  4232.      * @Route("/Parent/AlbummsavealbumcomandeParent", name="AlbummsavealbumcomandeParent")
  4233.      */
  4234.     public function Albummcomandesavealbum(Request $request)
  4235.     {
  4236.         $session $this->session;
  4237.         $serviceuser $this->etablissementService;
  4238.         $page $request->get("pages");
  4239.         $sejour $request->get("sejour");
  4240.         $prodid $request->get('idProd');
  4241.         $nomprod $request->get('nomprod');
  4242.         $versionalbm $request->get('new');
  4243.         $user $this->getUser();
  4244.         $produit $session->get("produittype");
  4245.         $produitcondi $session->get("produit");
  4246.         $Album $serviceuser->savealbumParent($page$user$sejour$prodid$produit$produitcondi$nomprod$versionalbm);
  4247.         $inser false;
  4248.         $session $this->session;
  4249.         $Products $session->get("Panier");
  4250.         $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  4251.         $em $this->em;
  4252.         $user $this->getUser();
  4253.         $typeref $em->getRepository(Typeref::class)->find(8);
  4254.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4255.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4256.         //fin
  4257.         if ($panierTrace == null) {
  4258.             $panierTrace = new Panier();
  4259.             $dateNow = new \Datetime();
  4260.             $panierTrace->setDateCreation($dateNow);
  4261.             $panierTrace->setCreerPar($user);
  4262.             $panierTrace->setStatut($statutPanier);
  4263.             $em->getManager()->persist($panierTrace);
  4264.             $em->getManager()->flush();
  4265.         }
  4266.         if ($Products == null) {
  4267.             $Products = [];
  4268.         }
  4269.         foreach ($Products as $key => $p) {
  4270.             if ($p['id'] == $produit->getId()) {
  4271.                 $inser true;
  4272.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4273.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  4274.             }
  4275.         }
  4276.         //Touhemi :Rechercher  si le produti existe dĂ©ja ds panierProduit
  4277.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $Album"idPanier" => $panierTrace));
  4278.         if ($panierProduit == null) {
  4279.             $panierProduit = new PanierProduit();
  4280.             $panierProduit->setIdProduit($Album);
  4281.             $panierProduit->setIdPanier($panierTrace);
  4282.             $em->getManager()->persist($panierProduit);
  4283.             $em->getManager()->flush();
  4284.         }
  4285.         //fin
  4286.         //Touhemi ajouter plus un au produit et modifier prixTotal
  4287.         $oldQte $panierProduit->getQuantite();
  4288.         $newQte $oldQte 1;
  4289.         $panierProduit->setQuantite($newQte);
  4290.         $oldTotal $panierProduit->getPrixTotal();
  4291.         $newTotal $oldTotal $Album->getIdConditionnement()->getMontantTTC();
  4292.         $panierProduit->setPrixTotal($newTotal);
  4293.         $this->em->getManager()->persist($panierProduit);
  4294.         $this->em->getManager()->flush();
  4295.         //fin
  4296.         if ($inser === false) {
  4297.             //get nessaisire element
  4298.             $p = [];
  4299.             $p["id"] = $produit->getId();
  4300.             $p["nom"] = $produit->getType()->getLabeletype();
  4301.             $p["ident"] = $produit->getLabele();
  4302.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4303.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4304.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4305.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4306.             $p["qte"] = 1;
  4307.             array_push($Products$p);
  4308.         }
  4309.         $session->set('Panier'$Products);
  4310.         //sendemail_parent
  4311.         $dateNow = new \Datetime();
  4312.         /** @var \App\Entity\User $user */
  4313.         $user $this->getUser();
  4314.         $userEmail $user->getEmail();
  4315.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4316.         //$this->EmailServie->MailRelancePanier($userEmail);
  4317.         //dd($etablissementDetail);
  4318.         return new response('done');
  4319.     }
  4320.     /**
  4321.      * @Route("/Parent/saveLivrePhotosParentPanier", name="saveLivrePhotosParentPanier")
  4322.      */
  4323.     public function saveLivrePhotospuisPanier(Request $request)
  4324.     {
  4325.         $em $this->em;
  4326.         $session $this->session;
  4327.         $produittype $session->get("produit");
  4328.         $produit $session->get("produittype");
  4329.         $serviceuser $this->etablissementService;
  4330.         $page $request->get("pages");
  4331.         $sejour $request->get("sejour");
  4332.         $prodid $request->get('idProd');
  4333.         $nomprod $request->get('nomprod');
  4334.         $versionalbm $request->get('new');
  4335.         $user $this->getUser();
  4336.         $Album $serviceuser->savelivreParent($page$user$sejour$prodid$produittype$nomprod$versionalbm);
  4337.         //dd($etablissementDetail);
  4338.         $inser false;
  4339.         $session $this->session;
  4340.         $Products $session->get("Panier");
  4341.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  4342.         //Touhemi  03-07-2020 :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  4343.         $user $this->getUser();
  4344.         $typeref $em->getRepository(Typeref::class)->find(8);
  4345.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4346.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4347.         //fin
  4348.         if ($panierTrace == null) {
  4349.             $panierTrace = new Panier();
  4350.             $dateNow = new \Datetime();
  4351.             $panierTrace->setDateCreation($dateNow);
  4352.             $panierTrace->setCreerPar($user);
  4353.             $panierTrace->setStatut($statutPanier);
  4354.             $em->getManager()->persist($panierTrace);
  4355.             $em->getManager()->flush();
  4356.         }
  4357.         //Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on Ă©crit un produit
  4358.         if ($Products == null) {
  4359.             $Products = [];
  4360.         }
  4361.         foreach ($Products as $key => $p) {
  4362.             if ($p['id'] == $produit->getId()) {
  4363.                 $inser true;
  4364.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4365.                 // $Products[$key]['mnt'] = $p['mnt'] + $produit->getType()->getTraif();
  4366.             }
  4367.         }
  4368.         //Touhemi 03-07-2020 :Rechercher  si le produti existe dĂ©ja ds panierProduit
  4369.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  4370.         if ($panierProduit == null) {
  4371.             $panierProduit = new PanierProduit();
  4372.             $panierProduit->setIdProduit($produit);
  4373.             $panierProduit->setIdPanier($panierTrace);
  4374.             $em->getManager()->persist($panierProduit);
  4375.             $em->getManager()->flush();
  4376.         }
  4377.         //fin
  4378.         //   Touhemi 02-07-2020 ajouter plus un au produit et modifier prixTotal
  4379.         $oldQte $panierProduit->getQuantite();
  4380.         $newQte $oldQte 1;
  4381.         $panierProduit->setQuantite($newQte);
  4382.         $oldTotal $panierProduit->getPrixTotal();
  4383.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  4384.         $panierProduit->setPrixTotal($newTotal);
  4385.         $em->getManager()->persist($panierProduit);
  4386.         $em->getManager()->flush();
  4387.         //fin
  4388.         if ($inser === false) {
  4389.             //get nessaisire element
  4390.             $p = [];
  4391.             $p["id"] = $produit->getId();
  4392.             $p["nom"] = $produit->getType()->getLabeletype();
  4393.             $p["ident"] = $produit->getLabele();
  4394.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4395.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4396.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4397.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4398.             $p["qte"] = 1;
  4399.             array_push($Products$p);
  4400.         }
  4401.         $session->set('Panier'$Products);
  4402.         //sendmail_patrent
  4403.         $dateNow = new \Datetime();
  4404.         /** @var \App\Entity\User $user */
  4405.         $user $this->getUser();
  4406.         $userEmail $user->getEmail();
  4407.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4408.         // $this->EmailServie->MailRelancePanier($userEmail);
  4409.         return new response('done');
  4410.     }
  4411.     /**
  4412.      * @Route("parent/condcnx", name="connexionparentsejour",methods={"POST"})
  4413.      */
  4414.     public function condition(Request $request)
  4415.     {
  4416.         $UserService $this->userService;
  4417.         $id $request->get('id');
  4418.         $ParentSejour $UserService->conditioncnxparent($id);
  4419.         return new JsonResponse('done');
  4420.     }
  4421.     /**
  4422.      * @Route("/Parent/MaPropresPhotos", name="MaPropresPhotos")
  4423.      */
  4424.     public function MaPropresPhotos(Request $request)
  4425.     {
  4426.         $path $request->get("path");
  4427.         $type $request->get("type");
  4428.         $sejId $request->get("id");
  4429.         $dateSejour $request->get("date");
  4430.         $SejourServiceattachh $this->sejourService;
  4431.         $Userservicemail $this->userService;
  4432.         $sejourfind $SejourServiceattachh->sejoursansattach($sejId);
  4433.         //$sendmail = $Userservicemail->sendmailuserforfirstattach($sejId);
  4434.         $attachementservice $this->attachementService;
  4435.         foreach ($path as $key => $path) {
  4436.             $src $path['path'];
  4437.             $attachement $attachementservice->creationAttachementS($src$type$dateSejour);
  4438.             $sejourservice $this->sejourService;
  4439.             $sejAttach $sejourservice->monpropreattachement($sejId$attachement$this->getUser());
  4440.             if ((array_key_exists("latitude"$path)) && ($path['latitude'] != null)) {
  4441.                 $lat $path['latitude'];
  4442.                 $lng $path['longitude'];
  4443.                 $Cartervice $this->carteService;
  4444.                 $position $Cartervice->create_newPositionImage($this->getUser(), $lat$lng);
  4445.                 $Cartervice->affecterPosition($attachement$position);
  4446.                 $FindSejour $this->em->getRepository(Sejour::class)->find($sejId);
  4447.                 $FindSejour->setEtatAdresseCarte(true);
  4448.                 $this->em->getManager()->persist($FindSejour);
  4449.                 $this->em->getManager()->flush();
  4450.             }
  4451.             //Ajouter les photos aux favoris
  4452.             $Like $this->photosFavorisService;
  4453.             $Like->AddFavoris($this->getUser(), $attachement$sejId);
  4454.         }
  4455.         return new JsonResponse(["id" => $attachement->getId()]);;
  4456.     }
  4457.     /**
  4458.      * @Route("/Parent/Ajouter_photo_sejour", name="pathadddnewphotos")
  4459.      */
  4460.     public function pathaddnewphotos()
  4461.     {
  4462.         /** @var \App\Entity\User $user */
  4463.         $user $this->getUser();
  4464.         $userId $user->getId();
  4465.         $session $this->session;
  4466.         $idParent $session->get("Sejour");
  4467.         $idSejour $session->get("Sejour");
  4468.         $conxparent $this->sejourService;
  4469.         $sejour1 $conxparent->sejourParentcnx($idSejour$idParent);
  4470.         //dd($sejour1);
  4471.         $SEjourService $this->sejourService;
  4472.         $sejour $SEjourService->getsejour($idSejour);
  4473.         //  dd($sejour);
  4474.         //Liste des photos public
  4475.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4476.         //Liste des photos privĂ©
  4477.         //        $listeattachPrivate = $SEjourService->getatachmentsejourparent($idSejour, $this->getUser()->getId());
  4478.         //        $AllPhotosParent = array_merge_recursive($listeattach, $listeattachPrivate);
  4479.         $listeVideo $SEjourService->getVideosejour($idSejour);
  4480.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  4481.         $nbImages count($listeattach);
  4482.         $positions $SEjourService->getsejourposition($idSejour);
  4483.         $messages $SEjourService->getsejourmessage($idSejour);
  4484.         $em $this->em;
  4485.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  4486.         //dd($parentsejour);
  4487.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4488.         $produits $this->typeProduiteService;
  4489.         $liste $produits->produitlistTypeConditionnement();
  4490.         $pubProd $user->getShowpubprod();
  4491.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4492.         if ($albumAcc == null) {
  4493.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  4494.         }
  4495.         return $this->render('Parent/DetailsSejour.html.twig', [
  4496.             "sejour" => $sejour,
  4497.             'listeattach' => $AllAttachements,
  4498.             'nbImages' => $nbImages,
  4499.             'albumAcc' => $albumAcc,
  4500.             'positions' => $positions,
  4501.             'messages' => $messages,
  4502.             'like' => $listeattachlikephoto,
  4503.             "parentsejour" => $parentsejour,
  4504.             'prod' => $liste,
  4505.             'smsnotif' => $parentsejour->getSmsnotif(),
  4506.             'showpub' => $pubProd
  4507.         ]);
  4508.     }
  4509.     /**
  4510.      * @Route("/Parent/ajouterauPanier_Parent_coffret", name="comandercoffre")
  4511.      */
  4512.     public function Ajouter_MonPanier_Coffret()
  4513.     {
  4514.         $em $this->em;
  4515.         $inser false;
  4516.         $session $this->session;
  4517.         $idSejour $session->get("Sejour");
  4518.         $userId $this->getUser();
  4519.         /** @var \App\Entity\User $user */
  4520.         $user $this->getUser();
  4521.         $userIdCom $user->getId();
  4522.         $sejourobj $this->em->getRepository(Sejour::class)->find($idSejour);
  4523.         $prodct $this->em->getRepository(Typeproduit::class)->find(15);
  4524.         $version $this->em->getRepository(Produit::class)->SearchVersionproduit($userIdCom);
  4525.         $Conditionnement $this->em->getRepository(TypeProduitConditionnement::class)->find(6);
  4526.         $Products $session->get("Panier");
  4527.         //Touhemi  03-07-2020 :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  4528.         $user $this->getUser();
  4529.         $typeref $em->getRepository(Typeref::class)->find(8);
  4530.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4531.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4532.         //fin
  4533.         if ($panierTrace == null) {
  4534.             $panierTrace = new Panier();
  4535.             $dateNow = new \Datetime();
  4536.             $panierTrace->setDateCreation($dateNow);
  4537.             $panierTrace->setCreerPar($user);
  4538.             $panierTrace->setStatut($statutPanier);
  4539.             $em->getManager()->persist($panierTrace);
  4540.             $em->getManager()->flush();
  4541.         }
  4542.         //Touhemi 02-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on Ă©crit un produit
  4543.         $produit $em->getRepository(Produit::class)->findOneBy(array("type" => $prodct'idConditionnement' => $Conditionnement'idsjour' => $sejourobj'iduser' => $user));
  4544.         if ($produit == null) {
  4545.             $produit = new Produit;
  4546.             $produit->setLabele("Coffret cadeau");
  4547.             $produit->setIduser($userId);
  4548.             $produit->setIdsjour($sejourobj);
  4549.             $produit->setDate(new \DateTime());
  4550.             $produit->setIdConditionnement($Conditionnement);
  4551.             $produit->setType($prodct);
  4552.             $em->getManager()->persist($produit);
  4553.             $em->getManager()->flush();
  4554.         }
  4555.         if ($Products == null) {
  4556.             $Products = [];
  4557.         }
  4558.         foreach ($Products as $key => $p) {
  4559.             if ($p['id'] == $produit->getId()) {
  4560.                 $inser true;
  4561.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4562.                 // $Products[$key]['mnt'] = $p['mnt'] + $produit->getType()->getTraif();
  4563.             }
  4564.         }
  4565.         //Touhemi 03-07-2020 :Rechercher  si le produti existe dĂ©ja ds panierProduit
  4566.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  4567.         if ($panierProduit == null) {
  4568.             $panierProduit = new PanierProduit();
  4569.             $panierProduit->setIdProduit($produit);
  4570.             $panierProduit->setIdPanier($panierTrace);
  4571.             $em->getManager()->persist($panierProduit);
  4572.             $em->getManager()->flush();
  4573.         }
  4574.         //fin
  4575.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  4576.         $oldQte $panierProduit->getQuantite();
  4577.         $newQte $oldQte 1;
  4578.         $panierProduit->setQuantite($newQte);
  4579.         $oldTotal $panierProduit->getPrixTotal();
  4580.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  4581.         $panierProduit->setPrixTotal($newTotal);
  4582.         $em->getManager()->persist($panierProduit);
  4583.         $em->getManager()->flush();
  4584.         //fin
  4585.         if ($inser === false) {
  4586.             //get nessaisire element
  4587.             $p = [];
  4588.             $p["id"] = $produit->getId();
  4589.             $p["nom"] = $produit->getType()->getLabeletype();
  4590.             $p["ident"] = $produit->getLabele();
  4591.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4592.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4593.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4594.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4595.             $p["qte"] = 1;
  4596.             array_push($Products$p);
  4597.         }
  4598.         //sendmailproduct_parent
  4599.         $dateNow = new \Datetime();
  4600.         /** @var \App\Entity\User $user */
  4601.         $user $this->getUser();
  4602.         $userEmail $user->getEmail();
  4603.         $userId $user->getId();
  4604.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4605.         //$this->EmailServie->MailRelancePanier($userEmail);
  4606.         $listeproduit $prod $this->em->getRepository(Produit::class)->findby(array('iduser' => $userId));
  4607.         $session->set('Panier'$Products);
  4608.         $Panier $session->get("Panier");
  4609.         $produit $this->typeProduiteService;
  4610.         $produitlist $produit->produitlistTypeConditionnement();
  4611.         $this->session->set('rout''rout');
  4612.         $parentent_sejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $this->getUser(), "idSejour" => $sejourobj]);
  4613.         $prodpanier = array();
  4614.         $nbrprodpromo 0;
  4615.         $nbralbum 0;
  4616.         $nbrlivre 0;
  4617.         $nbrphoto12 0;
  4618.         $nbrphoto24 0;
  4619.         $nbrphoto36 0;
  4620.         $nbrcal 0;
  4621.         $nbrretro12 0;
  4622.         $nbrretro24 0;
  4623.         $nbrretro36 0;
  4624.         $detailsprod = array();
  4625.         $prixalbum 0.0;
  4626.         $prixphoto12 0.0;
  4627.         $prixphoto24 0.0;
  4628.         $prixphoto36 0.0;
  4629.         $prixcal 0.0;
  4630.         $prixalbum 0.0;
  4631.         $prixretro12 0.0;
  4632.         $prixretro24 0.0;
  4633.         $prixretro36 0.0;
  4634.         $prodpanierpromo = array();
  4635.         $promo = array();
  4636.         foreach ($Panier as $key => $p) {
  4637.             if ($p['condition'] != null) {
  4638.                 array_push($prodpanier$p['condition']);
  4639.             }
  4640.             if ($p['condition'] != 11 && $p['condition'] != 6) {
  4641.                 $promo['condition'] = $p['condition'];
  4642.                 $nbrprodpromo $nbrprodpromo $p['qte'];
  4643.                 array_push($prodpanierpromo$promo);
  4644.                 if ($p['condition'] == 4) {
  4645.                     $nbralbum $nbralbum $p['qte'];
  4646.                     $prixalbum $p['mnt'];
  4647.                 } elseif ($p['condition'] == 1) {
  4648.                     $nbrphoto12 $nbrphoto12 $p['qte'];
  4649.                     $prixphoto12 $p['mnt'];
  4650.                 } elseif ($p['condition'] == 2) {
  4651.                     $nbrphoto24 $nbrphoto24 $p['qte'];
  4652.                     $prixphoto24 $p['mnt'];
  4653.                 } elseif ($p['condition'] == 3) {
  4654.                     $nbrphoto36 $nbrphoto36 $p['qte'];
  4655.                     $prixphoto36  $p['mnt'];
  4656.                 } elseif ($p['condition'] == 5) {
  4657.                     $nbrlivre $nbrlivre $p['qte'];
  4658.                     $prixlivre $p['mnt'];
  4659.                 } elseif ($p['condition'] == 7) {
  4660.                     $nbrcal $nbrcal $p['qte'];
  4661.                     $prixcal $p['mnt'];
  4662.                 } elseif ($p['condition'] == 8) {
  4663.                     $nbrretro36 $nbrretro36 $p['qte'];
  4664.                     $prixretro36 $p['mnt'];
  4665.                 } elseif ($p['condition'] == 9) {
  4666.                     $nbrretro12 $nbrretro12 $p['qte'];
  4667.                     $prixretro12 $p['mnt'];
  4668.                 } elseif ($p['condition'] == 10) {
  4669.                     $nbrretro24 $nbrretro24 $p['qte'];
  4670.                     $prixretro24 $p['mnt'];
  4671.                 }
  4672.             }
  4673.         }
  4674.         $detailsprod['album']['qt'] = $nbralbum;
  4675.         $detailsprod['album']['prix'] = $prixalbum;
  4676.         $detailsprod['photo12']['qt'] = $nbrphoto12;
  4677.         $detailsprod['photo12']['prix'] = $prixphoto12;
  4678.         $detailsprod['photo24']['qt'] = $nbrphoto24;
  4679.         $detailsprod['photo24']['prix'] = $prixphoto24;
  4680.         $detailsprod['photo36']['qt'] = $nbrphoto36;
  4681.         $detailsprod['photo36']['prix'] = $prixphoto36;
  4682.         $detailsprod['cal']['qt'] = $nbrcal;
  4683.         $detailsprod['cal']['prix'] = $prixcal;
  4684.         $detailsprod['livre']['qt'] = $nbrlivre;
  4685.         $detailsprod['livre']['prix'] = $prixalbum;
  4686.         $detailsprod['retro12']['qt'] = $nbrretro12;
  4687.         $detailsprod['retro12']['prix'] = $prixretro12;
  4688.         $detailsprod['retro24']['qt'] = $nbrretro24;
  4689.         $detailsprod['retro24']['prix'] = $prixretro24;
  4690.         $detailsprod['retro36']['qt'] = $nbrretro36;
  4691.         $detailsprod['retro36']['prix'] = $prixretro36;
  4692.         return $this->render('Parent/monpanier.html.twig', ['detailsprod' => $detailsprod'nbrprodpromo' => $nbrprodpromo'prodpanierpromo' => $prodpanierpromo'prodpanier' => $prodpanier"parentent_sejour" => $parentent_sejour"sejour" => $sejourobj'user' => $this->getUser(), 'Sejour' => $idSejour'listeproduit' => $listeproduit'Panier' => $Panier'produitlist' => $produitlist]);
  4693.     }
  4694.     /**
  4695.      * @Route("/Parent/Boite_vocale", name="Boite_vocale")
  4696.      */
  4697.     public function Boite_Vocale()
  4698.     {
  4699.         /** @var \App\Entity\User $user */
  4700.         $user $this->getUser();
  4701.         $userId $user->getId();
  4702.         $session $this->session;
  4703.         $session->set('pageMenu''BoiteVocale');
  4704.         $idSejour $session->get("Sejour");
  4705.         $SEjourService $this->sejourService;
  4706.         $sejour $SEjourService->getsejour($idSejour);
  4707.         /*         $listeattach = $SEjourService->getatachmentsejour($idSejour);
  4708.         $listeVideo = $SEjourService->getVideosejour($idSejour);
  4709.         $AllAttachements = array_merge_recursive($listeattach, $listeVideo); */
  4710.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  4711.         $attachementsCount $AllAttachements['total'];
  4712.         unset($AllAttachements['total']);
  4713.         $nbImages count($AllAttachements);
  4714.         $positions $SEjourService->getsejourposition($idSejour);
  4715.         $messages $SEjourService->getsejourmessage($idSejour);
  4716.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  4717.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4718.         // test if sejour est vide ou non 
  4719.         if (sizeof($sejour->getAttachements()) == 0) {
  4720.             $this->session->set('rout''rout');
  4721.             return $this->render('Parent/Aucunphoto.html.twig', [
  4722.                 "sejour" => $sejour,
  4723.                 "parentsejour" => $parentsejour
  4724.             ]);
  4725.         }
  4726.         if ($sejour->getPaym() == 1) {
  4727.             //findlinge
  4728.             $ParentSejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  4729.             if ($ParentSejour->getPayment() == 0) {
  4730.                 $this->session->set('rout''rout');
  4731.                 $ses_id session_id();
  4732.                 return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $ParentSejour]);
  4733.             }
  4734.             if ($ParentSejour->getPayment() == 1) {
  4735.                 $produits $this->typeProduiteService;
  4736.                 $liste $produits->produitlistTypeConditionnement();
  4737.                 $em $this->em;
  4738.                 $idAcc $sejour->getIdAcommp();
  4739.                 $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4740.                 $pubProd $user->getShowpubprod();
  4741.                 $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4742.                 if ($albumAcc == null) {
  4743.                     $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  4744.                 }
  4745.                 return $this->render('Parent/DetailsSejour.html.twig', [
  4746.                     "sejour" => $sejour,
  4747.                     'albumAcc' => $albumAcc,
  4748.                     'listeattach' => $AllAttachements,
  4749.                     'prod' => $liste,
  4750.                     'nbImages' => $nbImages,
  4751.                     'attachementsCount' => $attachementsCount,
  4752.                     'positions' => $positions,
  4753.                     'messages' => $messages,
  4754.                     'albumAcc' => $albumAcc,
  4755.                     'like' => $listeattachlikephoto,
  4756.                     "parentsejour" => $parentsejour,
  4757.                     'smsnotif' => $parentsejour->getSmsnotif(),
  4758.                     'showpub' => $pubProd
  4759.                 ]);
  4760.             }
  4761.         }
  4762.         $produits $this->typeProduiteService;
  4763.         $liste $produits->produitlistTypeConditionnement();
  4764.         $pubProd $user->getShowpubprod();
  4765.         $em $this->em;
  4766.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4767.         if ($albumAcc == null) {
  4768.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  4769.         }
  4770.         return $this->render('Parent/DetailsSejour.html.twig', [
  4771.             "sejour" => $sejour,
  4772.             'albumAcc' => $albumAcc,
  4773.             'prod' => $liste,
  4774.             'listeattach' => $AllAttachements,
  4775.             'nbImages' => $nbImages,
  4776.             'attachementsCount' => $attachementsCount,
  4777.             'positions' => $positions,
  4778.             'messages' => $messages,
  4779.             'like' => $listeattachlikephoto,
  4780.             "parentsejour" => $parentsejour,
  4781.             'smsnotif' => $parentsejour->getSmsnotif(),
  4782.             'showpub' => $pubProd
  4783.         ]);
  4784.     }
  4785.     /**
  4786.      * @Route("/Parent/Mon_Sejour_parent", name="Mon_Sejour_parent")
  4787.      */
  4788.     public function Mon_Sejour_parent()
  4789.     {
  4790.         /** @var \App\Entity\User $user */
  4791.         $user $this->getUser();
  4792.         $userId $user->getId();
  4793.         $session $this->session;
  4794.         // $idParent=$this->getUser()->getId();
  4795.         $idSejour $session->get("Sejour");
  4796.         $session->set('pageMenu''Monsejour');
  4797.         $conxparent $this->sejourService;
  4798.         //$sejour1 = $conxparent->sejourParentcnx($idSejour,$idParent);
  4799.         //
  4800.         $SEjourService $this->sejourService;
  4801.         $sejour $SEjourService->getsejour($idSejour);
  4802.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4803.         //Liste des photos privĂ©
  4804.         //        $listeattachPrivate = $SEjourService->getatachmentsejourparent($idSejour, $this->getUser()->getId());
  4805.         //        $AllPhotosParent = array_merge_recursive($listeattach, $listeattachPrivate);
  4806.         $listeVideo $SEjourService->getVideosejour($idSejour);
  4807.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  4808.         $nbImages count($listeattach);
  4809.         $positions $SEjourService->getsejourposition($idSejour);
  4810.         $messages $SEjourService->getsejourmessage($idSejour);
  4811.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  4812.         //dd($parentsejour);
  4813.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4814.         // test if sejour est vide ou non 
  4815.         if (sizeof($sejour->getAttachements()) == 0) {
  4816.             $this->session->set('rout''rout');
  4817.             return $this->render('Parent/Aucunphoto.html.twig', [
  4818.                 "sejour" => $sejour,
  4819.                 "parentsejour" => $parentsejour
  4820.             ]);
  4821.         }
  4822.         if ($sejour->getPaym() == 1) {
  4823.             /** @var \App\Entity\User $user */
  4824.             $user $this->getUser();
  4825.             $userid $user->getId();
  4826.             //findlinge
  4827.             $ParentSejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $userid]);
  4828.             if ($ParentSejour->getPayment() == 0) {
  4829.                 $this->session->set('rout''rout');
  4830.                 $ses_id session_id();
  4831.                 return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $listeattach"session_id" => $ses_id'ParentSejour' => $ParentSejour]);
  4832.             }
  4833.             if ($ParentSejour->getPayment() == 1) {
  4834.                 $produits $this->typeProduiteService;
  4835.                 $liste $produits->produitlistTypeConditionnement();
  4836.                 $pubProd $user->getShowpubprod();
  4837.                 return $this->render('Parent/DetailsSejour.html.twig', [
  4838.                     "sejour" => $sejour,
  4839.                     'listeattach' => $AllAttachements,
  4840.                     'prod' => $liste,
  4841.                     'nbImages' => $nbImages,
  4842.                     'positions' => $positions,
  4843.                     'messages' => $messages,
  4844.                     'like' => $listeattachlikephoto,
  4845.                     "parentsejour" => $parentsejour,
  4846.                     'smsnotif' => $parentsejour->getSmsnotif()
  4847.                 ]);
  4848.             }
  4849.         }
  4850.         //  dd($sejour);
  4851.         //Liste des photos public
  4852.         $produits $this->typeProduiteService;
  4853.         $liste $produits->produitlistTypeConditionnement();
  4854.         $pubProd $user->getShowpubprod();
  4855.         return $this->render('Parent/DetailsSejour.html.twig', [
  4856.             "sejour" => $sejour,
  4857.             'prod' => $liste,
  4858.             'listeattach' => $AllAttachements,
  4859.             'nbImages' => $nbImages,
  4860.             'positions' => $positions,
  4861.             'messages' => $messages,
  4862.             'like' => $listeattachlikephoto,
  4863.             "parentsejour" => $parentsejour,
  4864.             'smsnotif' => $parentsejour->getSmsnotif(),
  4865.             'showpub' => $pubProd
  4866.         ]);
  4867.     }
  4868.     /**
  4869.      * @Route("/Parent/Besoindaide", name="Besoindaide_Parent")
  4870.      */
  4871.     public function Besoindaide(): Response
  4872.     {
  4873.         $produit $this->typeProduiteService;
  4874.         $liste $produit->produitlistType();
  4875.         // dd($liste);
  4876.         return $this->render('Parent/footer/Besoindaide.html.twig', [
  4877.             'produit' => $liste,
  4878.         ]);
  4879.     }
  4880.     /**
  4881.      * @Route("/Parent/Besoindaide_5sur5", name="Besoindaide_5sur5")
  4882.      */
  4883.     public function Besoindaide_5sur5(): Response
  4884.     {
  4885.         $produit $this->typeProduiteService;
  4886.         $liste $produit->produitlistType();
  4887.         // dd($liste);
  4888.         $session $this->session;
  4889.         $idSejour $session->get("Sejour");
  4890.         $sejour null;
  4891.         if ($idSejour != null) {
  4892.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  4893.         }
  4894.         return $this->render('Parent/footer/5sur5Help.html.twig', [
  4895.             'produit' => $liste,
  4896.             'sejour' => $sejour
  4897.         ]);
  4898.     }
  4899.     /**
  4900.      * @Route("/Parent/Mentionlegale", name="Mentionlegale_Parent")
  4901.      */
  4902.     public function MentionlegaleParent()
  4903.     {
  4904.         return $this->render('Parent/footer/mentionlegal.html.twig', []);
  4905.     }
  4906.     /**
  4907.      * @Route("/Parent/Conditongeneral", name="Conditongeneral_Parent")
  4908.      */
  4909.     public function ConditongeneralParent()
  4910.     {
  4911.         return $this->render('Parent/footer/Condition.html.twig', []);
  4912.     }
  4913.     /**
  4914.      * @Route("/Parent/Politique", name="Politique_Parent")
  4915.      */
  4916.     public function PolitiqueParent()
  4917.     {
  4918.         return $this->render('Parent/footer/politique.html.twig', []);
  4919.     }
  4920.     /**
  4921.      * @Route("/Parent/Commande_groupee", name="Commande_groupee")
  4922.      * */
  4923.     public function  Commande_groupee()
  4924.     {
  4925.         $produit $this->typeProduiteService;
  4926.         $liste $produit->produitlistType();
  4927.         // dd($liste);
  4928.         return $this->render('Parent/footer/GroupeeCommande.html.twig', [
  4929.             'showArt' => 'ALL',
  4930.             'produit' => $liste
  4931.         ]);
  4932.     }
  4933.     /**
  4934.      * @Route("/Parent/partenaires", name="nosPartenaires")
  4935.      * */
  4936.     public function nosPartenaires()
  4937.     {
  4938.         return $this->render('Parent/footer/Partenaires.html.twig');
  4939.     }
  4940.     /**
  4941.      * @Route("/Parent/produits5sur5", name="produits5sur5")
  4942.      * */
  4943.     public function produits5sur5()
  4944.     {
  4945.         $produit $this->typeProduiteService;
  4946.         $liste $produit->produitlistType();
  4947.         // dd($liste);
  4948.         return $this->render('Parent/produitscinqsurcinq.html.twig', [
  4949.             'showArt' => 'ALL',
  4950.             'produit' => $liste
  4951.         ]);
  4952.     }
  4953.     /**
  4954.      * @Route("/Parent/Nous_Connaitre_5sur5", name="NousConnaitre")
  4955.      * */
  4956.     public function Nous_Connaitre_5sur5()
  4957.     {
  4958.         $produit $this->typeProduiteService;
  4959.         $liste $produit->produitlistType();
  4960.         // dd($liste);
  4961.         return $this->render('Parent/footer/5sur5.html.twig', [
  4962.             'produit' => $liste,
  4963.         ]);
  4964.     }
  4965.     /**
  4966.      * @Route("/Parent/ServiceClient", name="ServiceClient_Parent")
  4967.      * */
  4968.     public function ServiceClient()
  4969.     {
  4970.         $produit $this->typeProduiteService;
  4971.         $liste $produit->produitlistType();
  4972.         // dd($liste);
  4973.         return $this->render('Parent/footer/ServiceClient.html.twig', [
  4974.             'produit' => $liste,
  4975.         ]);
  4976.     }
  4977.     /**
  4978.      * @Route("/Parent/delateSession_parents", name="delateSession_parent")
  4979.      * */
  4980.     public function delateSession_parents()
  4981.     {
  4982.         $session $this->session;
  4983.         $em $this->em;
  4984.         $Products = [];
  4985.         if ($session->get("paymentmoniteco") == "succses") {
  4986.             $Products = [];
  4987.             $session->set('Panier'$Products);
  4988.             $user $this->getUser();
  4989.             $typeref $em->getRepository(Typeref::class)->find(8);
  4990.             $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4991.             $payer $em->getRepository(Ref::class)->findOneBy(array("libiller" => "payer""typeref" => $typeref));
  4992.             $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4993.             if ($panierTrace) {
  4994.                 $panierTrace->setStatut($payer);
  4995.                 $em->getManager()->persist($panierTrace);
  4996.                 $em->getManager()->flush();
  4997.             }
  4998.         }
  4999.         $this->session->remove('paymentmoniteco');
  5000.         $this->session->remove('montanttotalcomande');
  5001.         $this->session->remove('Panierlength');
  5002.         $this->session->remove('envoipost');
  5003.         return new Response('done');
  5004.     }
  5005.     /**
  5006.      * @Route("/Parent/chargement_form_conn_up2pay", name="chargement_form_conn_up2pay")
  5007.      */
  5008.     function chargeFormup2payAction(Request $request)
  5009.     {
  5010.         $session $this->session;
  5011.         $em $this->container->get('doctrine')->getManager();
  5012.         $idSejour $session->get("Sejour");
  5013.         /** @var \App\Entity\User $user */
  5014.         $user $this->getUser();
  5015.         $user $user->getId();
  5016.         $comande $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  5017.         $firstName $comande->getIdParent()->getNom();
  5018.         if ($firstName == null || $firstName == '') {
  5019.             $firstName "john";
  5020.         }
  5021.         $lastName $comande->getIdParent()->getPrenom();
  5022.         if ($lastName == null || $lastName == '') {
  5023.             $lastName "Doe";
  5024.         }
  5025.         $addressLine1 "3 rue de l'Ă©glise";
  5026.         $city "Ostheim";
  5027.         $postalCode "68150";
  5028.         $pbx_site '6062073';                              //variable de test 9999999
  5029.         $pbx_rang '001';                                    //variable de test 95
  5030.         $pbx_identifiant '38027616';                      //variable de test 123456789
  5031.         $pbx_cmd 'REFCN' $comande->getId();
  5032.         $pbx_effectue $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5033.         $pbx_annule $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5034.         $pbx_refuse $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5035.         // ParamĂ©trage de l'url de retour back office site (notification de paiement IPN) :
  5036.         $pbx_repondre_a "";
  5037.         //$pbx_repondre_a = $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5038.         $mail  $comande->getIdParent()->getEmail();
  5039.         $pbx_porteur $mail;                    //variable de test test@test.fr
  5040.         // ParamĂ©trage des donnĂ©es retournĂ©es via l'IPN :
  5041.         $pbx_retour 'Mt:M;Ref:R;Auto:A;Erreur:E';
  5042.         // On rĂ©cupĂ©re la date au format ISO-8601 :
  5043.         $dateTime date("c");
  5044.         //$montant = $comande->getMontantrth() . "EUR";
  5045.         $pbx_total $comande->getIdSejour()->getPrixcnxparent();
  5046.         $pbx_total = (int)((string)($pbx_total 100));
  5047.         // Suppression des points ou virgules dans le montant                        
  5048.         $pbx_total str_replace(","""$pbx_total);
  5049.         $pbx_total str_replace("."""$pbx_total);
  5050.         // Nombre de produit envoyĂ© dans PBX_SHOPPINGCART :
  5051.         $pbx_nb_produit '1';                                    //variable de test 5
  5052.         // Construction de PBX_SHOPPINGCART :
  5053.         $pbx_shoppingcart "<?xml version=\"1.0\" encoding=\"utf-8\"?><shoppingcart><total><totalQuantity>" $pbx_nb_produit "</totalQuantity></total></shoppingcart>";
  5054.         // Choix de l'authentification dans PBX_SOUHAITAUTHENT
  5055.         $pbx_souhaitauthent '01';        //variable de test authentification 3DS (1 par dĂ©faut, 2 pour exemption 3DS)
  5056.         // Valeurs envoyes dans PBX_BILLING :
  5057.         $pbx_prenom_fact $firstName;                                                             //variable de test Jean-Marie
  5058.         $pbx_nom_fact $lastName;                                                                 //variable de test Thomson
  5059.         $pbx_adresse1_fact $addressLine1;                                                         //variable de test 1 rue de Paris
  5060.         $pbx_adresse2_fact '';                                                                 //variable de test <vide>
  5061.         $pbx_zipcode_fact $postalCode;                                                         //variable de test 75001
  5062.         $pbx_city_fact $city;                                     //variable de test Paris
  5063.         $pbx_country_fact '250';        //variable de test 250 (pour la France)
  5064.         // Construction de PBX_BILLING :
  5065.         $pbx_billing "<?xml version=\"1.0\" encoding=\"utf-8\"?><Billing><Address><FirstName>" $pbx_prenom_fact "</FirstName>" .
  5066.             "<LastName>" $pbx_nom_fact "</LastName><Address1>" $pbx_adresse1_fact "</Address1>" .
  5067.             "<Address2>" $pbx_adresse2_fact "</Address2><ZipCode>" $pbx_zipcode_fact "</ZipCode>" .
  5068.             "<City>" $pbx_city_fact "</City><CountryCode>" $pbx_country_fact "</CountryCode>" .
  5069.             "</Address></Billing>";
  5070.         // Recette (paiements de test)  :
  5071.         //$urletrans ="https://recette-tpeweb.e-transactions.fr/php/";
  5072.         // Production (paiements rĂ©els) :
  5073.         // URL principale :
  5074.         $urletrans "https://tpeweb.e-transactions.fr/php/";
  5075.         // URL secondaire :
  5076.         // $urletrans ="https://tpeweb1.e-transactions.fr/php/";
  5077.         // $hmackey = 'A5FD6D11DA2B9C4112201B4D797EC2B32B877C09A0CF56CE8007D91ACBA9A6D9E026149A7E8441D39A9F52C61E0D250ACC6DEC6815EA02621AEE525576CF4DAE';
  5078.         $hmackey 'A5FD6D11DA2B9C4112201B4D797EC2B32B877C09A0CF56CE8007D91ACBA9A6D9E026149A7E8441D39A9F52C61E0D250ACC6DEC6815EA02621AEE525576CF4DAE';
  5079.         $pbx_prenom_fact strtoupper($pbx_prenom_fact);
  5080.         $pbx_nom_fact strtoupper($pbx_nom_fact);
  5081.         $pbx_adresse1_fact strtoupper($pbx_adresse1_fact);
  5082.         $pbx_adresse2_fact strtoupper($pbx_adresse2_fact);
  5083.         $pbx_city_fact strtoupper($pbx_city_fact);
  5084.         $pbx_country_fact strtoupper($pbx_country_fact);
  5085.         // --------------- TRAITEMENT DES VARIABLES ---------------
  5086.         // On crĂ©e la chaĂ©ne a hacher sans URLencodage
  5087.         $msg "PBX_SITE=" $pbx_site .
  5088.             "&PBX_RANG=" $pbx_rang .
  5089.             "&PBX_IDENTIFIANT=" $pbx_identifiant .
  5090.             "&PBX_SOURCE=RWD" .
  5091.             "&PBX_TOTAL=" $pbx_total .
  5092.             "&PBX_DEVISE=978" .
  5093.             "&PBX_CMD=" $pbx_cmd .
  5094.             "&PBX_PORTEUR=" $pbx_porteur .
  5095.             "&PBX_REPONDRE_A=" $pbx_repondre_a .
  5096.             "&PBX_RETOUR=" $pbx_retour .
  5097.             "&PBX_EFFECTUE=" $pbx_effectue .
  5098.             "&PBX_ANNULE=" $pbx_annule .
  5099.             "&PBX_REFUSE=" $pbx_refuse .
  5100.             "&PBX_HASH=SHA512" .
  5101.             "&PBX_TIME=" $dateTime .
  5102.             "&PBX_SHOPPINGCART=" $pbx_shoppingcart .
  5103.             "&PBX_BILLING=" $pbx_billing .
  5104.             "&PBX_SOUHAITAUTHENT=" $pbx_souhaitauthent;
  5105.         $binKey pack("H*"$hmackey);
  5106.         $hmac strtoupper(hash_hmac('sha512'$msg$binKey));
  5107.         return new JsonResponse(array(
  5108.             'urletrans' => $urletrans,
  5109.             'pbx_site' => $pbx_site,
  5110.             'pbx_rang' => $pbx_rang,
  5111.             'pbx_identifiant' => $pbx_identifiant,
  5112.             'pbx_total' => $pbx_total,
  5113.             'pbx_cmd' => $pbx_cmd,
  5114.             'pbx_porteur' => $pbx_porteur,
  5115.             'pbx_repondre_a' => $pbx_repondre_a,
  5116.             'pbx_retour' => $pbx_retour,
  5117.             'pbx_effectue' => $pbx_effectue,
  5118.             'pbx_annule' => $pbx_annule,
  5119.             'pbx_refuse' => $pbx_refuse,
  5120.             'dateTime' => $dateTime,
  5121.             'pbx_shoppingcart' => $pbx_shoppingcart,
  5122.             'pbx_billing' => $pbx_billing,
  5123.             'pbx_souhaitauthent' => $pbx_souhaitauthent,
  5124.             'hmac' => $hmac
  5125.         ));
  5126.         // return new JsonResponse(array('TITLE'=>$title,'ACCEPTURL'=>$ACCEPTURL,'DECLINEURL'=>$DECLINEURL,'EXCEPTIONURL'=>$EXCEPTIONURL,'CANCELURL'=>$CANCELURL,'orderID'=>$orderID,'PSPID'=>$PSPID,'CURRENCY'=>$CURRENCY,'LANGUAGE'=>$LANGUAGE,'PrixOgone'=>$PrixOgone,'shastring'=>$shastring));
  5127.     }
  5128.     /**
  5129.      * @Route("/Parent/chargement_form_connx", name="chargement_form__Connx")
  5130.      */
  5131.     function chargeFormOgoneAction_Connx(Request $request)
  5132.     {
  5133.         $session $this->session;
  5134.         $em $this->container->get('doctrine')->getManager();
  5135.         $idSejour $session->get("Sejour");
  5136.         /** @var \App\Entity\User $user */
  5137.         $user $this->getUser();
  5138.         $user $user->getId();
  5139.         $comande $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  5140.         $firstName $comande->getIdParent()->getNom();
  5141.         if ($firstName == null || $firstName == '') {
  5142.             $firstName "john";
  5143.         }
  5144.         $lastName $comande->getIdParent()->getPrenom();
  5145.         if ($lastName == null || $lastName == '') {
  5146.             $lastName "Doe";
  5147.         }
  5148.         $addressLine1 "3 rue de l'Ă©glise";
  5149.         $city $city "Ostheim";
  5150.         $postalCode "68150";
  5151.         //      $postalCode= trim ($postalCode) ;
  5152.         $country "FR";
  5153.         $contexte = array("billing" => array("firstName" => $firstName"lastName" => $lastName"addressLine1" => $addressLine1"city" => $city"postalCode" => $postalCode"country" => $country));
  5154.         //param de payement
  5155.         $contexte_commande base64_encode(json_encode($contexte));
  5156.         $PayementService $this->container->get("App\Service\PayementService");
  5157.         $version $this->getParameter('version'); //done
  5158.         $TPE $this->getParameter('TPE'); //done
  5159.         $dateTime $dateNow = new \DateTime();
  5160.         $date $dateTime->format("d/m/Y:H:i:s");
  5161.         //"05/05/2019:11:55:23" ;
  5162.         $montant $comande->getIdSejour()->getPrixcnxparent() . "EUR";
  5163.         $reference 'REFCN' $comande->getId();
  5164.         $url_retour_ok $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5165.         $url_retour_err $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5166.         $desactivemoyenpaiement "paypal";
  5167.         $lgue "FR"//done
  5168.         $societe "5sur5sejou"//done
  5169.         $textelibre "5sur5sejour"//
  5170.         $mail $this->getUser(); //
  5171.         $SHAIN $this->getParameter('shain');
  5172.         $param = array(
  5173.             'version' => $version,
  5174.             'TPE' => $TPE,
  5175.             'date' => $date,
  5176.             'montant' => $montant,
  5177.             'reference' => $reference,
  5178.             'url_retour_ok' => $url_retour_ok,
  5179.             'url_retour_err' => $url_retour_err,
  5180.             'lgue' => $lgue,
  5181.             'societe' => $societe,
  5182.             'contexte_commande' => $contexte_commande,
  5183.             'texte-libre' => $textelibre,
  5184.             'mail' => $mail,
  5185.             'desactivemoyenpaiement' => $desactivemoyenpaiement
  5186.         );
  5187.         $MAC $PayementService->monetico_hash_parameters('sha1'$param$SHAIN);
  5188.         //utf8_encode
  5189.         return new JsonResponse(array(
  5190.             'version' => $version,
  5191.             'TPE' => $TPE,
  5192.             'date' => $date,
  5193.             'montant' => $montant,
  5194.             'reference' => $reference,
  5195.             'MAC' => $MAC,
  5196.             'url_retour_ok' => utf8_encode($url_retour_ok),
  5197.             'url_retour_err' => utf8_encode($url_retour_err),
  5198.             'lgue' => $lgue,
  5199.             'societe' => $societe,
  5200.             'contexte_commande' => utf8_encode($contexte_commande),
  5201.             'textelibre' => utf8_encode($textelibre),
  5202.             'mail' => $mail,
  5203.             'desactivemoyenpaiement' => $desactivemoyenpaiement
  5204.         ));
  5205.         // return new JsonResponse(array('TITLE'=>$title,'ACCEPTURL'=>$ACCEPTURL,'DECLINEURL'=>$DECLINEURL,'EXCEPTIONURL'=>$EXCEPTIONURL,'CANCELURL'=>$CANCELURL,'orderID'=>$orderID,'PSPID'=>$PSPID,'CURRENCY'=>$CURRENCY,'LANGUAGE'=>$LANGUAGE,'PrixOgone'=>$PrixOgone,'shastring'=>$shastring));
  5206.     }
  5207.     /**
  5208.      * @Route("/Parent/chargement_form_connx_paypal", name="chargement_form__Connx_PayPal")
  5209.      */
  5210.     function chargeFormOgoneAction_Connx_PayPal(Request $request)
  5211.     {
  5212.         $session $this->session;
  5213.         $em $this->container->get('doctrine')->getManager();
  5214.         $idSejour $session->get("Sejour");
  5215.         /** @var \App\Entity\User $user */
  5216.         $user $this->getUser();
  5217.         $user $user->getId();
  5218.         $comande $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  5219.         $firstName $comande->getIdParent()->getNom();
  5220.         if ($firstName == null || $firstName == '') {
  5221.             $firstName "john";
  5222.         }
  5223.         $lastName $comande->getIdParent()->getPrenom();
  5224.         if ($lastName == null || $lastName == '') {
  5225.             $lastName "Doe";
  5226.         }
  5227.         $addressLine1 "3 rue de l'Ă©glise";
  5228.         $city $city "Ostheim";
  5229.         $postalCode "68150";
  5230.         //      $postalCode= trim ($postalCode) ;
  5231.         $country "FR";
  5232.         $contexte = array("billing" => array("firstName" => $firstName"lastName" => $lastName"addressLine1" => $addressLine1"city" => $city"postalCode" => $postalCode"country" => $country));
  5233.         $protocole "paypal";
  5234.         //param de payement
  5235.         $contexte_commande base64_encode(json_encode($contexte));
  5236.         $PayementService $this->container->get("App\Service\PayementService");
  5237.         $version $this->getParameter('version'); //done
  5238.         $TPE $this->getParameter('TPE'); //done
  5239.         $dateTime $dateNow = new \DateTime();
  5240.         $date $dateTime->format("d/m/Y:H:i:s");
  5241.         //"05/05/2019:11:55:23" ;
  5242.         $montant $comande->getIdSejour()->getPrixcnxparent() . "EUR";
  5243.         $reference 'REFCN' $comande->getId();
  5244.         $url_retour_ok $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5245.         $url_retour_err $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5246.         $lgue "FR"//done
  5247.         $societe "5sur5sejou"//done
  5248.         $textelibre "5sur5sejour"//
  5249.         $mail $this->getUser(); //
  5250.         $SHAIN $this->getParameter('shain');
  5251.         $param = array(
  5252.             'version' => $version,
  5253.             'TPE' => $TPE,
  5254.             'date' => $date,
  5255.             'montant' => $montant,
  5256.             'reference' => $reference,
  5257.             'url_retour_ok' => $url_retour_ok,
  5258.             'url_retour_err' => $url_retour_err,
  5259.             'lgue' => $lgue,
  5260.             'societe' => $societe,
  5261.             'contexte_commande' => $contexte_commande,
  5262.             'texte-libre' => $textelibre,
  5263.             'mail' => $mail,
  5264.             'protocole' => $protocole
  5265.         );
  5266.         $MAC $PayementService->monetico_hash_parameters('sha1'$param$SHAIN);
  5267.         //utf8_encode
  5268.         return new JsonResponse(array(
  5269.             'version' => $version,
  5270.             'TPE' => $TPE,
  5271.             'date' => $date,
  5272.             'montant' => $montant,
  5273.             'reference' => $reference,
  5274.             'MAC' => $MAC,
  5275.             'url_retour_ok' => utf8_encode($url_retour_ok),
  5276.             'url_retour_err' => utf8_encode($url_retour_err),
  5277.             'lgue' => $lgue,
  5278.             'societe' => $societe,
  5279.             'contexte_commande' => utf8_encode($contexte_commande),
  5280.             'textelibre' => utf8_encode($textelibre),
  5281.             'mail' => $mail,
  5282.             'protocole' => $protocole
  5283.         ));
  5284.         // return new JsonResponse(array('TITLE'=>$title,'ACCEPTURL'=>$ACCEPTURL,'DECLINEURL'=>$DECLINEURL,'EXCEPTIONURL'=>$EXCEPTIONURL,'CANCELURL'=>$CANCELURL,'orderID'=>$orderID,'PSPID'=>$PSPID,'CURRENCY'=>$CURRENCY,'LANGUAGE'=>$LANGUAGE,'PrixOgone'=>$PrixOgone,'shastring'=>$shastring));
  5285.     }
  5286.     /**
  5287.      * @Route("/Parent/SupprimerCommande", name="Supprimer_CommandeParent")
  5288.      */
  5289.     function RemoveCommandeParent(Request $request)
  5290.     {
  5291.         $CommandeService $this->commandeService;
  5292.         $idCmd $request->get('id');
  5293.         $result $CommandeService->CommandeCloture($idCmd);
  5294.         return new Response($result);
  5295.     }
  5296.     /**
  5297.      * @Route("/Parent/accept_url_parentcnxx/{id}", name="moneticoAcceptUrl_parentcnxx")
  5298.      */
  5299.     function moneticoAcceptUrl_parent($id)
  5300.     {
  5301.         $em $this->container->get('doctrine')->getManager();
  5302.         $comande $this->em->getRepository(ParentSejour::class)->find($id);
  5303.         if ($comande->getPayment() != 1) {
  5304.             $typ $this->em->getRepository(Typeproduit::class)->find(1);
  5305.             $condit $this->em->getRepository(TypeProduitConditionnement::class)->find(11);
  5306.             $produit = new Produit();
  5307.             $produit->setIdConditionnement($condit);
  5308.             $produit->setType($typ);
  5309.             $produit->setDate(new \DateTime());
  5310.             $produit->setLabele("Connexion");
  5311.             $produit->setIduser($this->getUser());
  5312.             $sats $this->em->getRepository(Ref::class)->find(33);
  5313.             //$ComandeService = $this->container->get("App\Service\ComandeService");
  5314.             $ComandeService $this->commandeService;
  5315.             $comande->setPayment(1);
  5316.             $this->em->getManager()->persist($comande);
  5317.             $this->em->getManager()->flush();
  5318.             $produit->setIdsjour($comande->getIdSejour());
  5319.             $this->em->getManager()->persist($produit);
  5320.             $this->em->getManager()->flush();
  5321.             $bytes random_int(10009999);
  5322.             $pass bin2hex($bytes);
  5323.             //generate Num facture
  5324.             $dateSJoue = new \Datetime();
  5325.             $annes $dateSJoue->format('y');
  5326.             $moi $dateSJoue->format('m');
  5327.             $val $this->em->getRepository(Commande::class)->serachNombreFacture();
  5328.             $val $val 1;
  5329.             $valx sprintf('%04d'$val);
  5330.             $valx1 "20" $annes $moi $valx;
  5331.             $cmdpaym = new Commande();
  5332.             $cmdpaym->setMontantrth($comande->getIdSejour()->getPrixcnxparent());
  5333.             $cmdpaym->setNumComande($pass);
  5334.             $cmdpaym->getIdSejour($pass);
  5335.             $cmdpaym->setNumfacture($valx1);
  5336.             $cmdpaym->setDateCreateCommande(new \DateTime());
  5337.             $cmdpaym->setDateFacture(new \DateTime());
  5338.             $cmdpaym->setStatut($sats);
  5339.             $cmdpaym->setIdSejour($comande->getIdSejour());
  5340.             $cmdpaym->setIdUser($this->getUser());
  5341.             $this->em->getManager()->persist($cmdpaym);
  5342.             $this->em->getManager()->flush();
  5343.             $cmdpaym->setNumfacture(substr($cmdpaym->getNumfacture(), '0'6) . $cmdpaym->getId());
  5344.             $this->em->getManager()->persist($cmdpaym);
  5345.             $this->em->getManager()->flush();
  5346.             $cpmd = new ComandeProduit();
  5347.             $cpmd->setIdComande($cmdpaym);
  5348.             $cpmd->setIdProduit($produit);
  5349.             $cpmd->setQuantiter(1);
  5350.             $cpmd->setDate(new \DateTime());
  5351.             //stille reversment par prod
  5352.             $this->em->getManager()->persist($cpmd);
  5353.             $this->em->getManager()->flush();
  5354.             $pdfOptions = new Options();
  5355.             $pdfOptions->set('isRemoteEnabled'TRUE);
  5356.             $pdfOptions->set('defaultFont''Arial');
  5357.             // Instantiate Dompdf with our options
  5358.             $dompdf = new Dompdf($pdfOptions);
  5359.             $dompdf->set_option('isRemoteEnabled'TRUE);
  5360.             // Retrieve the HTML generated in our twig file
  5361.             $html $this->renderView('Admin/pdfFactureparent.html.twig', [
  5362.                 "Commande" => $cmdpaym,
  5363.             ]);
  5364.             // Load HTML to Dompdf
  5365.             $dompdf->loadHtml($html);
  5366.             // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  5367.             $dompdf->setPaper('A4''portrait');
  5368.             // Render the HTML as PDF
  5369.             $dompdf->render();
  5370.             // Store PDF Binary Data
  5371.             $output $dompdf->output();
  5372.             // In this case, we want to write the file in the public directory
  5373.             $publicDirectory $this->getParameter('kernel.project_dir') . '/public/backupFacture/';
  5374.             // e.g /var/www/project/public/mypdf.pdf
  5375.             $pdfFilepath $publicDirectory "Facture" $cmdpaym->getId() . '-' $cmdpaym->getNumComande() . ".pdf";
  5376.             // Write file to the desired path
  5377.             file_put_contents($pdfFilepath$output);
  5378.         }
  5379.         $jetonService = new JetonService($this->em);
  5380.         if ($jetonService->checkUserFiveConnexion($comande->getIdSejour()->getIdAcommp(), $comande->getIdSejour())) {
  5381.             $jetonService->newJetonForUser($comande->getIdSejour()->getIdAcommp());
  5382.         }
  5383.         $session $this->session;
  5384.         $session->set('paymentmoniteco''succses');
  5385.         $resulat $session->get("paymentmoniteco");
  5386.         //dd($montanttotalcomande);
  5387.         return $this->redirectToRoute('AccueilParent');
  5388.     }
  5389.     /**
  5390.      * @Route("/Parent/accept_url_parentcnxxVirgo/{id}", name="moneticoAcceptUrl_parentcnxxVirgo")
  5391.      */
  5392.     function moneticoAcceptUrl_parentVirgo($id)
  5393.     {
  5394.         $em $this->container->get('doctrine')->getManager();
  5395.         $comande $this->em->getRepository(ParentSejour::class)->find($id);
  5396.         if ($comande->getPayment() != 1) {
  5397.             $typ $this->em->getRepository(Typeproduit::class)->find(1);
  5398.             $condit $this->em->getRepository(TypeProduitConditionnement::class)->find(11);
  5399.             $produit = new Produit();
  5400.             $produit->setIdConditionnement($condit);
  5401.             $produit->setType($typ);
  5402.             $produit->setLabele("Connexion");
  5403.             $produit->setIduser($this->getUser());
  5404.             $produit->setDate(new \DateTime());
  5405.             $sats $this->em->getRepository(Ref::class)->find(33);
  5406.             $ComandeService $this->container->get("App\Service\ComandeService");
  5407.             $comande->setPayment(1);
  5408.             $this->em->getManager()->persist($comande);
  5409.             $this->em->getManager()->flush();
  5410.             $produit->setIdsjour($comande->getIdSejour());
  5411.             $this->em->getManager()->persist($produit);
  5412.             $this->em->getManager()->flush();
  5413.             $bytes random_int(10009999);
  5414.             $pass bin2hex($bytes);
  5415.             //generate Num facture
  5416.             $dateSJoue = new \Datetime();
  5417.             $annes $dateSJoue->format('y');
  5418.             $moi $dateSJoue->format('m');
  5419.             $val $this->em->getRepository(Commande::class)->serachNombreFacture();
  5420.             $val $val 1;
  5421.             $valx sprintf('%04d'$val);
  5422.             $valx1 "20" $annes $moi $valx;
  5423.             $cmdpaym = new Commande();
  5424.             $cmdpaym->setMontantrth($comande->getIdSejour()->getPrixcnxparent());
  5425.             $cmdpaym->setNumComande($pass);
  5426.             $cmdpaym->getIdSejour($pass);
  5427.             $cmdpaym->setNumfacture($valx1);
  5428.             $cmdpaym->setDateFacture(new \DateTime());
  5429.             $cmdpaym->setDateCreateCommande(new \DateTime());
  5430.             $cmdpaym->setStatut($sats);
  5431.             $cmdpaym->setPaymentType("Mobile");
  5432.             $cmdpaym->setIdSejour($comande->getIdSejour());
  5433.             $cmdpaym->setIdUser($this->getUser());
  5434.             $this->em->getManager()->persist($cmdpaym);
  5435.             $this->em->getManager()->flush();
  5436.             $cmdpaym->setNumfacture(substr($cmdpaym->getNumfacture(), '0'6) . $cmdpaym->getId());
  5437.             $this->em->getManager()->persist($cmdpaym);
  5438.             $this->em->getManager()->flush();
  5439.             $cpmd = new ComandeProduit();
  5440.             $cpmd->setIdComande($cmdpaym);
  5441.             $cpmd->setIdProduit($produit);
  5442.             $cpmd->setQuantiter(1);
  5443.             $cpmd->setDate(new \DateTime());
  5444.             //stille reversment par prod
  5445.             $this->em->getManager()->persist($cpmd);
  5446.             $this->em->getManager()->flush();
  5447.             $pdfOptions = new Options();
  5448.             $pdfOptions->set('isRemoteEnabled'TRUE);
  5449.             $pdfOptions->set('defaultFont''Arial');
  5450.             // Instantiate Dompdf with our options
  5451.             $dompdf = new Dompdf($pdfOptions);
  5452.             $dompdf->set_option('isRemoteEnabled'TRUE);
  5453.             // Retrieve the HTML generated in our twig file
  5454.             $html $this->renderView('Admin/pdfFactureparent.html.twig', [
  5455.                 "Commande" => $cmdpaym,
  5456.             ]);
  5457.             // Load HTML to Dompdf
  5458.             $dompdf->loadHtml($html);
  5459.             // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  5460.             $dompdf->setPaper('A4''portrait');
  5461.             // Render the HTML as PDF
  5462.             $dompdf->render();
  5463.             // Store PDF Binary Data
  5464.             $output $dompdf->output();
  5465.             // In this case, we want to write the file in the public directory
  5466.             $publicDirectory $this->getParameter('kernel.project_dir') . '/public/backupFacture/';
  5467.             // e.g /var/www/project/public/mypdf.pdf
  5468.             $pdfFilepath $publicDirectory "Facture" $cmdpaym->getId() . '-' $cmdpaym->getNumComande() . ".pdf";
  5469.             // Write file to the desired path
  5470.             file_put_contents($pdfFilepath$output);
  5471.         }
  5472.         $jetonService = new JetonService($this->em);
  5473.         if ($jetonService->checkUserFiveConnexion($comande->getIdSejour()->getIdAcommp(), $comande->getIdSejour())) {
  5474.             $jetonService->newJetonForUser($comande->getIdSejour()->getIdAcommp());
  5475.         }
  5476.         $session $this->session;
  5477.         $session->set('paymentmoniteco''succses');
  5478.         $resulat $session->get("paymentmoniteco");
  5479.         //dd($montanttotalcomande);
  5480.         return $this->redirectToRoute('AccueilParent');
  5481.     }
  5482.     /**
  5483.      * @Route("/error_url_parentcnxx/{id}", name="moneticoExceptionUrl_parentcnxx")
  5484.      */
  5485.     function moneticoExceptionUrl_parentcnxx($id)
  5486.     {
  5487.         $em $this->container->get('doctrine')->getManager();
  5488.         $comande $this->em->getRepository(ParentSejour::class)->find($id);
  5489.         $session $this->session;
  5490.         $session->set('paymentmoniteco''echec');
  5491.         $comande->setPayment(0);
  5492.         $this->em->getManager()->persist($comande);
  5493.         $this->em->getManager()->flush();
  5494.         $resulat $session->get("paymentmoniteco");
  5495.         //dd($montanttotalcomande);
  5496.         return $this->redirectToRoute('AccueilParent');
  5497.     }
  5498.     /**
  5499.      * @Route("/Parent/SuiviCommande", name="SuiviCommande")
  5500.      * */
  5501.     public function SuiviCommande()
  5502.     {
  5503.         // dd($liste);
  5504.         $user $this->getUser();
  5505.         $session $this->session;
  5506.         $idSejour $session->get("Sejour");
  5507.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  5508.         $ParentSejour $this->em->getRepository(ParentSejour::class)->findBy(['idSejour' => $sejour'idParent' => $user]);
  5509.         //ParentSejour
  5510.         //cablala
  5511.         //dd($ParentSejour[0]);
  5512.         //$listeattach = $sejourservice->getatachmentsejour($id);
  5513.         //$listeattachM = $sejourservice->getsejourmessage($id);
  5514.         return $this->render('Parent/suivicommande.html.twig', [
  5515.             'user' => $user,
  5516.             'sejour' => $sejour,
  5517.             'ParentSejour' => $ParentSejour[0],
  5518.         ]);
  5519.     }
  5520.     /**
  5521.      * @Route("/Parent/SuiviCommandeparent", name="SuiviCommandeparent")
  5522.      * */
  5523.     public function SuiviCommandeparent()
  5524.     {
  5525.         // dd($liste);
  5526.         $user $this->getUser();
  5527.         //dd($user);
  5528.         $cmdservice $this->commandeService;
  5529.         $session $this->session;
  5530.         $idSejour $session->get("Sejour");
  5531.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  5532.         $listeCmd $cmdservice->listerCommandeParent($user);
  5533.         return $this->render('Parent/suivicommande.html.twig', [
  5534.             'user' => $user,
  5535.             'sejour' => $sejour,
  5536.             'listeCmd' => $listeCmd
  5537.         ]);
  5538.     }
  5539.     private function envoieMailPackNumerique($nameZip$email$commande)
  5540.     {
  5541.         // Utiliser directement le numĂ©ro de commande comme identifiant de tĂ©lĂ©chargement
  5542.         $downloadLink =  $nameZip;
  5543.         $this->emailsCmdService->MailPackPhotosNumerique(
  5544.             $email,
  5545.             $downloadLink,
  5546.             $commande->getId(),
  5547.         );
  5548.         // Marquer comme envoyĂ©
  5549.         $commande->setEnvoi(1);
  5550.         $this->em->getManager()->persist($commande);
  5551.         $this->em->getManager()->flush();
  5552.         $this->logger->info("Email sent for order: ");
  5553.         return true;
  5554.     }
  5555.     /**
  5556.      * @Route("/Parent/telechargerPack/{idCommande}", name="telechargerPack")
  5557.      */
  5558.     public function TelechagerPackNumerique($idCommande): Response
  5559.     {
  5560.         $this->logger->info("Tentative de tĂ©lĂ©chargement du pack pour la commande numĂ©rique ID: {$idCommande}");
  5561.         // RĂ©cupĂ©rer la commande numĂ©rique
  5562.         $commandeNumerique $this->em->getRepository(CommandeNumerique::class)->find($idCommande);
  5563.         // VĂ©rifier si la commande existe
  5564.         if (!$commandeNumerique) {
  5565.             $this->logger->error("Commande numĂ©rique introuvable - ID: {$idCommande}");
  5566.             return new JsonResponse(["message" => "Commande introuvable"], 404);
  5567.         }
  5568.         // RĂ©cupĂ©rer les informations associĂ©es
  5569.         $commande $commandeNumerique->getIdCommande();
  5570.         $idcommande $commande->getId();
  5571.         $user $commande->getIdUser();
  5572.         $iduser $user->getId();
  5573.         $sejour $commande->getIdSejour();
  5574.         $this->logger->info("Commande numĂ©rique {$commandeNumerique->getId()} trouvĂ©e, commande parent ID: {$idcommande}, utilisateur: {$user->getEmail()},ETAT: {$commandeNumerique->getEtat()}");
  5575.         $idCmdNumerique $commandeNumerique->getId();
  5576.         // VĂ©rifier si le lien de tĂ©lĂ©chargement existe
  5577.         $refcmdnum $commandeNumerique->getLinkdownload();
  5578.         $this->logger->info("Lien de tĂ©lĂ©chargement: {$refcmdnum}");
  5579.         if (!$refcmdnum) {
  5580.             // Envoyer un email d'alerte Ă  l'administrateur
  5581.             $email = (new Email())
  5582.                 ->from('noreply@5sur5sejour.com')
  5583.                 ->to('yousra.tlich@gmail.com')
  5584.                 ->subject('ALERTE - Lien de tĂ©lĂ©chargement corrompu')
  5585.                 ->text(
  5586.                     "Le lien de tĂ©lĂ©chargement est corrompu pour la commande suivante:\n" .
  5587.                         "ID Commande NumĂ©rique: " $idCmdNumerique "\n" .
  5588.                         "ID Commande: " $idcommande "\n" .
  5589.                         "Utilisateur: " $user->getEmail() . "\n" .
  5590.                         "SĂ©jour: " $sejour->getLibelleSejour() . "\n" .
  5591.                         "Date: " . (new \DateTime())->format('Y-m-d H:i:s')
  5592.                 );
  5593.             $this->symfonyMailer->send($email);
  5594.             $this->logger->error("Lien de tĂ©lĂ©chargement corrompu pour la commande numĂ©rique {$idCommande}");
  5595.             return new JsonResponse(["message" => "Lien de tĂ©lĂ©chargement non disponible"], 404);
  5596.         }
  5597.         $this->logger->info("Lien de tĂ©lĂ©chargement trouvĂ© pour la commande numĂ©rique {$idCommande}{$refcmdnum}");
  5598.         // VĂ©rifier que l'utilisateur et le sĂ©jour existent
  5599.         if (!$user || !$sejour) {
  5600.             $this->logger->error("Utilisateur ou sĂ©jour manquant pour la commande numĂ©rique {$idCommande}");
  5601.             return new JsonResponse(['message' => 'Lien invalide - utilisateur ou sĂ©jour manquant'], 400);
  5602.         }
  5603.         // VĂ©rifier l'Ă©tat de la commande
  5604.         if ($commandeNumerique->getEtat() === 1) {
  5605.             // Construire le chemin du fichier
  5606.             $filePath $this->getParameter('kernel.project_dir') . '/public/ParentPhotosNumerique/' $refcmdnum '.zip';
  5607.             // VĂ©rifier si le fichier existe
  5608.             if (file_exists($filePath)) {
  5609.                 $this->logger->info("Fichier trouvĂ©, tĂ©lĂ©chargement dĂ©marrĂ© pour la commande numĂ©rique {$idCmdNumerique}");
  5610.                 return $this->file($filePath$refcmdnum '.zip'ResponseHeaderBag::DISPOSITION_ATTACHMENT);
  5611.             } else {
  5612.                 // Envoyer un email d'alerte pour fichier manquant
  5613.                 $email = (new Email())
  5614.                     ->from('noreply@5sur5sejour.com')
  5615.                     ->to('yousra.tlich@gmail.com')
  5616.                     ->subject('ALERTE - Fichier ZIP manquant')
  5617.                     ->text(
  5618.                         "Le fichier ZIP est manquant pour la commande suivante:\n" .
  5619.                             "ID Commande NumĂ©rique: " $idCommande "\n" .
  5620.                             "ID Commande: " $idcommande "\n" .
  5621.                             "Lien de tĂ©lĂ©chargement: " $refcmdnum "\n" .
  5622.                             "Chemin attendu: " $filePath "\n" .
  5623.                             "Date: " . (new \DateTime())->format('Y-m-d H:i:s')
  5624.                     );
  5625.                 $this->symfonyMailer->send($email);
  5626.                 $this->logger->error("Fichier ZIP manquant pour la commande numĂ©rique {$idCommande} - chemin: {$filePath}");
  5627.                 return new JsonResponse(['message' => 'Fichier non trouvĂ©'], 404);
  5628.             }
  5629.         } elseif ($commandeNumerique->getEtat() == 2) {
  5630.             $this->logger->warning("Tentative de tĂ©lĂ©chargement d'une commande dĂ©jĂ  livrĂ©e - ID: {$idCommande}");
  5631.             return new JsonResponse(['message' => 'Commande dĂ©jĂ  livrĂ©e'], 400);
  5632.         } else {
  5633.             $this->logger->warning("État de commande invalide pour la commande numĂ©rique {$idCmdNumerique} - Ă©tat: {$commandeNumerique->getEtat()}");
  5634.             return new JsonResponse(['message' => 'Commande invalide'], 400);
  5635.         }
  5636.     }
  5637.     /**
  5638.      * @Route("/Parent/disableTelecharge/{idCommande}" , name="disableTelecharge" )
  5639.      */
  5640.     public function disableTelecharge($idCommande)
  5641.     {
  5642.         $commandenumerique $this->em->getRepository(CommandeNumerique::class)->findOneBy(['id' => $idCommande]);
  5643.         $commandenumerique->setEtat(2);
  5644.         $commandenumerique->setDateTelechargement(new \DateTime());
  5645.         $this->em->getManager()->persist($commandenumerique);
  5646.         $this->em->getManager()->flush();
  5647.         return "ok";
  5648.     }
  5649.     /**
  5650.      * @Route("/Accompagnateur/pdffacturetest/{id}", name="pdffacturetest")
  5651.      */
  5652.     public function pdffactureAccomptest($id)
  5653.     {
  5654.         $em $this->em;
  5655.         $cmd $em->getRepository(Commande::class)->find($id);
  5656.         return $this->render('Parent/pdfFactureParent.html.twig', [
  5657.             "comande" => $cmd,
  5658.         ]);
  5659.     }
  5660.     /**
  5661.      * @Route("/Parent/pdffacture/{id}", name="pdffacture")
  5662.      */
  5663.     public function pdffacture($id)
  5664.     {
  5665.         $user $this->getUser();
  5666.         $cmd $this->em->getRepository(Commande::class)->find($id);
  5667.         //   $result=   $this->EmailServie->MailCommandeSuivieParent($user->getEmail(),$cmd );
  5668.         // Configure Dompdf according to your needs
  5669.         $pdfOptions = new Options();
  5670.         $pdfOptions->set('isRemoteEnabled'TRUE);
  5671.         $pdfOptions->set('defaultFont''Arial');
  5672.         // Instantiate Dompdf with our options
  5673.         $dompdf = new Dompdf($pdfOptions);
  5674.         $dompdf->set_option('isRemoteEnabled'TRUE);
  5675.         // Retrieve the HTML generated in our twig file
  5676.         $html $this->renderView('Parent/pdfFactureParent.html.twig', [
  5677.             "comande" => $cmd,
  5678.         ]);
  5679.         // Load HTML to Dompdf
  5680.         $dompdf->loadHtml($html);
  5681.         // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  5682.         $dompdf->setPaper('A4''portrait');
  5683.         // Render the HTML as PDF
  5684.         $dompdf->render();
  5685.         // Output the generated PDF to Browser (force download)
  5686.         $dompdf->stream("facture.pdf", [
  5687.             "Attachment" => true
  5688.         ]);
  5689.         return new Response('yoopi');
  5690.     }
  5691.     /**
  5692.      * @Route("/Parent/testPDF/{idPrdt}", name="TcPdf")
  5693.      */
  5694.     public function TcPdf($idPrdt)
  5695.     {
  5696.         ini_set("max_execution_time", -1);
  5697.         $pageLayout = array(2115);
  5698.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  5699.         // set document information
  5700.         $pdf->SetCreator(PDF_CREATOR);
  5701.         $pdf->SetAuthor('Nicola Asuni');
  5702.         $pdf->SetTitle('TCPDF Example 009');
  5703.         $pdf->SetSubject('TCPDF Tutorial');
  5704.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  5705.         $pdf->SetSubject('TCPDF Tutorial');
  5706.         $pdf->setPrintHeader(false);
  5707.         $pdf->setPrintFooter(false);
  5708.         // set image scale factor
  5709.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  5710.         //        $pdf->AddPage();
  5711.         $pdf->setJPEGQuality(100);
  5712.         $horizontal_alignments = array('L''C''R');
  5713.         $vertical_alignments = array('T''M''B');
  5714.         //var_dump($pdf->getPageWidth());
  5715.         //var_dump($pdf->getPageHeight());die();
  5716.         $em $this->em;
  5717.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  5718.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  5719.         //dd($AllPages);
  5720.         //        $fP=[];
  5721.         //        array_push($fP,$AllPages[0]);
  5722.         //dd($AllPages);
  5723.         foreach ($AllPages as $p) {
  5724.             $pdf->AddPage();
  5725.             $pdf->setJPEGQuality(100);
  5726.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  5727.             $nbatach $contenu->nbrAttc;
  5728.             $nbatach intval(str_replace('"'''$nbatach));
  5729.             $color =  $contenu->color;
  5730.             // $color="rgb(255,255,255)";
  5731.             $color str_replace('"rgb('''$color);
  5732.             $color str_replace(')"'''$color);
  5733.             $color explode(","$color);
  5734.             $colorp = array(intval($color[0]), intval($color[1]), intval($color[2]));
  5735.             $tabtxt json_decode($contenu->txt);
  5736.             $tabphoto json_decode($contenu->attache);
  5737.             //
  5738.             //dd($tabtxt);
  5739.             //         dd($tabtxt);
  5740.             //dd($tabphoto);
  5741.             $tabClips json_decode($contenu->clips);
  5742.             // dd($tabClips);
  5743.             $x 0.6;
  5744.             $y 0.8;
  5745.             $w 19.8;
  5746.             $h 13.4;
  5747.             // get the current page break margin
  5748.             $bMargin $pdf->getBreakMargin();
  5749.             // get current auto-page-break mode
  5750.             $auto_page_break $pdf->getAutoPageBreak();
  5751.             // disable auto-page-break
  5752.             $pdf->SetAutoPageBreak(false0);
  5753.             // test all combinations of alignments
  5754.             $fitbox $horizontal_alignments[1] . ' ';
  5755.             $fitbox[1] = $vertical_alignments[1];
  5756.             $pdf->Rect(002115'F', array(), $colorp);
  5757.             //    sizeof($tabphoto)
  5758.             for ($i 0$i sizeof($tabphoto); $i++) {
  5759.                 $photo json_decode($tabphoto[$i]);
  5760.                 //les coordonnĂ©es de l'image rĂ©el:
  5761.                 $hght $photo->height;
  5762.                 $top $photo->top;
  5763.                 $left $photo->left;
  5764.                 $width $photo->width;
  5765.                 $ordre $photo->ordre;
  5766.                 $zoom $photo->zoom;
  5767.                 $path $photo->path;
  5768.                 $hght floatval(str_replace('cm'''$hght));
  5769.                 $top floatval(str_replace('cm'''$top));
  5770.                 $left floatval(str_replace('cm'''$left));
  5771.                 $width floatval(str_replace('cm'''$width));
  5772.                 //les coordonnĂ©es dropzone:
  5773.                 $heightOriginal $photo->height;
  5774.                 $widthOriginal $photo->width;
  5775.                 $top $photo->top;
  5776.                 $left $photo->left;
  5777.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  5778.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  5779.                 $top floatval(str_replace('cm'''$top));
  5780.                 $left floatval(str_replace('cm'''$left));
  5781.                 $heightOriginal $heightOriginal 37.7952755906;
  5782.                 $widthOriginal $widthOriginal 37.7952755906;
  5783.                 $topOriginal $top 37.7952755906;
  5784.                 $leftOriginal $left 37.7952755906;
  5785.                 $heightCrop $photo->heightCrop;
  5786.                 $topCrop $photo->topCrop;
  5787.                 $leftCrop $photo->leftCrop;
  5788.                 $widthCrop $photo->widthCrop;
  5789.                 $path $photo->path;
  5790.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  5791.                 $topCrop floatval(str_replace('cm'''$topCrop));
  5792.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  5793.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  5794.                 $widthCropPX $widthCrop 37.7952755906;
  5795.                 $heightCropPX $heightCrop 37.7952755906;
  5796.                 $topCropPX $topCrop 37.7952755906;
  5797.                 $leftCropPX $leftCrop 37.7952755906;
  5798.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  5799.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  5800.                 // var_dump("//00");
  5801.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  5802.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  5803.                 //Calculer position des images selon nombres images par page:
  5804.                 $positionX 0;
  5805.                 $positionY 0;
  5806.                 $widthImg 0;
  5807.                 $heightImg 0;
  5808.                 if ($nbatach == 1) {
  5809.                     $positionX 1.5;
  5810.                     $positionY 1.5;
  5811.                     $widthImg 18;
  5812.                     $heightImg 12;
  5813.                 } elseif ($nbatach == 2) {
  5814.                     if ($ordre == 1) {
  5815.                         $positionX 1.5;
  5816.                         $positionY 1.5;
  5817.                         $widthImg 8.7;
  5818.                         $heightImg 12;
  5819.                     }
  5820.                     if ($ordre == 2) {
  5821.                         $positionX 10.8;
  5822.                         $positionY 1.5;
  5823.                         $widthImg 8.7;
  5824.                         $heightImg 12;
  5825.                     }
  5826.                 } elseif ($nbatach == 3) {
  5827.                     if ($ordre == 1) {
  5828.                         $positionX 1.5;
  5829.                         $positionY 1.5;
  5830.                         $widthImg 8.7;
  5831.                         $heightImg 12;
  5832.                     }
  5833.                     if ($ordre == 2) {
  5834.                         $positionX 10.8;
  5835.                         $positionY 1.5;
  5836.                         $widthImg 8.7;
  5837.                         $heightImg 5.7;
  5838.                     }
  5839.                     if ($ordre == 3) {
  5840.                         $positionX 10.8;
  5841.                         $positionY 7.8;
  5842.                         $widthImg 8.7;
  5843.                         $heightImg 5.7;
  5844.                     }
  5845.                 } elseif ($nbatach == 4) {
  5846.                     if ($ordre == 1) {
  5847.                         $positionX 1.5;
  5848.                         $positionY 1.5;
  5849.                         $widthImg 8.7;
  5850.                         $heightImg 5.7;
  5851.                     }
  5852.                     if ($ordre == 2) {
  5853.                         $positionX 1.5;
  5854.                         $positionY 7.8;
  5855.                         $widthImg 8.7;
  5856.                         $heightImg 5.7;
  5857.                     }
  5858.                     if ($ordre == 3) {
  5859.                         $positionX 10.8;
  5860.                         $positionY 1.5;
  5861.                         $widthImg 8.7;
  5862.                         $heightImg 5.7;
  5863.                     }
  5864.                     if ($ordre == 4) {
  5865.                         $positionX 10.8;
  5866.                         $positionY 7.8;
  5867.                         $widthImg 8.7;
  5868.                         $heightImg 5.7;
  5869.                     }
  5870.                 } elseif ($nbatach == 5) {
  5871.                     if ($ordre == 1) {
  5872.                         $positionX 1.5;
  5873.                         $positionY 1.5;
  5874.                         $widthImg 18;
  5875.                         $heightImg 8;
  5876.                     }
  5877.                     if ($ordre == 2) {
  5878.                         $positionX 1.5;
  5879.                         $positionY 10.1;
  5880.                         $widthImg 4.05;
  5881.                         $heightImg 3.4;
  5882.                     }
  5883.                     if ($ordre == 3) {
  5884.                         $positionX 6.15;
  5885.                         $positionY 10.1;
  5886.                         $widthImg 4.05;
  5887.                         $heightImg 3.4;
  5888.                     }
  5889.                     if ($ordre == 4) {
  5890.                         $positionX 10.8;
  5891.                         $positionY 10.1;
  5892.                         $widthImg 4.05;
  5893.                         $heightImg 3.4;
  5894.                     }
  5895.                     if ($ordre == 5) {
  5896.                         $positionX 15.45;
  5897.                         $positionY 10.1;
  5898.                         $widthImg 4.05;
  5899.                         $heightImg 3.4;
  5900.                     }
  5901.                 } elseif ($nbatach == 6) {
  5902.                     if ($ordre == 1) {
  5903.                         $positionX 1.5;
  5904.                         $positionY 1.5;
  5905.                         $widthImg 5.53;
  5906.                         $heightImg 3.6;
  5907.                     }
  5908.                     if ($ordre == 2) {
  5909.                         $positionX 1.5;
  5910.                         $positionY 5.7;
  5911.                         $widthImg 5.53;
  5912.                         $heightImg 3.6;
  5913.                     }
  5914.                     if ($ordre == 3) {
  5915.                         $positionX 1.5;
  5916.                         $positionY 9.9;
  5917.                         $widthImg 5.53;
  5918.                         $heightImg 3.6;
  5919.                     }
  5920.                     if ($ordre == 4) {
  5921.                         $positionX 7.63;
  5922.                         $positionY 1.5;
  5923.                         $widthImg 5.53;
  5924.                         $heightImg 3.6;
  5925.                     }
  5926.                     if ($ordre == 5) {
  5927.                         $positionX 7.63;
  5928.                         $positionY 5.7;
  5929.                         $widthImg 5.53;
  5930.                         $heightImg 3.6;
  5931.                     }
  5932.                     if ($ordre == 6) {
  5933.                         $positionX 7.63;
  5934.                         $positionY 9.9;
  5935.                         $widthImg 5.53;
  5936.                         $heightImg 3.6;
  5937.                     }
  5938.                 } elseif ($nbatach == 12) {
  5939.                     if ($ordre == 1) {
  5940.                         $positionX 1.5;
  5941.                         $positionY 1.5;
  5942.                         $widthImg 4.05;
  5943.                         $heightImg 3.6;
  5944.                     }
  5945.                     if ($ordre == 2) {
  5946.                         $positionX 1.5;
  5947.                         $positionY 5.7;
  5948.                         $widthImg 4.05;
  5949.                         $heightImg 3.6;
  5950.                     }
  5951.                     if ($ordre == 3) {
  5952.                         $positionX 1.5;
  5953.                         $positionY 9.9;
  5954.                         $widthImg 4.05;
  5955.                         $heightImg 3.6;
  5956.                     }
  5957.                     if ($ordre == 4) {
  5958.                         $positionX 6.15;
  5959.                         $positionY 1.5;
  5960.                         $widthImg 4.05;
  5961.                         $heightImg 3.6;
  5962.                     }
  5963.                     if ($ordre == 5) {
  5964.                         $positionX 6.15;
  5965.                         $positionY 5.7;
  5966.                         $widthImg 4.05;
  5967.                         $heightImg 3.6;
  5968.                     }
  5969.                     if ($ordre == 6) {
  5970.                         $positionX 6.15;
  5971.                         $positionY 9.9;
  5972.                         $widthImg 4.05;
  5973.                         $heightImg 3.6;
  5974.                     }
  5975.                     if ($ordre == 7) {
  5976.                         $positionX 10.8;
  5977.                         $positionY 1.5;
  5978.                         $widthImg 4.05;
  5979.                         $heightImg 3.6;
  5980.                     }
  5981.                     if ($ordre == 8) {
  5982.                         $positionX 10.8;
  5983.                         $positionY 5.7;
  5984.                         $widthImg 4.05;
  5985.                         $heightImg 3.6;
  5986.                     }
  5987.                     if ($ordre == 9) {
  5988.                         $positionX 10.8;
  5989.                         $positionY 9.9;
  5990.                         $widthImg 4.05;
  5991.                         $heightImg 3.6;
  5992.                     }
  5993.                     if ($ordre == 10) {
  5994.                         $positionX 15.45;
  5995.                         $positionY 1.5;
  5996.                         $widthImg 4.05;
  5997.                         $heightImg 3.6;
  5998.                     }
  5999.                     if ($ordre == 11) {
  6000.                         $positionX 15.45;
  6001.                         $positionY 5.7;
  6002.                         $widthImg 4.05;
  6003.                         $heightImg 3.6;
  6004.                     }
  6005.                     if ($ordre == 12) {
  6006.                         $positionX 15.45;
  6007.                         $positionY 9.9;
  6008.                         $widthImg 4.05;
  6009.                         $heightImg 3.6;
  6010.                     }
  6011.                 }
  6012.                 //Recarder l'image :
  6013.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  6014.                 //                $path=str_replace( 'upload/', 'upload/ar_1,c_crop,x_'.round($left*37.7952755906).',y_'.round($top*37.7952755906).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',g_north_east/',$path);
  6015.                 $pathArray explode("/"$path);
  6016.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  6017.                 $idImage "";
  6018.                 foreach ($idsArray as $key => $elem) {
  6019.                     if ($key != (sizeof($idsArray) - 1)) {
  6020.                         $idImage $idImage $elem;
  6021.                     }
  6022.                 }
  6023.                 //   $cloudinaryWidht=$widthOriginal;
  6024.                 // $cloudinaryHeight=$widthOriginal;
  6025.                 $idImage 'newprod/' $idImage;
  6026.                 //var_dump($idImage);
  6027.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  6028.                 $headers = array('Accept' => 'application/json');
  6029.                 $data = array("public_ids" => array($idImage));
  6030.                 $body Unirest\Request\Body::form($data);
  6031.                 Unirest\Request::verifyPeer(false);
  6032.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  6033.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  6034.                 //  var_dump($url);
  6035.                 //https://media.5sur5sejour.com/api/upload/a_exif/original/
  6036.                 $resultMetadata Unirest\Request::post($url$headers$body);
  6037.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  6038.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  6039.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  6040.                 } else {
  6041.                     $cloudinaryWidht $widthOriginal;
  6042.                     $cloudinaryHeight $heightOriginal;
  6043.                 }
  6044.                 $ratiohight $cloudinaryWidht $widthOriginal;
  6045.                 $ratioHight $cloudinaryHeight $heightOriginal;
  6046.                 //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  6047.                 //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  6048.                 var_dump($cloudinaryWidht);
  6049.                 var_dump($cloudinaryHeight);
  6050.                 var_dump($ratioHight);
  6051.                 var_dump($zoom);
  6052.                 var_dump($leftOriginal);
  6053.                 var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  6054.                 var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  6055.                 var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  6056.                 var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  6057.                 //var_dump($path);i
  6058.                 $path str_replace('upload/''upload/w_' round($cloudinaryWidht) . ',h_' round($cloudinaryHeight) . ',c_scale/x_' round(abs($leftOriginal $zoom) * $ratioHight) . ',y_' round(abs($topOriginal $zoom) * $ratiohight) . ',w_' round(($widthCropPX $zoom) * $ratioHight) . ',h_' round(($heightCropPX $zoom) * $ratiohight) . ',c_crop/'$path);
  6059.                 //var_dump($path);i
  6060.                 //                $path=str_replace( 'upload/', 'upload/w_'.round($widthOriginal).',h_'.round($heightOriginal).'/x_'.round(abs($leftOriginal)).',y_'.round(abs($topOriginal)).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',c_crop/',$path);
  6061.                 //var_dump($path);
  6062.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  6063.                 //  var_dump("//00");
  6064.                 //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  6065.                 //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  6066.                 //    var_dump("//00");
  6067.                 //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  6068.                 //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  6069.                 var_dump($zoom);
  6070.                 var_dump($path);
  6071.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  6072.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  6073.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  6074.                 //
  6075.             }
  6076.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  6077.             for ($i 0$i sizeof($tabtxt); $i++) {
  6078.                 $txt json_decode($tabtxt[$i]);
  6079.                 $fontSize floatval(str_replace('px'''$txt->fontSize)) * 0.75;
  6080.                 //$txt->rotation
  6081.                 $check explode(','$txt->fontFamily);
  6082.                 if (sizeof($check) > 1) {
  6083.                     //default
  6084.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 400)) {
  6085.                         $finalFont "helvetica";
  6086.                         $weight '';
  6087.                     }
  6088.                     //classique
  6089.                     if (($check[0] == "Georgia") && ($txt->fontWeight == 400)) {
  6090.                         $finalFont "times";
  6091.                         $weight '';
  6092.                     }
  6093.                     //creative
  6094.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 700)) {
  6095.                         $finalFont "helveticaB";
  6096.                         $weight '';
  6097.                     }
  6098.                     // manuscrite
  6099.                     if (($check[0] == "Comic Sans") && ($txt->fontWeight == 400)) {
  6100.                         $finalFont "Courier";
  6101.                         $weight '';
  6102.                     }
  6103.                     //c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff2
  6104.                 } else {
  6105.                     //baton
  6106.                     if (($txt->fontFamily == 'Impact') && ($txt->fontWeight == 400)) {
  6107.                         $finalFont "helveticaB";
  6108.                         $weight 'B';
  6109.                     }
  6110.                 }
  6111.                 $pdf->SetFont($finalFont$weight$fontSize);
  6112.                 $leftTxt $txt->left;
  6113.                 $topTxt $txt->top;
  6114.                 $heightClips $txt->height;
  6115.                 $widthClips $txt->width;
  6116.                 $heightTxt floatval(str_replace('cm'''$heightClips));
  6117.                 $topTxt floatval(str_replace('cm'''$topTxt));
  6118.                 $leftTxt floatval(str_replace('cm'''$leftTxt));
  6119.                 $widthTxt floatval(str_replace('cm'''$widthClips));
  6120.                 $pdf->SetXY($leftTxt$topTxttrue);
  6121.                 //                    var_dump($leftTxt);
  6122.                 //                  var_dump($topTxt);
  6123.                 // var_dump(floatval(str_replace('rad','',$txt->rotation))*57,2958);
  6124.                 //                var_dump("text");
  6125.                 $pdf->StartTransform();
  6126.                 var_dump($txt->rotation);
  6127.                 var_dump(str_replace('rad'''$txt->rotation));
  6128.                 var_dump(floatval(str_replace('rad'''$txt->rotation)) * 57.2958);
  6129.                 $pdf->Rotate((floatval(str_replace('rad'''$txt->rotation)) * 57.2958) * -1$leftTxt + ($widthTxt 2), $topTxt + ($heightTxt 2));
  6130.                 // $pdf->Rotate(45);
  6131.                 //   $pdf->Text($leftTxt, $topTxt, $txt->contenu);
  6132.                 //$pdf->SetTextColor(200);
  6133.                 //$pdf->Text($leftTxt, $topTxt, $txt->contenu);
  6134.                 // $pdf->MultiCell($leftTxt, $topTxt,  $txt->contenu, 0, $ln=0, 'C', 0, '', 0, false, 'C', 'C');
  6135.                 $pdf->Write(str_replace('cm'''$txt->height), trim($txt->contenu));
  6136.                 // $pdf->writeHTML("<p>".$txt->contenu."</p>", true, false, false, false, '');
  6137.                 $pdf->StopTransform();
  6138.             }
  6139.             //Positionner text
  6140.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  6141.             //Positionner clipart
  6142.             //            dd($tabClips);
  6143.             for ($i 0$i sizeof($tabClips); $i++) {
  6144.                 $Clips json_decode($tabClips[$i]);
  6145.                 $heightClips $Clips->height;
  6146.                 $topClips $Clips->top;
  6147.                 $leftClips $Clips->left;
  6148.                 $widthClips $Clips->width;
  6149.                 $path $Clips->path;
  6150.                 $pathClips str_replace('"'''$path);
  6151.                 $heightClips floatval(str_replace('cm'''$heightClips));
  6152.                 $topClips floatval(str_replace('cm'''$topClips));
  6153.                 $leftClips floatval(str_replace('cm'''$leftClips));
  6154.                 $widthClips floatval(str_replace('cm'''$widthClips));
  6155.                 $heightClipsPX round($heightClips 37.7952755906);
  6156.                 $widthClipsPX round($widthClips 37.7952755906);
  6157.                 ////                $positionXclips = $positionX + $leftClips;
  6158.                 ////                $positionYclips = $positionY + $topClips;
  6159.                 //
  6160.                 //$pdf->ImageSVG("images/ClipArt_SVG/Ete4.svg",$leftClips,$topClips,$widthClips, $heightClips);
  6161.                 //https://res.cloudinary.com/apss-factory/image/private/s--EdExAzx8--/v1588758453/GlobeFooter_c4duua.svg
  6162.                 // https://res.cloudinary.com/apss-factory/image/upload/v1588764528/Groupe_113_pcjyj4.png
  6163.                 var_dump($pathClips);
  6164.                 $pdf->StartTransform();
  6165.                 $pdf->Rotate((floatval(str_replace('rad'''$Clips->rotation)) * 57.2958) * -1$leftClips + ($widthClips 2), $topClips + ($heightClips 2));
  6166.                 $pdf->Image($this->newPAthCLipart($pathClips$heightClipsPX$widthClipsPX), $leftClips,  $topClips$widthClips$heightClips''''''false300);
  6167.                 $pdf->StopTransform();
  6168.             }
  6169.         }
  6170.         // echo '</pre>';
  6171.         //return new response("yezi");
  6172.         $projectRoot $this->getParameter('kernel.project_dir');
  6173.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  6174.         return new response("yezi");
  6175.         //return $pdf->Output('example_009.pdf', 'I');
  6176.     }
  6177.     /**
  6178.      * @Route("/Parent/testPDFphoto/{idPrdt}", name="TcPdfphoto")
  6179.      */
  6180.     public function TcPdfPhoto($idPrdt)
  6181.     {
  6182.         ini_set("max_execution_time", -1);
  6183.         $pageLayout = array(1510);
  6184.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  6185.         // set document information
  6186.         $pdf->SetCreator(PDF_CREATOR);
  6187.         $pdf->SetAuthor('Nicola Asuni');
  6188.         $pdf->SetTitle('TCPDF Example 009');
  6189.         $pdf->SetSubject('TCPDF Tutorial');
  6190.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  6191.         $pdf->SetSubject('TCPDF Tutorial');
  6192.         $pdf->setPrintHeader(false);
  6193.         $pdf->setPrintFooter(false);
  6194.         // set image scale factor
  6195.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  6196.         //        $pdf->AddPage();
  6197.         $pdf->setJPEGQuality(100);
  6198.         $horizontal_alignments = array('L''C''R');
  6199.         $vertical_alignments = array('T''M''B');
  6200.         //var_dump($pdf->getPageWidth());
  6201.         //var_dump($pdf->getPageHeight());die();
  6202.         $em $this->em;
  6203.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  6204.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  6205.         //dd($AllPages);
  6206.         //        $fP=[];
  6207.         //        array_push($fP,$AllPages[0]);
  6208.         //dd($AllPages);
  6209.         foreach ($AllPages as $p) {
  6210.             $pdf->AddPage();
  6211.             $pdf->setJPEGQuality(100);
  6212.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  6213.             $nbatach $contenu->nbrAttc;
  6214.             $nbatach intval(str_replace('"'''$nbatach));
  6215.             $color =  $contenu->color;
  6216.             // $color="rgb(255,255,255)";
  6217.             $tabphoto json_decode($contenu->attache);
  6218.             //
  6219.             //dd($tabtxt);
  6220.             //         dd($tabtxt);
  6221.             //dd($tabphoto);
  6222.             // dd($tabClips);
  6223.             // get the current page break margin
  6224.             $bMargin $pdf->getBreakMargin();
  6225.             // get current auto-page-break mode
  6226.             $auto_page_break $pdf->getAutoPageBreak();
  6227.             // disable auto-page-break
  6228.             $pdf->SetAutoPageBreak(false0);
  6229.             // test all combinations of alignments
  6230.             $fitbox $horizontal_alignments[1] . ' ';
  6231.             $fitbox[1] = $vertical_alignments[1];
  6232.             //    sizeof($tabphoto)
  6233.             for ($i 0$i sizeof($tabphoto); $i++) {
  6234.                 $photo json_decode($tabphoto[$i]);
  6235.                 //les coordonnĂ©es de l'image rĂ©el:
  6236.                 $hght $photo->height;
  6237.                 $top $photo->top;
  6238.                 $left $photo->left;
  6239.                 $width $photo->width;
  6240.                 $ordre $photo->ordre;
  6241.                 $zoom $photo->zoom;
  6242.                 $path $photo->path;
  6243.                 $hght floatval(str_replace('cm'''$hght));
  6244.                 $top floatval(str_replace('cm'''$top));
  6245.                 $left floatval(str_replace('cm'''$left));
  6246.                 $width floatval(str_replace('cm'''$width));
  6247.                 //les coordonnĂ©es dropzone:
  6248.                 $heightOriginal $photo->height;
  6249.                 $widthOriginal $photo->width;
  6250.                 $top $photo->top;
  6251.                 $left $photo->left;
  6252.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  6253.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  6254.                 $top floatval(str_replace('cm'''$top));
  6255.                 $left floatval(str_replace('cm'''$left));
  6256.                 $heightOriginal $heightOriginal 37.7952755906;
  6257.                 $widthOriginal $widthOriginal 37.7952755906;
  6258.                 $topOriginal $top 37.7952755906;
  6259.                 $leftOriginal $left 37.7952755906;
  6260.                 $heightCrop $photo->heightCrop;
  6261.                 $topCrop $photo->topCrop;
  6262.                 $leftCrop $photo->leftCrop;
  6263.                 $widthCrop $photo->widthCrop;
  6264.                 $path $photo->path;
  6265.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  6266.                 $topCrop floatval(str_replace('cm'''$topCrop));
  6267.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  6268.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  6269.                 $widthCropPX $widthCrop 37.7952755906;
  6270.                 $heightCropPX $heightCrop 37.7952755906;
  6271.                 $topCropPX $topCrop 37.7952755906;
  6272.                 $leftCropPX $leftCrop 37.7952755906;
  6273.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  6274.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  6275.                 // var_dump("//00");
  6276.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  6277.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  6278.                 //Calculer position des images selon nombres images par page:
  6279.                 $positionX 0;
  6280.                 $positionY 0;
  6281.                 $widthImg 0;
  6282.                 $heightImg 0;
  6283.                 if ($nbatach == 1) {
  6284.                     $positionX 0.3;
  6285.                     $positionY 0.3;
  6286.                     $widthImg 14.4;
  6287.                     $heightImg 9.4;
  6288.                 }
  6289.                 //Recarder l'image :
  6290.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  6291.                 //                $path=str_replace( 'upload/', 'upload/ar_1,c_crop,x_'.round($left*37.7952755906).',y_'.round($top*37.7952755906).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',g_north_east/',$path);
  6292.                 $pathArray explode("/"$path);
  6293.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  6294.                 $idImage "";
  6295.                 foreach ($idsArray as $key => $elem) {
  6296.                     if ($key != (sizeof($idsArray) - 1)) {
  6297.                         $idImage $idImage $elem;
  6298.                     }
  6299.                 }
  6300.                 //   $cloudinaryWidht=$widthOriginal;
  6301.                 // $cloudinaryHeight=$widthOriginal;
  6302.                 $idImage 'newprod/' $idImage;
  6303.                 //var_dump($idImage);
  6304.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  6305.                 $headers = array('Accept' => 'application/json');
  6306.                 $data = array("public_ids" => array($idImage));
  6307.                 $body Unirest\Request\Body::form($data);
  6308.                 Unirest\Request::verifyPeer(false);
  6309.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  6310.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  6311.                 //  var_dump($url);
  6312.                 $resultMetadata Unirest\Request::post($url$headers$body);
  6313.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  6314.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  6315.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  6316.                 } else {
  6317.                     $cloudinaryWidht $widthOriginal;
  6318.                     $cloudinaryHeight $heightOriginal;
  6319.                 }
  6320.                 $ratiohight $cloudinaryWidht $widthOriginal;
  6321.                 $ratioHight $cloudinaryHeight $heightOriginal;
  6322.                 //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  6323.                 //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  6324.                 $zoom 1;
  6325.                 var_dump($cloudinaryWidht);
  6326.                 var_dump($cloudinaryHeight);
  6327.                 var_dump($ratioHight);
  6328.                 var_dump($zoom);
  6329.                 var_dump($leftOriginal);
  6330.                 var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  6331.                 var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  6332.                 var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  6333.                 var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  6334.                 //var_dump($path);i
  6335.                 $path str_replace('upload/''upload/w_' round($cloudinaryWidht) . ',h_' round($cloudinaryHeight) . ',c_scale/x_' round(abs($leftOriginal $zoom) * $ratioHight) . ',y_' round(abs($topOriginal $zoom) * $ratiohight) . ',w_' round(($widthCropPX $zoom) * $ratioHight) . ',h_' round(($heightCropPX $zoom) * $ratiohight) . ',c_crop/'$path);
  6336.                 //var_dump($path);i
  6337.                 //                $path=str_replace( 'upload/', 'upload/w_'.round($widthOriginal).',h_'.round($heightOriginal).'/x_'.round(abs($leftOriginal)).',y_'.round(abs($topOriginal)).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',c_crop/',$path);
  6338.                 //var_dump($path);
  6339.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  6340.                 //  var_dump("//00");
  6341.                 //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  6342.                 //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  6343.                 //    var_dump("//00");
  6344.                 //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  6345.                 //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  6346.                 var_dump($zoom);
  6347.                 var_dump($path);
  6348.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  6349.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  6350.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  6351.                 //
  6352.             }
  6353.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  6354.             //Positionner text
  6355.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  6356.             //Positionner clipart
  6357.             //            dd($tabClips);
  6358.         }
  6359.         // echo '</pre>';
  6360.         //return new response("yezi");
  6361.         $projectRoot $this->getParameter('kernel.project_dir');
  6362.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  6363.         return new response("yezi");
  6364.         //return $pdf->Output('example_009.pdf', 'I');
  6365.     }
  6366.     /**
  6367.      * @Route("/Parent/testPDFphotoR/{idPrdt}", name="TcPdfphotoR")
  6368.      */
  6369.     public function TcPdfPhotoR($idPrdt)
  6370.     {
  6371.         ini_set("max_execution_time", -1);
  6372.         $pageLayout = array(910);
  6373.         $pdf $this->get("white_october.tcpdf")->create('P''CM'$pageLayouttrue'UTF-8'false);
  6374.         // set document information
  6375.         $pdf->SetCreator(PDF_CREATOR);
  6376.         $pdf->SetAuthor('Nicola Asuni');
  6377.         $pdf->SetTitle('TCPDF Example 009');
  6378.         $pdf->SetSubject('TCPDF Tutorial');
  6379.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  6380.         $pdf->SetSubject('TCPDF Tutorial');
  6381.         $pdf->setPrintHeader(false);
  6382.         $pdf->setPrintFooter(false);
  6383.         // set image scale factor
  6384.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  6385.         //        $pdf->AddPage();
  6386.         $pdf->setJPEGQuality(100);
  6387.         $horizontal_alignments = array('L''C''R');
  6388.         $vertical_alignments = array('T''M''B');
  6389.         //var_dump($pdf->getPageWidth());
  6390.         //var_dump($pdf->getPageHeight());die();
  6391.         $em $this->em;
  6392.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  6393.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  6394.         //dd($AllPages);
  6395.         //        $fP=[];
  6396.         //        array_push($fP,$AllPages[0]);
  6397.         //dd($AllPages);
  6398.         foreach ($AllPages as $p) {
  6399.             $pdf->AddPage();
  6400.             $pdf->setJPEGQuality(100);
  6401.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  6402.             $nbatach $contenu->nbrAttc;
  6403.             $nbatach intval(str_replace('"'''$nbatach));
  6404.             $color =  $contenu->color;
  6405.             // $color="rgb(255,255,255)";
  6406.             $tabphoto json_decode($contenu->attache);
  6407.             //
  6408.             //dd($tabtxt);
  6409.             //         dd($tabtxt);
  6410.             //dd($tabphoto);
  6411.             // dd($tabClips);
  6412.             // get the current page break margin
  6413.             $bMargin $pdf->getBreakMargin();
  6414.             // get current auto-page-break mode
  6415.             $auto_page_break $pdf->getAutoPageBreak();
  6416.             // disable auto-page-break
  6417.             $pdf->SetAutoPageBreak(false0);
  6418.             // test all combinations of alignments
  6419.             $fitbox $horizontal_alignments[1] . ' ';
  6420.             $fitbox[1] = $vertical_alignments[1];
  6421.             //    sizeof($tabphoto)
  6422.             for ($i 0$i sizeof($tabphoto); $i++) {
  6423.                 $photo json_decode($tabphoto[$i]);
  6424.                 //les coordonnĂ©es de l'image rĂ©el:
  6425.                 $hght $photo->height;
  6426.                 $top $photo->top;
  6427.                 $left $photo->left;
  6428.                 $width $photo->width;
  6429.                 $ordre $photo->ordre;
  6430.                 $zoom $photo->zoom;
  6431.                 $path $photo->path;
  6432.                 $hght floatval(str_replace('cm'''$hght));
  6433.                 $top floatval(str_replace('cm'''$top));
  6434.                 $left floatval(str_replace('cm'''$left));
  6435.                 $width floatval(str_replace('cm'''$width));
  6436.                 //les coordonnĂ©es dropzone:
  6437.                 $heightOriginal $photo->height;
  6438.                 $widthOriginal $photo->width;
  6439.                 $top $photo->top;
  6440.                 $left $photo->left;
  6441.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  6442.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  6443.                 $top floatval(str_replace('cm'''$top));
  6444.                 $left floatval(str_replace('cm'''$left));
  6445.                 $heightOriginal $heightOriginal 37.7952755906;
  6446.                 $widthOriginal $widthOriginal 37.7952755906;
  6447.                 $topOriginal $top 37.7952755906;
  6448.                 $leftOriginal $left 37.7952755906;
  6449.                 $heightCrop $photo->heightCrop;
  6450.                 $topCrop $photo->topCrop;
  6451.                 $leftCrop $photo->leftCrop;
  6452.                 $widthCrop $photo->widthCrop;
  6453.                 $path $photo->path;
  6454.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  6455.                 $topCrop floatval(str_replace('cm'''$topCrop));
  6456.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  6457.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  6458.                 $widthCropPX $widthCrop 37.7952755906;
  6459.                 $heightCropPX $heightCrop 37.7952755906;
  6460.                 $topCropPX $topCrop 37.7952755906;
  6461.                 $leftCropPX $leftCrop 37.7952755906;
  6462.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  6463.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  6464.                 // var_dump("//00");
  6465.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  6466.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  6467.                 //Calculer position des images selon nombres images par page:
  6468.                 $positionX 0;
  6469.                 $positionY 0;
  6470.                 $widthImg 0;
  6471.                 $heightImg 0;
  6472.                 $positionX 0.55;
  6473.                 $positionY 0.5;
  6474.                 $widthImg 7.9;
  6475.                 $heightImg 6.9;
  6476.                 //Recarder l'image :
  6477.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  6478.                 //                $path=str_replace( 'upload/', 'upload/ar_1,c_crop,x_'.round($left*37.7952755906).',y_'.round($top*37.7952755906).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',g_north_east/',$path);
  6479.                 $pathArray explode("/"$path);
  6480.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  6481.                 $idImage "";
  6482.                 foreach ($idsArray as $key => $elem) {
  6483.                     if ($key != (sizeof($idsArray) - 1)) {
  6484.                         $idImage $idImage $elem;
  6485.                     }
  6486.                 }
  6487.                 //   $cloudinaryWidht=$widthOriginal;
  6488.                 // $cloudinaryHeight=$widthOriginal;
  6489.                 $idImage 'newprod/' $idImage;
  6490.                 //var_dump($idImage);
  6491.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  6492.                 $headers = array('Accept' => 'application/json');
  6493.                 $data = array("public_ids" => array($idImage));
  6494.                 $body Unirest\Request\Body::form($data);
  6495.                 Unirest\Request::verifyPeer(false);
  6496.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  6497.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  6498.                 //  var_dump($url);
  6499.                 $resultMetadata Unirest\Request::post($url$headers$body);
  6500.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  6501.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  6502.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  6503.                 } else {
  6504.                     $cloudinaryWidht $widthOriginal;
  6505.                     $cloudinaryHeight $heightOriginal;
  6506.                 }
  6507.                 $ratiohight $cloudinaryWidht $widthOriginal;
  6508.                 $ratioHight $cloudinaryHeight $heightOriginal;
  6509.                 //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  6510.                 //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  6511.                 $zoom 1;
  6512.                 var_dump($cloudinaryWidht);
  6513.                 var_dump($cloudinaryHeight);
  6514.                 var_dump($ratioHight);
  6515.                 var_dump($zoom);
  6516.                 var_dump($leftOriginal);
  6517.                 var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  6518.                 var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  6519.                 var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  6520.                 var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  6521.                 //var_dump($path);i
  6522.                 $path str_replace('upload/''upload/w_' round($cloudinaryWidht) . ',h_' round($cloudinaryHeight) . ',c_scale/x_' round(abs($leftOriginal $zoom) * $ratioHight) . ',y_' round(abs($topOriginal $zoom) * $ratiohight) . ',w_' round(($widthCropPX $zoom) * $ratioHight) . ',h_' round(($heightCropPX $zoom) * $ratiohight) . ',c_crop/'$path);
  6523.                 //var_dump($path);i
  6524.                 //                $path=str_replace( 'upload/', 'upload/w_'.round($widthOriginal).',h_'.round($heightOriginal).'/x_'.round(abs($leftOriginal)).',y_'.round(abs($topOriginal)).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',c_crop/',$path);
  6525.                 //var_dump($path);
  6526.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  6527.                 //  var_dump("//00");
  6528.                 //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  6529.                 //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  6530.                 //    var_dump("//00");
  6531.                 //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  6532.                 //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  6533.                 var_dump($zoom);
  6534.                 var_dump($path);
  6535.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  6536.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  6537.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  6538.                 //
  6539.             }
  6540.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  6541.             //Positionner text
  6542.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  6543.             //Positionner clipart
  6544.             //            dd($tabClips);
  6545.         }
  6546.         // echo '</pre>';
  6547.         //return new response("yezi");
  6548.         $projectRoot $this->getParameter('kernel.project_dir');
  6549.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  6550.         return new response("yezi");
  6551.         //return $pdf->Output('example_009.pdf', 'I');
  6552.     }
  6553.     /**
  6554.      * @Route("/Parent/testPDFCal/{idPrdt}", name="TcPdfCal")
  6555.      */
  6556.     public function TcPdfCalendrier($idPrdt)
  6557.     {
  6558.         ini_set("max_execution_time", -1);
  6559.         $pageLayout = array(2115);
  6560.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  6561.         // set document information
  6562.         $pdf->SetCreator(PDF_CREATOR);
  6563.         $pdf->SetAuthor('Nicola Asuni');
  6564.         $pdf->SetTitle('TCPDF Example 009');
  6565.         $pdf->SetSubject('TCPDF Tutorial');
  6566.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  6567.         $pdf->SetSubject('TCPDF Tutorial');
  6568.         $pdf->setPrintHeader(false);
  6569.         $pdf->setPrintFooter(false);
  6570.         // set image scale factor
  6571.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  6572.         //        $pdf->AddPage();
  6573.         $pdf->setJPEGQuality(100);
  6574.         $horizontal_alignments = array('L''C''R');
  6575.         $vertical_alignments = array('T''M''B');
  6576.         //var_dump($pdf->getPageWidth());
  6577.         //var_dump($pdf->getPageHeight());die();
  6578.         $em $this->em;
  6579.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  6580.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  6581.         //dd($AllPages);
  6582.         //        $fP=[];
  6583.         //        array_push($fP,$AllPages[0]);
  6584.         //dd($AllPages);
  6585.         foreach ($AllPages as $key => $p) {
  6586.             $pdf->AddPage();
  6587.             $pdf->setJPEGQuality(100);
  6588.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  6589.             $nbatachS $contenu->nbrAttc;
  6590.             $nbatach intval(str_replace('"'''$nbatachS));
  6591.             if (strpos($nbatachS"H")) {
  6592.                 $nbatach $nbatach 'H';
  6593.             }
  6594.             $tabtxt json_decode($contenu->txt);
  6595.             $tabphoto json_decode($contenu->attache);
  6596.             //
  6597.             //dd($tabtxt);
  6598.             //         dd($tabtxt);
  6599.             //dd($tabphoto);
  6600.             $tabClips json_decode($contenu->clips);
  6601.             // dd($tabClips);
  6602.             $x 0.6;
  6603.             $y 0.8;
  6604.             $w 19.8;
  6605.             $h 13.4;
  6606.             // get the current page break margin
  6607.             $bMargin $pdf->getBreakMargin();
  6608.             // get current auto-page-break mode
  6609.             $auto_page_break $pdf->getAutoPageBreak();
  6610.             // disable auto-page-break
  6611.             $pdf->SetAutoPageBreak(false0);
  6612.             // test all combinations of alignments
  6613.             $fitbox $horizontal_alignments[1] . ' ';
  6614.             $fitbox[1] = $vertical_alignments[1];
  6615.             //    sizeof($tabphoto)
  6616.             for ($i 0$i sizeof($tabphoto); $i++) {
  6617.                 $photo json_decode($tabphoto[$i]);
  6618.                 //les coordonnĂ©es de l'image rĂ©el:
  6619.                 $hght $photo->height;
  6620.                 $top $photo->top;
  6621.                 $left $photo->left;
  6622.                 $width $photo->width;
  6623.                 $ordre $photo->ordre;
  6624.                 $zoom $photo->zoom;
  6625.                 $path $photo->path;
  6626.                 $hght floatval(str_replace('cm'''$hght));
  6627.                 $top floatval(str_replace('cm'''$top));
  6628.                 $left floatval(str_replace('cm'''$left));
  6629.                 $width floatval(str_replace('cm'''$width));
  6630.                 //les coordonnĂ©es dropzone:
  6631.                 $heightOriginal $photo->height;
  6632.                 $widthOriginal $photo->width;
  6633.                 $top $photo->top;
  6634.                 $left $photo->left;
  6635.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  6636.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  6637.                 $top floatval(str_replace('cm'''$top));
  6638.                 $left floatval(str_replace('cm'''$left));
  6639.                 $heightOriginal $heightOriginal 37.7952755906;
  6640.                 $widthOriginal $widthOriginal 37.7952755906;
  6641.                 $topOriginal $top 37.7952755906;
  6642.                 $leftOriginal $left 37.7952755906;
  6643.                 $heightCrop $photo->heightCrop;
  6644.                 $topCrop $photo->topCrop;
  6645.                 $leftCrop $photo->leftCrop;
  6646.                 $widthCrop $photo->widthCrop;
  6647.                 $path $photo->path;
  6648.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  6649.                 $topCrop floatval(str_replace('cm'''$topCrop));
  6650.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  6651.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  6652.                 $widthCropPX $widthCrop 37.7952755906;
  6653.                 $heightCropPX $heightCrop 37.7952755906;
  6654.                 $topCropPX $topCrop 37.7952755906;
  6655.                 $leftCropPX $leftCrop 37.7952755906;
  6656.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  6657.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  6658.                 // var_dump("//00");
  6659.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  6660.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  6661.                 //Calculer position des images selon nombres images par page:
  6662.                 $positionX 0;
  6663.                 $positionY 0;
  6664.                 $widthImg 0;
  6665.                 $heightImg 0;
  6666.                 var_dump('nbr_attach ' $nbatach);
  6667.                 if ($nbatach == 1) {
  6668.                     if ($key == 0) {
  6669.                         $positionX 1.5;
  6670.                         $positionY 1.5;
  6671.                         $widthImg 18;
  6672.                         $heightImg 10;
  6673.                     } else {
  6674.                         $positionX 1.5;
  6675.                         $positionY 1.5;
  6676.                         $widthImg 8.7;
  6677.                         $heightImg 12;
  6678.                     }
  6679.                 } elseif (($nbatach == 2) && ($nbatach == '2V')) {
  6680.                     if ($ordre == 1) {
  6681.                         $positionX 1.5;
  6682.                         $positionY 1.5;
  6683.                         $widthImg 4.05;
  6684.                         $heightImg 12;
  6685.                     }
  6686.                     if ($ordre == 2) {
  6687.                         $positionX 6.15;
  6688.                         $positionY 1.5;
  6689.                         $widthImg 4.05;
  6690.                         $heightImg 12;
  6691.                     }
  6692.                 } elseif ($nbatach == '2H') {
  6693.                     if ($ordre == 1) {
  6694.                         $positionX 1.5;
  6695.                         $positionY 1.5;
  6696.                         $widthImg 8.7;
  6697.                         $heightImg 5.7;
  6698.                     }
  6699.                     if ($ordre == 2) {
  6700.                         $positionX 1.5;
  6701.                         $positionY 7.8;
  6702.                         $widthImg 8.7;
  6703.                         $heightImg 5.7;
  6704.                     }
  6705.                 } elseif (($nbatach == 3) && ($nbatach == "3V")) {
  6706.                     if ($ordre == 1) {
  6707.                         $positionX 1.5;
  6708.                         $positionY 1.5;
  6709.                         $widthImg 4.05;
  6710.                         $heightImg 12;
  6711.                     }
  6712.                     if ($ordre == 2) {
  6713.                         $positionX 6.15;
  6714.                         $positionY =  1.5;
  6715.                         $widthImg 4.05;
  6716.                         $heightImg 5.7;
  6717.                     }
  6718.                     if ($ordre == 3) {
  6719.                         $positionX =  6.15;
  6720.                         $positionY 7.8;
  6721.                         $widthImg 4.05;
  6722.                         $heightImg 5.7;
  6723.                     }
  6724.                 } elseif ($nbatach == '3H') {
  6725.                     if ($ordre == 1) {
  6726.                         $positionX 1.5;
  6727.                         $positionY 1.5;
  6728.                         $widthImg 8.7;
  6729.                         $heightImg 5.7;
  6730.                     }
  6731.                     if ($ordre == 2) {
  6732.                         $positionX 1.5;
  6733.                         $positionY 7.8;
  6734.                         $widthImg 4.05;
  6735.                         $heightImg 5.7;
  6736.                     }
  6737.                     if ($ordre == 3) {
  6738.                         $positionX 6.15;
  6739.                         $positionY 7.8;
  6740.                         $widthImg 4.05;
  6741.                         $heightImg 5.7;
  6742.                     }
  6743.                 } elseif ($nbatach == 4) {
  6744.                     if ($ordre == 1) {
  6745.                         $positionX 1.5;
  6746.                         $positionY 1.5;
  6747.                         $widthImg 4.05;
  6748.                         $heightImg 5.7;
  6749.                     }
  6750.                     if ($ordre == 2) {
  6751.                         $positionX 1.5;
  6752.                         $positionY 7.8;
  6753.                         $widthImg 4.05;
  6754.                         $heightImg 5.7;
  6755.                     }
  6756.                     if ($ordre == 3) {
  6757.                         $positionX 6.15;
  6758.                         $positionY =  1.5;
  6759.                         $widthImg 4.05;
  6760.                         $heightImg 5.7;
  6761.                     }
  6762.                     if ($ordre == 4) {
  6763.                         $positionX =  6.15;
  6764.                         $positionY 7.8;
  6765.                         $widthImg 4.05;
  6766.                         $heightImg 5.7;
  6767.                     }
  6768.                 }
  6769.                 //nop
  6770.                 elseif ($nbatach == 5) {
  6771.                     if ($ordre == 1) {
  6772.                         $positionX 1.5;
  6773.                         $positionY 1.5;
  6774.                         $widthImg 18;
  6775.                         $heightImg 8;
  6776.                     }
  6777.                     if ($ordre == 2) {
  6778.                         $positionX 1.5;
  6779.                         $positionY 10.5;
  6780.                         $widthImg 3.75;
  6781.                         $heightImg 3;
  6782.                     }
  6783.                     if ($ordre == 3) {
  6784.                         $positionX 6.25;
  6785.                         $positionY 10.5;
  6786.                         $widthImg 3.75;
  6787.                         $heightImg 3;
  6788.                     }
  6789.                     if ($ordre == 4) {
  6790.                         $positionX 11;
  6791.                         $positionY 10.5;
  6792.                         $widthImg 3.75;
  6793.                         $heightImg 3;
  6794.                     }
  6795.                     if ($ordre == 5) {
  6796.                         $positionX 15.75;
  6797.                         $positionY 10.5;
  6798.                         $widthImg 3.75;
  6799.                         $heightImg 3;
  6800.                     }
  6801.                 } elseif ($nbatach == 6) {
  6802.                     if ($ordre == 1) {
  6803.                         $positionX 1.5;
  6804.                         $positionY 1.5;
  6805.                         $widthImg 4.05;
  6806.                         $heightImg 3.6;
  6807.                     }
  6808.                     if ($ordre == 2) {
  6809.                         $positionX 1.5;
  6810.                         $positionY 5.7;
  6811.                         $widthImg 4.05;
  6812.                         $heightImg 3.6;
  6813.                     }
  6814.                     if ($ordre == 3) {
  6815.                         $positionX 1.5;
  6816.                         $positionY 9.9;
  6817.                         $widthImg 4.05;
  6818.                         $heightImg 3.6;
  6819.                     }
  6820.                     if ($ordre == 4) {
  6821.                         $positionX =  6.15;
  6822.                         $positionY 1.5;
  6823.                         $widthImg 4.05;
  6824.                         $heightImg 3.6;
  6825.                     }
  6826.                     if ($ordre == 5) {
  6827.                         $positionX =  6.15;
  6828.                         $positionY 5.7;
  6829.                         $widthImg 4.05;
  6830.                         $heightImg 3.6;
  6831.                     }
  6832.                     if ($ordre == 6) {
  6833.                         $positionX =  6.15;
  6834.                         $positionY 9.9;
  6835.                         $widthImg 4.05;
  6836.                         $heightImg 3.6;
  6837.                     }
  6838.                 }
  6839.                 //nop
  6840.                 elseif ($nbatach == 12) {
  6841.                     if ($ordre == 1) {
  6842.                         $positionX 1.5;
  6843.                         $positionY 1.5;
  6844.                         $widthImg 3.75;
  6845.                         $heightImg 3.33;
  6846.                     }
  6847.                     if ($ordre == 2) {
  6848.                         $positionX 1.5;
  6849.                         $positionY 5.83;
  6850.                         $widthImg 3.75;
  6851.                         $heightImg 3.33;
  6852.                     }
  6853.                     if ($ordre == 3) {
  6854.                         $positionX 1.5;
  6855.                         $positionY 10.16;
  6856.                         $widthImg 3.75;
  6857.                         $heightImg 3.33;
  6858.                     }
  6859.                     if ($ordre == 4) {
  6860.                         $positionX 6.25;
  6861.                         $positionY 1.5;
  6862.                         $widthImg 3.75;
  6863.                         $heightImg 3.33;
  6864.                     }
  6865.                     if ($ordre == 5) {
  6866.                         $positionX 6.25;
  6867.                         $positionY 5.83;
  6868.                         $widthImg 3.75;
  6869.                         $heightImg 3.33;
  6870.                     }
  6871.                     if ($ordre == 6) {
  6872.                         $positionX 6.25;
  6873.                         $positionY 10.16;
  6874.                         $widthImg 3.75;
  6875.                         $heightImg 3.33;
  6876.                     }
  6877.                     if ($ordre == 7) {
  6878.                         $positionX 11;
  6879.                         $positionY 1.5;
  6880.                         $widthImg 3.75;
  6881.                         $heightImg 3.33;
  6882.                     }
  6883.                     if ($ordre == 8) {
  6884.                         $positionX 11;
  6885.                         $positionY 5.83;
  6886.                         $widthImg 3.75;
  6887.                         $heightImg 3.33;
  6888.                     }
  6889.                     if ($ordre == 9) {
  6890.                         $positionX 11;
  6891.                         $positionY 10.16;
  6892.                         $widthImg 3.75;
  6893.                         $heightImg 3.33;
  6894.                     }
  6895.                     if ($ordre == 10) {
  6896.                         $positionX 15.75;
  6897.                         $positionY 1.5;
  6898.                         $widthImg 3.75;
  6899.                         $heightImg 3.33;
  6900.                     }
  6901.                     if ($ordre == 11) {
  6902.                         $positionX 15.75;
  6903.                         $positionY 5.83;
  6904.                         $widthImg 3.75;
  6905.                         $heightImg 3.33;
  6906.                     }
  6907.                     if ($ordre == 12) {
  6908.                         $positionX 15.75;
  6909.                         $positionY 10.16;
  6910.                         $widthImg 3.75;
  6911.                         $heightImg 3.33;
  6912.                     }
  6913.                 } elseif ($nbatach == 15) {
  6914.                     if ($ordre == 1) {
  6915.                         $positionX 1.5;
  6916.                         $positionY 1.5;
  6917.                         $widthImg 2.5;
  6918.                         $heightImg 1.92;
  6919.                     }
  6920.                     if ($ordre == 2) {
  6921.                         $positionX 1.5;
  6922.                         $positionY 4.2;
  6923.                         $widthImg 2.5;
  6924.                         $heightImg 1.92;
  6925.                     }
  6926.                     if ($ordre == 3) {
  6927.                         $positionX 1.5;
  6928.                         $positionY 6.54;
  6929.                         $widthImg 2.5;
  6930.                         $heightImg 1.92;
  6931.                     }
  6932.                     if ($ordre == 4) {
  6933.                         $positionX 1.5;
  6934.                         $positionY 9.06;
  6935.                         $widthImg 2.5;
  6936.                         $heightImg =  1.92;
  6937.                     }
  6938.                     if ($ordre == 5) {
  6939.                         $positionX 1.5;
  6940.                         $positionY 11.58;
  6941.                         $widthImg 2.5;
  6942.                         $heightImg =  1.92;
  6943.                     }
  6944.                     if ($ordre == 6) {
  6945.                         $positionX 4.6;
  6946.                         $positionY 1.5;
  6947.                         $widthImg 2.5;
  6948.                         $heightImg 1.92;
  6949.                     }
  6950.                     if ($ordre == 7) {
  6951.                         $positionX 4.6;
  6952.                         $positionY 4.2;
  6953.                         $widthImg 2.5;
  6954.                         $heightImg =  1.92;
  6955.                     }
  6956.                     if ($ordre == 8) {
  6957.                         $positionX 4.6;
  6958.                         $positionY 6.54;
  6959.                         $widthImg 2.5;
  6960.                         $heightImg =  1.92;
  6961.                     }
  6962.                     if ($ordre == 9) {
  6963.                         $positionX 4.6;
  6964.                         $positionY 9.06;
  6965.                         $widthImg 2.5;
  6966.                         $heightImg =  1.92;
  6967.                     }
  6968.                     if ($ordre == 10) {
  6969.                         $positionX 4.6;
  6970.                         $positionY 11.58;
  6971.                         $widthImg 2.5;
  6972.                         $heightImg =  1.92;
  6973.                     }
  6974.                     if ($ordre == 11) {
  6975.                         $positionX 7.7;
  6976.                         $positionY 1.5;
  6977.                         $widthImg 2.5;
  6978.                         $heightImg =  1.92;
  6979.                     }
  6980.                     if ($ordre == 12) {
  6981.                         $positionX 7.7;
  6982.                         $positionY 4.2;
  6983.                         $widthImg 2.5;
  6984.                         $heightImg 1.92;
  6985.                     }
  6986.                     if ($ordre == 13) {
  6987.                         $positionX 7.7;
  6988.                         $positionY 6.54;
  6989.                         $widthImg 2.5;
  6990.                         $heightImg =  1.92;
  6991.                     }
  6992.                     if ($ordre == 14) {
  6993.                         $positionX 7.7;
  6994.                         $positionY 9.06;
  6995.                         $widthImg 2.5;
  6996.                         $heightImg =  1.92;
  6997.                     }
  6998.                     if ($ordre == 15) {
  6999.                         $positionX 7.7;
  7000.                         $positionY 11.58;
  7001.                         $widthImg 2.5;
  7002.                         $heightImg =  1.92;
  7003.                     }
  7004.                 }
  7005.                 if (($i == sizeof($tabphoto) - 1) && ($key != 0)) {
  7006.                     $path 'https://demo.appsfactor.fr/' $path;
  7007.                     $positionX 10.8;
  7008.                     $positionY 1.5;
  7009.                     $widthImg 8.7;
  7010.                     $heightImg 12;
  7011.                     $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  7012.                 } else {
  7013.                     //Recarder l'image :
  7014.                     // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  7015.                     //                $path=str_replace( 'upload/', 'upload/ar_1,c_crop,x_'.round($left*37.7952755906).',y_'.round($top*37.7952755906).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',g_north_east/',$path);
  7016.                     $pathArray explode("/"$path);
  7017.                     $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  7018.                     $idImage "";
  7019.                     foreach ($idsArray as $key2 => $elem) {
  7020.                         if ($key2 != (sizeof($idsArray) - 1)) {
  7021.                             $idImage $idImage $elem;
  7022.                         }
  7023.                     }
  7024.                     //   $cloudinaryWidht=$widthOriginal;
  7025.                     // $cloudinaryHeight=$widthOriginal;
  7026.                     $idImage 'newprod/' $idImage;
  7027.                     //var_dump($idImage);
  7028.                     Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  7029.                     $headers = array('Accept' => 'application/json');
  7030.                     $data = array("public_ids" => array($idImage));
  7031.                     $body Unirest\Request\Body::form($data);
  7032.                     Unirest\Request::verifyPeer(false);
  7033.                     $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  7034.                     // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  7035.                     //  var_dump($url);
  7036.                     $resultMetadata Unirest\Request::post($url$headers$body);
  7037.                     var_dump($resultMetadata);
  7038.                     if (isset(json_decode($resultMetadata->raw_body)->width)) {
  7039.                         $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  7040.                         $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  7041.                     } else {
  7042.                         $cloudinaryWidht $widthOriginal;
  7043.                         $cloudinaryHeight $heightOriginal;
  7044.                     }
  7045.                     $ratiohight $cloudinaryWidht $widthOriginal;
  7046.                     $ratioHight $cloudinaryHeight $heightOriginal;
  7047.                     //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  7048.                     //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  7049.                     var_dump($cloudinaryWidht);
  7050.                     var_dump($cloudinaryHeight);
  7051.                     var_dump($ratioHight);
  7052.                     var_dump($zoom);
  7053.                     $zoom 1;
  7054.                     var_dump($leftOriginal);
  7055.                     var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  7056.                     var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  7057.                     var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  7058.                     var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  7059.                     //var_dump($path);i
  7060.                     $path str_replace('upload/''upload/w_' round($cloudinaryWidht) . ',h_' round($cloudinaryHeight) . ',c_scale/x_' round(abs($leftOriginal $zoom) * $ratioHight) . ',y_' round(abs($topOriginal $zoom) * $ratiohight) . ',w_' round(($widthCropPX $zoom) * $ratioHight) . ',h_' round(($heightCropPX $zoom) * $ratiohight) . ',c_crop/'$path);
  7061.                     //var_dump($path);i
  7062.                     //                $path=str_replace( 'upload/', 'upload/w_'.round($widthOriginal).',h_'.round($heightOriginal).'/x_'.round(abs($leftOriginal)).',y_'.round(abs($topOriginal)).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',c_crop/',$path);
  7063.                     //var_dump($path);
  7064.                     $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  7065.                     //  var_dump("//00");
  7066.                     //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  7067.                     //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  7068.                     //    var_dump("//00");
  7069.                     //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  7070.                     //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  7071.                     var_dump($zoom);
  7072.                     var_dump($path);
  7073.                     // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  7074.                     $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  7075.                     //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  7076.                     //
  7077.                 }
  7078.             }
  7079.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  7080.             for ($i 0$i sizeof($tabtxt); $i++) {
  7081.                 $txt json_decode($tabtxt[$i]);
  7082.                 $fontSize floatval(str_replace('px'''$txt->fontSize)) * 0.75;
  7083.                 //$txt->rotation
  7084.                 $check explode(','$txt->fontFamily);
  7085.                 if (sizeof($check) > 1) {
  7086.                     //default
  7087.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 400)) {
  7088.                         $finalFont "helvetica";
  7089.                         $weight '';
  7090.                     }
  7091.                     //classique
  7092.                     if (($check[0] == "Georgia") && ($txt->fontWeight == 400)) {
  7093.                         $finalFont "times";
  7094.                         $weight '';
  7095.                     }
  7096.                     //creative
  7097.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 700)) {
  7098.                         $finalFont "helveticaB";
  7099.                         $weight '';
  7100.                     }
  7101.                     // manuscrite
  7102.                     if (($check[0] == "Comic Sans") && ($txt->fontWeight == 400)) {
  7103.                         $finalFont "Courier";
  7104.                         $weight '';
  7105.                     }
  7106.                     //c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff2
  7107.                 } else {
  7108.                     //baton
  7109.                     if (($txt->fontFamily == 'Impact') && ($txt->fontWeight == 400)) {
  7110.                         $finalFont "helveticaB";
  7111.                         $weight 'B';
  7112.                     }
  7113.                 }
  7114.                 $pdf->SetFont($finalFont$weight$fontSize);
  7115.                 $leftTxt $txt->left;
  7116.                 $topTxt $txt->top;
  7117.                 $heightClips $txt->height;
  7118.                 $widthClips $txt->width;
  7119.                 $heightTxt floatval(str_replace('cm'''$heightClips));
  7120.                 $topTxt floatval(str_replace('cm'''$topTxt));
  7121.                 $leftTxt floatval(str_replace('cm'''$leftTxt));
  7122.                 $widthTxt floatval(str_replace('cm'''$widthClips));
  7123.                 if ($key == 0) {
  7124.                     $heightTxt 2;
  7125.                     $widthTxt 7;
  7126.                     $leftTxt = (21) - ($widthTxt 2);
  7127.                     $topTxt 11.8;
  7128.                     $pdf->SetXY(0$topTxttrue);
  7129.                     $pdf->Cell(210trim($txt->contenu), 00'C'0''0);
  7130.                 } else {
  7131.                     $heightTxt 2;
  7132.                     $widthTxt 7;
  7133.                     $leftTxt = (21) - ($widthTxt 2);
  7134.                     $topTxt 11.8;
  7135.                     $pdf->SetXY(13.612.4true);
  7136.                     $pdf->Cell(60trim($txt->contenu), 00'L'0''0);
  7137.                 }
  7138.                 //                    var_dump($leftTxt);
  7139.                 //                  var_dump($topTxt);
  7140.                 // var_dump(floatval(str_replace('rad','',$txt->rotation))*57,2958);
  7141.                 //                var_dump("text");
  7142.                 //$pdf->StartTransform();
  7143.                 //$txt->rotation=0;
  7144.                 //var_dump($txt->rotation);
  7145.                 //var_dump(str_replace('rad','',$txt->rotation));
  7146.                 //var_dump(floatval(str_replace('rad','',$txt->rotation))*57.2958);
  7147.                 // $pdf->Rotate((floatval(str_replace('rad','',$txt->rotation))*57.2958)*-1,$leftTxt+($widthTxt/2),$topTxt+($heightTxt/2));
  7148.                 // $pdf->Rotate(45);
  7149.                 //   $pdf->Text($leftTxt, $topTxt, $txt->contenu);
  7150.                 //$pdf->SetTextColor(200);
  7151.                 //$pdf->Text($leftTxt, $topTxt, $txt->contenu);
  7152.                 // $pdf->MultiCell($leftTxt, $topTxt,  $txt->contenu, 0, $ln=0, 'C', 0, '', 0, false, 'C', 'C');
  7153.                 //                $pdf->Write(str_replace('cm','',$txt->height),trim($txt->contenu));
  7154.                 // $pdf->writeHTML("<p>".$txt->contenu."</p>", true, false, false, false, '');
  7155.                 //$pdf->StopTransform();
  7156.             }
  7157.             //Positionner text
  7158.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  7159.             //Positionner clipart
  7160.             //            dd($tabClips);
  7161.             for ($i 0$i sizeof($tabClips); $i++) {
  7162.                 $Clips json_decode($tabClips[$i]);
  7163.                 $heightClips $Clips->height;
  7164.                 $topClips $Clips->top;
  7165.                 $leftClips $Clips->left;
  7166.                 $widthClips $Clips->width;
  7167.                 $path $Clips->path;
  7168.                 $pathClips str_replace('"'''$path);
  7169.                 $heightClips floatval(str_replace('cm'''$heightClips));
  7170.                 $topClips floatval(str_replace('cm'''$topClips));
  7171.                 $leftClips floatval(str_replace('cm'''$leftClips));
  7172.                 $widthClips floatval(str_replace('cm'''$widthClips));
  7173.                 $heightClipsPX round($heightClips 37.7952755906);
  7174.                 $widthClipsPX round($widthClips 37.7952755906);
  7175.                 ////                $positionXclips = $positionX + $leftClips;
  7176.                 ////                $positionYclips = $positionY + $topClips;
  7177.                 //
  7178.                 //$pdf->ImageSVG("images/ClipArt_SVG/Ete4.svg",$leftClips,$topClips,$widthClips, $heightClips);
  7179.                 //https://res.cloudinary.com/apss-factory/image/private/s--EdExAzx8--/v1588758453/GlobeFooter_c4duua.svg
  7180.                 // https://res.cloudinary.com/apss-factory/image/upload/v1588764528/Groupe_113_pcjyj4.png
  7181.                 var_dump($pathClips);
  7182.                 $pdf->StartTransform();
  7183.                 $pdf->Rotate((floatval(str_replace('rad'''$Clips->rotation)) * 57.2958) * -1$leftClips + ($widthClips 2), $topClips + ($heightClips 2));
  7184.                 $pdf->Image($this->newPAthCLipart($pathClips$heightClipsPX$widthClipsPX), $leftClips,  $topClips$widthClips$heightClips''''''false300);
  7185.                 $pdf->StopTransform();
  7186.             }
  7187.         }
  7188.         // echo '</pre>';
  7189.         //return new response("yezi");
  7190.         $projectRoot $this->getParameter('kernel.project_dir');
  7191.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  7192.         return new response("yezi");
  7193.         //return $pdf->Output('example_009.pdf', 'I');
  7194.     }
  7195.     function newPAthCLipart($url$heigh$width)
  7196.     {
  7197.         $allImage = [
  7198.             'Eclaire.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143379/newprod/clipart/Eclaire_pr0ecu.png',
  7199.             'ARcenciel.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143391/newprod/clipart/ARcenciel_grkyap.png',
  7200.             'Drapeaux.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Drapeaux_zqo8v3.png',
  7201.             'Annif.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143391/newprod/clipart/Annif_ihvyoo.png',
  7202.             'Basquettes.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Basquettes_znjd41.png',
  7203.             'Foot.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143382/newprod/clipart/Foot_az6bct.png',
  7204.             'Hello.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143383/newprod/clipart/Hello_njqifl.png',
  7205.             'Love.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143386/newprod/clipart/Love_q39usk.png',
  7206.             'LICORNE.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143385/newprod/clipart/LICORNE_hpomru.png',
  7207.             'Noeud.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143388/newprod/clipart/Noeud_mw5a4j.png',
  7208.             'Etoilerose.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143380/newprod/clipart/Etoilerose_ewrzff.png',
  7209.             'Ete4.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143379/newprod/clipart/Ete4_pdxadk.png',
  7210.             'Ete6.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143380/newprod/clipart/Ete6_a3xgpd.png',
  7211.             'Ete9.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143380/newprod/clipart/Ete9_s4vllm.png',
  7212.             'Hiver1.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143384/newprod/clipart/Hiver1_fekrjz.png',
  7213.             'Hiver2.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143384/newprod/clipart/Hiver2_e9iygg.png',
  7214.             'Noel2.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143387/newprod/clipart/Noel2_eqvdzr.png',
  7215.             'Hiver.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143383/newprod/clipart/Hiver_et04e1.png',
  7216.             'Sapin.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143390/newprod/clipart/Sapin_qjkxz6.png',
  7217.             'Chaussetet.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Chaussetet_xfpt6t.png',
  7218.             'Cloches.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Cloches_x2v3eo.png',
  7219.             'Like.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143387/newprod/clipart/Like_ynxb2u.png',
  7220.             'coeurlike.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143379/newprod/clipart/coeurlike_ferv9y.png',
  7221.             'Fetedesmeres.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/w_' $width '/upload/v1589143383/newprod/clipart/Fetedesmeres_ud9vac.png',
  7222.             'Fetedesperes.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/w_' $width '/upload/v1589143384/newprod/clipart/Fetedesperes_mltjmo.png',
  7223.             'OOPS.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143389/newprod/clipart/OOPS_gj9p1c.png',
  7224.             'OOPS_1.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143389/newprod/clipart/OOPS_1_r9a7l6.png',
  7225.             'WoW.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143393/newprod/clipart/WoW_ljlqjm.png',
  7226.             'Nuage.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143387/newprod/clipart/Nuage_fgomd0.png',
  7227.             'Pingouin.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143389/newprod/clipart/Pingouin_ogxb6e.png',
  7228.             'Renard.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143378/newprod/clipart/Chouette_mc1ik2.png',
  7229.             'Chouette.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143390/newprod/clipart/Renard_mlhrxt.png'
  7230.         ];
  7231.         //http://127.0.0.1:8000/images/ClipArt_SVG/LICORNE.svg
  7232.         $arryUrls explode('/'$url);
  7233.         return ($allImage[$arryUrls[sizeof($arryUrls) - 1]]);
  7234.     }
  7235.     /**
  7236.      * @Route("/Parent/TcPdfCalcul/{idPrdt}", name="TcPdfCalc")
  7237.      */
  7238.     public function TcPdfCalcule($idPrdt)
  7239.     {
  7240.         echo '<pre>';
  7241.         ini_set("max_execution_time", -1);
  7242.         $pageLayout = array(2115);
  7243.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  7244.         // set document information
  7245.         $pdf->SetCreator(PDF_CREATOR);
  7246.         $pdf->SetAuthor('Nicola Asuni');
  7247.         $pdf->SetTitle('TCPDF Example 009');
  7248.         $pdf->SetSubject('TCPDF Tutorial');
  7249.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  7250.         $pdf->SetSubject('TCPDF Tutorial');
  7251.         $pdf->setPrintHeader(false);
  7252.         $pdf->setPrintFooter(false);
  7253.         // set image scale factor
  7254.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  7255.         //        $pdf->AddPage();
  7256.         $pdf->setJPEGQuality(100);
  7257.         $horizontal_alignments = array('L''C''R');
  7258.         $vertical_alignments = array('T''M''B');
  7259.         //var_dump($pdf->getPageWidth());
  7260.         //var_dump($pdf->getPageHeight());die();
  7261.         $em $this->em;
  7262.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  7263.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  7264.         //dd($AllPages);
  7265.         //        $fP=[];
  7266.         //        array_push($fP,$AllPages[0]);
  7267.         //dd($AllPages);
  7268.         foreach ($AllPages as $p) {
  7269.             $pdf->AddPage();
  7270.             $pdf->setJPEGQuality(100);
  7271.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  7272.             $nbatach $contenu->nbrAttc;
  7273.             $nbatach intval(str_replace('"'''$nbatach));
  7274.             $color =  $contenu->color;
  7275.             // $color="rgb(255,255,255)";
  7276.             $color str_replace('"rgb('''$color);
  7277.             $color str_replace(')"'''$color);
  7278.             $color explode(","$color);
  7279.             $colorp = array(intval($color[0]), intval($color[1]), intval($color[2]));
  7280.             $tabtxt json_decode($contenu->txt);
  7281.             $tabphoto json_decode($contenu->attache);
  7282.             //
  7283.             //dd($tabtxt);
  7284.             //         dd($tabtxt);
  7285.             //dd($tabphoto);
  7286.             $tabClips json_decode($contenu->clips);
  7287.             // dd($tabClips);
  7288.             $x 0.6;
  7289.             $y 0.8;
  7290.             $w 19.8;
  7291.             $h 13.4;
  7292.             // get the current page break margin
  7293.             $bMargin $pdf->getBreakMargin();
  7294.             // get current auto-page-break mode
  7295.             $auto_page_break $pdf->getAutoPageBreak();
  7296.             // disable auto-page-break
  7297.             $pdf->SetAutoPageBreak(false0);
  7298.             // test all combinations of alignments
  7299.             $fitbox $horizontal_alignments[1] . ' ';
  7300.             $fitbox[1] = $vertical_alignments[1];
  7301.             $pdf->Rect(002115'F', array(), $colorp);
  7302.             //    sizeof($tabphoto)
  7303.             for ($i 0$i sizeof($tabphoto); $i++) {
  7304.                 $photo json_decode($tabphoto[$i]);
  7305.                 //les coordonnĂ©es de l'image rĂ©el:
  7306.                 $hght $photo->height;
  7307.                 $top $photo->top;
  7308.                 $left $photo->left;
  7309.                 $width $photo->width;
  7310.                 $ordre $photo->ordre;
  7311.                 $zoom $photo->zoom;
  7312.                 $path $photo->path;
  7313.                 $hght floatval(str_replace('cm'''$hght));
  7314.                 $top floatval(str_replace('cm'''$top));
  7315.                 $left floatval(str_replace('cm'''$left));
  7316.                 $width floatval(str_replace('cm'''$width));
  7317.                 //les coordonnĂ©es dropzone:
  7318.                 $heightOriginal $photo->height;
  7319.                 $widthOriginal $photo->width;
  7320.                 $top $photo->top;
  7321.                 $left $photo->left;
  7322.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  7323.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  7324.                 $top floatval(str_replace('cm'''$top));
  7325.                 $left floatval(str_replace('cm'''$left));
  7326.                 $heightOriginal $heightOriginal 37.7952755906;
  7327.                 $widthOriginal $widthOriginal 37.7952755906;
  7328.                 $topOriginal $top 37.7952755906;
  7329.                 $leftOriginal $left 37.7952755906;
  7330.                 $heightCrop $photo->heightCrop;
  7331.                 $topCrop $photo->topCrop;
  7332.                 $leftCrop $photo->leftCrop;
  7333.                 $widthCrop $photo->widthCrop;
  7334.                 $path $photo->path;
  7335.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  7336.                 $topCrop floatval(str_replace('cm'''$topCrop));
  7337.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  7338.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  7339.                 $widthCropPX $widthCrop 37.7952755906;
  7340.                 $heightCropPX $heightCrop 37.7952755906;
  7341.                 $topCropPX $topCrop 37.7952755906;
  7342.                 $leftCropPX $leftCrop 37.7952755906;
  7343.                 var_dump("original widh: " $widthCrop " " "original height : " $heightCrop);
  7344.                 var_dump("original left: " $topCrop " " "original top : " $leftCrop);
  7345.                 var_dump("//00");
  7346.                 var_dump("multip 37 widh: " $widthCropPX " " "multip 37 height : " $heightCropPX);
  7347.                 var_dump("multip 37 top: " $topOriginal " " "multip 37 left : " $leftOriginal);
  7348.                 //Calculer position des images selon nombres images par page:
  7349.                 $positionX 0;
  7350.                 $positionY 0;
  7351.                 $widthImg 0;
  7352.                 $heightImg 0;
  7353.                 if ($nbatach == 1) {
  7354.                     $positionX 1.5;
  7355.                     $positionY 1.5;
  7356.                     $widthImg 18;
  7357.                     $heightImg 12;
  7358.                 } elseif ($nbatach == 2) {
  7359.                     if ($ordre == 1) {
  7360.                         $positionX 1.5;
  7361.                         $positionY 1.5;
  7362.                         $widthImg 8.5;
  7363.                         $heightImg 12;
  7364.                     }
  7365.                     if ($ordre == 2) {
  7366.                         $positionX 11;
  7367.                         $positionY 1.5;
  7368.                         $widthImg 8.5;
  7369.                         $heightImg 12;
  7370.                     }
  7371.                 } elseif ($nbatach == 3) {
  7372.                     if ($ordre == 1) {
  7373.                         $positionX 1.5;
  7374.                         $positionY 1.5;
  7375.                         $widthImg 8.5;
  7376.                         $heightImg 12;
  7377.                     }
  7378.                     if ($ordre == 2) {
  7379.                         $positionX 11;
  7380.                         $positionY 1.5;
  7381.                         $widthImg 8.5;
  7382.                         $heightImg 5.5;
  7383.                     }
  7384.                     if ($ordre == 3) {
  7385.                         $positionX 11;
  7386.                         $positionY 8;
  7387.                         $widthImg 8.5;
  7388.                         $heightImg 5.5;
  7389.                     }
  7390.                 } elseif ($nbatach == 4) {
  7391.                     if ($ordre == 1) {
  7392.                         $positionX 1.5;
  7393.                         $positionY 1.5;
  7394.                         $widthImg 8.5;
  7395.                         $heightImg 5.5;
  7396.                     }
  7397.                     if ($ordre == 2) {
  7398.                         $positionX 1.5;
  7399.                         $positionY 8;
  7400.                         $widthImg 8.5;
  7401.                         $heightImg 5.5;
  7402.                     }
  7403.                     if ($ordre == 3) {
  7404.                         $positionX 11;
  7405.                         $positionY 1.5;
  7406.                         $widthImg 8.5;
  7407.                         $heightImg 5.5;
  7408.                     }
  7409.                     if ($ordre == 4) {
  7410.                         $positionX 11;
  7411.                         $positionY 8;
  7412.                         $widthImg 8.5;
  7413.                         $heightImg 5.5;
  7414.                     }
  7415.                 } elseif ($nbatach == 5) {
  7416.                     if ($ordre == 1) {
  7417.                         $positionX 1.5;
  7418.                         $positionY 1.5;
  7419.                         $widthImg 18;
  7420.                         $heightImg 8;
  7421.                     }
  7422.                     if ($ordre == 2) {
  7423.                         $positionX 1.5;
  7424.                         $positionY 10.5;
  7425.                         $widthImg 3.75;
  7426.                         $heightImg 4;
  7427.                     }
  7428.                     if ($ordre == 3) {
  7429.                         $positionX 6.25;
  7430.                         $positionY 10.5;
  7431.                         $widthImg 3.75;
  7432.                         $heightImg 4;
  7433.                     }
  7434.                     if ($ordre == 4) {
  7435.                         $positionX 11;
  7436.                         $positionY 10.5;
  7437.                         $widthImg 3.75;
  7438.                         $heightImg 4;
  7439.                     }
  7440.                     if ($ordre == 5) {
  7441.                         $positionX 15.75;
  7442.                         $positionY 10.5;
  7443.                         $widthImg 3.75;
  7444.                         $heightImg 4;
  7445.                     }
  7446.                 } elseif ($nbatach == 6) {
  7447.                     if ($ordre == 1) {
  7448.                         $positionX 1.5;
  7449.                         $positionY 1.5;
  7450.                         $widthImg 5.33;
  7451.                         $heightImg 3.33;
  7452.                     }
  7453.                     if ($ordre == 2) {
  7454.                         $positionX 1.5;
  7455.                         $positionY 5.83;
  7456.                         $widthImg == 5.33;
  7457.                         $heightImg 3.33;
  7458.                     }
  7459.                     if ($ordre == 3) {
  7460.                         $positionX 1.5;
  7461.                         $positionY 10.16;
  7462.                         $widthImg 5.33;
  7463.                         $heightImg 3.33;
  7464.                     }
  7465.                     if ($ordre == 4) {
  7466.                         $positionX 7.83;
  7467.                         $positionY 1.5;
  7468.                         $widthImg == 5.33;
  7469.                         $heightImg 3.33;
  7470.                     }
  7471.                     if ($ordre == 5) {
  7472.                         $positionX 7.83;
  7473.                         $positionY 5.83;
  7474.                         $widthImg == 5.33;
  7475.                         $heightImg 3.33;
  7476.                     }
  7477.                     if ($ordre == 6) {
  7478.                         $positionX 7.83;
  7479.                         $positionY 10.16;
  7480.                         $widthImg == 5.33;
  7481.                         $heightImg 3.33;
  7482.                     }
  7483.                 } elseif ($nbatach == 12) {
  7484.                     if ($ordre == 1) {
  7485.                         $positionX 1.5;
  7486.                         $positionY 1.5;
  7487.                         $widthImg 3.75;
  7488.                         $heightImg 3.33;
  7489.                     }
  7490.                     if ($ordre == 2) {
  7491.                         $positionX 1.5;
  7492.                         $positionY 5.83;
  7493.                         $widthImg 3.75;
  7494.                         $heightImg 3.33;
  7495.                     }
  7496.                     if ($ordre == 3) {
  7497.                         $positionX 1.5;
  7498.                         $positionY 10.16;
  7499.                         $widthImg 3.75;
  7500.                         $heightImg 3.33;
  7501.                     }
  7502.                     if ($ordre == 4) {
  7503.                         $positionX 6.25;
  7504.                         $positionY 1.5;
  7505.                         $widthImg 3.75;
  7506.                         $heightImg 3.33;
  7507.                     }
  7508.                     if ($ordre == 5) {
  7509.                         $positionX 6.25;
  7510.                         $positionY 5.83;
  7511.                         $widthImg 3.75;
  7512.                         $heightImg 3.33;
  7513.                     }
  7514.                     if ($ordre == 6) {
  7515.                         $positionX 6.25;
  7516.                         $positionY 10.16;
  7517.                         $widthImg 3.75;
  7518.                         $heightImg 3.33;
  7519.                     }
  7520.                     if ($ordre == 7) {
  7521.                         $positionX 11;
  7522.                         $positionY 1.5;
  7523.                         $widthImg 3.75;
  7524.                         $heightImg 3.33;
  7525.                     }
  7526.                     if ($ordre == 8) {
  7527.                         $positionX 11;
  7528.                         $positionY 5.83;
  7529.                         $widthImg 3.75;
  7530.                         $heightImg 3.33;
  7531.                     }
  7532.                     if ($ordre == 9) {
  7533.                         $positionX 11;
  7534.                         $positionY 10.16;
  7535.                         $widthImg 3.75;
  7536.                         $heightImg 3.33;
  7537.                     }
  7538.                     if ($ordre == 10) {
  7539.                         $positionX 15.75;
  7540.                         $positionY 1.5;
  7541.                         $widthImg 3.75;
  7542.                         $heightImg 3.33;
  7543.                     }
  7544.                     if ($ordre == 11) {
  7545.                         $positionX 15.75;
  7546.                         $positionY 5.83;
  7547.                         $widthImg 3.75;
  7548.                         $heightImg 3.33;
  7549.                     }
  7550.                     if ($ordre == 12) {
  7551.                         $positionX 15.75;
  7552.                         $positionY 10.16;
  7553.                         $widthImg 3.75;
  7554.                         $heightImg 3.33;
  7555.                     }
  7556.                 }
  7557.                 //Recarder l'image :
  7558.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  7559.                 //                $path=str_replace( 'upload/', 'upload/ar_1,c_crop,x_'.round($left*37.7952755906).',y_'.round($top*37.7952755906).',w_'.round($widthCropPX).',h_'.round($heightCropPX).',g_north_east/',$path);
  7560.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  7561.                 //var_dump($api);
  7562.                 $pathArray explode("/"$path);
  7563.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  7564.                 $idImage "";
  7565.                 foreach ($idsArray as $key2 => $elem) {
  7566.                     if ($key2 != (sizeof($idsArray) - 1)) {
  7567.                         $idImage $idImage $elem;
  7568.                     }
  7569.                 }
  7570.                 $idImage 'newprod/' $idImage;
  7571.                 var_dump($idImage);
  7572.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  7573.                 $headers = array('Accept' => 'application/json');
  7574.                 $data = array("public_ids" => array($idImage));
  7575.                 $body Unirest\Request\Body::form($data);
  7576.                 Unirest\Request::verifyPeer(false);
  7577.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  7578.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  7579.                 var_dump($url);
  7580.                 $resultMetadata Unirest\Request::post($url$headers$body);
  7581.                 var_dump($resultMetadata->raw_body);
  7582.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  7583.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  7584.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  7585.                 } else {
  7586.                     $cloudinaryWidht $widthOriginal;
  7587.                     $cloudinaryHeight $heightOriginal;
  7588.                 }
  7589.                 $ratiohight $cloudinaryWidht $widthOriginal;
  7590.                 $ratioHight $cloudinaryHeight $heightOriginal;
  7591.                 $path str_replace('upload/''upload/w_' round($cloudinaryWidht) . ',h_' round($cloudinaryHeight) . '/x_' round(abs($leftOriginal $ratioHight) / $zoom) . ',y_' round(abs($topOriginal $ratiohight) / $zoom) . ',w_' round(($widthCropPX $ratioHight) / $zoom) . ',h_' round(($heightCropPX $ratiohight) / $zoom) . ',c_crop/'$path);
  7592.                 //var_dump($path);i
  7593.                 var_dump("//00");
  7594.                 var_dump("avant 1.4 widh: " round($widthCropPX) . " " "avant 1.4 height : " round($heightCropPX));
  7595.                 var_dump("avant 1.4 top: " round(abs($top 37.7952755906)) . " avant 1.4 final left : " round(abs($left 37.7952755906)));
  7596.                 var_dump("//00");
  7597.                 var_dump("final widh: " round($widthCropPX 1.4) . " " "final height : " round($heightCropPX 1.4));
  7598.                 var_dump("final top: " round(abs($top 37.7952755906 1.4)) . " " "final left : " round(abs($left 37.7952755906 1.4)));
  7599.                 var_dump("//00");
  7600.                 var_dump($path);
  7601.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  7602.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false300''falsefalse0$fitboxfalsefalse);
  7603.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  7604.                 //
  7605.                 $pdf->SetY(-6);
  7606.                 // Set font
  7607.                 $pdf->SetFont('helvetica''I'8);
  7608.                 // Page number
  7609.                 $pdf->Cell(010'Page ' $pdf->getAliasNumPage() . '/' $pdf->getAliasNbPages(), 0false'C'0''0false'T''M');
  7610.                 $pdf->SetFont('helvetica''B'8);
  7611.                 $pdf->SetXY(11);
  7612.             }
  7613.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  7614.             for ($i 0$i sizeof($tabtxt); $i++) {
  7615.                 $txt json_decode($tabtxt[$i]);
  7616.                 $pdf->SetFont('helvetica''B'$txt->fontSize);
  7617.                 $leftTxt $txt->left;
  7618.                 $topTxt $txt->top;
  7619.                 //                $heightClips = floatval(str_replace('cm', '', $heightClips));
  7620.                 $topTxt floatval(str_replace('cm'''$topTxt));
  7621.                 $leftTxt floatval(str_replace('cm'''$leftTxt));
  7622.                 //                $widthClips = floatval(str_replace('cm', '', $widthClips));
  7623.                 $pdf->SetXY($leftTxt 1.2$topTxt 1);
  7624.                 $pdf->Write(0$txt->contenu''0'L'true0falsefalse0);
  7625.             }
  7626.             //Positionner text
  7627.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  7628.             //Positionner clipart
  7629.             //            dd($tabClips);
  7630.             //            for($i=0;$i <sizeof($tabClips);$i++) {
  7631.             //                $Clips = json_decode($tabClips[$i]);
  7632.             //                $heightClips = $Clips->height;
  7633.             //                $topClips = $Clips->top;
  7634.             //                $leftClips = $Clips->left;
  7635.             //                $widthClips = $Clips->width;
  7636.             //                $path = $Clips->path;
  7637.             //                $pathClips = str_replace('http://127.0.0.1:8000/', 'https://demo.appsfactor.fr/', $path);
  7638.             //
  7639.             //                $heightClips = floatval(str_replace('cm', '', $heightClips));
  7640.             //                $topClips = floatval(str_replace('cm', '', $topClips));
  7641.             //                $leftClips = floatval(str_replace('cm', '', $leftClips));
  7642.             //                $widthClips = floatval(str_replace('cm', '', $widthClips));
  7643.             //
  7644.             ////                $positionXclips = $positionX + $leftClips;
  7645.             ////                $positionYclips = $positionY + $topClips;
  7646.             //
  7647.             //              $pdf->ImageSVG("images/ClipArt_SVG/Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  7648.             //
  7649.             ////                $pdf->Image($path,$leftClips,  $topClips, $widthClips, $heightClips, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  7650.             //
  7651.             //            }
  7652.         }
  7653.         echo '</pre>';
  7654.         return new response("yezi");
  7655.         //  return $pdf->Output('example_009.pdf', 'I');
  7656.     }
  7657.     /**
  7658.      * @Route("/Parent/suprimerproduitAcompa", name="suprimerproduitAcompa_parent")
  7659.      */
  7660.     public function suprimerproduitAcompa(Request $request)
  7661.     {
  7662.         $em $this->em;
  7663.         $user $this->getUser();
  7664.         $p $request->get("p");
  7665.         $Album $em->getRepository(Produit::class)->find($p);
  7666.         $Album->setDelated(1);
  7667.         $em->getManager()->persist($Album);
  7668.         $em->getManager()->flush();
  7669.         return new Response('yoopi');
  7670.     }
  7671.     /**
  7672.      * @Route("/Parent/saveDiaporamaParent", name="saveDiaporamaParent")
  7673.      */
  7674.     public function saveDiaporamaParent()
  7675.     {
  7676.         $session $this->session;
  7677.         $idSejour $session->get("Sejour");
  7678.         /** @var \App\Entity\User $userId */
  7679.         $userId $this->getUser();
  7680.         $sejourobj $this->em->getRepository(Sejour::class)->find($idSejour);
  7681.         $prodct $this->em->getRepository(Typeproduit::class)->find(19);
  7682.         $produit $this->em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $userId->getId()]);
  7683.         if ($produit !== null && $produit !== "") {
  7684.             $produit->setLabele("Diaporama");
  7685.             $produit->setIduser($userId);
  7686.             $produit->setIdsjour($sejourobj);
  7687.             $produit->setType($prodct);
  7688.         } else {
  7689.             $produit = new Produit;
  7690.             $produit->setLabele("Diaporama");
  7691.             $produit->setIduser($userId);
  7692.             $produit->setIdsjour($sejourobj);
  7693.             $produit->setType($prodct);
  7694.             $produit->setDate(new \DateTime());
  7695.         }
  7696.         $this->em->getManager()->persist($produit);
  7697.         $this->em->getManager()->flush();
  7698.         return new Response('disporama saved');
  7699.     }
  7700.     /**
  7701.      * @Route("/Parent/appActiveAcompt/{id}", name="appActiveAcompt")
  7702.      */
  7703.     public function ActiveAcounnt($id)
  7704.     {
  7705.         $user $this->em->getRepository(User::class)->find($id);
  7706.         $user->setActivatemail(1);
  7707.         $this->em->getManager()->persist($user);
  7708.         $this->em->getManager()->flush();
  7709.         // AUTO-LOGIN DIRECT (mĂŞme implĂ©mentation que les accompagnateurs)
  7710.         $providerKey 'main_Parent'// your firewall name
  7711.         $token = new UsernamePasswordToken($usernull$providerKey$user->getRoles());
  7712.         $this->container->get('security.token_storage')->setToken($token);
  7713.         return $this->redirectToRoute('CodeSejour');
  7714.     }
  7715.     /**
  7716.      * @Route("/Parent/Album_du_Sejour", name="Album_du_Sejour")
  7717.      */
  7718.     function ActiverSessionAlbum()
  7719.     {
  7720.         $SEjourService $this->sejourService;
  7721.         /** @var \App\Entity\User $user */
  7722.         $user $this->getUser();
  7723.         $userId $user->getId();
  7724.         $session $this->session;
  7725.         $session->set('pageMenu''');
  7726.         $idSejour $session->get("Sejour");
  7727.         $sejour $SEjourService->getsejourpourparent($idSejour);
  7728.         $em $this->em;
  7729.         $AllPages null;
  7730.         $random false;
  7731.         $idAcc $sejour->getIdAcommp();
  7732.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'Album_sejour']);
  7733.         if ($Albumproduct == null) {
  7734.             $Albumproduct $this->em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  7735.         }
  7736.         if ($Albumproduct != null and $Albumproduct != "") {
  7737.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  7738.         }
  7739.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  7740.         $nbLikes count($listeattachlikephoto);
  7741.         $part $sejour->getIdPartenaire();
  7742.         $nompart $part->getUsername();
  7743.         $logopart $part->getLogourl();
  7744.         $session->set('produit'$Albumproduct->gettype());
  7745.         return $this->render('Parent/AlbumSejour.html.twig', ["nompart" => $nompart"logopart" => $logopart"sejour" => $sejour,  'cliparts' => null'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => null'AllPagesAcc' => null'random' => $random'nbLikes' => $nbLikes]);
  7746.     }
  7747.     /**
  7748.      * @Route("/Parent/Editer_Album_du_Sejour", name="Editer_Album_du_Sejour")
  7749.      */
  7750.     function EditerSessionAlbum()
  7751.     {
  7752.         $SEjourService $this->sejourService;
  7753.         /** @var \App\Entity\User $user */
  7754.         $user $this->getUser();
  7755.         $userId $user->getId();
  7756.         $session $this->session;
  7757.         $session->set('pageMenu''');
  7758.         $idSejour $session->get("Sejour");
  7759.         $sejour $SEjourService->getsejourpourparent($idSejour);
  7760.         $em $this->em;
  7761.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  7762.         $nbLikes count($listeattachlikephoto);
  7763.         $AllPages null;
  7764.         $random false;
  7765.         $idAcc $sejour->getIdAcommp();
  7766.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'Album_sejour']);
  7767.         if ($Albumproduct == null) {
  7768.             $Albumproduct $this->em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  7769.         }
  7770.         if ($Albumproduct != null and $Albumproduct != "") {
  7771.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  7772.         }
  7773.         $allpagesResult = array();
  7774.         $tabacc = array();
  7775.         $tabacc1 = array();
  7776.         foreach ($AllPages as $page) {
  7777.             $pageJ json_decode($page->getCouleurbordure());
  7778.             $pageDec json_decode($pageJ[0]);
  7779.             $attache json_decode($pageDec->attache);
  7780.             if (isset($attache[0])) {
  7781.                 $attachDec json_decode($attache[0]);
  7782.             }
  7783.             //var_dump($attachDec);
  7784.             //var_dump(json_decode($attachDec->id));
  7785.             if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  7786.                 $idAttach json_decode($attachDec->id);
  7787.                 array_push($tabacc$idAttach);
  7788.             }
  7789.         }
  7790.         $tabacc1 array_count_values($tabacc);
  7791.         $part $sejour->getIdPartenaire();
  7792.         $nompart $part->getUsername();
  7793.         $logopart $part->getLogourl();
  7794.         $session->set('produit'$Albumproduct->gettype());
  7795.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  7796.         $nbPhoto count($listeattach);
  7797.         return $this->render('Parent/NewAlbumLikes.html.twig', ["listeattach" => $listeattach"tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => null'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => null'AllPagesAcc' => null'random' => $random'nbLikes' => $nbLikes'nbPhoto' => $nbPhoto]);
  7798.     }
  7799.     /**
  7800.      * @Route("/Parent/Editer_Livre_du_Sejour", name="Editer_Livre_du_Sejour")
  7801.      */
  7802.     function EditerSessionLivre()
  7803.     {
  7804.         $SEjourService $this->sejourService;
  7805.         /** @var \App\Entity\User $user */
  7806.         $user $this->getUser();
  7807.         $userId $user->getId();
  7808.         $session $this->session;
  7809.         $session->set('pageMenu''');
  7810.         $idSejour $session->get("Sejour");
  7811.         $sejour $SEjourService->getsejourpourparent($idSejour);
  7812.         $em $this->em;
  7813.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  7814.         $nbLikes count($listeattachlikephoto);
  7815.         $AllPages null;
  7816.         $random false;
  7817.         $idAcc $sejour->getIdAcommp();
  7818.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  7819.         if ($Albumproduct == null) {
  7820.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['version' => 'Livre_Sejour_Admin''idsjour' =>   $idSejour]);
  7821.         }
  7822.         if ($Albumproduct == null) {
  7823.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomLivre']);
  7824.         }
  7825.         if ($Albumproduct != null and $Albumproduct != "") {
  7826.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  7827.         }
  7828.         $allpagesResult = array();
  7829.         $tabacc = array();
  7830.         $tabacc1 = array();
  7831.         foreach ($AllPages as $page) {
  7832.             $pageJ json_decode($page->getCouleurbordure());
  7833.             $pageDec json_decode($pageJ[0]);
  7834.             $attache json_decode($pageDec->attache);
  7835.             if (isset($attache[0])) {
  7836.                 $attachDec json_decode($attache[0]);
  7837.             }
  7838.             //var_dump($attachDec);
  7839.             //var_dump(json_decode($attachDec->id));
  7840.             if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  7841.                 $idAttach json_decode($attachDec->id);
  7842.                 array_push($tabacc$idAttach);
  7843.             }
  7844.         }
  7845.         $tabacc1 array_count_values($tabacc);
  7846.         $part $sejour->getIdPartenaire();
  7847.         $nompart $part->getUsername();
  7848.         $logopart $part->getLogourl();
  7849.         $session->set('produit'$Albumproduct->gettype());
  7850.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  7851.         $nbPhoto count($listeattach);
  7852.         return $this->render('Parent/NewLivreLikes.html.twig', ["listeattach" => $listeattach"tabacc" => $tabacc1"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => null'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => null'AllPagesAcc' => null'random' => $random'nbLikes' => $nbLikes'nbPhoto' => $nbPhoto]);
  7853.     }
  7854.     /**
  7855.      * @Route("/Parent/DesactiverSessionAlbum", name="DesactiverSessionAlbum")
  7856.      */
  7857.     function DesactiverSessionAlbum()
  7858.     {
  7859.         $session $this->session;
  7860.         $session->remove('sessionalbm');
  7861.         return new Response('session removed');
  7862.     }
  7863.     /**
  7864.      * @Route("/Parent/Mon_Compte_Activer", name="Mon_Compte_Activer")
  7865.      */
  7866.     public function Mon_Compte_Activer(Request $request)
  7867.     {
  7868.         $em $this->em;
  7869.         return $this->render('Parent/activeMoncompte.html.twig');
  7870.     }
  7871.     /**
  7872.      * @Route("/Parent/swuitchSejour/{id}", name="swuitchSejour")
  7873.      */
  7874.     public function swuitchSejour($id)
  7875.     {
  7876.         $em $this->em;
  7877.         $sejourobj $this->em->getRepository(Sejour::class)->find($id);
  7878.         $this->session->set('Sejour'$sejourobj->getId());
  7879.         return $this->redirectToRoute('AccueilParent');
  7880.     }
  7881.     /**
  7882.      * @Route("/migrationCloudinary", name="migrationCloudinary")
  7883.      */
  7884.     public function cloudinaryMigration()
  7885.     {
  7886.         $em $this->em;
  7887.         //        $path="https://res.cloudinary.com/apss-factory/image/upload/a_exif/v1588979564/newprod/JUEGOS-EN-LA-PLAYA5_dnvgj8.jpg";
  7888.         $attachement = [
  7889.             'Eclaire.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/Eclaire_pr0ecu.svg',
  7890.             'ARcenciel.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143391/newprod/clipart/ARcenciel_grkyap.svg',
  7891.             'Drapeaux.svg' => 'https://res.cloudinary.com/apss-factory/image/uploadv/1589143377/newprod/clipart/Drapeaux_zqo8v3.svg',
  7892.             'Annif.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143391/newprod/clipart/Annif_ihvyoo.svg',
  7893.             'Basquettes.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Basquettes_znjd41.svg',
  7894.             'Foot.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143382/newprod/clipart/Foot_az6bct.svg',
  7895.             'Hello.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Hello_njqifl.svg',
  7896.             'Love.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143386/newprod/clipart/Love_q39usk.svg',
  7897.             'LICORNE.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143385/newprod/clipart/LICORNE_hpomru.svg',
  7898.             'Noeud.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143388/newprod/clipart/Noeud_mw5a4j.svg',
  7899.             'Etoilerose.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Etoilerose_ewrzff.svg',
  7900.             'Ete4.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/Ete4_pdxadk.svg',
  7901.             'Ete6.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Ete6_a3xgpd.svg',
  7902.             'Ete9.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Ete9_s4vllm.svg',
  7903.             'Hiver1.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Hiver1_fekrjz.svg',
  7904.             'Hiver2.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Hiver2_e9iygg.svg',
  7905.             'Noel2.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Noel2_eqvdzr.svg',
  7906.             'Hiver.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Hiver_et04e1.svg',
  7907.             'Sapin.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143390/newprod/clipart/Sapin_qjkxz6.svg',
  7908.             'Chaussetet.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Chaussetet_xfpt6t.svg',
  7909.             'Cloches.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Cloches_x2v3eo.svg',
  7910.             'Like.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Like_ynxb2u.svg',
  7911.             'coeurlike.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/coeurlike_ferv9y.svg',
  7912.             'Fetedesmeres.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Fetedesmeres_ud9vac.svg',
  7913.             'Fetedesperes.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Fetedesperes_mltjmo.svg',
  7914.             'OOPS.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/OOPS_gj9p1c.svg',
  7915.             'OOPS_1.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/OOPS_1_r9a7l6.svg',
  7916.             'WoW.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143393/newprod/clipart/WoW_ljlqjm.svg',
  7917.             'Nuage.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Nuage_fgomd0.svg',
  7918.             'Pingouin.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/Pingouin_ogxb6e.svg',
  7919.             'Renard.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143378/newprod/clipart/Chouette_mc1ik2.svg',
  7920.             'Chouette.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143390/newprod/clipart/Renard_mlhrxt.svg'
  7921.         ];
  7922.         foreach ($attachement as $at) {
  7923.             $exif false;
  7924.             $path $at;
  7925.             $pathArray explode("/"$path);
  7926.             $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  7927.             $idImage "";
  7928.             foreach ($idsArray as $key2 => $elem) {
  7929.                 if ($key2 != (sizeof($idsArray) - 1)) {
  7930.                     $idImage $idImage $elem;
  7931.                 }
  7932.             }
  7933.             $idImage 'clipart/' $idImage;
  7934.             \Cloudinary::config(array(
  7935.                 "cloud_name" => "af5sur5sejour",
  7936.                 "api_key" => "263346742199243",
  7937.                 "api_secret" => "jYw-jg0FOJGv89-o5Wo0Fa3rQWU",
  7938.                 "secure" => true
  7939.             ));
  7940.             Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  7941.             Unirest\Request::verifyPeer(false);
  7942.             $url 'https://api.cloudinary.com/v1_1/af5sur5sejour/image/upload';
  7943.             $headers = array('Accept' => 'application/json');
  7944.             $data = array("file" => $path"public_id" => $idImage"upload_preset" => 'ml_default');
  7945.             $body Unirest\Request\Body::form($data);
  7946.             $resultMetadata Unirest\Request::post($url$headers$body);
  7947.             var_dump($resultMetadata);
  7948.             if (isset(json_decode($resultMetadata->raw_body)->secure_url)) {
  7949.                 var_dump(json_decode($resultMetadata->raw_body)->secure_url);
  7950.             }
  7951.         }
  7952.         $em->getManager()->flush();
  7953.         return new response("done");
  7954.     }
  7955.     /**
  7956.      * @Route("/Parent/virgoPAss", name="virgopass")
  7957.      */
  7958.     public function virgopass()
  7959.     {
  7960.         return $this->render('Parent/virgo.html.twig');
  7961.     }
  7962.     /**
  7963.      * @Route("/Parent/interfaceUpdatePassorwdParent", name="interfaceUpdatePassorwdParent")
  7964.      */
  7965.     public function interfaceUpdatePassorwdParent(Request $request)
  7966.     {
  7967.         $user $this->getUser();
  7968.         return $this->render('Parent/interfaceUpdatePassorwdParent.html.twig', ["userToSetPassword" => $user]);
  7969.     }
  7970.     /**
  7971.      * @Route("/Parent/updatePassorwdParent", name="updatePassorwd_parent")
  7972.      */
  7973.     public function updatePassorwdParent(Request $request)
  7974.     {
  7975.         $em $this->em;
  7976.         $serviceuser $this->userService;
  7977.         $id $request->get("userID");
  7978.         $password $request->get("password");
  7979.         $result $serviceuser->ModifierPwdParent($id$password);
  7980.         return new Response('pwd modifiĂ©');
  7981.     }
  7982.     /**
  7983.      * @Route("/Parent/sauthentifierAuto/{token}/{idUser}/{userHash}",name="sauthentifierAuto")
  7984.      */
  7985.     function sauthentifierAuto($token$idUser$userHash)
  7986.     {
  7987.         $parent $this->em->getRepository(User::class)->find($idUser);
  7988.         if ((hash("sha256"$parent->getUsername() . $parent->getId()) == $userHash)) {
  7989.             $providerKey 'main_Parent'// your firewall name
  7990.             $token = new UsernamePasswordToken($parentnull$providerKey$parent->getRoles());
  7991.             $this->container->get('security.token_storage')->setToken($token);
  7992.             return $this->redirectToRoute("CodeSejour");
  7993.         } else {
  7994.             return $this->redirectToRoute("app_back_Parent");
  7995.         }
  7996.     }
  7997.     /**
  7998.      * @Route("/loginAutotoAlbumAcco/{token}/{idUser}/{userHash}/{albumAcco}",name="loginAutotoAlbumAcco")
  7999.      */
  8000.     function loginAutotoAlbumAcco($token$idUser$userHash$albumAcco)
  8001.     {
  8002.         $parent $this->em->getRepository(User::class)->find($idUser);
  8003.         if ((hash("sha256"$parent->getUsername() . $parent->getId()) == $userHash)) {
  8004.             //            return $this->render('security/DemandePasswordParentv.html.twig', ["userToSetPassword" => $use
  8005.             //dd('im herge');             
  8006.             $providerKey 'main_Parent'// your firewall name
  8007.             $token = new UsernamePasswordToken($parentnull$providerKey$parent->getRoles());
  8008.             //dd($token);  
  8009.             $this->container->get('security.token_storage')->setToken($token);
  8010.             $session $this->session;
  8011.             $produit $this->em->getRepository(Produit::class)->find($albumAcco);
  8012.             // dd($produit->getIdsjour()->getId());    
  8013.             $session->set("Sejour"$produit->getIdsjour()->getId());
  8014.             return $this->redirectToRoute("ActiverSessionAlbum");
  8015.         } else {
  8016.             return $this->redirectToRoute("app_back_Parent");
  8017.         }
  8018.     }
  8019.     /**
  8020.      * @Route("/Parent/respondNotifSms",name="respondNotifSms")
  8021.      */
  8022.     function respondNotifSms(Request $request)
  8023.     {
  8024.         $resp $request->get("resp");
  8025.         /** @var \App\Entity\User $user */
  8026.         $user $this->getUser();
  8027.         $user->setSmsnotif($resp);
  8028.         $this->em->getManager()->persist($user);
  8029.         $parentsejour $this->em->getRepository(ParentSejour::class)->findBy(['idParent' => $user]);
  8030.         foreach ($parentsejour as $sejr) {
  8031.             $sejr->setSmsnotif($resp);
  8032.             if (strpos($sejr->getIdSejour()->getCodeSejour(), "EF") !== false) {
  8033.                 $sejr->setSmsnotif(0);
  8034.             }
  8035.             $this->em->getManager()->persist($sejr);
  8036.         }
  8037.         $this->em->getManager()->flush();
  8038.         return new Response('smsnotifmodifiĂ©');
  8039.     }
  8040.     /**
  8041.      * @Route("/Parent/CheckRandomNotice",name="CheckRandomNotice")
  8042.      */
  8043.     function CheckRandomNotice(Request $request)
  8044.     {
  8045.         $val $request->get("val");
  8046.         /** @var \App\Entity\User $user */
  8047.         $user $this->getUser();
  8048.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8049.         $parent->setRandomnotice($val);
  8050.         $this->em->getManager()->persist($parent);
  8051.         $this->em->getManager()->flush();
  8052.         return new Response('ok');
  8053.     }
  8054.     /**
  8055.      * @Route("/Parent/CheckalbumNotif",name="CheckalbumNotif")
  8056.      */
  8057.     function CheckalbumNotif(Request $request)
  8058.     {
  8059.         $val $request->get("val");
  8060.         /** @var \App\Entity\User $user */
  8061.         $user $this->getUser();
  8062.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8063.         $parent->setShowdetailsalbum($val);
  8064.         $this->em->getManager()->persist($parent);
  8065.         $this->em->getManager()->flush();
  8066.         return new Response('ok');
  8067.     }
  8068.     /**
  8069.      * @Route("/Parent/ChecklivreNotif",name="ChecklivreNotif")
  8070.      */
  8071.     function ChecklivreNotif(Request $request)
  8072.     {
  8073.         $val $request->get("val");
  8074.         /** @var \App\Entity\User $user */
  8075.         $user $this->getUser();
  8076.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8077.         $parent->setShowdetailslivre($val);
  8078.         $this->em->getManager()->persist($parent);
  8079.         $this->em->getManager()->flush();
  8080.         return new Response('ok');
  8081.     }
  8082.     /**
  8083.      * @Route("/Parent/CheckphotosNotif",name="CheckphotosNotif")
  8084.      */
  8085.     function CheckphotosNotif(Request $request)
  8086.     {
  8087.         $val $request->get("val");
  8088.         /** @var \App\Entity\User $user */
  8089.         $user $this->getUser();
  8090.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8091.         $parent->setShowdetailsphotos($val);
  8092.         $this->em->getManager()->persist($parent);
  8093.         $this->em->getManager()->flush();
  8094.         return new Response('ok');
  8095.     }
  8096.     /**
  8097.      * @Route("/Parent/CheckcalNotif",name="CheckcalNotif")
  8098.      */
  8099.     function CheckcalNotif(Request $request)
  8100.     {
  8101.         $val $request->get("val");
  8102.         /** @var \App\Entity\User $user */
  8103.         $user $this->getUser();
  8104.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8105.         $parent->setShowdetailscal($val);
  8106.         $this->em->getManager()->persist($parent);
  8107.         $this->em->getManager()->flush();
  8108.         return new Response('ok');
  8109.     }
  8110.     /**
  8111.      * @Route("/Parent/CheckretrosNotif",name="CheckretrosNotif")
  8112.      */
  8113.     function CheckretrosNotif(Request $request)
  8114.     {
  8115.         $val $request->get("val");
  8116.         /** @var \App\Entity\User $user */
  8117.         $user $this->getUser();
  8118.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8119.         $parent->setShowdetailsretros($val);
  8120.         $this->em->getManager()->persist($parent);
  8121.         $this->em->getManager()->flush();
  8122.         return new Response('ok');
  8123.     }
  8124.     /**
  8125.      * @Route("/Parent/hidePubProd",name="hidePubProd")
  8126.      */
  8127.     function hidePubProd(Request $request)
  8128.     {
  8129.         $val $request->get("val");
  8130.         /** @var \App\Entity\User $user */
  8131.         $user $this->getUser();
  8132.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8133.         $parent->setShowpubprod('false');
  8134.         $this->em->getManager()->persist($parent);
  8135.         $this->em->getManager()->flush();
  8136.         return new Response('ok');
  8137.     }
  8138.     /**
  8139.      * @Route("/Parent/PackPhotosNumerique_Modifier/{nbr}/{id}", name="PackPhotosNumerique_Modifier")
  8140.      */
  8141.     public function PackPhotosNumerique_Modifier($nbr$id)
  8142.     {
  8143.         $SEjourService $this->sejourService;
  8144.         /** @var \App\Entity\User $user */
  8145.         $user $this->getUser();
  8146.         $userId $user->getId();
  8147.         $user $this->getUser();
  8148.         $session $this->session;
  8149.         $session->set('pageMenu''');
  8150.         $idSejour $session->get("Sejour");
  8151.         $produitcondition $session->get("produit");
  8152.         $produit $session->get("produittype");
  8153.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8154.         $em $this->em;
  8155.         $clipart $em->getRepository(Clipart::class)->findAll();
  8156.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  8157.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  8158.         $nbLikes count($listeattachlikephoto);
  8159.         //Stella
  8160.         $AllPagesAcc null;
  8161.         $random false;
  8162.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  8163.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  8164.         $idAcc $sejour->getIdAcommp();
  8165.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  8166.         $part $sejour->getIdPartenaire();
  8167.         $nompart $part->getUsername();
  8168.         $logopart $part->getLogourl();
  8169.         $nbPhoto count($listeattach);
  8170.         // die();
  8171.         if ($nbLikes == 0) {
  8172.             return $this->render('Parent/PackPhotosNumerique.html.twig', ["nbr" => $nbr"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattach'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random]);
  8173.         }
  8174.         if ($nbLikes != 0) {
  8175.             return $this->render('Parent/PackPhotosNumerique_Favoris.html.twig', ["nbr" => $nbr"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random]);
  8176.         }
  8177.     }
  8178.     /**
  8179.      * @Route("Parent/PackPhotosNumerique_Favoris/{nbr}", name="PackPhotosNumerique_Favoris")
  8180.      */
  8181.     public function PackPhotosNumerique_Favoris($nbr)
  8182.     {
  8183.         $SEjourService $this->sejourService;
  8184.         $user $this->getUser();
  8185.         $userId $this->getUser()->getId();
  8186.         $session $this->get('session');
  8187.         $session->set('pageMenu''');
  8188.         $idSejour $session->get("Sejour");
  8189.         $produitcondition $session->get("produit");
  8190.         $produit $session->get("produittype");
  8191.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8192.         $em $this->getDoctrine()->getManager();
  8193.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' =>  $userId'idSejour' =>  $idSejour]);
  8194.         foreach ($listeattachlikephoto as $photo) {
  8195.             $idattach $photo->getIdSejourAttchment();
  8196.             $SejattachPhoto  $photo->getIdSejourAttchment();
  8197.             $urlPhoto  =   $SejattachPhoto->getIdAttchment()->getPath();
  8198.             //$urlPhoto =   $attachPhoto->getPath();
  8199.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/',  $urlPhoto);
  8200.             $photosData[] = [
  8201.                 'id' => $photo->getId(),
  8202.                 'url' =>    $new_url,
  8203.                 'caption' => "",
  8204.             ];
  8205.         }
  8206.         $nbLikes count($listeattachlikephoto);
  8207.         // Convertir le tableau PHP en JSON
  8208.         $photosDataJSON json_encode($photosData);
  8209.         return $this->render('Parent/PackPhotosNumerique_Favoris.html.twig', [
  8210.             "nbr" => $nbr,
  8211.             "sejour" => $sejour,
  8212.             "nbLikes" => $nbLikes,
  8213.             'photosFav' =>    $photosDataJSON
  8214.         ]);
  8215.     }
  8216.     /**
  8217.      * @Route("Parent/PackPhotosNumerique_Offert/{nbr}", name="PackPhotosNumerique_Offert")
  8218.      */
  8219.     public function PackPhotosNumerique_Offert($nbr)
  8220.     {
  8221.         $SEjourService $this->sejourService;
  8222.         $user $this->getUser();
  8223.         $userId $this->getUser()->getId();
  8224.         $session $this->get('session');
  8225.         $session->set('pageMenu''');
  8226.         $idSejour $session->get("Sejour");
  8227.         $produitcondition $session->get("produit");
  8228.         $produit $session->get("produittype");
  8229.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8230.         $em $this->getDoctrine()->getManager();
  8231.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' => $userId'idSejour' => $idSejour]);
  8232.         foreach ($listeattachlikephoto as $photo) {
  8233.             $idattach $photo->getIdSejourAttchment();
  8234.             $SejattachPhoto $photo->getIdSejourAttchment();
  8235.             $urlPhoto $SejattachPhoto->getIdAttchment()->getPath();
  8236.             //$urlPhoto = $attachPhoto->getPath();
  8237.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/'$urlPhoto);
  8238.             $photosData[] = [
  8239.                 'id' => $photo->getId(),
  8240.                 'url' => $new_url,
  8241.                 'caption' => "",
  8242.             ];
  8243.         }
  8244.         $nbLikes count($listeattachlikephoto);
  8245.         // Convertir le tableau PHP en JSON
  8246.         $photosDataJSON json_encode($photosData);
  8247.         return $this->render('Parent/PackPhotosNumerique_Favoris.html.twig', [
  8248.             "nbr" => $nbr,
  8249.             "sejour" => $sejour,
  8250.             "nbLikes" => $nbLikes,
  8251.             'photosFav' => $photosDataJSON
  8252.         ]);
  8253.     }
  8254.     /**
  8255.      * @Route("Parent/AjoutPackPhotosNum/{nbr}", name="AjoutPackPhotosNum")
  8256.      */
  8257.     public function AjoutPackPhotosNumParent($nbr)
  8258.     {
  8259.         $SEjourService $this->sejourService;
  8260.         /** @var \App\Entity\User $user */
  8261.         $user $this->getUser();
  8262.         $userId $user->getId();
  8263.         $user $this->getUser();
  8264.         $session $this->session;
  8265.         $session->set('pageMenu''');
  8266.         $idSejour $session->get("Sejour");
  8267.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8268.         $em $this->em;
  8269.         $clipart $em->getRepository(Clipart::class)->findAll();
  8270.         //  $listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
  8271.         //$listerandom =  $SEjourService->getatachmentsejour($idSejour);
  8272.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  8273.         $listerandom =  $listeattach;
  8274.         $AllPagesAcc null;
  8275.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPackPhotosNum' $nbr]);
  8276.         $random true;
  8277.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  8278.         $idAcc $sejour->getIdAcommp();
  8279.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  8280.         $part $sejour->getIdPartenaire();
  8281.         $nompart $part->getUsername();
  8282.         $logopart $part->getLogourl();
  8283.         if ($albumAcc != null and $albumAcc != "") {
  8284.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  8285.         }
  8286.         $allpagesResult = array();
  8287.         $j 0;
  8288.         if ($random == true) {
  8289.             foreach ($AllPages as $p) {
  8290.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  8291.                 $rr "";
  8292.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  8293.                     if ($i sizeof($arrayexploded)) {
  8294.                         if (sizeof($listerandom) == 0) {
  8295.                             //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  8296.                             $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  8297.                         }
  8298.                         $arrayRsRandom $this->random_functionNolikes($listerandom);
  8299.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  8300.                         unset($listerandom[$arrayRsRandom['elem']]);
  8301.                     } else {
  8302.                         $rr $rr $arrayexploded[$i];
  8303.                     }
  8304.                     $listerandom $listerandom;
  8305.                 }
  8306.                 $resultFinal $rr;
  8307.                 $p->setCouleurbordure($resultFinal);
  8308.                 array_push($allpagesResult$p);
  8309.                 if ($j sizeof($listeattach) - 1) {
  8310.                     $j $j 1;
  8311.                 } else {
  8312.                     $j 0;
  8313.                 }
  8314.             }
  8315.             $AllPages $allpagesResult;
  8316.         }
  8317.         return $this->render('Parent/PackPhotosNumerique.html.twig', ["nbr" => $nbr"nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattach'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'albumAcc' => $albumAcc'AllPagesAcc' => $AllPagesAcc'random' => $random'listeattach' => $listeattach]);
  8318.     }
  8319.     /**
  8320.      * @Route("/Parent/SavePackPhotosNumerique", name="SavePackPhotosNumeriqueParent")
  8321.      */
  8322.     public function SavePackPhotosNumeriqueParent(Request $request)
  8323.     {
  8324.         $session $this->session;
  8325.         $serviceuser $this->etablissementService;
  8326.         $page $request->get("pages");
  8327.         $sejour $request->get("sejour");
  8328.         $prodid $request->get('idProd');
  8329.         $nomprod $request->get('nomprod');
  8330.         $nbr $request->get('nbr');
  8331.         $user $this->getUser();
  8332.         $nbr strval($nbr);
  8333.         $produittype $session->get("produit");
  8334.         $produit $session->get("produittype");
  8335.         //  $Album = $serviceuser->SavePhotosPochetteParent($page, $user, $sejour, $prodid, $produit, $produittype, $nbr,$nomprod);
  8336.         $refPackNum null;
  8337.         if ($sejour) {
  8338.             $refPackNum $this->generateRefPackPhotosNum($sejour$user);
  8339.         }
  8340.         $Album $serviceuser->SavePackPhotosNumerique($page$user$sejour$prodid$produit$produittype$nbr$nomprod$refPackNum);
  8341.         //sendmailparent
  8342.         $dateNow = new \Datetime();
  8343.         /** @var \App\Entity\User $user */
  8344.         $user $this->getUser();
  8345.         $userEmail $user->getEmail();
  8346.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  8347.         //$this->EmailServie->MailRelancePanier($userEmail);
  8348.         return new response('done');
  8349.     }
  8350.     /**
  8351.      * @Route("/Parent/CommandeDirecteAddPackNumeriqueAuPanier", name="CommandeDirecteAddPackNumeriqueAuPanier")
  8352.      */
  8353.     public function CommandeDirecteAddPackNumeriqueAuPanier(Request $request)
  8354.     {
  8355.         $em $this->em->getManager();
  8356.         $session $this->session;
  8357.         $this->logger->info('DĂ©but CommandeDirecteAddPackNumeriqueAuPanier');
  8358.         $serviceuser $this->etablissementService;
  8359.         $photos $request->get("photos");
  8360.         $sejour $request->get("sejour");
  8361.         $nbr $request->get('nbr');
  8362.         $user $this->getUser();
  8363.         $nbr strval($nbr);
  8364.         $nomprod "Pack Photos Numerique - " $nbr;
  8365.         // CrĂ©er le produit pack photos
  8366.         $packPhotos $serviceuser->SavePackPhotosNumerique($photos$user$sejour$nbr$nomprod);
  8367.         $product $em->getRepository(Produit::class)->find($packPhotos->getId());
  8368.         // RĂ©cupĂ©rer ou crĂ©er le panier
  8369.         $typeref $em->getRepository(Typeref::class)->find(8);
  8370.         $statutPanier $em->getRepository(Ref::class)->findOneBy(["libiller" => "creer""typeref" => $typeref]);
  8371.         $panierTrace $em->getRepository(Panier::class)->findOneBy(["creerPar" => $user"statut" => $statutPanier]);
  8372.         if ($panierTrace === null) {
  8373.             $panierTrace = new Panier();
  8374.             $panierTrace->setDateCreation(new \DateTime());
  8375.             $panierTrace->setCreerPar($user);
  8376.             $panierTrace->setStatut($statutPanier);
  8377.             $em->persist($panierTrace);
  8378.             $em->flush();
  8379.         }
  8380.         $this->logger->info('Panier rĂ©cupĂ©rĂ©', ['panier_id' => $panierTrace $panierTrace->getId() : 'null']);
  8381.         // RĂ©cupĂ©rer les produits du panier en session
  8382.         $Products $session->get("Panier", []);
  8383.         $inser false;
  8384.         // VĂ©rifier si le panier est vide (pas de produits en session)
  8385.         if (count($Products) == 0) {
  8386.             // CrĂ©er directement une commande et une commande numĂ©rique
  8387.             $commande = new Commande();
  8388.             $commande->setDateCreation(new \DateTime());
  8389.             $commande->setCreerPar($user);
  8390.             $commande->setStatut($statutPanier);
  8391.             $commande->setTyperef($typeref);
  8392.             $commande->setMontantTTC($product->getIdConditionnement()->getMontantTTC());
  8393.             $commande->setIdsjour($sejour);
  8394.             $commande->setIdpanier($panierTrace->getId());
  8395.             $commande->setNumComande($this->generateUniqueOrderNumber());
  8396.             $em->persist($commande);
  8397.             $em->flush();
  8398.             $commandeNumerique = new CommandeNumerique();
  8399.             $commandeNumerique->setDateCreation(new \DateTime());
  8400.             $commandeNumerique->setCreerPar($user);
  8401.             $commandeNumerique->setIdCommande($commande);
  8402.             $commandeNumerique->setStatut($statutPanier);
  8403.             $commandeNumerique->setLinkdownload($product->getId());
  8404.             $commandeNumerique->setEtat(0); // Ă‰tat en attente de paiement
  8405.             $em->persist($commandeNumerique);
  8406.             $em->flush();
  8407.             // Ajouter le produit au panier en session pour le paiement
  8408.             $p = [
  8409.                 "id" => $product->getId(),
  8410.                 "nom" => $product->getType()->getLabeletype(),
  8411.                 "ident" => $product->getLabele(),
  8412.                 "codesejour" => $product->getIdsjour()->getcodeSejour(),
  8413.                 "mnt" => $product->getIdConditionnement()->getMontantTTC(),
  8414.                 "path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  8415.                 "condition" => $product->getIdConditionnement()->getId(),
  8416.                 "qte" => 1
  8417.             ];
  8418.             array_push($Products$p);
  8419.             $session->set('Panier'$Products);
  8420.             // Ajouter le produit au panier en base de donnĂ©es
  8421.             $panierProduit = new PanierProduit();
  8422.             $panierProduit->setIdProduit($product);
  8423.             $panierProduit->setIdPanier($panierTrace);
  8424.             $panierProduit->setQuantite(1);
  8425.             $panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
  8426.             $em->persist($panierProduit);
  8427.             $em->flush();
  8428.             // Rediriger vers la page de paiement
  8429.             return $this->redirectToRoute('paiement_commande_directe', [
  8430.                 'id' => $commande->getId()
  8431.             ]);
  8432.         } else {
  8433.             // Il y a dĂ©jĂ  des produits dans le panier
  8434.             // Ajouter le produit au panier existant
  8435.             // VĂ©rifier si le produit existe dĂ©jĂ  dans le panier en session
  8436.             foreach ($Products as $key => $p) {
  8437.                 if ($p['id'] === $product->getId()) {
  8438.                     $inser true;
  8439.                     $Products[$key]['qte'] += 1;
  8440.                     $Products[$key]['mnt'] += $product->getIdConditionnement()->getMontantTTC();
  8441.                 }
  8442.             }
  8443.             // VĂ©rifier si le produit existe dans PanierProduit en base de donnĂ©es
  8444.             $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(["idProduit" => $product"idPanier" => $panierTrace]);
  8445.             if ($panierProduit === null) {
  8446.                 $panierProduit = new PanierProduit();
  8447.                 $panierProduit->setIdProduit($product);
  8448.                 $panierProduit->setIdPanier($panierTrace);
  8449.                 $panierProduit->setQuantite(1);
  8450.                 $panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
  8451.                 $em->persist($panierProduit);
  8452.                 $em->flush();
  8453.             } else {
  8454.                 // Mettre Ă  jour la quantitĂ© et le prix total
  8455.                 $panierProduit->setQuantite($panierProduit->getQuantite() + 1);
  8456.                 $panierProduit->setPrixTotal($panierProduit->getPrixTotal() + $product->getIdConditionnement()->getMontantTTC());
  8457.                 $em->persist($panierProduit);
  8458.                 $em->flush();
  8459.             }
  8460.             // Si le produit n'est pas dĂ©jĂ  dans le panier en session, l'ajouter
  8461.             if (!$inser) {
  8462.                 $p = [
  8463.                     "id" => $product->getId(),
  8464.                     "nom" => $product->getType()->getLabeletype(),
  8465.                     "ident" => $product->getLabele(),
  8466.                     "codesejour" => $product->getIdsjour()->getcodeSejour(),
  8467.                     "mnt" => $product->getIdConditionnement()->getMontantTTC(),
  8468.                     "path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  8469.                     "condition" => $product->getIdConditionnement()->getId(),
  8470.                     "qte" => 1
  8471.                 ];
  8472.                 array_push($Products$p);
  8473.             }
  8474.             // Mettre Ă  jour le panier en session
  8475.             $session->set('Panier'$Products);
  8476.             // Ajouter un message flash pour informer l'utilisateur
  8477.             $this->addFlash('success''Le pack photos a Ă©tĂ© ajoutĂ© Ă  votre panier.');
  8478.             // Rediriger vers le panier
  8479.             $this->logger->info('Redirection vers le panier');
  8480.             return new Response('done');
  8481.         }
  8482.     }
  8483.     /**
  8484.      * GĂ©nère un numĂ©ro de commande unique
  8485.      */
  8486.     private function generateUniqueOrderNumber()
  8487.     {
  8488.         // GĂ©nĂ©rer un numĂ©ro de commande basĂ© sur la date et un nombre alĂ©atoire
  8489.         return date('YmdHis') . rand(10009999);
  8490.     }
  8491.     /**
  8492.      * @Route("/Parent/confirmation-pack-photos/{id}", name="confirmation_pack_photos")
  8493.      */
  8494.     public function confirmationPackPhotos($id): Response
  8495.     {
  8496.         $commandeNumerique $this->em->getRepository(CommandeNumerique::class)->find($id);
  8497.         if (!$commandeNumerique) {
  8498.             throw $this->createNotFoundException('Commande numĂ©rique introuvable');
  8499.         }
  8500.         $commande $commandeNumerique->getIdCommande();
  8501.         $user $commande->getCreerPar();
  8502.         $sejour $commande->getIdsjour();
  8503.         return $this->render('Parent/confirmation_pack_photos.html.twig', [
  8504.             'commandeNumerique' => $commandeNumerique,
  8505.             'commande' => $commande,
  8506.             'user' => $user,
  8507.             'sejour' => $sejour,
  8508.             'downloadUrl' => $this->generateUrl('telechargerPack', ['idCommande' => $commandeNumerique->getId()])
  8509.         ]);
  8510.     }
  8511.     /**
  8512.      * @Route("/Parent/SavePackPhotosNumeriqueComandeSave_panier", name="SavePackPhotosNumeriqueComandeSave_panier")
  8513.      */
  8514.     public function AddPackNumeriqueAuPanier(Request $request)
  8515.     {
  8516.         $em $this->em->getManager();
  8517.         $session $this->session;
  8518.         $serviceuser $this->etablissementService;
  8519.         $photos $request->get("photos");
  8520.         $sejour $request->get("sejour");
  8521.         $nbr $request->get('nbr');
  8522.         $user $this->getUser();
  8523.         $nbr strval($nbr);
  8524.         $nomprod "Pack Photos Numerique - " $nbr;
  8525.         //test de la fonction envoieMailPackNumerique
  8526.         $packPhotos $serviceuser->SavePackPhotosNumerique($photos$user$sejour$nbr$nomprod);
  8527.         $product $em->getRepository(Produit::class)->find($packPhotos->getId());
  8528.         // ---  Test pour envoyer le mail pak numerique ---// 
  8529.         //   $this->emailsCmdService->envoieMailPackNumerique($packPhotos->getId());
  8530.         // $this->printerService->PackPhotosNumerique($packPhotos->getId(),20);
  8531.         $typeref $em->getRepository(Typeref::class)->find(8);
  8532.         $statutPanier $em->getRepository(Ref::class)->findOneBy(["libiller" => "creer""typeref" => $typeref]);
  8533.         $panierTrace $em->getRepository(Panier::class)->findOneBy(["creerPar" => $user"statut" => $statutPanier]);
  8534.         if ($panierTrace === null) {
  8535.             $panierTrace = new Panier();
  8536.             $panierTrace->setDateCreation(new \DateTime());
  8537.             $panierTrace->setCreerPar($user);
  8538.             $panierTrace->setStatut($statutPanier);
  8539.             $em->persist($panierTrace);
  8540.             $em->flush();
  8541.         }
  8542.         // Add product to cart session
  8543.         $Products $session->get("Panier", []);
  8544.         $inser false;
  8545.         foreach ($Products as $key => $p) {
  8546.             if ($p['id'] === $product->getId()) {
  8547.                 $inser true;
  8548.                 $Products[$key]['qte'] += 1;
  8549.                 $Products[$key]['mnt'] += $product->getIdConditionnement()->getMontantTTC();
  8550.             }
  8551.         }
  8552.         // Check if product exists in PanierProduit
  8553.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(["idProduit" => $product"idPanier" => $panierTrace]);
  8554.         if ($panierProduit === null) {
  8555.             $panierProduit = new PanierProduit();
  8556.             $panierProduit->setIdProduit($product);
  8557.             $panierProduit->setIdPanier($panierTrace);
  8558.             $panierProduit->setQuantite(1);
  8559.             $panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
  8560.             $em->persist($panierProduit);
  8561.             $em->flush();
  8562.         } else {
  8563.             // Update existing product quantity and total price
  8564.             $panierProduit->setQuantite($panierProduit->getQuantite() + 1);
  8565.             $panierProduit->setPrixTotal($panierProduit->getPrixTotal() + $product->getIdConditionnement()->getMontantTTC());
  8566.             $em->persist($panierProduit);
  8567.             $em->flush();
  8568.         }
  8569.         if (!$inser) {
  8570.             $p = [
  8571.                 "id" => $product->getId(),
  8572.                 "nom" => $product->getType()->getLabeletype(),
  8573.                 "ident" => $product->getLabele(),
  8574.                 "codesejour" => $product->getIdsjour()->getcodeSejour(),
  8575.                 "mnt" => $product->getIdConditionnement()->getMontantTTC(),
  8576.                 "path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  8577.                 "condition" => $product->getIdConditionnement()->getId(),
  8578.                 "qte" => 1
  8579.             ];
  8580.             array_push($Products$p);
  8581.         }
  8582.         $session->set('Panier'$Products);
  8583.         // Send reminder email
  8584.         /** @var \App\Entity\User $user */
  8585.         $userEmail $user->getEmail();
  8586.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  8587.         return new Response('done');
  8588.     }
  8589.     /* public function SavePackPhotosNumeriqueComandeSave_panier(PrinterService $PrinterService, Request $request)
  8590.     {
  8591.         $em = $this->em;
  8592.         var_dump("Debut Creation du pack numerique ");
  8593.         $session = $this->session;
  8594.         $serviceuser = $this->etablissementService;
  8595.         $attachements = $request->get('attachements');
  8596.         $page = $request->get("pages");
  8597.         $sejour = $request->get("sejour");
  8598.         $prodid = $request->get('idProd');
  8599.         var_dump($prodid);
  8600.         $nomprod = $request->get('nomprod');
  8601.         $nbr = $request->get('nbr');
  8602.         $user = $this->getUser();
  8603.         $nbr = strval($nbr);
  8604.         $produittype = $session->get("produit");
  8605.         $produit = $session->get("produittype");
  8606.         if ($sejour !== null) {
  8607.             $refPackNum = $this->generateRefPackPhotosNum($sejour, $user);
  8608.             $Album = $serviceuser->SavePackPhotosNumerique($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod, $refPackNum);
  8609.             $produit = $em->getRepository(Produit::class)->find($Album->getId());
  8610.             $serviceuser->commandepackphotoNum($attachements, $sejour, $user, $Album);
  8611.             //   $PrinterService->PackPhotosNumerique($sejour,$refPackNum,$Album);
  8612.             $inser = false;
  8613.             $Products = $session->get("Panier");
  8614.             //Touhemi  03-07-2020 :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  8615.             $user = $this->getUser();
  8616.             $typeref = $em->getRepository(Typeref::class)->find(8);
  8617.             $statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
  8618.             $panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
  8619.             //fin
  8620.             if ($panierTrace == null) {
  8621.                 $panierTrace = new Panier();
  8622.                 $dateNow = new \Datetime();
  8623.                 $panierTrace->setDateCreation($dateNow);
  8624.                 $panierTrace->setCreerPar($user);
  8625.                 $panierTrace->setStatut($statutPanier);
  8626.                 $em->getManager()->persist($panierTrace);
  8627.                 $em->getManager()->flush();
  8628.             }
  8629.             //Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on Ă©crit un produit
  8630.             if ($Products == null) {
  8631.                 $Products = [];
  8632.             }
  8633.             if ($Products != null) {
  8634.                 foreach ($Products as $key => $p) {
  8635.                     if ($p['id'] == $produit->getId()) {
  8636.                         $inser = true;
  8637.                         $Products[$key]['qte'] = $p['qte'] + 1;
  8638.                         $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  8639.                     }
  8640.                 }
  8641.             }
  8642.             //Touhemi 03-07-2020 :Rechercher  si le produti existe dĂ©ja ds panierProduit
  8643.             $panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
  8644.             if ($panierProduit == null) {
  8645.                 $panierProduit = new PanierProduit();
  8646.                 $panierProduit->setIdProduit($produit);
  8647.                 $panierProduit->setIdPanier($panierTrace);
  8648.                 $em->getManager()->persist($panierProduit);
  8649.                 $em->getManager()->flush();
  8650.             }
  8651.             //fin
  8652.             //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  8653.             $oldQte = $panierProduit->getQuantite();
  8654.             $newQte = $oldQte + 1;
  8655.             $panierProduit->setQuantite($newQte);
  8656.             $oldTotal = $panierProduit->getPrixTotal();
  8657.             $newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
  8658.             $panierProduit->setPrixTotal($newTotal);
  8659.             $em->getManager()->persist($panierProduit);
  8660.             $em->getManager()->flush();
  8661.             //fin
  8662.             if ($inser === false) {
  8663.                 $p = [];
  8664.                 $p["id"] = $produit->getId();
  8665.                 $p["nom"] = $produit->getType()->getLabeletype();
  8666.                 $p["ident"] = $produit->getLabele();
  8667.                 $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  8668.                 $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  8669.                 $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  8670.                 $p["condition"] = $produit->getIdConditionnement()->getId();
  8671.                 $p["qte"] = 1;
  8672.                 array_push($Products, $p);
  8673.             }
  8674.             $session->set('Panier', $Products);
  8675.             //sendmail_parent
  8676.             $dateNow = new \Datetime();
  8677.             $user = $this->getUser();
  8678.             $userEmail = $user->getEmail();
  8679.             $this->EmailServie->SaveMailRelancePanier($userEmail);
  8680.             // $this->EmailServie->MailRelancePanier($userEmail);
  8681.         }
  8682.         return new response('done');
  8683.     }
  8684. */
  8685.     /**
  8686.      * @Route("/Parent/SavePackPhotosNumeriqueComandeSave_panierfree", name="SavePackPhotosNumeriqueComandeSave_panierfree")
  8687.      */
  8688.     public function SavePackPhotosNumeriqueComandeSave_panierfree(PrinterService $PrinterServiceRequest $request)
  8689.     {
  8690.         $em $this->em;
  8691.         var_dump("Debut Creation du pack numerique ");
  8692.         $session $this->session;
  8693.         $serviceuser $this->etablissementService;
  8694.         $attachements $request->get('attachements');
  8695.         $page $request->get("pages");
  8696.         $sejour $request->get("sejour");
  8697.         $prodid $request->get('idProd');
  8698.         var_dump($prodid);
  8699.         $nomprod $request->get('nomprod');
  8700.         $nbr $request->get('nbr');
  8701.         $user $this->getUser();
  8702.         $nbr strval($nbr);
  8703.         $produittype $session->get("produit");
  8704.         $produit $session->get("produittype");
  8705.         if ($sejour !== null) {
  8706.             $refPackNum $this->generateRefPackPhotosNum($sejour$user);
  8707.             $Album $serviceuser->SavePackPhotosNumeriquefree($page$user$sejour$prodid$produit$produittype$nbr$nomprod$refPackNum);
  8708.             $produit $em->getRepository(Produit::class)->find($Album->getId());
  8709.             $serviceuser->commandepackphotoNum($attachements$sejour$user$Album);
  8710.             //   $PrinterService->PackPhotosNumerique($sejour,$refPackNum,$Album);
  8711.             $inser false;
  8712.             $Products $session->get("Panier");
  8713.             //Touhemi  03-07-2020 :Rechercher  si l'utilisateur a dĂ©ja un panier avec statut crĂ©er ds la bd , sinon on Ă©crit un panier
  8714.             $user $this->getUser();
  8715.             $typeref $em->getRepository(Typeref::class)->find(8);
  8716.             $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  8717.             $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  8718.             //fin
  8719.             if ($panierTrace == null) {
  8720.                 $panierTrace = new Panier();
  8721.                 $dateNow = new \Datetime();
  8722.                 $panierTrace->setDateCreation($dateNow);
  8723.                 $panierTrace->setCreerPar($user);
  8724.                 $panierTrace->setStatut($statutPanier);
  8725.                 $em->getManager()->persist($panierTrace);
  8726.                 $em->getManager()->flush();
  8727.             }
  8728.             //Touhemi 03-07-2020 :s'il y a un produit avec (id user,id sejour, type produit et type conditionement) dans le panier , sinon on Ă©crit un produit
  8729.             if ($Products == null) {
  8730.                 $Products = [];
  8731.             }
  8732.             if ($Products != null) {
  8733.                 foreach ($Products as $key => $p) {
  8734.                     if ($p['id'] == $produit->getId()) {
  8735.                         $inser true;
  8736.                         $Products[$key]['qte'] = $p['qte'] + 1;
  8737.                         $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  8738.                     }
  8739.                 }
  8740.             }
  8741.             //Touhemi 03-07-2020 :Rechercher  si le produti existe dĂ©ja ds panierProduit
  8742.             $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  8743.             if ($panierProduit == null) {
  8744.                 $panierProduit = new PanierProduit();
  8745.                 $panierProduit->setIdProduit($produit);
  8746.                 $panierProduit->setIdPanier($panierTrace);
  8747.                 $em->getManager()->persist($panierProduit);
  8748.                 $em->getManager()->flush();
  8749.             }
  8750.             //fin
  8751.             //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  8752.             $oldQte $panierProduit->getQuantite();
  8753.             $newQte $oldQte 1;
  8754.             $panierProduit->setQuantite($newQte);
  8755.             $oldTotal $panierProduit->getPrixTotal();
  8756.             $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  8757.             $panierProduit->setPrixTotal($newTotal);
  8758.             $em->getManager()->persist($panierProduit);
  8759.             $em->getManager()->flush();
  8760.             //fin
  8761.             if ($inser === false) {
  8762.                 $p = [];
  8763.                 $p["id"] = $produit->getId();
  8764.                 $p["nom"] = $produit->getType()->getLabeletype();
  8765.                 $p["ident"] = $produit->getLabele();
  8766.                 $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  8767.                 $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  8768.                 $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  8769.                 $p["condition"] = $produit->getIdConditionnement()->getId();
  8770.                 $p["qte"] = 1;
  8771.                 array_push($Products$p);
  8772.             }
  8773.             $session->set('Panier'$Products);
  8774.             //sendmail_parent
  8775.             $dateNow = new \Datetime();
  8776.             /** @var \App\Entity\User $user */
  8777.             $user $this->getUser();
  8778.             $userEmail $user->getEmail();
  8779.             $this->EmailServie->SaveMailRelancePanier($userEmail);
  8780.             // $this->EmailServie->MailRelancePanier($userEmail);
  8781.         }
  8782.         return new response('done');
  8783.     }
  8784.     function generateRefPackPhotosNum($idsejour$user)
  8785.     {
  8786.         //photonum_code_sejour_idparent_random;
  8787.         $em $this->em;
  8788.         $date = new \Datetime();
  8789.         $Milliseconde $date->format('dmYhis');
  8790.         $sejour $this->em->getRepository(Sejour::class)->find($idsejour);
  8791.         $ref "photonum_" $sejour->getCodeSejour() . "_" $user->getId() . "_" $Milliseconde;
  8792.         return $ref;
  8793.     }
  8794.     /**
  8795.      * @Route("/downloadpackphotonum/{refcmdnum}", name="downloadpackphotonum",methods={"GET"})
  8796.      */
  8797.     public function downloadpackphotonumAction($refcmdnum)
  8798.     {
  8799.         $tab explode("_"$refcmdnum);
  8800.         if (sizeof($tab) == 4) {
  8801.             $codesejour $tab[1];
  8802.             $iduser $tab[2];
  8803.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(array('codeSejour' => $codesejour));
  8804.             $user $this->em->getRepository(User::class)->find(intval($iduser));
  8805.             if ($user && $sejour) {
  8806.                 $commandenumerique $this->em->getRepository(CommandeNumerique::class)->findOneBy(array('linkdownload' => $refcmdnum));
  8807.                 if ($commandenumerique) {
  8808.                     if ($commandenumerique->getEtat() === 1) {
  8809.                         $commandenumerique->setEtat(2);
  8810.                         $commandenumerique->setDateTelechargement(new \DateTime());
  8811.                         $this->em->getManager()->persist($commandenumerique);
  8812.                         $this->em->getManager()->flush();
  8813.                         $response = new BinaryFileResponse($this->getParameter('kernel.project_dir') . '/public/ParentPhotosNumerique/' $refcmdnum '/' $refcmdnum '.zip');
  8814.                         $response->headers->set('Content-Type'"application/zip");
  8815.                         // Set content disposition inline of the file
  8816.                         $response->setContentDisposition(
  8817.                             ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  8818.                             $refcmdnum '.zip'
  8819.                         );
  8820.                         return $response;
  8821.                     } elseif ($commandenumerique->getEtat() == 2) {
  8822.                         return new JsonResponse(array('message' => 'commande dĂ©jĂ  livrĂ©e'), 400);
  8823.                     } else {
  8824.                         return new JsonResponse(array('message' => 'commande invalide'), 400);
  8825.                     }
  8826.                 } else {
  8827.                     return new JsonResponse(array('message' => 'commande introuvable'), 400);
  8828.                 }
  8829.             }
  8830.         } else {
  8831.             return new JsonResponse(array('message' => 'lien invalide'), 400);
  8832.         }
  8833.     }
  8834.     /**
  8835.      * @Route("/Parent/showpub" , name="showpub")
  8836.      */
  8837.     public function showpub()
  8838.     {
  8839.         /** @var User $user */
  8840.         $user $this->getUser();
  8841.         if (!$user) {
  8842.             return new JsonResponse(['status' => 'error''message' => 'User not found'], 400);
  8843.         }
  8844.         // Set showpubprod to true
  8845.         $user->setShowpubprod(1);
  8846.         // Save the changes to the database
  8847.         $this->em->getManager()->persist($user);
  8848.         $this->em->getManager()->flush();
  8849.         // Return a success response
  8850.         return new JsonResponse(['status' => 'success']);
  8851.     }
  8852.     /**
  8853.      * @Route("/Parent/Mentionslegales", name="mentionlegale")
  8854.      */
  8855.     public function Mentionslegales()
  8856.     {
  8857.         return $this->render('Parent/footer/mentionlegal.html.twig', []);
  8858.     }
  8859.     /**
  8860.      * @Route("/Parent/Conditongeneral", name="Conditongeneral")
  8861.      */
  8862.     public function Conditongeneral()
  8863.     {
  8864.         return $this->render('Parent/footer/Condition.html.twig', []);
  8865.     }
  8866.     /**
  8867.      * @Route("/Parent/PdfParentP/{id}", name="PdfParentP_Parent")
  8868.      */
  8869.     public function ExportPdfParentPayeParent(Request $request$id)
  8870.     {
  8871.         $sejourservice $this->sejourService;
  8872.         $session $this->session;
  8873.         // RĂ©cupĂ©rer le sĂ©jour pour un parent
  8874.         $sejour $sejourservice->getsejour($id);
  8875.         // VĂ©rifier que le parent a accès Ă  ce sĂ©jour
  8876.         $parentSejour $this->em->getRepository(ParentSejour::class)->findOneBy([
  8877.             'IdParent' => $this->getUser(),
  8878.             'idSejour' => $sejour
  8879.         ]);
  8880.         if (!$parentSejour) {
  8881.             throw $this->createAccessDeniedException('Vous n\'avez pas accès Ă  ce sĂ©jour');
  8882.         }
  8883.         $pdf = new Fpdi();
  8884.         $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  8885.         $pdfFilepath $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
  8886.         $pageCount $pdf->setSourceFile($pdfFilepath);
  8887.         $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  8888.         $pdf->AddPage();
  8889.         $pdf->useImportedPage($pageId00);
  8890.         $pdf->SetFont("Arial"""10);
  8891.         $MotPass $sejour->getCodeSejour();
  8892.         $DateDebut $sejour->getDateCreationCode();
  8893.         $DateFin $sejour->getDateFinCode();
  8894.         $pdf->SetFont("Arial"""12);
  8895.         $DateDebutStr = ($DateDebut instanceof \DateTimeInterface) ? $DateDebut->format('d/m/Y') : ((is_string($DateDebut) && $DateDebut !== '') ? (new \DateTime($DateDebut))->format('d/m/Y') : '');
  8896.         $pdf->Text(88242$DateDebutStr);
  8897.         $pdf->SetFont("Arial"""12);
  8898.         $DateFinStr = ($DateFin instanceof \DateTimeInterface) ? $DateFin->format('d/m/Y') : ((is_string($DateFin) && $DateFin !== '') ? (new \DateTime($DateFin))->format('d/m/Y') : '');
  8899.         $pdf->Text(89258$DateFinStr);
  8900.         $pdf->Output("Mode d'emploi Parent 5sur5sejour.pdf""D");
  8901.         return new Response($pdf->Output(), 200, array('Content-Type' => 'application/pdf'));
  8902.     }
  8903.     /**
  8904.      * @Route("/Parent/PdfParentgrat/{id}", name="PdfParentgratt_Parent")
  8905.      */
  8906.     public function ExportPdfParentGratuitParent(Request $request$id)
  8907.     {
  8908.         $sejourservice $this->sejourService;
  8909.         $session $this->session;
  8910.         // RĂ©cupĂ©rer le sĂ©jour pour un parent
  8911.         $sejour $sejourservice->getsejour($id);
  8912.         // VĂ©rifier que le parent a accès Ă  ce sĂ©jour
  8913.         $parentSejour $this->em->getRepository(ParentSejour::class)->findOneBy([
  8914.             'IdParent' => $this->getUser(),
  8915.             'idSejour' => $sejour
  8916.         ]);
  8917.         if (!$parentSejour) {
  8918.             throw $this->createAccessDeniedException('Vous n\'avez pas accès Ă  ce sĂ©jour');
  8919.         }
  8920.         $pdf = new Fpdi();
  8921.         $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  8922.         $pdfFilepath $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5.pdf";
  8923.         $pageCount $pdf->setSourceFile($pdfFilepath);
  8924.         $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  8925.         $pdf->AddPage();
  8926.         $pdf->useImportedPage($pageId00);
  8927.         $pdf->SetFont("Arial"""10);
  8928.         $MotPass $sejour->getCodeSejour();
  8929.         $DateDebut $sejour->getDateCreationCode();
  8930.         $DateFin $sejour->getDateFinCode();
  8931.         $pdf->SetFont("Arial"""12);
  8932.         $DateDebutStr = ($DateDebut instanceof \DateTimeInterface) ? $DateDebut->format('d/m/Y') : ((is_string($DateDebut) && $DateDebut !== '') ? (new \DateTime($DateDebut))->format('d/m/Y') : '');
  8933.         $pdf->Text(87237$DateDebutStr);
  8934.         $pdf->SetFont("Arial"""12);
  8935.         $DateFinStr = ($DateFin instanceof \DateTimeInterface) ? $DateFin->format('d/m/Y') : ((is_string($DateFin) && $DateFin !== '') ? (new \DateTime($DateFin))->format('d/m/Y') : '');
  8936.         $pdf->Text(88252$DateFinStr);
  8937.         $pdf->Output("Mode d'emploi Parent 5sur5sejour.pdf""D");
  8938.         return new Response($pdf->Output(), 200, array('Content-Type' => 'application/pdf'));
  8939.     }
  8940.     /*** ====================album builder new ============================= */
  8941.     /**
  8942.      * @Route("/Parent/album-builder", name="album_builder", methods={"GET"})
  8943.      */
  8944.     public function albumBuilder(): Response
  8945.     {
  8946.         // Set page menu in session
  8947.         $this->session->set('pageMenu''AlbumSejour');
  8948.         $random true;
  8949.         // Get current user
  8950.         $user $this->getUser();
  8951.         if (!$user) {
  8952.             $this->addFlash('error''You must be logged in to access the album builder.');
  8953.             return $this->redirectToRoute('app_login');
  8954.         }
  8955.         $userId $user->getId();
  8956.         // Get sejour from session
  8957.         $sejourId $this->session->get('Sejour');
  8958.         if (!$sejourId) {
  8959.             $this->addFlash('error''No sejour selected. Please select a sejour first.');
  8960.             return $this->redirectToRoute('parent_dashboard');
  8961.         }
  8962.         // Get sejour details
  8963.         $sejour $this->sejourService->getsejourpourparent($sejourId);
  8964.         if (!$sejour) {
  8965.             $this->addFlash('error''Sejour not found.');
  8966.             return $this->redirectToRoute('parent_dashboard');
  8967.         }
  8968.         // Get partner information
  8969.         $partner $sejour->getIdPartenaire();
  8970.         $partnerName $partner $partner->getUsername() : null;
  8971.         $partnerLogo $partner $partner->getLogourl() : null;
  8972.         // Get liked photos for this user and sejour
  8973.         // These are Likephoto entities with SejourAttachment relationships
  8974.         $likedPhotos $this->sejourService->getlikephotosejour($userId$sejourId);
  8975.         $nbLikes count($likedPhotos);
  8976.         // Get all photos for this sejour (for statistics)
  8977.         $allPhotos $this->sejourService->getCombinedattachSejour($sejourId'photo');
  8978.         $totalPhotos count($allPhotos);
  8979.         // Transform liked photos into format expected by template
  8980.         $likedPhotosFormatted = [];
  8981.         foreach ($likedPhotos as $likePhoto) {
  8982.             // Extract the actual SejourAttachment from the Likephoto entity
  8983.             $attachment $likePhoto->getIdSejourAttchment();
  8984.             if ($attachment) {
  8985.                 $likedPhotosFormatted[] = [
  8986.                     'id' => $attachment->getId(),
  8987.                     'path' => $this->getAttachmentPath($attachment),
  8988.                     'nom' => $this->getAttachmentName($attachment),
  8989.                 ];
  8990.             }
  8991.         }
  8992.         // Check if user has no liked photos
  8993.         if ($nbLikes === 0) {
  8994.             $this->addFlash('warning''You haven\'t liked any photos yet. Like some photos first to add them to your album!');
  8995.         }
  8996.         // Get existing album if any (check pathpdf for saved JSON data)
  8997.         $existingAlbum $this->em->getRepository(Produit::class)->findOneBy([
  8998.             'idsjour' => $sejourId,
  8999.             'iduser' => $userId,
  9000.             'labele' => 'album',
  9001.             'statut' => 'saved'
  9002.         ], ['id' => 'DESC']);
  9003.         // Load existing album data if available
  9004.         $existingAlbumData null;
  9005.         if ($existingAlbum && $existingAlbum->getPathpdf()) {
  9006.             $decodedData json_decode($existingAlbum->getPathpdf(), true);
  9007.             if ($decodedData && isset($decodedData['pages'])) {
  9008.                 $existingAlbumData $decodedData;
  9009.             }
  9010.         }
  9011.         return $this->render('Parent/album_builder.html.twig', [
  9012.             'sejour' => $sejour,
  9013.             'sejourId' => $sejourId,
  9014.             'partnerName' => $partnerName,
  9015.             'partnerLogo' => $partnerLogo,
  9016.             'likedPhotos' => $likedPhotosFormatted,
  9017.             'like' => $likedPhotos,
  9018.             'totalPhotos' => $totalPhotos,
  9019.             'nbLikes' => $nbLikes,
  9020.             'existingAlbum' => $existingAlbum,
  9021.             'existingAlbumData' => $existingAlbumData// Pass the decoded data
  9022.         ]);
  9023.     }
  9024.     /**
  9025.      * @Route("/Parent/album/save", name="album_save", methods={"POST"})
  9026.      */
  9027.     public function saveAlbum(Request $request): JsonResponse
  9028.     {
  9029.         try {
  9030.             // Get current user
  9031.             $user $this->getUser();
  9032.             if (!$user) {
  9033.                 return new JsonResponse([
  9034.                     'success' => false,
  9035.                     'message' => 'You must be logged in to save an album.'
  9036.                 ], Response::HTTP_UNAUTHORIZED);
  9037.             }
  9038.             $userId $user->getId();
  9039.             // Get JSON data from request
  9040.             $data json_decode($request->getContent(), true);
  9041.             if (!$data || !isset($data['sejourId']) || !isset($data['pages'])) {
  9042.                 return new JsonResponse([
  9043.                     'success' => false,
  9044.                     'message' => 'Invalid data format.'
  9045.                 ], Response::HTTP_BAD_REQUEST);
  9046.             }
  9047.             $sejourId $data['sejourId'];
  9048.             $pages $data['pages'];
  9049.             // Get sejour
  9050.             $sejour $this->sejourService->getsejourpourparent($sejourId);
  9051.             if (!$sejour) {
  9052.                 return new JsonResponse([
  9053.                     'success' => false,
  9054.                     'message' => 'Sejour not found.'
  9055.                 ], Response::HTTP_NOT_FOUND);
  9056.             }
  9057.             // Check if album already exists
  9058.             $album $this->em->getRepository(Produit::class)->findOneBy([
  9059.                 'idsjour' => $sejourId,
  9060.                 'iduser' => $userId,
  9061.                 'labele' => 'album',
  9062.                 'statut' => 'saved'
  9063.             ]);
  9064.             // Create new album if doesn't exist
  9065.             if (!$album) {
  9066.                 $album = new Produit();
  9067.                 $album->setIdsjour($sejour);
  9068.                 $album->setIduser($user);
  9069.                 $album->setLabele('Album du sĂ©jour');
  9070.                 $album->setStatut('Album_sejour');
  9071.                 $album->setDate(new \DateTime());
  9072.                 $album->setType($this->em->getRepository(TypeProduit::class)->findOneBy(['id' => 2]));
  9073.                 $album->setIdConditionnement($this->em->getRepository(TypeProduitConditionnement::class)->findOneBy(['id' => 2]));
  9074.             } else {
  9075.                 // Update modification date if album exists
  9076.                 $album->setDate(new \DateTime());
  9077.             }
  9078.             // Store album pages as JSON in the pathpdf field (reusing existing field)
  9079.             // This allows us to save complex album data without adding new columns
  9080.             $albumJsonData json_encode([
  9081.                 'sejourId' => $sejourId,
  9082.                 'pages' => $pages,
  9083.                 'savedAt' => (new \DateTime())->format('Y-m-d H:i:s'),
  9084.                 'version' => '2.0' // New album builder version
  9085.             ]);
  9086.             $album->setPathpdf($albumJsonData);
  9087.             $this->em->getManager()->persist($album);
  9088.             $this->em->getManager()->flush();
  9089.             return new JsonResponse([
  9090.                 'success' => true,
  9091.                 'message' => 'Album saved successfully!',
  9092.                 'albumId' => $album->getId()
  9093.             ]);
  9094.         } catch (\Exception $e) {
  9095.             return new JsonResponse([
  9096.                 'success' => false,
  9097.                 'message' => 'An error occurred while saving the album: ' $e->getMessage()
  9098.             ], Response::HTTP_INTERNAL_SERVER_ERROR);
  9099.         }
  9100.     }
  9101.     /**
  9102.      * Get the path for a SejourAttachment
  9103.      * Update this method based on your SejourAttachment entity structure
  9104.      */
  9105.     private function getAttachmentPath($attachment): string
  9106.     {
  9107.         // Common patterns for SejourAttachment - adjust based on your entity:
  9108.         // Option 1: If attachment has a getCheminphoto() method:
  9109.         if (method_exists($attachment'getCheminphoto')) {
  9110.             return $attachment->getCheminphoto();
  9111.         }
  9112.         // Option 2: If attachment has a getPath() method:
  9113.         if (method_exists($attachment'getPath')) {
  9114.             return $attachment->getPath();
  9115.         }
  9116.         // Option 3: If attachment has a getUrl() method:
  9117.         if (method_exists($attachment'getUrl')) {
  9118.             return $attachment->getUrl();
  9119.         }
  9120.         // Option 4: If you need to build the path from filename:
  9121.         if (method_exists($attachment'getFilename')) {
  9122.             return '/uploads/sejours/' $attachment->getFilename();
  9123.         }
  9124.         // Option 5: If attachment has a getCheminfichier() method:
  9125.         if (method_exists($attachment'getCheminfichier')) {
  9126.             return $attachment->getCheminfichier();
  9127.         }
  9128.         // Fallback
  9129.         return '/uploads/photos/default.jpg';
  9130.     }
  9131.     /**
  9132.      * Get the name/label for a SejourAttachment
  9133.      * Update this method based on your SejourAttachment entity structure
  9134.      */
  9135.     private function getAttachmentName($attachment): string
  9136.     {
  9137.         // Try different common method names
  9138.         if (method_exists($attachment'getNom')) {
  9139.             return $attachment->getNom() ?? 'Photo ' $attachment->getId();
  9140.         }
  9141.         if (method_exists($attachment'getLibele')) {
  9142.             return $attachment->getLibele() ?? 'Photo ' $attachment->getId();
  9143.         }
  9144.         if (method_exists($attachment'getFilename')) {
  9145.             return $attachment->getFilename() ?? 'Photo ' $attachment->getId();
  9146.         }
  9147.         if (method_exists($attachment'getLabel')) {
  9148.             return $attachment->getLabel() ?? 'Photo ' $attachment->getId();
  9149.         }
  9150.         // Fallback
  9151.         return 'Photo ' . ($attachment->getId() ?? 'unknown');
  9152.     }
  9153.     /**
  9154.      * View a saved album (read-only by default, with edit mode toggle)
  9155.      * 
  9156.      * @Route("/Parent/album/{id}", name="album_view", methods={"GET"})
  9157.      */
  9158.     public function viewAlbum(int $id): Response
  9159.     {
  9160.         // Check authentication
  9161.         $user $this->getUser();
  9162.         if (!$user) {
  9163.             $this->addFlash('error''You must be logged in to view albums.');
  9164.             return $this->redirectToRoute('app_login');
  9165.         }
  9166.         // Find album and verify ownership
  9167.         $album $this->em->getRepository(Produit::class)->findOneBy([
  9168.             'id' => $id,
  9169.             'iduser' => $user->getId()
  9170.         ]);
  9171.         if (!$album) {
  9172.             $this->addFlash('error''Album not found or you do not have permission to view it.');
  9173.             return $this->redirectToRoute('parent_dashboard');
  9174.         }
  9175.         // Load album data from pathpdf field (stored as JSON)
  9176.         $albumJsonData $album->getPathpdf();
  9177.         $albumData null;
  9178.         $hasContent false;
  9179.         if ($albumJsonData) {
  9180.             $decodedData json_decode($albumJsonDatatrue);
  9181.             if ($decodedData && isset($decodedData['pages'])) {
  9182.                 $albumData $decodedData;
  9183.                 // Check if album has any content
  9184.                 $hasContent false;
  9185.                 foreach ($decodedData['pages'] as $page) {
  9186.                     if (!empty($page['photos']) || !empty($page['topText']) || !empty($page['bottomText'])) {
  9187.                         $hasContent true;
  9188.                         break;
  9189.                     }
  9190.                 }
  9191.             }
  9192.         }
  9193.         // If album is empty, show a message
  9194.         if (!$hasContent) {
  9195.             $this->addFlash('info''This album is empty. Click "Edit Album" to add photos.');
  9196.         }
  9197.         return $this->render('Parent/album_view.html.twig', [
  9198.             'album' => $album,
  9199.             'albumData' => $albumData,
  9200.             'hasContent' => $hasContent,
  9201.         ]);
  9202.     }
  9203.     /**
  9204.      * View album in builder/edit mode (alternative route if you want separate edit page)
  9205.      * 
  9206.      * @Route("/Parent/album/{id}/edit", name="album_edit", methods={"GET"})
  9207.      */
  9208.     public function editAlbum(int $id): Response
  9209.     {
  9210.         // Check authentication
  9211.         $user $this->getUser();
  9212.         if (!$user) {
  9213.             $this->addFlash('error''You must be logged in to edit albums.');
  9214.             return $this->redirectToRoute('app_login');
  9215.         }
  9216.         // Find album and verify ownership
  9217.         $album $this->em->getRepository(Produit::class)->findOneBy([
  9218.             'id' => $id,
  9219.             'iduser' => $user->getId()
  9220.         ]);
  9221.         if (!$album) {
  9222.             $this->addFlash('error''Album not found or you do not have permission to edit it.');
  9223.             return $this->redirectToRoute('parent_dashboard');
  9224.         }
  9225.         // Get the sejour (trip) associated with this album to load liked photos
  9226.         $sejour $album->getIdSejour(); // Assuming relationship exists
  9227.         if (!$sejour) {
  9228.             $this->addFlash('error''Cannot edit album: associated trip not found.');
  9229.             return $this->redirectToRoute('parent_dashboard');
  9230.         }
  9231.         // Load liked photos for this sejour
  9232.         $likedPhotos $this->em->getRepository(\App\Entity\Like::class)->findBy([
  9233.             'idSejour' => $sejour,
  9234.             'idUser' => $user
  9235.         ]);
  9236.         // Load existing album data
  9237.         $albumJsonData $album->getPathpdf();
  9238.         $existingAlbumData null;
  9239.         if ($albumJsonData) {
  9240.             $decodedData json_decode($albumJsonDatatrue);
  9241.             if ($decodedData && isset($decodedData['pages'])) {
  9242.                 $existingAlbumData $decodedData;
  9243.             }
  9244.         }
  9245.         // Render the album builder with edit mode enabled
  9246.         return $this->render('parent/album_builder.html.twig', [
  9247.             'sejour' => $sejour,
  9248.             'sejourId' => $sejour->getId(),
  9249.             'like' => $likedPhotos,
  9250.             'totalPhotos' => count($likedPhotos),
  9251.             'existingAlbum' => $album,
  9252.             'existingAlbumData' => $existingAlbumData,
  9253.             'editMode' => true// Flag to indicate we're editing an existing album
  9254.         ]);
  9255.     }
  9256.     /**
  9257.      * Delete an album
  9258.      * 
  9259.      * @Route("/Parent/album/{id}/delete", name="album_delete", methods={"POST"})
  9260.      */
  9261.     public function deleteAlbum(int $id): Response
  9262.     {
  9263.         // Check authentication
  9264.         $user $this->getUser();
  9265.         if (!$user) {
  9266.             $this->addFlash('error''You must be logged in to delete albums.');
  9267.             return $this->redirectToRoute('app_login');
  9268.         }
  9269.         // Find album and verify ownership
  9270.         $album $this->em->getRepository(Produit::class)->findOneBy([
  9271.             'id' => $id,
  9272.             'iduser' => $user->getId()
  9273.         ]);
  9274.         if (!$album) {
  9275.             $this->addFlash('error''Album not found or you do not have permission to delete it.');
  9276.             return $this->redirectToRoute('parent_dashboard');
  9277.         }
  9278.         try {
  9279.             $albumName $album->getNom();
  9280.             $this->em->remove($album);
  9281.             $this->em->flush();
  9282.             $this->addFlash('success'"Album '{$albumName}' has been deleted successfully.");
  9283.         } catch (\Exception $e) {
  9284.             $this->addFlash('error''An error occurred while deleting the album. Please try again.');
  9285.         }
  9286.         return $this->redirectToRoute('parent_dashboard');
  9287.     }
  9288.     /**=====================================Livre============================================***/
  9289.     /**
  9290.      * @Route("/Parent/livre-builder", name="livre_builder", methods={"GET"})
  9291.      */
  9292.     public function livreBuilder(): Response
  9293.     {
  9294.         // Set page menu in session
  9295.         $this->session->set('pageMenu''LivreSejour');
  9296.         $random true;
  9297.         // Get current user
  9298.         $user $this->getUser();
  9299.         if (!$user) {
  9300.             $this->addFlash('error''You must be logged in to access the livre builder.');
  9301.             return $this->redirectToRoute('app_login');
  9302.         }
  9303.         $userId $user->getId();
  9304.         // Get sejour from session
  9305.         $sejourId $this->session->get('Sejour');
  9306.         if (!$sejourId) {
  9307.             $this->addFlash('error''No sejour selected. Please select a sejour first.');
  9308.             return $this->redirectToRoute('parent_dashboard');
  9309.         }
  9310.         // Get sejour details
  9311.         $sejour $this->sejourService->getsejourpourparent($sejourId);
  9312.         if (!$sejour) {
  9313.             $this->addFlash('error''Sejour not found.');
  9314.             return $this->redirectToRoute('parent_dashboard');
  9315.         }
  9316.         // Get partner information
  9317.         $partner $sejour->getIdPartenaire();
  9318.         $partnerName $partner $partner->getUsername() : null;
  9319.         $partnerLogo $partner $partner->getLogourl() : null;
  9320.         // Get liked photos for this user and sejour
  9321.         // These are Likephoto entities with SejourAttachment relationships
  9322.         $likedPhotos $this->sejourService->getlikephotosejour($userId$sejourId);
  9323.         $nbLikes count($likedPhotos);
  9324.         // Get all photos for this sejour (for statistics)
  9325.         $allPhotos $this->sejourService->getCombinedattachSejour($sejourId'photo');
  9326.         $totalPhotos count($allPhotos);
  9327.         // Transform liked photos into format expected by template
  9328.         $likedPhotosFormatted = [];
  9329.         foreach ($likedPhotos as $likePhoto) {
  9330.             // Extract the actual SejourAttachment from the Likephoto entity
  9331.             $attachment $likePhoto->getIdSejourAttchment();
  9332.             if ($attachment) {
  9333.                 $likedPhotosFormatted[] = [
  9334.                     'id' => $attachment->getId(),
  9335.                     'path' => $this->getAttachmentPath($attachment),
  9336.                     'nom' => $this->getAttachmentName($attachment),
  9337.                 ];
  9338.             }
  9339.         }
  9340.         // Check if user has no liked photos
  9341.         if ($nbLikes === 0) {
  9342.             $this->addFlash('warning''You haven\'t liked any photos yet. Like some photos first to add them to your livre!');
  9343.         }
  9344.         // Check if livre already exists
  9345.         $existingLivre $this->em->getRepository(Produit::class)->findOneBy([
  9346.             'idsjour' => $sejourId,
  9347.             'iduser' => $userId,
  9348.             'labele' => 'livre',
  9349.             'statut' => 'saved'
  9350.         ], ['id' => 'DESC']);
  9351.         // Load existing livre data if available
  9352.         $existingLivreData null;
  9353.         if ($existingLivre && $existingLivre->getPathpdf()) {
  9354.             $decodedData json_decode($existingLivre->getPathpdf(), true);
  9355.             if ($decodedData && isset($decodedData['pages'])) {
  9356.                 $existingLivreData $decodedData;
  9357.             }
  9358.         }
  9359.         return $this->render('Parent/livre_builder.html.twig', [
  9360.             'sejour' => $sejour,
  9361.             'sejourId' => $sejourId,
  9362.             'partnerName' => $partnerName,
  9363.             'partnerLogo' => $partnerLogo,
  9364.             'likedPhotos' => $likedPhotosFormatted,
  9365.             'like' => $likedPhotos,
  9366.             'totalPhotos' => $totalPhotos,
  9367.             'nbLikes' => $nbLikes,
  9368.             'existingLivre' => $existingLivre,
  9369.             'existingLivreData' => $existingLivreData,
  9370.         ]);
  9371.     }
  9372.     /**
  9373.      * @Route("/Parent/livre/save", name="livre_save", methods={"POST"})
  9374.      */
  9375.     public function saveLivre(Request $request): JsonResponse
  9376.     {
  9377.         try {
  9378.             // Get current user
  9379.             $user $this->getUser();
  9380.             if (!$user) {
  9381.                 return new JsonResponse([
  9382.                     'success' => false,
  9383.                     'message' => 'You must be logged in to save a livre.'
  9384.                 ], Response::HTTP_UNAUTHORIZED);
  9385.             }
  9386.             $userId $user->getId();
  9387.             // Get JSON data from request
  9388.             $data json_decode($request->getContent(), true);
  9389.             if (!$data || !isset($data['sejourId']) || !isset($data['pages'])) {
  9390.                 return new JsonResponse([
  9391.                     'success' => false,
  9392.                     'message' => 'Invalid data format.'
  9393.                 ], Response::HTTP_BAD_REQUEST);
  9394.             }
  9395.             $sejourId $data['sejourId'];
  9396.             $pages $data['pages'];
  9397.             // Get sejour
  9398.             $sejour $this->sejourService->getsejourpourparent($sejourId);
  9399.             if (!$sejour) {
  9400.                 return new JsonResponse([
  9401.                     'success' => false,
  9402.                     'message' => 'Sejour not found.'
  9403.                 ], Response::HTTP_NOT_FOUND);
  9404.             }
  9405.             // Check if livre already exists
  9406.             $livre $this->em->getRepository(Produit::class)->findOneBy([
  9407.                 'idsjour' => $sejourId,
  9408.                 'iduser' => $userId,
  9409.                 'labele' => 'livre',
  9410.                 'statut' => 'saved'
  9411.             ]);
  9412.             // Create new livre if doesn't exist
  9413.             if (!$livre) {
  9414.                 $livre = new Produit();
  9415.                 $livre->setIdsjour($sejour);
  9416.                 $livre->setIduser($user);
  9417.                 $livre->setLabele('livre');
  9418.                 $livre->setStatut('saved');
  9419.                 $livre->setDate(new \DateTime());
  9420.                 $livre->setType($this->em->getRepository(TypeProduit::class)->findOneBy(['id' => 4]));
  9421.                 $livre->setIdConditionnement($this->em->getRepository(TypeProduitConditionnement::class)->findOneBy(['id' => 5]));
  9422.             } else {
  9423.                 // Update modification date if livre exists
  9424.                 $livre->setDate(new \DateTime());
  9425.             }
  9426.             // Store livre pages as JSON in the pathpdf field (reusing existing field)
  9427.             // This allows us to save complex livre data without adding new columns
  9428.             $livreJsonData json_encode([
  9429.                 'sejourId' => $sejourId,
  9430.                 'pages' => $pages,
  9431.                 'savedAt' => (new \DateTime())->format('Y-m-d H:i:s'),
  9432.                 'version' => '2.0' // New livre builder version
  9433.             ]);
  9434.             $livre->setPathpdf($livreJsonData);
  9435.             $this->em->getManager()->persist($livre);
  9436.             $this->em->getManager()->flush();
  9437.             return new JsonResponse([
  9438.                 'success' => true,
  9439.                 'message' => 'Livre saved successfully!',
  9440.                 'livreId' => $livre->getId()
  9441.             ]);
  9442.         } catch (\Exception $e) {
  9443.             return new JsonResponse([
  9444.                 'success' => false,
  9445.                 'message' => 'An error occurred while saving the livre: ' $e->getMessage()
  9446.             ], Response::HTTP_INTERNAL_SERVER_ERROR);
  9447.         }
  9448.     }
  9449. }