src/Controller/EspaceParentController.php line 11085

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\AlbumParticipation;
  36. use App\Entity\Attachment;
  37. use App\Service\EmailsCmdService;
  38. use App\Entity\TypeProduitConditionnement;
  39. use App\Service\AttachementService;
  40. use App\Service\CarteService;
  41. use App\Service\ComandeService;
  42. use App\Service\EtablissementService;
  43. use App\Service\PayementService;
  44. use App\Service\PhotosFavorisService;
  45. use App\Service\SejourService;
  46. use App\Service\TypeProduiteService;
  47. use App\Service\UserService;
  48. use Doctrine\Persistence\ManagerRegistry;
  49. use Psr\Log\LoggerInterface;
  50. use Qipsius\TCPDFBundle\Controller\TCPDFController;
  51. use SebastianBergmann\Environment\Console;
  52. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  53. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  54. use Symfony\Component\HttpFoundation\Request;
  55. use Symfony\Component\HttpFoundation\Response;
  56. use Symfony\Component\Routing\Annotation\Route;
  57. use Symfony\Component\HttpFoundation\JsonResponse;
  58. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  59. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  60. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  61. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  62. use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
  63. use setasign\Fpdi\Fpdi;
  64. use setasign\Fpdi\PdfReader;
  65. class EspaceParentController extends AbstractController
  66. {
  67.     private $em;
  68.     private $session;
  69.     private $templating;
  70.     private $mailer;
  71.     private $symfonyMailer;
  72.     private $EmailServie;
  73.     private $urlGenerator;
  74.     private $commandeService;
  75.     private $printerService;
  76.     private $emailsCmdService;
  77.     private $userService;
  78.     private $typeProduiteService;
  79.     private $sejourService;
  80.     private $attachementService;
  81.     private $etablissementService;
  82.     private $payementService;
  83.     private $carteService;
  84.     private $photosFavorisService;
  85.     private $params;
  86.     private $tcpdf;
  87.     private $logger;
  88.     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)
  89.     {
  90.         $this->em $em;
  91.         $this->session $session;
  92.         $this->templating $templating;
  93.         $this->mailer $mailer;
  94.         $this->symfonyMailer $symfonyMailer;
  95.         $this->EmailServie $EmailCommandeService;
  96.         $this->urlGenerator $urlGenerator;
  97.         $this->commandeService $commandeService;
  98.         $this->emailsCmdService $emailsCmdService;
  99.         $this->userService $userService;
  100.         $this->typeProduiteService $typeProduiteService;
  101.         $this->sejourService $sejourService;
  102.         $this->attachementService $attachementService;
  103.         $this->etablissementService $etablissementService;
  104.         $this->payementService $payementService;
  105.         $this->carteService $carteService;
  106.         $this->photosFavorisService $photosFavorisService;
  107.         $this->params $params;
  108.         $this->tcpdf $tcpdf;
  109.         $this->logger $logger;
  110.         $this->printerService $printerService;
  111.     }
  112.     /**
  113.      * Calcule albumAcc pour un séjour (même logique que headerparenrt pour le menu "Album du séjour").
  114.      * Utilisé par DetailsSejour (bannière) et partout où on doit afficher la même condition que le header.
  115.      */
  116.     private function getAlbumAccForSejour(Sejour $sejour): ?Produit
  117.     {
  118.         $em $this->em;
  119.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['statut' => 'Album_sejour''idsjour' => $sejour], ['id' => 'DESC']);
  120.         return $albumAcc;
  121.     }
  122.     /**
  123.      * Retourne les données pour le composant AlbumCollectiveCard (séjours EF uniquement).
  124.      */
  125.     private function getAlbumCollectiveData(Sejour $sejourint $photosCountint $likesTotal): array
  126.     {
  127.         $codePrefix substr($sejour->getCodeSejour() ?? ''02);
  128.         if ($codePrefix !== 'EF') {
  129.             return ['showCollectiveCard' => false];
  130.         }
  131.         $shouldShow = ($photosCount >= 15 || $likesTotal >= 30);
  132.         if (!$shouldShow) {
  133.             return ['showCollectiveCard' => false];
  134.         }
  135.         /** @var \App\Repository\AlbumParticipationRepository $partRepo */
  136.         $partRepo $this->em->getRepository(AlbumParticipation::class);
  137.         $participantsCount $partRepo->countParticipants($sejour);
  138.         $goalCount 20;
  139.         $displayCount max(5$participantsCount);
  140.         $progressPercent min(100round(($displayCount $goalCount) * 100));
  141.         return [
  142.             'showCollectiveCard' => true,
  143.             'collectiveParticipants' => $displayCount,
  144.             'collectiveGoal' => $goalCount,
  145.             'collectiveProgress' => $progressPercent,
  146.             'sejourId' => $sejour->getId(),
  147.         ];
  148.     }
  149.     /**
  150.      * @Route("/Parent/CreerAlbumSejourTest", name="CreerAlbumSejourTest")
  151.      */
  152.     public function CreerAlbumSejourTest(Request $request)
  153.     {
  154.         $serviceuser $this->etablissementService;
  155.         $page $request->get("pages");
  156.         $idsejour $request->get("id_du_sejour");
  157.         $prodid $request->get('idProd');
  158.         $nomprod $request->get('nomprod');
  159.         $stat $request->get('stat');
  160.         $version $request->get('new');
  161.         $user $this->getUser();
  162.         $Album $serviceuser->savealbumAcc($page$user$idsejour$prodid$stat$nomprod$version);
  163.         //Envoi des mails aux parents 
  164.         // Envoi SMS aux parents 
  165.         // Envoi mail proposition achat groupé au accompagnateur 
  166.         //YOSRA HERE
  167.         $PrentsConnextees $this->em->getRepository(ParentSejour::class)->findBy(array('idSejour' =>  $idsejour));
  168.         dd($PrentsConnextees);
  169.         return new response('done');
  170.     }
  171.     /**
  172.      * @Route("/Parent/DirectAchatAlbumm", name="DirectAchatAlbumm")
  173.      */
  174.     public function DirectAchatAlbumm(Request $request)
  175.     {
  176.         $session $this->session;
  177.         $serviceuser $this->etablissementService;
  178.         $page $request->get("pages");
  179.         $sejour $request->get("sejour");
  180.         $prodid $request->get('idProd');
  181.         $nomprod $request->get('nomprod');
  182.         $versionalbm $request->get('new');
  183.         $user $this->getUser();
  184.         $dateNow = new \Datetime();
  185.         $produit $session->get("produittype");
  186.         $produitcondi $session->get("produit");
  187.         $Album $serviceuser->savealbumParent($page$user$sejour$prodid$produit$produitcondi$nomprod$versionalbm);
  188.         $inser false;
  189.         $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  190.         $em $this->em;
  191.         $user $this->getUser();
  192.         $typeref $em->getRepository(Typeref::class)->find(8);
  193.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "achatdirect""typeref" => $typeref));
  194.         $panierTrace = new Panier();
  195.         $dateNow = new \Datetime();
  196.         $panierTrace->setDateCreation($dateNow);
  197.         $panierTrace->setCreerPar($user);
  198.         $panierTrace->setStatut($statutPanier);
  199.         $em->getManager()->persist($panierTrace);
  200.         $em->getManager()->flush();
  201.         $panierProduit = new PanierProduit();
  202.         $panierProduit->setIdProduit($Album);
  203.         $panierProduit->setIdPanier($panierTrace);
  204.         $em->getManager()->persist($panierProduit);
  205.         $em->getManager()->flush();
  206.         $panierProduit->setQuantite(1);
  207.         $panierProduit->setPrixTotal($Album->getIdConditionnement()->getMontantTTC());
  208.         $this->em->getManager()->persist($panierProduit);
  209.         $this->em->getManager()->flush();
  210.         return new response('achat direct done');
  211.     }
  212.     /**
  213.      * @Route("/Parent/Achat_direct", name="Achat_direct")
  214.      */
  215.     public function Achat_direct()
  216.     {
  217.         $em $this->em;
  218.         $session $this->session;
  219.         $idSejour $session->get("Sejour");
  220.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  221.         $typeref $em->getRepository(Typeref::class)->find(8);
  222.         $user $this->getUser();
  223.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "achatdirect""typeref" => $typeref));
  224.         $panier $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  225.         return $this->render('Parent/achatdirect.html.twig', ["user" => $user"sejour" => $sejour"panier" => $panier]);
  226.     }
  227.     /**
  228.      * @Route("/Parent/AccueilParent", name="AccueilParent")
  229.      */
  230.     public function AccueilParent(Request $requestLoggerInterface $loggerInterface): Response
  231.     {
  232.         $session $this->session;
  233.         /** @var \App\Entity\User $user */
  234.         $user $this->getUser();
  235.         $userId $user->getId();
  236.         $code $request->get("codeSejour");
  237.         $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  238.         if (isset($code)) {
  239.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  240.             if ($sejour == null) {
  241.                 $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  242.                 if ($sejour == null) {
  243.                     $this->session->set('rout''code');
  244.                     return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  245.                 }
  246.             } else {
  247.                 $this->session->set('Sejour'$sejour->getId());
  248.             }
  249.         }
  250.         if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
  251.             $code $session->get("Sejour");
  252.             $sejour $this->em->getRepository(Sejour::class)->find($code);
  253.         } else {
  254.             $code $request->get("codeSejour");
  255.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  256.         }
  257.         if ($sejour == null) {
  258.             $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  259.         }
  260.         if ($sejour == null) {
  261.             $this->session->set('rout''code');
  262.             return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  263.         }
  264.         // Fermer l'accès si la date de fin de code est atteinte (séjour expiré)
  265.         $dateFinCode $sejour->getDateFinCode();
  266.         if ($dateFinCode !== null) {
  267.             $dateStr $dateFinCode->format('Y-m-d');
  268.             $finCode = new \DateTimeImmutable($dateStr ' 23:59:59', new \DateTimeZone('Europe/Paris'));
  269.             $today = new \DateTimeImmutable('now', new \DateTimeZone('Europe/Paris'));
  270.             if ($today $finCode) {
  271.                 $this->session->remove('Sejour');
  272.                 return $this->render('Parent/SejourDepassee.html.twig', ['codeSejour' => $sejour->getCodeSejour()]);
  273.             }
  274.         }
  275.         // Vérifier le statut du séjour - statut 43 = en attente de paiement/activation
  276.         // IMPORTANT : Cette vérification s'applique à TOUS les codes (PF, PP, EP, EF)
  277.         // Même les codes gratuits (PF/EF) ne peuvent pas accéder si le séjour n'est pas activé
  278.         if ($sejour->getStatut() && $sejour->getStatut()->getId() == 43) {
  279.             return $this->render('Parent/SejourEnAttentePaiement.html.twig', [
  280.                 'sejour' => $sejour
  281.             ]);
  282.         }
  283.         $idSejour $sejour->getId();
  284.         $SEjourService $this->sejourService;
  285.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  286.         $this->session->set('Sejour'$idSejour);
  287.         // Double vérification date fin code (si non déjà faite plus tôt)
  288.         $dateFinCode $sejour->getDateFinCode();
  289.         if ($dateFinCode !== null) {
  290.             $dateStr $dateFinCode->format('Y-m-d');
  291.             $finCode = new \DateTimeImmutable($dateStr ' 23:59:59', new \DateTimeZone('Europe/Paris'));
  292.             $today = new \DateTimeImmutable('now', new \DateTimeZone('Europe/Paris'));
  293.             if ($today $finCode) {
  294.                 $this->session->remove('Sejour');
  295.                 return $this->render('Parent/SejourDepassee.html.twig', ['codeSejour' => $sejour->getCodeSejour()]);
  296.             }
  297.         }
  298.         $session->set('pageMenu''MonSejour');
  299.         $AllAttachements $SEjourService->getphotosVideosSejour($idSejour'watermark'$userId);
  300.         $nbImages count($AllAttachements);
  301.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  302.         $positions $SEjourService->getsejourposition($idSejour);
  303.         $em $this->em;
  304.         $idAcc $sejour->getIdAcommp();
  305.         $albumAcc $this->getAlbumAccForSejour($sejour);
  306.         $label "Livre_sejour" $sejour->getCodeSejour();
  307.         $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  308.         if ($livreSej == null) {
  309.             $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  310.         } else {
  311.             $livreSejour $livreSej;
  312.         }
  313.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  314.         if ($parentsejour == NULL) {
  315.             $parentsejour $SEjourService->inserparentsejour($userId$idSejour);
  316.         }
  317.         if ($AllAttachements == null && $messages == null) {
  318.             $this->session->set('rout''rout');
  319.             return $this->render('Parent/Aucunphoto.html.twig', [
  320.                 "sejour" => $sejour,
  321.                 "parentsejour" => $parentsejour
  322.             ]);
  323.         } else {
  324.             $attachementsCount $AllAttachements['total'];
  325.             unset($AllAttachements['total']);
  326.             // Déterminer le type de code (PF = gratuit, PP/EP = payant)
  327.             $codePrefix substr($sejour->getCodeSejour(), 02);
  328.             $isFreeAccess = ($codePrefix === 'PF' || $codePrefix === 'EF' || $sejour->getPaym() == 0);
  329.             
  330.             // PF et EF : accès direct (gratuit)
  331.             // PP et EP : nécessitent un paiement
  332.             if ($isFreeAccess) {
  333.                 $produits $this->typeProduiteService;
  334.                 $liste $produits->produitlistTypeConditionnement();
  335.                 $pubProd $user->getShowpubprod();
  336.                 $em $this->em;
  337.                 $idAcc $sejour->getIdAcommp();
  338.                 $nbmessages count($messages);
  339.                 $nblikes =  count($listeattachlikephoto);
  340.                 $collectiveData $this->getAlbumCollectiveData($sejour$attachementsCount$nblikes);
  341.                 return $this->render('Parent/DetailsSejour.html.twig'array_merge([
  342.                     "sejour" => $sejour,
  343.                     'albumAcc' => $albumAcc,
  344.                     'favoritesCount' => $nblikes,
  345.                     "livreSejour" => $livreSejour,
  346.                     'listeattach' => $AllAttachements,
  347.                     'nbmessages' => $nbmessages,
  348.                     'attachementsCount' => $attachementsCount,
  349.                     'prod' => $liste,
  350.                     'nbImages' => $nbImages,
  351.                     'positions' => $positions,
  352.                     'messages' => $messages,
  353.                     'nblikes' => $nblikes,
  354.                     'likes' => $listeattachlikephoto,
  355.                     "parentsejour" => $parentsejour,
  356.                     'smsnotif' => $parentsejour->getSmsnotif(),
  357.                     'showpub' => $pubProd
  358.                 ], $collectiveData));
  359.             }
  360.             
  361.             // PP ou EP : vérifier le paiement
  362.             if ($codePrefix === 'PP' || $codePrefix === 'EP') {
  363.                 if ($parentsejour->getPayment() == 0) {
  364.                     $this->session->set('rout''rout');
  365.                     $ses_id session_id();
  366.                     return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  367.                 }
  368.                 if ($parentsejour->getPayment() == 1) {
  369.                     $produits $this->typeProduiteService;
  370.                     $liste $produits->produitlistTypeConditionnement();
  371.                     $pubProd $user->getShowpubprod();
  372.                     $nblikes count($listeattachlikephoto);
  373.                     $collectiveData $this->getAlbumCollectiveData($sejour$attachementsCount$nblikes);
  374.                     return $this->render('Parent/DetailsSejour.html.twig'array_merge([
  375.                         "sejour" => $sejour,
  376.                         'favoritesCount' => $nblikes,
  377.                         'listeattach' => $AllAttachements,
  378.                         'attachementsCount' => $attachementsCount,
  379.                         'prod' => $liste,
  380.                         'albumAcc' => $albumAcc,
  381.                         "livreSejour" => $livreSejour,
  382.                         'nbImages' => $nbImages,
  383.                         'positions' => $positions,
  384.                         'messages' => $messages,
  385.                         'nblikes' => $nblikes,
  386.                         'likes' => $listeattachlikephoto,
  387.                         "parentsejour" => $parentsejour,
  388.                         'smsnotif' => $parentsejour->getSmsnotif(),
  389.                         'showpub' => $pubProd
  390.                     ], $collectiveData));
  391.                 }
  392.             }
  393.         }
  394.     }
  395.     /**
  396.      * @Route("/Parent/MessagesVocaux", name="MessagesVocaux")
  397.      */
  398.     public function MessagesVocaux_Accueil(Request $requestLoggerInterface $loggerInterface): Response
  399.     {
  400.         $session $this->session;
  401.         $session->set('pageMenu''MessagesVocaux');
  402.         /** @var \App\Entity\User $user */
  403.         $user $this->getUser();
  404.         $userId $user->getId();
  405.         $code $request->get("codeSejour");
  406.         $SEjourService $this->sejourService;
  407.         if (isset($code)) {
  408.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  409.             if ($sejour == null) {
  410.                 $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  411.                 if ($sejour == null) {
  412.                     $this->session->set('rout''code');
  413.                     return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  414.                 }
  415.             } else {
  416.                 $this->session->set('Sejour'$sejour->getId());
  417.             }
  418.         }
  419.         if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
  420.             $code $session->get("Sejour");
  421.             $sejour $this->em->getRepository(Sejour::class)->find($code);
  422.         } else {
  423.             $code $request->get("codeSejour");
  424.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  425.         }
  426.         if ($sejour == null) {
  427.             $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  428.         }
  429.         if ($sejour == null) {
  430.             $this->session->set('rout''code');
  431.             return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  432.         }
  433.         $idSejour $sejour->getId();
  434.         $this->session->set('Sejour'$idSejour);
  435.         $dateCreationArch = clone $sejour->getDateFinCode();
  436.         if ($dateCreationArch <= new \DateTime()) {
  437.             return $this->render('Parent/SejourDepassee.html.twig');
  438.         }
  439.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  440.         $nbImages count($AllAttachements);
  441.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  442.         $positions $SEjourService->getsejourposition($idSejour);
  443.         $albumAcc $this->getAlbumAccForSejour($sejour);
  444.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  445.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  446.         if ($parentsejour == NULL) {
  447.             $parentsejour $SEjourService->inserparentsejour($userId$idSejour);
  448.         }
  449.         if ($AllAttachements == null && $messages == null) {
  450.             $this->session->set('rout''rout');
  451.             return $this->render('Parent/Aucunphoto.html.twig', [
  452.                 "sejour" => $sejour,
  453.                 "parentsejour" => $parentsejour
  454.             ]);
  455.         } else {
  456.             $attachementsCount $AllAttachements['total'];
  457.             unset($AllAttachements['total']);
  458.             // Déterminer le type de code (PF = gratuit, PP/EP = payant)
  459.             $codePrefix substr($sejour->getCodeSejour(), 02);
  460.             $isFreeAccess = ($codePrefix === 'PF' || $codePrefix === 'EF' || $sejour->getPaym() == 0);
  461.             
  462.             // PF et EF : accès direct (gratuit)
  463.             if ($isFreeAccess) {
  464.                 $produits $this->typeProduiteService;
  465.                 $liste $produits->produitlistTypeConditionnement();
  466.                 $pubProd $user->getShowpubprod();
  467.                 $nblikes count($listeattachlikephoto);
  468.                 $collectiveData $this->getAlbumCollectiveData($sejour$attachementsCount$nblikes);
  469.                 return $this->render('Parent/DetailsSejour.html.twig'array_merge([
  470.                     "sejour" => $sejour,
  471.                     'albumAcc' =>  $albumAcc,
  472.                     'listeattach' => $AllAttachements,
  473.                     'attachementsCount' => $attachementsCount,
  474.                     'prod' => $liste,
  475.                     'nblikes' => $nblikes,
  476.                     'likes' => $listeattachlikephoto,
  477.                     'nbImages' => $nbImages,
  478.                     'positions' => $positions,
  479.                     'messages' => $messages,
  480.                     'like' => $listeattachlikephoto,
  481.                     "parentsejour" => $parentsejour,
  482.                     'smsnotif' => $parentsejour->getSmsnotif(),
  483.                     'showpub' => $pubProd
  484.                 ], $collectiveData));
  485.             }
  486.             
  487.             // PP ou EP : vérifier le paiement
  488.             if ($codePrefix === 'PP' || $codePrefix === 'EP') {
  489.                 if ($parentsejour->getPayment() == 0) {
  490.                     $this->session->set('rout''rout');
  491.                     $ses_id session_id();
  492.                     return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  493.                 }
  494.                 if ($parentsejour->getPayment() == 1) {
  495.                     $produits $this->typeProduiteService;
  496.                     $liste $produits->produitlistTypeConditionnement();
  497.                     $pubProd $user->getShowpubprod();
  498.                     $nblikes count($listeattachlikephoto);
  499.                     $collectiveData $this->getAlbumCollectiveData($sejour$attachementsCount$nblikes);
  500.                     return $this->render('Parent/DetailsSejour.html.twig'array_merge([
  501.                         "sejour" => $sejour,
  502.                         'favoritesCount' => $nblikes,
  503.                         'listeattach' => $AllAttachements,
  504.                         'attachementsCount' => $attachementsCount,
  505.                         'prod' => $liste,
  506.                         'nblikes' => $nblikes,
  507.                         'likes' => $listeattachlikephoto,
  508.                         'nbImages' => $nbImages,
  509.                         'albumAcc' =>  $albumAcc,
  510.                         'positions' => $positions,
  511.                         'messages' => $messages,
  512.                         'like' => $listeattachlikephoto,
  513.                         "parentsejour" => $parentsejour,
  514.                         'smsnotif' => $parentsejour->getSmsnotif(),
  515.                         'showpub' => $pubProd
  516.                     ], $collectiveData));
  517.                 }
  518.             }
  519.         }
  520.     }
  521.     /**
  522.      * @Route("/Parent/MesFavoris_Accueil", name="MesFavoris_Accueil")
  523.      */
  524.     public function MesFavoris_Accueil(Request $requestLoggerInterface $loggerInterface): Response
  525.     {
  526.         $session $this->session;
  527.         $session->set('pageMenu''MesFavoris');
  528.         /** @var \App\Entity\User $user */
  529.         $user $this->getUser();
  530.         $userId $user->getId();
  531.         $code $request->get("codeSejour");
  532.         $SEjourService $this->sejourService;
  533.         if (isset($code)) {
  534.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  535.             if ($sejour == null) {
  536.                 $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  537.                 if ($sejour == null) {
  538.                     $this->session->set('rout''code');
  539.                     return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  540.                 }
  541.             } else {
  542.                 $this->session->set('Sejour'$sejour->getId());
  543.             }
  544.         }
  545.         if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
  546.             $code $session->get("Sejour");
  547.             $sejour $this->em->getRepository(Sejour::class)->find($code);
  548.         } else {
  549.             $code $request->get("codeSejour");
  550.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  551.         }
  552.         if ($sejour == null) {
  553.             $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  554.         }
  555.         if ($sejour == null) {
  556.             $this->session->set('rout''code');
  557.             return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  558.         }
  559.         $idSejour $sejour->getId();
  560.         $this->session->set('Sejour'$idSejour);
  561.         $dateCreationArch = clone $sejour->getDateFinCode();
  562.         $em $this->em;
  563.         $idAcc $sejour->getIdAcommp();
  564.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['statut' => 'Album_sejour''idsjour' => $sejour], ['id' => 'DESC']);
  565.         $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  566.         if ($dateCreationArch <= new \DateTime()) {
  567.             return $this->render('Parent/SejourDepassee.html.twig');
  568.         }
  569.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  570.         $nbImages count($AllAttachements);
  571.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  572.         $positions $SEjourService->getsejourposition($idSejour);
  573.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  574.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  575.         if ($parentsejour == NULL) {
  576.             $parentsejour $SEjourService->inserparentsejour($userId$idSejour);
  577.         }
  578.         if ($AllAttachements == null && $messages == null) {
  579.             $this->session->set('rout''rout');
  580.             return $this->render('Parent/Aucunphoto.html.twig', [
  581.                 "sejour" => $sejour,
  582.                 "parentsejour" => $parentsejour
  583.             ]);
  584.         } else {
  585.             $attachementsCount $AllAttachements['total'];
  586.             unset($AllAttachements['total']);
  587.             // Déterminer le type de code (PF = gratuit, PP/EP = payant)
  588.             $codePrefix substr($sejour->getCodeSejour(), 02);
  589.             $isFreeAccess = ($codePrefix === 'PF' || $codePrefix === 'EF' || $sejour->getPaym() == 0);
  590.             
  591.             // PF et EF : accès direct (gratuit)
  592.             if ($isFreeAccess) {
  593.                 $produits $this->typeProduiteService;
  594.                 $liste $produits->produitlistTypeConditionnement();
  595.                 $pubProd $user->getShowpubprod();
  596.                 $em $this->em;
  597.                 $idAcc $sejour->getIdAcommp();
  598.                 $label "Livre_sejour" $sejour->getCodeSejour();
  599.                 $albumAcc $this->getAlbumAccForSejour($sejour);
  600.                 $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  601.                 if ($livreSej == null) {
  602.                     $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  603.                 } else {
  604.                     $livreSejour $livreSej;
  605.                 }
  606.                 $nblikes count($listeattachlikephoto);
  607.                 $collectiveData $this->getAlbumCollectiveData($sejour$attachementsCount$nblikes);
  608.                 return $this->render('Parent/DetailsSejour.html.twig'array_merge([
  609.                     "sejour" => $sejour,
  610.                     "livreSejour" => $livreSejour,
  611.                     'listeattach' => $AllAttachements,
  612.                     'attachementsCount' => $attachementsCount,
  613.                     'prod' => $liste,
  614.                     'nblikes' => $nblikes,
  615.                     'likes' => $listeattachlikephoto,
  616.                     'nbImages' => $nbImages,
  617.                     'positions' => $positions,
  618.                     'messages' => $messages,
  619.                     'like' => $listeattachlikephoto,
  620.                     "parentsejour" => $parentsejour,
  621.                     'smsnotif' => $parentsejour->getSmsnotif(),
  622.                     'showpub' => $pubProd,
  623.                     'albumAcc' => $albumAcc,
  624.                 ], $collectiveData));
  625.             }
  626.             
  627.             // PP ou EP : vérifier le paiement
  628.             if ($codePrefix === 'PP' || $codePrefix === 'EP') {
  629.                 if ($parentsejour->getPayment() == 0) {
  630.                     $this->session->set('rout''rout');
  631.                     $ses_id session_id();
  632.                     return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  633.                 }
  634.                 if ($parentsejour->getPayment() == 1) {
  635.                     $produits $this->typeProduiteService;
  636.                     $liste $produits->produitlistTypeConditionnement();
  637.                     $pubProd $user->getShowpubprod();
  638.                     $albumAcc $this->getAlbumAccForSejour($sejour);
  639.                     $nblikes2 count($listeattachlikephoto);
  640.                     $collectiveData $this->getAlbumCollectiveData($sejour$attachementsCount$nblikes2);
  641.                     return $this->render('Parent/DetailsSejour.html.twig'array_merge([
  642.                         "sejour" => $sejour,
  643.                         'albumAcc' => $albumAcc,
  644.                         'favoritesCount' => $nblikes2,
  645.                         'nblikes' => $nblikes2,
  646.                         'likes' => $listeattachlikephoto,
  647.                         'listeattach' => $AllAttachements,
  648.                         'attachementsCount' => $attachementsCount,
  649.                         'prod' => $liste,
  650.                         'nbImages' => $nbImages,
  651.                         'positions' => $positions,
  652.                         'messages' => $messages,
  653.                         'like' => $listeattachlikephoto,
  654.                         "parentsejour" => $parentsejour,
  655.                         'smsnotif' => $parentsejour->getSmsnotif(),
  656.                         'showpub' => $pubProd
  657.                     ], $collectiveData));
  658.                 }
  659.             }
  660.         }
  661.     }
  662.     /**
  663.      * @Route("/Parent/DetailsSejour", name="DetailsSejour")
  664.      */
  665.     public function ModifierSejour()
  666.     {
  667.         $SEjourService $this->sejourService;
  668.         $sejour $SEjourService->getsejour(3);
  669.         $listeattach $SEjourService->getatachmentsejour(3);
  670.         $positions $SEjourService->getsejourposition(3);
  671.         $messages $SEjourService->getsejourmessage(3);
  672.         //dd($messages);
  673.         $produits $this->typeProduiteService;
  674.         $liste $produits->produitlistTypeConditionnement();
  675.         return $this->render('Parent/DetailsSejour.html.twig', [
  676.             'prod' => $liste,
  677.             'sejour' => $sejour,
  678.             'listeattach' => $listeattach,
  679.             'positions' => $positions,
  680.             'messages' => $messages,
  681.         ]);
  682.     }
  683.     /**
  684.      * @Route("/Parent/listefavorie", name="listefavorie")
  685.      */
  686.     public function listefavorie()
  687.     {
  688.         $SEjourService $this->sejourService;
  689.         /** @var \App\Entity\User $user */
  690.         $user $this->getUser();
  691.         $userId $user->getId();
  692.         $session $this->session;
  693.         $session->set('pageMenu''');
  694.         $idSejour $session->get("Sejour");
  695.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  696.         dd($listeattachlikephoto);
  697.         return ('yoopii');
  698.     }
  699.     /**
  700.      * @Route("/Parent/Store", name="boutique5sur5")
  701.      */
  702.     public function boutique5sur5()
  703.     {
  704.         $SEjourService $this->sejourService;
  705.         /** @var \App\Entity\User $userId */
  706.         $userId $this->getUser();
  707.         $userId $userId->getId();
  708.         $session $this->session;
  709.         $session->set('pageMenu''boutique5su5');
  710.         $idSejour $session->get("Sejour");
  711.         $sejour $SEjourService->getsejourpourparent($idSejour);
  712.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  713.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  714.         $messages $SEjourService->getsejourmessage($idSejour);
  715.         $nbImages count($listeattach);
  716.         $nbmessages count($messages);
  717.         $produit $this->typeProduiteService;
  718.         $liste $produit->produitlistTypeConditionnement();
  719.         $idAcc $sejour->getIdAcommp();
  720.         $em $this->em;
  721.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  722.         $nbLikes count($listeattachlikephoto);
  723.         // dd($liste);
  724.         return $this->render('Parent/boutique_5sur5.html.twig', [
  725.             "sejour" => $sejour,
  726.             'like' => $listeattachlikephoto,
  727.             'produit' => $liste,
  728.             'albumAcc' => $albumAcc,
  729.             'nbImages' => $nbImages,
  730.             'nbmessages' => $nbmessages,
  731.             'nbLikes' => $nbLikes
  732.         ]);
  733.     }
  734.     /*public function maSelection()
  735.     {
  736.         $SEjourService = $this->sejourService;
  737.         $user = $this->getUser();        
  738.         $userId = $user->getId();
  739.         $user = $this->getUser();
  740.         $session = $this->session;
  741.         $session->set('pageMenu', '');
  742.         $idSejour = $session->get("Sejour");
  743.         $sejour = $SEjourService->getsejourpourparent($idSejour);
  744.         $listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
  745.         $produit = $this->typeProduiteService;
  746.         $liste = $produit->produitlistTypeConditionnement();
  747.         $idAcc = $sejour->getIdAcommp();
  748.         $em = $this->em;
  749.         $albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
  750.         // dd($liste);
  751.         return $this->render('Parent/VoirMaSelection.html.twig', [
  752.             "sejour" => $sejour,
  753.             'like' => $listeattachlikephoto, 'produit' => $liste, 'albumAcc' => $albumAcc
  754.         ]);
  755.     }*/
  756.     /**
  757.      * @Route("/Parent/MaSelection", name="maSelection")
  758.      */
  759.     public function maSelection()
  760.     {
  761.         //Yosra
  762.         $nbLikes 0;
  763.         $SEjourService $this->sejourService;
  764.         $session $this->session;
  765.         $session->set('pageMenu''Meselection');
  766.         $idSejour $session->get("Sejour");
  767.         /** @var \App\Entity\User $user */
  768.         $user $this->getUser();
  769.         $iduser $user->getId();
  770.         $SEjourService $this->sejourService;
  771.         $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  772.         $sejour $SEjourService->getsejour($idSejour);
  773.         $positions $SEjourService->getsejourposition($idSejour);
  774.         //$messages = $SEjourService->getsejourmessage($idSejour);
  775.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  776.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  777.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  778.         $nbLikes count($listeattachlikephoto);
  779.         /* $listeattach = $SEjourService->getatachmentsejour($idSejour);
  780.         $listeVideo = $SEjourService->getVideosejour($idSejour);
  781.         $AllAttachements = array_merge_recursive($listeattach, $listeVideo); */
  782.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  783.         $attachementsCount $AllAttachements['total'];
  784.         unset($AllAttachements['total']);
  785.         $produits $this->typeProduiteService;
  786.         $liste $produits->produitlistTypeConditionnement();
  787.         $pubProd $user->getShowpubprod();
  788.         $albumAcc $this->getAlbumAccForSejour($sejour);
  789.         $collectiveData $this->getAlbumCollectiveData($sejour$attachementsCount$nbLikes);
  790.         return $this->render('Parent/DetailsSejour.html.twig'array_merge([
  791.             "sejour" => $sejour,
  792.             'albumAcc' => $albumAcc,
  793.             "listeattach" => $AllAttachements,
  794.             'attachementsCount' => $attachementsCount,
  795.             'positions' => $positions,
  796.             'messages' => $messages,
  797.             'likes' => $listeattachlikephoto,
  798.             'like' => $listeattachlikephoto,
  799.             'nblikes' => $nbLikes,
  800.             'nbImages' =>   $attachementsCount,
  801.             "parentsejour" => $parentsejour,
  802.             'prod' => $liste,
  803.             'smsnotif' => $parentsejour->getSmsnotif(),
  804.             'showpub' => $pubProd
  805.         ], $collectiveData));
  806.     }
  807.     /**
  808.      * @Route("/Parent/MesPhotosPerso", name="mesPhotosperso")
  809.      */
  810.     public function mesPhotosperso()
  811.     {  //Yosra
  812.         $SEjourService $this->sejourService;
  813.         $session $this->session;
  814.         $session->set('pageMenu''Meselection');
  815.         $idSejour $session->get("Sejour");
  816.         /** @var \App\Entity\User $user */
  817.         $user $this->getUser();
  818.         $iduser $user->getId();
  819.         $SEjourService $this->sejourService;
  820.         $sejour $SEjourService->getsejour($idSejour);
  821.         $positions $SEjourService->getsejourposition($idSejour);
  822.         $messages $SEjourService->getsejourmessage($idSejour);
  823.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  824.         $listeattachlikephoto $this->em->getRepository(SejourAttachment::class)->findBy(['idParent' => $iduser'statut' => "private"'idSejour' => $sejour]);
  825.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  826.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  827.         $listeVideo $SEjourService->getVideosejour($idSejour);
  828.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  829.         $attachementsCount count($listeattach);
  830.         $nbImages count($listeattachlikephoto);
  831.         $produits $this->typeProduiteService;
  832.         $liste $produits->produitlistTypeConditionnement();
  833.         return $this->render('Parent/MesPhotosPerso.html.twig', [
  834.             "sejour" => $sejour,
  835.             'attachementsCount' => $attachementsCount,
  836.             'listeattach' => $AllAttachements,
  837.             'positions' => $positions,
  838.             'nbImages' => $nbImages,
  839.             'messages' => $messages,
  840.             'likes' => $listeattachlikephoto,
  841.             "parentsejour" => $parentsejour,
  842.             'prod' => $liste,
  843.             'smsnotif' => $parentsejour->getSmsnotif()
  844.         ]);
  845.     }
  846.     /**
  847.      * @Route("/Parent/achatBoiteVocale", name="achatBoiteVocale")
  848.      */
  849.     public function achatBoiteVocale()
  850.     {
  851.         $this->session->set('rout''rout');
  852.         $session $this->session;
  853.         /** @var \App\Entity\User $user */
  854.         $user $this->getUser();
  855.         $iduser $user->getId();
  856.         $idSejour $session->get("Sejour");
  857.         $ses_id session_id();
  858.         $SEjourService $this->sejourService;
  859.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  860.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  861.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  862.         return $this->render('Parent/achatBoiteVocale.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  863.     }
  864.     /**
  865.      * @Route("/Parent/achatsejour", name="achatsejour")
  866.      */
  867.     public function achatsejour()
  868.     {
  869.         $this->session->set('rout''rout');
  870.         $session $this->session;
  871.         /** @var \App\Entity\User $user */
  872.         $user $this->getUser();
  873.         $iduser $user->getId();
  874.         $idSejour $session->get("Sejour");
  875.         $ses_id session_id();
  876.         $SEjourService $this->sejourService;
  877.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  878.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  879.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  880.         return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  881.     }
  882.     /**
  883.      * @Route("/Parent/CodeSejour", name="CodeSejour")
  884.      */
  885.     public function CodeSejour()
  886.     {
  887.         /** @var \App\Entity\User $user */
  888.         $user $this->getUser();
  889.         $userId $user->getId();
  890.         $this->session->set('rout''code');
  891.         return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 0'smsnotif' => $user->getSmsnotif()]);
  892.     }
  893.     /** @Route("/Parent/produits", name="produit_parent")
  894.      */
  895.     public function produitsparent()
  896.     {
  897.         $SEjourService $this->sejourService;
  898.         $produitparent $this->typeProduiteService;
  899.         /** @var \App\Entity\User $user */
  900.         $user $this->getUser();
  901.         $userId $user->getId();
  902.         $session $this->session;
  903.         $session->set('pageMenu''');
  904.         $idSejour $session->get("Sejour");
  905.         $listproduit $produitparent->produitparent();
  906.         return ('yoopii');
  907.     }
  908.     /**
  909.      * @Route("/Parent/AucunePhoto", name="AucunePhoto")
  910.      * */
  911.     public function premiercnx()
  912.     {
  913.         $this->session->set('rout''rout');
  914.         return $this->render('Parent/Aucunphoto.html.twig');
  915.     }
  916.     /**
  917.      * @Route("/Parent/notif", name="notif_parent",methods={"POST","GET"})
  918.      */
  919.     public function notif_parent(Request $request)
  920.     {
  921.         $UserService $this->userService;
  922.         $session $this->session;
  923.         $session->set('pageMenu''');
  924.         $idSejour $session->get("Sejour");
  925.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  926.         /** @var \App\Entity\User $user */
  927.         $user $this->getUser();
  928.         $iduser $user->getId();
  929.         $sms $request->get("sms");
  930.         $mail $request->get('mail');
  931.         $refaverti $request->get('refaverti');
  932.         //$ville = $request->get("nonnotif");
  933.         $parentsejour $UserService->notifparentsejour($mail$sms$idSejour$iduser$refaverti);
  934.         return new JsonResponse('done');
  935.     }
  936.     /**
  937.      * @Route("/Parent/passerconnxion", name="notif_parenpasserconnxion",methods={"POST","GET"})
  938.      */
  939.     public function passerconnxion(Request $request)
  940.     {
  941.         $UserService $this->userService;
  942.         $session $this->session;
  943.         $session->set('pageMenu''');
  944.         $idSejour $session->get("Sejour");
  945.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  946.         /** @var \App\Entity\User $user */
  947.         $user $this->getUser();
  948.         $iduser $user->getId();
  949.         $SEjourService $this->sejourService;
  950.         $setparentsejour $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  951.         $sejour $SEjourService->getsejour($idSejour);
  952.         $positions $SEjourService->getsejourposition($idSejour);
  953.         $messages $SEjourService->getsejourmessage($idSejour);
  954.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  955.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  956.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  957.         if (sizeof($sejour->getAttachements()) == 0) {
  958.             return new JsonResponse('0');
  959.         } else {
  960.             return new JsonResponse('1');
  961.         }
  962.     }
  963.     /**
  964.      * @Route("/Parent/sejourParent", name="sejourParent_5sur5")
  965.      * */
  966.     public function sejourParent()
  967.     {
  968.         $SEjourService $this->sejourService;
  969.         $UserService $this->userService;
  970.         $session $this->session;
  971.         $session->set('pageMenu''');
  972.         $idSejour $session->get("Sejour");
  973.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  974.         /** @var \App\Entity\User $user */
  975.         $user $this->getUser();
  976.         $iduser $user->getId();
  977.         $SEjourService $this->sejourService;
  978.         $setparentsejour $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  979.         $sejour $SEjourService->getsejour($idSejour);
  980.         $positions $SEjourService->getsejourposition($idSejour);
  981.         $messages $SEjourService->getsejourmessage($idSejour);
  982.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  983.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  984.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  985.         $nbImages count($listeattach);
  986.         $listeVideo $SEjourService->getVideosejour($idSejour);
  987.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  988.         $produits $this->typeProduiteService;
  989.         $liste $produits->produitlistTypeConditionnement();
  990.         $pubProd $user->getShowpubprod();
  991.         $albumAcc $this->getAlbumAccForSejour($sejour);
  992.         return $this->render('Parent/DetailsSejour.html.twig', [
  993.             "sejour" => $sejour,
  994.             'albumAcc' => $albumAcc,
  995.             'listeattach' => $AllAttachements,
  996.             'positions' => $positions,
  997.             'nbImages' => $nbImages,
  998.             'messages' => $messages,
  999.             'like' => $listeattachlikephoto,
  1000.             "parentsejour" => $parentsejour,
  1001.             'prod' => $liste,
  1002.             'smsnotif' => $parentsejour->getSmsnotif(),
  1003.             'showpub' => $pubProd
  1004.         ]);
  1005.     }
  1006.     /**
  1007.      * @Route("/Parent/sejourVide", name="sejourvideee")
  1008.      * */
  1009.     public function sejourvide()
  1010.     {
  1011.         $this->session->set('rout''code');
  1012.         $SEjourService $this->sejourService;
  1013.         $UserService $this->userService;
  1014.         $session $this->session;
  1015.         $session->set('pageMenu''');
  1016.         $idSejour $session->get("Sejour");
  1017.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  1018.         /** @var \App\Entity\User $user */
  1019.         $user $this->getUser();
  1020.         $iduser $user->getId();
  1021.         $SEjourService $this->sejourService;
  1022.         $setparentsejour $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  1023.         $sejour $SEjourService->getsejour($idSejour);
  1024.         $positions $SEjourService->getsejourposition($idSejour);
  1025.         $messages $SEjourService->getsejourmessage($idSejour);
  1026.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  1027.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  1028.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  1029.         return $this->render('Parent/Aucunphoto.html.twig', [
  1030.             "sejour" => $sejour,
  1031.             "parentsejour" => $parentsejour
  1032.         ]);
  1033.     }
  1034.     /**
  1035.      * @Route("Parent/EditContenuPage", name="EditContenuPage")
  1036.      */
  1037.     public function EditContenuPageParent()
  1038.     {
  1039.         $em $this->em;
  1040.         $Albumproduct $em->getRepository(Produit::class)->findBy(['idConditionnement' => 4]);
  1041.         foreach ($Albumproduct as $album) {
  1042.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $album]);
  1043.             foreach ($AllPages as $p) {
  1044.                 $arrayexploded $p->getCouleurbordure();
  1045.                 $arrayexploded1 str_replace("font-size""fontSize"$arrayexploded);
  1046.                 $p->setCouleurbordure($arrayexploded1);
  1047.                 $em->getManager()->persist($p);
  1048.                 $em->getManager()->flush();
  1049.             }
  1050.         }
  1051.         return new Response('ok');
  1052.     }
  1053.     /**
  1054.      * @Route("Parent/AjoutAlbum", name="EditionAlbum")
  1055.      */
  1056.     public function EditionAlbumParent()
  1057.     {
  1058.         $SEjourService $this->sejourService;
  1059.         $em $this->em;
  1060.         /** @var \App\Entity\User $user */
  1061.         $user $this->getUser();
  1062.         $userId $user->getId();
  1063.         $session $this->session;
  1064.         $session->set('pageMenu''AlbumSejour');
  1065.         $idSejour $session->get("Sejour");
  1066.         $clipart null;
  1067.         $random true;
  1068.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1069.         $idAcc $sejour->getIdAcommp();
  1070.         $part $sejour->getIdPartenaire();
  1071.         $nompart $part->getUsername();
  1072.         $logopart $part->getLogourl();
  1073.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1074.         $nbLikes count($listeattachlikephoto);
  1075.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1076.         $listerandom $listeattach;
  1077.         $nbPhoto count($listeattach);
  1078.         $AllPagesAcc null;
  1079.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
  1080.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1081.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1082.         if ($albumAcc) {
  1083.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1084.         }
  1085.         $allpagesResult = array();
  1086.         $tabacc = array();
  1087.         $tabacc1 = array();
  1088.         if ($random == true) {
  1089.             foreach ($AllPages as $p) {
  1090.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1091.                 $rr "";
  1092.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1093.                     if ($i sizeof($arrayexploded)) {
  1094.                         if (sizeof($listerandom) == 0) {
  1095.                             //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  1096.                             $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  1097.                         }
  1098.                         if ($nbLikes != 0) {
  1099.                             $listerandom $SEjourService->getlikephotosejour($userId$idSejour);
  1100.                             $arrayRsRandom $this->random_function($listerandom);
  1101.                         }
  1102.                         if ($nbLikes == 0) {
  1103.                             $arrayRsRandom $this->random_functionNolikes($listerandom);
  1104.                         }
  1105.                         array_push($tabacc$arrayRsRandom['idelem']);
  1106.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1107.                         unset($listerandom[$arrayRsRandom['elem']]);
  1108.                     } else {
  1109.                         $rr $rr $arrayexploded[$i];
  1110.                     }
  1111.                     $listerandom $listerandom;
  1112.                 }
  1113.                 $resultFinal $rr;
  1114.                 $p->setCouleurbordure($resultFinal);
  1115.                 array_push($allpagesResult$p);
  1116.             }
  1117.             $AllPages $allpagesResult;
  1118.         }
  1119.         $tabacc1 array_count_values($tabacc);
  1120.         if ($nbLikes  == 0) {
  1121.             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]);
  1122.         }
  1123.         if ($nbLikes  != 0) {
  1124.             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]);
  1125.         }
  1126.     }
  1127.     /**
  1128.      * @Route("Parent/AjoutPochettePhotos_Sejour/{nbr}", name="AjoutPochettePhotos_Sejour")
  1129.      */
  1130.     public function AjoutPochettePhotosParent_Sejour($nbr)
  1131.     {
  1132.         $SEjourService $this->sejourService;
  1133.         $userId $this->getUser()->getId();
  1134.         $user $this->getUser();
  1135.         $session $this->get('session');
  1136.         $session->set('pageMenu''');
  1137.         $idSejour $session->get("Sejour");
  1138.         $produitcondition $session->get("produit");
  1139.         $produit $session->get("produittype");
  1140.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1141.         $em $this->getDoctrine()->getManager();
  1142.         $clipart $em->getRepository(Clipart::class)->findAll();
  1143.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1144.         $listerandom =  $listeattach;
  1145.         $AllPagesAcc null;
  1146.         //        $random = false;
  1147.         //        $Albumproduct = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $userId], ['id' => 'DESC']);
  1148.         //        if ($Albumproduct == null || $Albumproduct == "") {
  1149.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1150.         $random true;
  1151.         //        }
  1152.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1153.         $idAcc $sejour->getIdAcommp();
  1154.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1155.         $part $sejour->getIdPartenaire();
  1156.         //$part = $em->getRepository(Etablisment::class)->findOneBy(['id' => $idpart->getId()]);
  1157.         //dd($part);
  1158.         $nompart $part->getUsername();
  1159.         $logopart $part->getLogourl();
  1160.         // dd($Albumproduct);  
  1161.         if ($albumAcc != null and $albumAcc != "") {
  1162.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1163.         }
  1164.         //        dd($albumAcc);
  1165.         $allpagesResult = array();
  1166.         $j 0;
  1167.         if ($random == true) {
  1168.             foreach ($AllPages as $p) {
  1169.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1170.                 //                var_dump($arrayexploded);
  1171.                 $rr "";
  1172.                 $elemPath "";
  1173.                 $elemId "";
  1174.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1175.                     if ($i sizeof($arrayexploded)) {
  1176.                         if (sizeof($listerandom) == 0) {
  1177.                             $listerandom =  $listeattach;
  1178.                         }
  1179.                         $arrayRsRandom $this->random_functionPhotoNolIKES($listerandom$j);
  1180.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1181.                         unset($listerandom[$arrayRsRandom['elem']]);
  1182.                     } else {
  1183.                         $rr $rr $arrayexploded[$i];
  1184.                     }
  1185.                     $listerandom $listerandom;
  1186.                 }
  1187.                 $resultFinal $rr;
  1188.                 $p->setCouleurbordure($resultFinal);
  1189.                 array_push($allpagesResult$p);
  1190.                 if ($j sizeof($listeattach) - 1) {
  1191.                     $j $j 1;
  1192.                 } else {
  1193.                     $j 0;
  1194.                 }
  1195.             }
  1196.             $AllPages $allpagesResult;
  1197.         }
  1198.         // die();
  1199.         $nbAttach count($listeattach);
  1200.         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]);
  1201.     }
  1202.     /**
  1203.      * @Route("Parent/AjoutPochettePhotos_Fav/{nbr}", name="AjoutPochettePhotos_Favoris")
  1204.      */
  1205.     public function EnregistrerPochettePhoto($nbr)
  1206.     {
  1207.         $SEjourService $this->sejourService;
  1208.         $user $this->getUser();
  1209.         $userId $this->getUser()->getId();
  1210.         $session $this->get('session');
  1211.         $session->set('pageMenu''');
  1212.         $idSejour $session->get("Sejour");
  1213.         $produitcondition $session->get("produit");
  1214.         $produit $session->get("produittype");
  1215.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1216.         $em $this->getDoctrine()->getManager();
  1217.         $clipart $em->getRepository(Clipart::class)->findAll();
  1218.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1219.         $listerandom $listeattachlikephoto;
  1220.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1221.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1222.         $allpagesResult = array();
  1223.         $j 0;
  1224.         foreach ($AllPages as $p) {
  1225.             $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1226.             //                var_dump($arrayexploded);
  1227.             $rr "";
  1228.             $elemPath "";
  1229.             $elemId "";
  1230.             for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1231.                 if ($i sizeof($arrayexploded)) {
  1232.                     if (sizeof($listerandom) == 0) {
  1233.                         $listerandom $listeattachlikephoto;
  1234.                     }
  1235.                     $arrayRsRandom $this->random_functionPhoto($listerandom);
  1236.                     $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1237.                     unset($listerandom[$arrayRsRandom['elem']]);
  1238.                 } else {
  1239.                     $rr $rr $arrayexploded[$i];
  1240.                 }
  1241.                 $listerandom $listerandom;
  1242.             }
  1243.             $resultFinal $rr;
  1244.             $p->setCouleurbordure($resultFinal);
  1245.             array_push($allpagesResult$p);
  1246.             if ($j sizeof($listeattachlikephoto) - 1) {
  1247.                 $j $j 1;
  1248.             } else {
  1249.                 $j 0;
  1250.             }
  1251.         }
  1252.         $AllPages $allpagesResult;
  1253.         // die();
  1254.         return new JsonResponse('done');
  1255.     }
  1256.     /**
  1257.      * @Route("Parent/AjoutPochettePhotos_Fav/{nbr}", name="AjoutPochettePhotos_Favoris")
  1258.      */
  1259.     public function AjoutPochettePhotosParent_Fav($nbr)
  1260.     {
  1261.         $SEjourService $this->sejourService;
  1262.         $user $this->getUser();
  1263.         $userId $this->getUser()->getId();
  1264.         $session $this->get('session');
  1265.         $session->set('pageMenu''');
  1266.         $idSejour $session->get("Sejour");
  1267.         $produitcondition $session->get("produit");
  1268.         $produit $session->get("produittype");
  1269.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1270.         $em $this->getDoctrine()->getManager();
  1271.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' =>  $userId'idSejour' =>  $idSejour]);
  1272.         foreach ($listeattachlikephoto as $photo) {
  1273.             $idattach $photo->getIdSejourAttchment();
  1274.             $SejattachPhoto  $photo->getIdSejourAttchment();
  1275.             $urlPhoto  =   $SejattachPhoto->getIdAttchment()->getPath();
  1276.             //$urlPhoto =   $attachPhoto->getPath();
  1277.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/',  $urlPhoto);
  1278.             $photosData[] = [
  1279.                 'id' => $photo->getId(),
  1280.                 'url' =>    $new_url,
  1281.                 'caption' => "",
  1282.             ];
  1283.         }
  1284.         $nbLikes count($listeattachlikephoto);
  1285.         // Convertir le tableau PHP en JSON
  1286.         $photosDataJSON json_encode($photosData);
  1287.         return $this->render('Parent/PochettePhotosLikes.html.twig', ["nbr" => $nbr"sejour" => $sejour,  "nbLikes" => $nbLikes'photosFav' =>    $photosDataJSON]);
  1288.     }
  1289.     /**
  1290.      * @Route("Parent/AjoutRetroPhotos_Fav/{nbr}", name="AjoutRetroPhotos_Favoris")
  1291.      */
  1292.     public function AjoutRetroPhotosParent_Fav($nbr)
  1293.     {
  1294.         $SEjourService $this->sejourService;
  1295.         $user $this->getUser();
  1296.         $userId $this->getUser()->getId();
  1297.         $session $this->get('session');
  1298.         $session->set('pageMenu''');
  1299.         $idSejour $session->get("Sejour");
  1300.         $produitcondition $session->get("produit");
  1301.         $produit $session->get("produittype");
  1302.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1303.         $em $this->getDoctrine()->getManager();
  1304.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' =>  $userId'idSejour' =>  $idSejour]);
  1305.         foreach ($listeattachlikephoto as $photo) {
  1306.             $idattach $photo->getIdSejourAttchment();
  1307.             $SejattachPhoto  $photo->getIdSejourAttchment();
  1308.             $urlPhoto  =   $SejattachPhoto->getIdAttchment()->getPath();
  1309.             //$urlPhoto =   $attachPhoto->getPath();
  1310.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/',  $urlPhoto);
  1311.             $photosData[] = [
  1312.                 'id' => $photo->getId(),
  1313.                 'url' =>    $new_url,
  1314.                 'caption' => "",
  1315.             ];
  1316.         }
  1317.         $nbLikes count($listeattachlikephoto);
  1318.         // Convertir le tableau PHP en JSON
  1319.         $photosDataJSON json_encode($photosData);
  1320.         return $this->render('Parent/RetroRefonte.html.twig', ["nbr" => $nbr"sejour" => $sejour,  "nbLikes" => $nbLikes'photosFav' =>    $photosDataJSON]);
  1321.     }
  1322.     function random_function($listerandom)
  1323.     {
  1324.         $elem array_rand($listerandom);
  1325.         $photo $listerandom[$elem];
  1326.         $idelem $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1327.         $pathelem $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
  1328.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1329.     }
  1330.     function random_functionNolikes($listerandom)
  1331.     {
  1332.         //dd(array_keys($listerandom));
  1333.         $elem array_rand($listerandom);
  1334.         $photo $listerandom[$elem];
  1335.         $idelem $photo["id"];
  1336.         $pathelem $photo["path"];
  1337.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1338.     }
  1339.     function random_functionPhoto($listerandom)
  1340.     {
  1341.         $elem array_rand($listerandom);
  1342.         $photo $listerandom[$elem];
  1343.         $idelem $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1344.         $pathelem $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
  1345.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1346.     }
  1347.     function random_functionPhotosSejour($listerandom$elem)
  1348.     {
  1349.         $elem array_rand($listerandom);
  1350.         $photo $listerandom[$elem];
  1351.         $idelem $photo->getId();
  1352.         $pathelem $photo->getPath();
  1353.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1354.     }
  1355.     function random_functionPhotoNolIKES($listerandom$elem)
  1356.     {
  1357.         $elem array_rand($listerandom);
  1358.         $photo $listerandom[$elem];
  1359.         $idelem $photo['id'];
  1360.         $pathelem $photo['path'];
  1361.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1362.     }
  1363.     /**
  1364.      * 🚀 Smart Distribution Algorithm BASÉ SUR LES IDS RÉELS DES PHOTOS
  1365.      * Expert PHP Senior Implementation - Garantit l'unicité et la distribution correcte
  1366.      * LIMITE: Max 3 répétitions par photo ID pour éviter la monotonie
  1367.      */
  1368.     private function calculateOptimalDistribution($favoritePhotos$totalSlots)
  1369.     {
  1370.         if (empty($favoritePhotos) || $totalSlots === 0) {
  1371.             return [];
  1372.         }
  1373.         $nbFavorites count($favoritePhotos);
  1374.         $MAX_REPETITIONS 3// 🚀 LIMITE ANTI-MONOTONIE
  1375.         // Extraire les IDs réels des photos pour tracking précis
  1376.         $photoIds = [];
  1377.         foreach ($favoritePhotos as $index => $photo) {
  1378.             if (is_object($photo)) {
  1379.                 $photoIds[$index] = $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1380.             } else {
  1381.                 $photoIds[$index] = $photo['id'];
  1382.             }
  1383.         }
  1384.         $distribution = [];
  1385.         $photoUsageCount = []; // Tracking des utilisations par ID réel
  1386.         if ($nbFavorites >= $totalSlots) {
  1387.             // Plus de favoris que de slots → 1 photo par slot, pas de répétition
  1388.             for ($i 0$i $totalSlots$i++) {
  1389.                 $photoIndex $i $nbFavorites;
  1390.                 $photoId $photoIds[$photoIndex];
  1391.                 $distribution[] = $photoIndex;
  1392.                 $photoUsageCount[$photoId] = ($photoUsageCount[$photoId] ?? 0) + 1;
  1393.             }
  1394.         } else {
  1395.             // 🎯 LOGIQUE SENIOR: Toutes les photos favorites d'abord, puis répétitions contrôlées
  1396.             // Étape 1: GARANTIR que chaque photo favorite apparaît au moins une fois
  1397.             for ($i 0$i $nbFavorites$i++) {
  1398.                 $photoId $photoIds[$i];
  1399.                 $distribution[] = $i;
  1400.                 $photoUsageCount[$photoId] = 1;
  1401.             }
  1402.             // Étape 2: Distribuer les slots restants avec contrôle strict
  1403.             $remainingSlots $totalSlots $nbFavorites;
  1404.             if ($remainingSlots 0) {
  1405.                 // Vérifier si on peut respecter la limite MAX_REPETITIONS
  1406.                 $maxPossibleRepetitions $nbFavorites * ($MAX_REPETITIONS 1);
  1407.                 if ($remainingSlots $maxPossibleRepetitions) {
  1408.                     // Fallback vers distribution mixte
  1409.                     return $this->calculateMixedDistribution($favoritePhotos$totalSlots$MAX_REPETITIONS);
  1410.                 }
  1411.                 // Distribution équitable des répétitions avec contrôle par ID
  1412.                 $slotsToDistribute $remainingSlots;
  1413.                 $round 0;
  1414.                 while ($slotsToDistribute && $round $MAX_REPETITIONS 1) {
  1415.                     for ($i 0$i $nbFavorites && $slotsToDistribute 0$i++) {
  1416.                         $photoId $photoIds[$i];
  1417.                         // Vérifier que cette photo n'a pas atteint la limite
  1418.                         if ($photoUsageCount[$photoId] < $MAX_REPETITIONS) {
  1419.                             $distribution[] = $i;
  1420.                             $photoUsageCount[$photoId]++;
  1421.                             $slotsToDistribute--;
  1422.                         }
  1423.                     }
  1424.                     $round++;
  1425.                 }
  1426.             }
  1427.             // Mélange intelligent préservant la règle "toutes les favorites d'abord"
  1428.             $this->smartShufflePreservingFirst($distribution$nbFavorites);
  1429.         }
  1430.         // 🧪 Validation stricte avec IDs réels
  1431.         if (!$this->validateDistributionWithIds($distribution$photoIds$MAX_REPETITIONS)) {
  1432.             error_log("⚠️ ALGORITHME PHOTO: Distribution invalide détectée avec IDs réels");
  1433.             error_log("Distribution: " json_encode($distribution));
  1434.             error_log("Photo Usage: " json_encode($photoUsageCount));
  1435.         }
  1436.         return $distribution;
  1437.     }
  1438.     /**
  1439.      * Distribution mixte quand il y a trop peu de favoris
  1440.      * Combine favoris + meilleures photos du séjour
  1441.      */
  1442.     private function calculateMixedDistribution($favoritePhotos$totalSlots$maxRepetitions)
  1443.     {
  1444.         if (empty($favoritePhotos)) {
  1445.             // Aucun favori, retourner des marqueurs pour photos du séjour
  1446.             return array_fill(0$totalSlots, -1);
  1447.         }
  1448.         $nbFavorites count($favoritePhotos);
  1449.         $distribution = [];
  1450.         // Extraire les IDs pour tracking
  1451.         $photoIds = [];
  1452.         foreach ($favoritePhotos as $index => $photo) {
  1453.             if (is_object($photo)) {
  1454.                 $photoIds[$index] = $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1455.             } else {
  1456.                 $photoIds[$index] = $photo['id'];
  1457.             }
  1458.         }
  1459.         $photoUsageCount = [];
  1460.         // Étape 1: S'assurer que chaque favori apparaît au moins une fois
  1461.         for ($i 0$i $nbFavorites && count($distribution) < $totalSlots$i++) {
  1462.             $distribution[] = $i;
  1463.             $photoUsageCount[$photoIds[$i]] = 1;
  1464.         }
  1465.         // Étape 2: Ajouter des répétitions jusqu'à la limite
  1466.         $round 1;
  1467.         while (count($distribution) < $totalSlots && $round $maxRepetitions) {
  1468.             for ($i 0$i $nbFavorites && count($distribution) < $totalSlots$i++) {
  1469.                 $photoId $photoIds[$i];
  1470.                 if ($photoUsageCount[$photoId] < $maxRepetitions) {
  1471.                     $distribution[] = $i;
  1472.                     $photoUsageCount[$photoId]++;
  1473.                 }
  1474.             }
  1475.             $round++;
  1476.         }
  1477.         // Étape 3: Compléter avec des marqueurs pour photos du séjour
  1478.         while (count($distribution) < $totalSlots) {
  1479.             $distribution[] = -1// Marqueur pour photo du séjour
  1480.         }
  1481.         // Mélange intelligent en préservant la règle "favoris d'abord"
  1482.         $this->smartShufflePreservingFirst($distribution$nbFavorites);
  1483.         return $distribution;
  1484.     }
  1485.     /**
  1486.      * Mélange intelligent pour éviter les répétitions consécutives
  1487.      */
  1488.     private function smartShuffle(&$distribution$nbFavorites)
  1489.     {
  1490.         $maxAttempts 100;
  1491.         $attempts 0;
  1492.         do {
  1493.             shuffle($distribution);
  1494.             $attempts++;
  1495.             $hasConsecutive false;
  1496.             // Vérifier s'il y a des répétitions consécutives
  1497.             for ($i 1$i count($distribution); $i++) {
  1498.                 if ($distribution[$i] === $distribution[$i 1]) {
  1499.                     $hasConsecutive true;
  1500.                     break;
  1501.                 }
  1502.             }
  1503.             if (!$hasConsecutive) {
  1504.                 break;
  1505.             }
  1506.         } while ($attempts $maxAttempts);
  1507.         // Si on n'arrive pas à éviter toutes les répétitions consécutives,
  1508.         // on fait un arrangement manuel intelligent
  1509.         if ($hasConsecutive && $nbFavorites 1) {
  1510.             $this->manualArrangement($distribution$nbFavorites);
  1511.         }
  1512.     }
  1513.     /**
  1514.      * Mélange intelligent qui préserve l'apparition de toutes les photos favorites d'abord
  1515.      * 🎯 GARANTIT: Toutes les photos favorites apparaissent avant les répétitions
  1516.      */
  1517.     private function smartShufflePreservingFirst(&$distribution$nbFavorites)
  1518.     {
  1519.         if (count($distribution) <= $nbFavorites) {
  1520.             // Si on n'a que les photos favorites, mélange léger
  1521.             shuffle($distribution);
  1522.             return;
  1523.         }
  1524.         // Séparer les premières occurrences des répétitions
  1525.         $firstOccurrences array_slice($distribution0$nbFavorites);
  1526.         $repetitions array_slice($distribution$nbFavorites);
  1527.         // Mélanger légèrement les premières occurrences pour éviter un ordre prévisible
  1528.         shuffle($firstOccurrences);
  1529.         // Mélanger les répétitions
  1530.         shuffle($repetitions);
  1531.         // Recombiner en évitant les répétitions consécutives
  1532.         $distribution $firstOccurrences;
  1533.         // Ajouter les répétitions en évitant les consécutives
  1534.         foreach ($repetitions as $rep) {
  1535.             $lastIndex count($distribution) - 1;
  1536.             $lastUsed $distribution[$lastIndex];
  1537.             if ($rep === $lastUsed) {
  1538.                 // Insérer à une position antérieure pour éviter la consécutive
  1539.                 $insertPos max(0$lastIndex 1);
  1540.                 array_splice($distribution$insertPos0, [$rep]);
  1541.             } else {
  1542.                 $distribution[] = $rep;
  1543.             }
  1544.         }
  1545.     }
  1546.     /**
  1547.      * 🧪 VALIDATION STRICTE BASÉE SUR LES IDS RÉELS DES PHOTOS
  1548.      * Expert PHP Senior - Garantit la distribution correcte
  1549.      */
  1550.     private function validateDistributionWithIds($distribution$photoIds$maxRepetitions)
  1551.     {
  1552.         if (empty($distribution) || empty($photoIds)) {
  1553.             return true;
  1554.         }
  1555.         $nbFavorites count($photoIds);
  1556.         $photoUsageTracking = []; // Tracking par ID réel de photo
  1557.         $photoFirstAppearance = []; // Index de première apparition par ID réel
  1558.         $photoRepetitionStart = []; // Index de première répétition par ID réel
  1559.         // Analyser la distribution
  1560.         foreach ($distribution as $slotIndex => $photoIndex) {
  1561.             if ($photoIndex >= $nbFavorites) {
  1562.                 error_log("⚠️ ERREUR: Index photo invalide $photoIndex >= $nbFavorites");
  1563.                 return false;
  1564.             }
  1565.             $photoId $photoIds[$photoIndex];
  1566.             // Compter les utilisations
  1567.             $photoUsageTracking[$photoId] = ($photoUsageTracking[$photoId] ?? 0) + 1;
  1568.             // Marquer la première apparition
  1569.             if (!isset($photoFirstAppearance[$photoId])) {
  1570.                 $photoFirstAppearance[$photoId] = $slotIndex;
  1571.             } else {
  1572.                 // C'est une répétition - marquer si c'est la première répétition
  1573.                 if (!isset($photoRepetitionStart[$photoId])) {
  1574.                     $photoRepetitionStart[$photoId] = $slotIndex;
  1575.                 }
  1576.             }
  1577.         }
  1578.         // ✅ Vérification 1: Toutes les photos favorites utilisées au moins une fois
  1579.         foreach ($photoIds as $photoId) {
  1580.             if (!isset($photoUsageTracking[$photoId]) || $photoUsageTracking[$photoId] < 1) {
  1581.                 error_log("⚠️ ERREUR: Photo ID $photoId non utilisée");
  1582.                 return false;
  1583.             }
  1584.         }
  1585.         // ✅ Vérification 2: Aucune photo ne dépasse la limite de répétitions
  1586.         foreach ($photoUsageTracking as $photoId => $count) {
  1587.             if ($count $maxRepetitions) {
  1588.                 error_log("⚠️ ERREUR: Photo ID $photoId utilisée $count fois (limite: $maxRepetitions)");
  1589.                 return false;
  1590.             }
  1591.         }
  1592.         // ✅ Vérification 3: Toutes les photos apparaissent avant toute répétition
  1593.         $lastFirstAppearance 0;
  1594.         foreach ($photoFirstAppearance as $photoId => $firstIndex) {
  1595.             $lastFirstAppearance max($lastFirstAppearance$firstIndex);
  1596.         }
  1597.         $earliestRepetition PHP_INT_MAX;
  1598.         foreach ($photoRepetitionStart as $photoId => $repetitionIndex) {
  1599.             $earliestRepetition min($earliestRepetition$repetitionIndex);
  1600.         }
  1601.         if ($earliestRepetition !== PHP_INT_MAX && $earliestRepetition <= $lastFirstAppearance) {
  1602.             error_log("⚠️ ERREUR: Répétition détectée avant que toutes les favorites soient utilisées");
  1603.             error_log("Dernière première apparition: $lastFirstAppearance, Première répétition: $earliestRepetition");
  1604.             return false;
  1605.         }
  1606.         // ✅ Vérification 4: Pas de répétitions consécutives
  1607.         for ($i 1$i count($distribution); $i++) {
  1608.             $currentPhotoId $photoIds[$distribution[$i]];
  1609.             $previousPhotoId $photoIds[$distribution[$i 1]];
  1610.             if ($currentPhotoId === $previousPhotoId) {
  1611.                 error_log("⚠️ WARNING: Répétition consécutive détectée aux positions " . ($i 1) . " et $i pour photo ID $currentPhotoId");
  1612.                 // Note: On continue, ce n'est qu'un warning
  1613.             }
  1614.         }
  1615.         return true;
  1616.     }
  1617.     /**
  1618.      * 🧪 FONCTION DE TEST LEGACY - Conservée pour compatibilité
  1619.      */
  1620.     private function validateDistribution($distribution$nbFavorites)
  1621.     {
  1622.         // Fallback vers la nouvelle validation si possible
  1623.         return !empty($distribution) && $nbFavorites 0;
  1624.     }
  1625.     /**
  1626.      * Arrangement manuel pour minimiser les répétitions consécutives
  1627.      */
  1628.     private function manualArrangement(&$distribution$nbFavorites)
  1629.     {
  1630.         $length count($distribution);
  1631.         for ($i 1$i $length$i++) {
  1632.             if ($distribution[$i] === $distribution[$i 1]) {
  1633.                 // Chercher une position différente à échanger
  1634.                 for ($j $i 1$j $length$j++) {
  1635.                     if (
  1636.                         $distribution[$j] !== $distribution[$i 1] &&
  1637.                         ($j === $length || $distribution[$j] !== $distribution[$j 1])
  1638.                     ) {
  1639.                         // Échanger
  1640.                         $temp $distribution[$i];
  1641.                         $distribution[$i] = $distribution[$j];
  1642.                         $distribution[$j] = $temp;
  1643.                         break;
  1644.                     }
  1645.                 }
  1646.             }
  1647.         }
  1648.     }
  1649.     /**
  1650.      * Fonction intelligente de sélection de photos - Remplace random_function
  1651.      */
  1652.     function smart_random_function($listerandom$currentSlot$distribution)
  1653.     {
  1654.         if (empty($listerandom) || empty($distribution) || !isset($distribution[$currentSlot])) {
  1655.             // Fallback sur l'ancien système si problème
  1656.             return $this->random_function($listerandom);
  1657.         }
  1658.         $photoIndex $distribution[$currentSlot];
  1659.         $photos array_values($listerandom); // Réindexer pour avoir des index numériques
  1660.         if (!isset($photos[$photoIndex])) {
  1661.             // Fallback sécurisé
  1662.             return $this->random_function($listerandom);
  1663.         }
  1664.         $photo $photos[$photoIndex];
  1665.         $idelem $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1666.         $pathelem $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
  1667.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $photoIndex);
  1668.     }
  1669.     /**
  1670.      * Version pour photos sans likes
  1671.      */
  1672.     function smart_random_functionNoLikes($listerandom$currentSlot$distribution)
  1673.     {
  1674.         if (empty($listerandom) || empty($distribution) || !isset($distribution[$currentSlot])) {
  1675.             return $this->random_functionNolikes($listerandom);
  1676.         }
  1677.         $photoIndex $distribution[$currentSlot];
  1678.         $photos array_values($listerandom);
  1679.         if (!isset($photos[$photoIndex])) {
  1680.             return $this->random_functionNolikes($listerandom);
  1681.         }
  1682.         $photo $photos[$photoIndex];
  1683.         $idelem $photo["id"];
  1684.         $pathelem $photo["path"];
  1685.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $photoIndex);
  1686.     }
  1687.     /**
  1688.      * Détermine si on doit utiliser une photo du séjour au lieu d'une répétition excessive
  1689.      */
  1690.     private function shouldUseSejourPhoto($currentSlot$distribution$favoritePhotos)
  1691.     {
  1692.         if (empty($distribution) || !isset($distribution[$currentSlot])) {
  1693.             return false;
  1694.         }
  1695.         // Compter combien de fois cette photo favorite a déjà été utilisée
  1696.         $photoIndex $distribution[$currentSlot];
  1697.         $usageCount 0;
  1698.         for ($i 0$i $currentSlot$i++) {
  1699.             if (isset($distribution[$i]) && $distribution[$i] === $photoIndex) {
  1700.                 $usageCount++;
  1701.             }
  1702.         }
  1703.         // Si cette photo a déjà été utilisée 3 fois, utiliser une photo du séjour
  1704.         return $usageCount >= 3;
  1705.     }
  1706.     /**
  1707.      * @Route("Parent/LivrePhotos", name="LivrePhotos")
  1708.      */
  1709.     public function EditionLivrePhotosParent()
  1710.     {
  1711.         $SEjourService $this->sejourService;
  1712.         /** @var \App\Entity\User $user */
  1713.         $user $this->getUser();
  1714.         $userId $user->getId();
  1715.         $session $this->session;
  1716.         $session->set('pageMenu''');
  1717.         $idSejour $session->get("Sejour");
  1718.         $sejour $this->getDoctrine()->getRepository(Sejour::class)->findOneBy(['id' => $idSejour]);
  1719.         $em $this->em;
  1720.         $clipart null;
  1721.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1722.         $nbLikes count($listeattachlikephoto);
  1723.         //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  1724.         $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  1725.         $random true;
  1726.         $allpagesResult = array();
  1727.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomLivre']);
  1728.         $AllPagesTemp $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1729.         // 🚀 CORRECTION CHIRURGICALE : Forcer exactement 20 pages pour l'album standard
  1730.         // Ajustement précis : 18 pages de contenu + 2 pages fixes = 20 pages total
  1731.         $MAX_CONTENT_PAGES 18;
  1732.         $AllPages array_slice($AllPagesTemp0$MAX_CONTENT_PAGES);
  1733.         $part $sejour->getIdPartenaire();
  1734.         $nompart $part->getUsername();
  1735.         $logopart $part->getLogourl();
  1736.         $tabacc = array();
  1737.         $tabacc1 = array();
  1738.         // 🚀 SMART DISTRIBUTION ALGORITHM - Expert UX Implementation
  1739.         $totalSlots 0;
  1740.         foreach ($AllPages as $p) {
  1741.             $slots substr_count($p->getCouleurbordure(), 'randomid');
  1742.             $totalSlots += $slots;
  1743.         }
  1744.         // 🚀 SMART DISTRIBUTION avec gestion mixte favoris + photos séjour
  1745.         $listeattachlikephoto = ($nbLikes != 0) ?
  1746.             $SEjourService->getlikephotosejour($userId$idSejour) : [];
  1747.         $allSejourPhotos $SEjourService->getCombinedattachSejour($idSejour'photo');
  1748.         // 🚀 Distribution intelligente basée sur les IDs réels des photos
  1749.         $smartDistribution $this->calculateOptimalDistribution($listeattachlikephoto$totalSlots);
  1750.         $needsSejourPhotos = ($nbLikes 0) && (count($listeattachlikephoto) * $totalSlots);
  1751.         $currentSlot 0;
  1752.         foreach ($AllPages as $p) {
  1753.             $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1754.             $rr "";
  1755.             for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1756.                 if ($i sizeof($arrayexploded)) {
  1757.                     // ✅ Distribution intelligente avec limite MAX 3 répétitions
  1758.                     if ($nbLikes != 0) {
  1759.                         // Vérifier si on doit utiliser une photo du séjour au lieu d'une répétition excessive
  1760.                         if ($needsSejourPhotos && $this->shouldUseSejourPhoto($currentSlot$smartDistribution$listeattachlikephoto)) {
  1761.                             $arrayRsRandom $this->smart_random_functionNoLikes($allSejourPhotos$currentSlot$smartDistribution);
  1762.                         } else {
  1763.                             $arrayRsRandom $this->smart_random_function($listeattachlikephoto$currentSlot$smartDistribution);
  1764.                         }
  1765.                     } else {
  1766.                         $arrayRsRandom $this->smart_random_functionNoLikes($allSejourPhotos$currentSlot$smartDistribution);
  1767.                     }
  1768.                     array_push($tabacc$arrayRsRandom['idelem']);
  1769.                     $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1770.                     $currentSlot++; // ✅ Performance optimisée - pas de unset
  1771.                 } else {
  1772.                     $rr $rr $arrayexploded[$i];
  1773.                 }
  1774.             }
  1775.             $resultFinal $rr;
  1776.             $p->setCouleurbordure($resultFinal);
  1777.             array_push($allpagesResult$p);
  1778.         }
  1779.         $AllPages $allpagesResult;
  1780.         $tabacc1 array_count_values($tabacc);
  1781.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1782.         $nbPhotos count($listeattach);
  1783.         $nbLike count($listeattachlikephoto);
  1784.         if ($nbLike == 0) {
  1785.             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]);
  1786.         }
  1787.         if ($nbLike != 0) {
  1788.             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]);
  1789.         }
  1790.     }
  1791.     /**
  1792.      * @Route("Parent/AjoutPochettePhotos/{nbr}", name="AjoutPochettePhotos")
  1793.      */
  1794.     public function AjoutPochettePhotosParent($nbr)
  1795.     {
  1796.         $SEjourService $this->sejourService;
  1797.         /** @var \App\Entity\User $user */
  1798.         $user $this->getUser();
  1799.         $userId $user->getId();
  1800.         $user $this->getUser();
  1801.         $session $this->session;
  1802.         $session->set('pageMenu''');
  1803.         $idSejour $session->get("Sejour");
  1804.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1805.         $em $this->em;
  1806.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  1807.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1808.         $nbPhoto count($listeattach);
  1809.         $clipart $em->getRepository(Clipart::class)->findAll();
  1810.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1811.         $nbLikes count($listeattachlikephoto);
  1812.         $listerandom  = array();
  1813.         $listerandom $listeattach;
  1814.         $AllPagesAcc null;
  1815.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1816.         $random true;
  1817.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1818.         $idAcc $sejour->getIdAcommp();
  1819.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1820.         $part $sejour->getIdPartenaire();
  1821.         $nompart $part->getUsername();
  1822.         $logopart $part->getLogourl();
  1823.         if ($albumAcc != null and $albumAcc != "") {
  1824.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1825.         }
  1826.         $allpagesResult = array();
  1827.         if ($random == true) {
  1828.             // 🚀 SMART DISTRIBUTION ALGORITHM pour POCHETTES - Expert UX Implementation
  1829.             $totalSlots 0;
  1830.             foreach ($AllPages as $p) {
  1831.                 $slots substr_count($p->getCouleurbordure(), 'randomid');
  1832.                 $totalSlots += $slots;
  1833.             }
  1834.             // 🚀 Distribution intelligente pour pochettes basée sur les IDs réels
  1835.             $favoritesList = ($nbLikes != 0) ? $listeattachlikephoto : [];
  1836.             $sejourPhotosList $listerandom;
  1837.             $smartDistribution $this->calculateOptimalDistribution($favoritesList$totalSlots);
  1838.             $needsSejourPhotos = ($nbLikes 0) && (count($favoritesList) * $totalSlots);
  1839.             $currentSlot 0;
  1840.             foreach ($AllPages as $p) {
  1841.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1842.                 $rr "";
  1843.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1844.                     if ($i sizeof($arrayexploded)) {
  1845.                         // ✅ Distribution intelligente pour pochettes - MAX 3 répétitions
  1846.                         if ($nbLikes != 0) {
  1847.                             // Vérifier si on doit utiliser une photo du séjour
  1848.                             if ($needsSejourPhotos && $this->shouldUseSejourPhoto($currentSlot$smartDistribution$favoritesList)) {
  1849.                                 $arrayRsRandom $this->smart_random_functionNoLikes($sejourPhotosList$currentSlot$smartDistribution);
  1850.                             } else {
  1851.                                 $arrayRsRandom $this->smart_random_function($favoritesList$currentSlot$smartDistribution);
  1852.                             }
  1853.                         } else {
  1854.                             $arrayRsRandom $this->smart_random_functionNoLikes($sejourPhotosList$currentSlot$smartDistribution);
  1855.                         }
  1856.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1857.                         $currentSlot++; // ✅ Performance optimisée
  1858.                     } else {
  1859.                         $rr $rr $arrayexploded[$i];
  1860.                     }
  1861.                 }
  1862.                 $resultFinal $rr;
  1863.                 $p->setCouleurbordure($resultFinal);
  1864.                 array_push($allpagesResult$p);
  1865.             }
  1866.             $AllPages $allpagesResult;
  1867.         }
  1868.         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]);
  1869.     }
  1870.     /**
  1871.      * @Route("Parent/AjoutPhotosRetrosFavoris/{nbr}", name="AjoutPhotosRetros_Favoris")
  1872.      */
  1873.     public function AjoutPhotosRetrosParentFavoris($nbr)
  1874.     {
  1875.         $SEjourService $this->sejourService;
  1876.         /** @var \App\Entity\User $user */
  1877.         $user $this->getUser();
  1878.         $userId $user->getId();
  1879.         $session $this->session;
  1880.         $session->set('pageMenu''');
  1881.         $idSejour $session->get("Sejour");
  1882.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1883.         $em $this->em;
  1884.         $clipart $em->getRepository(Clipart::class)->findAll();
  1885.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1886.         $nbLikes count($listeattachlikephoto);
  1887.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  1888.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1889.         $listerandom =  $listeattach;
  1890.         $AllPagesAcc null;
  1891.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1892.         $random true;
  1893.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1894.         $idAcc $sejour->getIdAcommp();
  1895.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1896.         $part $sejour->getIdPartenaire();
  1897.         $nompart $part->getUsername();
  1898.         $logopart $part->getLogourl();
  1899.         if ($albumAcc != null and $albumAcc != "") {
  1900.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1901.         }
  1902.         $allpagesResult = array();
  1903.         $j 0;
  1904.         if ($random == true) {
  1905.             foreach ($AllPages as $p) {
  1906.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1907.                 $rr "";
  1908.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1909.                     if ($i sizeof($arrayexploded)) {
  1910.                         if (sizeof($listerandom) == 0) {
  1911.                             //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  1912.                             $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  1913.                         }
  1914.                         if ($nbLikes != 0) {
  1915.                             $listerandom $SEjourService->getlikephotosejour($userId$idSejour);
  1916.                             $arrayRsRandom $this->random_functionPhoto($listerandom);
  1917.                         }
  1918.                         if ($nbLikes == 0) {
  1919.                             $arrayRsRandom $this->random_functionPhotoNolIKES($listerandom$j);
  1920.                         }
  1921.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1922.                         unset($listerandom[$arrayRsRandom['elem']]);
  1923.                     } else {
  1924.                         $rr $rr $arrayexploded[$i];
  1925.                     }
  1926.                     $listerandom $listerandom;
  1927.                 }
  1928.                 $resultFinal $rr;
  1929.                 $p->setCouleurbordure($resultFinal);
  1930.                 array_push($allpagesResult$p);
  1931.                 if ($j sizeof($listeattachlikephoto) - 1) {
  1932.                     $j $j 1;
  1933.                 } else {
  1934.                     $j 0;
  1935.                 }
  1936.             }
  1937.             $AllPages $allpagesResult;
  1938.         }
  1939.         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]);
  1940.     }
  1941.     /**
  1942.      * @Route("Parent/AjoutPhotosRetros/{nbr}", name="AjoutPhotosRetros")
  1943.      */
  1944.     public function AjoutPhotosRetrosParent($nbr)
  1945.     {
  1946.         $SEjourService $this->sejourService;
  1947.         /** @var \App\Entity\User $user */
  1948.         $user $this->getUser();
  1949.         $userId $user->getId();
  1950.         $session $this->session;
  1951.         $session->set('pageMenu''');
  1952.         $idSejour $session->get("Sejour");
  1953.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1954.         $em $this->em;
  1955.         $clipart $em->getRepository(Clipart::class)->findAll();
  1956.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1957.         $nbLikes count($listeattachlikephoto);
  1958.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  1959.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1960.         if ($nbLikes == 0) {
  1961.             $listerandom =  $listeattach;
  1962.         }
  1963.         if ($nbLikes != 0) {
  1964.             $listerandom =  $listeattachlikephoto;
  1965.         }
  1966.         $AllPagesAcc null;
  1967.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1968.         $random true;
  1969.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1970.         $idAcc $sejour->getIdAcommp();
  1971.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1972.         $part $sejour->getIdPartenaire();
  1973.         $nompart $part->getUsername();
  1974.         $logopart $part->getLogourl();
  1975.         if ($albumAcc != null and $albumAcc != "") {
  1976.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1977.         }
  1978.         $allpagesResult = array();
  1979.         $j 0;
  1980.         if ($random == true) {
  1981.             foreach ($AllPages as $p) {
  1982.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1983.                 $rr "";
  1984.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1985.                     if ($i sizeof($arrayexploded)) {
  1986.                         if ($nbLikes == 0) {
  1987.                             $arrayRsRandom $this->random_functionPhotoNolIKES($listerandom$j);
  1988.                         }
  1989.                         if ($nbLikes != 0) {
  1990.                             $arrayRsRandom $this->random_functionPhoto($listeattachlikephoto);
  1991.                         }
  1992.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1993.                         unset($listerandom[$arrayRsRandom['elem']]);
  1994.                     } else {
  1995.                         $rr $rr $arrayexploded[$i];
  1996.                     }
  1997.                     $listerandom $listerandom;
  1998.                 }
  1999.                 $resultFinal $rr;
  2000.                 $p->setCouleurbordure($resultFinal);
  2001.                 array_push($allpagesResult$p);
  2002.                 if ($nbLikes == 0) {
  2003.                     if ($j sizeof($listeattachlikephoto) - 1) {
  2004.                         $j $j 1;
  2005.                     } else {
  2006.                         $j 0;
  2007.                     }
  2008.                 }
  2009.                 if ($nbLikes != 0) {
  2010.                     if ($j sizeof($listeattach) - 1) {
  2011.                         $j $j 1;
  2012.                     } else {
  2013.                         $j 0;
  2014.                     }
  2015.                 }
  2016.                 $AllPages $allpagesResult;
  2017.             }
  2018.         }
  2019.         if ($nbLikes == 0) {
  2020.             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]);
  2021.         }
  2022.         if ($nbLikes != 0) {
  2023.             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]);
  2024.         }
  2025.     }
  2026.     /**
  2027.      * @Route("Parent/CalendrierParent", name="CalendrierParent")
  2028.      */
  2029.     public function CalendrierParent()
  2030.     {
  2031.         $SEjourService $this->sejourService;
  2032.         /** @var \App\Entity\User $user */
  2033.         $user $this->getUser();
  2034.         $userId $user->getId();
  2035.         $user $this->getUser();
  2036.         $session $this->session;
  2037.         $session->set('pageMenu''');
  2038.         $idSejour $session->get("Sejour");
  2039.         $produitcondition $session->get("produit");
  2040.         $produit $session->get("produittype");
  2041.         $sejour $SEjourService->getsejourpourparent($idSejour);
  2042.         $em $this->em;
  2043.         $clipart $em->getRepository(Clipart::class)->findAll();
  2044.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  2045.         $listerandom $listeattachlikephoto;
  2046.         $AllPagesAcc null;
  2047.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomcalendrier']);
  2048.         $random true;
  2049.         //        }
  2050.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  2051.         $idAcc $sejour->getIdAcommp();
  2052.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  2053.         $part $sejour->getIdPartenaire();
  2054.         //$part = $em->getRepository(Etablisment::class)->findOneBy(['id' => $idpart->getId()]);
  2055.         //dd($part);
  2056.         $nompart $part->getUsername();
  2057.         $logopart $part->getLogourl();
  2058.         // dd($Albumproduct);  
  2059.         if ($albumAcc != null and $albumAcc != "") {
  2060.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  2061.         }
  2062.         //        dd($albumAcc);
  2063.         $allpagesResult = array();
  2064.         $tabacc = array();
  2065.         $tabacc1 = array();
  2066.         if ($random == true) {
  2067.             foreach ($AllPages as $p) {
  2068.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  2069.                 //dd($arrayexploded);
  2070.                 $rr "";
  2071.                 $elemPath "";
  2072.                 $elemId "";
  2073.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  2074.                     if ($i sizeof($arrayexploded)) {
  2075.                         if (sizeof($listerandom) == 0) {
  2076.                             $listerandom $SEjourService->getlikephotosejour($userId$idSejour);
  2077.                         }
  2078.                         $arrayRsRandom $this->random_function($listerandom);
  2079.                         array_push($tabacc$arrayRsRandom['idelem']);
  2080.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  2081.                         unset($listerandom[$arrayRsRandom['elem']]);
  2082.                     } else {
  2083.                         $rr $rr $arrayexploded[$i];
  2084.                     }
  2085.                     $listerandom $listerandom;
  2086.                 }
  2087.                 $resultFinal $rr;
  2088.                 $p->setCouleurbordure($resultFinal);
  2089.                 array_push($allpagesResult$p);
  2090.             }
  2091.             $AllPages $allpagesResult;
  2092.         }
  2093.         $tabacc1 array_count_values($tabacc);
  2094.         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]);
  2095.     }
  2096.     /**
  2097.      * @Route("Parent/ListeSejour", name="ListeSejourParent")
  2098.      */
  2099.     public function ListeSejourParent()
  2100.     {
  2101.         return $this->render('Parent/AccueillParent.html.twig', []);
  2102.     }
  2103.     /**
  2104.      * @Route("/parent/couverture", name="choixCouverture")
  2105.      */
  2106.     public function sur5()
  2107.     {
  2108.         return $this->render('Parent/couverture.html.twig');
  2109.     }
  2110.     /**
  2111.      * @Route("/", name="footerparent")
  2112.      */
  2113.     public function footerparent(): Response
  2114.     {
  2115.         $produit $this->typeProduiteService;
  2116.         $liste $produit->produitlistType();
  2117.         // dd($liste);
  2118.         $session $this->session;
  2119.         $destination $session->get("destionation");
  2120.         $nbvocal 0;
  2121.         $nbSlection 0;
  2122.         $nbPhoto 0;
  2123.         $sejour null;
  2124.         $sejourservice $this->sejourService;
  2125.         $idSejour $session->get("Sejour");
  2126.         /** @var \App\Entity\User $user */
  2127.         $user $this->getUser();
  2128.         $userId $user->getId();
  2129.         $albumAcc null;
  2130.         $em $this->em;
  2131.         if ($idSejour != null) {
  2132.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2133.             // Nb favoris 
  2134.             $listeattachlikephoto $sejourservice->getlikephotosejour($userId$idSejour);
  2135.             $nbSlection count($listeattachlikephoto);
  2136.             // Nb photos 
  2137.             $listeattach $sejourservice->getatachmentsejour($idSejour);
  2138.             $nbPhoto count($listeattach);
  2139.             // Nb messages vocaux 
  2140.             $messages $sejourservice->getsejourmessage($idSejour);
  2141.             $nbvocal count($messages);
  2142.             // Rechercher s'il y'a un album acompagnateur 
  2143.             $idAcc $sejour->getIdAcommp();
  2144.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  2145.         }
  2146.         return $this->render('Parent/footerParent.html.twig', [
  2147.             'destionation' =>  $destination,
  2148.             'nbvocal' =>  $nbvocal,
  2149.             'nbSlection' => $nbSlection,
  2150.             'nbPhotos' => $nbPhoto,
  2151.             'albumAcc' => $albumAcc,
  2152.         ]);
  2153.     }
  2154.     /**
  2155.      * @Route("/", name="heedear")
  2156.      */
  2157.     public function headerparenrt(): Response
  2158.     {
  2159.         $produit $this->typeProduiteService;
  2160.         $liste $produit->produitlistType();
  2161.         $nblikes 0;
  2162.         $nbmesssages 0;
  2163.         // dd($liste);
  2164.         $session $this->session;
  2165.         $panierSession $session->get("Panier");
  2166.         $destination $session->get("destionation");
  2167.         $nbvocal 0;
  2168.         $idSejour $session->get("Sejour");
  2169.         $sejour null;
  2170.         if ($idSejour != null) {
  2171.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2172.         }
  2173.         $Products $session->get("Panier");
  2174.         $numSuivi false;
  2175.         if ($sejour != null) {
  2176.             $Products $session->get("Panier");
  2177.             if ($Products == Null) {
  2178.                 $Products = [];
  2179.             }
  2180.             $UserService $this->userService;
  2181.             /** @var \App\Entity\User $user */
  2182.             $user $this->getUser();
  2183.             $iduser $user->getId();
  2184.             $containsProduitType20 false;
  2185.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2186.             $commandes $this->em->getRepository(Commande::class)->findBy(["idSejour" => $idSejour"idUser" => $iduser]);
  2187.             $sejourparent $this->em->getRepository(ParentSejour::class)->findOneBy(['idSejour' => $idSejour"idParent" => $iduser]);
  2188.             $payment $sejourparent->getPayment();
  2189.             // Check commands
  2190.             foreach ($commandes as $commande) {
  2191.                 $commandCondition $commande->getNumSuivi();
  2192.                 $status $commande->getStatut()->getId();
  2193.                 if ($commandCondition == && $status == 33) {
  2194.                     $containsProduitType20 true;
  2195.                     break; // No need to check further if condition is met
  2196.                 }
  2197.             }
  2198.             // Check panierSession if the condition is not met in commandes
  2199.             if (!$containsProduitType20 && is_array($panierSession) && !empty($panierSession)) {
  2200.                 foreach ($panierSession as $item) {
  2201.                     // Access the details of each item in the Panier
  2202.                     $condition $item['condition'];
  2203.                     $codesejour $item['codesejour'];
  2204.                     if ($condition == 16 && $codesejour == $sejour->getCodeSejour()) {
  2205.                         $containsProduitType20 true;
  2206.                         break; // No need to check further if condition is met
  2207.                     }
  2208.                 }
  2209.             }
  2210.             $sejourservice $this->sejourService;
  2211.             //$messages = $sejourservice->getsejourmessage($idSejour);
  2212.             $messages $sejourservice->getCombinedattachSejour($idSejour'message');
  2213.             $nbmessages count($messages);
  2214.             $listeattachlikephoto =  $sejourservice->getlikephotosejour($iduser$idSejour);
  2215.             $nblikes count($listeattachlikephoto);
  2216.             $em $this->em;
  2217.             $label "Livre_sejour" $sejour->getCodeSejour();
  2218.             $idAcc $sejour->getIdAcommp();
  2219.             $albumAcc $this->getAlbumAccForSejour($sejour);
  2220.             $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'Livre_sejour']);
  2221.             if ($livreSej == null) {
  2222.                 $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  2223.             } else {
  2224.                 $livreSejour $livreSej;
  2225.             }
  2226.             $code_sejour =  $sejour->getCodeSejour();
  2227.             return $this->render('Parent/headerParent.html.twig', [
  2228.                 'produit' => $liste,
  2229.                 'sejour' => $sejour,
  2230.                 'livreSejour' => $livreSejour,
  2231.                 'Products' => $Products,
  2232.                 'destionation' =>  $destination,
  2233.                 'nbvocal' =>  $nbmessages,
  2234.                 'albumAcc' => $albumAcc,
  2235.                 'nbLikes' => $nblikes,
  2236.                 'code_sejour' => $code_sejour,
  2237.                 'payment' => $payment
  2238.             ]);
  2239.         }
  2240.         if ($sejour == null) {
  2241.             return $this->render('Parent/headerParent2.html.twig');
  2242.         }
  2243.     }
  2244.     /**
  2245.      * @Route("/Parent/disablepack", name="disablePack")
  2246.      */
  2247.     public function disableFreepack()
  2248.     {
  2249.         //this section is used to disale the freePackOffert
  2250.         $em $this->em;
  2251.         $session $this->session;
  2252.         /** @var \App\Entity\User $user */
  2253.         $user $this->getUser();
  2254.         $iduser $user->getId();
  2255.         $idSejour $session->get("Sejour");
  2256.         $SEjourService $this->sejourService;
  2257.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  2258.         $panierSession $session->get("Panier");
  2259.         $containsProduitType20 false;
  2260.         $nbrphoto count($listeattach);
  2261.         /** @var \App\Entity\User $user */
  2262.         $user $this->getUser();
  2263.         $iduser $user->getId();
  2264.         $containsProduitType20 false;
  2265.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2266.         $commandes $this->em->getRepository(Commande::class)->findBy(["idSejour" => $idSejour"idUser" => $iduser]);
  2267.         // Check commands
  2268.         foreach ($commandes as $commande) {
  2269.             $commandCondition $commande->getNumSuivi();
  2270.             $status $commande->getStatut()->getId();
  2271.             // Check if Num Suivi is set one and if payment is completed
  2272.             if ($commandCondition == && $status == 33) {
  2273.                 $containsProduitType20 true;
  2274.                 break; // No need to check further if condition is met
  2275.             }
  2276.         }
  2277.         // Check panierSession if the condition is not met in commandes
  2278.         if (!$containsProduitType20 && is_array($panierSession) && !empty($panierSession)) {
  2279.             foreach ($panierSession as $item) {
  2280.                 // Access the details of each item in the Panier
  2281.                 $condition $item['condition'];
  2282.                 $codesejour $item['codesejour'];
  2283.                 if ($condition == 16 && $codesejour == $sejour->getCodeSejour()) {
  2284.                     $containsProduitType20 true;
  2285.                     break; // No need to check further if condition is met
  2286.                 }
  2287.             }
  2288.         }
  2289.         return new JsonResponse(['containsProduitType20' => $containsProduitType20'idSejour' => $nbrphoto]);
  2290.     }
  2291.     /**
  2292.      * @Route("/Parent/disablepackpanier", name="disablePackpanier")
  2293.      */
  2294.     public function disableFreepackpanier(): JsonResponse
  2295.     {
  2296.         //this section is used to disale the + in the panier for the packOffert
  2297.         $em $this->em;
  2298.         $disabledProductIds = [];
  2299.         $session $this->session;
  2300.         $panierSession $session->get("Panier");
  2301.         $ids = [];
  2302.         foreach ($panierSession as $item) {
  2303.             $ids[] = $item['id'];
  2304.         }
  2305.         if ($panierSession) {
  2306.             foreach ($ids as $id) {
  2307.                 $panierProduits $em->getRepository(PanierProduit::class)->findBy(['idProduit' => $id]);
  2308.                 foreach ($panierProduits as $panierProduit) {
  2309.                     $produit $panierProduit->getIdProduit();
  2310.                     $type $produit->getType();
  2311.                     // Check if the product type is 20 and add to disabledProductIds if true
  2312.                     if ($type && $type->getId() == 20) {
  2313.                         $disabledProductIds[] = $produit->getId();
  2314.                     }
  2315.                 }
  2316.             }
  2317.             return new JsonResponse(['disabledProductIds' => $disabledProductIds]);
  2318.         }
  2319.     }
  2320.     /**
  2321.      * @Route("/", name="heedear2")
  2322.      */
  2323.     public function headerparenrt2(): Response
  2324.     {
  2325.         $session $this->session;
  2326.         $produit $this->typeProduiteService;
  2327.         $nbvocal 0;
  2328.         $idSejour $session->get("Sejour");
  2329.         $liste $produit->produitlistType();
  2330.         $session $this->session;
  2331.         $destination $session->get("destionation");
  2332.         $Products $session->get("Panier");
  2333.         if ($Products == Null) {
  2334.             $Products = [];
  2335.         }
  2336.         return $this->render('Parent/headerParent2.html.twig', [
  2337.             'produit' => $liste,
  2338.             'Products' => $Products,
  2339.             'destionation' =>  $destination,
  2340.             'nbvocal' =>  $nbvocal
  2341.         ]);
  2342.     }
  2343.     /**
  2344.      * @Route("/Parent/ParametresParent", name="ParametresParent")
  2345.      */
  2346.     public function Parametreparent()
  2347.     {
  2348.         // $sejourservice = $this->sejourService;
  2349.         //$sejour = $sejourservice->getparentsejour($id, $this->getUser());
  2350.         ///$session = $this->session;
  2351.         //$session->set('moncompte', 'parametres');
  2352.         $user $this->getUser();
  2353.         $session $this->session;
  2354.         $idSejour $session->get("Sejour");
  2355.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2356.         $ParentSejour $this->em->getRepository(ParentSejour::class)->findBy(['idSejour' => $sejour'idParent' => $user]);
  2357.         //ParentSejour
  2358.         //cablala
  2359.         //dd($ParentSejour[0]);
  2360.         //$listeattach = $sejourservice->getatachmentsejour($id);
  2361.         //$listeattachM = $sejourservice->getsejourmessage($id);
  2362.         return $this->render('Parent/Parentparametre.html.twig', [
  2363.             'user' => $user,
  2364.             'sejour' => $sejour,
  2365.             'ParentSejour' => $ParentSejour[0],
  2366.         ]);
  2367.     }
  2368.     /**
  2369.      * @Route("/Parent/Accueil5sur5/ajouteradresslirison", name="ajouteradress_livrson",methods={"POST"})
  2370.      */
  2371.     public function ajouteradresslivr(Request $request)
  2372.     {
  2373.         $UserService $this->userService;
  2374.         //dd($this->getUser()->getId());
  2375.         /** @var \App\Entity\User $user */
  2376.         $user $this->getUser();
  2377.         $iduser $user->getId();
  2378.         $prenom $request->get("prenom");
  2379.         $nom $request->get("nom");
  2380.         $organism $request->get("organism");
  2381.         $num $request->get("num");
  2382.         $rue $request->get('ruevoi');
  2383.         $ville $request->get("villle");
  2384.         $pays $request->get("pays");
  2385.         $codepostal $request->get("codpostal");
  2386.         //adress facturation if exsist
  2387.         $prenomfacturation $request->get("prenomadressfacturation");
  2388.         $nomfacturation $request->get("nomadressfacturation");
  2389.         $organismfacturation $request->get("etablismadressfacturation");
  2390.         $numfacturation $request->get("numdressfacturation");
  2391.         $ruefacturation $request->get('rueadressfacturation');
  2392.         $villefacturation $request->get("villefacturation");
  2393.         $paysfacturation $request->get("payadressfacturation");
  2394.         $codepostalfacturation $request->get("codepostalfacturation");
  2395.         //modification userPArent
  2396.         $usernomAcommpa $request->get("usernom");
  2397.         $userprenomAcommpa $request->get("userprenom");
  2398.         $userfonctionAcommpa $request->get("userfonction");
  2399.         $useretablismentAcommpa $request->get("useretablisment");
  2400.         $useremailcommpa $request->get("useremail");
  2401.         $sejourthem $request->get("sejourthem");
  2402.         $adresssejour $request->get("sejouradresse");
  2403.         $id $request->get("id");
  2404.         $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);
  2405.         return new JsonResponse('done');
  2406.     }
  2407.     /**
  2408.      * @Route("/Accueil5sur5/ajouteradressfacturation", name="ajouteradress_facturation",methods={"POST","GET"})
  2409.      */
  2410.     public function ajouteradressfacturation(Request $request)
  2411.     {
  2412.         $UserService $this->userService;
  2413.         /** @var \App\Entity\User $user */
  2414.         $user $this->getUser();
  2415.         $iduser $user->getId();
  2416.         $num $request->get("num");
  2417.         $rue $request->get('rue');
  2418.         $ville $request->get("ville");
  2419.         $pays $request->get("pays");
  2420.         $codepostal $request->get("codepostal");
  2421.         $adress $UserService->setadressfacturation($num$rue$ville$pays$codepostal$iduser);
  2422.         return new JsonResponse('done');
  2423.     }
  2424.     /**
  2425.      * @Route("/EntrezCode", name="EntrezCode")
  2426.      */
  2427.     public function EntrezCode(Request $request)
  2428.     {
  2429.         $email $request->get('email');
  2430.         $password $request->get('password');
  2431.         $this->session->set('rout''code');
  2432.         return $this->redirectToRoute('CodeSejour', ['email' => $email'password' => $password]);
  2433.     }
  2434.     /**
  2435.      * @Route("/DemandeCode", name="DemandeCode")
  2436.      */
  2437.     public function DemandeCode(Request $request)
  2438.     {
  2439.         $nomEnfant $request->get('nomEnfant');
  2440.         $prenomEnfant $request->get('prenomEnfant');
  2441.         $votreNom $request->get('votreNom');
  2442.         $votrePrenom $request->get('votrePrenom');
  2443.         $Mail $request->get('Mail');
  2444.         $votreLien $request->get('votreLien');
  2445.         $du $request->get('du');
  2446.         $au $request->get('au');
  2447.         $code $request->get('code');
  2448.         $ville $request->get('ville');
  2449.         $listeSejour $this->em->getRepository(Sejour::class)->listAcco($du$au$code$ville);
  2450.         $RefEmail $this->em->getRepository(Ref::class)->find(23);
  2451.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  2452.         foreach ($listeSejour as $accompagnateur) {
  2453.             $sendTo $accompagnateur->getIdAcommp()->getEmail();
  2454.             $message = (new \Swift_Message('Demande code séjour'))
  2455.                 ->setFrom('contact@5sur5sejour.com')
  2456.                 ->setTo($sendTo);
  2457.             //->setBcc("contact@5sur5sejour.com");
  2458.             $pathImage2 $Email->getIdImage2()->getPath();
  2459.             $pathImage1 $Email->getIdImage1()->getPath();
  2460.             $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2461.             $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2462.             $iconphoto $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_419_pqx0dx._6656d07326a50.png"));
  2463.             $iconloca $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_420_uynuqz._6656d10f4daaf.png"));
  2464.             $iconmsg $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_418_wbyysk._6656d16240404.png"));
  2465.             $iconfooter $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Picto5sur5_rapbfy._6656d1c1bb536.png"));
  2466.             $iMagesProduits $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Picto5sur5_rapbfy._6656d1c1bb536.png"));
  2467.             $message->setBody(
  2468.                 $this->templating->render(
  2469.                     'emails/ParentDemandeCodeSejour.html.twig',
  2470.                     [
  2471.                         "nomAcco" => $accompagnateur->getIdAcommp()->getNom(),
  2472.                         "prenomAcco" => $accompagnateur->getIdAcommp()->getPrenom(),
  2473.                         "nomEnfant" => $nomEnfant,
  2474.                         "prenomEnfant" => $prenomEnfant,
  2475.                         "votreNom" => $votreNom,
  2476.                         "votrePrenom" => $votrePrenom,
  2477.                         "mail" => $Mail,
  2478.                         "votreLien" => $votreLien,
  2479.                         "image1" => $image1,
  2480.                         "image2" => $image2,
  2481.                         "iconfooter" => $iconfooter,
  2482.                         "iconphoto" => $iconphoto,
  2483.                         "iconloca" => $iconloca,
  2484.                         "iconmsg" => $iconmsg,
  2485.                         "du" => $du,
  2486.                         "au" => $au,
  2487.                         "code" => $code,
  2488.                         "ville" => $ville,
  2489.                     ]
  2490.                 ),
  2491.                 'text/html'
  2492.             );
  2493.             try {
  2494.                 $signMail $this->getParameter('signMail');
  2495.                 if ($signMail == 'yes') {
  2496.                     $domainName $this->getParameter('domaine');
  2497.                     $selector $this->getParameter('selector');
  2498.                     $PrivateKey file_get_contents($this->getParameter('pathDKIM'));
  2499.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2500.                     $message->attachSigner($signer);
  2501.                 }
  2502.                 $this->mailer->send($message);
  2503.             } catch (\Swift_SwiftException $ex) {
  2504.                 $ex->getMessage();
  2505.             }
  2506.         }
  2507.         return new JsonResponse(count($listeSejour));
  2508.     }
  2509.     /**
  2510.      * @Route("/Parent/ChoixCouverture", name="ChoixCouvertureParent")
  2511.      */
  2512.     public function Couverture()
  2513.     {
  2514.         return $this->render('Parent/ChoixCouverture.html.twig', []);
  2515.     }
  2516.     /**
  2517.      * @Route("/Parent/couvertureAccompagnateur", name="couvertureAccompagnateur")
  2518.      */
  2519.     public function CouvertureAccompagnateur()
  2520.     {
  2521.         $user $this->getUser();
  2522.         $session $this->session;
  2523.         $idSejour $session->get("Sejour");
  2524.         $listeproduit $prod $this->em->getRepository(Produit::class)->findby(array('idsjour' => $idSejour));
  2525.         return $this->render('Parent/couvertureAccompagnateur.html.twig', []);
  2526.     }
  2527.     /**
  2528.      * @Route("/Parent/Projet", name="projet-Parent")
  2529.      */
  2530.     public function parentTWo()
  2531.     {
  2532.         $this->session->set('rout''rout');
  2533.         /** @var \App\Entity\User $user */
  2534.         $user $this->getUser();
  2535.         $session $this->session;
  2536.         $session->set('pageMenu''projets');
  2537.         $idSejour $session->get("Sejour");
  2538.         $listeproduit $this->em->getRepository(Produit::class)->findby(array('idsjour' => $idSejour'iduser' => $user->getId()), ['id' => 'DESC']);
  2539.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2540.         $parentent_sejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $user->getId(), "idSejour" => $idSejour]);
  2541.         return $this->render('Parent/ProjetsParent.html.twig', ['sejour' => $sejour'parentent_sejour' => $parentent_sejour'listeproduit' => $listeproduit]);
  2542.     }
  2543.     /**
  2544.      * @Route("/Parent/MesProjets", name="MesProjets")
  2545.      */
  2546.     public function MesProjets()
  2547.     {
  2548.         return $this->render('Parent/MesProjetsSauvegardes.html.twig', []);
  2549.     }
  2550.     /**
  2551.      * @Route("/Parent/allSejourparent", name="SejourParent")
  2552.      */
  2553.     public function SejourAccompagnateur()
  2554.     {
  2555.         $sejourservice $this->sejourService;
  2556.         $session $this->session;
  2557.         $idSejour $session->get("Sejour");
  2558.         $session->set('rout''rout');
  2559.         /** @var \App\Entity\User $user */
  2560.         $user $this->getUser();
  2561.         $userId $user->getId();
  2562.         $listeSejour $prod $this->em->getRepository(ParentSejour::class)->findby(array('idParent' => $userId));
  2563.         return $this->render('Parent/Messejours.html.twig', ['listeSejour' => $listeSejour]);
  2564.     }
  2565.     /**
  2566.      * @Route("/Parent/Commander", name="Commander")
  2567.      */
  2568.     public function Commander()
  2569.     {
  2570.         $session $this->session;
  2571.         $idSejour $session->get("Sejour");
  2572.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2573.         $user $this->getUser();
  2574.         $comande $session->get("comande");
  2575.         $panier $session->get("Panier");
  2576.         $nbrprodpromo 0;
  2577.         $nbralbum 0;
  2578.         $nbrlivre 0;
  2579.         $nbrphoto12 0;
  2580.         $nbrphoto24 0;
  2581.         $nbrphoto36 0;
  2582.         $nbrcal 0;
  2583.         $nbrretro12 0;
  2584.         $nbrretro24 0;
  2585.         $nbrretro36 0;
  2586.         $detailsprod = array();
  2587.         $prixalbum 0.0;
  2588.         $prixphoto12 0.0;
  2589.         $prixphoto24 0.0;
  2590.         $prixphoto36 0.0;
  2591.         $prixcal 0.0;
  2592.         $prixalbum 0.0;
  2593.         $prixretro12 0.0;
  2594.         $prixretro24 0.0;
  2595.         $prixretro36 0.0;
  2596.         $prodpanierpromo = array();
  2597.         $promo = array();
  2598.         foreach ($panier as $key => $p) {
  2599.             if ($p['condition'] != 11 && $p['condition'] != 6) {
  2600.                 $promo['condition'] = $p['condition'];
  2601.                 $nbrprodpromo $nbrprodpromo $p['qte'];
  2602.                 array_push($prodpanierpromo$promo);
  2603.                 if ($p['condition'] == 4) {
  2604.                     $nbralbum $nbralbum $p['qte'];
  2605.                     $prixalbum $p['mnt'];
  2606.                 } elseif ($p['condition'] == 1) {
  2607.                     $nbrphoto12 $nbrphoto12 $p['qte'];
  2608.                     $prixphoto12 $p['mnt'];
  2609.                 } elseif ($p['condition'] == 2) {
  2610.                     $nbrphoto24 $nbrphoto24 $p['qte'];
  2611.                     $prixphoto24 $p['mnt'];
  2612.                 } elseif ($p['condition'] == 3) {
  2613.                     $nbrphoto36 $nbrphoto36 $p['qte'];
  2614.                     $prixphoto36  $p['mnt'];
  2615.                 } elseif ($p['condition'] == 5) {
  2616.                     $nbrlivre $nbrlivre $p['qte'];
  2617.                     $prixlivre $p['mnt'];
  2618.                 } elseif ($p['condition'] == 7) {
  2619.                     $nbrcal $nbrcal $p['qte'];
  2620.                     $prixcal $p['mnt'];
  2621.                 } elseif ($p['condition'] == 8) {
  2622.                     $nbrretro36 $nbrretro36 $p['qte'];
  2623.                     $prixretro36 $p['mnt'];
  2624.                 } elseif ($p['condition'] == 9) {
  2625.                     $nbrretro12 $nbrretro12 $p['qte'];
  2626.                     $prixretro12 $p['mnt'];
  2627.                 } elseif ($p['condition'] == 10) {
  2628.                     $nbrretro24 $nbrretro24 $p['qte'];
  2629.                     $prixretro24 $p['mnt'];
  2630.                 }
  2631.             }
  2632.         }
  2633.         $detailsprod['album']['qt'] = $nbralbum;
  2634.         $detailsprod['album']['prix'] = $prixalbum;
  2635.         $detailsprod['photo12']['qt'] = $nbrphoto12;
  2636.         $detailsprod['photo12']['prix'] = $prixphoto12;
  2637.         $detailsprod['photo24']['qt'] = $nbrphoto24;
  2638.         $detailsprod['photo24']['prix'] = $prixphoto24;
  2639.         $detailsprod['photo36']['qt'] = $nbrphoto36;
  2640.         $detailsprod['photo36']['prix'] = $prixphoto36;
  2641.         $detailsprod['cal']['qt'] = $nbrcal;
  2642.         $detailsprod['cal']['prix'] = $prixcal;
  2643.         $detailsprod['livre']['qt'] = $nbrlivre;
  2644.         $detailsprod['livre']['prix'] = $prixalbum;
  2645.         $detailsprod['retro12']['qt'] = $nbrretro12;
  2646.         $detailsprod['retro12']['prix'] = $prixretro12;
  2647.         $detailsprod['retro24']['qt'] = $nbrretro24;
  2648.         $detailsprod['retro24']['prix'] = $prixretro24;
  2649.         $detailsprod['retro36']['qt'] = $nbrretro36;
  2650.         $detailsprod['retro36']['prix'] = $prixretro36;
  2651.         $Panier $session->get("Panier");
  2652.         return $this->render('Parent/commande.html.twig', ["detailsprod" => $detailsprod"nbrprodpromo" => $nbrprodpromo"prodpanierpromo" => $prodpanierpromo"user" => $user"sejour" => $sejour"x" => $panier'Panier' => $Panier]);
  2653.     }
  2654.     /**
  2655.      * @Route("/Parent/MonPanier", name="MonPanier")
  2656.      */
  2657.     public function MonPanier()
  2658.     {
  2659.         /** @var \App\Entity\User $user */
  2660.         $user $this->getUser();
  2661.         $session $this->session;
  2662.         $idSejour $session->get("Sejour");
  2663.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2664.         $listeproduit $prod $this->em->getRepository(Produit::class)->findby(array('iduser' => $user->getId()));
  2665.         $parentent_sejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $user->getId(), "idSejour" => $idSejour]);
  2666.         $Panier $session->get("Panier");
  2667.         //dd($Panier);
  2668.         $prodpanier = array();
  2669.         $nbrprodpromo 0;
  2670.         $nbralbum 0;
  2671.         $nbrlivre 0;
  2672.         $nbrphoto12 0;
  2673.         $nbrphoto24 0;
  2674.         $nbrphoto36 0;
  2675.         $nbrcal 0;
  2676.         $nbrretro12 0;
  2677.         $nbrretro24 0;
  2678.         $nbrretro36 0;
  2679.         $detailsprod = array();
  2680.         $prixalbum 0.0;
  2681.         $prixphoto12 0.0;
  2682.         $prixphoto24 0.0;
  2683.         $prixphoto36 0.0;
  2684.         $prixcal 0.0;
  2685.         $prixalbum 0.0;
  2686.         $prixretro12 0.0;
  2687.         $prixretro24 0.0;
  2688.         $prixretro36 0.0;
  2689.         $prodpanierpromo = array();
  2690.         $promo = array();
  2691.         foreach ($Panier as $key => $p) {
  2692.             if ($p['condition'] != null) {
  2693.                 array_push($prodpanier$p['condition']);
  2694.             }
  2695.             if ($p['condition'] != 11 && $p['condition'] != 6) {
  2696.                 $promo['condition'] = $p['condition'];
  2697.                 $nbrprodpromo $nbrprodpromo $p['qte'];
  2698.                 array_push($prodpanierpromo$promo);
  2699.                 if ($p['condition'] == 4) {
  2700.                     $nbralbum $nbralbum $p['qte'];
  2701.                     $prixalbum $p['mnt'];
  2702.                 } elseif ($p['condition'] == 1) {
  2703.                     $nbrphoto12 $nbrphoto12 $p['qte'];
  2704.                     $prixphoto12 $p['mnt'];
  2705.                 } elseif ($p['condition'] == 2) {
  2706.                     $nbrphoto24 $nbrphoto24 $p['qte'];
  2707.                     $prixphoto24 $p['mnt'];
  2708.                 } elseif ($p['condition'] == 3) {
  2709.                     $nbrphoto36 $nbrphoto36 $p['qte'];
  2710.                     $prixphoto36  $p['mnt'];
  2711.                 } elseif ($p['condition'] == 5) {
  2712.                     $nbrlivre $nbrlivre $p['qte'];
  2713.                     $prixlivre $p['mnt'];
  2714.                 } elseif ($p['condition'] == 7) {
  2715.                     $nbrcal $nbrcal $p['qte'];
  2716.                     $prixcal $p['mnt'];
  2717.                 } elseif ($p['condition'] == 8) {
  2718.                     $nbrretro36 $nbrretro36 $p['qte'];
  2719.                     $prixretro36 $p['mnt'];
  2720.                 } elseif ($p['condition'] == 9) {
  2721.                     $nbrretro12 $nbrretro12 $p['qte'];
  2722.                     $prixretro12 $p['mnt'];
  2723.                 } elseif ($p['condition'] == 10) {
  2724.                     $nbrretro24 $nbrretro24 $p['qte'];
  2725.                     $prixretro24 $p['mnt'];
  2726.                 }
  2727.             }
  2728.         }
  2729.         $detailsprod['album']['qt'] = $nbralbum;
  2730.         $detailsprod['album']['prix'] = $prixalbum;
  2731.         $detailsprod['photo12']['qt'] = $nbrphoto12;
  2732.         $detailsprod['photo12']['prix'] = $prixphoto12;
  2733.         $detailsprod['photo24']['qt'] = $nbrphoto24;
  2734.         $detailsprod['photo24']['prix'] = $prixphoto24;
  2735.         $detailsprod['photo36']['qt'] = $nbrphoto36;
  2736.         $detailsprod['photo36']['prix'] = $prixphoto36;
  2737.         $detailsprod['cal']['qt'] = $nbrcal;
  2738.         $detailsprod['cal']['prix'] = $prixcal;
  2739.         $detailsprod['livre']['qt'] = $nbrlivre;
  2740.         $detailsprod['livre']['prix'] = $prixalbum;
  2741.         $detailsprod['retro12']['qt'] = $nbrretro12;
  2742.         $detailsprod['retro12']['prix'] = $prixretro12;
  2743.         $detailsprod['retro24']['qt'] = $nbrretro24;
  2744.         $detailsprod['retro24']['prix'] = $prixretro24;
  2745.         $detailsprod['retro36']['qt'] = $nbrretro36;
  2746.         $detailsprod['retro36']['prix'] = $prixretro36;
  2747.         $produit $this->typeProduiteService;
  2748.         $produitlist $produit->produitlistTypeConditionnement();
  2749.         //dd( $detailsprod);
  2750.         $this->session->set('rout''rout');
  2751.         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]);
  2752.     }
  2753.     /**
  2754.      * @Route("/Parent/mail", name="mail")
  2755.      */
  2756.     public function mail()
  2757.     {
  2758.         return $this->render('emails/Inscriptionparent.html.twig', []);
  2759.     }
  2760.     /**
  2761.      * @Route("/Parent/AlbummsavealbumParent", name="AlbummsavealbumParent")
  2762.      */
  2763.     public function Albummsavealbum(Request $request)
  2764.     {
  2765.         $session $this->session;
  2766.         $serviceuser $this->etablissementService;
  2767.         $page $request->get("pages");
  2768.         $sejour $request->get("sejour");
  2769.         $prodid $request->get('idProd');
  2770.         $nomprod $request->get('nomprod');
  2771.         $versionalbm $request->get('new');
  2772.         $user $this->getUser();
  2773.         $produittype $session->get("produit");
  2774.         $produit $session->get("produittype");
  2775.         /** @var \App\Entity\User $user */
  2776.         $user $this->getUser();
  2777.         $userEmail $user->getEmail();
  2778.         $Album $serviceuser->savealbumParent($page$user$sejour$prodid$produit$produittype$nomprod$versionalbm);
  2779.         //dd($etablissementDetail);
  2780.         $dateNow = new \Datetime();
  2781.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2782.         // $this->EmailServie->MailRelancePanier($userEmail);
  2783.         return new response();
  2784.     }
  2785.     /**
  2786.      * @Route("/Parent/saveLivrePhotosParent", name="saveLivrePhotosParent")
  2787.      */
  2788.     public function saveLivrePhotos(Request $request)
  2789.     {
  2790.         $session $this->session;
  2791.         $serviceuser $this->etablissementService;
  2792.         $page $request->get("pages");
  2793.         $sejour $request->get("sejour");
  2794.         $prodid $request->get('idProd');
  2795.         $nomprod $request->get('nomprod');
  2796.         $versionalbm $request->get('new');
  2797.         $user $this->getUser();
  2798.         $produitcondition $session->get("produit");
  2799.         $produit $session->get("produittype");
  2800.         $produitcondss $session->get('produitconditionAlbum');
  2801.         $Album $serviceuser->savelivreParent($page$user$sejour$prodid$produitcondss$nomprod$versionalbm);
  2802.         //dd($etablissementDetail);
  2803.         //sendmail_parent
  2804.         $dateNow = new \Datetime();
  2805.         /** @var \App\Entity\User $user */
  2806.         $user $this->getUser();
  2807.         $userEmail $user->getEmail();
  2808.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2809.         // $this->EmailServie->MailRelancePanier($userEmail);
  2810.         return new response('done');
  2811.     }
  2812.     /**
  2813.      * @Route("/Parent/SavePhotosPochette", name="SavePhotosPochetteParent")
  2814.      */
  2815.     public function SavePhotosPochetteParent(Request $request)
  2816.     {
  2817.         $session $this->session;
  2818.         $serviceuser $this->etablissementService;
  2819.         $page $request->get("pages");
  2820.         $sejour $request->get("sejour");
  2821.         $prodid $request->get('idProd');
  2822.         $nomprod $request->get('nomprod');
  2823.         $nbr $request->get('nbr');
  2824.         $user $this->getUser();
  2825.         $nbr strval($nbr);
  2826.         $produittype $session->get("produit");
  2827.         $produit $session->get("produittype");
  2828.         $Album $serviceuser->SavePhotosPochetteParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  2829.         //sendmailparent
  2830.         $dateNow = new \Datetime();
  2831.         /** @var \App\Entity\User $user */
  2832.         $user $this->getUser();
  2833.         $userEmail $user->getEmail();
  2834.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2835.         //$this->EmailServie->MailRelancePanier($userEmail);
  2836.         return new response('done');
  2837.     }
  2838.     /**
  2839.      * @Route("/Parent/RetrosComandeSaveRetros", name="PochettePhotosComandeSave")
  2840.      */
  2841.     public function PochettePhotosComandeSave(Request $request)
  2842.     {
  2843.         $em $this->em;
  2844.         $session $this->session;
  2845.         $serviceuser $this->etablissementService;
  2846.         $page $request->get("pages");
  2847.         $sejour $request->get("sejour");
  2848.         $prodid $request->get('idProd');
  2849.         $nomprod $request->get('nomprod');
  2850.         $nbr $request->get('nbr');
  2851.         $user $this->getUser();
  2852.         $nbr strval($nbr);
  2853.         if (empty($page) || !is_array($page)) {
  2854.             return new Response('Erreur : aucune donnée reçue'400);
  2855.         }
  2856.         $produittype $session->get("produit");
  2857.         $produit $session->get("produittype");
  2858.         $Album $serviceuser->SavePhotosRetrosParents($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  2859.         $inser false;
  2860.         $Products $session->get("Panier");
  2861.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  2862.         //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
  2863.         $user $this->getUser();
  2864.         $typeref $em->getRepository(Typeref::class)->find(8);
  2865.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  2866.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  2867.         //fin
  2868.         if ($panierTrace == null) {
  2869.             $panierTrace = new Panier();
  2870.             $dateNow = new \Datetime();
  2871.             $panierTrace->setDateCreation($dateNow);
  2872.             $panierTrace->setCreerPar($user);
  2873.             $panierTrace->setStatut($statutPanier);
  2874.             $em->getManager()->persist($panierTrace);
  2875.             $em->getManager()->flush();
  2876.         }
  2877.         //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
  2878.         if ($Products == null) {
  2879.             $Products = [];
  2880.         }
  2881.         foreach ($Products as $key => $p) {
  2882.             if ($p['id'] == $produit->getId()) {
  2883.                 $inser true;
  2884.                 $Products[$key]['qte'] = $p['qte'] + 1;
  2885.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  2886.             }
  2887.         }
  2888.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  2889.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  2890.         if ($panierProduit == null) {
  2891.             $panierProduit = new PanierProduit();
  2892.             $panierProduit->setIdProduit($produit);
  2893.             $panierProduit->setIdPanier($panierTrace);
  2894.             $em->getManager()->persist($panierProduit);
  2895.             $em->getManager()->flush();
  2896.         }
  2897.         //fin
  2898.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  2899.         $oldQte $panierProduit->getQuantite();
  2900.         $newQte $oldQte 1;
  2901.         $panierProduit->setQuantite($newQte);
  2902.         $oldTotal $panierProduit->getPrixTotal();
  2903.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  2904.         $panierProduit->setPrixTotal($newTotal);
  2905.         $em->getManager()->persist($panierProduit);
  2906.         $em->getManager()->flush();
  2907.         //fin
  2908.         if ($inser === false) {
  2909.             $p = [];
  2910.             $p["id"] = $produit->getId();
  2911.             $p["nom"] = $produit->getType()->getLabeletype();
  2912.             $p["ident"] = $produit->getLabele();
  2913.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  2914.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  2915.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  2916.             $p["condition"] = $produit->getIdConditionnement()->getId();
  2917.             $p["qte"] = 1;
  2918.             array_push($Products$p);
  2919.         }
  2920.         $session->set('Panier'$Products);
  2921.         //sendmail_parent
  2922.         $dateNow = new \Datetime();
  2923.         /** @var \App\Entity\User $user */
  2924.         $user $this->getUser();
  2925.         $userEmail $user->getEmail();
  2926.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2927.         //$this->EmailServie->MailRelancePanier($userEmail);
  2928.         return new response('done');
  2929.     }
  2930.     //fonction pour pochett photo comande direct au panier 
  2931.     /**
  2932.      * @Route("/Parent/PochetcomdComandeSave", name="PochettePhotosComandeSave_pochet_panier")
  2933.      */
  2934.     public function PochettePhotosComandeSave_pochet_panier(Request $request)
  2935.     {
  2936.         $em $this->em;
  2937.         $session $this->session;
  2938.         $serviceuser $this->etablissementService;
  2939.         $page $request->get("pages");
  2940.         $sejour $request->get("sejour");
  2941.         $prodid $request->get('idProd');
  2942.         $nomprod $request->get('nomprod');
  2943.         $nbr $request->get('nbr');
  2944.         $user $this->getUser();
  2945.         $nbr strval($nbr);
  2946.         if (empty($page) || !is_array($page)) {
  2947.             return new Response('Erreur : aucune photo reçue'400);
  2948.         }
  2949.         $produittype $session->get("produit");
  2950.         $produit $session->get("produittype");
  2951.         $Album $serviceuser->SavePhotosPochetteParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  2952.         $inser false;
  2953.         $Products $session->get("Panier");
  2954.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  2955.         //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
  2956.         $user $this->getUser();
  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.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  2992.         $oldQte $panierProduit->getQuantite();
  2993.         $newQte $oldQte 1;
  2994.         $panierProduit->setQuantite($newQte);
  2995.         $oldTotal $panierProduit->getPrixTotal();
  2996.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  2997.         $panierProduit->setPrixTotal($newTotal);
  2998.         $em->getManager()->persist($panierProduit);
  2999.         $em->getManager()->flush();
  3000.         //fin
  3001.         if ($inser === false) {
  3002.             $p = [];
  3003.             $p["id"] = $produit->getId();
  3004.             $p["nom"] = $produit->getType()->getLabeletype();
  3005.             $p["ident"] = $produit->getLabele();
  3006.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3007.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3008.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3009.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3010.             $p["qte"] = 1;
  3011.             array_push($Products$p);
  3012.         }
  3013.         $session->set('Panier'$Products);
  3014.         //sendmail_parent
  3015.         $dateNow = new \Datetime();
  3016.         /** @var \App\Entity\User $user */
  3017.         $user $this->getUser();
  3018.         $userEmail $user->getEmail();
  3019.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3020.         // $this->EmailServie->MailRelancePanier($userEmail);
  3021.         return new response('done');
  3022.     }
  3023.     //Nouvelle fonction ajout pochette
  3024.     /**
  3025.      * @Route("/Parent/TestcreateFilePhotosNew", name="TestcreateFilePhotosNew")
  3026.      */
  3027.     function TestcreateFilePhotosNew(Request $request)
  3028.     {
  3029.         $prdt $request->get("produit");
  3030.         $printerSer $this->printerService;
  3031.         $pages $this->em->getRepository(Page::class)->findBy(array("idproduit" => $prdt));
  3032.         $this->logger->notice('Generating File for Pack photos');
  3033.         $name =  $printerSer->CreerTcpPhotosPochette_Parent($prdt'NumCmd_963''Photo'$pages);
  3034.         dump($name);
  3035.         die();
  3036.         return ("ok");
  3037.     }
  3038.     //Nouvelle fonction ajout pochette
  3039.     /**
  3040.      * @Route("/Parent/AddPochetteAuPanier", name="AddPochetteAuPanier")
  3041.      */
  3042.     public function AddPochetteAuPanier(Request $request)
  3043.     {
  3044.         $em $this->em;
  3045.         $session $this->session;
  3046.         $serviceuser $this->etablissementService;
  3047.         $page $request->get("photos");
  3048.         $sejour $request->get("sejour");
  3049.         $nbr $request->get('nbr');
  3050.         $user $this->getUser();
  3051.         $nbr strval($nbr);
  3052.         // Fallback : si jQuery n'a pas sérialisé le tableau correctement, utiliser jsonPhotos
  3053.         if (empty($page)) {
  3054.             $jsonPhotos $request->get("jsonPhotos");
  3055.             if (!empty($jsonPhotos)) {
  3056.                 $page json_decode($jsonPhotostrue);
  3057.             }
  3058.         }
  3059.         if (empty($page) || !is_array($page)) {
  3060.             return new Response('Erreur : aucune photo sélectionnée'400);
  3061.         }
  3062.         $Pochette_photos $serviceuser->photosPochette_Nouvelle($page$user$sejour$nbr);
  3063.         $produit $em->getRepository(Produit::class)->find($Pochette_photos->getId());
  3064.         // $zipFileName = $this->printerService->CreerTcpPhotosPochette_Parent($Pochette_photos->getId(), "9999999", "pochette_photo");
  3065.         $inser false;
  3066.         $Products $session->get("Panier");
  3067.         $produit $em->getRepository(Produit::class)->find($Pochette_photos->getId());
  3068.         //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
  3069.         $typeref $em->getRepository(Typeref::class)->find(8);
  3070.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3071.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3072.         //fin
  3073.         if ($panierTrace == null) {
  3074.             $panierTrace = new Panier();
  3075.             $dateNow = new \Datetime();
  3076.             $panierTrace->setDateCreation($dateNow);
  3077.             $panierTrace->setCreerPar($user);
  3078.             $panierTrace->setStatut($statutPanier);
  3079.             $em->getManager()->persist($panierTrace);
  3080.             $em->getManager()->flush();
  3081.         }
  3082.         //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
  3083.         if ($Products == null) {
  3084.             $Products = [];
  3085.         }
  3086.         foreach ($Products as $key => $p) {
  3087.             if ($p['id'] == $produit->getId()) {
  3088.                 $inser true;
  3089.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3090.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3091.             }
  3092.         }
  3093.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  3094.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3095.         if ($panierProduit == null) {
  3096.             $panierProduit = new PanierProduit();
  3097.             $panierProduit->setIdProduit($produit);
  3098.             $panierProduit->setIdPanier($panierTrace);
  3099.             $em->getManager()->persist($panierProduit);
  3100.             $em->getManager()->flush();
  3101.         }
  3102.         //fin
  3103.         $oldQte $panierProduit->getQuantite();
  3104.         $newQte $oldQte 1;
  3105.         $panierProduit->setQuantite($newQte);
  3106.         $oldTotal $panierProduit->getPrixTotal();
  3107.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3108.         $panierProduit->setPrixTotal($newTotal);
  3109.         $em->getManager()->persist($panierProduit);
  3110.         $em->getManager()->flush();
  3111.         // Test creation du fichier zip pdf pochette
  3112.         if ($inser === false) {
  3113.             $p = [];
  3114.             $p["id"] = $produit->getId();
  3115.             $p["nom"] = $produit->getType()->getLabeletype();
  3116.             $p["ident"] = $produit->getLabele();
  3117.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3118.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3119.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3120.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3121.             $p["qte"] = 1;
  3122.             array_push($Products$p);
  3123.         }
  3124.         $session->set('Panier'$Products);
  3125.         //sendmail_parent
  3126.         $dateNow = new \Datetime();
  3127.         /** @var \App\Entity\User $user */
  3128.         $user $this->getUser();
  3129.         $userEmail $user->getEmail();
  3130.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3131.         // $this->EmailServie->MailRelancePanier($userEmail);
  3132.         //   $this->TestcreateFilePhotosNew($produit);
  3133.         return new response('done');
  3134.     }
  3135.     /**
  3136.      * @Route("/Parent/AddRetroAuPanier", name="AddRetroAuPanier", methods={"POST"})
  3137.      */
  3138.     public function AddRetroAuPanier(Request $request)
  3139.     {
  3140.         $em       $this->em;
  3141.         $session  $this->session;
  3142.         $user     $this->getUser();
  3143.         $service  $this->etablissementService;
  3144.         // Accept JSON body so large base64 payload is not truncated (form encoding can hit limits)
  3145.         $content $request->getContent();
  3146.         if (!empty($content) && strpos($request->headers->get('Content-Type'''), 'application/json') !== false) {
  3147.             $data json_decode($contenttrue);
  3148.             $photos   $data['photos'] ?? null;
  3149.             $sejourId $data['sejour'] ?? null;
  3150.             $nbr      = isset($data['nbr']) ? strval($data['nbr']) : null;
  3151.         } else {
  3152.             $photos   $request->get('photos');
  3153.             $sejourId $request->get('sejour');
  3154.             $nbr      $request->get('nbr') !== null strval($request->get('nbr')) : null;
  3155.         }
  3156.         if (empty($photos) || !is_array($photos) || $sejourId === null || $sejourId === '' || $nbr === null) {
  3157.             return new \Symfony\Component\HttpFoundation\JsonResponse(['success' => false'message' => 'Données manquantes (photos, séjour ou nombre).'], 400);
  3158.         }
  3159.         // 1) Let the service create the new "Retro" product + store pages
  3160.         //    We’ll define photosRetro_Nouvelle similar to photosPochette_Nouvelle
  3161.         $RetroProduit $service->photosRetro_Nouvelle($photos$user$sejourId$nbr);
  3162.         // 2) Same logic to insert that new product in the user’s Panier
  3163.         //    (Essentially the same as your AddPochetteAuPanier code)
  3164.         $inser false;
  3165.         $Products $session->get("Panier");
  3166.         if (!$Products) {
  3167.             $Products = [];
  3168.         }
  3169.         // The newly created product
  3170.         $produit $em->getRepository(Produit::class)->find($RetroProduit->getId());
  3171.         // A) Check if a "Panier" with status "creer" for this user exists,
  3172.         //    or create one if needed
  3173.         $typeref $em->getRepository(Typeref::class)->find(8);
  3174.         $statutPanier $em->getRepository(Ref::class)->findOneBy([
  3175.             "libiller" => "creer",
  3176.             "typeref" => $typeref
  3177.         ]);
  3178.         $panierTrace $em->getRepository(Panier::class)->findOneBy([
  3179.             "creerPar" => $user,
  3180.             "statut"   => $statutPanier
  3181.         ]);
  3182.         if (!$panierTrace) {
  3183.             $panierTrace = new Panier();
  3184.             $panierTrace->setDateCreation(new \DateTime());
  3185.             $panierTrace->setCreerPar($user);
  3186.             $panierTrace->setStatut($statutPanier);
  3187.             $em->getManager()->persist($panierTrace);
  3188.             $em->getManager()->flush();
  3189.         }
  3190.         // B) Check if this product already exists in $Products
  3191.         foreach ($Products as $key => $p) {
  3192.             if ($p['id'] == $produit->getId()) {
  3193.                 $inser true;
  3194.                 $Products[$key]['qte'] += 1;
  3195.                 $Products[$key]['mnt'] += $produit->getIdConditionnement()->getMontantTTC();
  3196.             }
  3197.         }
  3198.         // C) Check if it also exists in PanierProduit table
  3199.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy([
  3200.             "idProduit" => $produit,
  3201.             "idPanier"  => $panierTrace
  3202.         ]);
  3203.         if (!$panierProduit) {
  3204.             $panierProduit = new PanierProduit();
  3205.             $panierProduit->setIdProduit($produit);
  3206.             $panierProduit->setIdPanier($panierTrace);
  3207.             $em->getManager()->persist($panierProduit);
  3208.             $em->getManager()->flush();
  3209.         }
  3210.         // D) Increase quantity & total
  3211.         $oldQte $panierProduit->getQuantite();
  3212.         $panierProduit->setQuantite($oldQte 1);
  3213.         $oldTotal $panierProduit->getPrixTotal();
  3214.         $panierProduit->setPrixTotal($oldTotal $produit->getIdConditionnement()->getMontantTTC());
  3215.         $em->getManager()->persist($panierProduit);
  3216.         $em->getManager()->flush();
  3217.         // E) If not inserted in $Products above, push new array item
  3218.         if (!$inser) {
  3219.             $p = [
  3220.                 "id"         => $produit->getId(),
  3221.                 "nom"        => $produit->getType()->getLabeletype(),
  3222.                 "ident"      => $produit->getLabele(),
  3223.                 "codesejour" => $produit->getIdsjour()->getcodeSejour(),
  3224.                 "mnt"        => $produit->getIdConditionnement()->getMontantTTC(),
  3225.                 "path"       => $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  3226.                 "condition"  => $produit->getIdConditionnement()->getId(),
  3227.                 "qte"        => 1
  3228.             ];
  3229.             $Products[] = $p;
  3230.         }
  3231.         $session->set('Panier'$Products);
  3232.         /** @var \App\Entity\User $user */
  3233.         $user $this->getUser();
  3234.         $userEmail $user->getEmail();
  3235.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3236.         return new \Symfony\Component\HttpFoundation\JsonResponse(['success' => true]);
  3237.     }
  3238.     /**
  3239.      * @Route("/Parent/SavePhotosRetros", name="SavePhotosRetrosParent")
  3240.      */
  3241.     public function SavePhotosRetrosParent(Request $request)
  3242.     {
  3243.         $em $this->em;
  3244.         $session $this->session;
  3245.         $serviceuser $this->etablissementService;
  3246.         $page $request->get("pages");
  3247.         $sejour $request->get("sejour");
  3248.         $prodid $request->get('idProd');
  3249.         $nomprod $request->get('nomprod');
  3250.         $nbr $request->get('nbr');
  3251.         $comandePanier $request->get('comandePanier');
  3252.         $user $this->getUser();
  3253.         $nbr strval($nbr);
  3254.         $produittype $session->get("produit");
  3255.         $produit $session->get("produittype");
  3256.         $Album $serviceuser->SavePhotosRetrosParents($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3257.         //dd($etablissementDetail);
  3258.         if ($comandePanier == "comandePanier") {
  3259.             $inser false;
  3260.             $Products $session->get("Panier");
  3261.             $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  3262.             //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
  3263.             $user $this->getUser();
  3264.             $typeref $em->getRepository(Typeref::class)->find(8);
  3265.             $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3266.             $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3267.             //fin
  3268.             if ($panierTrace == null) {
  3269.                 $panierTrace = new Panier();
  3270.                 $dateNow = new \Datetime();
  3271.                 $panierTrace->setDateCreation($dateNow);
  3272.                 $panierTrace->setCreerPar($user);
  3273.                 $panierTrace->setStatut($statutPanier);
  3274.                 $em->getManager()->persist($panierTrace);
  3275.                 $em->getManager()->flush();
  3276.             }
  3277.             //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
  3278.             if ($Products == null) {
  3279.                 $Products = [];
  3280.             }
  3281.             foreach ($Products as $key => $p) {
  3282.                 if ($p['id'] == $produit->getId()) {
  3283.                     $inser true;
  3284.                     $Products[$key]['qte'] = $p['qte'] + 1;
  3285.                     $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3286.                 }
  3287.             }
  3288.             //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  3289.             $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3290.             if ($panierProduit == null) {
  3291.                 $panierProduit = new PanierProduit();
  3292.                 $panierProduit->setIdProduit($produit);
  3293.                 $panierProduit->setIdPanier($panierTrace);
  3294.                 $em->getManager()->persist($panierProduit);
  3295.                 $em->getManager()->flush();
  3296.             }
  3297.             //fin
  3298.             //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  3299.             $oldQte $panierProduit->getQuantite();
  3300.             $newQte $oldQte 1;
  3301.             $panierProduit->setQuantite($newQte);
  3302.             $oldTotal $panierProduit->getPrixTotal();
  3303.             $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3304.             $panierProduit->setPrixTotal($newTotal);
  3305.             $em->getManager()->persist($panierProduit);
  3306.             $em->getManager()->flush();
  3307.             //fin
  3308.             if ($inser === false) {
  3309.                 $p = [];
  3310.                 $p["id"] = $produit->getId();
  3311.                 $p["nom"] = $produit->getType()->getLabeletype();
  3312.                 $p["ident"] = $produit->getLabele();
  3313.                 $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3314.                 $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3315.                 $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3316.                 $p["condition"] = $produit->getIdConditionnement()->getId();
  3317.                 $p["qte"] = 1;
  3318.                 array_push($Products$p);
  3319.             }
  3320.             $session->set('Panier'$Products);
  3321.         }
  3322.         //sendmail_parent
  3323.         $dateNow = new \Datetime();
  3324.         /** @var \App\Entity\User $user */
  3325.         $user $this->getUser();
  3326.         $userEmail $user->getEmail();
  3327.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3328.         // $this->EmailServie->MailRelancePanier($userEmail);
  3329.         return new response($Album->getId());
  3330.     }
  3331.     /**
  3332.      * @Route("/Parent/SaveCalendrierParent", name="SaveCalendrierParent")
  3333.      */
  3334.     public function SaveCalendrierParent(Request $request)
  3335.     {
  3336.         $session $this->session;
  3337.         $serviceuser $this->etablissementService;
  3338.         $page $request->get("pages");
  3339.         $sejour $request->get("sejour");
  3340.         $prodid $request->get('idProd');
  3341.         $nomprod $request->get('nomprod');
  3342.         $nbr $request->get('nbr');
  3343.         $user $this->getUser();
  3344.         $nbr strval($nbr);
  3345.         $produittype $session->get("produit");
  3346.         $produit $session->get("produittype");
  3347.         $Album $serviceuser->SaveCalendrierParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3348.         //sendmail_parent
  3349.         $dateNow = new \Datetime();
  3350.         /** @var \App\Entity\User $user */
  3351.         $user $this->getUser();
  3352.         $userEmail $user->getEmail();
  3353.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3354.         //$this->EmailServie->MailRelancePanier($userEmail);
  3355.         return new response('done');
  3356.     }
  3357.     /**
  3358.      * @Route("/Parent/SaveCommandeCalendrierParent", name="SaveCommandeCalendrierParent")
  3359.      */
  3360.     public function SaveCommandeCalendrierParent(Request $request)
  3361.     {
  3362.         $em $this->em;
  3363.         $session $this->session;
  3364.         $serviceuser $this->etablissementService;
  3365.         $page $request->get("pages");
  3366.         $sejour $request->get("sejour");
  3367.         $prodid $request->get('idProd');
  3368.         $nomprod $request->get('nomprod');
  3369.         $nbr $request->get('nbr');
  3370.         $user $this->getUser();
  3371.         $nbr strval($nbr);
  3372.         $produittype $session->get("produit");
  3373.         $produit $session->get("produittype");
  3374.         $Album $serviceuser->SaveCalendrierParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3375.         $inser false;
  3376.         $Products $session->get("Panier");
  3377.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  3378.         //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
  3379.         $user $this->getUser();
  3380.         $typeref $em->getRepository(Typeref::class)->find(8);
  3381.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3382.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3383.         //fin
  3384.         if ($panierTrace == null) {
  3385.             $panierTrace = new Panier();
  3386.             $dateNow = new \Datetime();
  3387.             $panierTrace->setDateCreation($dateNow);
  3388.             $panierTrace->setCreerPar($user);
  3389.             $panierTrace->setStatut($statutPanier);
  3390.             $em->getManager()->persist($panierTrace);
  3391.             $em->getManager()->flush();
  3392.         }
  3393.         //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
  3394.         if ($Products == null) {
  3395.             $Products = [];
  3396.         }
  3397.         foreach ($Products as $key => $p) {
  3398.             if ($p['id'] == $produit->getId()) {
  3399.                 $inser true;
  3400.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3401.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3402.             }
  3403.         }
  3404.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  3405.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3406.         if ($panierProduit == null) {
  3407.             $panierProduit = new PanierProduit();
  3408.             $panierProduit->setIdProduit($produit);
  3409.             $panierProduit->setIdPanier($panierTrace);
  3410.             $em->getManager()->persist($panierProduit);
  3411.             $em->getManager()->flush();
  3412.         }
  3413.         //fin
  3414.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  3415.         $oldQte $panierProduit->getQuantite();
  3416.         $newQte $oldQte 1;
  3417.         $panierProduit->setQuantite($newQte);
  3418.         $oldTotal $panierProduit->getPrixTotal();
  3419.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3420.         $panierProduit->setPrixTotal($newTotal);
  3421.         $em->getManager()->persist($panierProduit);
  3422.         $em->getManager()->flush();
  3423.         //fin
  3424.         if ($inser === false) {
  3425.             $p = [];
  3426.             $p["id"] = $produit->getId();
  3427.             $p["nom"] = $produit->getType()->getLabeletype();
  3428.             $p["ident"] = $produit->getLabele();
  3429.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3430.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3431.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3432.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3433.             $p["qte"] = 1;
  3434.             array_push($Products$p);
  3435.         }
  3436.         $session->set('Panier'$Products);
  3437.         //sendmail_parent
  3438.         $dateNow = new \Datetime();
  3439.         /** @var \App\Entity\User $user */
  3440.         $user $this->getUser();
  3441.         $userEmail $user->getEmail();
  3442.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3443.         // $this->EmailServie->MailRelancePanier($userEmail);
  3444.         return new response('done');
  3445.     }
  3446.     /**
  3447.      * @Route("/Parent/SavePdfParent", name="SavePdfParent")
  3448.      */
  3449.     public function SavePdfParent(Request $request)
  3450.     {
  3451.         //        $blob = $request->get("blob");
  3452.         if (!empty($_POST['blob'])) {
  3453.             $data $_POST['blob'];
  3454.             $fname "test.pdf"// name the file
  3455.             $file fopen("pdf/" $fname'w'); // open the file path
  3456.             fwrite($file$data); //save data
  3457.             fclose($file);
  3458.         } else {
  3459.             echo "No Data Sent";
  3460.         }
  3461.         return new response('ok');
  3462.     }
  3463.     /**
  3464.      * @Route("/Parent/infosphp", name="infos")
  3465.      */
  3466.     public function infos()
  3467.     {
  3468.         echo phpinfo();
  3469.     }
  3470.     /**
  3471.      * @Route("/Parent/RetrosComandeSaveRetros", name="RetrosComandeSaveRetros")
  3472.      */
  3473.     public function RetrosComandeSaveRetros(Request $request)
  3474.     {
  3475.         $em $this->em;
  3476.         $session $this->session;
  3477.         $serviceuser $this->etablissementService;
  3478.         $page $request->get("pages");
  3479.         $sejour $request->get("sejour");
  3480.         $prodid $request->get('idProd');
  3481.         $nomprod $request->get('nomprod');
  3482.         $nbr $request->get('nbr');
  3483.         $user $this->getUser();
  3484.         $nbr strval($nbr);
  3485.         $produittype $session->get("produit");
  3486.         $produit $session->get("produittype");
  3487.         $Album $serviceuser->SavePhotosRetrosParents($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3488.         $inser false;
  3489.         $Products $session->get("Panier");
  3490.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  3491.         //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
  3492.         $user $this->getUser();
  3493.         $typeref $em->getRepository(Typeref::class)->find(8);
  3494.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3495.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3496.         //fin
  3497.         if ($panierTrace == null) {
  3498.             $panierTrace = new Panier();
  3499.             $dateNow = new \Datetime();
  3500.             $panierTrace->setDateCreation($dateNow);
  3501.             $panierTrace->setCreerPar($user);
  3502.             $panierTrace->setStatut($statutPanier);
  3503.             $em->getManager()->persist($panierTrace);
  3504.             $em->getManager()->flush();
  3505.         }
  3506.         //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
  3507.         if ($Products == null) {
  3508.             $Products = [];
  3509.         }
  3510.         foreach ($Products as $key => $p) {
  3511.             if ($p['id'] == $produit->getId()) {
  3512.                 $inser true;
  3513.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3514.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3515.             }
  3516.         }
  3517.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  3518.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3519.         if ($panierProduit == null) {
  3520.             $panierProduit = new PanierProduit();
  3521.             $panierProduit->setIdProduit($produit);
  3522.             $panierProduit->setIdPanier($panierTrace);
  3523.             $em->getManager()->persist($panierProduit);
  3524.             $em->getManager()->flush();
  3525.         }
  3526.         //fin
  3527.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  3528.         $oldQte $panierProduit->getQuantite();
  3529.         $newQte $oldQte 1;
  3530.         $panierProduit->setQuantite($newQte);
  3531.         $oldTotal $panierProduit->getPrixTotal();
  3532.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3533.         $panierProduit->setPrixTotal($newTotal);
  3534.         $em->getManager()->persist($panierProduit);
  3535.         $em->getManager()->flush();
  3536.         //fin
  3537.         if ($inser === false) {
  3538.             $p = [];
  3539.             $p["id"] = $produit->getId();
  3540.             $p["nom"] = $produit->getType()->getLabeletype();
  3541.             $p["ident"] = $produit->getLabele();
  3542.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3543.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3544.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3545.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3546.             $p["qte"] = 1;
  3547.             array_push($Products$p);
  3548.         }
  3549.         $session->set('Panier'$Products);
  3550.         return new response('done');
  3551.     }
  3552.     /**
  3553.      * @Route("/Parent/nbvisite", name="nbvisite",methods={"POST","GET"})
  3554.      */
  3555.     public function ajouternombrevisite(Request $request)
  3556.     {
  3557.         $SejourService $this->sejourService;
  3558.         $CarteService $this->carteService;
  3559.         $typevisite $request->get("typevisite");
  3560.         $idsejour $request->get("idsejour");
  3561.         $idattach $request->get("idattachement");
  3562.         if ($typevisite == "carte") {
  3563.             $nbvisite $CarteService->carteVisite($idsejour);
  3564.         } else {
  3565.             $nbvisite $SejourService->affectationnbvisiteattachement($idsejour$idattach);
  3566.         }
  3567.         return new JsonResponse('done');
  3568.     }
  3569.     /**
  3570.      * @Route("/Parent/ajouterauPanier_Parent", name="Ajouter_MonPanier")
  3571.      */
  3572.     public function Ajouter_MonPanier(Request $request)
  3573.     {
  3574.         $inser false;
  3575.         $session $this->session;
  3576.         $em $this->em;
  3577.         $Products $session->get("Panier");
  3578.         $id $request->get("id");
  3579.         //Touhemi :Rechercher  si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
  3580.         $user $this->getUser();
  3581.         $typeref $em->getRepository(Typeref::class)->find(8);
  3582.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3583.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3584.         //fin
  3585.         if ($panierTrace == null) {
  3586.             $panierTrace = new Panier();
  3587.             $dateNow = new \Datetime();
  3588.             $panierTrace->setDateCreation($dateNow);
  3589.             $panierTrace->setCreerPar($user);
  3590.             $panierTrace->setStatut($statutPanier);
  3591.             $em->getManager()->persist($panierTrace);
  3592.             $em->getManager()->flush();
  3593.         }
  3594.         $produit $this->em->getRepository(Produit::class)->find($id);
  3595.         if ($Products == null) {
  3596.             $Products = [];
  3597.         }
  3598.         //Touhemi :Rechercher  si le produti existe déja ds panierProduit
  3599.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3600.         if ($panierProduit == null) {
  3601.             $panierProduit = new PanierProduit();
  3602.             $panierProduit->setIdProduit($produit);
  3603.             $panierProduit->setIdPanier($panierTrace);
  3604.             $em->getManager()->persist($panierProduit);
  3605.             $em->getManager()->flush();
  3606.         }
  3607.         //fin
  3608.         foreach ($Products as $key => $p) {
  3609.             if ($p['id'] == $produit->getId()) {
  3610.                 $inser true;
  3611.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3612.             }
  3613.         }
  3614.         //Touhemi ajouter plus un au produit et modifier prixTotal
  3615.         $oldQte $panierProduit->getQuantite();
  3616.         $newQte $oldQte 1;
  3617.         $panierProduit->setQuantite($newQte);
  3618.         $oldTotal $panierProduit->getPrixTotal();
  3619.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3620.         $panierProduit->setPrixTotal($newTotal);
  3621.         $this->em->getManager()->persist($panierProduit);
  3622.         $this->em->getManager()->flush();
  3623.         //fin
  3624.         if ($inser === false) {
  3625.             //get nessaisire element
  3626.             $p = [];
  3627.             $p["id"] = $produit->getId();
  3628.             $p["nom"] = $produit->getType()->getLabeletype();
  3629.             $p["ident"] = $produit->getLabele();
  3630.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3631.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3632.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3633.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3634.             $p["qte"] = 1;
  3635.             array_push($Products$p);
  3636.         }
  3637.         $session->set('Panier'$Products);
  3638.         return new JsonResponse(['success' => true'message' => 'Produit ajouté au panier']);
  3639.     }
  3640.     /**
  3641.      * Ajoute l'album du séjour au panier et redirige vers la page commande.
  3642.      * @Route("/Parent/Ajouter_Album_Sejour_Et_Commander", name="Ajouter_Album_Sejour_Et_Commander", methods={"GET"})
  3643.      */
  3644.     public function Ajouter_Album_Sejour_Et_Commander(Request $request)
  3645.     {
  3646.         $id $request->query->get('id');
  3647.         if (!$id) {
  3648.             $this->addFlash('warning''Album non spécifié.');
  3649.             return $this->redirectToRoute('Album_du_Sejour');
  3650.         }
  3651.         $session $this->session;
  3652.         $em $this->em;
  3653.         $user $this->getUser();
  3654.         if (!$user) {
  3655.             return $this->redirectToRoute('app_login');
  3656.         }
  3657.         $Products $session->get('Panier');
  3658.         if ($Products === null) {
  3659.             $Products = [];
  3660.         }
  3661.         $typeref $em->getRepository(Typeref::class)->find(8);
  3662.         $statutPanier $em->getRepository(Ref::class)->findOneBy(['libiller' => 'creer''typeref' => $typeref]);
  3663.         $panierTrace $em->getRepository(Panier::class)->findOneBy(['creerPar' => $user'statut' => $statutPanier]);
  3664.         if ($panierTrace === null) {
  3665.             $panierTrace = new Panier();
  3666.             $panierTrace->setDateCreation(new \DateTime());
  3667.             $panierTrace->setCreerPar($user);
  3668.             $panierTrace->setStatut($statutPanier);
  3669.             $em->getManager()->persist($panierTrace);
  3670.             $em->getManager()->flush();
  3671.         }
  3672.         $produit $em->getRepository(Produit::class)->find($id);
  3673.         if (!$produit) {
  3674.             $this->addFlash('error''Album introuvable.');
  3675.             return $this->redirectToRoute('Album_du_Sejour');
  3676.         }
  3677.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(['idProduit' => $produit'idPanier' => $panierTrace]);
  3678.         if ($panierProduit === null) {
  3679.             $panierProduit = new PanierProduit();
  3680.             $panierProduit->setIdProduit($produit);
  3681.             $panierProduit->setIdPanier($panierTrace);
  3682.             $em->getManager()->persist($panierProduit);
  3683.             $em->getManager()->flush();
  3684.         }
  3685.         $oldQte $panierProduit->getQuantite();
  3686.         $panierProduit->setQuantite($oldQte 1);
  3687.         $oldTotal $panierProduit->getPrixTotal();
  3688.         $panierProduit->setPrixTotal($oldTotal $produit->getIdConditionnement()->getMontantTTC());
  3689.         $em->getManager()->persist($panierProduit);
  3690.         $em->getManager()->flush();
  3691.         $inser false;
  3692.         foreach ($Products as $key => $p) {
  3693.             if (isset($p['id']) && (int) $p['id'] === (int) $produit->getId()) {
  3694.                 $inser true;
  3695.                 $Products[$key]['qte'] = ($p['qte'] ?? 1) + 1;
  3696.                 $Products[$key]['mnt'] = ($p['mnt'] ?? 0) + $produit->getIdConditionnement()->getMontantTTC();
  3697.                 break;
  3698.             }
  3699.         }
  3700.         if (!$inser) {
  3701.             $attachments $produit->getType()->getAttachements();
  3702.             $path $attachments && $attachments->count() > 0
  3703.                 $attachments->get(0)->getIdAttachement()->getPath()
  3704.                 : '';
  3705.             $Products[] = [
  3706.                 'id' => $produit->getId(),
  3707.                 'nom' => $produit->getType()->getLabeletype(),
  3708.                 'ident' => $produit->getLabele(),
  3709.                 'codesejour' => $produit->getIdsjour()->getcodeSejour(),
  3710.                 'mnt' => $produit->getIdConditionnement()->getMontantTTC(),
  3711.                 'path' => $path,
  3712.                 'condition' => $produit->getIdConditionnement()->getId(),
  3713.                 'qte' => 1,
  3714.             ];
  3715.         }
  3716.         $session->set('Panier'$Products);
  3717.         return $this->redirectToRoute('Commander');
  3718.     }
  3719.     /**
  3720.      * @Route("/Parent/Ajouter_Album_Parent", name="Ajouter_Album_Parent_Alb")
  3721.      */
  3722.     public function Ajouter_Album(Request $request)
  3723.     {
  3724.         $session $this->session;
  3725.         $id $request->get("id");
  3726.         $typeProdcondition $this->em->getRepository(TypeProduitConditionnement::class)->find($id);
  3727.         $typeprod $typeProdcondition->getIdTypeProduit()->getId();
  3728.         $session->set('produit'$id);
  3729.         $session->set('produitconditionAlbum'$id);
  3730.         $session->set('produittype'$typeprod);
  3731.         return new JsonResponse('done');
  3732.     }
  3733.     /**
  3734.      * @Route("/Parent/ComandeParent", name="ComandeParent")
  3735.      */
  3736.     public function comande_Parent(Request $request)
  3737.     {
  3738.         $session $this->session;
  3739.         // $comande = $request->get("p");
  3740.         $Panier $session->get("Panier");
  3741.         $session->set('comande'$Panier);
  3742.         return new JsonResponse('done');
  3743.     }
  3744.     /**
  3745.      * @Route("/Parent/Accueil5sur5/adresse_comande", name="adresse_comande",methods={"POST"})
  3746.      */
  3747.     public function adresse_comande(Request $request)
  3748.     {
  3749.         $UserService $this->userService;
  3750.         /** @var \App\Entity\User $user */
  3751.         $user $this->getUser();
  3752.         $iduser $user->getId();
  3753.         $idCommande $request->get("idCommande");
  3754.         $prenom $request->get("prenom");
  3755.         $nom $request->get("nom");
  3756.         $organism $request->get("organism");
  3757.         $rue $request->get('ruevoi');
  3758.         $ville $request->get("villle");
  3759.         $pays $request->get("pays");
  3760.         $codepostal $request->get("codpostal");
  3761.         //adress facturation if exsist
  3762.         $prenomfacturation $request->get("prenomadressfacturation");
  3763.         $nomfacturation $request->get("nomadressfacturation");
  3764.         $organismfacturation $request->get("etablismadressfacturation");
  3765.         $ruefacturation $request->get('rueadressfacturation');
  3766.         $villefacturation $request->get("villefacturation");
  3767.         $paysfacturation $request->get("payadressfacturation");
  3768.         $codepostalfacturation $request->get("codepostalfacturation");
  3769.         //modification userPArent
  3770.         $em $this->em;
  3771.         $adress $UserService->modifieradress_comande($rue$ville$pays$codepostal$iduser$prenom$nom$organism$prenomfacturation$nomfacturation$organismfacturation$ruefacturation$villefacturation$paysfacturation$codepostalfacturation);
  3772.         $commande $em->getRepository(Commande::class)->findOneBy(array("id" => $idCommande));
  3773.         $commande->setAdresslivraison($adress);
  3774.         $commande->setAddresseLivraison($ville);
  3775.         $commande->setAdressfactoration($adress);
  3776.         $em->getManager()->persist($commande);
  3777.         $em->getManager()->flush();
  3778.         return new JsonResponse('Adresse Enregitrée');
  3779.     }
  3780.     /**
  3781.      * @Route("/Parent/Accueil5sur5/codesecuriter", name="codesecuriter",methods={"POST"})
  3782.      */
  3783.     public function codesecuriter(Request $request)
  3784.     {
  3785.         $UserService $this->userService;
  3786.         /** @var \App\Entity\User $user */
  3787.         $user $this->getUser();
  3788.         $iduser $user->getId();
  3789.         $code1 $request->get("code1");
  3790.         $code2 $request->get("code2");
  3791.         $code3 $request->get("code3");
  3792.         $set1 $request->get("set");
  3793.         if ($set1 == 1) {
  3794.             if ($code1 == "") {
  3795.                 return new Response('erore');
  3796.             }
  3797.             $adress $UserService->codesecuriter($code1$iduser);
  3798.         }
  3799.         if ($set1 == 2) {
  3800.             if ($code2 == "") {
  3801.                 return new Response('erore');
  3802.             }
  3803.             $adress $UserService->codesecuriter($code2$iduser);
  3804.         }
  3805.         if ($set1 == 3) {
  3806.             if ($code3 == "") {
  3807.                 return new Response('erore');
  3808.             }
  3809.             $adress $UserService->codesecuriter($code3$iduser);
  3810.         }
  3811.         return new Response('done');
  3812.     }
  3813.     /**
  3814.      * @Route("/Parent/Accueil5sur5/suprimer_Album_panier", name="suprimer_Album_panier",methods={"POST"})
  3815.      */
  3816.     public function suprimer_Album_panier(Request $request)
  3817.     {
  3818.         $id $request->get('p') ?? $request->get('id');
  3819.         if ($id === null) {
  3820.             return new Response('error'400);
  3821.         }
  3822.         $session $this->session;
  3823.         $Products $session->get('Panier') ?? [];
  3824.         if (is_array($Products)) {
  3825.             foreach ($Products as $key => $p) {
  3826.                 if (isset($p['id']) && (int) $p['id'] === (int) $id) {
  3827.                     unset($Products[$key]);
  3828.                 }
  3829.             }
  3830.             $session->set('Panier'array_values($Products));
  3831.         }
  3832.         $em $this->em;
  3833.         $user $this->getUser();
  3834.         $produit $em->getRepository(Produit::class)->find($id);
  3835.         if (!$produit) {
  3836.             return new Response('error'404);
  3837.         }
  3838.         // Marquer le produit comme supprimé pour qu'il disparaisse de la page Mes créations
  3839.         $produit->setDelated(1);
  3840.         $em->getManager()->persist($produit);
  3841.         $typeref $em->getRepository(Typeref::class)->find(8);
  3842.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3843.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3844.         $panierProduit $panierTrace $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace)) : null;
  3845.         if ($panierProduit !== null) {
  3846.             $em->getManager()->remove($panierProduit);
  3847.         }
  3848.         $em->getManager()->flush();
  3849.         return new Response('done');
  3850.     }
  3851.     /**
  3852.      * @Route("/Parent/Accueil5sur5/additiondproduit_parent", name="additiondproduit_parent",methods={"POST"})
  3853.      */
  3854.     public function additiondproduit_parent(Request $request)
  3855.     {
  3856.         $session $this->session;
  3857.         $Products $session->get("Panier");
  3858.         $id $request->get("p");
  3859.         foreach ($Products as $key => $p) {
  3860.             if ($p['id'] == $id) {
  3861.                 $qte_dans_panier $Products[$key]['qte'];
  3862.                 $mnt_dans_panier $Products[$key]['mnt'] / $qte_dans_panier;
  3863.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3864.                 // $Products[$key]['mnt']=$p['mnt']+$mnt_dans_panier;
  3865.             }
  3866.         }
  3867.         $session->set('Panier'$Products);
  3868.         //Touhemi addition au panier produit ds bd
  3869.         $em $this->em;
  3870.         $user $this->getUser();
  3871.         $produit $em->getRepository(Produit::class)->find($id);
  3872.         $typeref $em->getRepository(Typeref::class)->find(8);
  3873.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3874.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3875.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3876.         if ($panierProduit != null) {
  3877.             $oldQte $panierProduit->getQuantite();
  3878.             $newQte $oldQte 1;
  3879.             $panierProduit->setQuantite($newQte);
  3880.             $oldTotal $panierProduit->getPrixTotal();
  3881.             $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3882.             $panierProduit->setPrixTotal($newTotal);
  3883.             $em->getManager()->persist($panierProduit);
  3884.             $em->getManager()->flush();
  3885.         }
  3886.         return new Response('done');
  3887.     }
  3888.     /**
  3889.      * @Route("/Parent/Accueil5sur5/sousstractionproduit_parent", name="sousstractionproduit_parent",methods={"POST"})
  3890.      */
  3891.     public function sousstractionproduit_parent(Request $request)
  3892.     {
  3893.         $session $this->session;
  3894.         $Products $session->get("Panier");
  3895.         $id $request->get("p");
  3896.         foreach ($Products as $key => $p) {
  3897.             if ($p['id'] == $id) {
  3898.                 $qte_dans_panier $Products[$key]['qte'];
  3899.                 $mnt_dans_panier $Products[$key]['mnt'] / $qte_dans_panier;
  3900.                 $Products[$key]['qte'] = $p['qte'] - 1;
  3901.                 // $Products[$key]['mnt']=$p['mnt']-$mnt_dans_panier;
  3902.                 $set $Products[$key];
  3903.             }
  3904.             if ($Products[$key]['qte'] == 0) {
  3905.                 unset($Products[$key]);
  3906.             }
  3907.         }
  3908.         $session->set('Panier'$Products);
  3909.         $em $this->em;
  3910.         $user $this->getUser();
  3911.         $produit $em->getRepository(Produit::class)->find($id);
  3912.         $typeref $em->getRepository(Typeref::class)->find(8);
  3913.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3914.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3915.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3916.         if ($panierProduit != null) {
  3917.             $oldQte $panierProduit->getQuantite();
  3918.             $newQte $oldQte 1;
  3919.             if ($newQte 0) {
  3920.                 $panierProduit->setQuantite($newQte);
  3921.                 $oldTotal $panierProduit->getPrixTotal();
  3922.                 $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3923.                 $panierProduit->setPrixTotal($newTotal);
  3924.                 $em->getManager()->persist($panierProduit);
  3925.                 $em->getManager()->flush();
  3926.             }
  3927.             if ($newQte == 0) {
  3928.                 $em->getManager()->remove($panierProduit);
  3929.                 $em->getManager()->flush();
  3930.             }
  3931.         }
  3932.         return new Response('done');
  3933.     }
  3934.     /**
  3935.      * @Route("Parent/AjoutAlbum_parent/{idAlbm}", name="EditionAlbumfrompanier")
  3936.      */
  3937.     public function EditionAlbumParent_panier($idAlbm)
  3938.     {
  3939.         $SEjourService $this->sejourService;
  3940.         /** @var \App\Entity\User $user */
  3941.         $user $this->getUser();
  3942.         $userId $user->getId();
  3943.         $user $this->getUser();
  3944.         $session $this->session;
  3945.         $session->set('pageMenu''');
  3946.         $idSejour $session->get("Sejour");
  3947.         $produitcondition $session->get("produit");
  3948.         $produit $session->get("produittype");
  3949.         $sejour $SEjourService->getsejourpourparent($idSejour);
  3950.         $em $this->em;
  3951.         $clipart null;
  3952.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  3953.         $nbLikes 0;
  3954.         if ($listeattachlikephoto) {
  3955.             $nbLikes count($listeattachlikephoto);
  3956.         }
  3957.         $AllPages null;
  3958.         $Albumproduct null;
  3959.         $AllPagesAcc null;
  3960.         $random false;
  3961.         $Albumproduct $em->getRepository(Produit::class)->find($idAlbm);
  3962.         if ($Albumproduct == null || $Albumproduct == "") {
  3963.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
  3964.             $random true;
  3965.         }
  3966.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  3967.         $idAcc $sejour->getIdAcommp();
  3968.         $albumAcc null;
  3969.         $allpagesResult = array();
  3970.         $tabacc = array();
  3971.         $tabacc1 = array();
  3972.         foreach ($AllPages as $page) {
  3973.             $pageJ json_decode($page->getCouleurbordure());
  3974.             $pageDec json_decode($pageJ[0]);
  3975.             $attache json_decode($pageDec->attache);
  3976.             foreach ($attache as $att) {
  3977.                 $attachDec json_decode($att);
  3978.                 if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  3979.                     $idAttach json_decode($attachDec->id);
  3980.                     array_push($tabacc$idAttach);
  3981.                 }
  3982.             }
  3983.         }
  3984.         $tabacc1 array_count_values($tabacc);
  3985.         $part $sejour->getIdPartenaire();
  3986.         $nompart $part->getUsername();
  3987.         $logopart $part->getLogourl();
  3988.         $session->set('produit'$Albumproduct->gettype());
  3989.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  3990.         $nbphoto count($listeattach);
  3991.         if ($Albumproduct->getVersion() === 'new') {
  3992.             if ($nbLikes != 0) {
  3993.                 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]);
  3994.             }
  3995.             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]);
  3996.         } else {
  3997.             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]);
  3998.         }
  3999.     }
  4000.     /**
  4001.      * @Route("/Parent/Accueil5sur5/modifierLabel_produit_parent", name="modifierLabel_produit_parent",methods={"POST"})
  4002.      */
  4003.     public function modifierLabel_produit_parent(Request $request)
  4004.     {
  4005.         $SEjourService $this->sejourService;
  4006.         /** @var \App\Entity\User $user */
  4007.         $user $this->getUser();
  4008.         $userId $user->getId();
  4009.         $session $this->session;
  4010.         $idPrd $request->get("id");
  4011.         $description $request->get("description");
  4012.         $SEjourService->modif_lbel_Produit($idPrd$description);
  4013.         $Products $session->get("Panier");
  4014.         if ($Products != null) {
  4015.             foreach ($Products as $key => $p) {
  4016.                 if ($idPrd == $p['id']) {
  4017.                     $Products[$key]["ident"] = $description;
  4018.                 }
  4019.             }
  4020.         }
  4021.         $session->set('Panier'$Products);
  4022.         return new Response('done');
  4023.     }
  4024.     /**
  4025.      * @Route("/Parent/checkCodePromoParents", name="checkCodePromoParents")
  4026.      */
  4027.     public function checkCodePromoParents(Request $request)
  4028.     {
  4029.         $em $this->em;
  4030.         $SejourService $this->sejourService;
  4031.         $session $this->get('session');
  4032.         $code $request->get('code');
  4033.         $idUser $request->get('idUser');
  4034.         $user $em->getRepository(User::class)->findOneBy(['id' => $idUser]);
  4035.         $CodePromoUtilisse "";
  4036.         $totalpanier  $request->get('totalPanier');
  4037.         $infosPromo $SejourService->checkCodePromoPrents($code$user);
  4038.         $remise 0;
  4039.         $pourcentage 0;
  4040.         if (isset($infosPromo['remise'])) {
  4041.             $remise =  $infosPromo['remise'];
  4042.         }
  4043.         if (isset($infosPromo['pourcentage'])) {
  4044.             $pourcentage =  $infosPromo['pourcentage'];
  4045.         }
  4046.         $totalRemise $totalpanier $pourcentage;
  4047.         $totalRemise = ($totalRemise) / 100;
  4048.         $totalpanierNew $totalpanier $totalRemise;
  4049.         $tvaTotalRemise =   ($totalpanierNew 20) / 100;
  4050.         $reason = isset($infosPromo['reason']) ? $infosPromo['reason'] : null;
  4051.         return new JsonResponse(array('message' =>  $infosPromo['test'], 'pourcentage' => intval($infosPromo['pourcentage']), 'remise' => $remise'totalDupanier' => $totalpanierNew'totalRemise' => $totalRemise"tvaTotalRemise" => $tvaTotalRemise"CodePromoUtilisse" => $CodePromoUtilisse"reason" => $reason), 200);
  4052.     }
  4053.     /**
  4054.      * @Route("/Parent/Accueil5sur5/ParentcomandeProduit", name="ParentcomandeProduit",methods={"POST"})
  4055.      */
  4056.     public function ParentcomandeProduit(Request $request)
  4057.     {
  4058.         $em $this->em;
  4059.         $comandeservice $this->commandeService;
  4060.         $sejourService $this->sejourService;
  4061.         /** @var \App\Entity\User $user */
  4062.         $user $this->getUser();
  4063.         $userId $user->getId();
  4064.         $session $this->session;
  4065.         $frais $request->get("fraiEnvoi");
  4066.         $Products $session->get("Panier");
  4067.         $totalepanier $request->get("totalepanier");
  4068.         $envoipost $request->get("envoipost");
  4069.         $remise $request->get("remise");
  4070.         $totalBlackFriday $request->get("totalBlackFriday");
  4071.         $session->set('envoipost'$envoipost);
  4072.         $containsProduitType20 false;
  4073.         $comand $comandeservice->addcomande_parent($Products$userId$frais$totalepanier$envoipost$remise$containsProduitType20);
  4074.         $codePromo $request->get('codePromo');
  4075.         $test $sejourService->checkCodePromo($codePromo);
  4076.         if (isset($test['test'])) {
  4077.             if ($test['test'] == true) {
  4078.                 $promotion $sejourService->findPromotionByCode($codePromo);
  4079.                 if ($promotion) {
  4080.                     $listeProduitsCommande $em->getRepository(ComandeProduit::class)->findBy(array('idComande' => $comand->getId()));
  4081.                     $pourcentage intval($promotion->getPourcentage());
  4082.                     if ($promotion->getNbreApplicable() == 1) {
  4083.                         foreach ($listeProduitsCommande as $cmdProduit) {
  4084.                             $cmdProduit->setPourcentage($pourcentage);
  4085.                             $em->getManager()->persist($cmdProduit);
  4086.                             $em->getManager()->flush();
  4087.                         }
  4088.                     } else {
  4089.                         foreach ($listeProduitsCommande as $cmdProduit) {
  4090.                             $qte $cmdProduit->getQuantiter();
  4091.                             for ($i 0$i $qte$i++) {
  4092.                                 $ligneCmdProd = new ComandeProduit();
  4093.                                 $ligneCmdProd->setQuantiter(1);
  4094.                                 $ligneCmdProd->setIdProduit($cmdProduit->getIdProduit());
  4095.                                 $ligneCmdProd->setIdComande($cmdProduit->getIdComande());
  4096.                                 $ligneCmdProd->setDate($cmdProduit->getDate());
  4097.                                 $em->getManager()->persist($ligneCmdProd);
  4098.                                 $em->getManager()->remove($cmdProduit);
  4099.                             }
  4100.                             $em->getManager()->flush();
  4101.                         }
  4102.                         $listeProduitsCommande $em->getRepository(ComandeProduit::class)->findBy(array('idComande' => $comand->getId()));
  4103.                         $qte 0;
  4104.                         $tabPrices = [];
  4105.                         foreach ($listeProduitsCommande as $cmdProduit) {
  4106.                             $ligne = array('idCmdProduit' => $cmdProduit->getId(), 'price' => $cmdProduit->getIdProduit()->getIdConditionnement()->getMontantTTC());
  4107.                             $qte += $cmdProduit->getQuantiter();
  4108.                             array_push($tabPrices$ligne);
  4109.                         }
  4110.                         $x intval($qte $promotion->getNbreApplicable());
  4111.                         $this->aasort($tabPrices"price");
  4112.                         $tabPricesPromo =   array_slice($tabPrices, -$x$xtrue);
  4113.                         foreach ($tabPricesPromo as $item) {
  4114.                             $cp $em->getRepository(ComandeProduit::class)->find($item['idCmdProduit']);
  4115.                             $cp->setPourcentage($pourcentage);
  4116.                             $em->getManager()->persist($cp);
  4117.                             $em->getManager()->flush();
  4118.                         }
  4119.                     }
  4120.                     $comand->setIdPromotion($promotion);
  4121.                     // Recalculer le montant total en tenant compte de la remise sur chaque ligne
  4122.                     $listeProduitsCommandeFinale $em->getRepository(ComandeProduit::class)->findBy(array('idComande' => $comand->getId()));
  4123.                     $nouveauMontant 0;
  4124.                     foreach ($listeProduitsCommandeFinale as $cmdProduit) {
  4125.                         $prixUnit floatval($cmdProduit->getIdProduit()->getIdConditionnement()->getMontantTTC());
  4126.                         $qte = (int) $cmdProduit->getQuantiter();
  4127.                         $pctRemise intval($cmdProduit->getPourcentage());
  4128.                         $montantLigne $prixUnit $qte * ($pctRemise 100);
  4129.                         $nouveauMontant += $montantLigne;
  4130.                     }
  4131.                     $comand->setMontantrth(round($nouveauMontant2));
  4132.                     $em->getManager()->persist($comand);
  4133.                     $em->getManager()->flush();
  4134.                     $sejourService->createLogPromotion($promotion$comand$user);
  4135.                 }
  4136.             }
  4137.         }
  4138.         $session->set('commandeActual'$comand->getId());
  4139.         return new Response($comand->getId());
  4140.     }
  4141.     function aasort(&$array$key)
  4142.     {
  4143.         $sorter = array();
  4144.         $ret = array();
  4145.         reset($array);
  4146.         foreach ($array as $ii => $va) {
  4147.             $sorter[$ii] = $va[$key];
  4148.         }
  4149.         arsort($sorter);
  4150.         foreach ($sorter as $ii => $va) {
  4151.             $ret[$ii] = $array[$ii];
  4152.         }
  4153.         $array $ret;
  4154.     }
  4155.     /**
  4156.      * @Route("Parent/LivreSejourParent", name="Livre_du_Sejour")
  4157.      */
  4158.     public function LivreSejourParent()
  4159.     {
  4160.         $SEjourService $this->sejourService;
  4161.         /** @var \App\Entity\User $user */
  4162.         $user $this->getUser();
  4163.         $userId $user->getId();
  4164.         $user $this->getUser();
  4165.         $session $this->session;
  4166.         $idSejour $session->get("Sejour");
  4167.         $session->set('LivreSejour''LivreSejour');
  4168.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4169.         $em $this->em;
  4170.         $clipart null;
  4171.         $AllPages null;
  4172.         $AllPagesAcc null;
  4173.         $random false;
  4174.         $codeSejour $sejour->getCodeSejour();
  4175.         $nomprod "Livre_Sejour" $codeSejour;
  4176.         $sejour $em->getRepository(Sejour::class)->findOneBy(['id' => $idSejour]);
  4177.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['version' => 'Livre_Sejour_Admin''labele' => $nomprod'idsjour' => $idSejour]);
  4178.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4179.         $tabacc = array();
  4180.         $tabacc1 = array();
  4181.         foreach ($AllPages as $page) {
  4182.             $pageJ json_decode($page->getCouleurbordure());
  4183.             $pageDec json_decode($pageJ[0]);
  4184.             $attache json_decode($pageDec->attache);
  4185.             foreach ($attache as $att) {
  4186.                 $attachDec json_decode($att);
  4187.                 if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  4188.                     $idAttach json_decode($attachDec->id);
  4189.                     array_push($tabacc$idAttach);
  4190.                 }
  4191.             }
  4192.         }
  4193.         $tabacc1 array_count_values($tabacc);
  4194.         $part $sejour->getIdPartenaire();
  4195.         $nompart $part->getUsername();
  4196.         $logopart $part->getLogourl();
  4197.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4198.         $nbPhoto count($listeattach);
  4199.         //  $session->set('produit', $Albumproduct->gettype());
  4200.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4201.         $nbLikes count($listeattachlikephoto);
  4202.         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]);
  4203.     }
  4204.     /**
  4205.      * @Route("Parent/LivrePhotos_Parent/{idAlbm}", name="Editionlivrefrompanier")
  4206.      */
  4207.     public function EditionLivrePhotosParentparId($idAlbm)
  4208.     {
  4209.         $SEjourService $this->sejourService;
  4210.         /** @var \App\Entity\User $user */
  4211.         $user $this->getUser();
  4212.         $userId $user->getId();
  4213.         $user $this->getUser();
  4214.         $session $this->session;
  4215.         $session->set('pageMenu''');
  4216.         $idSejour $session->get("Sejour");
  4217.         $produit $session->get("produit");
  4218.         // $sejour = $SEjourService->getsejourpourparent($idSejour);
  4219.         $sejour $this->em->getRepository(Sejour::class)->findOneBy(["id" => $idSejour]);
  4220.         $em $this->em;
  4221.         $clipart null;
  4222.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4223.         $nbLikes count($listeattachlikephoto);
  4224.         $AllPages null;
  4225.         $Albumproduct null;
  4226.         $AllPagesAcc null;
  4227.         $random false;
  4228.         $Albumproduct $em->getRepository(Produit::class)->find($idAlbm);
  4229.         if ($Albumproduct == null || $Albumproduct == "") {
  4230.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
  4231.             $random true;
  4232.         }
  4233.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4234.         $idAcc $sejour->getIdAcommp();
  4235.         $albumAcc null;
  4236.         $allpagesResult = array();
  4237.         $tabacc = array();
  4238.         $tabacc1 = array();
  4239.         foreach ($AllPages as $page) {
  4240.             $pageJ json_decode($page->getCouleurbordure());
  4241.             $pageDec json_decode($pageJ[0]);
  4242.             $attache json_decode($pageDec->attache);
  4243.             foreach ($attache as $att) {
  4244.                 $attachDec json_decode($att);
  4245.                 if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  4246.                     $idAttach json_decode($attachDec->id);
  4247.                     array_push($tabacc$idAttach);
  4248.                 }
  4249.             }
  4250.         }
  4251.         $tabacc1 array_count_values($tabacc);
  4252.         $part $sejour->getIdPartenaire();
  4253.         $nompart $part->getUsername();
  4254.         $logopart $part->getLogourl();
  4255.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4256.         $nbPhoto count($listeattach);
  4257.         $session->set('produit'$Albumproduct->gettype());
  4258.         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]);
  4259.     }
  4260.     /**
  4261.      * @Route("Parent/ModificationPochettePhotos/{nbr}/{id}", name="EditionPochettefrompanier")
  4262.      */
  4263.     public function EditionPochetteParentfrompanier($nbr$id)
  4264.     {
  4265.         $SEjourService $this->sejourService;
  4266.         /** @var \App\Entity\User $user */
  4267.         $user $this->getUser();
  4268.         $userId $user->getId();
  4269.         $user $this->getUser();
  4270.         $session $this->session;
  4271.         $session->set('pageMenu''');
  4272.         $idSejour $session->get("Sejour");
  4273.         $produitcondition $session->get("produit");
  4274.         $produit $session->get("produittype");
  4275.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4276.         $em $this->em;
  4277.         $clipart $em->getRepository(Clipart::class)->findAll();
  4278.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4279.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4280.         $nbLikes count($listeattachlikephoto);
  4281.         //Stella
  4282.         $AllPagesAcc null;
  4283.         $random false;
  4284.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  4285.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4286.         $idAcc $sejour->getIdAcommp();
  4287.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4288.         $part $sejour->getIdPartenaire();
  4289.         $nompart $part->getUsername();
  4290.         $logopart $part->getLogourl();
  4291.         $nomProjet $Albumproduct->getLabele();
  4292.         $nbPhoto count($listeattach);
  4293.         $nbLikes count($listeattachlikephoto);
  4294.         if ($nbLikes $nbr) {
  4295.             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]);
  4296.         }
  4297.         if ($nbLikes >= $nbr) {
  4298.             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]);
  4299.         }
  4300.     }
  4301.     /**
  4302.      * @Route("Parent/ModificationCalendrier/{id}", name="EditionCalendrierParentfrompanier")
  4303.      */
  4304.     public function EditionCalendrierParentfrompanier($id)
  4305.     {
  4306.         $SEjourService $this->sejourService;
  4307.         /** @var \App\Entity\User $user */
  4308.         $user $this->getUser();
  4309.         $userId $user->getId();
  4310.         $user $this->getUser();
  4311.         $session $this->session;
  4312.         $session->set('pageMenu''');
  4313.         $idSejour $session->get("Sejour");
  4314.         $produitcondition $session->get("produit");
  4315.         $produit $session->get("produittype");
  4316.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4317.         $em $this->em;
  4318.         $clipart $em->getRepository(Clipart::class)->findAll();
  4319.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4320.         $random false;
  4321.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  4322.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4323.         $part $sejour->getIdPartenaire();
  4324.         $nompart $part->getUsername();
  4325.         $logopart $part->getLogourl();
  4326.         return $this->render('Parent/Calendrier.html.twig', ["nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'random' => $random]);
  4327.     }
  4328.     /**
  4329.      * @Route("Parent/ModificationPhotosRetros/{nbr}/{id}", name="EditionRetrofrompanier")
  4330.      */
  4331.     public function EditionRetroParentfrompanier($nbr$id)
  4332.     {
  4333.         $SEjourService $this->sejourService;
  4334.         /** @var \App\Entity\User $user */
  4335.         $user $this->getUser();
  4336.         $userId $user->getId();
  4337.         $user $this->getUser();
  4338.         $session $this->session;
  4339.         $session->set('pageMenu''');
  4340.         $idSejour $session->get("Sejour");
  4341.         $produitcondition $session->get("produit");
  4342.         $produit $session->get("produittype");
  4343.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4344.         $em $this->em;
  4345.         $clipart $em->getRepository(Clipart::class)->findAll();
  4346.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4347.         $listerandom $listeattachlikephoto;
  4348.         $nbLikes count($listeattachlikephoto);
  4349.         $AllPagesAcc null;
  4350.         $random false;
  4351.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  4352.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4353.         $idAcc $sejour->getIdAcommp();
  4354.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4355.         $part $sejour->getIdPartenaire();
  4356.         $nompart $part->getUsername();
  4357.         $logopart $part->getLogourl();
  4358.         //Liste des photos public
  4359.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4360.         $nbPhoto =  $listeattach;
  4361.         if ($nbLikes == 0) {
  4362.             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]);
  4363.         }
  4364.         if ($nbLikes != 0) {
  4365.             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]);
  4366.         }
  4367.     }
  4368.     //CommanderalbumSejour
  4369.     /**
  4370.      * @Route("/Parent/CommanderalbumSejour", name="CommanderalbumSejour")
  4371.      */
  4372.     public function CommanderalbumSejour(Request $request)
  4373.     {
  4374.         $session $this->session;
  4375.         $serviceuser $this->etablissementService;
  4376.         $page $request->get("pages");
  4377.         $sejour $request->get("sejour");
  4378.         $prodid $request->get('idProd');
  4379.         $nomprod $request->get('nomprod');
  4380.         $versionalbm $request->get('new');
  4381.         $user $this->getUser();
  4382.         $em $this->em;
  4383.         //  $AlbumSejour  = $em->getRepository(Produit::class)->findOneBy(array("id" =>$prodid));
  4384.         $produit $session->get("produittype");
  4385.         $produitcondi $session->get("produit");
  4386.         $Album $serviceuser->saveCopyalbumParent($page$user$sejour$prodid$produit$produitcondi$nomprod$versionalbm);
  4387.         $inser false;
  4388.         $session $this->session;
  4389.         $Products $session->get("Panier");
  4390.         $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  4391.         $user $this->getUser();
  4392.         $typeref $em->getRepository(Typeref::class)->find(8);
  4393.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4394.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4395.         //fin
  4396.         if ($panierTrace == null) {
  4397.             $panierTrace = new Panier();
  4398.             $dateNow = new \Datetime();
  4399.             $panierTrace->setDateCreation($dateNow);
  4400.             $panierTrace->setCreerPar($user);
  4401.             $panierTrace->setStatut($statutPanier);
  4402.             $em->getManager()->persist($panierTrace);
  4403.             $em->getManager()->flush();
  4404.         }
  4405.         if ($Products == null) {
  4406.             $Products = [];
  4407.         }
  4408.         foreach ($Products as $key => $p) {
  4409.             if ($p['id'] == $produit->getId()) {
  4410.                 $inser true;
  4411.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4412.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  4413.             }
  4414.         }
  4415.         //Touhemi :Rechercher  si le produti existe déja ds panierProduit
  4416.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $Album"idPanier" => $panierTrace));
  4417.         if ($panierProduit == null) {
  4418.             $panierProduit = new PanierProduit();
  4419.             $panierProduit->setIdProduit($Album);
  4420.             $panierProduit->setIdPanier($panierTrace);
  4421.             $em->getManager()->persist($panierProduit);
  4422.             $em->getManager()->flush();
  4423.         }
  4424.         //fin
  4425.         //Touhemi ajouter plus un au produit et modifier prixTotal
  4426.         $oldQte $panierProduit->getQuantite();
  4427.         $newQte $oldQte 1;
  4428.         $panierProduit->setQuantite($newQte);
  4429.         $oldTotal $panierProduit->getPrixTotal();
  4430.         $newTotal $oldTotal $Album->getIdConditionnement()->getMontantTTC();
  4431.         $panierProduit->setPrixTotal($newTotal);
  4432.         $this->em->getManager()->persist($panierProduit);
  4433.         $this->em->getManager()->flush();
  4434.         //fin
  4435.         if ($inser === false) {
  4436.             //get nessaisire element
  4437.             $p = [];
  4438.             $p["id"] = $produit->getId();
  4439.             $p["nom"] = $produit->getType()->getLabeletype();
  4440.             $p["ident"] = $produit->getLabele();
  4441.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4442.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4443.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4444.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4445.             $p["qte"] = 1;
  4446.             array_push($Products$p);
  4447.         }
  4448.         $session->set('Panier'$Products);
  4449.         //sendemail_parent
  4450.         $dateNow = new \Datetime();
  4451.         /** @var \App\Entity\User $user */
  4452.         $user $this->getUser();
  4453.         $userEmail $user->getEmail();
  4454.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4455.         //$this->EmailServie->MailRelancePanier($userEmail);
  4456.         //dd($etablissementDetail);
  4457.         return new response('done');
  4458.     }
  4459.     /**
  4460.      * @Route("/Parent/AlbummsavealbumcomandeParent", name="AlbummsavealbumcomandeParent")
  4461.      */
  4462.     public function Albummcomandesavealbum(Request $request)
  4463.     {
  4464.         $session $this->session;
  4465.         $serviceuser $this->etablissementService;
  4466.         $page $request->get("pages");
  4467.         $sejour $request->get("sejour");
  4468.         $prodid $request->get('idProd');
  4469.         $nomprod $request->get('nomprod');
  4470.         $versionalbm $request->get('new');
  4471.         $user $this->getUser();
  4472.         $produit $session->get("produittype");
  4473.         $produitcondi $session->get("produit");
  4474.         $Album $serviceuser->savealbumParent($page$user$sejour$prodid$produit$produitcondi$nomprod$versionalbm);
  4475.         $inser false;
  4476.         $session $this->session;
  4477.         $Products $session->get("Panier");
  4478.         $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  4479.         $em $this->em;
  4480.         $user $this->getUser();
  4481.         $typeref $em->getRepository(Typeref::class)->find(8);
  4482.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4483.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4484.         //fin
  4485.         if ($panierTrace == null) {
  4486.             $panierTrace = new Panier();
  4487.             $dateNow = new \Datetime();
  4488.             $panierTrace->setDateCreation($dateNow);
  4489.             $panierTrace->setCreerPar($user);
  4490.             $panierTrace->setStatut($statutPanier);
  4491.             $em->getManager()->persist($panierTrace);
  4492.             $em->getManager()->flush();
  4493.         }
  4494.         if ($Products == null) {
  4495.             $Products = [];
  4496.         }
  4497.         foreach ($Products as $key => $p) {
  4498.             if ($p['id'] == $produit->getId()) {
  4499.                 $inser true;
  4500.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4501.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  4502.             }
  4503.         }
  4504.         //Touhemi :Rechercher  si le produti existe déja ds panierProduit
  4505.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $Album"idPanier" => $panierTrace));
  4506.         if ($panierProduit == null) {
  4507.             $panierProduit = new PanierProduit();
  4508.             $panierProduit->setIdProduit($Album);
  4509.             $panierProduit->setIdPanier($panierTrace);
  4510.             $em->getManager()->persist($panierProduit);
  4511.             $em->getManager()->flush();
  4512.         }
  4513.         //fin
  4514.         //Touhemi ajouter plus un au produit et modifier prixTotal
  4515.         $oldQte $panierProduit->getQuantite();
  4516.         $newQte $oldQte 1;
  4517.         $panierProduit->setQuantite($newQte);
  4518.         $oldTotal $panierProduit->getPrixTotal();
  4519.         $newTotal $oldTotal $Album->getIdConditionnement()->getMontantTTC();
  4520.         $panierProduit->setPrixTotal($newTotal);
  4521.         $this->em->getManager()->persist($panierProduit);
  4522.         $this->em->getManager()->flush();
  4523.         //fin
  4524.         if ($inser === false) {
  4525.             //get nessaisire element
  4526.             $p = [];
  4527.             $p["id"] = $produit->getId();
  4528.             $p["nom"] = $produit->getType()->getLabeletype();
  4529.             $p["ident"] = $produit->getLabele();
  4530.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4531.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4532.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4533.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4534.             $p["qte"] = 1;
  4535.             array_push($Products$p);
  4536.         }
  4537.         $session->set('Panier'$Products);
  4538.         //sendemail_parent
  4539.         $dateNow = new \Datetime();
  4540.         /** @var \App\Entity\User $user */
  4541.         $user $this->getUser();
  4542.         $userEmail $user->getEmail();
  4543.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4544.         //$this->EmailServie->MailRelancePanier($userEmail);
  4545.         //dd($etablissementDetail);
  4546.         return new response('done');
  4547.     }
  4548.     /**
  4549.      * @Route("/Parent/saveLivrePhotosParentPanier", name="saveLivrePhotosParentPanier")
  4550.      */
  4551.     public function saveLivrePhotospuisPanier(Request $request)
  4552.     {
  4553.         $em $this->em;
  4554.         $session $this->session;
  4555.         $produittype $session->get("produit");
  4556.         $produit $session->get("produittype");
  4557.         $serviceuser $this->etablissementService;
  4558.         $page $request->get("pages");
  4559.         $sejour $request->get("sejour");
  4560.         $prodid $request->get('idProd');
  4561.         $nomprod $request->get('nomprod');
  4562.         $versionalbm $request->get('new');
  4563.         $user $this->getUser();
  4564.         $Album $serviceuser->savelivreParent($page$user$sejour$prodid$produittype$nomprod$versionalbm);
  4565.         //dd($etablissementDetail);
  4566.         $inser false;
  4567.         $session $this->session;
  4568.         $Products $session->get("Panier");
  4569.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  4570.         //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
  4571.         $user $this->getUser();
  4572.         $typeref $em->getRepository(Typeref::class)->find(8);
  4573.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4574.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4575.         //fin
  4576.         if ($panierTrace == null) {
  4577.             $panierTrace = new Panier();
  4578.             $dateNow = new \Datetime();
  4579.             $panierTrace->setDateCreation($dateNow);
  4580.             $panierTrace->setCreerPar($user);
  4581.             $panierTrace->setStatut($statutPanier);
  4582.             $em->getManager()->persist($panierTrace);
  4583.             $em->getManager()->flush();
  4584.         }
  4585.         //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
  4586.         if ($Products == null) {
  4587.             $Products = [];
  4588.         }
  4589.         foreach ($Products as $key => $p) {
  4590.             if ($p['id'] == $produit->getId()) {
  4591.                 $inser true;
  4592.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4593.                 // $Products[$key]['mnt'] = $p['mnt'] + $produit->getType()->getTraif();
  4594.             }
  4595.         }
  4596.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  4597.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  4598.         if ($panierProduit == null) {
  4599.             $panierProduit = new PanierProduit();
  4600.             $panierProduit->setIdProduit($produit);
  4601.             $panierProduit->setIdPanier($panierTrace);
  4602.             $em->getManager()->persist($panierProduit);
  4603.             $em->getManager()->flush();
  4604.         }
  4605.         //fin
  4606.         //   Touhemi 02-07-2020 ajouter plus un au produit et modifier prixTotal
  4607.         $oldQte $panierProduit->getQuantite();
  4608.         $newQte $oldQte 1;
  4609.         $panierProduit->setQuantite($newQte);
  4610.         $oldTotal $panierProduit->getPrixTotal();
  4611.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  4612.         $panierProduit->setPrixTotal($newTotal);
  4613.         $em->getManager()->persist($panierProduit);
  4614.         $em->getManager()->flush();
  4615.         //fin
  4616.         if ($inser === false) {
  4617.             //get nessaisire element
  4618.             $p = [];
  4619.             $p["id"] = $produit->getId();
  4620.             $p["nom"] = $produit->getType()->getLabeletype();
  4621.             $p["ident"] = $produit->getLabele();
  4622.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4623.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4624.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4625.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4626.             $p["qte"] = 1;
  4627.             array_push($Products$p);
  4628.         }
  4629.         $session->set('Panier'$Products);
  4630.         //sendmail_patrent
  4631.         $dateNow = new \Datetime();
  4632.         /** @var \App\Entity\User $user */
  4633.         $user $this->getUser();
  4634.         $userEmail $user->getEmail();
  4635.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4636.         // $this->EmailServie->MailRelancePanier($userEmail);
  4637.         return new response('done');
  4638.     }
  4639.     /**
  4640.      * @Route("parent/condcnx", name="connexionparentsejour",methods={"POST"})
  4641.      */
  4642.     public function condition(Request $request)
  4643.     {
  4644.         $UserService $this->userService;
  4645.         $id $request->get('id');
  4646.         $ParentSejour $UserService->conditioncnxparent($id);
  4647.         return new JsonResponse('done');
  4648.     }
  4649.     /**
  4650.      * @Route("/Parent/MaPropresPhotos", name="MaPropresPhotos")
  4651.      */
  4652.     public function MaPropresPhotos(Request $request)
  4653.     {
  4654.         $path $request->get("path");
  4655.         $type $request->get("type");
  4656.         $sejId $request->get("id");
  4657.         $dateSejour $request->get("date");
  4658.         $SejourServiceattachh $this->sejourService;
  4659.         $Userservicemail $this->userService;
  4660.         $sejourfind $SejourServiceattachh->sejoursansattach($sejId);
  4661.         //$sendmail = $Userservicemail->sendmailuserforfirstattach($sejId);
  4662.         $attachementservice $this->attachementService;
  4663.         foreach ($path as $key => $path) {
  4664.             $src $path['path'];
  4665.             $attachement $attachementservice->creationAttachementS($src$type$dateSejour);
  4666.             $sejourservice $this->sejourService;
  4667.             $sejAttach $sejourservice->monpropreattachement($sejId$attachement$this->getUser());
  4668.             if ((array_key_exists("latitude"$path)) && ($path['latitude'] != null)) {
  4669.                 $lat $path['latitude'];
  4670.                 $lng $path['longitude'];
  4671.                 $Cartervice $this->carteService;
  4672.                 $position $Cartervice->create_newPositionImage($this->getUser(), $lat$lng);
  4673.                 $Cartervice->affecterPosition($attachement$position);
  4674.                 $FindSejour $this->em->getRepository(Sejour::class)->find($sejId);
  4675.                 $FindSejour->setEtatAdresseCarte(true);
  4676.                 $this->em->getManager()->persist($FindSejour);
  4677.                 $this->em->getManager()->flush();
  4678.             }
  4679.             //Ajouter les photos aux favoris
  4680.             $Like $this->photosFavorisService;
  4681.             $Like->AddFavoris($this->getUser(), $attachement$sejId);
  4682.         }
  4683.         return new JsonResponse(["id" => $attachement->getId()]);;
  4684.     }
  4685.     /**
  4686.      * @Route("/Parent/Ajouter_photo_sejour", name="pathadddnewphotos")
  4687.      */
  4688.     public function pathaddnewphotos()
  4689.     {
  4690.         /** @var \App\Entity\User $user */
  4691.         $user $this->getUser();
  4692.         $userId $user->getId();
  4693.         $session $this->session;
  4694.         $idParent $session->get("Sejour");
  4695.         $idSejour $session->get("Sejour");
  4696.         $conxparent $this->sejourService;
  4697.         $sejour1 $conxparent->sejourParentcnx($idSejour$idParent);
  4698.         //dd($sejour1);
  4699.         $SEjourService $this->sejourService;
  4700.         $sejour $SEjourService->getsejour($idSejour);
  4701.         //  dd($sejour);
  4702.         //Liste des photos public
  4703.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4704.         //Liste des photos privé
  4705.         //        $listeattachPrivate = $SEjourService->getatachmentsejourparent($idSejour, $this->getUser()->getId());
  4706.         //        $AllPhotosParent = array_merge_recursive($listeattach, $listeattachPrivate);
  4707.         $listeVideo $SEjourService->getVideosejour($idSejour);
  4708.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  4709.         $nbImages count($listeattach);
  4710.         $positions $SEjourService->getsejourposition($idSejour);
  4711.         $messages $SEjourService->getsejourmessage($idSejour);
  4712.         $em $this->em;
  4713.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  4714.         //dd($parentsejour);
  4715.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4716.         $produits $this->typeProduiteService;
  4717.         $liste $produits->produitlistTypeConditionnement();
  4718.         $pubProd $user->getShowpubprod();
  4719.         $albumAcc $this->getAlbumAccForSejour($sejour);
  4720.         return $this->render('Parent/DetailsSejour.html.twig', [
  4721.             "sejour" => $sejour,
  4722.             'albumAcc' => $albumAcc,
  4723.             'listeattach' => $AllAttachements,
  4724.             'nbImages' => $nbImages,
  4725.             'positions' => $positions,
  4726.             'messages' => $messages,
  4727.             'like' => $listeattachlikephoto,
  4728.             "parentsejour" => $parentsejour,
  4729.             'prod' => $liste,
  4730.             'smsnotif' => $parentsejour->getSmsnotif(),
  4731.             'showpub' => $pubProd
  4732.         ]);
  4733.     }
  4734.     /**
  4735.      * @Route("/Parent/ajouterauPanier_Parent_coffret", name="comandercoffre")
  4736.      */
  4737.     public function Ajouter_MonPanier_Coffret()
  4738.     {
  4739.         $em $this->em;
  4740.         $inser false;
  4741.         $session $this->session;
  4742.         $idSejour $session->get("Sejour");
  4743.         $userId $this->getUser();
  4744.         /** @var \App\Entity\User $user */
  4745.         $user $this->getUser();
  4746.         $userIdCom $user->getId();
  4747.         $sejourobj $this->em->getRepository(Sejour::class)->find($idSejour);
  4748.         $prodct $this->em->getRepository(Typeproduit::class)->find(15);
  4749.         $version $this->em->getRepository(Produit::class)->SearchVersionproduit($userIdCom);
  4750.         $Conditionnement $this->em->getRepository(TypeProduitConditionnement::class)->find(6);
  4751.         $Products $session->get("Panier");
  4752.         //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
  4753.         $user $this->getUser();
  4754.         $typeref $em->getRepository(Typeref::class)->find(8);
  4755.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4756.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4757.         //fin
  4758.         if ($panierTrace == null) {
  4759.             $panierTrace = new Panier();
  4760.             $dateNow = new \Datetime();
  4761.             $panierTrace->setDateCreation($dateNow);
  4762.             $panierTrace->setCreerPar($user);
  4763.             $panierTrace->setStatut($statutPanier);
  4764.             $em->getManager()->persist($panierTrace);
  4765.             $em->getManager()->flush();
  4766.         }
  4767.         //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
  4768.         $produit $em->getRepository(Produit::class)->findOneBy(array("type" => $prodct'idConditionnement' => $Conditionnement'idsjour' => $sejourobj'iduser' => $user));
  4769.         if ($produit == null) {
  4770.             $produit = new Produit;
  4771.             $produit->setLabele("Coffret cadeau");
  4772.             $produit->setIduser($userId);
  4773.             $produit->setIdsjour($sejourobj);
  4774.             $produit->setDate(new \DateTime());
  4775.             $produit->setIdConditionnement($Conditionnement);
  4776.             $produit->setType($prodct);
  4777.             $em->getManager()->persist($produit);
  4778.             $em->getManager()->flush();
  4779.         }
  4780.         if ($Products == null) {
  4781.             $Products = [];
  4782.         }
  4783.         foreach ($Products as $key => $p) {
  4784.             if ($p['id'] == $produit->getId()) {
  4785.                 $inser true;
  4786.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4787.                 // $Products[$key]['mnt'] = $p['mnt'] + $produit->getType()->getTraif();
  4788.             }
  4789.         }
  4790.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  4791.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  4792.         if ($panierProduit == null) {
  4793.             $panierProduit = new PanierProduit();
  4794.             $panierProduit->setIdProduit($produit);
  4795.             $panierProduit->setIdPanier($panierTrace);
  4796.             $em->getManager()->persist($panierProduit);
  4797.             $em->getManager()->flush();
  4798.         }
  4799.         //fin
  4800.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  4801.         $oldQte $panierProduit->getQuantite();
  4802.         $newQte $oldQte 1;
  4803.         $panierProduit->setQuantite($newQte);
  4804.         $oldTotal $panierProduit->getPrixTotal();
  4805.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  4806.         $panierProduit->setPrixTotal($newTotal);
  4807.         $em->getManager()->persist($panierProduit);
  4808.         $em->getManager()->flush();
  4809.         //fin
  4810.         if ($inser === false) {
  4811.             //get nessaisire element
  4812.             $p = [];
  4813.             $p["id"] = $produit->getId();
  4814.             $p["nom"] = $produit->getType()->getLabeletype();
  4815.             $p["ident"] = $produit->getLabele();
  4816.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4817.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4818.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4819.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4820.             $p["qte"] = 1;
  4821.             array_push($Products$p);
  4822.         }
  4823.         //sendmailproduct_parent
  4824.         $dateNow = new \Datetime();
  4825.         /** @var \App\Entity\User $user */
  4826.         $user $this->getUser();
  4827.         $userEmail $user->getEmail();
  4828.         $userId $user->getId();
  4829.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4830.         //$this->EmailServie->MailRelancePanier($userEmail);
  4831.         $listeproduit $prod $this->em->getRepository(Produit::class)->findby(array('iduser' => $userId));
  4832.         $session->set('Panier'$Products);
  4833.         $Panier $session->get("Panier");
  4834.         $produit $this->typeProduiteService;
  4835.         $produitlist $produit->produitlistTypeConditionnement();
  4836.         $this->session->set('rout''rout');
  4837.         $parentent_sejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $this->getUser(), "idSejour" => $sejourobj]);
  4838.         $prodpanier = array();
  4839.         $nbrprodpromo 0;
  4840.         $nbralbum 0;
  4841.         $nbrlivre 0;
  4842.         $nbrphoto12 0;
  4843.         $nbrphoto24 0;
  4844.         $nbrphoto36 0;
  4845.         $nbrcal 0;
  4846.         $nbrretro12 0;
  4847.         $nbrretro24 0;
  4848.         $nbrretro36 0;
  4849.         $detailsprod = array();
  4850.         $prixalbum 0.0;
  4851.         $prixphoto12 0.0;
  4852.         $prixphoto24 0.0;
  4853.         $prixphoto36 0.0;
  4854.         $prixcal 0.0;
  4855.         $prixalbum 0.0;
  4856.         $prixretro12 0.0;
  4857.         $prixretro24 0.0;
  4858.         $prixretro36 0.0;
  4859.         $prodpanierpromo = array();
  4860.         $promo = array();
  4861.         foreach ($Panier as $key => $p) {
  4862.             if ($p['condition'] != null) {
  4863.                 array_push($prodpanier$p['condition']);
  4864.             }
  4865.             if ($p['condition'] != 11 && $p['condition'] != 6) {
  4866.                 $promo['condition'] = $p['condition'];
  4867.                 $nbrprodpromo $nbrprodpromo $p['qte'];
  4868.                 array_push($prodpanierpromo$promo);
  4869.                 if ($p['condition'] == 4) {
  4870.                     $nbralbum $nbralbum $p['qte'];
  4871.                     $prixalbum $p['mnt'];
  4872.                 } elseif ($p['condition'] == 1) {
  4873.                     $nbrphoto12 $nbrphoto12 $p['qte'];
  4874.                     $prixphoto12 $p['mnt'];
  4875.                 } elseif ($p['condition'] == 2) {
  4876.                     $nbrphoto24 $nbrphoto24 $p['qte'];
  4877.                     $prixphoto24 $p['mnt'];
  4878.                 } elseif ($p['condition'] == 3) {
  4879.                     $nbrphoto36 $nbrphoto36 $p['qte'];
  4880.                     $prixphoto36  $p['mnt'];
  4881.                 } elseif ($p['condition'] == 5) {
  4882.                     $nbrlivre $nbrlivre $p['qte'];
  4883.                     $prixlivre $p['mnt'];
  4884.                 } elseif ($p['condition'] == 7) {
  4885.                     $nbrcal $nbrcal $p['qte'];
  4886.                     $prixcal $p['mnt'];
  4887.                 } elseif ($p['condition'] == 8) {
  4888.                     $nbrretro36 $nbrretro36 $p['qte'];
  4889.                     $prixretro36 $p['mnt'];
  4890.                 } elseif ($p['condition'] == 9) {
  4891.                     $nbrretro12 $nbrretro12 $p['qte'];
  4892.                     $prixretro12 $p['mnt'];
  4893.                 } elseif ($p['condition'] == 10) {
  4894.                     $nbrretro24 $nbrretro24 $p['qte'];
  4895.                     $prixretro24 $p['mnt'];
  4896.                 }
  4897.             }
  4898.         }
  4899.         $detailsprod['album']['qt'] = $nbralbum;
  4900.         $detailsprod['album']['prix'] = $prixalbum;
  4901.         $detailsprod['photo12']['qt'] = $nbrphoto12;
  4902.         $detailsprod['photo12']['prix'] = $prixphoto12;
  4903.         $detailsprod['photo24']['qt'] = $nbrphoto24;
  4904.         $detailsprod['photo24']['prix'] = $prixphoto24;
  4905.         $detailsprod['photo36']['qt'] = $nbrphoto36;
  4906.         $detailsprod['photo36']['prix'] = $prixphoto36;
  4907.         $detailsprod['cal']['qt'] = $nbrcal;
  4908.         $detailsprod['cal']['prix'] = $prixcal;
  4909.         $detailsprod['livre']['qt'] = $nbrlivre;
  4910.         $detailsprod['livre']['prix'] = $prixalbum;
  4911.         $detailsprod['retro12']['qt'] = $nbrretro12;
  4912.         $detailsprod['retro12']['prix'] = $prixretro12;
  4913.         $detailsprod['retro24']['qt'] = $nbrretro24;
  4914.         $detailsprod['retro24']['prix'] = $prixretro24;
  4915.         $detailsprod['retro36']['qt'] = $nbrretro36;
  4916.         $detailsprod['retro36']['prix'] = $prixretro36;
  4917.         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]);
  4918.     }
  4919.     /**
  4920.      * @Route("/Parent/Boite_vocale", name="Boite_vocale")
  4921.      */
  4922.     public function Boite_Vocale()
  4923.     {
  4924.         /** @var \App\Entity\User $user */
  4925.         $user $this->getUser();
  4926.         $userId $user->getId();
  4927.         $session $this->session;
  4928.         $session->set('pageMenu''BoiteVocale');
  4929.         $idSejour $session->get("Sejour");
  4930.         $SEjourService $this->sejourService;
  4931.         $sejour $SEjourService->getsejour($idSejour);
  4932.         /*         $listeattach = $SEjourService->getatachmentsejour($idSejour);
  4933.         $listeVideo = $SEjourService->getVideosejour($idSejour);
  4934.         $AllAttachements = array_merge_recursive($listeattach, $listeVideo); */
  4935.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  4936.         $attachementsCount $AllAttachements['total'];
  4937.         unset($AllAttachements['total']);
  4938.         $nbImages count($AllAttachements);
  4939.         $positions $SEjourService->getsejourposition($idSejour);
  4940.         $messages $SEjourService->getsejourmessage($idSejour);
  4941.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  4942.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4943.         // test if sejour est vide ou non 
  4944.         if (sizeof($sejour->getAttachements()) == 0) {
  4945.             $this->session->set('rout''rout');
  4946.             return $this->render('Parent/Aucunphoto.html.twig', [
  4947.                 "sejour" => $sejour,
  4948.                 "parentsejour" => $parentsejour
  4949.             ]);
  4950.         }
  4951.         // Déterminer le type de code (PF = gratuit, PP/EP = payant)
  4952.         $codePrefix substr($sejour->getCodeSejour(), 02);
  4953.         $isFreeAccess = ($codePrefix === 'PF' || $codePrefix === 'EF' || $sejour->getPaym() == 0);
  4954.         
  4955.         // PP ou EP : vérifier le paiement
  4956.         if (!$isFreeAccess && ($codePrefix === 'PP' || $codePrefix === 'EP')) {
  4957.             $ParentSejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  4958.             if ($ParentSejour && $ParentSejour->getPayment() == 0) {
  4959.                 $this->session->set('rout''rout');
  4960.                 $ses_id session_id();
  4961.                 return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $ParentSejour]);
  4962.             }
  4963.             if ($ParentSejour && $ParentSejour->getPayment() == 1) {
  4964.                 $produits $this->typeProduiteService;
  4965.                 $liste $produits->produitlistTypeConditionnement();
  4966.                 $albumAcc $this->getAlbumAccForSejour($sejour);
  4967.                 $pubProd $user->getShowpubprod();
  4968.                 return $this->render('Parent/DetailsSejour.html.twig', [
  4969.                     "sejour" => $sejour,
  4970.                     'albumAcc' => $albumAcc,
  4971.                     'listeattach' => $AllAttachements,
  4972.                     'prod' => $liste,
  4973.                     'nbImages' => $nbImages,
  4974.                     'attachementsCount' => $attachementsCount,
  4975.                     'positions' => $positions,
  4976.                     'messages' => $messages,
  4977.                     'like' => $listeattachlikephoto,
  4978.                     "parentsejour" => $parentsejour,
  4979.                     'smsnotif' => $parentsejour->getSmsnotif(),
  4980.                     'showpub' => $pubProd
  4981.                 ]);
  4982.             }
  4983.         }
  4984.         $produits $this->typeProduiteService;
  4985.         $liste $produits->produitlistTypeConditionnement();
  4986.         $pubProd $user->getShowpubprod();
  4987.         $albumAcc $this->getAlbumAccForSejour($sejour);
  4988.         return $this->render('Parent/DetailsSejour.html.twig', [
  4989.             "sejour" => $sejour,
  4990.             'albumAcc' => $albumAcc,
  4991.             'prod' => $liste,
  4992.             'listeattach' => $AllAttachements,
  4993.             'nbImages' => $nbImages,
  4994.             'attachementsCount' => $attachementsCount,
  4995.             'positions' => $positions,
  4996.             'messages' => $messages,
  4997.             'like' => $listeattachlikephoto,
  4998.             "parentsejour" => $parentsejour,
  4999.             'smsnotif' => $parentsejour->getSmsnotif(),
  5000.             'showpub' => $pubProd
  5001.         ]);
  5002.     }
  5003.     /**
  5004.      * @Route("/Parent/Mon_Sejour_parent", name="Mon_Sejour_parent")
  5005.      */
  5006.     public function Mon_Sejour_parent()
  5007.     {
  5008.         /** @var \App\Entity\User $user */
  5009.         $user $this->getUser();
  5010.         $userId $user->getId();
  5011.         $session $this->session;
  5012.         // $idParent=$this->getUser()->getId();
  5013.         $idSejour $session->get("Sejour");
  5014.         $session->set('pageMenu''Monsejour');
  5015.         $conxparent $this->sejourService;
  5016.         //$sejour1 = $conxparent->sejourParentcnx($idSejour,$idParent);
  5017.         //
  5018.         $SEjourService $this->sejourService;
  5019.         $sejour $SEjourService->getsejour($idSejour);
  5020.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  5021.         //Liste des photos privé
  5022.         //        $listeattachPrivate = $SEjourService->getatachmentsejourparent($idSejour, $this->getUser()->getId());
  5023.         //        $AllPhotosParent = array_merge_recursive($listeattach, $listeattachPrivate);
  5024.         $listeVideo $SEjourService->getVideosejour($idSejour);
  5025.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  5026.         $nbImages count($listeattach);
  5027.         $positions $SEjourService->getsejourposition($idSejour);
  5028.         $messages $SEjourService->getsejourmessage($idSejour);
  5029.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  5030.         //dd($parentsejour);
  5031.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  5032.         // test if sejour est vide ou non 
  5033.         if (sizeof($sejour->getAttachements()) == 0) {
  5034.             $this->session->set('rout''rout');
  5035.             return $this->render('Parent/Aucunphoto.html.twig', [
  5036.                 "sejour" => $sejour,
  5037.                 "parentsejour" => $parentsejour
  5038.             ]);
  5039.         }
  5040.         // Déterminer le type de code (PF = gratuit, PP/EP = payant)
  5041.         $codePrefix substr($sejour->getCodeSejour(), 02);
  5042.         $isFreeAccess = ($codePrefix === 'PF' || $codePrefix === 'EF' || $sejour->getPaym() == 0);
  5043.         
  5044.         // PP ou EP : vérifier le paiement
  5045.         if (!$isFreeAccess && ($codePrefix === 'PP' || $codePrefix === 'EP')) {
  5046.             /** @var \App\Entity\User $user */
  5047.             $user $this->getUser();
  5048.             $userid $user->getId();
  5049.             //findlinge
  5050.             $ParentSejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $userid]);
  5051.             if ($ParentSejour && $ParentSejour->getPayment() == 0) {
  5052.                 $this->session->set('rout''rout');
  5053.                 $ses_id session_id();
  5054.                 return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $listeattach"session_id" => $ses_id'ParentSejour' => $ParentSejour]);
  5055.             }
  5056.             if ($ParentSejour && $ParentSejour->getPayment() == 1) {
  5057.                 $produits $this->typeProduiteService;
  5058.                 $liste $produits->produitlistTypeConditionnement();
  5059.                 $pubProd $user->getShowpubprod();
  5060.                 $albumAcc $this->getAlbumAccForSejour($sejour);
  5061.                 return $this->render('Parent/DetailsSejour.html.twig', [
  5062.                     "sejour" => $sejour,
  5063.                     'albumAcc' => $albumAcc,
  5064.                     'listeattach' => $AllAttachements,
  5065.                     'prod' => $liste,
  5066.                     'nbImages' => $nbImages,
  5067.                     'positions' => $positions,
  5068.                     'messages' => $messages,
  5069.                     'like' => $listeattachlikephoto,
  5070.                     "parentsejour" => $parentsejour,
  5071.                     'smsnotif' => $parentsejour->getSmsnotif()
  5072.                 ]);
  5073.             }
  5074.         }
  5075.         //  dd($sejour);
  5076.         //Liste des photos public
  5077.         $produits $this->typeProduiteService;
  5078.         $liste $produits->produitlistTypeConditionnement();
  5079.         $pubProd $user->getShowpubprod();
  5080.         $albumAcc $this->getAlbumAccForSejour($sejour);
  5081.         return $this->render('Parent/DetailsSejour.html.twig', [
  5082.             "sejour" => $sejour,
  5083.             'albumAcc' => $albumAcc,
  5084.             'prod' => $liste,
  5085.             'listeattach' => $AllAttachements,
  5086.             'nbImages' => $nbImages,
  5087.             'positions' => $positions,
  5088.             'messages' => $messages,
  5089.             'like' => $listeattachlikephoto,
  5090.             "parentsejour" => $parentsejour,
  5091.             'smsnotif' => $parentsejour->getSmsnotif(),
  5092.             'showpub' => $pubProd
  5093.         ]);
  5094.     }
  5095.     /**
  5096.      * @Route("/Parent/Besoindaide", name="Besoindaide_Parent")
  5097.      */
  5098.     public function Besoindaide(): Response
  5099.     {
  5100.         $produit $this->typeProduiteService;
  5101.         $liste $produit->produitlistType();
  5102.         // dd($liste);
  5103.         return $this->render('Parent/footer/Besoindaide.html.twig', [
  5104.             'produit' => $liste,
  5105.         ]);
  5106.     }
  5107.     /**
  5108.      * @Route("/Parent/About", name="About_Parent")
  5109.      */
  5110.     public function AboutParent(): Response
  5111.     {
  5112.         return $this->render('Parent/AboutParent.html.twig', []);
  5113.     }
  5114.     /**
  5115.      * @Route("/Parent/Besoindaide_5sur5", name="Besoindaide_5sur5")
  5116.      */
  5117.     public function Besoindaide_5sur5(): Response
  5118.     {
  5119.         $produit $this->typeProduiteService;
  5120.         $liste $produit->produitlistType();
  5121.         // dd($liste);
  5122.         $session $this->session;
  5123.         $idSejour $session->get("Sejour");
  5124.         $sejour null;
  5125.         if ($idSejour != null) {
  5126.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  5127.         }
  5128.         return $this->render('Parent/footer/5sur5Help.html.twig', [
  5129.             'produit' => $liste,
  5130.             'sejour' => $sejour
  5131.         ]);
  5132.     }
  5133.     /**
  5134.      * @Route("/Parent/Mentionlegale", name="Mentionlegale_Parent")
  5135.      */
  5136.     public function MentionlegaleParent()
  5137.     {
  5138.         return $this->render('Parent/footer/mentionlegal.html.twig', []);
  5139.     }
  5140.     /**
  5141.      * @Route("/Parent/Conditongeneral", name="Conditongeneral_Parent")
  5142.      */
  5143.     public function ConditongeneralParent()
  5144.     {
  5145.         return $this->render('Parent/footer/Condition.html.twig', []);
  5146.     }
  5147.     /**
  5148.      * @Route("/Parent/Politique", name="Politique_Parent")
  5149.      */
  5150.     public function PolitiqueParent()
  5151.     {
  5152.         return $this->render('Parent/footer/politique.html.twig', []);
  5153.     }
  5154.     /**
  5155.      * @Route("/Parent/Commande_groupee", name="Commande_groupee")
  5156.      * */
  5157.     public function  Commande_groupee()
  5158.     {
  5159.         $produit $this->typeProduiteService;
  5160.         $liste $produit->produitlistType();
  5161.         // dd($liste);
  5162.         return $this->render('Parent/footer/GroupeeCommande.html.twig', [
  5163.             'showArt' => 'ALL',
  5164.             'produit' => $liste
  5165.         ]);
  5166.     }
  5167.     /**
  5168.      * @Route("/Parent/partenaires", name="nosPartenaires")
  5169.      * */
  5170.     public function nosPartenaires()
  5171.     {
  5172.         return $this->render('Parent/footer/Partenaires.html.twig');
  5173.     }
  5174.     /**
  5175.      * @Route("/Parent/produits5sur5", name="produits5sur5")
  5176.      * */
  5177.     public function produits5sur5()
  5178.     {
  5179.         $produit $this->typeProduiteService;
  5180.         $liste $produit->produitlistType();
  5181.         // dd($liste);
  5182.         return $this->render('Parent/produitscinqsurcinq.html.twig', [
  5183.             'showArt' => 'ALL',
  5184.             'produit' => $liste
  5185.         ]);
  5186.     }
  5187.     /**
  5188.      * @Route("/Parent/Nous_Connaitre_5sur5", name="NousConnaitre")
  5189.      * */
  5190.     public function Nous_Connaitre_5sur5()
  5191.     {
  5192.         $produit $this->typeProduiteService;
  5193.         $liste $produit->produitlistType();
  5194.         // dd($liste);
  5195.         return $this->render('Parent/footer/5sur5.html.twig', [
  5196.             'produit' => $liste,
  5197.         ]);
  5198.     }
  5199.     /**
  5200.      * @Route("/Parent/ServiceClient", name="ServiceClient_Parent")
  5201.      * */
  5202.     public function ServiceClient()
  5203.     {
  5204.         $produit $this->typeProduiteService;
  5205.         $liste $produit->produitlistType();
  5206.         // dd($liste);
  5207.         return $this->render('Parent/footer/ServiceClient.html.twig', [
  5208.             'produit' => $liste,
  5209.         ]);
  5210.     }
  5211.     /**
  5212.      * @Route("/Parent/delateSession_parents", name="delateSession_parent")
  5213.      * */
  5214.     public function delateSession_parents()
  5215.     {
  5216.         $session $this->session;
  5217.         $em $this->em;
  5218.         $Products = [];
  5219.         if ($session->get("paymentmoniteco") == "succses") {
  5220.             $Products = [];
  5221.             $session->set('Panier'$Products);
  5222.             $user $this->getUser();
  5223.             $typeref $em->getRepository(Typeref::class)->find(8);
  5224.             $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  5225.             $payer $em->getRepository(Ref::class)->findOneBy(array("libiller" => "payer""typeref" => $typeref));
  5226.             $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  5227.             if ($panierTrace) {
  5228.                 $panierTrace->setStatut($payer);
  5229.                 $em->getManager()->persist($panierTrace);
  5230.                 $em->getManager()->flush();
  5231.             }
  5232.         }
  5233.         $this->session->remove('paymentmoniteco');
  5234.         $this->session->remove('montanttotalcomande');
  5235.         $this->session->remove('Panierlength');
  5236.         $this->session->remove('envoipost');
  5237.         return new Response('done');
  5238.     }
  5239.     /**
  5240.      * @Route("/Parent/chargement_form_conn_up2pay", name="chargement_form_conn_up2pay")
  5241.      */
  5242.     function chargeFormup2payAction(Request $request)
  5243.     {
  5244.         $session $this->session;
  5245.         $em $this->container->get('doctrine')->getManager();
  5246.         $idSejour $session->get("Sejour");
  5247.         /** @var \App\Entity\User $user */
  5248.         $user $this->getUser();
  5249.         $user $user->getId();
  5250.         $comande $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  5251.         $firstName $comande->getIdParent()->getNom();
  5252.         if ($firstName == null || $firstName == '') {
  5253.             $firstName "john";
  5254.         }
  5255.         $lastName $comande->getIdParent()->getPrenom();
  5256.         if ($lastName == null || $lastName == '') {
  5257.             $lastName "Doe";
  5258.         }
  5259.         $addressLine1 "3 rue de l'église";
  5260.         $city "Ostheim";
  5261.         $postalCode "68150";
  5262.         $pbx_site '6062073';                              //variable de test 9999999
  5263.         $pbx_rang '001';                                    //variable de test 95
  5264.         $pbx_identifiant '38027616';                      //variable de test 123456789
  5265.         $pbx_cmd 'REFCN' $comande->getId();
  5266.         $pbx_effectue $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5267.         $pbx_annule $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5268.         $pbx_refuse $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5269.         // Paramétrage de l'url de retour back office site (notification de paiement IPN) :
  5270.         $pbx_repondre_a "";
  5271.         //$pbx_repondre_a = $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5272.         $mail  $comande->getIdParent()->getEmail();
  5273.         $pbx_porteur $mail;                    //variable de test test@test.fr
  5274.         // Paramétrage des données retournées via l'IPN :
  5275.         $pbx_retour 'Mt:M;Ref:R;Auto:A;Erreur:E';
  5276.         // On récupére la date au format ISO-8601 :
  5277.         $dateTime date("c");
  5278.         //$montant = $comande->getMontantrth() . "EUR";
  5279.         $pbx_total $comande->getIdSejour()->getPrixcnxparent();
  5280.         $pbx_total = (int)((string)($pbx_total 100));
  5281.         // Suppression des points ou virgules dans le montant                        
  5282.         $pbx_total str_replace(","""$pbx_total);
  5283.         $pbx_total str_replace("."""$pbx_total);
  5284.         // Nombre de produit envoyé dans PBX_SHOPPINGCART :
  5285.         $pbx_nb_produit '1';                                    //variable de test 5
  5286.         // Construction de PBX_SHOPPINGCART :
  5287.         $pbx_shoppingcart "<?xml version=\"1.0\" encoding=\"utf-8\"?><shoppingcart><total><totalQuantity>" $pbx_nb_produit "</totalQuantity></total></shoppingcart>";
  5288.         // Choix de l'authentification dans PBX_SOUHAITAUTHENT
  5289.         $pbx_souhaitauthent '01';        //variable de test authentification 3DS (1 par défaut, 2 pour exemption 3DS)
  5290.         // Valeurs envoyes dans PBX_BILLING :
  5291.         $pbx_prenom_fact $firstName;                                                             //variable de test Jean-Marie
  5292.         $pbx_nom_fact $lastName;                                                                 //variable de test Thomson
  5293.         $pbx_adresse1_fact $addressLine1;                                                         //variable de test 1 rue de Paris
  5294.         $pbx_adresse2_fact '';                                                                 //variable de test <vide>
  5295.         $pbx_zipcode_fact $postalCode;                                                         //variable de test 75001
  5296.         $pbx_city_fact $city;                                     //variable de test Paris
  5297.         $pbx_country_fact '250';        //variable de test 250 (pour la France)
  5298.         // Construction de PBX_BILLING :
  5299.         $pbx_billing "<?xml version=\"1.0\" encoding=\"utf-8\"?><Billing><Address><FirstName>" $pbx_prenom_fact "</FirstName>" .
  5300.             "<LastName>" $pbx_nom_fact "</LastName><Address1>" $pbx_adresse1_fact "</Address1>" .
  5301.             "<Address2>" $pbx_adresse2_fact "</Address2><ZipCode>" $pbx_zipcode_fact "</ZipCode>" .
  5302.             "<City>" $pbx_city_fact "</City><CountryCode>" $pbx_country_fact "</CountryCode>" .
  5303.             "</Address></Billing>";
  5304.         // Recette (paiements de test)  :
  5305.         //$urletrans ="https://recette-tpeweb.e-transactions.fr/php/";
  5306.         // Production (paiements réels) :
  5307.         // URL principale :
  5308.         $urletrans "https://tpeweb.e-transactions.fr/php/";
  5309.         // URL secondaire :
  5310.         // $urletrans ="https://tpeweb1.e-transactions.fr/php/";
  5311.         // $hmackey = 'A5FD6D11DA2B9C4112201B4D797EC2B32B877C09A0CF56CE8007D91ACBA9A6D9E026149A7E8441D39A9F52C61E0D250ACC6DEC6815EA02621AEE525576CF4DAE';
  5312.         $hmackey 'A5FD6D11DA2B9C4112201B4D797EC2B32B877C09A0CF56CE8007D91ACBA9A6D9E026149A7E8441D39A9F52C61E0D250ACC6DEC6815EA02621AEE525576CF4DAE';
  5313.         $pbx_prenom_fact strtoupper($pbx_prenom_fact);
  5314.         $pbx_nom_fact strtoupper($pbx_nom_fact);
  5315.         $pbx_adresse1_fact strtoupper($pbx_adresse1_fact);
  5316.         $pbx_adresse2_fact strtoupper($pbx_adresse2_fact);
  5317.         $pbx_city_fact strtoupper($pbx_city_fact);
  5318.         $pbx_country_fact strtoupper($pbx_country_fact);
  5319.         // --------------- TRAITEMENT DES VARIABLES ---------------
  5320.         // On crée la chaéne a hacher sans URLencodage
  5321.         $msg "PBX_SITE=" $pbx_site .
  5322.             "&PBX_RANG=" $pbx_rang .
  5323.             "&PBX_IDENTIFIANT=" $pbx_identifiant .
  5324.             "&PBX_SOURCE=RWD" .
  5325.             "&PBX_TOTAL=" $pbx_total .
  5326.             "&PBX_DEVISE=978" .
  5327.             "&PBX_CMD=" $pbx_cmd .
  5328.             "&PBX_PORTEUR=" $pbx_porteur .
  5329.             "&PBX_REPONDRE_A=" $pbx_repondre_a .
  5330.             "&PBX_RETOUR=" $pbx_retour .
  5331.             "&PBX_EFFECTUE=" $pbx_effectue .
  5332.             "&PBX_ANNULE=" $pbx_annule .
  5333.             "&PBX_REFUSE=" $pbx_refuse .
  5334.             "&PBX_HASH=SHA512" .
  5335.             "&PBX_TIME=" $dateTime .
  5336.             "&PBX_SHOPPINGCART=" $pbx_shoppingcart .
  5337.             "&PBX_BILLING=" $pbx_billing .
  5338.             "&PBX_SOUHAITAUTHENT=" $pbx_souhaitauthent;
  5339.         $binKey pack("H*"$hmackey);
  5340.         $hmac strtoupper(hash_hmac('sha512'$msg$binKey));
  5341.         return new JsonResponse(array(
  5342.             'urletrans' => $urletrans,
  5343.             'pbx_site' => $pbx_site,
  5344.             'pbx_rang' => $pbx_rang,
  5345.             'pbx_identifiant' => $pbx_identifiant,
  5346.             'pbx_total' => $pbx_total,
  5347.             'pbx_cmd' => $pbx_cmd,
  5348.             'pbx_porteur' => $pbx_porteur,
  5349.             'pbx_repondre_a' => $pbx_repondre_a,
  5350.             'pbx_retour' => $pbx_retour,
  5351.             'pbx_effectue' => $pbx_effectue,
  5352.             'pbx_annule' => $pbx_annule,
  5353.             'pbx_refuse' => $pbx_refuse,
  5354.             'dateTime' => $dateTime,
  5355.             'pbx_shoppingcart' => $pbx_shoppingcart,
  5356.             'pbx_billing' => $pbx_billing,
  5357.             'pbx_souhaitauthent' => $pbx_souhaitauthent,
  5358.             'hmac' => $hmac
  5359.         ));
  5360.         // 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));
  5361.     }
  5362.     /**
  5363.      * @Route("/Parent/chargement_form_connx", name="chargement_form__Connx")
  5364.      */
  5365.     function chargeFormOgoneAction_Connx(Request $request)
  5366.     {
  5367.         $session $this->session;
  5368.         $em $this->container->get('doctrine')->getManager();
  5369.         $idSejour $session->get("Sejour");
  5370.         /** @var \App\Entity\User $user */
  5371.         $user $this->getUser();
  5372.         $user $user->getId();
  5373.         $comande $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  5374.         $firstName $comande->getIdParent()->getNom();
  5375.         if ($firstName == null || $firstName == '') {
  5376.             $firstName "john";
  5377.         }
  5378.         $lastName $comande->getIdParent()->getPrenom();
  5379.         if ($lastName == null || $lastName == '') {
  5380.             $lastName "Doe";
  5381.         }
  5382.         $addressLine1 "3 rue de l'église";
  5383.         $city $city "Ostheim";
  5384.         $postalCode "68150";
  5385.         //      $postalCode= trim ($postalCode) ;
  5386.         $country "FR";
  5387.         $contexte = array("billing" => array("firstName" => $firstName"lastName" => $lastName"addressLine1" => $addressLine1"city" => $city"postalCode" => $postalCode"country" => $country));
  5388.         //param de payement
  5389.         $contexte_commande base64_encode(json_encode($contexte));
  5390.         $PayementService $this->container->get("App\Service\PayementService");
  5391.         $version $this->getParameter('version'); //done
  5392.         $TPE $this->getParameter('TPE'); //done
  5393.         $dateTime $dateNow = new \DateTime();
  5394.         $date $dateTime->format("d/m/Y:H:i:s");
  5395.         //"05/05/2019:11:55:23" ;
  5396.         $montant $comande->getIdSejour()->getPrixcnxparent() . "EUR";
  5397.         $reference 'REFCN' $comande->getId();
  5398.         $url_retour_ok $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5399.         $url_retour_err $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5400.         $desactivemoyenpaiement "paypal";
  5401.         $lgue "FR"//done
  5402.         $societe "5sur5sejou"//done
  5403.         $textelibre "5sur5sejour"//
  5404.         $mail $this->getUser(); //
  5405.         $SHAIN $this->getParameter('shain');
  5406.         $param = array(
  5407.             'version' => $version,
  5408.             'TPE' => $TPE,
  5409.             'date' => $date,
  5410.             'montant' => $montant,
  5411.             'reference' => $reference,
  5412.             'url_retour_ok' => $url_retour_ok,
  5413.             'url_retour_err' => $url_retour_err,
  5414.             'lgue' => $lgue,
  5415.             'societe' => $societe,
  5416.             'contexte_commande' => $contexte_commande,
  5417.             'texte-libre' => $textelibre,
  5418.             'mail' => $mail,
  5419.             'desactivemoyenpaiement' => $desactivemoyenpaiement
  5420.         );
  5421.         $MAC $PayementService->monetico_hash_parameters('sha1'$param$SHAIN);
  5422.         //utf8_encode
  5423.         return new JsonResponse(array(
  5424.             'version' => $version,
  5425.             'TPE' => $TPE,
  5426.             'date' => $date,
  5427.             'montant' => $montant,
  5428.             'reference' => $reference,
  5429.             'MAC' => $MAC,
  5430.             'url_retour_ok' => utf8_encode($url_retour_ok),
  5431.             'url_retour_err' => utf8_encode($url_retour_err),
  5432.             'lgue' => $lgue,
  5433.             'societe' => $societe,
  5434.             'contexte_commande' => utf8_encode($contexte_commande),
  5435.             'textelibre' => utf8_encode($textelibre),
  5436.             'mail' => $mail,
  5437.             'desactivemoyenpaiement' => $desactivemoyenpaiement
  5438.         ));
  5439.         // 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));
  5440.     }
  5441.     /**
  5442.      * @Route("/Parent/chargement_form_connx_paypal", name="chargement_form__Connx_PayPal")
  5443.      */
  5444.     function chargeFormOgoneAction_Connx_PayPal(Request $request)
  5445.     {
  5446.         $session $this->session;
  5447.         $em $this->container->get('doctrine')->getManager();
  5448.         $idSejour $session->get("Sejour");
  5449.         /** @var \App\Entity\User $user */
  5450.         $user $this->getUser();
  5451.         $user $user->getId();
  5452.         $comande $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  5453.         $firstName $comande->getIdParent()->getNom();
  5454.         if ($firstName == null || $firstName == '') {
  5455.             $firstName "john";
  5456.         }
  5457.         $lastName $comande->getIdParent()->getPrenom();
  5458.         if ($lastName == null || $lastName == '') {
  5459.             $lastName "Doe";
  5460.         }
  5461.         $addressLine1 "3 rue de l'église";
  5462.         $city $city "Ostheim";
  5463.         $postalCode "68150";
  5464.         //      $postalCode= trim ($postalCode) ;
  5465.         $country "FR";
  5466.         $contexte = array("billing" => array("firstName" => $firstName"lastName" => $lastName"addressLine1" => $addressLine1"city" => $city"postalCode" => $postalCode"country" => $country));
  5467.         $protocole "paypal";
  5468.         //param de payement
  5469.         $contexte_commande base64_encode(json_encode($contexte));
  5470.         $PayementService $this->container->get("App\Service\PayementService");
  5471.         $version $this->getParameter('version'); //done
  5472.         $TPE $this->getParameter('TPE'); //done
  5473.         $dateTime $dateNow = new \DateTime();
  5474.         $date $dateTime->format("d/m/Y:H:i:s");
  5475.         //"05/05/2019:11:55:23" ;
  5476.         $montant $comande->getIdSejour()->getPrixcnxparent() . "EUR";
  5477.         $reference 'REFCN' $comande->getId();
  5478.         $url_retour_ok $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5479.         $url_retour_err $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5480.         $lgue "FR"//done
  5481.         $societe "5sur5sejou"//done
  5482.         $textelibre "5sur5sejour"//
  5483.         $mail $this->getUser(); //
  5484.         $SHAIN $this->getParameter('shain');
  5485.         $param = array(
  5486.             'version' => $version,
  5487.             'TPE' => $TPE,
  5488.             'date' => $date,
  5489.             'montant' => $montant,
  5490.             'reference' => $reference,
  5491.             'url_retour_ok' => $url_retour_ok,
  5492.             'url_retour_err' => $url_retour_err,
  5493.             'lgue' => $lgue,
  5494.             'societe' => $societe,
  5495.             'contexte_commande' => $contexte_commande,
  5496.             'texte-libre' => $textelibre,
  5497.             'mail' => $mail,
  5498.             'protocole' => $protocole
  5499.         );
  5500.         $MAC $PayementService->monetico_hash_parameters('sha1'$param$SHAIN);
  5501.         //utf8_encode
  5502.         return new JsonResponse(array(
  5503.             'version' => $version,
  5504.             'TPE' => $TPE,
  5505.             'date' => $date,
  5506.             'montant' => $montant,
  5507.             'reference' => $reference,
  5508.             'MAC' => $MAC,
  5509.             'url_retour_ok' => utf8_encode($url_retour_ok),
  5510.             'url_retour_err' => utf8_encode($url_retour_err),
  5511.             'lgue' => $lgue,
  5512.             'societe' => $societe,
  5513.             'contexte_commande' => utf8_encode($contexte_commande),
  5514.             'textelibre' => utf8_encode($textelibre),
  5515.             'mail' => $mail,
  5516.             'protocole' => $protocole
  5517.         ));
  5518.         // 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));
  5519.     }
  5520.     /**
  5521.      * @Route("/Parent/SupprimerCommande", name="Supprimer_CommandeParent")
  5522.      */
  5523.     function RemoveCommandeParent(Request $request)
  5524.     {
  5525.         $CommandeService $this->commandeService;
  5526.         $idCmd $request->get('id');
  5527.         $result $CommandeService->CommandeCloture($idCmd);
  5528.         return new Response($result);
  5529.     }
  5530.     /**
  5531.      * @Route("/Parent/accept_url_parentcnxx/{id}", name="moneticoAcceptUrl_parentcnxx")
  5532.      */
  5533.     function moneticoAcceptUrl_parent($id)
  5534.     {
  5535.         $em $this->container->get('doctrine')->getManager();
  5536.         $comande $this->em->getRepository(ParentSejour::class)->find($id);
  5537.         if ($comande->getPayment() != 1) {
  5538.             $typ $this->em->getRepository(Typeproduit::class)->find(1);
  5539.             $condit $this->em->getRepository(TypeProduitConditionnement::class)->find(11);
  5540.             $produit = new Produit();
  5541.             $produit->setIdConditionnement($condit);
  5542.             $produit->setType($typ);
  5543.             $produit->setDate(new \DateTime());
  5544.             $produit->setLabele("Connexion");
  5545.             $produit->setIduser($this->getUser());
  5546.             $sats $this->em->getRepository(Ref::class)->find(33);
  5547.             //$ComandeService = $this->container->get("App\Service\ComandeService");
  5548.             $ComandeService $this->commandeService;
  5549.             $comande->setPayment(1);
  5550.             $this->em->getManager()->persist($comande);
  5551.             $this->em->getManager()->flush();
  5552.             $produit->setIdsjour($comande->getIdSejour());
  5553.             $this->em->getManager()->persist($produit);
  5554.             $this->em->getManager()->flush();
  5555.             $bytes random_int(10009999);
  5556.             $pass bin2hex($bytes);
  5557.             //generate Num facture
  5558.             $dateSJoue = new \Datetime();
  5559.             $annes $dateSJoue->format('y');
  5560.             $moi $dateSJoue->format('m');
  5561.             $val $this->em->getRepository(Commande::class)->serachNombreFacture();
  5562.             $val $val 1;
  5563.             $valx sprintf('%04d'$val);
  5564.             $valx1 "20" $annes $moi $valx;
  5565.             $cmdpaym = new Commande();
  5566.             $cmdpaym->setMontantrth($comande->getIdSejour()->getPrixcnxparent());
  5567.             $cmdpaym->setNumComande($pass);
  5568.             $cmdpaym->getIdSejour($pass);
  5569.             $cmdpaym->setNumfacture($valx1);
  5570.             $cmdpaym->setDateCreateCommande(new \DateTime());
  5571.             $cmdpaym->setDateFacture(new \DateTime());
  5572.             $cmdpaym->setStatut($sats);
  5573.             $cmdpaym->setIdSejour($comande->getIdSejour());
  5574.             $cmdpaym->setIdUser($this->getUser());
  5575.             $this->em->getManager()->persist($cmdpaym);
  5576.             $this->em->getManager()->flush();
  5577.             $cmdpaym->setNumfacture(substr($cmdpaym->getNumfacture(), '0'6) . $cmdpaym->getId());
  5578.             $this->em->getManager()->persist($cmdpaym);
  5579.             $this->em->getManager()->flush();
  5580.             $cpmd = new ComandeProduit();
  5581.             $cpmd->setIdComande($cmdpaym);
  5582.             $cpmd->setIdProduit($produit);
  5583.             $cpmd->setQuantiter(1);
  5584.             $cpmd->setDate(new \DateTime());
  5585.             //stille reversment par prod
  5586.             $this->em->getManager()->persist($cpmd);
  5587.             $this->em->getManager()->flush();
  5588.             $pdfOptions = new Options();
  5589.             $pdfOptions->set('isRemoteEnabled'TRUE);
  5590.             $pdfOptions->set('defaultFont''Arial');
  5591.             // Instantiate Dompdf with our options
  5592.             $dompdf = new Dompdf($pdfOptions);
  5593.             $dompdf->set_option('isRemoteEnabled'TRUE);
  5594.             // Retrieve the HTML generated in our twig file
  5595.             $html $this->renderView('Admin/pdfFactureparent.html.twig', [
  5596.                 "Commande" => $cmdpaym,
  5597.             ]);
  5598.             // Load HTML to Dompdf
  5599.             $dompdf->loadHtml($html);
  5600.             // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  5601.             $dompdf->setPaper('A4''portrait');
  5602.             // Render the HTML as PDF
  5603.             $dompdf->render();
  5604.             // Store PDF Binary Data
  5605.             $output $dompdf->output();
  5606.             // In this case, we want to write the file in the public directory
  5607.             $publicDirectory $this->getParameter('kernel.project_dir') . '/public/backupFacture/';
  5608.             // e.g /var/www/project/public/mypdf.pdf
  5609.             $pdfFilepath $publicDirectory "Facture" $cmdpaym->getId() . '-' $cmdpaym->getNumComande() . ".pdf";
  5610.             // Write file to the desired path
  5611.             file_put_contents($pdfFilepath$output);
  5612.         }
  5613.         $jetonService = new JetonService($this->em);
  5614.         if ($jetonService->checkUserFiveConnexion($comande->getIdSejour()->getIdAcommp(), $comande->getIdSejour())) {
  5615.             $jetonService->newJetonForUser($comande->getIdSejour()->getIdAcommp());
  5616.         }
  5617.         $session $this->session;
  5618.         $session->set('paymentmoniteco''succses');
  5619.         $resulat $session->get("paymentmoniteco");
  5620.         //dd($montanttotalcomande);
  5621.         return $this->redirectToRoute('AccueilParent');
  5622.     }
  5623.     /**
  5624.      * @Route("/Parent/accept_url_parentcnxxVirgo/{id}", name="moneticoAcceptUrl_parentcnxxVirgo")
  5625.      */
  5626.     function moneticoAcceptUrl_parentVirgo($id)
  5627.     {
  5628.         $em $this->container->get('doctrine')->getManager();
  5629.         $comande $this->em->getRepository(ParentSejour::class)->find($id);
  5630.         if ($comande->getPayment() != 1) {
  5631.             $typ $this->em->getRepository(Typeproduit::class)->find(1);
  5632.             $condit $this->em->getRepository(TypeProduitConditionnement::class)->find(11);
  5633.             $produit = new Produit();
  5634.             $produit->setIdConditionnement($condit);
  5635.             $produit->setType($typ);
  5636.             $produit->setLabele("Connexion");
  5637.             $produit->setIduser($this->getUser());
  5638.             $produit->setDate(new \DateTime());
  5639.             $sats $this->em->getRepository(Ref::class)->find(33);
  5640.             $ComandeService $this->container->get("App\Service\ComandeService");
  5641.             $comande->setPayment(1);
  5642.             $this->em->getManager()->persist($comande);
  5643.             $this->em->getManager()->flush();
  5644.             $produit->setIdsjour($comande->getIdSejour());
  5645.             $this->em->getManager()->persist($produit);
  5646.             $this->em->getManager()->flush();
  5647.             $bytes random_int(10009999);
  5648.             $pass bin2hex($bytes);
  5649.             //generate Num facture
  5650.             $dateSJoue = new \Datetime();
  5651.             $annes $dateSJoue->format('y');
  5652.             $moi $dateSJoue->format('m');
  5653.             $val $this->em->getRepository(Commande::class)->serachNombreFacture();
  5654.             $val $val 1;
  5655.             $valx sprintf('%04d'$val);
  5656.             $valx1 "20" $annes $moi $valx;
  5657.             $cmdpaym = new Commande();
  5658.             $cmdpaym->setMontantrth($comande->getIdSejour()->getPrixcnxparent());
  5659.             $cmdpaym->setNumComande($pass);
  5660.             $cmdpaym->getIdSejour($pass);
  5661.             $cmdpaym->setNumfacture($valx1);
  5662.             $cmdpaym->setDateFacture(new \DateTime());
  5663.             $cmdpaym->setDateCreateCommande(new \DateTime());
  5664.             $cmdpaym->setStatut($sats);
  5665.             $cmdpaym->setPaymentType("Mobile");
  5666.             $cmdpaym->setIdSejour($comande->getIdSejour());
  5667.             $cmdpaym->setIdUser($this->getUser());
  5668.             $this->em->getManager()->persist($cmdpaym);
  5669.             $this->em->getManager()->flush();
  5670.             $cmdpaym->setNumfacture(substr($cmdpaym->getNumfacture(), '0'6) . $cmdpaym->getId());
  5671.             $this->em->getManager()->persist($cmdpaym);
  5672.             $this->em->getManager()->flush();
  5673.             $cpmd = new ComandeProduit();
  5674.             $cpmd->setIdComande($cmdpaym);
  5675.             $cpmd->setIdProduit($produit);
  5676.             $cpmd->setQuantiter(1);
  5677.             $cpmd->setDate(new \DateTime());
  5678.             //stille reversment par prod
  5679.             $this->em->getManager()->persist($cpmd);
  5680.             $this->em->getManager()->flush();
  5681.             $pdfOptions = new Options();
  5682.             $pdfOptions->set('isRemoteEnabled'TRUE);
  5683.             $pdfOptions->set('defaultFont''Arial');
  5684.             // Instantiate Dompdf with our options
  5685.             $dompdf = new Dompdf($pdfOptions);
  5686.             $dompdf->set_option('isRemoteEnabled'TRUE);
  5687.             // Retrieve the HTML generated in our twig file
  5688.             $html $this->renderView('Admin/pdfFactureparent.html.twig', [
  5689.                 "Commande" => $cmdpaym,
  5690.             ]);
  5691.             // Load HTML to Dompdf
  5692.             $dompdf->loadHtml($html);
  5693.             // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  5694.             $dompdf->setPaper('A4''portrait');
  5695.             // Render the HTML as PDF
  5696.             $dompdf->render();
  5697.             // Store PDF Binary Data
  5698.             $output $dompdf->output();
  5699.             // In this case, we want to write the file in the public directory
  5700.             $publicDirectory $this->getParameter('kernel.project_dir') . '/public/backupFacture/';
  5701.             // e.g /var/www/project/public/mypdf.pdf
  5702.             $pdfFilepath $publicDirectory "Facture" $cmdpaym->getId() . '-' $cmdpaym->getNumComande() . ".pdf";
  5703.             // Write file to the desired path
  5704.             file_put_contents($pdfFilepath$output);
  5705.         }
  5706.         $jetonService = new JetonService($this->em);
  5707.         if ($jetonService->checkUserFiveConnexion($comande->getIdSejour()->getIdAcommp(), $comande->getIdSejour())) {
  5708.             $jetonService->newJetonForUser($comande->getIdSejour()->getIdAcommp());
  5709.         }
  5710.         $session $this->session;
  5711.         $session->set('paymentmoniteco''succses');
  5712.         $resulat $session->get("paymentmoniteco");
  5713.         //dd($montanttotalcomande);
  5714.         return $this->redirectToRoute('AccueilParent');
  5715.     }
  5716.     /**
  5717.      * @Route("/error_url_parentcnxx/{id}", name="moneticoExceptionUrl_parentcnxx")
  5718.      */
  5719.     function moneticoExceptionUrl_parentcnxx($id)
  5720.     {
  5721.         $em $this->container->get('doctrine')->getManager();
  5722.         $comande $this->em->getRepository(ParentSejour::class)->find($id);
  5723.         $session $this->session;
  5724.         $session->set('paymentmoniteco''echec');
  5725.         $comande->setPayment(0);
  5726.         $this->em->getManager()->persist($comande);
  5727.         $this->em->getManager()->flush();
  5728.         $resulat $session->get("paymentmoniteco");
  5729.         //dd($montanttotalcomande);
  5730.         return $this->redirectToRoute('AccueilParent');
  5731.     }
  5732.     /**
  5733.      * @Route("/Parent/SuiviCommande", name="SuiviCommande")
  5734.      * */
  5735.     public function SuiviCommande()
  5736.     {
  5737.         // dd($liste);
  5738.         $user $this->getUser();
  5739.         $session $this->session;
  5740.         $idSejour $session->get("Sejour");
  5741.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  5742.         $ParentSejour $this->em->getRepository(ParentSejour::class)->findBy(['idSejour' => $sejour'idParent' => $user]);
  5743.         //ParentSejour
  5744.         //cablala
  5745.         //dd($ParentSejour[0]);
  5746.         //$listeattach = $sejourservice->getatachmentsejour($id);
  5747.         //$listeattachM = $sejourservice->getsejourmessage($id);
  5748.         return $this->render('Parent/suivicommande.html.twig', [
  5749.             'user' => $user,
  5750.             'sejour' => $sejour,
  5751.             'ParentSejour' => $ParentSejour[0],
  5752.         ]);
  5753.     }
  5754.     /**
  5755.      * @Route("/Parent/SuiviCommandeparent", name="SuiviCommandeparent")
  5756.      * */
  5757.     public function SuiviCommandeparent()
  5758.     {
  5759.         // dd($liste);
  5760.         $user $this->getUser();
  5761.         //dd($user);
  5762.         $cmdservice $this->commandeService;
  5763.         $session $this->session;
  5764.         $idSejour $session->get("Sejour");
  5765.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  5766.         $listeCmd $cmdservice->listerCommandeParent($user);
  5767.         return $this->render('Parent/suivicommande.html.twig', [
  5768.             'user' => $user,
  5769.             'sejour' => $sejour,
  5770.             'listeCmd' => $listeCmd
  5771.         ]);
  5772.     }
  5773.     private function envoieMailPackNumerique($nameZip$email$commande)
  5774.     {
  5775.         // Utiliser directement le numéro de commande comme identifiant de téléchargement
  5776.         $downloadLink =  $nameZip;
  5777.         $this->emailsCmdService->MailPackPhotosNumerique(
  5778.             $email,
  5779.             $downloadLink,
  5780.             $commande->getId(),
  5781.         );
  5782.         // Marquer comme envoyé
  5783.         $commande->setEnvoi(1);
  5784.         $this->em->getManager()->persist($commande);
  5785.         $this->em->getManager()->flush();
  5786.         $this->logger->info("Email sent for order: ");
  5787.         return true;
  5788.     }
  5789.     /**
  5790.      * @Route("/Parent/telechargerPack/{idCommande}", name="telechargerPack")
  5791.      */
  5792.     public function TelechagerPackNumerique($idCommande): Response
  5793.     {
  5794.         $this->logger->info("Tentative de téléchargement du pack pour la commande numérique ID: {$idCommande}");
  5795.         // Récupérer la commande numérique
  5796.         $commandeNumerique $this->em->getRepository(CommandeNumerique::class)->find($idCommande);
  5797.         // Vérifier si la commande existe
  5798.         if (!$commandeNumerique) {
  5799.             $this->logger->error("Commande numérique introuvable - ID: {$idCommande}");
  5800.             return new JsonResponse(["message" => "Commande introuvable"], 404);
  5801.         }
  5802.         // Récupérer les informations associées
  5803.         $commande $commandeNumerique->getIdCommande();
  5804.         $idcommande $commande->getId();
  5805.         $user $commande->getIdUser();
  5806.         $iduser $user->getId();
  5807.         $sejour $commande->getIdSejour();
  5808.         $this->logger->info("Commande numérique {$commandeNumerique->getId()} trouvée, commande parent ID: {$idcommande}, utilisateur: {$user->getEmail()},ETAT: {$commandeNumerique->getEtat()}");
  5809.         $idCmdNumerique $commandeNumerique->getId();
  5810.         // Vérifier si le lien de téléchargement existe
  5811.         $refcmdnum $commandeNumerique->getLinkdownload();
  5812.         $this->logger->info("Lien de téléchargement: {$refcmdnum}");
  5813.         if (!$refcmdnum) {
  5814.             // Envoyer un email d'alerte à l'administrateur
  5815.             $email = (new Email())
  5816.                 ->from('noreply@5sur5sejour.com')
  5817.                 ->to('yousra.tlich@gmail.com')
  5818.                 ->subject('ALERTE - Lien de téléchargement corrompu')
  5819.                 ->text(
  5820.                     "Le lien de téléchargement est corrompu pour la commande suivante:\n" .
  5821.                         "ID Commande Numérique: " $idCmdNumerique "\n" .
  5822.                         "ID Commande: " $idcommande "\n" .
  5823.                         "Utilisateur: " $user->getEmail() . "\n" .
  5824.                         "Séjour: " $sejour->getLibelleSejour() . "\n" .
  5825.                         "Date: " . (new \DateTime())->format('Y-m-d H:i:s')
  5826.                 );
  5827.             $this->symfonyMailer->send($email);
  5828.             $this->logger->error("Lien de téléchargement corrompu pour la commande numérique {$idCommande}");
  5829.             return new JsonResponse(["message" => "Lien de téléchargement non disponible"], 404);
  5830.         }
  5831.         $this->logger->info("Lien de téléchargement trouvé pour la commande numérique {$idCommande}{$refcmdnum}");
  5832.         // Vérifier que l'utilisateur et le séjour existent
  5833.         if (!$user || !$sejour) {
  5834.             $this->logger->error("Utilisateur ou séjour manquant pour la commande numérique {$idCommande}");
  5835.             return new JsonResponse(['message' => 'Lien invalide - utilisateur ou séjour manquant'], 400);
  5836.         }
  5837.         // Vérifier l'état de la commande
  5838.         if ($commandeNumerique->getEtat() === 1) {
  5839.             // Construire le chemin du fichier
  5840.             $filePath $this->getParameter('kernel.project_dir') . '/public/ParentPhotosNumerique/' $refcmdnum '.zip';
  5841.             // Vérifier si le fichier existe
  5842.             if (file_exists($filePath)) {
  5843.                 $this->logger->info("Fichier trouvé, téléchargement démarré pour la commande numérique {$idCmdNumerique}");
  5844.                 return $this->file($filePath$refcmdnum '.zip'ResponseHeaderBag::DISPOSITION_ATTACHMENT);
  5845.             } else {
  5846.                 // Envoyer un email d'alerte pour fichier manquant
  5847.                 $email = (new Email())
  5848.                     ->from('noreply@5sur5sejour.com')
  5849.                     ->to('yousra.tlich@gmail.com')
  5850.                     ->subject('ALERTE - Fichier ZIP manquant')
  5851.                     ->text(
  5852.                         "Le fichier ZIP est manquant pour la commande suivante:\n" .
  5853.                             "ID Commande Numérique: " $idCommande "\n" .
  5854.                             "ID Commande: " $idcommande "\n" .
  5855.                             "Lien de téléchargement: " $refcmdnum "\n" .
  5856.                             "Chemin attendu: " $filePath "\n" .
  5857.                             "Date: " . (new \DateTime())->format('Y-m-d H:i:s')
  5858.                     );
  5859.                 $this->symfonyMailer->send($email);
  5860.                 $this->logger->error("Fichier ZIP manquant pour la commande numérique {$idCommande} - chemin: {$filePath}");
  5861.                 return new JsonResponse(['message' => 'Fichier non trouvé'], 404);
  5862.             }
  5863.         } elseif ($commandeNumerique->getEtat() == 2) {
  5864.             $this->logger->warning("Tentative de téléchargement d'une commande déjà livrée - ID: {$idCommande}");
  5865.             return new JsonResponse(['message' => 'Commande déjà livrée'], 400);
  5866.         } else {
  5867.             $this->logger->warning("État de commande invalide pour la commande numérique {$idCmdNumerique} - état: {$commandeNumerique->getEtat()}");
  5868.             return new JsonResponse(['message' => 'Commande invalide'], 400);
  5869.         }
  5870.     }
  5871.     /**
  5872.      * @Route("/Parent/disableTelecharge/{idCommande}" , name="disableTelecharge" )
  5873.      */
  5874.     public function disableTelecharge($idCommande)
  5875.     {
  5876.         $commandenumerique $this->em->getRepository(CommandeNumerique::class)->findOneBy(['id' => $idCommande]);
  5877.         $commandenumerique->setEtat(2);
  5878.         $commandenumerique->setDateTelechargement(new \DateTime());
  5879.         $this->em->getManager()->persist($commandenumerique);
  5880.         $this->em->getManager()->flush();
  5881.         return "ok";
  5882.     }
  5883.     /**
  5884.      * @Route("/Accompagnateur/pdffacturetest/{id}", name="pdffacturetest")
  5885.      */
  5886.     public function pdffactureAccomptest($id)
  5887.     {
  5888.         $em $this->em;
  5889.         $cmd $em->getRepository(Commande::class)->find($id);
  5890.         return $this->render('Parent/pdfFactureParent.html.twig', [
  5891.             "comande" => $cmd,
  5892.         ]);
  5893.     }
  5894.     /**
  5895.      * @Route("/Parent/pdffacture/{id}", name="pdffacture")
  5896.      */
  5897.     public function pdffacture($id)
  5898.     {
  5899.         $user $this->getUser();
  5900.         $cmd $this->em->getRepository(Commande::class)->find($id);
  5901.         //   $result=   $this->EmailServie->MailCommandeSuivieParent($user->getEmail(),$cmd );
  5902.         // Configure Dompdf according to your needs
  5903.         $pdfOptions = new Options();
  5904.         $pdfOptions->set('isRemoteEnabled'TRUE);
  5905.         $pdfOptions->set('defaultFont''Arial');
  5906.         // Instantiate Dompdf with our options
  5907.         $dompdf = new Dompdf($pdfOptions);
  5908.         $dompdf->set_option('isRemoteEnabled'TRUE);
  5909.         // Retrieve the HTML generated in our twig file
  5910.         $html $this->renderView('Parent/pdfFactureParent.html.twig', [
  5911.             "comande" => $cmd,
  5912.         ]);
  5913.         // Load HTML to Dompdf
  5914.         $dompdf->loadHtml($html);
  5915.         // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  5916.         $dompdf->setPaper('A4''portrait');
  5917.         // Render the HTML as PDF
  5918.         $dompdf->render();
  5919.         // Output the generated PDF to Browser (force download)
  5920.         $dompdf->stream("facture.pdf", [
  5921.             "Attachment" => true
  5922.         ]);
  5923.         return new Response('yoopi');
  5924.     }
  5925.     /**
  5926.      * @Route("/Parent/testPDF/{idPrdt}", name="TcPdf")
  5927.      */
  5928.     public function TcPdf($idPrdt)
  5929.     {
  5930.         ini_set("max_execution_time", -1);
  5931.         $pageLayout = array(2115);
  5932.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  5933.         // set document information
  5934.         $pdf->SetCreator(PDF_CREATOR);
  5935.         $pdf->SetAuthor('Nicola Asuni');
  5936.         $pdf->SetTitle('TCPDF Example 009');
  5937.         $pdf->SetSubject('TCPDF Tutorial');
  5938.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  5939.         $pdf->SetSubject('TCPDF Tutorial');
  5940.         $pdf->setPrintHeader(false);
  5941.         $pdf->setPrintFooter(false);
  5942.         // set image scale factor
  5943.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  5944.         //        $pdf->AddPage();
  5945.         $pdf->setJPEGQuality(100);
  5946.         $horizontal_alignments = array('L''C''R');
  5947.         $vertical_alignments = array('T''M''B');
  5948.         //var_dump($pdf->getPageWidth());
  5949.         //var_dump($pdf->getPageHeight());die();
  5950.         $em $this->em;
  5951.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  5952.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  5953.         //dd($AllPages);
  5954.         //        $fP=[];
  5955.         //        array_push($fP,$AllPages[0]);
  5956.         //dd($AllPages);
  5957.         foreach ($AllPages as $p) {
  5958.             $pdf->AddPage();
  5959.             $pdf->setJPEGQuality(100);
  5960.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  5961.             $nbatach $contenu->nbrAttc;
  5962.             $nbatach intval(str_replace('"'''$nbatach));
  5963.             $color =  $contenu->color;
  5964.             // $color="rgb(255,255,255)";
  5965.             $color str_replace('"rgb('''$color);
  5966.             $color str_replace(')"'''$color);
  5967.             $color explode(","$color);
  5968.             $colorp = array(intval($color[0]), intval($color[1]), intval($color[2]));
  5969.             $tabtxt json_decode($contenu->txt);
  5970.             $tabphoto json_decode($contenu->attache);
  5971.             //
  5972.             //dd($tabtxt);
  5973.             //         dd($tabtxt);
  5974.             //dd($tabphoto);
  5975.             $tabClips json_decode($contenu->clips);
  5976.             // dd($tabClips);
  5977.             $x 0.6;
  5978.             $y 0.8;
  5979.             $w 19.8;
  5980.             $h 13.4;
  5981.             // get the current page break margin
  5982.             $bMargin $pdf->getBreakMargin();
  5983.             // get current auto-page-break mode
  5984.             $auto_page_break $pdf->getAutoPageBreak();
  5985.             // disable auto-page-break
  5986.             $pdf->SetAutoPageBreak(false0);
  5987.             // test all combinations of alignments
  5988.             $fitbox $horizontal_alignments[1] . ' ';
  5989.             $fitbox[1] = $vertical_alignments[1];
  5990.             $pdf->Rect(002115'F', array(), $colorp);
  5991.             //    sizeof($tabphoto)
  5992.             for ($i 0$i sizeof($tabphoto); $i++) {
  5993.                 $photo json_decode($tabphoto[$i]);
  5994.                 //les coordonnées de l'image réel:
  5995.                 $hght $photo->height;
  5996.                 $top $photo->top;
  5997.                 $left $photo->left;
  5998.                 $width $photo->width;
  5999.                 $ordre $photo->ordre;
  6000.                 $zoom $photo->zoom;
  6001.                 $path $photo->path;
  6002.                 $hght floatval(str_replace('cm'''$hght));
  6003.                 $top floatval(str_replace('cm'''$top));
  6004.                 $left floatval(str_replace('cm'''$left));
  6005.                 $width floatval(str_replace('cm'''$width));
  6006.                 //les coordonnées dropzone:
  6007.                 $heightOriginal $photo->height;
  6008.                 $widthOriginal $photo->width;
  6009.                 $top $photo->top;
  6010.                 $left $photo->left;
  6011.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  6012.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  6013.                 $top floatval(str_replace('cm'''$top));
  6014.                 $left floatval(str_replace('cm'''$left));
  6015.                 $heightOriginal $heightOriginal 37.7952755906;
  6016.                 $widthOriginal $widthOriginal 37.7952755906;
  6017.                 $topOriginal $top 37.7952755906;
  6018.                 $leftOriginal $left 37.7952755906;
  6019.                 $heightCrop $photo->heightCrop;
  6020.                 $topCrop $photo->topCrop;
  6021.                 $leftCrop $photo->leftCrop;
  6022.                 $widthCrop $photo->widthCrop;
  6023.                 $path $photo->path;
  6024.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  6025.                 $topCrop floatval(str_replace('cm'''$topCrop));
  6026.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  6027.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  6028.                 $widthCropPX $widthCrop 37.7952755906;
  6029.                 $heightCropPX $heightCrop 37.7952755906;
  6030.                 $topCropPX $topCrop 37.7952755906;
  6031.                 $leftCropPX $leftCrop 37.7952755906;
  6032.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  6033.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  6034.                 // var_dump("//00");
  6035.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  6036.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  6037.                 //Calculer position des images selon nombres images par page:
  6038.                 $positionX 0;
  6039.                 $positionY 0;
  6040.                 $widthImg 0;
  6041.                 $heightImg 0;
  6042.                 if ($nbatach == 1) {
  6043.                     $positionX 1.5;
  6044.                     $positionY 1.5;
  6045.                     $widthImg 18;
  6046.                     $heightImg 12;
  6047.                 } elseif ($nbatach == 2) {
  6048.                     if ($ordre == 1) {
  6049.                         $positionX 1.5;
  6050.                         $positionY 1.5;
  6051.                         $widthImg 8.7;
  6052.                         $heightImg 12;
  6053.                     }
  6054.                     if ($ordre == 2) {
  6055.                         $positionX 10.8;
  6056.                         $positionY 1.5;
  6057.                         $widthImg 8.7;
  6058.                         $heightImg 12;
  6059.                     }
  6060.                 } elseif ($nbatach == 3) {
  6061.                     if ($ordre == 1) {
  6062.                         $positionX 1.5;
  6063.                         $positionY 1.5;
  6064.                         $widthImg 8.7;
  6065.                         $heightImg 12;
  6066.                     }
  6067.                     if ($ordre == 2) {
  6068.                         $positionX 10.8;
  6069.                         $positionY 1.5;
  6070.                         $widthImg 8.7;
  6071.                         $heightImg 5.7;
  6072.                     }
  6073.                     if ($ordre == 3) {
  6074.                         $positionX 10.8;
  6075.                         $positionY 7.8;
  6076.                         $widthImg 8.7;
  6077.                         $heightImg 5.7;
  6078.                     }
  6079.                 } elseif ($nbatach == 4) {
  6080.                     if ($ordre == 1) {
  6081.                         $positionX 1.5;
  6082.                         $positionY 1.5;
  6083.                         $widthImg 8.7;
  6084.                         $heightImg 5.7;
  6085.                     }
  6086.                     if ($ordre == 2) {
  6087.                         $positionX 1.5;
  6088.                         $positionY 7.8;
  6089.                         $widthImg 8.7;
  6090.                         $heightImg 5.7;
  6091.                     }
  6092.                     if ($ordre == 3) {
  6093.                         $positionX 10.8;
  6094.                         $positionY 1.5;
  6095.                         $widthImg 8.7;
  6096.                         $heightImg 5.7;
  6097.                     }
  6098.                     if ($ordre == 4) {
  6099.                         $positionX 10.8;
  6100.                         $positionY 7.8;
  6101.                         $widthImg 8.7;
  6102.                         $heightImg 5.7;
  6103.                     }
  6104.                 } elseif ($nbatach == 5) {
  6105.                     if ($ordre == 1) {
  6106.                         $positionX 1.5;
  6107.                         $positionY 1.5;
  6108.                         $widthImg 18;
  6109.                         $heightImg 8;
  6110.                     }
  6111.                     if ($ordre == 2) {
  6112.                         $positionX 1.5;
  6113.                         $positionY 10.1;
  6114.                         $widthImg 4.05;
  6115.                         $heightImg 3.4;
  6116.                     }
  6117.                     if ($ordre == 3) {
  6118.                         $positionX 6.15;
  6119.                         $positionY 10.1;
  6120.                         $widthImg 4.05;
  6121.                         $heightImg 3.4;
  6122.                     }
  6123.                     if ($ordre == 4) {
  6124.                         $positionX 10.8;
  6125.                         $positionY 10.1;
  6126.                         $widthImg 4.05;
  6127.                         $heightImg 3.4;
  6128.                     }
  6129.                     if ($ordre == 5) {
  6130.                         $positionX 15.45;
  6131.                         $positionY 10.1;
  6132.                         $widthImg 4.05;
  6133.                         $heightImg 3.4;
  6134.                     }
  6135.                 } elseif ($nbatach == 6) {
  6136.                     if ($ordre == 1) {
  6137.                         $positionX 1.5;
  6138.                         $positionY 1.5;
  6139.                         $widthImg 5.53;
  6140.                         $heightImg 3.6;
  6141.                     }
  6142.                     if ($ordre == 2) {
  6143.                         $positionX 1.5;
  6144.                         $positionY 5.7;
  6145.                         $widthImg 5.53;
  6146.                         $heightImg 3.6;
  6147.                     }
  6148.                     if ($ordre == 3) {
  6149.                         $positionX 1.5;
  6150.                         $positionY 9.9;
  6151.                         $widthImg 5.53;
  6152.                         $heightImg 3.6;
  6153.                     }
  6154.                     if ($ordre == 4) {
  6155.                         $positionX 7.63;
  6156.                         $positionY 1.5;
  6157.                         $widthImg 5.53;
  6158.                         $heightImg 3.6;
  6159.                     }
  6160.                     if ($ordre == 5) {
  6161.                         $positionX 7.63;
  6162.                         $positionY 5.7;
  6163.                         $widthImg 5.53;
  6164.                         $heightImg 3.6;
  6165.                     }
  6166.                     if ($ordre == 6) {
  6167.                         $positionX 7.63;
  6168.                         $positionY 9.9;
  6169.                         $widthImg 5.53;
  6170.                         $heightImg 3.6;
  6171.                     }
  6172.                 } elseif ($nbatach == 12) {
  6173.                     if ($ordre == 1) {
  6174.                         $positionX 1.5;
  6175.                         $positionY 1.5;
  6176.                         $widthImg 4.05;
  6177.                         $heightImg 3.6;
  6178.                     }
  6179.                     if ($ordre == 2) {
  6180.                         $positionX 1.5;
  6181.                         $positionY 5.7;
  6182.                         $widthImg 4.05;
  6183.                         $heightImg 3.6;
  6184.                     }
  6185.                     if ($ordre == 3) {
  6186.                         $positionX 1.5;
  6187.                         $positionY 9.9;
  6188.                         $widthImg 4.05;
  6189.                         $heightImg 3.6;
  6190.                     }
  6191.                     if ($ordre == 4) {
  6192.                         $positionX 6.15;
  6193.                         $positionY 1.5;
  6194.                         $widthImg 4.05;
  6195.                         $heightImg 3.6;
  6196.                     }
  6197.                     if ($ordre == 5) {
  6198.                         $positionX 6.15;
  6199.                         $positionY 5.7;
  6200.                         $widthImg 4.05;
  6201.                         $heightImg 3.6;
  6202.                     }
  6203.                     if ($ordre == 6) {
  6204.                         $positionX 6.15;
  6205.                         $positionY 9.9;
  6206.                         $widthImg 4.05;
  6207.                         $heightImg 3.6;
  6208.                     }
  6209.                     if ($ordre == 7) {
  6210.                         $positionX 10.8;
  6211.                         $positionY 1.5;
  6212.                         $widthImg 4.05;
  6213.                         $heightImg 3.6;
  6214.                     }
  6215.                     if ($ordre == 8) {
  6216.                         $positionX 10.8;
  6217.                         $positionY 5.7;
  6218.                         $widthImg 4.05;
  6219.                         $heightImg 3.6;
  6220.                     }
  6221.                     if ($ordre == 9) {
  6222.                         $positionX 10.8;
  6223.                         $positionY 9.9;
  6224.                         $widthImg 4.05;
  6225.                         $heightImg 3.6;
  6226.                     }
  6227.                     if ($ordre == 10) {
  6228.                         $positionX 15.45;
  6229.                         $positionY 1.5;
  6230.                         $widthImg 4.05;
  6231.                         $heightImg 3.6;
  6232.                     }
  6233.                     if ($ordre == 11) {
  6234.                         $positionX 15.45;
  6235.                         $positionY 5.7;
  6236.                         $widthImg 4.05;
  6237.                         $heightImg 3.6;
  6238.                     }
  6239.                     if ($ordre == 12) {
  6240.                         $positionX 15.45;
  6241.                         $positionY 9.9;
  6242.                         $widthImg 4.05;
  6243.                         $heightImg 3.6;
  6244.                     }
  6245.                 }
  6246.                 //Recarder l'image :
  6247.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  6248.                 //                $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);
  6249.                 $pathArray explode("/"$path);
  6250.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  6251.                 $idImage "";
  6252.                 foreach ($idsArray as $key => $elem) {
  6253.                     if ($key != (sizeof($idsArray) - 1)) {
  6254.                         $idImage $idImage $elem;
  6255.                     }
  6256.                 }
  6257.                 //   $cloudinaryWidht=$widthOriginal;
  6258.                 // $cloudinaryHeight=$widthOriginal;
  6259.                 $idImage 'newprod/' $idImage;
  6260.                 //var_dump($idImage);
  6261.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  6262.                 $headers = array('Accept' => 'application/json');
  6263.                 $data = array("public_ids" => array($idImage));
  6264.                 $body Unirest\Request\Body::form($data);
  6265.                 Unirest\Request::verifyPeer(false);
  6266.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  6267.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  6268.                 //  var_dump($url);
  6269.                 //https://media.5sur5sejour.com/api/upload/a_exif/original/
  6270.                 $resultMetadata Unirest\Request::post($url$headers$body);
  6271.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  6272.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  6273.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  6274.                 } else {
  6275.                     $cloudinaryWidht $widthOriginal;
  6276.                     $cloudinaryHeight $heightOriginal;
  6277.                 }
  6278.                 $ratiohight $cloudinaryWidht $widthOriginal;
  6279.                 $ratioHight $cloudinaryHeight $heightOriginal;
  6280.                 //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  6281.                 //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  6282.                 var_dump($cloudinaryWidht);
  6283.                 var_dump($cloudinaryHeight);
  6284.                 var_dump($ratioHight);
  6285.                 var_dump($zoom);
  6286.                 var_dump($leftOriginal);
  6287.                 var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  6288.                 var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  6289.                 var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  6290.                 var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  6291.                 //var_dump($path);i
  6292.                 $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);
  6293.                 //var_dump($path);i
  6294.                 //                $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);
  6295.                 //var_dump($path);
  6296.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  6297.                 //  var_dump("//00");
  6298.                 //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  6299.                 //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  6300.                 //    var_dump("//00");
  6301.                 //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  6302.                 //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  6303.                 var_dump($zoom);
  6304.                 var_dump($path);
  6305.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  6306.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  6307.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  6308.                 //
  6309.             }
  6310.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  6311.             for ($i 0$i sizeof($tabtxt); $i++) {
  6312.                 $txt json_decode($tabtxt[$i]);
  6313.                 $fontSize floatval(str_replace('px'''$txt->fontSize)) * 0.75;
  6314.                 //$txt->rotation
  6315.                 $check explode(','$txt->fontFamily);
  6316.                 if (sizeof($check) > 1) {
  6317.                     //default
  6318.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 400)) {
  6319.                         $finalFont "helvetica";
  6320.                         $weight '';
  6321.                     }
  6322.                     //classique
  6323.                     if (($check[0] == "Georgia") && ($txt->fontWeight == 400)) {
  6324.                         $finalFont "times";
  6325.                         $weight '';
  6326.                     }
  6327.                     //creative
  6328.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 700)) {
  6329.                         $finalFont "helveticaB";
  6330.                         $weight '';
  6331.                     }
  6332.                     // manuscrite
  6333.                     if (($check[0] == "Comic Sans") && ($txt->fontWeight == 400)) {
  6334.                         $finalFont "Courier";
  6335.                         $weight '';
  6336.                     }
  6337.                     //c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff2
  6338.                 } else {
  6339.                     //baton
  6340.                     if (($txt->fontFamily == 'Impact') && ($txt->fontWeight == 400)) {
  6341.                         $finalFont "helveticaB";
  6342.                         $weight 'B';
  6343.                     }
  6344.                 }
  6345.                 $pdf->SetFont($finalFont$weight$fontSize);
  6346.                 $leftTxt $txt->left;
  6347.                 $topTxt $txt->top;
  6348.                 $heightClips $txt->height;
  6349.                 $widthClips $txt->width;
  6350.                 $heightTxt floatval(str_replace('cm'''$heightClips));
  6351.                 $topTxt floatval(str_replace('cm'''$topTxt));
  6352.                 $leftTxt floatval(str_replace('cm'''$leftTxt));
  6353.                 $widthTxt floatval(str_replace('cm'''$widthClips));
  6354.                 $pdf->SetXY($leftTxt$topTxttrue);
  6355.                 //                    var_dump($leftTxt);
  6356.                 //                  var_dump($topTxt);
  6357.                 // var_dump(floatval(str_replace('rad','',$txt->rotation))*57,2958);
  6358.                 //                var_dump("text");
  6359.                 $pdf->StartTransform();
  6360.                 var_dump($txt->rotation);
  6361.                 var_dump(str_replace('rad'''$txt->rotation));
  6362.                 var_dump(floatval(str_replace('rad'''$txt->rotation)) * 57.2958);
  6363.                 $pdf->Rotate((floatval(str_replace('rad'''$txt->rotation)) * 57.2958) * -1$leftTxt + ($widthTxt 2), $topTxt + ($heightTxt 2));
  6364.                 // $pdf->Rotate(45);
  6365.                 //   $pdf->Text($leftTxt, $topTxt, $txt->contenu);
  6366.                 //$pdf->SetTextColor(200);
  6367.                 //$pdf->Text($leftTxt, $topTxt, $txt->contenu);
  6368.                 // $pdf->MultiCell($leftTxt, $topTxt,  $txt->contenu, 0, $ln=0, 'C', 0, '', 0, false, 'C', 'C');
  6369.                 $pdf->Write(str_replace('cm'''$txt->height), trim($txt->contenu));
  6370.                 // $pdf->writeHTML("<p>".$txt->contenu."</p>", true, false, false, false, '');
  6371.                 $pdf->StopTransform();
  6372.             }
  6373.             //Positionner text
  6374.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  6375.             //Positionner clipart
  6376.             //            dd($tabClips);
  6377.             for ($i 0$i sizeof($tabClips); $i++) {
  6378.                 $Clips json_decode($tabClips[$i]);
  6379.                 $heightClips $Clips->height;
  6380.                 $topClips $Clips->top;
  6381.                 $leftClips $Clips->left;
  6382.                 $widthClips $Clips->width;
  6383.                 $path $Clips->path;
  6384.                 $pathClips str_replace('"'''$path);
  6385.                 $heightClips floatval(str_replace('cm'''$heightClips));
  6386.                 $topClips floatval(str_replace('cm'''$topClips));
  6387.                 $leftClips floatval(str_replace('cm'''$leftClips));
  6388.                 $widthClips floatval(str_replace('cm'''$widthClips));
  6389.                 $heightClipsPX round($heightClips 37.7952755906);
  6390.                 $widthClipsPX round($widthClips 37.7952755906);
  6391.                 ////                $positionXclips = $positionX + $leftClips;
  6392.                 ////                $positionYclips = $positionY + $topClips;
  6393.                 //
  6394.                 //$pdf->ImageSVG("images/ClipArt_SVG/Ete4.svg",$leftClips,$topClips,$widthClips, $heightClips);
  6395.                 //https://res.cloudinary.com/apss-factory/image/private/s--EdExAzx8--/v1588758453/GlobeFooter_c4duua.svg
  6396.                 // https://res.cloudinary.com/apss-factory/image/upload/v1588764528/Groupe_113_pcjyj4.png
  6397.                 var_dump($pathClips);
  6398.                 $pdf->StartTransform();
  6399.                 $pdf->Rotate((floatval(str_replace('rad'''$Clips->rotation)) * 57.2958) * -1$leftClips + ($widthClips 2), $topClips + ($heightClips 2));
  6400.                 $pdf->Image($this->newPAthCLipart($pathClips$heightClipsPX$widthClipsPX), $leftClips,  $topClips$widthClips$heightClips''''''false300);
  6401.                 $pdf->StopTransform();
  6402.             }
  6403.         }
  6404.         // echo '</pre>';
  6405.         //return new response("yezi");
  6406.         $projectRoot $this->getParameter('kernel.project_dir');
  6407.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  6408.         return new response("yezi");
  6409.         //return $pdf->Output('example_009.pdf', 'I');
  6410.     }
  6411.     /**
  6412.      * @Route("/Parent/testPDFphoto/{idPrdt}", name="TcPdfphoto")
  6413.      */
  6414.     public function TcPdfPhoto($idPrdt)
  6415.     {
  6416.         ini_set("max_execution_time", -1);
  6417.         $pageLayout = array(1510);
  6418.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  6419.         // set document information
  6420.         $pdf->SetCreator(PDF_CREATOR);
  6421.         $pdf->SetAuthor('Nicola Asuni');
  6422.         $pdf->SetTitle('TCPDF Example 009');
  6423.         $pdf->SetSubject('TCPDF Tutorial');
  6424.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  6425.         $pdf->SetSubject('TCPDF Tutorial');
  6426.         $pdf->setPrintHeader(false);
  6427.         $pdf->setPrintFooter(false);
  6428.         // set image scale factor
  6429.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  6430.         //        $pdf->AddPage();
  6431.         $pdf->setJPEGQuality(100);
  6432.         $horizontal_alignments = array('L''C''R');
  6433.         $vertical_alignments = array('T''M''B');
  6434.         //var_dump($pdf->getPageWidth());
  6435.         //var_dump($pdf->getPageHeight());die();
  6436.         $em $this->em;
  6437.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  6438.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  6439.         //dd($AllPages);
  6440.         //        $fP=[];
  6441.         //        array_push($fP,$AllPages[0]);
  6442.         //dd($AllPages);
  6443.         foreach ($AllPages as $p) {
  6444.             $pdf->AddPage();
  6445.             $pdf->setJPEGQuality(100);
  6446.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  6447.             $nbatach $contenu->nbrAttc;
  6448.             $nbatach intval(str_replace('"'''$nbatach));
  6449.             $color =  $contenu->color;
  6450.             // $color="rgb(255,255,255)";
  6451.             $tabphoto json_decode($contenu->attache);
  6452.             //
  6453.             //dd($tabtxt);
  6454.             //         dd($tabtxt);
  6455.             //dd($tabphoto);
  6456.             // dd($tabClips);
  6457.             // get the current page break margin
  6458.             $bMargin $pdf->getBreakMargin();
  6459.             // get current auto-page-break mode
  6460.             $auto_page_break $pdf->getAutoPageBreak();
  6461.             // disable auto-page-break
  6462.             $pdf->SetAutoPageBreak(false0);
  6463.             // test all combinations of alignments
  6464.             $fitbox $horizontal_alignments[1] . ' ';
  6465.             $fitbox[1] = $vertical_alignments[1];
  6466.             //    sizeof($tabphoto)
  6467.             for ($i 0$i sizeof($tabphoto); $i++) {
  6468.                 $photo json_decode($tabphoto[$i]);
  6469.                 //les coordonnées de l'image réel:
  6470.                 $hght $photo->height;
  6471.                 $top $photo->top;
  6472.                 $left $photo->left;
  6473.                 $width $photo->width;
  6474.                 $ordre $photo->ordre;
  6475.                 $zoom $photo->zoom;
  6476.                 $path $photo->path;
  6477.                 $hght floatval(str_replace('cm'''$hght));
  6478.                 $top floatval(str_replace('cm'''$top));
  6479.                 $left floatval(str_replace('cm'''$left));
  6480.                 $width floatval(str_replace('cm'''$width));
  6481.                 //les coordonnées dropzone:
  6482.                 $heightOriginal $photo->height;
  6483.                 $widthOriginal $photo->width;
  6484.                 $top $photo->top;
  6485.                 $left $photo->left;
  6486.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  6487.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  6488.                 $top floatval(str_replace('cm'''$top));
  6489.                 $left floatval(str_replace('cm'''$left));
  6490.                 $heightOriginal $heightOriginal 37.7952755906;
  6491.                 $widthOriginal $widthOriginal 37.7952755906;
  6492.                 $topOriginal $top 37.7952755906;
  6493.                 $leftOriginal $left 37.7952755906;
  6494.                 $heightCrop $photo->heightCrop;
  6495.                 $topCrop $photo->topCrop;
  6496.                 $leftCrop $photo->leftCrop;
  6497.                 $widthCrop $photo->widthCrop;
  6498.                 $path $photo->path;
  6499.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  6500.                 $topCrop floatval(str_replace('cm'''$topCrop));
  6501.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  6502.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  6503.                 $widthCropPX $widthCrop 37.7952755906;
  6504.                 $heightCropPX $heightCrop 37.7952755906;
  6505.                 $topCropPX $topCrop 37.7952755906;
  6506.                 $leftCropPX $leftCrop 37.7952755906;
  6507.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  6508.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  6509.                 // var_dump("//00");
  6510.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  6511.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  6512.                 //Calculer position des images selon nombres images par page:
  6513.                 $positionX 0;
  6514.                 $positionY 0;
  6515.                 $widthImg 0;
  6516.                 $heightImg 0;
  6517.                 if ($nbatach == 1) {
  6518.                     $positionX 0.3;
  6519.                     $positionY 0.3;
  6520.                     $widthImg 14.4;
  6521.                     $heightImg 9.4;
  6522.                 }
  6523.                 //Recarder l'image :
  6524.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  6525.                 //                $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);
  6526.                 $pathArray explode("/"$path);
  6527.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  6528.                 $idImage "";
  6529.                 foreach ($idsArray as $key => $elem) {
  6530.                     if ($key != (sizeof($idsArray) - 1)) {
  6531.                         $idImage $idImage $elem;
  6532.                     }
  6533.                 }
  6534.                 //   $cloudinaryWidht=$widthOriginal;
  6535.                 // $cloudinaryHeight=$widthOriginal;
  6536.                 $idImage 'newprod/' $idImage;
  6537.                 //var_dump($idImage);
  6538.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  6539.                 $headers = array('Accept' => 'application/json');
  6540.                 $data = array("public_ids" => array($idImage));
  6541.                 $body Unirest\Request\Body::form($data);
  6542.                 Unirest\Request::verifyPeer(false);
  6543.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  6544.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  6545.                 //  var_dump($url);
  6546.                 $resultMetadata Unirest\Request::post($url$headers$body);
  6547.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  6548.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  6549.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  6550.                 } else {
  6551.                     $cloudinaryWidht $widthOriginal;
  6552.                     $cloudinaryHeight $heightOriginal;
  6553.                 }
  6554.                 $ratiohight $cloudinaryWidht $widthOriginal;
  6555.                 $ratioHight $cloudinaryHeight $heightOriginal;
  6556.                 //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  6557.                 //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  6558.                 $zoom 1;
  6559.                 var_dump($cloudinaryWidht);
  6560.                 var_dump($cloudinaryHeight);
  6561.                 var_dump($ratioHight);
  6562.                 var_dump($zoom);
  6563.                 var_dump($leftOriginal);
  6564.                 var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  6565.                 var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  6566.                 var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  6567.                 var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  6568.                 //var_dump($path);i
  6569.                 $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);
  6570.                 //var_dump($path);i
  6571.                 //                $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);
  6572.                 //var_dump($path);
  6573.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  6574.                 //  var_dump("//00");
  6575.                 //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  6576.                 //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  6577.                 //    var_dump("//00");
  6578.                 //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  6579.                 //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  6580.                 var_dump($zoom);
  6581.                 var_dump($path);
  6582.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  6583.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  6584.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  6585.                 //
  6586.             }
  6587.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  6588.             //Positionner text
  6589.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  6590.             //Positionner clipart
  6591.             //            dd($tabClips);
  6592.         }
  6593.         // echo '</pre>';
  6594.         //return new response("yezi");
  6595.         $projectRoot $this->getParameter('kernel.project_dir');
  6596.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  6597.         return new response("yezi");
  6598.         //return $pdf->Output('example_009.pdf', 'I');
  6599.     }
  6600.     /**
  6601.      * @Route("/Parent/testPDFphotoR/{idPrdt}", name="TcPdfphotoR")
  6602.      */
  6603.     public function TcPdfPhotoR($idPrdt)
  6604.     {
  6605.         ini_set("max_execution_time", -1);
  6606.         $pageLayout = array(910);
  6607.         $pdf $this->get("white_october.tcpdf")->create('P''CM'$pageLayouttrue'UTF-8'false);
  6608.         // set document information
  6609.         $pdf->SetCreator(PDF_CREATOR);
  6610.         $pdf->SetAuthor('Nicola Asuni');
  6611.         $pdf->SetTitle('TCPDF Example 009');
  6612.         $pdf->SetSubject('TCPDF Tutorial');
  6613.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  6614.         $pdf->SetSubject('TCPDF Tutorial');
  6615.         $pdf->setPrintHeader(false);
  6616.         $pdf->setPrintFooter(false);
  6617.         // set image scale factor
  6618.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  6619.         //        $pdf->AddPage();
  6620.         $pdf->setJPEGQuality(100);
  6621.         $horizontal_alignments = array('L''C''R');
  6622.         $vertical_alignments = array('T''M''B');
  6623.         //var_dump($pdf->getPageWidth());
  6624.         //var_dump($pdf->getPageHeight());die();
  6625.         $em $this->em;
  6626.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  6627.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  6628.         //dd($AllPages);
  6629.         //        $fP=[];
  6630.         //        array_push($fP,$AllPages[0]);
  6631.         //dd($AllPages);
  6632.         foreach ($AllPages as $p) {
  6633.             $pdf->AddPage();
  6634.             $pdf->setJPEGQuality(100);
  6635.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  6636.             $nbatach $contenu->nbrAttc;
  6637.             $nbatach intval(str_replace('"'''$nbatach));
  6638.             $color =  $contenu->color;
  6639.             // $color="rgb(255,255,255)";
  6640.             $tabphoto json_decode($contenu->attache);
  6641.             //
  6642.             //dd($tabtxt);
  6643.             //         dd($tabtxt);
  6644.             //dd($tabphoto);
  6645.             // dd($tabClips);
  6646.             // get the current page break margin
  6647.             $bMargin $pdf->getBreakMargin();
  6648.             // get current auto-page-break mode
  6649.             $auto_page_break $pdf->getAutoPageBreak();
  6650.             // disable auto-page-break
  6651.             $pdf->SetAutoPageBreak(false0);
  6652.             // test all combinations of alignments
  6653.             $fitbox $horizontal_alignments[1] . ' ';
  6654.             $fitbox[1] = $vertical_alignments[1];
  6655.             //    sizeof($tabphoto)
  6656.             for ($i 0$i sizeof($tabphoto); $i++) {
  6657.                 $photo json_decode($tabphoto[$i]);
  6658.                 //les coordonnées de l'image réel:
  6659.                 $hght $photo->height;
  6660.                 $top $photo->top;
  6661.                 $left $photo->left;
  6662.                 $width $photo->width;
  6663.                 $ordre $photo->ordre;
  6664.                 $zoom $photo->zoom;
  6665.                 $path $photo->path;
  6666.                 $hght floatval(str_replace('cm'''$hght));
  6667.                 $top floatval(str_replace('cm'''$top));
  6668.                 $left floatval(str_replace('cm'''$left));
  6669.                 $width floatval(str_replace('cm'''$width));
  6670.                 //les coordonnées dropzone:
  6671.                 $heightOriginal $photo->height;
  6672.                 $widthOriginal $photo->width;
  6673.                 $top $photo->top;
  6674.                 $left $photo->left;
  6675.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  6676.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  6677.                 $top floatval(str_replace('cm'''$top));
  6678.                 $left floatval(str_replace('cm'''$left));
  6679.                 $heightOriginal $heightOriginal 37.7952755906;
  6680.                 $widthOriginal $widthOriginal 37.7952755906;
  6681.                 $topOriginal $top 37.7952755906;
  6682.                 $leftOriginal $left 37.7952755906;
  6683.                 $heightCrop $photo->heightCrop;
  6684.                 $topCrop $photo->topCrop;
  6685.                 $leftCrop $photo->leftCrop;
  6686.                 $widthCrop $photo->widthCrop;
  6687.                 $path $photo->path;
  6688.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  6689.                 $topCrop floatval(str_replace('cm'''$topCrop));
  6690.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  6691.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  6692.                 $widthCropPX $widthCrop 37.7952755906;
  6693.                 $heightCropPX $heightCrop 37.7952755906;
  6694.                 $topCropPX $topCrop 37.7952755906;
  6695.                 $leftCropPX $leftCrop 37.7952755906;
  6696.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  6697.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  6698.                 // var_dump("//00");
  6699.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  6700.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  6701.                 //Calculer position des images selon nombres images par page:
  6702.                 $positionX 0;
  6703.                 $positionY 0;
  6704.                 $widthImg 0;
  6705.                 $heightImg 0;
  6706.                 $positionX 0.55;
  6707.                 $positionY 0.5;
  6708.                 $widthImg 7.9;
  6709.                 $heightImg 6.9;
  6710.                 //Recarder l'image :
  6711.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  6712.                 //                $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);
  6713.                 $pathArray explode("/"$path);
  6714.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  6715.                 $idImage "";
  6716.                 foreach ($idsArray as $key => $elem) {
  6717.                     if ($key != (sizeof($idsArray) - 1)) {
  6718.                         $idImage $idImage $elem;
  6719.                     }
  6720.                 }
  6721.                 //   $cloudinaryWidht=$widthOriginal;
  6722.                 // $cloudinaryHeight=$widthOriginal;
  6723.                 $idImage 'newprod/' $idImage;
  6724.                 //var_dump($idImage);
  6725.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  6726.                 $headers = array('Accept' => 'application/json');
  6727.                 $data = array("public_ids" => array($idImage));
  6728.                 $body Unirest\Request\Body::form($data);
  6729.                 Unirest\Request::verifyPeer(false);
  6730.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  6731.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  6732.                 //  var_dump($url);
  6733.                 $resultMetadata Unirest\Request::post($url$headers$body);
  6734.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  6735.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  6736.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  6737.                 } else {
  6738.                     $cloudinaryWidht $widthOriginal;
  6739.                     $cloudinaryHeight $heightOriginal;
  6740.                 }
  6741.                 $ratiohight $cloudinaryWidht $widthOriginal;
  6742.                 $ratioHight $cloudinaryHeight $heightOriginal;
  6743.                 //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  6744.                 //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  6745.                 $zoom 1;
  6746.                 var_dump($cloudinaryWidht);
  6747.                 var_dump($cloudinaryHeight);
  6748.                 var_dump($ratioHight);
  6749.                 var_dump($zoom);
  6750.                 var_dump($leftOriginal);
  6751.                 var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  6752.                 var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  6753.                 var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  6754.                 var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  6755.                 //var_dump($path);i
  6756.                 $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);
  6757.                 //var_dump($path);i
  6758.                 //                $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);
  6759.                 //var_dump($path);
  6760.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  6761.                 //  var_dump("//00");
  6762.                 //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  6763.                 //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  6764.                 //    var_dump("//00");
  6765.                 //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  6766.                 //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  6767.                 var_dump($zoom);
  6768.                 var_dump($path);
  6769.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  6770.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  6771.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  6772.                 //
  6773.             }
  6774.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  6775.             //Positionner text
  6776.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  6777.             //Positionner clipart
  6778.             //            dd($tabClips);
  6779.         }
  6780.         // echo '</pre>';
  6781.         //return new response("yezi");
  6782.         $projectRoot $this->getParameter('kernel.project_dir');
  6783.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  6784.         return new response("yezi");
  6785.         //return $pdf->Output('example_009.pdf', 'I');
  6786.     }
  6787.     /**
  6788.      * @Route("/Parent/testPDFCal/{idPrdt}", name="TcPdfCal")
  6789.      */
  6790.     public function TcPdfCalendrier($idPrdt)
  6791.     {
  6792.         ini_set("max_execution_time", -1);
  6793.         $pageLayout = array(2115);
  6794.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  6795.         // set document information
  6796.         $pdf->SetCreator(PDF_CREATOR);
  6797.         $pdf->SetAuthor('Nicola Asuni');
  6798.         $pdf->SetTitle('TCPDF Example 009');
  6799.         $pdf->SetSubject('TCPDF Tutorial');
  6800.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  6801.         $pdf->SetSubject('TCPDF Tutorial');
  6802.         $pdf->setPrintHeader(false);
  6803.         $pdf->setPrintFooter(false);
  6804.         // set image scale factor
  6805.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  6806.         //        $pdf->AddPage();
  6807.         $pdf->setJPEGQuality(100);
  6808.         $horizontal_alignments = array('L''C''R');
  6809.         $vertical_alignments = array('T''M''B');
  6810.         //var_dump($pdf->getPageWidth());
  6811.         //var_dump($pdf->getPageHeight());die();
  6812.         $em $this->em;
  6813.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  6814.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  6815.         //dd($AllPages);
  6816.         //        $fP=[];
  6817.         //        array_push($fP,$AllPages[0]);
  6818.         //dd($AllPages);
  6819.         foreach ($AllPages as $key => $p) {
  6820.             $pdf->AddPage();
  6821.             $pdf->setJPEGQuality(100);
  6822.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  6823.             $nbatachS $contenu->nbrAttc;
  6824.             $nbatach intval(str_replace('"'''$nbatachS));
  6825.             if (strpos($nbatachS"H")) {
  6826.                 $nbatach $nbatach 'H';
  6827.             }
  6828.             $tabtxt json_decode($contenu->txt);
  6829.             $tabphoto json_decode($contenu->attache);
  6830.             //
  6831.             //dd($tabtxt);
  6832.             //         dd($tabtxt);
  6833.             //dd($tabphoto);
  6834.             $tabClips json_decode($contenu->clips);
  6835.             // dd($tabClips);
  6836.             $x 0.6;
  6837.             $y 0.8;
  6838.             $w 19.8;
  6839.             $h 13.4;
  6840.             // get the current page break margin
  6841.             $bMargin $pdf->getBreakMargin();
  6842.             // get current auto-page-break mode
  6843.             $auto_page_break $pdf->getAutoPageBreak();
  6844.             // disable auto-page-break
  6845.             $pdf->SetAutoPageBreak(false0);
  6846.             // test all combinations of alignments
  6847.             $fitbox $horizontal_alignments[1] . ' ';
  6848.             $fitbox[1] = $vertical_alignments[1];
  6849.             //    sizeof($tabphoto)
  6850.             for ($i 0$i sizeof($tabphoto); $i++) {
  6851.                 $photo json_decode($tabphoto[$i]);
  6852.                 //les coordonnées de l'image réel:
  6853.                 $hght $photo->height;
  6854.                 $top $photo->top;
  6855.                 $left $photo->left;
  6856.                 $width $photo->width;
  6857.                 $ordre $photo->ordre;
  6858.                 $zoom $photo->zoom;
  6859.                 $path $photo->path;
  6860.                 $hght floatval(str_replace('cm'''$hght));
  6861.                 $top floatval(str_replace('cm'''$top));
  6862.                 $left floatval(str_replace('cm'''$left));
  6863.                 $width floatval(str_replace('cm'''$width));
  6864.                 //les coordonnées dropzone:
  6865.                 $heightOriginal $photo->height;
  6866.                 $widthOriginal $photo->width;
  6867.                 $top $photo->top;
  6868.                 $left $photo->left;
  6869.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  6870.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  6871.                 $top floatval(str_replace('cm'''$top));
  6872.                 $left floatval(str_replace('cm'''$left));
  6873.                 $heightOriginal $heightOriginal 37.7952755906;
  6874.                 $widthOriginal $widthOriginal 37.7952755906;
  6875.                 $topOriginal $top 37.7952755906;
  6876.                 $leftOriginal $left 37.7952755906;
  6877.                 $heightCrop $photo->heightCrop;
  6878.                 $topCrop $photo->topCrop;
  6879.                 $leftCrop $photo->leftCrop;
  6880.                 $widthCrop $photo->widthCrop;
  6881.                 $path $photo->path;
  6882.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  6883.                 $topCrop floatval(str_replace('cm'''$topCrop));
  6884.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  6885.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  6886.                 $widthCropPX $widthCrop 37.7952755906;
  6887.                 $heightCropPX $heightCrop 37.7952755906;
  6888.                 $topCropPX $topCrop 37.7952755906;
  6889.                 $leftCropPX $leftCrop 37.7952755906;
  6890.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  6891.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  6892.                 // var_dump("//00");
  6893.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  6894.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  6895.                 //Calculer position des images selon nombres images par page:
  6896.                 $positionX 0;
  6897.                 $positionY 0;
  6898.                 $widthImg 0;
  6899.                 $heightImg 0;
  6900.                 var_dump('nbr_attach ' $nbatach);
  6901.                 if ($nbatach == 1) {
  6902.                     if ($key == 0) {
  6903.                         $positionX 1.5;
  6904.                         $positionY 1.5;
  6905.                         $widthImg 18;
  6906.                         $heightImg 10;
  6907.                     } else {
  6908.                         $positionX 1.5;
  6909.                         $positionY 1.5;
  6910.                         $widthImg 8.7;
  6911.                         $heightImg 12;
  6912.                     }
  6913.                 } elseif (($nbatach == 2) && ($nbatach == '2V')) {
  6914.                     if ($ordre == 1) {
  6915.                         $positionX 1.5;
  6916.                         $positionY 1.5;
  6917.                         $widthImg 4.05;
  6918.                         $heightImg 12;
  6919.                     }
  6920.                     if ($ordre == 2) {
  6921.                         $positionX 6.15;
  6922.                         $positionY 1.5;
  6923.                         $widthImg 4.05;
  6924.                         $heightImg 12;
  6925.                     }
  6926.                 } elseif ($nbatach == '2H') {
  6927.                     if ($ordre == 1) {
  6928.                         $positionX 1.5;
  6929.                         $positionY 1.5;
  6930.                         $widthImg 8.7;
  6931.                         $heightImg 5.7;
  6932.                     }
  6933.                     if ($ordre == 2) {
  6934.                         $positionX 1.5;
  6935.                         $positionY 7.8;
  6936.                         $widthImg 8.7;
  6937.                         $heightImg 5.7;
  6938.                     }
  6939.                 } elseif (($nbatach == 3) && ($nbatach == "3V")) {
  6940.                     if ($ordre == 1) {
  6941.                         $positionX 1.5;
  6942.                         $positionY 1.5;
  6943.                         $widthImg 4.05;
  6944.                         $heightImg 12;
  6945.                     }
  6946.                     if ($ordre == 2) {
  6947.                         $positionX 6.15;
  6948.                         $positionY =  1.5;
  6949.                         $widthImg 4.05;
  6950.                         $heightImg 5.7;
  6951.                     }
  6952.                     if ($ordre == 3) {
  6953.                         $positionX =  6.15;
  6954.                         $positionY 7.8;
  6955.                         $widthImg 4.05;
  6956.                         $heightImg 5.7;
  6957.                     }
  6958.                 } elseif ($nbatach == '3H') {
  6959.                     if ($ordre == 1) {
  6960.                         $positionX 1.5;
  6961.                         $positionY 1.5;
  6962.                         $widthImg 8.7;
  6963.                         $heightImg 5.7;
  6964.                     }
  6965.                     if ($ordre == 2) {
  6966.                         $positionX 1.5;
  6967.                         $positionY 7.8;
  6968.                         $widthImg 4.05;
  6969.                         $heightImg 5.7;
  6970.                     }
  6971.                     if ($ordre == 3) {
  6972.                         $positionX 6.15;
  6973.                         $positionY 7.8;
  6974.                         $widthImg 4.05;
  6975.                         $heightImg 5.7;
  6976.                     }
  6977.                 } elseif ($nbatach == 4) {
  6978.                     if ($ordre == 1) {
  6979.                         $positionX 1.5;
  6980.                         $positionY 1.5;
  6981.                         $widthImg 4.05;
  6982.                         $heightImg 5.7;
  6983.                     }
  6984.                     if ($ordre == 2) {
  6985.                         $positionX 1.5;
  6986.                         $positionY 7.8;
  6987.                         $widthImg 4.05;
  6988.                         $heightImg 5.7;
  6989.                     }
  6990.                     if ($ordre == 3) {
  6991.                         $positionX 6.15;
  6992.                         $positionY =  1.5;
  6993.                         $widthImg 4.05;
  6994.                         $heightImg 5.7;
  6995.                     }
  6996.                     if ($ordre == 4) {
  6997.                         $positionX =  6.15;
  6998.                         $positionY 7.8;
  6999.                         $widthImg 4.05;
  7000.                         $heightImg 5.7;
  7001.                     }
  7002.                 }
  7003.                 //nop
  7004.                 elseif ($nbatach == 5) {
  7005.                     if ($ordre == 1) {
  7006.                         $positionX 1.5;
  7007.                         $positionY 1.5;
  7008.                         $widthImg 18;
  7009.                         $heightImg 8;
  7010.                     }
  7011.                     if ($ordre == 2) {
  7012.                         $positionX 1.5;
  7013.                         $positionY 10.5;
  7014.                         $widthImg 3.75;
  7015.                         $heightImg 3;
  7016.                     }
  7017.                     if ($ordre == 3) {
  7018.                         $positionX 6.25;
  7019.                         $positionY 10.5;
  7020.                         $widthImg 3.75;
  7021.                         $heightImg 3;
  7022.                     }
  7023.                     if ($ordre == 4) {
  7024.                         $positionX 11;
  7025.                         $positionY 10.5;
  7026.                         $widthImg 3.75;
  7027.                         $heightImg 3;
  7028.                     }
  7029.                     if ($ordre == 5) {
  7030.                         $positionX 15.75;
  7031.                         $positionY 10.5;
  7032.                         $widthImg 3.75;
  7033.                         $heightImg 3;
  7034.                     }
  7035.                 } elseif ($nbatach == 6) {
  7036.                     if ($ordre == 1) {
  7037.                         $positionX 1.5;
  7038.                         $positionY 1.5;
  7039.                         $widthImg 4.05;
  7040.                         $heightImg 3.6;
  7041.                     }
  7042.                     if ($ordre == 2) {
  7043.                         $positionX 1.5;
  7044.                         $positionY 5.7;
  7045.                         $widthImg 4.05;
  7046.                         $heightImg 3.6;
  7047.                     }
  7048.                     if ($ordre == 3) {
  7049.                         $positionX 1.5;
  7050.                         $positionY 9.9;
  7051.                         $widthImg 4.05;
  7052.                         $heightImg 3.6;
  7053.                     }
  7054.                     if ($ordre == 4) {
  7055.                         $positionX =  6.15;
  7056.                         $positionY 1.5;
  7057.                         $widthImg 4.05;
  7058.                         $heightImg 3.6;
  7059.                     }
  7060.                     if ($ordre == 5) {
  7061.                         $positionX =  6.15;
  7062.                         $positionY 5.7;
  7063.                         $widthImg 4.05;
  7064.                         $heightImg 3.6;
  7065.                     }
  7066.                     if ($ordre == 6) {
  7067.                         $positionX =  6.15;
  7068.                         $positionY 9.9;
  7069.                         $widthImg 4.05;
  7070.                         $heightImg 3.6;
  7071.                     }
  7072.                 }
  7073.                 //nop
  7074.                 elseif ($nbatach == 12) {
  7075.                     if ($ordre == 1) {
  7076.                         $positionX 1.5;
  7077.                         $positionY 1.5;
  7078.                         $widthImg 3.75;
  7079.                         $heightImg 3.33;
  7080.                     }
  7081.                     if ($ordre == 2) {
  7082.                         $positionX 1.5;
  7083.                         $positionY 5.83;
  7084.                         $widthImg 3.75;
  7085.                         $heightImg 3.33;
  7086.                     }
  7087.                     if ($ordre == 3) {
  7088.                         $positionX 1.5;
  7089.                         $positionY 10.16;
  7090.                         $widthImg 3.75;
  7091.                         $heightImg 3.33;
  7092.                     }
  7093.                     if ($ordre == 4) {
  7094.                         $positionX 6.25;
  7095.                         $positionY 1.5;
  7096.                         $widthImg 3.75;
  7097.                         $heightImg 3.33;
  7098.                     }
  7099.                     if ($ordre == 5) {
  7100.                         $positionX 6.25;
  7101.                         $positionY 5.83;
  7102.                         $widthImg 3.75;
  7103.                         $heightImg 3.33;
  7104.                     }
  7105.                     if ($ordre == 6) {
  7106.                         $positionX 6.25;
  7107.                         $positionY 10.16;
  7108.                         $widthImg 3.75;
  7109.                         $heightImg 3.33;
  7110.                     }
  7111.                     if ($ordre == 7) {
  7112.                         $positionX 11;
  7113.                         $positionY 1.5;
  7114.                         $widthImg 3.75;
  7115.                         $heightImg 3.33;
  7116.                     }
  7117.                     if ($ordre == 8) {
  7118.                         $positionX 11;
  7119.                         $positionY 5.83;
  7120.                         $widthImg 3.75;
  7121.                         $heightImg 3.33;
  7122.                     }
  7123.                     if ($ordre == 9) {
  7124.                         $positionX 11;
  7125.                         $positionY 10.16;
  7126.                         $widthImg 3.75;
  7127.                         $heightImg 3.33;
  7128.                     }
  7129.                     if ($ordre == 10) {
  7130.                         $positionX 15.75;
  7131.                         $positionY 1.5;
  7132.                         $widthImg 3.75;
  7133.                         $heightImg 3.33;
  7134.                     }
  7135.                     if ($ordre == 11) {
  7136.                         $positionX 15.75;
  7137.                         $positionY 5.83;
  7138.                         $widthImg 3.75;
  7139.                         $heightImg 3.33;
  7140.                     }
  7141.                     if ($ordre == 12) {
  7142.                         $positionX 15.75;
  7143.                         $positionY 10.16;
  7144.                         $widthImg 3.75;
  7145.                         $heightImg 3.33;
  7146.                     }
  7147.                 } elseif ($nbatach == 15) {
  7148.                     if ($ordre == 1) {
  7149.                         $positionX 1.5;
  7150.                         $positionY 1.5;
  7151.                         $widthImg 2.5;
  7152.                         $heightImg 1.92;
  7153.                     }
  7154.                     if ($ordre == 2) {
  7155.                         $positionX 1.5;
  7156.                         $positionY 4.2;
  7157.                         $widthImg 2.5;
  7158.                         $heightImg 1.92;
  7159.                     }
  7160.                     if ($ordre == 3) {
  7161.                         $positionX 1.5;
  7162.                         $positionY 6.54;
  7163.                         $widthImg 2.5;
  7164.                         $heightImg 1.92;
  7165.                     }
  7166.                     if ($ordre == 4) {
  7167.                         $positionX 1.5;
  7168.                         $positionY 9.06;
  7169.                         $widthImg 2.5;
  7170.                         $heightImg =  1.92;
  7171.                     }
  7172.                     if ($ordre == 5) {
  7173.                         $positionX 1.5;
  7174.                         $positionY 11.58;
  7175.                         $widthImg 2.5;
  7176.                         $heightImg =  1.92;
  7177.                     }
  7178.                     if ($ordre == 6) {
  7179.                         $positionX 4.6;
  7180.                         $positionY 1.5;
  7181.                         $widthImg 2.5;
  7182.                         $heightImg 1.92;
  7183.                     }
  7184.                     if ($ordre == 7) {
  7185.                         $positionX 4.6;
  7186.                         $positionY 4.2;
  7187.                         $widthImg 2.5;
  7188.                         $heightImg =  1.92;
  7189.                     }
  7190.                     if ($ordre == 8) {
  7191.                         $positionX 4.6;
  7192.                         $positionY 6.54;
  7193.                         $widthImg 2.5;
  7194.                         $heightImg =  1.92;
  7195.                     }
  7196.                     if ($ordre == 9) {
  7197.                         $positionX 4.6;
  7198.                         $positionY 9.06;
  7199.                         $widthImg 2.5;
  7200.                         $heightImg =  1.92;
  7201.                     }
  7202.                     if ($ordre == 10) {
  7203.                         $positionX 4.6;
  7204.                         $positionY 11.58;
  7205.                         $widthImg 2.5;
  7206.                         $heightImg =  1.92;
  7207.                     }
  7208.                     if ($ordre == 11) {
  7209.                         $positionX 7.7;
  7210.                         $positionY 1.5;
  7211.                         $widthImg 2.5;
  7212.                         $heightImg =  1.92;
  7213.                     }
  7214.                     if ($ordre == 12) {
  7215.                         $positionX 7.7;
  7216.                         $positionY 4.2;
  7217.                         $widthImg 2.5;
  7218.                         $heightImg 1.92;
  7219.                     }
  7220.                     if ($ordre == 13) {
  7221.                         $positionX 7.7;
  7222.                         $positionY 6.54;
  7223.                         $widthImg 2.5;
  7224.                         $heightImg =  1.92;
  7225.                     }
  7226.                     if ($ordre == 14) {
  7227.                         $positionX 7.7;
  7228.                         $positionY 9.06;
  7229.                         $widthImg 2.5;
  7230.                         $heightImg =  1.92;
  7231.                     }
  7232.                     if ($ordre == 15) {
  7233.                         $positionX 7.7;
  7234.                         $positionY 11.58;
  7235.                         $widthImg 2.5;
  7236.                         $heightImg =  1.92;
  7237.                     }
  7238.                 }
  7239.                 if (($i == sizeof($tabphoto) - 1) && ($key != 0)) {
  7240.                     $path 'https://demo.appsfactor.fr/' $path;
  7241.                     $positionX 10.8;
  7242.                     $positionY 1.5;
  7243.                     $widthImg 8.7;
  7244.                     $heightImg 12;
  7245.                     $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  7246.                 } else {
  7247.                     //Recarder l'image :
  7248.                     // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  7249.                     //                $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);
  7250.                     $pathArray explode("/"$path);
  7251.                     $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  7252.                     $idImage "";
  7253.                     foreach ($idsArray as $key2 => $elem) {
  7254.                         if ($key2 != (sizeof($idsArray) - 1)) {
  7255.                             $idImage $idImage $elem;
  7256.                         }
  7257.                     }
  7258.                     //   $cloudinaryWidht=$widthOriginal;
  7259.                     // $cloudinaryHeight=$widthOriginal;
  7260.                     $idImage 'newprod/' $idImage;
  7261.                     //var_dump($idImage);
  7262.                     Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  7263.                     $headers = array('Accept' => 'application/json');
  7264.                     $data = array("public_ids" => array($idImage));
  7265.                     $body Unirest\Request\Body::form($data);
  7266.                     Unirest\Request::verifyPeer(false);
  7267.                     $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  7268.                     // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  7269.                     //  var_dump($url);
  7270.                     $resultMetadata Unirest\Request::post($url$headers$body);
  7271.                     var_dump($resultMetadata);
  7272.                     if (isset(json_decode($resultMetadata->raw_body)->width)) {
  7273.                         $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  7274.                         $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  7275.                     } else {
  7276.                         $cloudinaryWidht $widthOriginal;
  7277.                         $cloudinaryHeight $heightOriginal;
  7278.                     }
  7279.                     $ratiohight $cloudinaryWidht $widthOriginal;
  7280.                     $ratioHight $cloudinaryHeight $heightOriginal;
  7281.                     //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  7282.                     //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  7283.                     var_dump($cloudinaryWidht);
  7284.                     var_dump($cloudinaryHeight);
  7285.                     var_dump($ratioHight);
  7286.                     var_dump($zoom);
  7287.                     $zoom 1;
  7288.                     var_dump($leftOriginal);
  7289.                     var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  7290.                     var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  7291.                     var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  7292.                     var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  7293.                     //var_dump($path);i
  7294.                     $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);
  7295.                     //var_dump($path);i
  7296.                     //                $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);
  7297.                     //var_dump($path);
  7298.                     $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  7299.                     //  var_dump("//00");
  7300.                     //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  7301.                     //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  7302.                     //    var_dump("//00");
  7303.                     //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  7304.                     //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  7305.                     var_dump($zoom);
  7306.                     var_dump($path);
  7307.                     // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  7308.                     $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  7309.                     //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  7310.                     //
  7311.                 }
  7312.             }
  7313.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  7314.             for ($i 0$i sizeof($tabtxt); $i++) {
  7315.                 $txt json_decode($tabtxt[$i]);
  7316.                 $fontSize floatval(str_replace('px'''$txt->fontSize)) * 0.75;
  7317.                 //$txt->rotation
  7318.                 $check explode(','$txt->fontFamily);
  7319.                 if (sizeof($check) > 1) {
  7320.                     //default
  7321.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 400)) {
  7322.                         $finalFont "helvetica";
  7323.                         $weight '';
  7324.                     }
  7325.                     //classique
  7326.                     if (($check[0] == "Georgia") && ($txt->fontWeight == 400)) {
  7327.                         $finalFont "times";
  7328.                         $weight '';
  7329.                     }
  7330.                     //creative
  7331.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 700)) {
  7332.                         $finalFont "helveticaB";
  7333.                         $weight '';
  7334.                     }
  7335.                     // manuscrite
  7336.                     if (($check[0] == "Comic Sans") && ($txt->fontWeight == 400)) {
  7337.                         $finalFont "Courier";
  7338.                         $weight '';
  7339.                     }
  7340.                     //c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff2
  7341.                 } else {
  7342.                     //baton
  7343.                     if (($txt->fontFamily == 'Impact') && ($txt->fontWeight == 400)) {
  7344.                         $finalFont "helveticaB";
  7345.                         $weight 'B';
  7346.                     }
  7347.                 }
  7348.                 $pdf->SetFont($finalFont$weight$fontSize);
  7349.                 $leftTxt $txt->left;
  7350.                 $topTxt $txt->top;
  7351.                 $heightClips $txt->height;
  7352.                 $widthClips $txt->width;
  7353.                 $heightTxt floatval(str_replace('cm'''$heightClips));
  7354.                 $topTxt floatval(str_replace('cm'''$topTxt));
  7355.                 $leftTxt floatval(str_replace('cm'''$leftTxt));
  7356.                 $widthTxt floatval(str_replace('cm'''$widthClips));
  7357.                 if ($key == 0) {
  7358.                     $heightTxt 2;
  7359.                     $widthTxt 7;
  7360.                     $leftTxt = (21) - ($widthTxt 2);
  7361.                     $topTxt 11.8;
  7362.                     $pdf->SetXY(0$topTxttrue);
  7363.                     $pdf->Cell(210trim($txt->contenu), 00'C'0''0);
  7364.                 } else {
  7365.                     $heightTxt 2;
  7366.                     $widthTxt 7;
  7367.                     $leftTxt = (21) - ($widthTxt 2);
  7368.                     $topTxt 11.8;
  7369.                     $pdf->SetXY(13.612.4true);
  7370.                     $pdf->Cell(60trim($txt->contenu), 00'L'0''0);
  7371.                 }
  7372.                 //                    var_dump($leftTxt);
  7373.                 //                  var_dump($topTxt);
  7374.                 // var_dump(floatval(str_replace('rad','',$txt->rotation))*57,2958);
  7375.                 //                var_dump("text");
  7376.                 //$pdf->StartTransform();
  7377.                 //$txt->rotation=0;
  7378.                 //var_dump($txt->rotation);
  7379.                 //var_dump(str_replace('rad','',$txt->rotation));
  7380.                 //var_dump(floatval(str_replace('rad','',$txt->rotation))*57.2958);
  7381.                 // $pdf->Rotate((floatval(str_replace('rad','',$txt->rotation))*57.2958)*-1,$leftTxt+($widthTxt/2),$topTxt+($heightTxt/2));
  7382.                 // $pdf->Rotate(45);
  7383.                 //   $pdf->Text($leftTxt, $topTxt, $txt->contenu);
  7384.                 //$pdf->SetTextColor(200);
  7385.                 //$pdf->Text($leftTxt, $topTxt, $txt->contenu);
  7386.                 // $pdf->MultiCell($leftTxt, $topTxt,  $txt->contenu, 0, $ln=0, 'C', 0, '', 0, false, 'C', 'C');
  7387.                 //                $pdf->Write(str_replace('cm','',$txt->height),trim($txt->contenu));
  7388.                 // $pdf->writeHTML("<p>".$txt->contenu."</p>", true, false, false, false, '');
  7389.                 //$pdf->StopTransform();
  7390.             }
  7391.             //Positionner text
  7392.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  7393.             //Positionner clipart
  7394.             //            dd($tabClips);
  7395.             for ($i 0$i sizeof($tabClips); $i++) {
  7396.                 $Clips json_decode($tabClips[$i]);
  7397.                 $heightClips $Clips->height;
  7398.                 $topClips $Clips->top;
  7399.                 $leftClips $Clips->left;
  7400.                 $widthClips $Clips->width;
  7401.                 $path $Clips->path;
  7402.                 $pathClips str_replace('"'''$path);
  7403.                 $heightClips floatval(str_replace('cm'''$heightClips));
  7404.                 $topClips floatval(str_replace('cm'''$topClips));
  7405.                 $leftClips floatval(str_replace('cm'''$leftClips));
  7406.                 $widthClips floatval(str_replace('cm'''$widthClips));
  7407.                 $heightClipsPX round($heightClips 37.7952755906);
  7408.                 $widthClipsPX round($widthClips 37.7952755906);
  7409.                 ////                $positionXclips = $positionX + $leftClips;
  7410.                 ////                $positionYclips = $positionY + $topClips;
  7411.                 //
  7412.                 //$pdf->ImageSVG("images/ClipArt_SVG/Ete4.svg",$leftClips,$topClips,$widthClips, $heightClips);
  7413.                 //https://res.cloudinary.com/apss-factory/image/private/s--EdExAzx8--/v1588758453/GlobeFooter_c4duua.svg
  7414.                 // https://res.cloudinary.com/apss-factory/image/upload/v1588764528/Groupe_113_pcjyj4.png
  7415.                 var_dump($pathClips);
  7416.                 $pdf->StartTransform();
  7417.                 $pdf->Rotate((floatval(str_replace('rad'''$Clips->rotation)) * 57.2958) * -1$leftClips + ($widthClips 2), $topClips + ($heightClips 2));
  7418.                 $pdf->Image($this->newPAthCLipart($pathClips$heightClipsPX$widthClipsPX), $leftClips,  $topClips$widthClips$heightClips''''''false300);
  7419.                 $pdf->StopTransform();
  7420.             }
  7421.         }
  7422.         // echo '</pre>';
  7423.         //return new response("yezi");
  7424.         $projectRoot $this->getParameter('kernel.project_dir');
  7425.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  7426.         return new response("yezi");
  7427.         //return $pdf->Output('example_009.pdf', 'I');
  7428.     }
  7429.     function newPAthCLipart($url$heigh$width)
  7430.     {
  7431.         $allImage = [
  7432.             'Eclaire.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143379/newprod/clipart/Eclaire_pr0ecu.png',
  7433.             'ARcenciel.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143391/newprod/clipart/ARcenciel_grkyap.png',
  7434.             'Drapeaux.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Drapeaux_zqo8v3.png',
  7435.             'Annif.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143391/newprod/clipart/Annif_ihvyoo.png',
  7436.             'Basquettes.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Basquettes_znjd41.png',
  7437.             'Foot.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143382/newprod/clipart/Foot_az6bct.png',
  7438.             'Hello.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143383/newprod/clipart/Hello_njqifl.png',
  7439.             'Love.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143386/newprod/clipart/Love_q39usk.png',
  7440.             'LICORNE.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143385/newprod/clipart/LICORNE_hpomru.png',
  7441.             'Noeud.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143388/newprod/clipart/Noeud_mw5a4j.png',
  7442.             'Etoilerose.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143380/newprod/clipart/Etoilerose_ewrzff.png',
  7443.             'Ete4.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143379/newprod/clipart/Ete4_pdxadk.png',
  7444.             'Ete6.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143380/newprod/clipart/Ete6_a3xgpd.png',
  7445.             'Ete9.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143380/newprod/clipart/Ete9_s4vllm.png',
  7446.             'Hiver1.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143384/newprod/clipart/Hiver1_fekrjz.png',
  7447.             'Hiver2.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143384/newprod/clipart/Hiver2_e9iygg.png',
  7448.             'Noel2.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143387/newprod/clipart/Noel2_eqvdzr.png',
  7449.             'Hiver.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143383/newprod/clipart/Hiver_et04e1.png',
  7450.             'Sapin.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143390/newprod/clipart/Sapin_qjkxz6.png',
  7451.             'Chaussetet.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Chaussetet_xfpt6t.png',
  7452.             'Cloches.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Cloches_x2v3eo.png',
  7453.             'Like.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143387/newprod/clipart/Like_ynxb2u.png',
  7454.             'coeurlike.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143379/newprod/clipart/coeurlike_ferv9y.png',
  7455.             'Fetedesmeres.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/w_' $width '/upload/v1589143383/newprod/clipart/Fetedesmeres_ud9vac.png',
  7456.             'Fetedesperes.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/w_' $width '/upload/v1589143384/newprod/clipart/Fetedesperes_mltjmo.png',
  7457.             'OOPS.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143389/newprod/clipart/OOPS_gj9p1c.png',
  7458.             'OOPS_1.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143389/newprod/clipart/OOPS_1_r9a7l6.png',
  7459.             'WoW.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143393/newprod/clipart/WoW_ljlqjm.png',
  7460.             'Nuage.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143387/newprod/clipart/Nuage_fgomd0.png',
  7461.             'Pingouin.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143389/newprod/clipart/Pingouin_ogxb6e.png',
  7462.             'Renard.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143378/newprod/clipart/Chouette_mc1ik2.png',
  7463.             'Chouette.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143390/newprod/clipart/Renard_mlhrxt.png'
  7464.         ];
  7465.         //http://127.0.0.1:8000/images/ClipArt_SVG/LICORNE.svg
  7466.         $arryUrls explode('/'$url);
  7467.         return ($allImage[$arryUrls[sizeof($arryUrls) - 1]]);
  7468.     }
  7469.     /**
  7470.      * @Route("/Parent/TcPdfCalcul/{idPrdt}", name="TcPdfCalc")
  7471.      */
  7472.     public function TcPdfCalcule($idPrdt)
  7473.     {
  7474.         echo '<pre>';
  7475.         ini_set("max_execution_time", -1);
  7476.         $pageLayout = array(2115);
  7477.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  7478.         // set document information
  7479.         $pdf->SetCreator(PDF_CREATOR);
  7480.         $pdf->SetAuthor('Nicola Asuni');
  7481.         $pdf->SetTitle('TCPDF Example 009');
  7482.         $pdf->SetSubject('TCPDF Tutorial');
  7483.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  7484.         $pdf->SetSubject('TCPDF Tutorial');
  7485.         $pdf->setPrintHeader(false);
  7486.         $pdf->setPrintFooter(false);
  7487.         // set image scale factor
  7488.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  7489.         //        $pdf->AddPage();
  7490.         $pdf->setJPEGQuality(100);
  7491.         $horizontal_alignments = array('L''C''R');
  7492.         $vertical_alignments = array('T''M''B');
  7493.         //var_dump($pdf->getPageWidth());
  7494.         //var_dump($pdf->getPageHeight());die();
  7495.         $em $this->em;
  7496.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  7497.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  7498.         //dd($AllPages);
  7499.         //        $fP=[];
  7500.         //        array_push($fP,$AllPages[0]);
  7501.         //dd($AllPages);
  7502.         foreach ($AllPages as $p) {
  7503.             $pdf->AddPage();
  7504.             $pdf->setJPEGQuality(100);
  7505.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  7506.             $nbatach $contenu->nbrAttc;
  7507.             $nbatach intval(str_replace('"'''$nbatach));
  7508.             $color =  $contenu->color;
  7509.             // $color="rgb(255,255,255)";
  7510.             $color str_replace('"rgb('''$color);
  7511.             $color str_replace(')"'''$color);
  7512.             $color explode(","$color);
  7513.             $colorp = array(intval($color[0]), intval($color[1]), intval($color[2]));
  7514.             $tabtxt json_decode($contenu->txt);
  7515.             $tabphoto json_decode($contenu->attache);
  7516.             //
  7517.             //dd($tabtxt);
  7518.             //         dd($tabtxt);
  7519.             //dd($tabphoto);
  7520.             $tabClips json_decode($contenu->clips);
  7521.             // dd($tabClips);
  7522.             $x 0.6;
  7523.             $y 0.8;
  7524.             $w 19.8;
  7525.             $h 13.4;
  7526.             // get the current page break margin
  7527.             $bMargin $pdf->getBreakMargin();
  7528.             // get current auto-page-break mode
  7529.             $auto_page_break $pdf->getAutoPageBreak();
  7530.             // disable auto-page-break
  7531.             $pdf->SetAutoPageBreak(false0);
  7532.             // test all combinations of alignments
  7533.             $fitbox $horizontal_alignments[1] . ' ';
  7534.             $fitbox[1] = $vertical_alignments[1];
  7535.             $pdf->Rect(002115'F', array(), $colorp);
  7536.             //    sizeof($tabphoto)
  7537.             for ($i 0$i sizeof($tabphoto); $i++) {
  7538.                 $photo json_decode($tabphoto[$i]);
  7539.                 //les coordonnées de l'image réel:
  7540.                 $hght $photo->height;
  7541.                 $top $photo->top;
  7542.                 $left $photo->left;
  7543.                 $width $photo->width;
  7544.                 $ordre $photo->ordre;
  7545.                 $zoom $photo->zoom;
  7546.                 $path $photo->path;
  7547.                 $hght floatval(str_replace('cm'''$hght));
  7548.                 $top floatval(str_replace('cm'''$top));
  7549.                 $left floatval(str_replace('cm'''$left));
  7550.                 $width floatval(str_replace('cm'''$width));
  7551.                 //les coordonnées dropzone:
  7552.                 $heightOriginal $photo->height;
  7553.                 $widthOriginal $photo->width;
  7554.                 $top $photo->top;
  7555.                 $left $photo->left;
  7556.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  7557.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  7558.                 $top floatval(str_replace('cm'''$top));
  7559.                 $left floatval(str_replace('cm'''$left));
  7560.                 $heightOriginal $heightOriginal 37.7952755906;
  7561.                 $widthOriginal $widthOriginal 37.7952755906;
  7562.                 $topOriginal $top 37.7952755906;
  7563.                 $leftOriginal $left 37.7952755906;
  7564.                 $heightCrop $photo->heightCrop;
  7565.                 $topCrop $photo->topCrop;
  7566.                 $leftCrop $photo->leftCrop;
  7567.                 $widthCrop $photo->widthCrop;
  7568.                 $path $photo->path;
  7569.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  7570.                 $topCrop floatval(str_replace('cm'''$topCrop));
  7571.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  7572.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  7573.                 $widthCropPX $widthCrop 37.7952755906;
  7574.                 $heightCropPX $heightCrop 37.7952755906;
  7575.                 $topCropPX $topCrop 37.7952755906;
  7576.                 $leftCropPX $leftCrop 37.7952755906;
  7577.                 var_dump("original widh: " $widthCrop " " "original height : " $heightCrop);
  7578.                 var_dump("original left: " $topCrop " " "original top : " $leftCrop);
  7579.                 var_dump("//00");
  7580.                 var_dump("multip 37 widh: " $widthCropPX " " "multip 37 height : " $heightCropPX);
  7581.                 var_dump("multip 37 top: " $topOriginal " " "multip 37 left : " $leftOriginal);
  7582.                 //Calculer position des images selon nombres images par page:
  7583.                 $positionX 0;
  7584.                 $positionY 0;
  7585.                 $widthImg 0;
  7586.                 $heightImg 0;
  7587.                 if ($nbatach == 1) {
  7588.                     $positionX 1.5;
  7589.                     $positionY 1.5;
  7590.                     $widthImg 18;
  7591.                     $heightImg 12;
  7592.                 } elseif ($nbatach == 2) {
  7593.                     if ($ordre == 1) {
  7594.                         $positionX 1.5;
  7595.                         $positionY 1.5;
  7596.                         $widthImg 8.5;
  7597.                         $heightImg 12;
  7598.                     }
  7599.                     if ($ordre == 2) {
  7600.                         $positionX 11;
  7601.                         $positionY 1.5;
  7602.                         $widthImg 8.5;
  7603.                         $heightImg 12;
  7604.                     }
  7605.                 } elseif ($nbatach == 3) {
  7606.                     if ($ordre == 1) {
  7607.                         $positionX 1.5;
  7608.                         $positionY 1.5;
  7609.                         $widthImg 8.5;
  7610.                         $heightImg 12;
  7611.                     }
  7612.                     if ($ordre == 2) {
  7613.                         $positionX 11;
  7614.                         $positionY 1.5;
  7615.                         $widthImg 8.5;
  7616.                         $heightImg 5.5;
  7617.                     }
  7618.                     if ($ordre == 3) {
  7619.                         $positionX 11;
  7620.                         $positionY 8;
  7621.                         $widthImg 8.5;
  7622.                         $heightImg 5.5;
  7623.                     }
  7624.                 } elseif ($nbatach == 4) {
  7625.                     if ($ordre == 1) {
  7626.                         $positionX 1.5;
  7627.                         $positionY 1.5;
  7628.                         $widthImg 8.5;
  7629.                         $heightImg 5.5;
  7630.                     }
  7631.                     if ($ordre == 2) {
  7632.                         $positionX 1.5;
  7633.                         $positionY 8;
  7634.                         $widthImg 8.5;
  7635.                         $heightImg 5.5;
  7636.                     }
  7637.                     if ($ordre == 3) {
  7638.                         $positionX 11;
  7639.                         $positionY 1.5;
  7640.                         $widthImg 8.5;
  7641.                         $heightImg 5.5;
  7642.                     }
  7643.                     if ($ordre == 4) {
  7644.                         $positionX 11;
  7645.                         $positionY 8;
  7646.                         $widthImg 8.5;
  7647.                         $heightImg 5.5;
  7648.                     }
  7649.                 } elseif ($nbatach == 5) {
  7650.                     if ($ordre == 1) {
  7651.                         $positionX 1.5;
  7652.                         $positionY 1.5;
  7653.                         $widthImg 18;
  7654.                         $heightImg 8;
  7655.                     }
  7656.                     if ($ordre == 2) {
  7657.                         $positionX 1.5;
  7658.                         $positionY 10.5;
  7659.                         $widthImg 3.75;
  7660.                         $heightImg 4;
  7661.                     }
  7662.                     if ($ordre == 3) {
  7663.                         $positionX 6.25;
  7664.                         $positionY 10.5;
  7665.                         $widthImg 3.75;
  7666.                         $heightImg 4;
  7667.                     }
  7668.                     if ($ordre == 4) {
  7669.                         $positionX 11;
  7670.                         $positionY 10.5;
  7671.                         $widthImg 3.75;
  7672.                         $heightImg 4;
  7673.                     }
  7674.                     if ($ordre == 5) {
  7675.                         $positionX 15.75;
  7676.                         $positionY 10.5;
  7677.                         $widthImg 3.75;
  7678.                         $heightImg 4;
  7679.                     }
  7680.                 } elseif ($nbatach == 6) {
  7681.                     if ($ordre == 1) {
  7682.                         $positionX 1.5;
  7683.                         $positionY 1.5;
  7684.                         $widthImg 5.33;
  7685.                         $heightImg 3.33;
  7686.                     }
  7687.                     if ($ordre == 2) {
  7688.                         $positionX 1.5;
  7689.                         $positionY 5.83;
  7690.                         $widthImg == 5.33;
  7691.                         $heightImg 3.33;
  7692.                     }
  7693.                     if ($ordre == 3) {
  7694.                         $positionX 1.5;
  7695.                         $positionY 10.16;
  7696.                         $widthImg 5.33;
  7697.                         $heightImg 3.33;
  7698.                     }
  7699.                     if ($ordre == 4) {
  7700.                         $positionX 7.83;
  7701.                         $positionY 1.5;
  7702.                         $widthImg == 5.33;
  7703.                         $heightImg 3.33;
  7704.                     }
  7705.                     if ($ordre == 5) {
  7706.                         $positionX 7.83;
  7707.                         $positionY 5.83;
  7708.                         $widthImg == 5.33;
  7709.                         $heightImg 3.33;
  7710.                     }
  7711.                     if ($ordre == 6) {
  7712.                         $positionX 7.83;
  7713.                         $positionY 10.16;
  7714.                         $widthImg == 5.33;
  7715.                         $heightImg 3.33;
  7716.                     }
  7717.                 } elseif ($nbatach == 12) {
  7718.                     if ($ordre == 1) {
  7719.                         $positionX 1.5;
  7720.                         $positionY 1.5;
  7721.                         $widthImg 3.75;
  7722.                         $heightImg 3.33;
  7723.                     }
  7724.                     if ($ordre == 2) {
  7725.                         $positionX 1.5;
  7726.                         $positionY 5.83;
  7727.                         $widthImg 3.75;
  7728.                         $heightImg 3.33;
  7729.                     }
  7730.                     if ($ordre == 3) {
  7731.                         $positionX 1.5;
  7732.                         $positionY 10.16;
  7733.                         $widthImg 3.75;
  7734.                         $heightImg 3.33;
  7735.                     }
  7736.                     if ($ordre == 4) {
  7737.                         $positionX 6.25;
  7738.                         $positionY 1.5;
  7739.                         $widthImg 3.75;
  7740.                         $heightImg 3.33;
  7741.                     }
  7742.                     if ($ordre == 5) {
  7743.                         $positionX 6.25;
  7744.                         $positionY 5.83;
  7745.                         $widthImg 3.75;
  7746.                         $heightImg 3.33;
  7747.                     }
  7748.                     if ($ordre == 6) {
  7749.                         $positionX 6.25;
  7750.                         $positionY 10.16;
  7751.                         $widthImg 3.75;
  7752.                         $heightImg 3.33;
  7753.                     }
  7754.                     if ($ordre == 7) {
  7755.                         $positionX 11;
  7756.                         $positionY 1.5;
  7757.                         $widthImg 3.75;
  7758.                         $heightImg 3.33;
  7759.                     }
  7760.                     if ($ordre == 8) {
  7761.                         $positionX 11;
  7762.                         $positionY 5.83;
  7763.                         $widthImg 3.75;
  7764.                         $heightImg 3.33;
  7765.                     }
  7766.                     if ($ordre == 9) {
  7767.                         $positionX 11;
  7768.                         $positionY 10.16;
  7769.                         $widthImg 3.75;
  7770.                         $heightImg 3.33;
  7771.                     }
  7772.                     if ($ordre == 10) {
  7773.                         $positionX 15.75;
  7774.                         $positionY 1.5;
  7775.                         $widthImg 3.75;
  7776.                         $heightImg 3.33;
  7777.                     }
  7778.                     if ($ordre == 11) {
  7779.                         $positionX 15.75;
  7780.                         $positionY 5.83;
  7781.                         $widthImg 3.75;
  7782.                         $heightImg 3.33;
  7783.                     }
  7784.                     if ($ordre == 12) {
  7785.                         $positionX 15.75;
  7786.                         $positionY 10.16;
  7787.                         $widthImg 3.75;
  7788.                         $heightImg 3.33;
  7789.                     }
  7790.                 }
  7791.                 //Recarder l'image :
  7792.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  7793.                 //                $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);
  7794.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  7795.                 //var_dump($api);
  7796.                 $pathArray explode("/"$path);
  7797.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  7798.                 $idImage "";
  7799.                 foreach ($idsArray as $key2 => $elem) {
  7800.                     if ($key2 != (sizeof($idsArray) - 1)) {
  7801.                         $idImage $idImage $elem;
  7802.                     }
  7803.                 }
  7804.                 $idImage 'newprod/' $idImage;
  7805.                 var_dump($idImage);
  7806.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  7807.                 $headers = array('Accept' => 'application/json');
  7808.                 $data = array("public_ids" => array($idImage));
  7809.                 $body Unirest\Request\Body::form($data);
  7810.                 Unirest\Request::verifyPeer(false);
  7811.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  7812.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  7813.                 var_dump($url);
  7814.                 $resultMetadata Unirest\Request::post($url$headers$body);
  7815.                 var_dump($resultMetadata->raw_body);
  7816.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  7817.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  7818.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  7819.                 } else {
  7820.                     $cloudinaryWidht $widthOriginal;
  7821.                     $cloudinaryHeight $heightOriginal;
  7822.                 }
  7823.                 $ratiohight $cloudinaryWidht $widthOriginal;
  7824.                 $ratioHight $cloudinaryHeight $heightOriginal;
  7825.                 $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);
  7826.                 //var_dump($path);i
  7827.                 var_dump("//00");
  7828.                 var_dump("avant 1.4 widh: " round($widthCropPX) . " " "avant 1.4 height : " round($heightCropPX));
  7829.                 var_dump("avant 1.4 top: " round(abs($top 37.7952755906)) . " avant 1.4 final left : " round(abs($left 37.7952755906)));
  7830.                 var_dump("//00");
  7831.                 var_dump("final widh: " round($widthCropPX 1.4) . " " "final height : " round($heightCropPX 1.4));
  7832.                 var_dump("final top: " round(abs($top 37.7952755906 1.4)) . " " "final left : " round(abs($left 37.7952755906 1.4)));
  7833.                 var_dump("//00");
  7834.                 var_dump($path);
  7835.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  7836.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false300''falsefalse0$fitboxfalsefalse);
  7837.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  7838.                 //
  7839.                 $pdf->SetY(-6);
  7840.                 // Set font
  7841.                 $pdf->SetFont('helvetica''I'8);
  7842.                 // Page number
  7843.                 $pdf->Cell(010'Page ' $pdf->getAliasNumPage() . '/' $pdf->getAliasNbPages(), 0false'C'0''0false'T''M');
  7844.                 $pdf->SetFont('helvetica''B'8);
  7845.                 $pdf->SetXY(11);
  7846.             }
  7847.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  7848.             for ($i 0$i sizeof($tabtxt); $i++) {
  7849.                 $txt json_decode($tabtxt[$i]);
  7850.                 $pdf->SetFont('helvetica''B'$txt->fontSize);
  7851.                 $leftTxt $txt->left;
  7852.                 $topTxt $txt->top;
  7853.                 //                $heightClips = floatval(str_replace('cm', '', $heightClips));
  7854.                 $topTxt floatval(str_replace('cm'''$topTxt));
  7855.                 $leftTxt floatval(str_replace('cm'''$leftTxt));
  7856.                 //                $widthClips = floatval(str_replace('cm', '', $widthClips));
  7857.                 $pdf->SetXY($leftTxt 1.2$topTxt 1);
  7858.                 $pdf->Write(0$txt->contenu''0'L'true0falsefalse0);
  7859.             }
  7860.             //Positionner text
  7861.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  7862.             //Positionner clipart
  7863.             //            dd($tabClips);
  7864.             //            for($i=0;$i <sizeof($tabClips);$i++) {
  7865.             //                $Clips = json_decode($tabClips[$i]);
  7866.             //                $heightClips = $Clips->height;
  7867.             //                $topClips = $Clips->top;
  7868.             //                $leftClips = $Clips->left;
  7869.             //                $widthClips = $Clips->width;
  7870.             //                $path = $Clips->path;
  7871.             //                $pathClips = str_replace('http://127.0.0.1:8000/', 'https://demo.appsfactor.fr/', $path);
  7872.             //
  7873.             //                $heightClips = floatval(str_replace('cm', '', $heightClips));
  7874.             //                $topClips = floatval(str_replace('cm', '', $topClips));
  7875.             //                $leftClips = floatval(str_replace('cm', '', $leftClips));
  7876.             //                $widthClips = floatval(str_replace('cm', '', $widthClips));
  7877.             //
  7878.             ////                $positionXclips = $positionX + $leftClips;
  7879.             ////                $positionYclips = $positionY + $topClips;
  7880.             //
  7881.             //              $pdf->ImageSVG("images/ClipArt_SVG/Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  7882.             //
  7883.             ////                $pdf->Image($path,$leftClips,  $topClips, $widthClips, $heightClips, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  7884.             //
  7885.             //            }
  7886.         }
  7887.         echo '</pre>';
  7888.         return new response("yezi");
  7889.         //  return $pdf->Output('example_009.pdf', 'I');
  7890.     }
  7891.     /**
  7892.      * @Route("/Parent/suprimerproduitAcompa", name="suprimerproduitAcompa_parent")
  7893.      */
  7894.     public function suprimerproduitAcompa(Request $request)
  7895.     {
  7896.         $em $this->em;
  7897.         $user $this->getUser();
  7898.         $p $request->get("p");
  7899.         $Album $em->getRepository(Produit::class)->find($p);
  7900.         $Album->setDelated(1);
  7901.         $em->getManager()->persist($Album);
  7902.         $em->getManager()->flush();
  7903.         return new Response('yoopi');
  7904.     }
  7905.     /**
  7906.      * @Route("/Parent/saveDiaporamaParent", name="saveDiaporamaParent")
  7907.      */
  7908.     public function saveDiaporamaParent()
  7909.     {
  7910.         $session $this->session;
  7911.         $idSejour $session->get("Sejour");
  7912.         /** @var \App\Entity\User $userId */
  7913.         $userId $this->getUser();
  7914.         $sejourobj $this->em->getRepository(Sejour::class)->find($idSejour);
  7915.         $prodct $this->em->getRepository(Typeproduit::class)->find(19);
  7916.         $produit $this->em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $userId->getId()]);
  7917.         if ($produit !== null && $produit !== "") {
  7918.             $produit->setLabele("Diaporama");
  7919.             $produit->setIduser($userId);
  7920.             $produit->setIdsjour($sejourobj);
  7921.             $produit->setType($prodct);
  7922.         } else {
  7923.             $produit = new Produit;
  7924.             $produit->setLabele("Diaporama");
  7925.             $produit->setIduser($userId);
  7926.             $produit->setIdsjour($sejourobj);
  7927.             $produit->setType($prodct);
  7928.             $produit->setDate(new \DateTime());
  7929.         }
  7930.         $this->em->getManager()->persist($produit);
  7931.         $this->em->getManager()->flush();
  7932.         return new Response('disporama saved');
  7933.     }
  7934.     /**
  7935.      * @Route("/Parent/appActiveAcompt/{id}", name="appActiveAcompt")
  7936.      */
  7937.     public function ActiveAcounnt($id)
  7938.     {
  7939.         $user $this->em->getRepository(User::class)->find($id);
  7940.         $user->setActivatemail(1);
  7941.         $this->em->getManager()->persist($user);
  7942.         $this->em->getManager()->flush();
  7943.         // AUTO-LOGIN DIRECT (même implémentation que les accompagnateurs)
  7944.         $providerKey 'main_Parent'// your firewall name
  7945.         $token = new UsernamePasswordToken($usernull$providerKey$user->getRoles());
  7946.         $this->container->get('security.token_storage')->setToken($token);
  7947.         return $this->redirectToRoute('CodeSejour');
  7948.     }
  7949.     /**
  7950.      * @Route("/Parent/Album_du_Sejour", name="Album_du_Sejour")
  7951.      */
  7952.     function ActiverSessionAlbum()
  7953.     {
  7954.         $SEjourService $this->sejourService;
  7955.         /** @var \App\Entity\User $user */
  7956.         $user $this->getUser();
  7957.         $userId $user->getId();
  7958.         $session $this->session;
  7959.         $session->set('pageMenu''');
  7960.         $idSejour $session->get("Sejour");
  7961.         $sejour $SEjourService->getsejourpourparent($idSejour);
  7962.         $em $this->em;
  7963.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['statut' => 'Album_sejour''idsjour' => $sejour], ['id' => 'DESC']);
  7964.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  7965.         $nbLikes count($listeattachlikephoto);
  7966.         if ($Albumproduct === null) {
  7967.             $this->addFlash('warning''Aucun album du séjour n\'est disponible pour l\'instant.');
  7968.             return $this->redirectToRoute('CodeSejour');
  7969.         }
  7970.         $session->set('produit'$Albumproduct->getType());
  7971.         // Check if the parent already has a saved album for this sejour
  7972.         $parentAlbum $em->getRepository(Produit::class)->findOneBy([
  7973.             'iduser' => $userId,
  7974.             'idsjour' => $sejour,
  7975.             'statut' => 'saved',
  7976.         ], ['id' => 'DESC']);
  7977.         $existingAlbumData null;
  7978.         $userAlbumId null;
  7979.         if ($parentAlbum && $parentAlbum->getPathpdf()) {
  7980.             $decodedData json_decode($parentAlbum->getPathpdf(), true);
  7981.             if ($decodedData && isset($decodedData['pages'])) {
  7982.                 $existingAlbumData $decodedData;
  7983.                 $userAlbumId $parentAlbum->getId();
  7984.             }
  7985.         }
  7986.         $part $sejour->getIdPartenaire();
  7987.         $partnerName $part $part->getUsername() : '';
  7988.         $partnerLogo $part $part->getLogourl() : null;
  7989.         $sejourId = (int) $idSejour;
  7990.         $likedPhotosFormatted = [];
  7991.         foreach ($listeattachlikephoto as $likePhoto) {
  7992.             $sejourAttach $likePhoto->getIdSejourAttchment();
  7993.             if ($sejourAttach) {
  7994.                 $realAttachment $sejourAttach->getIdAttchment();
  7995.                 if ($realAttachment) {
  7996.                     $likedPhotosFormatted[] = [
  7997.                         'id' => $realAttachment->getId(),
  7998.                         'path' => $realAttachment->getPath(),
  7999.                         'nom' => $realAttachment->getDescreption() ?? 'Photo',
  8000.                     ];
  8001.                 }
  8002.             }
  8003.         }
  8004.         $prixAlbum '14,90';
  8005.         if ($Albumproduct->getIdConditionnement()) {
  8006.             $ttc $Albumproduct->getIdConditionnement()->getMontantTTC();
  8007.             if ($ttc !== null) {
  8008.                 $prixAlbum number_format((float) $ttc2','' ');
  8009.             }
  8010.         }
  8011.         // Photos groupées par jour (même logique que l'admin album builder)
  8012.         $conn $em->getConnection();
  8013.         $sql "SELECT sa.id AS sejour_attachment_id, a.path, a.descreption,
  8014.                        DATE(sa.date_depot_attachement) AS photo_date
  8015.                 FROM sejour_attachment sa
  8016.                 JOIN attachment a ON sa.id_attchment = a.id
  8017.                 JOIN ref r ON a.idref = r.id
  8018.                 WHERE sa.id_sejour = :sejourId
  8019.                   AND sa.statut = 'public'
  8020.                   AND r.libiller = 'photo'
  8021.                 ORDER BY sa.date_depot_attachement ASC";
  8022.         $stmt $conn->prepare($sql);
  8023.         $rows $stmt->executeQuery(['sejourId' => $idSejour])->fetchAllAssociative();
  8024.         $dayDescriptions = [];
  8025.         foreach ($sejour->getJourdescripdate() as $jourDesc) {
  8026.             if ($jourDesc->getDatejourphoto()) {
  8027.                 $dateKey $jourDesc->getDatejourphoto()->format('Y-m-d');
  8028.                 $dayDescriptions[$dateKey] = $jourDesc->getDescription();
  8029.             }
  8030.         }
  8031.         $photosByDayMap = [];
  8032.         $totalPhotos 0;
  8033.         foreach ($rows as $row) {
  8034.             $date $row['photo_date'];
  8035.             $photosByDayMap[$date][] = [
  8036.                 'id' => $row['sejour_attachment_id'],
  8037.                 'path' => $row['path'],
  8038.                 'nom' => $row['descreption'] ?? 'Photo',
  8039.             ];
  8040.             $totalPhotos++;
  8041.         }
  8042.         unset($rows);
  8043.         $photosByDay = [];
  8044.         foreach ($photosByDayMap as $date => $photos) {
  8045.             $photosByDay[] = [
  8046.                 'date' => $date,
  8047.                 'description' => $dayDescriptions[$date] ?? null,
  8048.                 'photos' => $photos,
  8049.                 'count' => count($photos),
  8050.             ];
  8051.         }
  8052.         unset($photosByDayMap);
  8053.         usort($photosByDay, function ($a$b) {
  8054.             return strtotime($a['date']) - strtotime($b['date']);
  8055.         });
  8056.         return $this->render('Parent/album_builder_parent.html.twig', [
  8057.             'sejour' => $sejour,
  8058.             'sejourId' => $sejourId,
  8059.             'partnerName' => $partnerName,
  8060.             'partnerLogo' => $partnerLogo,
  8061.             'likedPhotos' => $likedPhotosFormatted,
  8062.             'photosByDay' => $photosByDay,
  8063.             'like' => $listeattachlikephoto,
  8064.             'totalPhotos' => $totalPhotos,
  8065.             'nbLikes' => $nbLikes,
  8066.             'existingAlbum' => $parentAlbum ?? $Albumproduct,
  8067.             'existingAlbumData' => $existingAlbumData,
  8068.             'mode' => ($existingAlbumData) ? 'edit' 'create',
  8069.             'albumId' => $userAlbumId,
  8070.             'prixAlbum' => $prixAlbum,
  8071.         ]);
  8072.     }
  8073.     /**
  8074.      * @Route("/Parent/Editer_Album_du_Sejour", name="Editer_Album_du_Sejour")
  8075.      */
  8076.     function EditerSessionAlbum()
  8077.     {
  8078.         $SEjourService $this->sejourService;
  8079.         /** @var \App\Entity\User $user */
  8080.         $user $this->getUser();
  8081.         $userId $user->getId();
  8082.         $session $this->session;
  8083.         $session->set('pageMenu''');
  8084.         $idSejour $session->get("Sejour");
  8085.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8086.         $em $this->em;
  8087.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  8088.         $nbLikes count($listeattachlikephoto);
  8089.         $AllPages null;
  8090.         $random false;
  8091.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['statut' => 'Album_sejour''idsjour' => $sejour], ['id' => 'DESC']);
  8092.         if ($Albumproduct != null and $Albumproduct != "") {
  8093.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  8094.         }
  8095.         $allpagesResult = array();
  8096.         $tabacc = array();
  8097.         $tabacc1 = array();
  8098.         foreach ($AllPages as $page) {
  8099.             $pageJ json_decode($page->getCouleurbordure());
  8100.             $pageDec json_decode($pageJ[0]);
  8101.             $attache json_decode($pageDec->attache);
  8102.             if (isset($attache[0])) {
  8103.                 $attachDec json_decode($attache[0]);
  8104.             }
  8105.             //var_dump($attachDec);
  8106.             //var_dump(json_decode($attachDec->id));
  8107.             if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  8108.                 $idAttach json_decode($attachDec->id);
  8109.                 array_push($tabacc$idAttach);
  8110.             }
  8111.         }
  8112.         $tabacc1 array_count_values($tabacc);
  8113.         $part $sejour->getIdPartenaire();
  8114.         $nompart $part->getUsername();
  8115.         $logopart $part->getLogourl();
  8116.         $session->set('produit'$Albumproduct->gettype());
  8117.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  8118.         $nbPhoto count($listeattach);
  8119.         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]);
  8120.     }
  8121.     /**
  8122.      * @Route("/Parent/Editer_Livre_du_Sejour", name="Editer_Livre_du_Sejour")
  8123.      */
  8124.     function EditerSessionLivre()
  8125.     {
  8126.         $SEjourService $this->sejourService;
  8127.         /** @var \App\Entity\User $user */
  8128.         $user $this->getUser();
  8129.         $userId $user->getId();
  8130.         $session $this->session;
  8131.         $session->set('pageMenu''');
  8132.         $idSejour $session->get("Sejour");
  8133.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8134.         $em $this->em;
  8135.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  8136.         $nbLikes count($listeattachlikephoto);
  8137.         $AllPages null;
  8138.         $random false;
  8139.         $idAcc $sejour->getIdAcommp();
  8140.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  8141.         if ($Albumproduct == null) {
  8142.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['version' => 'Livre_Sejour_Admin''idsjour' =>   $idSejour]);
  8143.         }
  8144.         if ($Albumproduct == null) {
  8145.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomLivre']);
  8146.         }
  8147.         if ($Albumproduct != null and $Albumproduct != "") {
  8148.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  8149.         }
  8150.         $allpagesResult = array();
  8151.         $tabacc = array();
  8152.         $tabacc1 = array();
  8153.         foreach ($AllPages as $page) {
  8154.             $pageJ json_decode($page->getCouleurbordure());
  8155.             $pageDec json_decode($pageJ[0]);
  8156.             $attache json_decode($pageDec->attache);
  8157.             if (isset($attache[0])) {
  8158.                 $attachDec json_decode($attache[0]);
  8159.             }
  8160.             //var_dump($attachDec);
  8161.             //var_dump(json_decode($attachDec->id));
  8162.             if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  8163.                 $idAttach json_decode($attachDec->id);
  8164.                 array_push($tabacc$idAttach);
  8165.             }
  8166.         }
  8167.         $tabacc1 array_count_values($tabacc);
  8168.         $part $sejour->getIdPartenaire();
  8169.         $nompart $part->getUsername();
  8170.         $logopart $part->getLogourl();
  8171.         $session->set('produit'$Albumproduct->gettype());
  8172.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  8173.         $nbPhoto count($listeattach);
  8174.         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]);
  8175.     }
  8176.     /**
  8177.      * @Route("/Parent/DesactiverSessionAlbum", name="DesactiverSessionAlbum")
  8178.      */
  8179.     function DesactiverSessionAlbum()
  8180.     {
  8181.         $session $this->session;
  8182.         $session->remove('sessionalbm');
  8183.         return new Response('session removed');
  8184.     }
  8185.     /**
  8186.      * @Route("/Parent/Mon_Compte_Activer", name="Mon_Compte_Activer")
  8187.      */
  8188.     public function Mon_Compte_Activer(Request $request)
  8189.     {
  8190.         $em $this->em;
  8191.         return $this->render('Parent/activeMoncompte.html.twig');
  8192.     }
  8193.     /**
  8194.      * @Route("/Parent/swuitchSejour/{id}", name="swuitchSejour")
  8195.      */
  8196.     public function swuitchSejour($id)
  8197.     {
  8198.         $em $this->em;
  8199.         $sejourobj $this->em->getRepository(Sejour::class)->find($id);
  8200.         $this->session->set('Sejour'$sejourobj->getId());
  8201.         return $this->redirectToRoute('AccueilParent');
  8202.     }
  8203.     /**
  8204.      * @Route("/migrationCloudinary", name="migrationCloudinary")
  8205.      */
  8206.     public function cloudinaryMigration()
  8207.     {
  8208.         $em $this->em;
  8209.         //        $path="https://res.cloudinary.com/apss-factory/image/upload/a_exif/v1588979564/newprod/JUEGOS-EN-LA-PLAYA5_dnvgj8.jpg";
  8210.         $attachement = [
  8211.             'Eclaire.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/Eclaire_pr0ecu.svg',
  8212.             'ARcenciel.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143391/newprod/clipart/ARcenciel_grkyap.svg',
  8213.             'Drapeaux.svg' => 'https://res.cloudinary.com/apss-factory/image/uploadv/1589143377/newprod/clipart/Drapeaux_zqo8v3.svg',
  8214.             'Annif.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143391/newprod/clipart/Annif_ihvyoo.svg',
  8215.             'Basquettes.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Basquettes_znjd41.svg',
  8216.             'Foot.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143382/newprod/clipart/Foot_az6bct.svg',
  8217.             'Hello.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Hello_njqifl.svg',
  8218.             'Love.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143386/newprod/clipart/Love_q39usk.svg',
  8219.             'LICORNE.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143385/newprod/clipart/LICORNE_hpomru.svg',
  8220.             'Noeud.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143388/newprod/clipart/Noeud_mw5a4j.svg',
  8221.             'Etoilerose.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Etoilerose_ewrzff.svg',
  8222.             'Ete4.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/Ete4_pdxadk.svg',
  8223.             'Ete6.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Ete6_a3xgpd.svg',
  8224.             'Ete9.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Ete9_s4vllm.svg',
  8225.             'Hiver1.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Hiver1_fekrjz.svg',
  8226.             'Hiver2.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Hiver2_e9iygg.svg',
  8227.             'Noel2.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Noel2_eqvdzr.svg',
  8228.             'Hiver.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Hiver_et04e1.svg',
  8229.             'Sapin.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143390/newprod/clipart/Sapin_qjkxz6.svg',
  8230.             'Chaussetet.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Chaussetet_xfpt6t.svg',
  8231.             'Cloches.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Cloches_x2v3eo.svg',
  8232.             'Like.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Like_ynxb2u.svg',
  8233.             'coeurlike.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/coeurlike_ferv9y.svg',
  8234.             'Fetedesmeres.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Fetedesmeres_ud9vac.svg',
  8235.             'Fetedesperes.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Fetedesperes_mltjmo.svg',
  8236.             'OOPS.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/OOPS_gj9p1c.svg',
  8237.             'OOPS_1.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/OOPS_1_r9a7l6.svg',
  8238.             'WoW.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143393/newprod/clipart/WoW_ljlqjm.svg',
  8239.             'Nuage.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Nuage_fgomd0.svg',
  8240.             'Pingouin.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/Pingouin_ogxb6e.svg',
  8241.             'Renard.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143378/newprod/clipart/Chouette_mc1ik2.svg',
  8242.             'Chouette.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143390/newprod/clipart/Renard_mlhrxt.svg'
  8243.         ];
  8244.         foreach ($attachement as $at) {
  8245.             $exif false;
  8246.             $path $at;
  8247.             $pathArray explode("/"$path);
  8248.             $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  8249.             $idImage "";
  8250.             foreach ($idsArray as $key2 => $elem) {
  8251.                 if ($key2 != (sizeof($idsArray) - 1)) {
  8252.                     $idImage $idImage $elem;
  8253.                 }
  8254.             }
  8255.             $idImage 'clipart/' $idImage;
  8256.             \Cloudinary::config(array(
  8257.                 "cloud_name" => "af5sur5sejour",
  8258.                 "api_key" => "263346742199243",
  8259.                 "api_secret" => "jYw-jg0FOJGv89-o5Wo0Fa3rQWU",
  8260.                 "secure" => true
  8261.             ));
  8262.             Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  8263.             Unirest\Request::verifyPeer(false);
  8264.             $url 'https://api.cloudinary.com/v1_1/af5sur5sejour/image/upload';
  8265.             $headers = array('Accept' => 'application/json');
  8266.             $data = array("file" => $path"public_id" => $idImage"upload_preset" => 'ml_default');
  8267.             $body Unirest\Request\Body::form($data);
  8268.             $resultMetadata Unirest\Request::post($url$headers$body);
  8269.             var_dump($resultMetadata);
  8270.             if (isset(json_decode($resultMetadata->raw_body)->secure_url)) {
  8271.                 var_dump(json_decode($resultMetadata->raw_body)->secure_url);
  8272.             }
  8273.         }
  8274.         $em->getManager()->flush();
  8275.         return new response("done");
  8276.     }
  8277.     /**
  8278.      * @Route("/Parent/virgoPAss", name="virgopass")
  8279.      */
  8280.     public function virgopass()
  8281.     {
  8282.         return $this->render('Parent/virgo.html.twig');
  8283.     }
  8284.     /**
  8285.      * @Route("/Parent/interfaceUpdatePassorwdParent", name="interfaceUpdatePassorwdParent")
  8286.      */
  8287.     public function interfaceUpdatePassorwdParent(Request $request)
  8288.     {
  8289.         $user $this->getUser();
  8290.         return $this->render('Parent/interfaceUpdatePassorwdParent.html.twig', ["userToSetPassword" => $user]);
  8291.     }
  8292.     /**
  8293.      * @Route("/Parent/updatePassorwdParent", name="updatePassorwd_parent")
  8294.      */
  8295.     public function updatePassorwdParent(Request $request)
  8296.     {
  8297.         $em $this->em;
  8298.         $serviceuser $this->userService;
  8299.         $id $request->get("userID");
  8300.         $password $request->get("password");
  8301.         $result $serviceuser->ModifierPwdParent($id$password);
  8302.         return new Response('pwd modifié');
  8303.     }
  8304.     /**
  8305.      * @Route("/Parent/sauthentifierAuto/{token}/{idUser}/{userHash}",name="sauthentifierAuto")
  8306.      */
  8307.     function sauthentifierAuto($token$idUser$userHash)
  8308.     {
  8309.         $parent $this->em->getRepository(User::class)->find($idUser);
  8310.         if ((hash("sha256"$parent->getUsername() . $parent->getId()) == $userHash)) {
  8311.             $providerKey 'main_Parent'// your firewall name
  8312.             $token = new UsernamePasswordToken($parentnull$providerKey$parent->getRoles());
  8313.             $this->container->get('security.token_storage')->setToken($token);
  8314.             return $this->redirectToRoute("CodeSejour");
  8315.         } else {
  8316.             return $this->redirectToRoute("app_back_Parent");
  8317.         }
  8318.     }
  8319.     /**
  8320.      * @Route("/loginAutotoAlbumAcco/{token}/{idUser}/{userHash}/{albumAcco}",name="loginAutotoAlbumAcco")
  8321.      */
  8322.     function loginAutotoAlbumAcco($token$idUser$userHash$albumAcco)
  8323.     {
  8324.         $parent $this->em->getRepository(User::class)->find($idUser);
  8325.         if ((hash("sha256"$parent->getUsername() . $parent->getId()) == $userHash)) {
  8326.             //            return $this->render('security/DemandePasswordParentv.html.twig', ["userToSetPassword" => $use
  8327.             //dd('im herge');             
  8328.             $providerKey 'main_Parent'// your firewall name
  8329.             $token = new UsernamePasswordToken($parentnull$providerKey$parent->getRoles());
  8330.             //dd($token);  
  8331.             $this->container->get('security.token_storage')->setToken($token);
  8332.             $session $this->session;
  8333.             $produit $this->em->getRepository(Produit::class)->find($albumAcco);
  8334.             // dd($produit->getIdsjour()->getId());    
  8335.             $session->set("Sejour"$produit->getIdsjour()->getId());
  8336.             return $this->redirectToRoute("ActiverSessionAlbum");
  8337.         } else {
  8338.             return $this->redirectToRoute("app_back_Parent");
  8339.         }
  8340.     }
  8341.     /**
  8342.      * @Route("/Parent/respondNotifSms",name="respondNotifSms")
  8343.      */
  8344.     function respondNotifSms(Request $request)
  8345.     {
  8346.         $resp $request->get("resp");
  8347.         /** @var \App\Entity\User $user */
  8348.         $user $this->getUser();
  8349.         $user->setSmsnotif($resp);
  8350.         $this->em->getManager()->persist($user);
  8351.         $parentsejour $this->em->getRepository(ParentSejour::class)->findBy(['idParent' => $user]);
  8352.         foreach ($parentsejour as $sejr) {
  8353.             $sejr->setSmsnotif($resp);
  8354.             if (strpos($sejr->getIdSejour()->getCodeSejour(), "EF") !== false) {
  8355.                 $sejr->setSmsnotif(0);
  8356.             }
  8357.             $this->em->getManager()->persist($sejr);
  8358.         }
  8359.         $this->em->getManager()->flush();
  8360.         return new Response('smsnotifmodifié');
  8361.     }
  8362.     /**
  8363.      * @Route("/Parent/CheckRandomNotice",name="CheckRandomNotice")
  8364.      */
  8365.     function CheckRandomNotice(Request $request)
  8366.     {
  8367.         $val $request->get("val");
  8368.         /** @var \App\Entity\User $user */
  8369.         $user $this->getUser();
  8370.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8371.         $parent->setRandomnotice($val);
  8372.         $this->em->getManager()->persist($parent);
  8373.         $this->em->getManager()->flush();
  8374.         return new Response('ok');
  8375.     }
  8376.     /**
  8377.      * @Route("/Parent/CheckalbumNotif",name="CheckalbumNotif")
  8378.      */
  8379.     function CheckalbumNotif(Request $request)
  8380.     {
  8381.         $val $request->get("val");
  8382.         /** @var \App\Entity\User $user */
  8383.         $user $this->getUser();
  8384.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8385.         $parent->setShowdetailsalbum($val);
  8386.         $this->em->getManager()->persist($parent);
  8387.         $this->em->getManager()->flush();
  8388.         return new Response('ok');
  8389.     }
  8390.     /**
  8391.      * @Route("/Parent/ChecklivreNotif",name="ChecklivreNotif")
  8392.      */
  8393.     function ChecklivreNotif(Request $request)
  8394.     {
  8395.         $val $request->get("val");
  8396.         /** @var \App\Entity\User $user */
  8397.         $user $this->getUser();
  8398.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8399.         $parent->setShowdetailslivre($val);
  8400.         $this->em->getManager()->persist($parent);
  8401.         $this->em->getManager()->flush();
  8402.         return new Response('ok');
  8403.     }
  8404.     /**
  8405.      * @Route("/Parent/CheckphotosNotif",name="CheckphotosNotif")
  8406.      */
  8407.     function CheckphotosNotif(Request $request)
  8408.     {
  8409.         $val $request->get("val");
  8410.         /** @var \App\Entity\User $user */
  8411.         $user $this->getUser();
  8412.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8413.         $parent->setShowdetailsphotos($val);
  8414.         $this->em->getManager()->persist($parent);
  8415.         $this->em->getManager()->flush();
  8416.         return new Response('ok');
  8417.     }
  8418.     /**
  8419.      * @Route("/Parent/CheckcalNotif",name="CheckcalNotif")
  8420.      */
  8421.     function CheckcalNotif(Request $request)
  8422.     {
  8423.         $val $request->get("val");
  8424.         /** @var \App\Entity\User $user */
  8425.         $user $this->getUser();
  8426.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8427.         $parent->setShowdetailscal($val);
  8428.         $this->em->getManager()->persist($parent);
  8429.         $this->em->getManager()->flush();
  8430.         return new Response('ok');
  8431.     }
  8432.     /**
  8433.      * @Route("/Parent/CheckretrosNotif",name="CheckretrosNotif")
  8434.      */
  8435.     function CheckretrosNotif(Request $request)
  8436.     {
  8437.         $val $request->get("val");
  8438.         /** @var \App\Entity\User $user */
  8439.         $user $this->getUser();
  8440.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8441.         $parent->setShowdetailsretros($val);
  8442.         $this->em->getManager()->persist($parent);
  8443.         $this->em->getManager()->flush();
  8444.         return new Response('ok');
  8445.     }
  8446.     /**
  8447.      * @Route("/Parent/hidePubProd",name="hidePubProd")
  8448.      */
  8449.     function hidePubProd(Request $request)
  8450.     {
  8451.         $val $request->get("val");
  8452.         /** @var \App\Entity\User $user */
  8453.         $user $this->getUser();
  8454.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8455.         $parent->setShowpubprod('false');
  8456.         $this->em->getManager()->persist($parent);
  8457.         $this->em->getManager()->flush();
  8458.         return new Response('ok');
  8459.     }
  8460.     /**
  8461.      * @Route("/Parent/PackPhotosNumerique_Modifier/{nbr}/{id}", name="PackPhotosNumerique_Modifier")
  8462.      */
  8463.     public function PackPhotosNumerique_Modifier($nbr$id)
  8464.     {
  8465.         $SEjourService $this->sejourService;
  8466.         /** @var \App\Entity\User $user */
  8467.         $user $this->getUser();
  8468.         $userId $user->getId();
  8469.         $user $this->getUser();
  8470.         $session $this->session;
  8471.         $session->set('pageMenu''');
  8472.         $idSejour $session->get("Sejour");
  8473.         $produitcondition $session->get("produit");
  8474.         $produit $session->get("produittype");
  8475.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8476.         $em $this->em;
  8477.         $clipart $em->getRepository(Clipart::class)->findAll();
  8478.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  8479.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  8480.         $nbLikes count($listeattachlikephoto);
  8481.         //Stella
  8482.         $AllPagesAcc null;
  8483.         $random false;
  8484.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  8485.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  8486.         $idAcc $sejour->getIdAcommp();
  8487.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  8488.         $part $sejour->getIdPartenaire();
  8489.         $nompart $part->getUsername();
  8490.         $logopart $part->getLogourl();
  8491.         $nbPhoto count($listeattach);
  8492.         // die();
  8493.         if ($nbLikes == 0) {
  8494.             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]);
  8495.         }
  8496.         if ($nbLikes != 0) {
  8497.             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]);
  8498.         }
  8499.     }
  8500.     /**
  8501.      * @Route("Parent/PackPhotosNumerique_Favoris/{nbr}", name="PackPhotosNumerique_Favoris")
  8502.      */
  8503.     public function PackPhotosNumerique_Favoris($nbr)
  8504.     {
  8505.         $SEjourService $this->sejourService;
  8506.         $user $this->getUser();
  8507.         $userId $this->getUser()->getId();
  8508.         $session $this->get('session');
  8509.         $session->set('pageMenu''');
  8510.         $idSejour $session->get("Sejour");
  8511.         $produitcondition $session->get("produit");
  8512.         $produit $session->get("produittype");
  8513.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8514.         $em $this->getDoctrine()->getManager();
  8515.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' =>  $userId'idSejour' =>  $idSejour]);
  8516.         foreach ($listeattachlikephoto as $photo) {
  8517.             $idattach $photo->getIdSejourAttchment();
  8518.             $SejattachPhoto  $photo->getIdSejourAttchment();
  8519.             $urlPhoto  =   $SejattachPhoto->getIdAttchment()->getPath();
  8520.             //$urlPhoto =   $attachPhoto->getPath();
  8521.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/',  $urlPhoto);
  8522.             $photosData[] = [
  8523.                 'id' => $photo->getId(),
  8524.                 'url' =>    $new_url,
  8525.                 'caption' => "",
  8526.             ];
  8527.         }
  8528.         $nbLikes count($listeattachlikephoto);
  8529.         // Convertir le tableau PHP en JSON
  8530.         $photosDataJSON json_encode($photosData);
  8531.         return $this->render('Parent/PackPhotosNumerique_Favoris.html.twig', [
  8532.             "nbr" => $nbr,
  8533.             "sejour" => $sejour,
  8534.             "nbLikes" => $nbLikes,
  8535.             'photosFav' =>    $photosDataJSON
  8536.         ]);
  8537.     }
  8538.     /**
  8539.      * @Route("Parent/PackPhotosNumerique_Offert/{nbr}", name="PackPhotosNumerique_Offert")
  8540.      */
  8541.     public function PackPhotosNumerique_Offert($nbr)
  8542.     {
  8543.         $SEjourService $this->sejourService;
  8544.         $user $this->getUser();
  8545.         $userId $this->getUser()->getId();
  8546.         $session $this->get('session');
  8547.         $session->set('pageMenu''');
  8548.         $idSejour $session->get("Sejour");
  8549.         $produitcondition $session->get("produit");
  8550.         $produit $session->get("produittype");
  8551.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8552.         $em $this->getDoctrine()->getManager();
  8553.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' => $userId'idSejour' => $idSejour]);
  8554.         foreach ($listeattachlikephoto as $photo) {
  8555.             $idattach $photo->getIdSejourAttchment();
  8556.             $SejattachPhoto $photo->getIdSejourAttchment();
  8557.             $urlPhoto $SejattachPhoto->getIdAttchment()->getPath();
  8558.             //$urlPhoto = $attachPhoto->getPath();
  8559.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/'$urlPhoto);
  8560.             $photosData[] = [
  8561.                 'id' => $photo->getId(),
  8562.                 'url' => $new_url,
  8563.                 'caption' => "",
  8564.             ];
  8565.         }
  8566.         $nbLikes count($listeattachlikephoto);
  8567.         // Convertir le tableau PHP en JSON
  8568.         $photosDataJSON json_encode($photosData);
  8569.         return $this->render('Parent/PackPhotosNumerique_Favoris.html.twig', [
  8570.             "nbr" => $nbr,
  8571.             "sejour" => $sejour,
  8572.             "nbLikes" => $nbLikes,
  8573.             'photosFav' => $photosDataJSON
  8574.         ]);
  8575.     }
  8576.     /**
  8577.      * @Route("Parent/AjoutPackPhotosNum/{nbr}", name="AjoutPackPhotosNum")
  8578.      */
  8579.     public function AjoutPackPhotosNumParent($nbr)
  8580.     {
  8581.         $SEjourService $this->sejourService;
  8582.         /** @var \App\Entity\User $user */
  8583.         $user $this->getUser();
  8584.         $userId $user->getId();
  8585.         $user $this->getUser();
  8586.         $session $this->session;
  8587.         $session->set('pageMenu''');
  8588.         $idSejour $session->get("Sejour");
  8589.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8590.         $em $this->em;
  8591.         $clipart $em->getRepository(Clipart::class)->findAll();
  8592.         //  $listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
  8593.         //$listerandom =  $SEjourService->getatachmentsejour($idSejour);
  8594.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  8595.         $listerandom =  $listeattach;
  8596.         $AllPagesAcc null;
  8597.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPackPhotosNum' $nbr]);
  8598.         $random true;
  8599.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  8600.         $idAcc $sejour->getIdAcommp();
  8601.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  8602.         $part $sejour->getIdPartenaire();
  8603.         $nompart $part->getUsername();
  8604.         $logopart $part->getLogourl();
  8605.         if ($albumAcc != null and $albumAcc != "") {
  8606.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  8607.         }
  8608.         $allpagesResult = array();
  8609.         $j 0;
  8610.         if ($random == true) {
  8611.             foreach ($AllPages as $p) {
  8612.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  8613.                 $rr "";
  8614.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  8615.                     if ($i sizeof($arrayexploded)) {
  8616.                         if (sizeof($listerandom) == 0) {
  8617.                             //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  8618.                             $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  8619.                         }
  8620.                         $arrayRsRandom $this->random_functionNolikes($listerandom);
  8621.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  8622.                         unset($listerandom[$arrayRsRandom['elem']]);
  8623.                     } else {
  8624.                         $rr $rr $arrayexploded[$i];
  8625.                     }
  8626.                     $listerandom $listerandom;
  8627.                 }
  8628.                 $resultFinal $rr;
  8629.                 $p->setCouleurbordure($resultFinal);
  8630.                 array_push($allpagesResult$p);
  8631.                 if ($j sizeof($listeattach) - 1) {
  8632.                     $j $j 1;
  8633.                 } else {
  8634.                     $j 0;
  8635.                 }
  8636.             }
  8637.             $AllPages $allpagesResult;
  8638.         }
  8639.         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]);
  8640.     }
  8641.     /**
  8642.      * @Route("/Parent/SavePackPhotosNumerique", name="SavePackPhotosNumeriqueParent")
  8643.      */
  8644.     public function SavePackPhotosNumeriqueParent(Request $request)
  8645.     {
  8646.         $session $this->session;
  8647.         $serviceuser $this->etablissementService;
  8648.         $page $request->get("pages");
  8649.         $sejour $request->get("sejour");
  8650.         $prodid $request->get('idProd');
  8651.         $nomprod $request->get('nomprod');
  8652.         $nbr $request->get('nbr');
  8653.         $user $this->getUser();
  8654.         $nbr strval($nbr);
  8655.         $produittype $session->get("produit");
  8656.         $produit $session->get("produittype");
  8657.         //  $Album = $serviceuser->SavePhotosPochetteParent($page, $user, $sejour, $prodid, $produit, $produittype, $nbr,$nomprod);
  8658.         $refPackNum null;
  8659.         if ($sejour) {
  8660.             $refPackNum $this->generateRefPackPhotosNum($sejour$user);
  8661.         }
  8662.         $Album $serviceuser->SavePackPhotosNumerique($page$user$sejour$prodid$produit$produittype$nbr$nomprod$refPackNum);
  8663.         //sendmailparent
  8664.         $dateNow = new \Datetime();
  8665.         /** @var \App\Entity\User $user */
  8666.         $user $this->getUser();
  8667.         $userEmail $user->getEmail();
  8668.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  8669.         //$this->EmailServie->MailRelancePanier($userEmail);
  8670.         return new response('done');
  8671.     }
  8672.     /**
  8673.      * @Route("/Parent/CommandeDirecteAddPackNumeriqueAuPanier", name="CommandeDirecteAddPackNumeriqueAuPanier")
  8674.      */
  8675.     public function CommandeDirecteAddPackNumeriqueAuPanier(Request $request)
  8676.     {
  8677.         $em $this->em->getManager();
  8678.         $session $this->session;
  8679.         $this->logger->info('Début CommandeDirecteAddPackNumeriqueAuPanier');
  8680.         $serviceuser $this->etablissementService;
  8681.         $photos $request->get("photos");
  8682.         $sejour $request->get("sejour");
  8683.         $nbr $request->get('nbr');
  8684.         $user $this->getUser();
  8685.         $nbr strval($nbr);
  8686.         $nomprod "Pack Photos Numerique - " $nbr;
  8687.         // Créer le produit pack photos
  8688.         $packPhotos $serviceuser->SavePackPhotosNumerique($photos$user$sejour$nbr$nomprod);
  8689.         $product $em->getRepository(Produit::class)->find($packPhotos->getId());
  8690.         // Récupérer ou créer le panier
  8691.         $typeref $em->getRepository(Typeref::class)->find(8);
  8692.         $statutPanier $em->getRepository(Ref::class)->findOneBy(["libiller" => "creer""typeref" => $typeref]);
  8693.         $panierTrace $em->getRepository(Panier::class)->findOneBy(["creerPar" => $user"statut" => $statutPanier]);
  8694.         if ($panierTrace === null) {
  8695.             $panierTrace = new Panier();
  8696.             $panierTrace->setDateCreation(new \DateTime());
  8697.             $panierTrace->setCreerPar($user);
  8698.             $panierTrace->setStatut($statutPanier);
  8699.             $em->persist($panierTrace);
  8700.             $em->flush();
  8701.         }
  8702.         $this->logger->info('Panier récupéré', ['panier_id' => $panierTrace $panierTrace->getId() : 'null']);
  8703.         // Récupérer les produits du panier en session
  8704.         $Products $session->get("Panier", []);
  8705.         $inser false;
  8706.         // Vérifier si le panier est vide (pas de produits en session)
  8707.         if (count($Products) == 0) {
  8708.             // Créer directement une commande et une commande numérique
  8709.             $commande = new Commande();
  8710.             $commande->setDateCreation(new \DateTime());
  8711.             $commande->setCreerPar($user);
  8712.             $commande->setStatut($statutPanier);
  8713.             $commande->setTyperef($typeref);
  8714.             $commande->setMontantTTC($product->getIdConditionnement()->getMontantTTC());
  8715.             $commande->setIdsjour($sejour);
  8716.             $commande->setIdpanier($panierTrace->getId());
  8717.             $commande->setNumComande($this->generateUniqueOrderNumber());
  8718.             $em->persist($commande);
  8719.             $em->flush();
  8720.             $commandeNumerique = new CommandeNumerique();
  8721.             $commandeNumerique->setDateCreation(new \DateTime());
  8722.             $commandeNumerique->setCreerPar($user);
  8723.             $commandeNumerique->setIdCommande($commande);
  8724.             $commandeNumerique->setStatut($statutPanier);
  8725.             $commandeNumerique->setLinkdownload($product->getId());
  8726.             $commandeNumerique->setEtat(0); // État en attente de paiement
  8727.             $em->persist($commandeNumerique);
  8728.             $em->flush();
  8729.             // Ajouter le produit au panier en session pour le paiement
  8730.             $p = [
  8731.                 "id" => $product->getId(),
  8732.                 "nom" => $product->getType()->getLabeletype(),
  8733.                 "ident" => $product->getLabele(),
  8734.                 "codesejour" => $product->getIdsjour()->getcodeSejour(),
  8735.                 "mnt" => $product->getIdConditionnement()->getMontantTTC(),
  8736.                 "path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  8737.                 "condition" => $product->getIdConditionnement()->getId(),
  8738.                 "qte" => 1
  8739.             ];
  8740.             array_push($Products$p);
  8741.             $session->set('Panier'$Products);
  8742.             // Ajouter le produit au panier en base de données
  8743.             $panierProduit = new PanierProduit();
  8744.             $panierProduit->setIdProduit($product);
  8745.             $panierProduit->setIdPanier($panierTrace);
  8746.             $panierProduit->setQuantite(1);
  8747.             $panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
  8748.             $em->persist($panierProduit);
  8749.             $em->flush();
  8750.             // Rediriger vers la page de paiement
  8751.             return $this->redirectToRoute('paiement_commande_directe', [
  8752.                 'id' => $commande->getId()
  8753.             ]);
  8754.         } else {
  8755.             // Il y a déjà des produits dans le panier
  8756.             // Ajouter le produit au panier existant
  8757.             // Vérifier si le produit existe déjà dans le panier en session
  8758.             foreach ($Products as $key => $p) {
  8759.                 if ($p['id'] === $product->getId()) {
  8760.                     $inser true;
  8761.                     $Products[$key]['qte'] += 1;
  8762.                     $Products[$key]['mnt'] += $product->getIdConditionnement()->getMontantTTC();
  8763.                 }
  8764.             }
  8765.             // Vérifier si le produit existe dans PanierProduit en base de données
  8766.             $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(["idProduit" => $product"idPanier" => $panierTrace]);
  8767.             if ($panierProduit === null) {
  8768.                 $panierProduit = new PanierProduit();
  8769.                 $panierProduit->setIdProduit($product);
  8770.                 $panierProduit->setIdPanier($panierTrace);
  8771.                 $panierProduit->setQuantite(1);
  8772.                 $panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
  8773.                 $em->persist($panierProduit);
  8774.                 $em->flush();
  8775.             } else {
  8776.                 // Mettre à jour la quantité et le prix total
  8777.                 $panierProduit->setQuantite($panierProduit->getQuantite() + 1);
  8778.                 $panierProduit->setPrixTotal($panierProduit->getPrixTotal() + $product->getIdConditionnement()->getMontantTTC());
  8779.                 $em->persist($panierProduit);
  8780.                 $em->flush();
  8781.             }
  8782.             // Si le produit n'est pas déjà dans le panier en session, l'ajouter
  8783.             if (!$inser) {
  8784.                 $p = [
  8785.                     "id" => $product->getId(),
  8786.                     "nom" => $product->getType()->getLabeletype(),
  8787.                     "ident" => $product->getLabele(),
  8788.                     "codesejour" => $product->getIdsjour()->getcodeSejour(),
  8789.                     "mnt" => $product->getIdConditionnement()->getMontantTTC(),
  8790.                     "path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  8791.                     "condition" => $product->getIdConditionnement()->getId(),
  8792.                     "qte" => 1
  8793.                 ];
  8794.                 array_push($Products$p);
  8795.             }
  8796.             // Mettre à jour le panier en session
  8797.             $session->set('Panier'$Products);
  8798.             // Ajouter un message flash pour informer l'utilisateur
  8799.             $this->addFlash('success''Le pack photos a été ajouté à votre panier.');
  8800.             // Rediriger vers le panier
  8801.             $this->logger->info('Redirection vers le panier');
  8802.             return new Response('done');
  8803.         }
  8804.     }
  8805.     /**
  8806.      * Génère un numéro de commande unique
  8807.      */
  8808.     private function generateUniqueOrderNumber()
  8809.     {
  8810.         // Générer un numéro de commande basé sur la date et un nombre aléatoire
  8811.         return date('YmdHis') . rand(10009999);
  8812.     }
  8813.     /**
  8814.      * @Route("/Parent/confirmation-pack-photos/{id}", name="confirmation_pack_photos")
  8815.      */
  8816.     public function confirmationPackPhotos($id): Response
  8817.     {
  8818.         $commandeNumerique $this->em->getRepository(CommandeNumerique::class)->find($id);
  8819.         if (!$commandeNumerique) {
  8820.             throw $this->createNotFoundException('Commande numérique introuvable');
  8821.         }
  8822.         $commande $commandeNumerique->getIdCommande();
  8823.         $user $commande->getCreerPar();
  8824.         $sejour $commande->getIdsjour();
  8825.         return $this->render('Parent/confirmation_pack_photos.html.twig', [
  8826.             'commandeNumerique' => $commandeNumerique,
  8827.             'commande' => $commande,
  8828.             'user' => $user,
  8829.             'sejour' => $sejour,
  8830.             'downloadUrl' => $this->generateUrl('telechargerPack', ['idCommande' => $commandeNumerique->getId()])
  8831.         ]);
  8832.     }
  8833.     /**
  8834.      * @Route("/Parent/SavePackPhotosNumeriqueComandeSave_panier", name="SavePackPhotosNumeriqueComandeSave_panier")
  8835.      */
  8836.     public function AddPackNumeriqueAuPanier(Request $request)
  8837.     {
  8838.         $em $this->em->getManager();
  8839.         $session $this->session;
  8840.         $serviceuser $this->etablissementService;
  8841.         $photos $request->get("photos");
  8842.         $sejour $request->get("sejour");
  8843.         $nbr $request->get('nbr');
  8844.         $user $this->getUser();
  8845.         $nbr strval($nbr);
  8846.         $nomprod "Pack Photos Numerique - " $nbr;
  8847.         //test de la fonction envoieMailPackNumerique
  8848.         $packPhotos $serviceuser->SavePackPhotosNumerique($photos$user$sejour$nbr$nomprod);
  8849.         $product $em->getRepository(Produit::class)->find($packPhotos->getId());
  8850.         // ---  Test pour envoyer le mail pak numerique ---// 
  8851.         //   $this->emailsCmdService->envoieMailPackNumerique($packPhotos->getId());
  8852.         // $this->printerService->PackPhotosNumerique($packPhotos->getId(),20);
  8853.         $typeref $em->getRepository(Typeref::class)->find(8);
  8854.         $statutPanier $em->getRepository(Ref::class)->findOneBy(["libiller" => "creer""typeref" => $typeref]);
  8855.         $panierTrace $em->getRepository(Panier::class)->findOneBy(["creerPar" => $user"statut" => $statutPanier]);
  8856.         if ($panierTrace === null) {
  8857.             $panierTrace = new Panier();
  8858.             $panierTrace->setDateCreation(new \DateTime());
  8859.             $panierTrace->setCreerPar($user);
  8860.             $panierTrace->setStatut($statutPanier);
  8861.             $em->persist($panierTrace);
  8862.             $em->flush();
  8863.         }
  8864.         // Add product to cart session
  8865.         $Products $session->get("Panier", []);
  8866.         $inser false;
  8867.         foreach ($Products as $key => $p) {
  8868.             if ($p['id'] === $product->getId()) {
  8869.                 $inser true;
  8870.                 $Products[$key]['qte'] += 1;
  8871.                 $Products[$key]['mnt'] += $product->getIdConditionnement()->getMontantTTC();
  8872.             }
  8873.         }
  8874.         // Check if product exists in PanierProduit
  8875.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(["idProduit" => $product"idPanier" => $panierTrace]);
  8876.         if ($panierProduit === null) {
  8877.             $panierProduit = new PanierProduit();
  8878.             $panierProduit->setIdProduit($product);
  8879.             $panierProduit->setIdPanier($panierTrace);
  8880.             $panierProduit->setQuantite(1);
  8881.             $panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
  8882.             $em->persist($panierProduit);
  8883.             $em->flush();
  8884.         } else {
  8885.             // Update existing product quantity and total price
  8886.             $panierProduit->setQuantite($panierProduit->getQuantite() + 1);
  8887.             $panierProduit->setPrixTotal($panierProduit->getPrixTotal() + $product->getIdConditionnement()->getMontantTTC());
  8888.             $em->persist($panierProduit);
  8889.             $em->flush();
  8890.         }
  8891.         if (!$inser) {
  8892.             $p = [
  8893.                 "id" => $product->getId(),
  8894.                 "nom" => $product->getType()->getLabeletype(),
  8895.                 "ident" => $product->getLabele(),
  8896.                 "codesejour" => $product->getIdsjour()->getcodeSejour(),
  8897.                 "mnt" => $product->getIdConditionnement()->getMontantTTC(),
  8898.                 "path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  8899.                 "condition" => $product->getIdConditionnement()->getId(),
  8900.                 "qte" => 1
  8901.             ];
  8902.             array_push($Products$p);
  8903.         }
  8904.         $session->set('Panier'$Products);
  8905.         // Send reminder email
  8906.         /** @var \App\Entity\User $user */
  8907.         $userEmail $user->getEmail();
  8908.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  8909.         return new Response('done');
  8910.     }
  8911.     /* public function SavePackPhotosNumeriqueComandeSave_panier(PrinterService $PrinterService, Request $request)
  8912.     {
  8913.         $em = $this->em;
  8914.         var_dump("Debut Creation du pack numerique ");
  8915.         $session = $this->session;
  8916.         $serviceuser = $this->etablissementService;
  8917.         $attachements = $request->get('attachements');
  8918.         $page = $request->get("pages");
  8919.         $sejour = $request->get("sejour");
  8920.         $prodid = $request->get('idProd');
  8921.         var_dump($prodid);
  8922.         $nomprod = $request->get('nomprod');
  8923.         $nbr = $request->get('nbr');
  8924.         $user = $this->getUser();
  8925.         $nbr = strval($nbr);
  8926.         $produittype = $session->get("produit");
  8927.         $produit = $session->get("produittype");
  8928.         if ($sejour !== null) {
  8929.             $refPackNum = $this->generateRefPackPhotosNum($sejour, $user);
  8930.             $Album = $serviceuser->SavePackPhotosNumerique($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod, $refPackNum);
  8931.             $produit = $em->getRepository(Produit::class)->find($Album->getId());
  8932.             $serviceuser->commandepackphotoNum($attachements, $sejour, $user, $Album);
  8933.             //   $PrinterService->PackPhotosNumerique($sejour,$refPackNum,$Album);
  8934.             $inser = false;
  8935.             $Products = $session->get("Panier");
  8936.             //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
  8937.             $user = $this->getUser();
  8938.             $typeref = $em->getRepository(Typeref::class)->find(8);
  8939.             $statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
  8940.             $panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
  8941.             //fin
  8942.             if ($panierTrace == null) {
  8943.                 $panierTrace = new Panier();
  8944.                 $dateNow = new \Datetime();
  8945.                 $panierTrace->setDateCreation($dateNow);
  8946.                 $panierTrace->setCreerPar($user);
  8947.                 $panierTrace->setStatut($statutPanier);
  8948.                 $em->getManager()->persist($panierTrace);
  8949.                 $em->getManager()->flush();
  8950.             }
  8951.             //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
  8952.             if ($Products == null) {
  8953.                 $Products = [];
  8954.             }
  8955.             if ($Products != null) {
  8956.                 foreach ($Products as $key => $p) {
  8957.                     if ($p['id'] == $produit->getId()) {
  8958.                         $inser = true;
  8959.                         $Products[$key]['qte'] = $p['qte'] + 1;
  8960.                         $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  8961.                     }
  8962.                 }
  8963.             }
  8964.             //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  8965.             $panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
  8966.             if ($panierProduit == null) {
  8967.                 $panierProduit = new PanierProduit();
  8968.                 $panierProduit->setIdProduit($produit);
  8969.                 $panierProduit->setIdPanier($panierTrace);
  8970.                 $em->getManager()->persist($panierProduit);
  8971.                 $em->getManager()->flush();
  8972.             }
  8973.             //fin
  8974.             //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  8975.             $oldQte = $panierProduit->getQuantite();
  8976.             $newQte = $oldQte + 1;
  8977.             $panierProduit->setQuantite($newQte);
  8978.             $oldTotal = $panierProduit->getPrixTotal();
  8979.             $newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
  8980.             $panierProduit->setPrixTotal($newTotal);
  8981.             $em->getManager()->persist($panierProduit);
  8982.             $em->getManager()->flush();
  8983.             //fin
  8984.             if ($inser === false) {
  8985.                 $p = [];
  8986.                 $p["id"] = $produit->getId();
  8987.                 $p["nom"] = $produit->getType()->getLabeletype();
  8988.                 $p["ident"] = $produit->getLabele();
  8989.                 $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  8990.                 $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  8991.                 $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  8992.                 $p["condition"] = $produit->getIdConditionnement()->getId();
  8993.                 $p["qte"] = 1;
  8994.                 array_push($Products, $p);
  8995.             }
  8996.             $session->set('Panier', $Products);
  8997.             //sendmail_parent
  8998.             $dateNow = new \Datetime();
  8999.             $user = $this->getUser();
  9000.             $userEmail = $user->getEmail();
  9001.             $this->EmailServie->SaveMailRelancePanier($userEmail);
  9002.             // $this->EmailServie->MailRelancePanier($userEmail);
  9003.         }
  9004.         return new response('done');
  9005.     }
  9006. */
  9007.     /**
  9008.      * @Route("/Parent/SavePackPhotosNumeriqueComandeSave_panierfree", name="SavePackPhotosNumeriqueComandeSave_panierfree")
  9009.      */
  9010.     public function SavePackPhotosNumeriqueComandeSave_panierfree(PrinterService $PrinterServiceRequest $request)
  9011.     {
  9012.         $em $this->em;
  9013.         var_dump("Debut Creation du pack numerique ");
  9014.         $session $this->session;
  9015.         $serviceuser $this->etablissementService;
  9016.         $attachements $request->get('attachements');
  9017.         $page $request->get("pages");
  9018.         $sejour $request->get("sejour");
  9019.         $prodid $request->get('idProd');
  9020.         var_dump($prodid);
  9021.         $nomprod $request->get('nomprod');
  9022.         $nbr $request->get('nbr');
  9023.         $user $this->getUser();
  9024.         $nbr strval($nbr);
  9025.         $produittype $session->get("produit");
  9026.         $produit $session->get("produittype");
  9027.         if ($sejour !== null) {
  9028.             $refPackNum $this->generateRefPackPhotosNum($sejour$user);
  9029.             $Album $serviceuser->SavePackPhotosNumeriquefree($page$user$sejour$prodid$produit$produittype$nbr$nomprod$refPackNum);
  9030.             $produit $em->getRepository(Produit::class)->find($Album->getId());
  9031.             $serviceuser->commandepackphotoNum($attachements$sejour$user$Album);
  9032.             //   $PrinterService->PackPhotosNumerique($sejour,$refPackNum,$Album);
  9033.             $inser false;
  9034.             $Products $session->get("Panier");
  9035.             //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
  9036.             $user $this->getUser();
  9037.             $typeref $em->getRepository(Typeref::class)->find(8);
  9038.             $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  9039.             $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  9040.             //fin
  9041.             if ($panierTrace == null) {
  9042.                 $panierTrace = new Panier();
  9043.                 $dateNow = new \Datetime();
  9044.                 $panierTrace->setDateCreation($dateNow);
  9045.                 $panierTrace->setCreerPar($user);
  9046.                 $panierTrace->setStatut($statutPanier);
  9047.                 $em->getManager()->persist($panierTrace);
  9048.                 $em->getManager()->flush();
  9049.             }
  9050.             //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
  9051.             if ($Products == null) {
  9052.                 $Products = [];
  9053.             }
  9054.             if ($Products != null) {
  9055.                 foreach ($Products as $key => $p) {
  9056.                     if ($p['id'] == $produit->getId()) {
  9057.                         $inser true;
  9058.                         $Products[$key]['qte'] = $p['qte'] + 1;
  9059.                         $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  9060.                     }
  9061.                 }
  9062.             }
  9063.             //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  9064.             $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  9065.             if ($panierProduit == null) {
  9066.                 $panierProduit = new PanierProduit();
  9067.                 $panierProduit->setIdProduit($produit);
  9068.                 $panierProduit->setIdPanier($panierTrace);
  9069.                 $em->getManager()->persist($panierProduit);
  9070.                 $em->getManager()->flush();
  9071.             }
  9072.             //fin
  9073.             //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  9074.             $oldQte $panierProduit->getQuantite();
  9075.             $newQte $oldQte 1;
  9076.             $panierProduit->setQuantite($newQte);
  9077.             $oldTotal $panierProduit->getPrixTotal();
  9078.             $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  9079.             $panierProduit->setPrixTotal($newTotal);
  9080.             $em->getManager()->persist($panierProduit);
  9081.             $em->getManager()->flush();
  9082.             //fin
  9083.             if ($inser === false) {
  9084.                 $p = [];
  9085.                 $p["id"] = $produit->getId();
  9086.                 $p["nom"] = $produit->getType()->getLabeletype();
  9087.                 $p["ident"] = $produit->getLabele();
  9088.                 $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  9089.                 $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  9090.                 $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  9091.                 $p["condition"] = $produit->getIdConditionnement()->getId();
  9092.                 $p["qte"] = 1;
  9093.                 array_push($Products$p);
  9094.             }
  9095.             $session->set('Panier'$Products);
  9096.             //sendmail_parent
  9097.             $dateNow = new \Datetime();
  9098.             /** @var \App\Entity\User $user */
  9099.             $user $this->getUser();
  9100.             $userEmail $user->getEmail();
  9101.             $this->EmailServie->SaveMailRelancePanier($userEmail);
  9102.             // $this->EmailServie->MailRelancePanier($userEmail);
  9103.         }
  9104.         return new response('done');
  9105.     }
  9106.     function generateRefPackPhotosNum($idsejour$user)
  9107.     {
  9108.         //photonum_code_sejour_idparent_random;
  9109.         $em $this->em;
  9110.         $date = new \Datetime();
  9111.         $Milliseconde $date->format('dmYhis');
  9112.         $sejour $this->em->getRepository(Sejour::class)->find($idsejour);
  9113.         $ref "photonum_" $sejour->getCodeSejour() . "_" $user->getId() . "_" $Milliseconde;
  9114.         return $ref;
  9115.     }
  9116.     /**
  9117.      * @Route("/downloadpackphotonum/{refcmdnum}", name="downloadpackphotonum",methods={"GET"})
  9118.      */
  9119.     public function downloadpackphotonumAction($refcmdnumPrinterService $printerService)
  9120.     {
  9121.         // Try to find CommandeNumerique by linkdownload (can be product ID or ZIP name)
  9122.         $commandenumerique $this->em->getRepository(CommandeNumerique::class)->findOneBy(array('linkdownload' => $refcmdnum));
  9123.         if (!$commandenumerique) {
  9124.             return new JsonResponse(array('message' => 'Commande introuvable pour ref: ' $refcmdnum), 404);
  9125.         }
  9126.         // Check if order is paid
  9127.         if ($commandenumerique->getIdCommande()->getStatut()->getId() != 33) {
  9128.             return new JsonResponse(array('message' => 'Commande non payée'), 400);
  9129.         }
  9130.         $linkdownload $commandenumerique->getLinkdownload();
  9131.         // Check if ZIP needs to be generated
  9132.         // If linkdownload is numeric, it's the product ID and ZIP hasn't been generated yet
  9133.         $needsGeneration is_numeric($linkdownload) || $commandenumerique->getEtat() === 0;
  9134.         if (!$needsGeneration) {
  9135.             // ZIP name already set, check if file exists
  9136.             $zipPath $this->getParameter('kernel.project_dir') . '/public/ParentPhotosNumerique/' $linkdownload '.zip';
  9137.             if (!file_exists($zipPath)) {
  9138.                 $needsGeneration true;
  9139.             }
  9140.         }
  9141.         if ($needsGeneration) {
  9142.             try {
  9143.                 // linkdownload contains the product ID when not yet generated
  9144.                 $idProduit is_numeric($linkdownload) ? $linkdownload $linkdownload;
  9145.                 $produit $this->em->getRepository(Produit::class)->find($idProduit);
  9146.                 if (!$produit) {
  9147.                     return new JsonResponse(array('message' => 'Produit introuvable (ID: ' $idProduit ')'), 400);
  9148.                 }
  9149.                 // Generate ZIP using PrinterService (updates linkdownload to ZIP name on success)
  9150.                 $zipResult $printerService->PackPhotosNumerique($produit->getId(), $commandenumerique->getId());
  9151.                 if ($zipResult === null) {
  9152.                     return new JsonResponse(array(
  9153.                         'message' => 'La génération du pack a échoué. Le produit ne contient peut-être pas de photos, ou une erreur est survenue. Veuillez réessayer ou contacter le support.'
  9154.                     ), 500);
  9155.                 }
  9156.                 // Refresh entity to get updated linkdownload value
  9157.                 $this->em->getManager()->refresh($commandenumerique);
  9158.                 // Update state to ready for download
  9159.                 $commandenumerique->setEtat(1);
  9160.                 $this->em->getManager()->persist($commandenumerique);
  9161.                 $this->em->getManager()->flush();
  9162.             } catch (\Exception $e) {
  9163.                 return new JsonResponse(array('message' => 'Erreur lors de la génération du ZIP: ' $e->getMessage()), 500);
  9164.             }
  9165.         }
  9166.         // Get updated linkdownload (now contains ZIP name like "Pack_Numerique-CMD123_2025-12-18")
  9167.         $linkdownload $commandenumerique->getLinkdownload();
  9168.         if (is_numeric($linkdownload)) {
  9169.             return new JsonResponse(array(
  9170.                 'message' => 'La génération du pack n\'a pas pu aboutir. Veuillez réessayer ou contacter le support.'
  9171.             ), 500);
  9172.         }
  9173.         $zipPath $this->getParameter('kernel.project_dir') . '/public/ParentPhotosNumerique/' $linkdownload '.zip';
  9174.         // Download the ZIP (etat 1 or 2)
  9175.         if ($commandenumerique->getEtat() === || $commandenumerique->getEtat() === 2) {
  9176.             if (!file_exists($zipPath)) {
  9177.                 return new JsonResponse(array('message' => 'Fichier ZIP introuvable. Réessayez dans un instant ou contactez le support.'), 404);
  9178.             }
  9179.             // Mark as downloaded if first time
  9180.             if ($commandenumerique->getEtat() === 1) {
  9181.                 $commandenumerique->setEtat(2);
  9182.                 $commandenumerique->setDateTelechargement(new \DateTime());
  9183.                 $this->em->getManager()->persist($commandenumerique);
  9184.                 $this->em->getManager()->flush();
  9185.             }
  9186.             $response = new BinaryFileResponse($zipPath);
  9187.             $response->headers->set('Content-Type'"application/zip");
  9188.             $response->setContentDisposition(
  9189.                 ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  9190.                 basename($zipPath)
  9191.             );
  9192.             return $response;
  9193.         } else {
  9194.             return new JsonResponse(array('message' => 'État de commande invalide: ' $commandenumerique->getEtat()), 400);
  9195.         }
  9196.     }
  9197.     /**
  9198.      * @Route("/Parent/showpub" , name="showpub")
  9199.      */
  9200.     public function showpub()
  9201.     {
  9202.         /** @var User $user */
  9203.         $user $this->getUser();
  9204.         if (!$user) {
  9205.             return new JsonResponse(['status' => 'error''message' => 'User not found'], 400);
  9206.         }
  9207.         // Set showpubprod to true
  9208.         $user->setShowpubprod(1);
  9209.         // Save the changes to the database
  9210.         $this->em->getManager()->persist($user);
  9211.         $this->em->getManager()->flush();
  9212.         // Return a success response
  9213.         return new JsonResponse(['status' => 'success']);
  9214.     }
  9215.     /**
  9216.      * @Route("/Parent/Mentionslegales", name="mentionlegale")
  9217.      */
  9218.     public function Mentionslegales()
  9219.     {
  9220.         return $this->render('Parent/footer/mentionlegal.html.twig', []);
  9221.     }
  9222.     /**
  9223.      * @Route("/Parent/Conditongeneral", name="Conditongeneral")
  9224.      */
  9225.     public function Conditongeneral()
  9226.     {
  9227.         return $this->render('Parent/footer/Condition.html.twig', []);
  9228.     }
  9229.     /**
  9230.      * @Route("/Parent/PdfParentP/{id}", name="PdfParentP_Parent")
  9231.      */
  9232.     public function ExportPdfParentPayeParent(Request $request$id)
  9233.     {
  9234.         $sejourservice $this->sejourService;
  9235.         $session $this->session;
  9236.         // Récupérer le séjour pour un parent
  9237.         $sejour $sejourservice->getsejour($id);
  9238.         // Vérifier que le parent a accès à ce séjour
  9239.         $parentSejour $this->em->getRepository(ParentSejour::class)->findOneBy([
  9240.             'IdParent' => $this->getUser(),
  9241.             'idSejour' => $sejour
  9242.         ]);
  9243.         if (!$parentSejour) {
  9244.             throw $this->createAccessDeniedException('Vous n\'avez pas accès à ce séjour');
  9245.         }
  9246.         $pdf = new Fpdi();
  9247.         $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  9248.         $pdfFilepath $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
  9249.         $pageCount $pdf->setSourceFile($pdfFilepath);
  9250.         $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  9251.         $pdf->AddPage();
  9252.         $pdf->useImportedPage($pageId00);
  9253.         $pdf->SetFont("Arial"""10);
  9254.         $MotPass $sejour->getCodeSejour();
  9255.         $DateDebut $sejour->getDateCreationCode();
  9256.         $DateFin $sejour->getDateFinCode();
  9257.         $pdf->SetFont("Arial"""12);
  9258.         $DateDebutStr = ($DateDebut instanceof \DateTimeInterface) ? $DateDebut->format('d/m/Y') : ((is_string($DateDebut) && $DateDebut !== '') ? (new \DateTime($DateDebut))->format('d/m/Y') : '');
  9259.         $pdf->Text(88242$DateDebutStr);
  9260.         $pdf->SetFont("Arial"""12);
  9261.         $DateFinStr = ($DateFin instanceof \DateTimeInterface) ? $DateFin->format('d/m/Y') : ((is_string($DateFin) && $DateFin !== '') ? (new \DateTime($DateFin))->format('d/m/Y') : '');
  9262.         $pdf->Text(89258$DateFinStr);
  9263.         $pdf->Output("Mode d'emploi Parent 5sur5sejour.pdf""D");
  9264.         return new Response($pdf->Output(), 200, array('Content-Type' => 'application/pdf'));
  9265.     }
  9266.     /**
  9267.      * @Route("/Parent/PdfParentgrat/{id}", name="PdfParentgratt_Parent")
  9268.      */
  9269.     public function ExportPdfParentGratuitParent(Request $request$id)
  9270.     {
  9271.         $sejourservice $this->sejourService;
  9272.         $session $this->session;
  9273.         // Récupérer le séjour pour un parent
  9274.         $sejour $sejourservice->getsejour($id);
  9275.         // Vérifier que le parent a accès à ce séjour
  9276.         $parentSejour $this->em->getRepository(ParentSejour::class)->findOneBy([
  9277.             'IdParent' => $this->getUser(),
  9278.             'idSejour' => $sejour
  9279.         ]);
  9280.         if (!$parentSejour) {
  9281.             throw $this->createAccessDeniedException('Vous n\'avez pas accès à ce séjour');
  9282.         }
  9283.         $pdf = new Fpdi();
  9284.         $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  9285.         $pdfFilepath $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5.pdf";
  9286.         $pageCount $pdf->setSourceFile($pdfFilepath);
  9287.         $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  9288.         $pdf->AddPage();
  9289.         $pdf->useImportedPage($pageId00);
  9290.         $pdf->SetFont("Arial"""10);
  9291.         $MotPass $sejour->getCodeSejour();
  9292.         $DateDebut $sejour->getDateCreationCode();
  9293.         $DateFin $sejour->getDateFinCode();
  9294.         $pdf->SetFont("Arial"""12);
  9295.         $DateDebutStr = ($DateDebut instanceof \DateTimeInterface) ? $DateDebut->format('d/m/Y') : ((is_string($DateDebut) && $DateDebut !== '') ? (new \DateTime($DateDebut))->format('d/m/Y') : '');
  9296.         $pdf->Text(87237$DateDebutStr);
  9297.         $pdf->SetFont("Arial"""12);
  9298.         $DateFinStr = ($DateFin instanceof \DateTimeInterface) ? $DateFin->format('d/m/Y') : ((is_string($DateFin) && $DateFin !== '') ? (new \DateTime($DateFin))->format('d/m/Y') : '');
  9299.         $pdf->Text(88252$DateFinStr);
  9300.         $pdf->Output("Mode d'emploi Parent 5sur5sejour.pdf""D");
  9301.         return new Response($pdf->Output(), 200, array('Content-Type' => 'application/pdf'));
  9302.     }
  9303.     /**
  9304.      * @Route("/album/participate", name="album_participate", methods={"GET"})
  9305.      */
  9306.     public function albumParticipate(Request $request): Response
  9307.     {
  9308.         $user $this->getUser();
  9309.         if (!$user) {
  9310.             return $this->redirectToRoute('app_login');
  9311.         }
  9312.         $sejourId $this->session->get('Sejour');
  9313.         if ($sejourId) {
  9314.             return $this->redirectToRoute('album_participate_action', ['sejourId' => $sejourId]);
  9315.         }
  9316.         return $this->redirectToRoute('AccueilParent');
  9317.     }
  9318.     /*** ====================album builder new ============================= */
  9319.     /**
  9320.      * @Route("/Parent/album-builder", name="album_builder", methods={"GET"})
  9321.      */
  9322.     public function albumBuilder(Request $request): Response
  9323.     {
  9324.         // Set page menu in session
  9325.         $this->session->set('pageMenu''AlbumSejour');
  9326.         $random true;
  9327.         // Get current user
  9328.         $user $this->getUser();
  9329.         if (!$user) {
  9330.             $this->addFlash('error''You must be logged in to access the album builder.');
  9331.             return $this->redirectToRoute('app_login');
  9332.         }
  9333.         $userId $user->getId();
  9334.         // Determine mode: 'create' or 'edit'
  9335.         $mode $request->query->get('mode''create'); // default to 'create'
  9336.         $albumId $request->query->get('id'null);
  9337.         $existingAlbum null;
  9338.         $existingAlbumData null;
  9339.         $sejourId null;
  9340.         // EDIT MODE: Load album first to get the sejour ID
  9341.         if ($mode === 'edit' && $albumId) {
  9342.             $existingAlbum $this->em->getRepository(Produit::class)->findOneBy([
  9343.                 'id' => $albumId,
  9344.                 'iduser' => $userId  // Security: ensure album belongs to current user
  9345.             ]);
  9346.             // Verify the album belongs to this user
  9347.             if (!$existingAlbum) {
  9348.                 $this->addFlash('error''Album not found or access denied.');
  9349.                 return $this->redirectToRoute('AccueilParent');
  9350.             }
  9351.             // Get sejour from the album
  9352.             $sejourId $existingAlbum->getIdsjour()->getId();
  9353.             // Update session with this sejour
  9354.             $this->session->set('Sejour'$sejourId);
  9355.             // Load existing album data
  9356.             if ($existingAlbum->getPathpdf()) {
  9357.                 $decodedData json_decode($existingAlbum->getPathpdf(), true);
  9358.                 if ($decodedData && isset($decodedData['pages'])) {
  9359.                     $existingAlbumData $decodedData;
  9360.                 }
  9361.             }
  9362.         } else {
  9363.             // CREATE MODE: Get sejour from session
  9364.             $sejourId $this->session->get('Sejour');
  9365.             if (!$sejourId) {
  9366.                 $this->addFlash('error''No sejour selected. Please select a sejour first.');
  9367.                 return $this->redirectToRoute('AccueilParent');
  9368.             }
  9369.         }
  9370.         // Get sejour details (for both create and edit modes)
  9371.         $sejour $this->sejourService->getsejourpourparent($sejourId);
  9372.         if (!$sejour) {
  9373.             $this->addFlash('error''Sejour not found.');
  9374.             return $this->redirectToRoute('AccueilParent');
  9375.         }
  9376.         // Get partner information
  9377.         $partner $sejour->getIdPartenaire();
  9378.         $partnerName $partner $partner->getUsername() : null;
  9379.         $partnerLogo $partner $partner->getLogourl() : null;
  9380.         // Get liked photos for this user and sejour
  9381.         // These are Likephoto entities with SejourAttachment relationships
  9382.         $likedPhotos $this->sejourService->getlikephotosejour($userId$sejourId);
  9383.         $nbLikes count($likedPhotos);
  9384.         // Get all photos for this sejour (for statistics)
  9385.         $allPhotos $this->sejourService->getCombinedattachSejour($sejourId'photo');
  9386.         $totalPhotos count($allPhotos);
  9387.         // Transform liked photos into format expected by template
  9388.         $likedPhotosFormatted = [];
  9389.         foreach ($likedPhotos as $likePhoto) {
  9390.             $sejourAttach $likePhoto->getIdSejourAttchment();
  9391.             if ($sejourAttach) {
  9392.                 $realAttachment $sejourAttach->getIdAttchment();
  9393.                 if ($realAttachment) {
  9394.                     $likedPhotosFormatted[] = [
  9395.                         'id' => $realAttachment->getId(),
  9396.                         'path' => $realAttachment->getPath(),
  9397.                         'nom' => $realAttachment->getDescreption() ?? 'Photo',
  9398.                     ];
  9399.                 }
  9400.             }
  9401.         }
  9402.         // Check if user has no liked photos
  9403.         if ($nbLikes === 0) {
  9404.             $this->addFlash('warning''You haven\'t liked any photos yet. Like some photos first to add them to your album!');
  9405.         }
  9406.         $conn $this->em->getConnection();
  9407.         $sql "SELECT sa.id AS sejour_attachment_id, a.path, a.descreption,
  9408.                        DATE(sa.date_depot_attachement) AS photo_date
  9409.                 FROM sejour_attachment sa
  9410.                 JOIN attachment a ON sa.id_attchment = a.id
  9411.                 JOIN ref r ON a.idref = r.id
  9412.                 WHERE sa.id_sejour = :sejourId
  9413.                   AND sa.statut = 'public'
  9414.                   AND r.libiller = 'photo'
  9415.                 ORDER BY sa.date_depot_attachement ASC";
  9416.         $stmt $conn->prepare($sql);
  9417.         $rows $stmt->executeQuery(['sejourId' => $sejourId])->fetchAllAssociative();
  9418.         $dayDescriptions = [];
  9419.         foreach ($sejour->getJourdescripdate() as $jourDesc) {
  9420.             if ($jourDesc->getDatejourphoto()) {
  9421.                 $dateKey $jourDesc->getDatejourphoto()->format('Y-m-d');
  9422.                 $dayDescriptions[$dateKey] = $jourDesc->getDescription();
  9423.             }
  9424.         }
  9425.         $photosByDayMap = [];
  9426.         foreach ($rows as $row) {
  9427.             $date $row['photo_date'];
  9428.             $photosByDayMap[$date][] = [
  9429.                 'id' => $row['sejour_attachment_id'],
  9430.                 'path' => $row['path'],
  9431.                 'nom' => $row['descreption'] ?? 'Photo',
  9432.             ];
  9433.         }
  9434.         unset($rows);
  9435.         $photosByDay = [];
  9436.         foreach ($photosByDayMap as $date => $photos) {
  9437.             $photosByDay[] = [
  9438.                 'date' => $date,
  9439.                 'description' => $dayDescriptions[$date] ?? null,
  9440.                 'photos' => $photos,
  9441.                 'count' => count($photos),
  9442.             ];
  9443.         }
  9444.         unset($photosByDayMap);
  9445.         usort($photosByDay, function ($a$b) {
  9446.             return strtotime($a['date']) - strtotime($b['date']);
  9447.         });
  9448.         $totalPhotos 0;
  9449.         foreach ($photosByDay as $day) {
  9450.             $totalPhotos += $day['count'];
  9451.         }
  9452.         return $this->render('Parent/album_builder_parent.html.twig', [
  9453.             'sejour' => $sejour,
  9454.             'sejourId' => $sejourId,
  9455.             'partnerName' => $partnerName,
  9456.             'partnerLogo' => $partnerLogo,
  9457.             'likedPhotos' => $likedPhotosFormatted,
  9458.             'photosByDay' => $photosByDay,
  9459.             'like' => $likedPhotos,
  9460.             'totalPhotos' => $totalPhotos,
  9461.             'nbLikes' => $nbLikes,
  9462.             'existingAlbum' => $existingAlbum,
  9463.             'existingAlbumData' => $existingAlbumData,
  9464.             'mode' => $mode,
  9465.             'albumId' => $albumId,
  9466.         ]);
  9467.     }
  9468.     /**
  9469.      * @Route("/Parent/album/save", name="album_save", methods={"POST"})
  9470.      */
  9471.     public function saveAlbum(Request $request): JsonResponse
  9472.     {
  9473.         try {
  9474.             // Get current user
  9475.             $user $this->getUser();
  9476.             if (!$user) {
  9477.                 return new JsonResponse([
  9478.                     'success' => false,
  9479.                     'message' => 'You must be logged in to save an album.'
  9480.                 ], Response::HTTP_UNAUTHORIZED);
  9481.             }
  9482.             $userId $user->getId();
  9483.             // Get JSON data from request
  9484.             $data json_decode($request->getContent(), true);
  9485.             if (!$data || !isset($data['sejourId']) || !isset($data['pages'])) {
  9486.                 return new JsonResponse([
  9487.                     'success' => false,
  9488.                     'message' => 'Invalid data format.'
  9489.                 ], Response::HTTP_BAD_REQUEST);
  9490.             }
  9491.             $sejourId $data['sejourId'];
  9492.             $pages $data['pages'];
  9493.             $albumId $data['albumId'] ?? null// Get album ID if in edit mode
  9494.             $albumName $data['albumName'] ?? 'Mon Album'// Get custom name
  9495.             // Get sejour
  9496.             $sejour $this->sejourService->getsejourpourparent($sejourId);
  9497.             if (!$sejour) {
  9498.                 return new JsonResponse([
  9499.                     'success' => false,
  9500.                     'message' => 'Sejour not found.'
  9501.                 ], Response::HTTP_NOT_FOUND);
  9502.             }
  9503.             $album null;
  9504.             // EDIT MODE: Load existing album by ID
  9505.             if ($albumId) {
  9506.                 $album $this->em->getRepository(Produit::class)->findOneBy([
  9507.                     'id' => $albumId,
  9508.                     'iduser' => $userId  // Security: ensure album belongs to current user
  9509.                 ]);
  9510.                 // Verify album exists and belongs to user
  9511.                 if (!$album) {
  9512.                     return new JsonResponse([
  9513.                         'success' => false,
  9514.                         'message' => 'Album not found or access denied.'
  9515.                     ], Response::HTTP_FORBIDDEN);
  9516.                 }
  9517.                 // Update modification date and name
  9518.                 $album->setDate(new \DateTime());
  9519.                 $album->setLabele($albumName);
  9520.             }
  9521.             // CREATE MODE: Always create a new album
  9522.             else {
  9523.                 $album = new Produit();
  9524.                 $album->setIdsjour($sejour);
  9525.                 $album->setIduser($user);
  9526.                 $album->setLabele($albumName);
  9527.                 $album->setStatut('saved');
  9528.                 $album->setDate(new \DateTime());
  9529.                 $album->setType($this->em->getRepository(TypeProduit::class)->findOneBy(['id' => 2]));
  9530.                 $album->setIdConditionnement($this->em->getRepository(TypeProduitConditionnement::class)->findOneBy(['id' => 2]));
  9531.             }
  9532.             // Store album pages as JSON in the pathpdf field (reusing existing field)
  9533.             // This allows us to save complex album data without adding new columns
  9534.             $albumJsonData json_encode([
  9535.                 'sejourId' => $sejourId,
  9536.                 'pages' => $pages,
  9537.                 'savedAt' => (new \DateTime())->format('Y-m-d H:i:s'),
  9538.                 'version' => '2.0' // New album builder version
  9539.             ]);
  9540.             $album->setPathpdf($albumJsonData);
  9541.             $this->em->getManager()->persist($album);
  9542.             $this->em->getManager()->flush();
  9543.             return new JsonResponse([
  9544.                 'success' => true,
  9545.                 'message' => 'Album saved successfully!',
  9546.                 'albumId' => $album->getId()
  9547.             ]);
  9548.         } catch (\Exception $e) {
  9549.             return new JsonResponse([
  9550.                 'success' => false,
  9551.                 'message' => 'An error occurred while saving the album: ' $e->getMessage()
  9552.             ], Response::HTTP_INTERNAL_SERVER_ERROR);
  9553.         }
  9554.     }
  9555.     /**
  9556.      * Get the path for a SejourAttachment
  9557.      * Update this method based on your SejourAttachment entity structure
  9558.      */
  9559.     private function getAttachmentPath($attachment): string
  9560.     {
  9561.         // Common patterns for SejourAttachment - adjust based on your entity:
  9562.         // Option 1: If attachment has a getCheminphoto() method:
  9563.         if (method_exists($attachment'getCheminphoto')) {
  9564.             return $attachment->getCheminphoto();
  9565.         }
  9566.         // Option 2: If attachment has a getPath() method:
  9567.         if (method_exists($attachment'getPath')) {
  9568.             return $attachment->getPath();
  9569.         }
  9570.         // Option 3: If attachment has a getUrl() method:
  9571.         if (method_exists($attachment'getUrl')) {
  9572.             return $attachment->getUrl();
  9573.         }
  9574.         // Option 4: If you need to build the path from filename:
  9575.         if (method_exists($attachment'getFilename')) {
  9576.             return '/uploads/sejours/' $attachment->getFilename();
  9577.         }
  9578.         // Option 5: If attachment has a getCheminfichier() method:
  9579.         if (method_exists($attachment'getCheminfichier')) {
  9580.             return $attachment->getCheminfichier();
  9581.         }
  9582.         // Fallback
  9583.         return '/uploads/photos/default.jpg';
  9584.     }
  9585.     /**
  9586.      * Get the name/label for a SejourAttachment
  9587.      * Update this method based on your SejourAttachment entity structure
  9588.      */
  9589.     private function getAttachmentName($attachment): string
  9590.     {
  9591.         // Try different common method names
  9592.         if (method_exists($attachment'getNom')) {
  9593.             return $attachment->getNom() ?? 'Photo ' $attachment->getId();
  9594.         }
  9595.         if (method_exists($attachment'getLibele')) {
  9596.             return $attachment->getLibele() ?? 'Photo ' $attachment->getId();
  9597.         }
  9598.         if (method_exists($attachment'getFilename')) {
  9599.             return $attachment->getFilename() ?? 'Photo ' $attachment->getId();
  9600.         }
  9601.         if (method_exists($attachment'getLabel')) {
  9602.             return $attachment->getLabel() ?? 'Photo ' $attachment->getId();
  9603.         }
  9604.         // Fallback
  9605.         return 'Photo ' . ($attachment->getId() ?? 'unknown');
  9606.     }
  9607.     /**
  9608.      * View a saved album (read-only by default, with edit mode toggle)
  9609.      * 
  9610.      * @Route("/Parent/album/{id}", name="album_view", methods={"GET"})
  9611.      */
  9612.     public function viewAlbum(int $id): Response
  9613.     {
  9614.         // Check authentication
  9615.         $user $this->getUser();
  9616.         if (!$user) {
  9617.             $this->addFlash('error''You must be logged in to view albums.');
  9618.             return $this->redirectToRoute('app_login');
  9619.         }
  9620.         // Find album and verify ownership
  9621.         $album $this->em->getRepository(Produit::class)->findOneBy([
  9622.             'id' => $id,
  9623.             'iduser' => $user->getId()
  9624.         ]);
  9625.         if (!$album) {
  9626.             $this->addFlash('error''Album not found or you do not have permission to view it.');
  9627.             return $this->redirectToRoute('AccueilParent');
  9628.         }
  9629.         // Load album data from pathpdf field (stored as JSON)
  9630.         $albumJsonData $album->getPathpdf();
  9631.         $albumData null;
  9632.         $hasContent false;
  9633.         if ($albumJsonData) {
  9634.             $decodedData json_decode($albumJsonDatatrue);
  9635.             if ($decodedData && isset($decodedData['pages'])) {
  9636.                 $albumData $decodedData;
  9637.                 // Check if album has any content
  9638.                 $hasContent false;
  9639.                 foreach ($decodedData['pages'] as $page) {
  9640.                     if (!empty($page['photos']) || !empty($page['topText']) || !empty($page['bottomText'])) {
  9641.                         $hasContent true;
  9642.                         break;
  9643.                     }
  9644.                 }
  9645.             }
  9646.         }
  9647.         // If album is empty, show a message
  9648.         if (!$hasContent) {
  9649.             $this->addFlash('info''This album is empty. Click "Edit Album" to add photos.');
  9650.         }
  9651.         return $this->render('Parent/album_view.html.twig', [
  9652.             'album' => $album,
  9653.             'albumData' => $albumData,
  9654.             'hasContent' => $hasContent,
  9655.         ]);
  9656.     }
  9657.     /**
  9658.      * View album in builder/edit mode (alternative route if you want separate edit page)
  9659.      * 
  9660.      * @Route("/Parent/album/{id}/edit", name="album_edit", methods={"GET"})
  9661.      */
  9662.     public function editAlbum(int $id): Response
  9663.     {
  9664.         // Check authentication
  9665.         $user $this->getUser();
  9666.         if (!$user) {
  9667.             $this->addFlash('error''You must be logged in to edit albums.');
  9668.             return $this->redirectToRoute('app_login');
  9669.         }
  9670.         // Find album and verify ownership
  9671.         $album $this->em->getRepository(Produit::class)->findOneBy([
  9672.             'id' => $id,
  9673.             'iduser' => $user->getId()
  9674.         ]);
  9675.         if (!$album) {
  9676.             $this->addFlash('error''Album not found or you do not have permission to edit it.');
  9677.             return $this->redirectToRoute('AccueilParent');
  9678.         }
  9679.         // Get the sejour (trip) associated with this album to load liked photos
  9680.         $sejour $album->getIdSejour(); // Assuming relationship exists
  9681.         if (!$sejour) {
  9682.             $this->addFlash('error''Cannot edit album: associated trip not found.');
  9683.             return $this->redirectToRoute('AccueilParent');
  9684.         }
  9685.         // Load liked photos for this sejour
  9686.         $likedPhotos $this->em->getRepository(\App\Entity\Like::class)->findBy([
  9687.             'idSejour' => $sejour,
  9688.             'idUser' => $user
  9689.         ]);
  9690.         // Load existing album data
  9691.         $albumJsonData $album->getPathpdf();
  9692.         $existingAlbumData null;
  9693.         if ($albumJsonData) {
  9694.             $decodedData json_decode($albumJsonDatatrue);
  9695.             if ($decodedData && isset($decodedData['pages'])) {
  9696.                 $existingAlbumData $decodedData;
  9697.             }
  9698.         }
  9699.         // Render the album builder with edit mode enabled
  9700.         return $this->render('Parent/album_builder_parent.html.twig', [
  9701.             'sejour' => $sejour,
  9702.             'sejourId' => $sejour->getId(),
  9703.             'like' => $likedPhotos,
  9704.             'totalPhotos' => count($likedPhotos),
  9705.             'existingAlbum' => $album,
  9706.             'existingAlbumData' => $existingAlbumData,
  9707.             'mode' => 'edit',
  9708.             'albumId' => $id,
  9709.         ]);
  9710.     }
  9711.     /**
  9712.      * Delete an album
  9713.      * 
  9714.      * @Route("/Parent/album/{id}/delete", name="album_delete", methods={"POST"})
  9715.      */
  9716.     public function deleteAlbum(int $id): Response
  9717.     {
  9718.         // Check authentication
  9719.         $user $this->getUser();
  9720.         if (!$user) {
  9721.             $this->addFlash('error''You must be logged in to delete albums.');
  9722.             return $this->redirectToRoute('app_login');
  9723.         }
  9724.         // Find album and verify ownership
  9725.         $album $this->em->getRepository(Produit::class)->findOneBy([
  9726.             'id' => $id,
  9727.             'iduser' => $user->getId()
  9728.         ]);
  9729.         if (!$album) {
  9730.             $this->addFlash('error''Album not found or you do not have permission to delete it.');
  9731.             return $this->redirectToRoute('AccueilParent');
  9732.         }
  9733.         try {
  9734.             $albumName $album->getNom();
  9735.             $this->em->remove($album);
  9736.             $this->em->flush();
  9737.             $this->addFlash('success'"Album '{$albumName}' has been deleted successfully.");
  9738.         } catch (\Exception $e) {
  9739.             $this->addFlash('error''An error occurred while deleting the album. Please try again.');
  9740.         }
  9741.         return $this->redirectToRoute('AccueilParent');
  9742.     }
  9743.     /**=====================================Livre============================================***/
  9744.     /**
  9745.      * @Route("/Parent/livre-builder", name="livre_builder", methods={"GET"})
  9746.      */
  9747.     public function livreBuilder(Request $request): Response
  9748.     {
  9749.         // Set page menu in session
  9750.         $this->session->set('pageMenu''LivreSejour');
  9751.         $random true;
  9752.         // Get current user
  9753.         $user $this->getUser();
  9754.         if (!$user) {
  9755.             $this->addFlash('error''You must be logged in to access the livre builder.');
  9756.             return $this->redirectToRoute('app_login');
  9757.         }
  9758.         $userId $user->getId();
  9759.         // Determine mode: 'create' or 'edit'
  9760.         $mode $request->query->get('mode''create'); // default to 'create'
  9761.         $livreId $request->query->get('id'null);
  9762.         $existingLivre null;
  9763.         $existingLivreData null;
  9764.         $sejourId null;
  9765.         // EDIT MODE: Load livre first to get the sejour ID
  9766.         if ($mode === 'edit' && $livreId) {
  9767.             $existingLivre $this->em->getRepository(Produit::class)->findOneBy([
  9768.                 'id' => $livreId,
  9769.                 'iduser' => $userId  // Security: ensure livre belongs to current user
  9770.             ]);
  9771.             // Verify the livre belongs to this user
  9772.             if (!$existingLivre) {
  9773.                 $this->addFlash('error''Livre not found or access denied.');
  9774.                 return $this->redirectToRoute('AccueilParent');
  9775.             }
  9776.             // Get sejour from the livre
  9777.             $sejourId $existingLivre->getIdsjour()->getId();
  9778.             // Update session with this sejour
  9779.             $this->session->set('Sejour'$sejourId);
  9780.             // Load existing livre data
  9781.             if ($existingLivre->getPathpdf()) {
  9782.                 $decodedData json_decode($existingLivre->getPathpdf(), true);
  9783.                 if ($decodedData && isset($decodedData['pages'])) {
  9784.                     $existingLivreData $decodedData;
  9785.                 }
  9786.             }
  9787.         } else {
  9788.             // CREATE MODE: Get sejour from session
  9789.             $sejourId $this->session->get('Sejour');
  9790.             if (!$sejourId) {
  9791.                 $this->addFlash('error''No sejour selected. Please select a sejour first.');
  9792.                 return $this->redirectToRoute('AccueilParent');
  9793.             }
  9794.         }
  9795.         // Get sejour details (for both create and edit modes)
  9796.         $sejour $this->sejourService->getsejourpourparent($sejourId);
  9797.         if (!$sejour) {
  9798.             $this->addFlash('error''Sejour not found.');
  9799.             return $this->redirectToRoute('AccueilParent');
  9800.         }
  9801.         // Get partner information
  9802.         $partner $sejour->getIdPartenaire();
  9803.         $partnerName $partner $partner->getUsername() : null;
  9804.         $partnerLogo $partner $partner->getLogourl() : null;
  9805.         // Get liked photos for this user and sejour
  9806.         // These are Likephoto entities with SejourAttachment relationships
  9807.         $likedPhotos $this->sejourService->getlikephotosejour($userId$sejourId);
  9808.         $nbLikes count($likedPhotos);
  9809.         // Get all photos for this sejour (for statistics)
  9810.         $allPhotos $this->sejourService->getCombinedattachSejour($sejourId'photo');
  9811.         $totalPhotos count($allPhotos);
  9812.         // Transform liked photos into format expected by template
  9813.         $likedPhotosFormatted = [];
  9814.         foreach ($likedPhotos as $likePhoto) {
  9815.             $sejourAttach $likePhoto->getIdSejourAttchment();
  9816.             if ($sejourAttach) {
  9817.                 $realAttachment $sejourAttach->getIdAttchment();
  9818.                 if ($realAttachment) {
  9819.                     $likedPhotosFormatted[] = [
  9820.                         'id' => $realAttachment->getId(),
  9821.                         'path' => $realAttachment->getPath(),
  9822.                         'nom' => $realAttachment->getDescreption() ?? 'Photo',
  9823.                     ];
  9824.                 }
  9825.             }
  9826.         }
  9827.         $conn $this->em->getConnection();
  9828.         $sql "SELECT sa.id AS sejour_attachment_id, a.path, a.descreption,
  9829.                        DATE(sa.date_depot_attachement) AS photo_date
  9830.                 FROM sejour_attachment sa
  9831.                 JOIN attachment a ON sa.id_attchment = a.id
  9832.                 JOIN ref r ON a.idref = r.id
  9833.                 WHERE sa.id_sejour = :sejourId
  9834.                   AND sa.statut = 'public'
  9835.                   AND r.libiller = 'photo'
  9836.                 ORDER BY sa.date_depot_attachement ASC";
  9837.         $stmt $conn->prepare($sql);
  9838.         $rows $stmt->executeQuery(['sejourId' => $sejourId])->fetchAllAssociative();
  9839.         $dayDescriptions = [];
  9840.         foreach ($sejour->getJourdescripdate() as $jourDesc) {
  9841.             if ($jourDesc->getDatejourphoto()) {
  9842.                 $dateKey $jourDesc->getDatejourphoto()->format('Y-m-d');
  9843.                 $dayDescriptions[$dateKey] = $jourDesc->getDescription();
  9844.             }
  9845.         }
  9846.         $photosByDayMap = [];
  9847.         foreach ($rows as $row) {
  9848.             $date $row['photo_date'];
  9849.             $photosByDayMap[$date][] = [
  9850.                 'id' => $row['sejour_attachment_id'],
  9851.                 'path' => $row['path'],
  9852.                 'nom' => $row['descreption'] ?? 'Photo',
  9853.             ];
  9854.         }
  9855.         unset($rows);
  9856.         $photosByDay = [];
  9857.         foreach ($photosByDayMap as $date => $photos) {
  9858.             $photosByDay[] = [
  9859.                 'date' => $date,
  9860.                 'description' => $dayDescriptions[$date] ?? null,
  9861.                 'photos' => $photos,
  9862.                 'count' => count($photos),
  9863.             ];
  9864.         }
  9865.         unset($photosByDayMap);
  9866.         usort($photosByDay, function ($a$b) {
  9867.             return strtotime($a['date']) - strtotime($b['date']);
  9868.         });
  9869.         $totalPhotos 0;
  9870.         foreach ($photosByDay as $day) {
  9871.             $totalPhotos += $day['count'];
  9872.         }
  9873.         return $this->render('Parent/livre_builder.html.twig', [
  9874.             'sejour' => $sejour,
  9875.             'sejourId' => $sejourId,
  9876.             'partnerName' => $partnerName,
  9877.             'partnerLogo' => $partnerLogo,
  9878.             'likedPhotos' => $likedPhotosFormatted,
  9879.             'photosByDay' => $photosByDay,
  9880.             'like' => $likedPhotos,
  9881.             'totalPhotos' => $totalPhotos,
  9882.             'nbLikes' => $nbLikes,
  9883.             'existingLivre' => $existingLivre,
  9884.             'existingLivreData' => $existingLivreData,
  9885.             'mode' => $mode,
  9886.             'livreId' => $livreId,
  9887.         ]);
  9888.     }
  9889.     /**
  9890.      * @Route("/Parent/livre/save", name="livre_save", methods={"POST"})
  9891.      */
  9892.     public function saveLivre(Request $request): JsonResponse
  9893.     {
  9894.         try {
  9895.             // Get current user
  9896.             $user $this->getUser();
  9897.             if (!$user) {
  9898.                 return new JsonResponse([
  9899.                     'success' => false,
  9900.                     'message' => 'You must be logged in to save a livre.'
  9901.                 ], Response::HTTP_UNAUTHORIZED);
  9902.             }
  9903.             $userId $user->getId();
  9904.             // Get JSON data from request
  9905.             $data json_decode($request->getContent(), true);
  9906.             if (!$data || !isset($data['sejourId']) || !isset($data['pages'])) {
  9907.                 return new JsonResponse([
  9908.                     'success' => false,
  9909.                     'message' => 'Invalid data format.'
  9910.                 ], Response::HTTP_BAD_REQUEST);
  9911.             }
  9912.             $sejourId $data['sejourId'];
  9913.             $pages $data['pages'];
  9914.             $livreId $data['livreId'] ?? null// Get livre ID if in edit mode
  9915.             $livreName $data['livreName'] ?? 'Mon Livre'// Get custom name
  9916.             // Get sejour
  9917.             $sejour $this->sejourService->getsejourpourparent($sejourId);
  9918.             if (!$sejour) {
  9919.                 return new JsonResponse([
  9920.                     'success' => false,
  9921.                     'message' => 'Sejour not found.'
  9922.                 ], Response::HTTP_NOT_FOUND);
  9923.             }
  9924.             $livre null;
  9925.             // EDIT MODE: Load existing livre by ID
  9926.             if ($livreId) {
  9927.                 $livre $this->em->getRepository(Produit::class)->findOneBy([
  9928.                     'id' => $livreId,
  9929.                     'iduser' => $userId  // Security: ensure livre belongs to current user
  9930.                 ]);
  9931.                 // Verify livre exists and belongs to user
  9932.                 if (!$livre) {
  9933.                     return new JsonResponse([
  9934.                         'success' => false,
  9935.                         'message' => 'Livre not found or access denied.'
  9936.                     ], Response::HTTP_FORBIDDEN);
  9937.                 }
  9938.                 // Update modification date and name
  9939.                 $livre->setDate(new \DateTime());
  9940.                 $livre->setLabele($livreName);
  9941.             }
  9942.             // CREATE MODE: Always create a new livre
  9943.             else {
  9944.                 $livre = new Produit();
  9945.                 $livre->setIdsjour($sejour);
  9946.                 $livre->setIduser($user);
  9947.                 $livre->setLabele($livreName);
  9948.                 $livre->setStatut('saved');
  9949.                 $livre->setDate(new \DateTime());
  9950.                 $livre->setType($this->em->getRepository(TypeProduit::class)->findOneBy(['id' => 4]));
  9951.                 $livre->setIdConditionnement($this->em->getRepository(TypeProduitConditionnement::class)->findOneBy(['id' => 5]));
  9952.             }
  9953.             // Store livre pages as JSON in the pathpdf field (reusing existing field)
  9954.             // This allows us to save complex livre data without adding new columns
  9955.             $livreJsonData json_encode([
  9956.                 'sejourId' => $sejourId,
  9957.                 'pages' => $pages,
  9958.                 'savedAt' => (new \DateTime())->format('Y-m-d H:i:s'),
  9959.                 'version' => '2.0' // New livre builder version
  9960.             ]);
  9961.             $livre->setPathpdf($livreJsonData);
  9962.             $this->em->getManager()->persist($livre);
  9963.             $this->em->getManager()->flush();
  9964.             return new JsonResponse([
  9965.                 'success' => true,
  9966.                 'message' => 'Livre saved successfully!',
  9967.                 'livreId' => $livre->getId()
  9968.             ]);
  9969.         } catch (\Exception $e) {
  9970.             return new JsonResponse([
  9971.                 'success' => false,
  9972.                 'message' => 'An error occurred while saving the livre: ' $e->getMessage()
  9973.             ], Response::HTTP_INTERNAL_SERVER_ERROR);
  9974.         }
  9975.     }
  9976.     /**
  9977.      * @Route("/Parent/DetailsSejourAcc/EF171161", name="DetailsSejourAccParentFixed")
  9978.      */
  9979.     public function DetailsSejourAccParentFixed(Request $request)
  9980.     {
  9981.         $session $this->session;
  9982.         /** @var \App\Entity\User $user */
  9983.         $user $this->getUser();
  9984.         $userId $user $user->getId() : null;
  9985.         // Code séjour fixe
  9986.         $codeSejour 'EF171161';
  9987.         
  9988.         // Récupérer le séjour par son code
  9989.         $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $codeSejour]);
  9990.         
  9991.         if (!$sejour) {
  9992.             throw $this->createNotFoundException('Séjour non trouvé avec le code: ' $codeSejour);
  9993.         }
  9994.         $idSejour $sejour->getId();
  9995.         $dateCreationArch = clone $sejour->getDateFinCode();
  9996.         if ($dateCreationArch <= new \DateTime()) {
  9997.             return $this->render('Parent/SejourDepassee.html.twig');
  9998.         }
  9999.         $SEjourService $this->sejourService;
  10000.         $listeattachlikephoto $userId $SEjourService->getlikephotosejour($userId$idSejour) : [];
  10001.         $this->session->set('Sejour'$idSejour);
  10002.         $dateCreationArch = clone $sejour->getDateFinCode();
  10003.         if ($dateCreationArch <= new \DateTime()) {
  10004.             return $this->render('Parent/SejourDepassee.html.twig');
  10005.         }
  10006.         $session->set('pageMenu''MonSejour');
  10007.         $AllAttachements $SEjourService->getphotosVideosSejour($idSejour'original'$userId);
  10008.         $nbImages count($AllAttachements);
  10009.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  10010.         $positions $SEjourService->getsejourposition($idSejour);
  10011.         $photoLikes = [];
  10012.         foreach ($AllAttachements as $key => $group) {
  10013.             if ($key === 'total' || !isset($group['attachments'])) {
  10014.                 continue;
  10015.             }
  10016.             foreach ($group['attachments'] as $attach) {
  10017.                 if (!isset($attach['id_attchment'])) {
  10018.                     continue;
  10019.                 }
  10020.                 $libiller $attach['libiller'] ?? null;
  10021.                 if ($libiller !== 'video') {
  10022.                     $photoLikes[$attach['id_attchment']] = $this->sejourService->getTotallikesphotosejour($attach['id_attchment'], $idSejour);
  10023.                 }
  10024.             }
  10025.         }
  10026.         $em $this->em;
  10027.         $idAcc $sejour->getIdAcommp();
  10028.         
  10029.         //VERIFICATION DE L EXISTANCE DE LIVRE OU D ALBUM SEJOUR
  10030.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['statut' => 'Album_sejour''idsjour' => $sejour], ['id' => 'DESC']);
  10031.         $label "Livre_sejour" $sejour->getCodeSejour();
  10032.         $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  10033.         if ($livreSej == null) {
  10034.             $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  10035.         } else {
  10036.             $livreSejour $livreSej;
  10037.         }
  10038.         $attachementsCount $AllAttachements['total'] ?? 0;
  10039.         if (isset($AllAttachements['total'])) {
  10040.             unset($AllAttachements['total']);
  10041.         }
  10042.         $date = new \Datetime("midnight");
  10043.         $date->modify('+1 day');
  10044.         $date->modify('-1 seconds');
  10045.         // Share Booster - Calcul des statistiques du jour
  10046.         $today = new \DateTime('today');
  10047.         $tomorrow = new \DateTime('tomorrow');
  10048.         // Nombre d'uploads aujourd'hui par cet accompagnateur pour ce séjour
  10049.         $todayUploadedCount $em->getRepository(\App\Entity\SejourAttachment::class)
  10050.             ->createQueryBuilder('sa')
  10051.             ->select('COUNT(sa.id)')
  10052.             ->where('sa.idSejour = :sejourId')
  10053.             ->andWhere('sa.dateDepotAttachement >= :today')
  10054.             ->andWhere('sa.dateDepotAttachement < :tomorrow')
  10055.             ->setParameter('sejourId'$idSejour)
  10056.             ->setParameter('today'$today)
  10057.             ->setParameter('tomorrow'$tomorrow)
  10058.             ->getQuery()
  10059.             ->getSingleScalarResult();
  10060.         // Nombre total d'uploads aujourd'hui par tous les accompagnateurs (collectif)
  10061.         $collectiveTodayCount $em->getRepository(\App\Entity\SejourAttachment::class)
  10062.             ->createQueryBuilder('sa')
  10063.             ->select('COUNT(sa.id)')
  10064.             ->where('sa.dateDepotAttachement >= :today')
  10065.             ->andWhere('sa.dateDepotAttachement < :tomorrow')
  10066.             ->setParameter('today'$today)
  10067.             ->setParameter('tomorrow'$tomorrow)
  10068.             ->getQuery()
  10069.             ->getSingleScalarResult();
  10070.         // Objectif du jour (peut être personnalisé selon la structure)
  10071.         $targetDaily 15;
  10072.         // Vérifier si le séjour est terminé
  10073.         $sejourTermine $sejour->getDateFinSejour() < new \DateTime('today');
  10074.         // Vérifier si le séjour n'a pas encore commencé
  10075.         $sejourPasEncoreCommence $sejour->getDateDebutSejour() > new \DateTime('today');
  10076.         // Vérifier si on est après J+3 (3 jours après la fin du séjour)
  10077.         $dateFinSejourPlus3 = clone $sejour->getDateFinSejour();
  10078.         $dateFinSejourPlus3->modify('+3 days');
  10079.         $afterJplus3 = new \DateTime('today') > $dateFinSejourPlus3;
  10080.         // Calculer le total des parents et likes
  10081.         $totalParent $SEjourService->getTotalParent($idSejour);
  10082.         $totalLikes $SEjourService->getTotalLikesSejour($idSejour);
  10083.         $counts $SEjourService->countAll($idSejour);
  10084.         // Calculer les photos et messages du jour
  10085.         $photosDuJour 0;
  10086.         $messagesDuJour 0;
  10087.         foreach ($AllAttachements as $attach) {
  10088.             if (isset($attach['date_depot_attachement']) && $attach['date_depot_attachement'] instanceof \DateTime) {
  10089.                 if ($attach['date_depot_attachement']->format('Y-m-d') === $today->format('Y-m-d')) {
  10090.                     $photosDuJour++;
  10091.                 }
  10092.             }
  10093.         }
  10094.         foreach ($messages as $message) {
  10095.             if (isset($message['date_depot_attachement']) && $message['date_depot_attachement'] instanceof \DateTime) {
  10096.                 if ($message['date_depot_attachement']->format('Y-m-d') === $today->format('Y-m-d')) {
  10097.                     $messagesDuJour++;
  10098.                 }
  10099.             }
  10100.         }
  10101.         return $this->render('Parent/DetailsSejourAcc.html.twig', [
  10102.             "sejour" => $sejour,
  10103.             'listeattach' => $AllAttachements,
  10104.             'attachementsCount' => $attachementsCount,
  10105.             'albumAcc' => $albumAcc,
  10106.             "livreSejour" => $livreSejour,
  10107.             'nbImages' => $nbImages,
  10108.             'positions' => $positions,
  10109.             'dateexpretise' => $date,
  10110.             'messages' => $messages,
  10111.             'like' => $listeattachlikephoto,
  10112.             'nblike' => count($listeattachlikephoto),
  10113.             'photoLikes' => $photoLikes,
  10114.             'datefincode' => $sejour->getDateFinCode(),
  10115.             // Share Booster variables
  10116.             'targetDaily' => $targetDaily,
  10117.             'todayUploadedCount' => $todayUploadedCount,
  10118.             'collectiveTodayCount' => $collectiveTodayCount,
  10119.             // Variables Dashboard
  10120.             'sejourTermine' => $sejourTermine,
  10121.             'sejourPasEncoreCommence' => $sejourPasEncoreCommence,
  10122.             'afterJplus3' => $afterJplus3,
  10123.             'totalParent' => $totalParent,
  10124.             'totalLikes' => $totalLikes,
  10125.             'counts' => $counts,
  10126.             'photosDuJour' => $photosDuJour,
  10127.             'messagesDuJour' => $messagesDuJour,
  10128.         ]);
  10129.     }
  10130. }