src/Controller/EspaceParentController.php line 6015

Open in your IDE?
  1. <?php
  2. /*
  3.  * To change this license header, choose License Headers in Project Properties.
  4.  * To change this template file, choose Tools | Templates
  5.  * and open the template in the editor.
  6.  */
  7. namespace App\Controller;
  8. use Symfony\Component\Mailer\MailerInterface;
  9. use Swift_Message;
  10. use Symfony\Component\Mime\Email;
  11. use Unirest;
  12. use Swift_Image;
  13. use Dompdf\Dompdf;
  14. use App\Entity\Ref;
  15. use Dompdf\Options;
  16. use App\Entity\Page;
  17. use App\Entity\User;
  18. use Twig\Environment;
  19. use App\Entity\Panier;
  20. use App\Entity\Sejour;
  21. use App\Entity\Clipart;
  22. use App\Entity\Produit;
  23. use App\Entity\CommandeNumerique;
  24. use App\Entity\Typeref;
  25. use App\Entity\Commande;
  26. use App\Entity\Emailing;
  27. use App\Entity\Typeproduit;
  28. use App\Entity\ParentSejour;
  29. use App\Entity\PanierProduit;
  30. use App\Service\JetonService;
  31. use App\Entity\ComandeProduit;
  32. use App\Entity\SejourAttachment;
  33. use App\Service\PrinterService;
  34. use App\Entity\Likephoto;
  35. use App\Entity\Attachment;
  36. use App\Service\EmailsCmdService;
  37. use App\Entity\TypeProduitConditionnement;
  38. use App\Service\AttachementService;
  39. use App\Service\CarteService;
  40. use App\Service\ComandeService;
  41. use App\Service\EtablissementService;
  42. use App\Service\PayementService;
  43. use App\Service\PhotosFavorisService;
  44. use App\Service\SejourService;
  45. use App\Service\TypeProduiteService;
  46. use App\Service\UserService;
  47. use Doctrine\Persistence\ManagerRegistry;
  48. use Psr\Log\LoggerInterface;
  49. use Qipsius\TCPDFBundle\Controller\TCPDFController;
  50. use SebastianBergmann\Environment\Console;
  51. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  52. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  53. use Symfony\Component\HttpFoundation\Request;
  54. use Symfony\Component\HttpFoundation\Response;
  55. use Symfony\Component\Routing\Annotation\Route;
  56. use Symfony\Component\HttpFoundation\JsonResponse;
  57. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  58. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  59. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  60. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  61. use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
  62. use setasign\Fpdi\Fpdi;
  63. use setasign\Fpdi\PdfReader;
  64. class EspaceParentController extends AbstractController
  65. {
  66.     private $em;
  67.     private $session;
  68.     private $templating;
  69.     private $mailer;
  70.     private $symfonyMailer;
  71.     private $EmailServie;
  72.     private $urlGenerator;
  73.     private $commandeService;
  74.     private $printerService;
  75.     private $emailsCmdService;
  76.     private $userService;
  77.     private $typeProduiteService;
  78.     private $sejourService;
  79.     private $attachementService;
  80.     private $etablissementService;
  81.     private $payementService;
  82.     private $carteService;
  83.     private $photosFavorisService;
  84.     private $params;
  85.     private $tcpdf;
  86.     private $logger;
  87.     public function __construct(UrlGeneratorInterface $urlGeneratorManagerRegistry $emSessionInterface $session\Swift_Mailer $mailerMailerInterface $symfonyMailerEnvironment $templatingEmailsCmdService $EmailCommandeServiceComandeService $commandeServiceUserService $userServiceTypeProduiteService $typeProduiteServiceSejourService $sejourServiceAttachementService $attachementServiceEtablissementService $etablissementServicePayementService $payementServiceCarteService $carteServicePhotosFavorisService $photosFavorisServiceParameterBagInterface $paramsTCPDFController $tcpdfLoggerInterface $loggerPrinterService $printerServiceEmailsCmdService $emailsCmdService)
  88.     {
  89.         $this->em $em;
  90.         $this->session $session;
  91.         $this->templating $templating;
  92.         $this->mailer $mailer;
  93.         $this->symfonyMailer $symfonyMailer;
  94.         $this->EmailServie $EmailCommandeService;
  95.         $this->urlGenerator $urlGenerator;
  96.         $this->commandeService $commandeService;
  97.         $this->emailsCmdService $emailsCmdService;
  98.         $this->userService $userService;
  99.         $this->typeProduiteService $typeProduiteService;
  100.         $this->sejourService $sejourService;
  101.         $this->attachementService $attachementService;
  102.         $this->etablissementService $etablissementService;
  103.         $this->payementService $payementService;
  104.         $this->carteService $carteService;
  105.         $this->photosFavorisService $photosFavorisService;
  106.         $this->params $params;
  107.         $this->tcpdf $tcpdf;
  108.         $this->logger $logger;
  109.         $this->printerService $printerService;
  110.     }
  111.     /**
  112.      * @Route("/Parent/CreerAlbumSejourTest", name="CreerAlbumSejourTest")
  113.      */
  114.     public function CreerAlbumSejourTest(Request $request)
  115.     {
  116.         $serviceuser $this->etablissementService;
  117.         $page $request->get("pages");
  118.         $idsejour $request->get("id_du_sejour");
  119.         $prodid $request->get('idProd');
  120.         $nomprod $request->get('nomprod');
  121.         $stat $request->get('stat');
  122.         $version $request->get('new');
  123.         $user $this->getUser();
  124.         $Album $serviceuser->savealbumAcc($page$user$idsejour$prodid$stat$nomprod$version);
  125.         //Envoi des mails aux parents 
  126.         // Envoi SMS aux parents 
  127.         // Envoi mail proposition achat groupé au accompagnateur 
  128.         //YOSRA HERE
  129.         $PrentsConnextees $this->em->getRepository(ParentSejour::class)->findBy(array('idSejour' =>  $idsejour));
  130.         dd($PrentsConnextees);
  131.         return new response('done');
  132.     }
  133.     /**
  134.      * @Route("/Parent/DirectAchatAlbumm", name="DirectAchatAlbumm")
  135.      */
  136.     public function DirectAchatAlbumm(Request $request)
  137.     {
  138.         $session $this->session;
  139.         $serviceuser $this->etablissementService;
  140.         $page $request->get("pages");
  141.         $sejour $request->get("sejour");
  142.         $prodid $request->get('idProd');
  143.         $nomprod $request->get('nomprod');
  144.         $versionalbm $request->get('new');
  145.         $user $this->getUser();
  146.         $dateNow = new \Datetime();
  147.         $produit $session->get("produittype");
  148.         $produitcondi $session->get("produit");
  149.         $Album $serviceuser->savealbumParent($page$user$sejour$prodid$produit$produitcondi$nomprod$versionalbm);
  150.         $inser false;
  151.         $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  152.         $em $this->em;
  153.         $user $this->getUser();
  154.         $typeref $em->getRepository(Typeref::class)->find(8);
  155.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "achatdirect""typeref" => $typeref));
  156.         $panierTrace = new Panier();
  157.         $dateNow = new \Datetime();
  158.         $panierTrace->setDateCreation($dateNow);
  159.         $panierTrace->setCreerPar($user);
  160.         $panierTrace->setStatut($statutPanier);
  161.         $em->getManager()->persist($panierTrace);
  162.         $em->getManager()->flush();
  163.         $panierProduit = new PanierProduit();
  164.         $panierProduit->setIdProduit($Album);
  165.         $panierProduit->setIdPanier($panierTrace);
  166.         $em->getManager()->persist($panierProduit);
  167.         $em->getManager()->flush();
  168.         $panierProduit->setQuantite(1);
  169.         $panierProduit->setPrixTotal($Album->getIdConditionnement()->getMontantTTC());
  170.         $this->em->getManager()->persist($panierProduit);
  171.         $this->em->getManager()->flush();
  172.         return new response('achat direct done');
  173.     }
  174.     /**
  175.      * @Route("/Parent/Achat_direct", name="Achat_direct")
  176.      */
  177.     public function Achat_direct()
  178.     {
  179.         $em $this->em;
  180.         $session $this->session;
  181.         $idSejour $session->get("Sejour");
  182.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  183.         $typeref $em->getRepository(Typeref::class)->find(8);
  184.         $user $this->getUser();
  185.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "achatdirect""typeref" => $typeref));
  186.         $panier $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  187.         return $this->render('Parent/achatdirect.html.twig', ["user" => $user"sejour" => $sejour"panier" => $panier]);
  188.     }
  189.     /**
  190.      * @Route("/Parent/AccueilParent", name="AccueilParent")
  191.      */
  192.     public function AccueilParent(Request $requestLoggerInterface $loggerInterface): Response
  193.     {
  194.         $session $this->session;
  195.         /** @var \App\Entity\User $user */
  196.         $user $this->getUser();
  197.         $userId $user->getId();
  198.         $code $request->get("codeSejour");
  199.         $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  200.         if (isset($code)) {
  201.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  202.             if ($sejour == null) {
  203.                 $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  204.                 if ($sejour == null) {
  205.                     $this->session->set('rout''code');
  206.                     return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  207.                 }
  208.             } else {
  209.                 $this->session->set('Sejour'$sejour->getId());
  210.             }
  211.         }
  212.         if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
  213.             $code $session->get("Sejour");
  214.             $sejour $this->em->getRepository(Sejour::class)->find($code);
  215.         } else {
  216.             $code $request->get("codeSejour");
  217.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  218.         }
  219.         if ($sejour == null) {
  220.             $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  221.         }
  222.         if ($sejour == null) {
  223.             $this->session->set('rout''code');
  224.             return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  225.         }
  226.         // Vérifier le statut du séjour - statut 43 = en attente de paiement/activation
  227.         // IMPORTANT : Cette vérification s'applique à TOUS les codes (PF, PP, EP, EF)
  228.         // Même les codes gratuits (PF/EF) ne peuvent pas accéder si le séjour n'est pas activé
  229.         if ($sejour->getStatut() && $sejour->getStatut()->getId() == 43) {
  230.             return $this->render('Parent/SejourEnAttentePaiement.html.twig', [
  231.                 'sejour' => $sejour
  232.             ]);
  233.         }
  234.         $idSejour $sejour->getId();
  235.         $SEjourService $this->sejourService;
  236.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  237.         $this->session->set('Sejour'$idSejour);
  238.         $dateCreationArch = clone $sejour->getDateFinCode();
  239.         if ($dateCreationArch <= new \DateTime()) {
  240.             return $this->render('Parent/SejourDepassee.html.twig');
  241.         }
  242.         $session->set('pageMenu''MonSejour');
  243.         $AllAttachements $SEjourService->getphotosVideosSejour($idSejour'watermark'$userId);
  244.         $nbImages count($AllAttachements);
  245.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  246.         $positions $SEjourService->getsejourposition($idSejour);
  247.         $em $this->em;
  248.         $idAcc $sejour->getIdAcommp();
  249.         //VERIFICATION DE L EXISTANCE DE LIVRE OU D ALBUM SEJOUR 
  250.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  251.         if ($albumAcc == null) {
  252.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  253.         }
  254.         $label "Livre_sejour" $sejour->getCodeSejour();
  255.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  256.         $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  257.         if ($albumAcc == null) {
  258.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  259.         }
  260.         if ($livreSej == null) {
  261.             $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  262.         } else {
  263.             $livreSejour $livreSej;
  264.         }
  265.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  266.         if ($parentsejour == NULL) {
  267.             $parentsejour $SEjourService->inserparentsejour($userId$idSejour);
  268.         }
  269.         if ($AllAttachements == null && $messages == null) {
  270.             $this->session->set('rout''rout');
  271.             return $this->render('Parent/Aucunphoto.html.twig', [
  272.                 "sejour" => $sejour,
  273.                 "parentsejour" => $parentsejour
  274.             ]);
  275.         } else {
  276.             $attachementsCount $AllAttachements['total'];
  277.             unset($AllAttachements['total']);
  278.             // Déterminer le type de code (PF = gratuit, PP/EP = payant)
  279.             $codePrefix substr($sejour->getCodeSejour(), 02);
  280.             $isFreeAccess = ($codePrefix === 'PF' || $codePrefix === 'EF' || $sejour->getPaym() == 0);
  281.             
  282.             // PF et EF : accès direct (gratuit)
  283.             // PP et EP : nécessitent un paiement
  284.             if ($isFreeAccess) {
  285.                 $produits $this->typeProduiteService;
  286.                 $liste $produits->produitlistTypeConditionnement();
  287.                 $pubProd $user->getShowpubprod();
  288.                 $em $this->em;
  289.                 $idAcc $sejour->getIdAcommp();
  290.                 $nbmessages count($messages);
  291.                 $nblikes =  count($listeattachlikephoto);
  292.                 return $this->render('Parent/DetailsSejour.html.twig', [
  293.                     "sejour" => $sejour,
  294.                     'albumAcc' => $albumAcc,
  295.                     'favoritesCount' => $nblikes,
  296.                     "livreSejour" => $livreSejour,
  297.                     'listeattach' => $AllAttachements,
  298.                     'nbmessages' => $nbmessages,
  299.                     'attachementsCount' => $attachementsCount,
  300.                     'prod' => $liste,
  301.                     'nbImages' => $nbImages,
  302.                     'positions' => $positions,
  303.                     'messages' => $messages,
  304.                     'nblikes' => $nblikes,
  305.                     'likes' => $listeattachlikephoto,
  306.                     "parentsejour" => $parentsejour,
  307.                     'smsnotif' => $parentsejour->getSmsnotif(),
  308.                     'showpub' => $pubProd
  309.                 ]);
  310.             }
  311.             
  312.             // PP ou EP : vérifier le paiement
  313.             if ($codePrefix === 'PP' || $codePrefix === 'EP') {
  314.                 if ($parentsejour->getPayment() == 0) {
  315.                     $this->session->set('rout''rout');
  316.                     $ses_id session_id();
  317.                     return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  318.                 }
  319.                 if ($parentsejour->getPayment() == 1) {
  320.                     $produits $this->typeProduiteService;
  321.                     $liste $produits->produitlistTypeConditionnement();
  322.                     $pubProd $user->getShowpubprod();
  323.                     $nblikes count($listeattachlikephoto);
  324.                     return $this->render('Parent/DetailsSejour.html.twig', [
  325.                         "sejour" => $sejour,
  326.                         'favoritesCount' => $nblikes,
  327.                         'listeattach' => $AllAttachements,
  328.                         'attachementsCount' => $attachementsCount,
  329.                         'prod' => $liste,
  330.                         'albumAcc' => $albumAcc,
  331.                         "livreSejour" => $livreSejour,
  332.                         'nbImages' => $nbImages,
  333.                         'positions' => $positions,
  334.                         'messages' => $messages,
  335.                         'nblikes' => $nblikes,
  336.                         'likes' => $listeattachlikephoto,
  337.                         "parentsejour" => $parentsejour,
  338.                         'smsnotif' => $parentsejour->getSmsnotif(),
  339.                         'showpub' => $pubProd
  340.                     ]);
  341.                 }
  342.             }
  343.         }
  344.     }
  345.     /**
  346.      * @Route("/Parent/MessagesVocaux", name="MessagesVocaux")
  347.      */
  348.     public function MessagesVocaux_Accueil(Request $requestLoggerInterface $loggerInterface): Response
  349.     {
  350.         $session $this->session;
  351.         $session->set('pageMenu''MessagesVocaux');
  352.         /** @var \App\Entity\User $user */
  353.         $user $this->getUser();
  354.         $userId $user->getId();
  355.         $code $request->get("codeSejour");
  356.         $SEjourService $this->sejourService;
  357.         if (isset($code)) {
  358.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  359.             if ($sejour == null) {
  360.                 $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  361.                 if ($sejour == null) {
  362.                     $this->session->set('rout''code');
  363.                     return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  364.                 }
  365.             } else {
  366.                 $this->session->set('Sejour'$sejour->getId());
  367.             }
  368.         }
  369.         if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
  370.             $code $session->get("Sejour");
  371.             $sejour $this->em->getRepository(Sejour::class)->find($code);
  372.         } else {
  373.             $code $request->get("codeSejour");
  374.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  375.         }
  376.         if ($sejour == null) {
  377.             $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  378.         }
  379.         if ($sejour == null) {
  380.             $this->session->set('rout''code');
  381.             return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  382.         }
  383.         $idSejour $sejour->getId();
  384.         $this->session->set('Sejour'$idSejour);
  385.         $dateCreationArch = clone $sejour->getDateFinCode();
  386.         if ($dateCreationArch <= new \DateTime()) {
  387.             return $this->render('Parent/SejourDepassee.html.twig');
  388.         }
  389.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  390.         $nbImages count($AllAttachements);
  391.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  392.         $positions $SEjourService->getsejourposition($idSejour);
  393.         $em $this->em;
  394.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => "1"'statut' => 'saved'], ['id' => 'DESC']);
  395.         if ($albumAcc == null) {
  396.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  397.         }
  398.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  399.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  400.         if ($parentsejour == NULL) {
  401.             $parentsejour $SEjourService->inserparentsejour($userId$idSejour);
  402.         }
  403.         if ($AllAttachements == null && $messages == null) {
  404.             $this->session->set('rout''rout');
  405.             return $this->render('Parent/Aucunphoto.html.twig', [
  406.                 "sejour" => $sejour,
  407.                 "parentsejour" => $parentsejour
  408.             ]);
  409.         } else {
  410.             $attachementsCount $AllAttachements['total'];
  411.             unset($AllAttachements['total']);
  412.             // Déterminer le type de code (PF = gratuit, PP/EP = payant)
  413.             $codePrefix substr($sejour->getCodeSejour(), 02);
  414.             $isFreeAccess = ($codePrefix === 'PF' || $codePrefix === 'EF' || $sejour->getPaym() == 0);
  415.             
  416.             // PF et EF : accès direct (gratuit)
  417.             if ($isFreeAccess) {
  418.                 $produits $this->typeProduiteService;
  419.                 $liste $produits->produitlistTypeConditionnement();
  420.                 $pubProd $user->getShowpubprod();
  421.                 return $this->render('Parent/DetailsSejour.html.twig', [
  422.                     "sejour" => $sejour,
  423.                     'albumAcc' =>  $albumAcc,
  424.                     'listeattach' => $AllAttachements,
  425.                     'attachementsCount' => $attachementsCount,
  426.                     'prod' => $liste,
  427.                     'nbImages' => $nbImages,
  428.                     'positions' => $positions,
  429.                     'messages' => $messages,
  430.                     'like' => $listeattachlikephoto,
  431.                     "parentsejour" => $parentsejour,
  432.                     'smsnotif' => $parentsejour->getSmsnotif(),
  433.                     'showpub' => $pubProd
  434.                 ]);
  435.             }
  436.             
  437.             // PP ou EP : vérifier le paiement
  438.             if ($codePrefix === 'PP' || $codePrefix === 'EP') {
  439.                 if ($parentsejour->getPayment() == 0) {
  440.                     $this->session->set('rout''rout');
  441.                     $ses_id session_id();
  442.                     return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  443.                 }
  444.                 if ($parentsejour->getPayment() == 1) {
  445.                     $produits $this->typeProduiteService;
  446.                     $liste $produits->produitlistTypeConditionnement();
  447.                     $pubProd $user->getShowpubprod();
  448.                     return $this->render('Parent/DetailsSejour.html.twig', [
  449.                         "sejour" => $sejour,
  450.                         'favoritesCount' => count($listeattachlikephoto),
  451.                         'listeattach' => $AllAttachements,
  452.                         'attachementsCount' => $attachementsCount,
  453.                         'prod' => $liste,
  454.                         'nbImages' => $nbImages,
  455.                         'albumAcc' =>  $albumAcc,
  456.                         'positions' => $positions,
  457.                         'messages' => $messages,
  458.                         'like' => $listeattachlikephoto,
  459.                         "parentsejour" => $parentsejour,
  460.                         'smsnotif' => $parentsejour->getSmsnotif(),
  461.                         'showpub' => $pubProd
  462.                     ]);
  463.                 }
  464.             }
  465.         }
  466.     }
  467.     /**
  468.      * @Route("/Parent/MesFavoris_Accueil", name="MesFavoris_Accueil")
  469.      */
  470.     public function MesFavoris_Accueil(Request $requestLoggerInterface $loggerInterface): Response
  471.     {
  472.         $session $this->session;
  473.         $session->set('pageMenu''MesFavoris');
  474.         /** @var \App\Entity\User $user */
  475.         $user $this->getUser();
  476.         $userId $user->getId();
  477.         $code $request->get("codeSejour");
  478.         $SEjourService $this->sejourService;
  479.         if (isset($code)) {
  480.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  481.             if ($sejour == null) {
  482.                 $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  483.                 if ($sejour == null) {
  484.                     $this->session->set('rout''code');
  485.                     return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  486.                 }
  487.             } else {
  488.                 $this->session->set('Sejour'$sejour->getId());
  489.             }
  490.         }
  491.         if ($session->has('paymentmoniteco') || $session->get("Sejour") != "" || $session->get("Sejour") != null) {
  492.             $code $session->get("Sejour");
  493.             $sejour $this->em->getRepository(Sejour::class)->find($code);
  494.         } else {
  495.             $code $request->get("codeSejour");
  496.             $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $code]);
  497.         }
  498.         if ($sejour == null) {
  499.             $sejour $this->em->getRepository(Sejour::class)->USeOldCodes($code);
  500.         }
  501.         if ($sejour == null) {
  502.             $this->session->set('rout''code');
  503.             return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 1'smsnotif' => $user->getSmsnotif()]);
  504.         }
  505.         $idSejour $sejour->getId();
  506.         $this->session->set('Sejour'$idSejour);
  507.         $dateCreationArch = clone $sejour->getDateFinCode();
  508.         $em $this->em;
  509.         $idAcc $sejour->getIdAcommp();
  510.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  511.         $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  512.         if ($albumAcc == null) {
  513.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  514.         }
  515.         if ($dateCreationArch <= new \DateTime()) {
  516.             return $this->render('Parent/SejourDepassee.html.twig');
  517.         }
  518.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  519.         $nbImages count($AllAttachements);
  520.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  521.         $positions $SEjourService->getsejourposition($idSejour);
  522.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  523.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  524.         if ($parentsejour == NULL) {
  525.             $parentsejour $SEjourService->inserparentsejour($userId$idSejour);
  526.         }
  527.         if ($AllAttachements == null && $messages == null) {
  528.             $this->session->set('rout''rout');
  529.             return $this->render('Parent/Aucunphoto.html.twig', [
  530.                 "sejour" => $sejour,
  531.                 "parentsejour" => $parentsejour
  532.             ]);
  533.         } else {
  534.             $attachementsCount $AllAttachements['total'];
  535.             unset($AllAttachements['total']);
  536.             // Déterminer le type de code (PF = gratuit, PP/EP = payant)
  537.             $codePrefix substr($sejour->getCodeSejour(), 02);
  538.             $isFreeAccess = ($codePrefix === 'PF' || $codePrefix === 'EF' || $sejour->getPaym() == 0);
  539.             
  540.             // PF et EF : accès direct (gratuit)
  541.             if ($isFreeAccess) {
  542.                 $produits $this->typeProduiteService;
  543.                 $liste $produits->produitlistTypeConditionnement();
  544.                 $pubProd $user->getShowpubprod();
  545.                 $em $this->em;
  546.                 $idAcc $sejour->getIdAcommp();
  547.                 $label "Livre_sejour" $sejour->getCodeSejour();
  548.                 $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  549.                 $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  550.                 if ($albumAcc == null) {
  551.                     $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  552.                 }
  553.                 if ($livreSej == null) {
  554.                     $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  555.                 }
  556.                 return $this->render('Parent/DetailsSejour.html.twig', [
  557.                     "sejour" => $sejour,
  558.                     "livreSejour" => $livreSejour,
  559.                     "sejour" => $sejour,
  560.                     'listeattach' => $AllAttachements,
  561.                     'attachementsCount' => $attachementsCount,
  562.                     'prod' => $liste,
  563.                     'nbImages' => $nbImages,
  564.                     'positions' => $positions,
  565.                     'messages' => $messages,
  566.                     'like' => $listeattachlikephoto,
  567.                     "parentsejour" => $parentsejour,
  568.                     'smsnotif' => $parentsejour->getSmsnotif(),
  569.                     'showpub' => $pubProd,
  570.                     'albumAcc' => $albumAcc,
  571.                 ]);
  572.             }
  573.             
  574.             // PP ou EP : vérifier le paiement
  575.             if ($codePrefix === 'PP' || $codePrefix === 'EP') {
  576.                 if ($parentsejour->getPayment() == 0) {
  577.                     $this->session->set('rout''rout');
  578.                     $ses_id session_id();
  579.                     return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  580.                 }
  581.                 if ($parentsejour->getPayment() == 1) {
  582.                     $produits $this->typeProduiteService;
  583.                     $liste $produits->produitlistTypeConditionnement();
  584.                     $pubProd $user->getShowpubprod();
  585.                     return $this->render('Parent/DetailsSejour.html.twig', [
  586.                         "sejour" => $sejour,
  587.                         'favoritesCount' => count($listeattachlikephoto),
  588.                         'listeattach' => $AllAttachements,
  589.                         'attachementsCount' => $attachementsCount,
  590.                         'prod' => $liste,
  591.                         'nbImages' => $nbImages,
  592.                         'positions' => $positions,
  593.                         'messages' => $messages,
  594.                         'like' => $listeattachlikephoto,
  595.                         "parentsejour" => $parentsejour,
  596.                         'smsnotif' => $parentsejour->getSmsnotif(),
  597.                         'showpub' => $pubProd
  598.                     ]);
  599.                 }
  600.             }
  601.         }
  602.     }
  603.     /**
  604.      * @Route("/Parent/DetailsSejour", name="DetailsSejour")
  605.      */
  606.     public function ModifierSejour()
  607.     {
  608.         $SEjourService $this->sejourService;
  609.         $sejour $SEjourService->getsejour(3);
  610.         $listeattach $SEjourService->getatachmentsejour(3);
  611.         $positions $SEjourService->getsejourposition(3);
  612.         $messages $SEjourService->getsejourmessage(3);
  613.         //dd($messages);
  614.         $produits $this->typeProduiteService;
  615.         $liste $produits->produitlistTypeConditionnement();
  616.         return $this->render('Parent/DetailsSejour.html.twig', [
  617.             'prod' => $liste,
  618.             'sejour' => $sejour,
  619.             'listeattach' => $listeattach,
  620.             'positions' => $positions,
  621.             'messages' => $messages,
  622.         ]);
  623.     }
  624.     /**
  625.      * @Route("/Parent/listefavorie", name="listefavorie")
  626.      */
  627.     public function listefavorie()
  628.     {
  629.         $SEjourService $this->sejourService;
  630.         /** @var \App\Entity\User $user */
  631.         $user $this->getUser();
  632.         $userId $user->getId();
  633.         $session $this->session;
  634.         $session->set('pageMenu''');
  635.         $idSejour $session->get("Sejour");
  636.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  637.         dd($listeattachlikephoto);
  638.         return ('yoopii');
  639.     }
  640.     /**
  641.      * @Route("/Parent/Store", name="boutique5sur5")
  642.      */
  643.     public function boutique5sur5()
  644.     {
  645.         $SEjourService $this->sejourService;
  646.         /** @var \App\Entity\User $userId */
  647.         $userId $this->getUser();
  648.         $userId $userId->getId();
  649.         $session $this->session;
  650.         $session->set('pageMenu''boutique5su5');
  651.         $idSejour $session->get("Sejour");
  652.         $sejour $SEjourService->getsejourpourparent($idSejour);
  653.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  654.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  655.         $messages $SEjourService->getsejourmessage($idSejour);
  656.         $nbImages count($listeattach);
  657.         $nbmessages count($messages);
  658.         $produit $this->typeProduiteService;
  659.         $liste $produit->produitlistTypeConditionnement();
  660.         $idAcc $sejour->getIdAcommp();
  661.         $em $this->em;
  662.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  663.         $nbLikes count($listeattachlikephoto);
  664.         // dd($liste);
  665.         return $this->render('Parent/boutique_5sur5.html.twig', [
  666.             "sejour" => $sejour,
  667.             'like' => $listeattachlikephoto,
  668.             'produit' => $liste,
  669.             'albumAcc' => $albumAcc,
  670.             'nbImages' => $nbImages,
  671.             'nbmessages' => $nbmessages,
  672.             'nbLikes' => $nbLikes
  673.         ]);
  674.     }
  675.     /*public function maSelection()
  676.     {
  677.         $SEjourService = $this->sejourService;
  678.         $user = $this->getUser();        
  679.         $userId = $user->getId();
  680.         $user = $this->getUser();
  681.         $session = $this->session;
  682.         $session->set('pageMenu', '');
  683.         $idSejour = $session->get("Sejour");
  684.         $sejour = $SEjourService->getsejourpourparent($idSejour);
  685.         $listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
  686.         $produit = $this->typeProduiteService;
  687.         $liste = $produit->produitlistTypeConditionnement();
  688.         $idAcc = $sejour->getIdAcommp();
  689.         $em = $this->em;
  690.         $albumAcc = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $idAcc, 'statut' => 'saved'], ['id' => 'DESC']);
  691.         // dd($liste);
  692.         return $this->render('Parent/VoirMaSelection.html.twig', [
  693.             "sejour" => $sejour,
  694.             'like' => $listeattachlikephoto, 'produit' => $liste, 'albumAcc' => $albumAcc
  695.         ]);
  696.     }*/
  697.     /**
  698.      * @Route("/Parent/MaSelection", name="maSelection")
  699.      */
  700.     public function maSelection()
  701.     {
  702.         //Yosra
  703.         $nbLikes 0;
  704.         $SEjourService $this->sejourService;
  705.         $session $this->session;
  706.         $session->set('pageMenu''Meselection');
  707.         $idSejour $session->get("Sejour");
  708.         /** @var \App\Entity\User $user */
  709.         $user $this->getUser();
  710.         $iduser $user->getId();
  711.         $SEjourService $this->sejourService;
  712.         $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  713.         $sejour $SEjourService->getsejour($idSejour);
  714.         $positions $SEjourService->getsejourposition($idSejour);
  715.         //$messages = $SEjourService->getsejourmessage($idSejour);
  716.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  717.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  718.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  719.         $nbLikes count($listeattachlikephoto);
  720.         /* $listeattach = $SEjourService->getatachmentsejour($idSejour);
  721.         $listeVideo = $SEjourService->getVideosejour($idSejour);
  722.         $AllAttachements = array_merge_recursive($listeattach, $listeVideo); */
  723.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  724.         $attachementsCount $AllAttachements['total'];
  725.         unset($AllAttachements['total']);
  726.         $produits $this->typeProduiteService;
  727.         $liste $produits->produitlistTypeConditionnement();
  728.         $pubProd $user->getShowpubprod();
  729.         return $this->render('Parent/DetailsSejour.html.twig', [
  730.             "sejour" => $sejour,
  731.             "listeattach" => $AllAttachements,
  732.             'attachementsCount' => $attachementsCount,
  733.             'positions' => $positions,
  734.             'messages' => $messages,
  735.             'likes' => $listeattachlikephoto,
  736.             'like' => $listeattachlikephoto,
  737.             'nblikes' => $nbLikes,
  738.             'nbImages' =>   $attachementsCount,
  739.             "parentsejour" => $parentsejour,
  740.             'prod' => $liste,
  741.             'smsnotif' => $parentsejour->getSmsnotif(),
  742.             'showpub' => $pubProd
  743.         ]);
  744.     }
  745.     /**
  746.      * @Route("/Parent/MesPhotosPerso", name="mesPhotosperso")
  747.      */
  748.     public function mesPhotosperso()
  749.     {  //Yosra
  750.         $SEjourService $this->sejourService;
  751.         $session $this->session;
  752.         $session->set('pageMenu''Meselection');
  753.         $idSejour $session->get("Sejour");
  754.         /** @var \App\Entity\User $user */
  755.         $user $this->getUser();
  756.         $iduser $user->getId();
  757.         $SEjourService $this->sejourService;
  758.         $sejour $SEjourService->getsejour($idSejour);
  759.         $positions $SEjourService->getsejourposition($idSejour);
  760.         $messages $SEjourService->getsejourmessage($idSejour);
  761.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  762.         $listeattachlikephoto $this->em->getRepository(SejourAttachment::class)->findBy(['idParent' => $iduser'statut' => "private"'idSejour' => $sejour]);
  763.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  764.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  765.         $listeVideo $SEjourService->getVideosejour($idSejour);
  766.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  767.         $attachementsCount count($listeattach);
  768.         $nbImages count($listeattachlikephoto);
  769.         $produits $this->typeProduiteService;
  770.         $liste $produits->produitlistTypeConditionnement();
  771.         return $this->render('Parent/MesPhotosPerso.html.twig', [
  772.             "sejour" => $sejour,
  773.             'attachementsCount' => $attachementsCount,
  774.             'listeattach' => $AllAttachements,
  775.             'positions' => $positions,
  776.             'nbImages' => $nbImages,
  777.             'messages' => $messages,
  778.             'likes' => $listeattachlikephoto,
  779.             "parentsejour" => $parentsejour,
  780.             'prod' => $liste,
  781.             'smsnotif' => $parentsejour->getSmsnotif()
  782.         ]);
  783.     }
  784.     /**
  785.      * @Route("/Parent/achatBoiteVocale", name="achatBoiteVocale")
  786.      */
  787.     public function achatBoiteVocale()
  788.     {
  789.         $this->session->set('rout''rout');
  790.         $session $this->session;
  791.         /** @var \App\Entity\User $user */
  792.         $user $this->getUser();
  793.         $iduser $user->getId();
  794.         $idSejour $session->get("Sejour");
  795.         $ses_id session_id();
  796.         $SEjourService $this->sejourService;
  797.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  798.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  799.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  800.         return $this->render('Parent/achatBoiteVocale.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  801.     }
  802.     /**
  803.      * @Route("/Parent/achatsejour", name="achatsejour")
  804.      */
  805.     public function achatsejour()
  806.     {
  807.         $this->session->set('rout''rout');
  808.         $session $this->session;
  809.         /** @var \App\Entity\User $user */
  810.         $user $this->getUser();
  811.         $iduser $user->getId();
  812.         $idSejour $session->get("Sejour");
  813.         $ses_id session_id();
  814.         $SEjourService $this->sejourService;
  815.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  816.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  817.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  818.         return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $parentsejour]);
  819.     }
  820.     /**
  821.      * @Route("/Parent/CodeSejour", name="CodeSejour")
  822.      */
  823.     public function CodeSejour()
  824.     {
  825.         /** @var \App\Entity\User $user */
  826.         $user $this->getUser();
  827.         $userId $user->getId();
  828.         $this->session->set('rout''code');
  829.         return $this->render('Parent/EntrerVotreCodeSejour.html.twig', ['user' => $user"defaultval" => 0'smsnotif' => $user->getSmsnotif()]);
  830.     }
  831.     /** @Route("/Parent/produits", name="produit_parent")
  832.      */
  833.     public function produitsparent()
  834.     {
  835.         $SEjourService $this->sejourService;
  836.         $produitparent $this->typeProduiteService;
  837.         /** @var \App\Entity\User $user */
  838.         $user $this->getUser();
  839.         $userId $user->getId();
  840.         $session $this->session;
  841.         $session->set('pageMenu''');
  842.         $idSejour $session->get("Sejour");
  843.         $listproduit $produitparent->produitparent();
  844.         return ('yoopii');
  845.     }
  846.     /**
  847.      * @Route("/Parent/AucunePhoto", name="AucunePhoto")
  848.      * */
  849.     public function premiercnx()
  850.     {
  851.         $this->session->set('rout''rout');
  852.         return $this->render('Parent/Aucunphoto.html.twig');
  853.     }
  854.     /**
  855.      * @Route("/Parent/notif", name="notif_parent",methods={"POST","GET"})
  856.      */
  857.     public function notif_parent(Request $request)
  858.     {
  859.         $UserService $this->userService;
  860.         $session $this->session;
  861.         $session->set('pageMenu''');
  862.         $idSejour $session->get("Sejour");
  863.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  864.         /** @var \App\Entity\User $user */
  865.         $user $this->getUser();
  866.         $iduser $user->getId();
  867.         $sms $request->get("sms");
  868.         $mail $request->get('mail');
  869.         $refaverti $request->get('refaverti');
  870.         //$ville = $request->get("nonnotif");
  871.         $parentsejour $UserService->notifparentsejour($mail$sms$idSejour$iduser$refaverti);
  872.         return new JsonResponse('done');
  873.     }
  874.     /**
  875.      * @Route("/Parent/passerconnxion", name="notif_parenpasserconnxion",methods={"POST","GET"})
  876.      */
  877.     public function passerconnxion(Request $request)
  878.     {
  879.         $UserService $this->userService;
  880.         $session $this->session;
  881.         $session->set('pageMenu''');
  882.         $idSejour $session->get("Sejour");
  883.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  884.         /** @var \App\Entity\User $user */
  885.         $user $this->getUser();
  886.         $iduser $user->getId();
  887.         $SEjourService $this->sejourService;
  888.         $setparentsejour $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  889.         $sejour $SEjourService->getsejour($idSejour);
  890.         $positions $SEjourService->getsejourposition($idSejour);
  891.         $messages $SEjourService->getsejourmessage($idSejour);
  892.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  893.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  894.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  895.         if (sizeof($sejour->getAttachements()) == 0) {
  896.             return new JsonResponse('0');
  897.         } else {
  898.             return new JsonResponse('1');
  899.         }
  900.     }
  901.     /**
  902.      * @Route("/Parent/sejourParent", name="sejourParent_5sur5")
  903.      * */
  904.     public function sejourParent()
  905.     {
  906.         $SEjourService $this->sejourService;
  907.         $UserService $this->userService;
  908.         $session $this->session;
  909.         $session->set('pageMenu''');
  910.         $idSejour $session->get("Sejour");
  911.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  912.         /** @var \App\Entity\User $user */
  913.         $user $this->getUser();
  914.         $iduser $user->getId();
  915.         $SEjourService $this->sejourService;
  916.         $setparentsejour $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  917.         $sejour $SEjourService->getsejour($idSejour);
  918.         $positions $SEjourService->getsejourposition($idSejour);
  919.         $messages $SEjourService->getsejourmessage($idSejour);
  920.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  921.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  922.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  923.         $nbImages count($listeattach);
  924.         $listeVideo $SEjourService->getVideosejour($idSejour);
  925.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  926.         $produits $this->typeProduiteService;
  927.         $liste $produits->produitlistTypeConditionnement();
  928.         $pubProd $user->getShowpubprod();
  929.         return $this->render('Parent/DetailsSejour.html.twig', [
  930.             "sejour" => $sejour,
  931.             'listeattach' => $AllAttachements,
  932.             'positions' => $positions,
  933.             'nbImages' => $nbImages,
  934.             'messages' => $messages,
  935.             'like' => $listeattachlikephoto,
  936.             "parentsejour" => $parentsejour,
  937.             'prod' => $liste,
  938.             'smsnotif' => $parentsejour->getSmsnotif(),
  939.             'showpub' => $pubProd
  940.         ]);
  941.     }
  942.     /**
  943.      * @Route("/Parent/sejourVide", name="sejourvideee")
  944.      * */
  945.     public function sejourvide()
  946.     {
  947.         $this->session->set('rout''code');
  948.         $SEjourService $this->sejourService;
  949.         $UserService $this->userService;
  950.         $session $this->session;
  951.         $session->set('pageMenu''');
  952.         $idSejour $session->get("Sejour");
  953.         // $sejour = $sejourservice->getsejourpourparent($idSejour);
  954.         /** @var \App\Entity\User $user */
  955.         $user $this->getUser();
  956.         $iduser $user->getId();
  957.         $SEjourService $this->sejourService;
  958.         $setparentsejour $SEjourService->inserparentsejourPayenet($iduser$idSejour);
  959.         $sejour $SEjourService->getsejour($idSejour);
  960.         $positions $SEjourService->getsejourposition($idSejour);
  961.         $messages $SEjourService->getsejourmessage($idSejour);
  962.         $parentsejour $SEjourService->getparentsejour($iduser$idSejour);
  963.         $listeattachlikephoto $SEjourService->getlikephotosejour($iduser$idSejour);
  964.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  965.         return $this->render('Parent/Aucunphoto.html.twig', [
  966.             "sejour" => $sejour,
  967.             "parentsejour" => $parentsejour
  968.         ]);
  969.     }
  970.     /**
  971.      * @Route("Parent/EditContenuPage", name="EditContenuPage")
  972.      */
  973.     public function EditContenuPageParent()
  974.     {
  975.         $em $this->em;
  976.         $Albumproduct $em->getRepository(Produit::class)->findBy(['idConditionnement' => 4]);
  977.         foreach ($Albumproduct as $album) {
  978.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $album]);
  979.             foreach ($AllPages as $p) {
  980.                 $arrayexploded $p->getCouleurbordure();
  981.                 $arrayexploded1 str_replace("font-size""fontSize"$arrayexploded);
  982.                 $p->setCouleurbordure($arrayexploded1);
  983.                 $em->getManager()->persist($p);
  984.                 $em->getManager()->flush();
  985.             }
  986.         }
  987.         return new Response('ok');
  988.     }
  989.     /**
  990.      * @Route("Parent/AjoutAlbum", name="EditionAlbum")
  991.      */
  992.     public function EditionAlbumParent()
  993.     {
  994.         $SEjourService $this->sejourService;
  995.         $em $this->em;
  996.         /** @var \App\Entity\User $user */
  997.         $user $this->getUser();
  998.         $userId $user->getId();
  999.         $session $this->session;
  1000.         $session->set('pageMenu''AlbumSejour');
  1001.         $idSejour $session->get("Sejour");
  1002.         $clipart null;
  1003.         $random true;
  1004.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1005.         $idAcc $sejour->getIdAcommp();
  1006.         $part $sejour->getIdPartenaire();
  1007.         $nompart $part->getUsername();
  1008.         $logopart $part->getLogourl();
  1009.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1010.         $nbLikes count($listeattachlikephoto);
  1011.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1012.         $listerandom $listeattach;
  1013.         $nbPhoto count($listeattach);
  1014.         $AllPagesAcc null;
  1015.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
  1016.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1017.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1018.         if ($albumAcc) {
  1019.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1020.         }
  1021.         $allpagesResult = array();
  1022.         $tabacc = array();
  1023.         $tabacc1 = array();
  1024.         if ($random == true) {
  1025.             foreach ($AllPages as $p) {
  1026.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1027.                 $rr "";
  1028.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1029.                     if ($i sizeof($arrayexploded)) {
  1030.                         if (sizeof($listerandom) == 0) {
  1031.                             //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  1032.                             $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  1033.                         }
  1034.                         if ($nbLikes != 0) {
  1035.                             $listerandom $SEjourService->getlikephotosejour($userId$idSejour);
  1036.                             $arrayRsRandom $this->random_function($listerandom);
  1037.                         }
  1038.                         if ($nbLikes == 0) {
  1039.                             $arrayRsRandom $this->random_functionNolikes($listerandom);
  1040.                         }
  1041.                         array_push($tabacc$arrayRsRandom['idelem']);
  1042.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1043.                         unset($listerandom[$arrayRsRandom['elem']]);
  1044.                     } else {
  1045.                         $rr $rr $arrayexploded[$i];
  1046.                     }
  1047.                     $listerandom $listerandom;
  1048.                 }
  1049.                 $resultFinal $rr;
  1050.                 $p->setCouleurbordure($resultFinal);
  1051.                 array_push($allpagesResult$p);
  1052.             }
  1053.             $AllPages $allpagesResult;
  1054.         }
  1055.         $tabacc1 array_count_values($tabacc);
  1056.         if ($nbLikes  == 0) {
  1057.             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]);
  1058.         }
  1059.         if ($nbLikes  != 0) {
  1060.             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]);
  1061.         }
  1062.     }
  1063.     /**
  1064.      * @Route("Parent/AjoutPochettePhotos_Sejour/{nbr}", name="AjoutPochettePhotos_Sejour")
  1065.      */
  1066.     public function AjoutPochettePhotosParent_Sejour($nbr)
  1067.     {
  1068.         $SEjourService $this->sejourService;
  1069.         $userId $this->getUser()->getId();
  1070.         $user $this->getUser();
  1071.         $session $this->get('session');
  1072.         $session->set('pageMenu''');
  1073.         $idSejour $session->get("Sejour");
  1074.         $produitcondition $session->get("produit");
  1075.         $produit $session->get("produittype");
  1076.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1077.         $em $this->getDoctrine()->getManager();
  1078.         $clipart $em->getRepository(Clipart::class)->findAll();
  1079.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1080.         $listerandom =  $listeattach;
  1081.         $AllPagesAcc null;
  1082.         //        $random = false;
  1083.         //        $Albumproduct = $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour, 'iduser' => $userId], ['id' => 'DESC']);
  1084.         //        if ($Albumproduct == null || $Albumproduct == "") {
  1085.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1086.         $random true;
  1087.         //        }
  1088.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1089.         $idAcc $sejour->getIdAcommp();
  1090.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1091.         $part $sejour->getIdPartenaire();
  1092.         //$part = $em->getRepository(Etablisment::class)->findOneBy(['id' => $idpart->getId()]);
  1093.         //dd($part);
  1094.         $nompart $part->getUsername();
  1095.         $logopart $part->getLogourl();
  1096.         // dd($Albumproduct);  
  1097.         if ($albumAcc != null and $albumAcc != "") {
  1098.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1099.         }
  1100.         //        dd($albumAcc);
  1101.         $allpagesResult = array();
  1102.         $j 0;
  1103.         if ($random == true) {
  1104.             foreach ($AllPages as $p) {
  1105.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1106.                 //                var_dump($arrayexploded);
  1107.                 $rr "";
  1108.                 $elemPath "";
  1109.                 $elemId "";
  1110.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1111.                     if ($i sizeof($arrayexploded)) {
  1112.                         if (sizeof($listerandom) == 0) {
  1113.                             $listerandom =  $listeattach;
  1114.                         }
  1115.                         $arrayRsRandom $this->random_functionPhotoNolIKES($listerandom$j);
  1116.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1117.                         unset($listerandom[$arrayRsRandom['elem']]);
  1118.                     } else {
  1119.                         $rr $rr $arrayexploded[$i];
  1120.                     }
  1121.                     $listerandom $listerandom;
  1122.                 }
  1123.                 $resultFinal $rr;
  1124.                 $p->setCouleurbordure($resultFinal);
  1125.                 array_push($allpagesResult$p);
  1126.                 if ($j sizeof($listeattach) - 1) {
  1127.                     $j $j 1;
  1128.                 } else {
  1129.                     $j 0;
  1130.                 }
  1131.             }
  1132.             $AllPages $allpagesResult;
  1133.         }
  1134.         // die();
  1135.         $nbAttach count($listeattach);
  1136.         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]);
  1137.     }
  1138.     /**
  1139.      * @Route("Parent/AjoutPochettePhotos_Fav/{nbr}", name="AjoutPochettePhotos_Favoris")
  1140.      */
  1141.     public function EnregistrerPochettePhoto($nbr)
  1142.     {
  1143.         $SEjourService $this->sejourService;
  1144.         $user $this->getUser();
  1145.         $userId $this->getUser()->getId();
  1146.         $session $this->get('session');
  1147.         $session->set('pageMenu''');
  1148.         $idSejour $session->get("Sejour");
  1149.         $produitcondition $session->get("produit");
  1150.         $produit $session->get("produittype");
  1151.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1152.         $em $this->getDoctrine()->getManager();
  1153.         $clipart $em->getRepository(Clipart::class)->findAll();
  1154.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1155.         $listerandom $listeattachlikephoto;
  1156.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1157.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1158.         $allpagesResult = array();
  1159.         $j 0;
  1160.         foreach ($AllPages as $p) {
  1161.             $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1162.             //                var_dump($arrayexploded);
  1163.             $rr "";
  1164.             $elemPath "";
  1165.             $elemId "";
  1166.             for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1167.                 if ($i sizeof($arrayexploded)) {
  1168.                     if (sizeof($listerandom) == 0) {
  1169.                         $listerandom $listeattachlikephoto;
  1170.                     }
  1171.                     $arrayRsRandom $this->random_functionPhoto($listerandom);
  1172.                     $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1173.                     unset($listerandom[$arrayRsRandom['elem']]);
  1174.                 } else {
  1175.                     $rr $rr $arrayexploded[$i];
  1176.                 }
  1177.                 $listerandom $listerandom;
  1178.             }
  1179.             $resultFinal $rr;
  1180.             $p->setCouleurbordure($resultFinal);
  1181.             array_push($allpagesResult$p);
  1182.             if ($j sizeof($listeattachlikephoto) - 1) {
  1183.                 $j $j 1;
  1184.             } else {
  1185.                 $j 0;
  1186.             }
  1187.         }
  1188.         $AllPages $allpagesResult;
  1189.         // die();
  1190.         return new JsonResponse('done');
  1191.     }
  1192.     /**
  1193.      * @Route("Parent/AjoutPochettePhotos_Fav/{nbr}", name="AjoutPochettePhotos_Favoris")
  1194.      */
  1195.     public function AjoutPochettePhotosParent_Fav($nbr)
  1196.     {
  1197.         $SEjourService $this->sejourService;
  1198.         $user $this->getUser();
  1199.         $userId $this->getUser()->getId();
  1200.         $session $this->get('session');
  1201.         $session->set('pageMenu''');
  1202.         $idSejour $session->get("Sejour");
  1203.         $produitcondition $session->get("produit");
  1204.         $produit $session->get("produittype");
  1205.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1206.         $em $this->getDoctrine()->getManager();
  1207.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' =>  $userId'idSejour' =>  $idSejour]);
  1208.         foreach ($listeattachlikephoto as $photo) {
  1209.             $idattach $photo->getIdSejourAttchment();
  1210.             $SejattachPhoto  $photo->getIdSejourAttchment();
  1211.             $urlPhoto  =   $SejattachPhoto->getIdAttchment()->getPath();
  1212.             //$urlPhoto =   $attachPhoto->getPath();
  1213.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/',  $urlPhoto);
  1214.             $photosData[] = [
  1215.                 'id' => $photo->getId(),
  1216.                 'url' =>    $new_url,
  1217.                 'caption' => "",
  1218.             ];
  1219.         }
  1220.         $nbLikes count($listeattachlikephoto);
  1221.         // Convertir le tableau PHP en JSON
  1222.         $photosDataJSON json_encode($photosData);
  1223.         return $this->render('Parent/PochettePhotosLikes.html.twig', ["nbr" => $nbr"sejour" => $sejour,  "nbLikes" => $nbLikes'photosFav' =>    $photosDataJSON]);
  1224.     }
  1225.     /**
  1226.      * @Route("Parent/AjoutRetroPhotos_Fav/{nbr}", name="AjoutRetroPhotos_Favoris")
  1227.      */
  1228.     public function AjoutRetroPhotosParent_Fav($nbr)
  1229.     {
  1230.         $SEjourService $this->sejourService;
  1231.         $user $this->getUser();
  1232.         $userId $this->getUser()->getId();
  1233.         $session $this->get('session');
  1234.         $session->set('pageMenu''');
  1235.         $idSejour $session->get("Sejour");
  1236.         $produitcondition $session->get("produit");
  1237.         $produit $session->get("produittype");
  1238.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1239.         $em $this->getDoctrine()->getManager();
  1240.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' =>  $userId'idSejour' =>  $idSejour]);
  1241.         foreach ($listeattachlikephoto as $photo) {
  1242.             $idattach $photo->getIdSejourAttchment();
  1243.             $SejattachPhoto  $photo->getIdSejourAttchment();
  1244.             $urlPhoto  =   $SejattachPhoto->getIdAttchment()->getPath();
  1245.             //$urlPhoto =   $attachPhoto->getPath();
  1246.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/',  $urlPhoto);
  1247.             $photosData[] = [
  1248.                 'id' => $photo->getId(),
  1249.                 'url' =>    $new_url,
  1250.                 'caption' => "",
  1251.             ];
  1252.         }
  1253.         $nbLikes count($listeattachlikephoto);
  1254.         // Convertir le tableau PHP en JSON
  1255.         $photosDataJSON json_encode($photosData);
  1256.         return $this->render('Parent/RetroRefonte.html.twig', ["nbr" => $nbr"sejour" => $sejour,  "nbLikes" => $nbLikes'photosFav' =>    $photosDataJSON]);
  1257.     }
  1258.     function random_function($listerandom)
  1259.     {
  1260.         $elem array_rand($listerandom);
  1261.         $photo $listerandom[$elem];
  1262.         $idelem $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1263.         $pathelem $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
  1264.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1265.     }
  1266.     function random_functionNolikes($listerandom)
  1267.     {
  1268.         //dd(array_keys($listerandom));
  1269.         $elem array_rand($listerandom);
  1270.         $photo $listerandom[$elem];
  1271.         $idelem $photo["id"];
  1272.         $pathelem $photo["path"];
  1273.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1274.     }
  1275.     function random_functionPhoto($listerandom)
  1276.     {
  1277.         $elem array_rand($listerandom);
  1278.         $photo $listerandom[$elem];
  1279.         $idelem $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1280.         $pathelem $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
  1281.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1282.     }
  1283.     function random_functionPhotosSejour($listerandom$elem)
  1284.     {
  1285.         $elem array_rand($listerandom);
  1286.         $photo $listerandom[$elem];
  1287.         $idelem $photo->getId();
  1288.         $pathelem $photo->getPath();
  1289.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1290.     }
  1291.     function random_functionPhotoNolIKES($listerandom$elem)
  1292.     {
  1293.         $elem array_rand($listerandom);
  1294.         $photo $listerandom[$elem];
  1295.         $idelem $photo['id'];
  1296.         $pathelem $photo['path'];
  1297.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $elem);
  1298.     }
  1299.     /**
  1300.      * 🚀 Smart Distribution Algorithm BASÉ SUR LES IDS RÉELS DES PHOTOS
  1301.      * Expert PHP Senior Implementation - Garantit l'unicité et la distribution correcte
  1302.      * LIMITE: Max 3 répétitions par photo ID pour éviter la monotonie
  1303.      */
  1304.     private function calculateOptimalDistribution($favoritePhotos$totalSlots)
  1305.     {
  1306.         if (empty($favoritePhotos) || $totalSlots === 0) {
  1307.             return [];
  1308.         }
  1309.         $nbFavorites count($favoritePhotos);
  1310.         $MAX_REPETITIONS 3// 🚀 LIMITE ANTI-MONOTONIE
  1311.         // Extraire les IDs réels des photos pour tracking précis
  1312.         $photoIds = [];
  1313.         foreach ($favoritePhotos as $index => $photo) {
  1314.             if (is_object($photo)) {
  1315.                 $photoIds[$index] = $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1316.             } else {
  1317.                 $photoIds[$index] = $photo['id'];
  1318.             }
  1319.         }
  1320.         $distribution = [];
  1321.         $photoUsageCount = []; // Tracking des utilisations par ID réel
  1322.         if ($nbFavorites >= $totalSlots) {
  1323.             // Plus de favoris que de slots → 1 photo par slot, pas de répétition
  1324.             for ($i 0$i $totalSlots$i++) {
  1325.                 $photoIndex $i $nbFavorites;
  1326.                 $photoId $photoIds[$photoIndex];
  1327.                 $distribution[] = $photoIndex;
  1328.                 $photoUsageCount[$photoId] = ($photoUsageCount[$photoId] ?? 0) + 1;
  1329.             }
  1330.         } else {
  1331.             // 🎯 LOGIQUE SENIOR: Toutes les photos favorites d'abord, puis répétitions contrôlées
  1332.             // Étape 1: GARANTIR que chaque photo favorite apparaît au moins une fois
  1333.             for ($i 0$i $nbFavorites$i++) {
  1334.                 $photoId $photoIds[$i];
  1335.                 $distribution[] = $i;
  1336.                 $photoUsageCount[$photoId] = 1;
  1337.             }
  1338.             // Étape 2: Distribuer les slots restants avec contrôle strict
  1339.             $remainingSlots $totalSlots $nbFavorites;
  1340.             if ($remainingSlots 0) {
  1341.                 // Vérifier si on peut respecter la limite MAX_REPETITIONS
  1342.                 $maxPossibleRepetitions $nbFavorites * ($MAX_REPETITIONS 1);
  1343.                 if ($remainingSlots $maxPossibleRepetitions) {
  1344.                     // Fallback vers distribution mixte
  1345.                     return $this->calculateMixedDistribution($favoritePhotos$totalSlots$MAX_REPETITIONS);
  1346.                 }
  1347.                 // Distribution équitable des répétitions avec contrôle par ID
  1348.                 $slotsToDistribute $remainingSlots;
  1349.                 $round 0;
  1350.                 while ($slotsToDistribute && $round $MAX_REPETITIONS 1) {
  1351.                     for ($i 0$i $nbFavorites && $slotsToDistribute 0$i++) {
  1352.                         $photoId $photoIds[$i];
  1353.                         // Vérifier que cette photo n'a pas atteint la limite
  1354.                         if ($photoUsageCount[$photoId] < $MAX_REPETITIONS) {
  1355.                             $distribution[] = $i;
  1356.                             $photoUsageCount[$photoId]++;
  1357.                             $slotsToDistribute--;
  1358.                         }
  1359.                     }
  1360.                     $round++;
  1361.                 }
  1362.             }
  1363.             // Mélange intelligent préservant la règle "toutes les favorites d'abord"
  1364.             $this->smartShufflePreservingFirst($distribution$nbFavorites);
  1365.         }
  1366.         // 🧪 Validation stricte avec IDs réels
  1367.         if (!$this->validateDistributionWithIds($distribution$photoIds$MAX_REPETITIONS)) {
  1368.             error_log("⚠️ ALGORITHME PHOTO: Distribution invalide détectée avec IDs réels");
  1369.             error_log("Distribution: " json_encode($distribution));
  1370.             error_log("Photo Usage: " json_encode($photoUsageCount));
  1371.         }
  1372.         return $distribution;
  1373.     }
  1374.     /**
  1375.      * Distribution mixte quand il y a trop peu de favoris
  1376.      * Combine favoris + meilleures photos du séjour
  1377.      */
  1378.     private function calculateMixedDistribution($favoritePhotos$totalSlots$maxRepetitions)
  1379.     {
  1380.         if (empty($favoritePhotos)) {
  1381.             // Aucun favori, retourner des marqueurs pour photos du séjour
  1382.             return array_fill(0$totalSlots, -1);
  1383.         }
  1384.         $nbFavorites count($favoritePhotos);
  1385.         $distribution = [];
  1386.         // Extraire les IDs pour tracking
  1387.         $photoIds = [];
  1388.         foreach ($favoritePhotos as $index => $photo) {
  1389.             if (is_object($photo)) {
  1390.                 $photoIds[$index] = $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1391.             } else {
  1392.                 $photoIds[$index] = $photo['id'];
  1393.             }
  1394.         }
  1395.         $photoUsageCount = [];
  1396.         // Étape 1: S'assurer que chaque favori apparaît au moins une fois
  1397.         for ($i 0$i $nbFavorites && count($distribution) < $totalSlots$i++) {
  1398.             $distribution[] = $i;
  1399.             $photoUsageCount[$photoIds[$i]] = 1;
  1400.         }
  1401.         // Étape 2: Ajouter des répétitions jusqu'à la limite
  1402.         $round 1;
  1403.         while (count($distribution) < $totalSlots && $round $maxRepetitions) {
  1404.             for ($i 0$i $nbFavorites && count($distribution) < $totalSlots$i++) {
  1405.                 $photoId $photoIds[$i];
  1406.                 if ($photoUsageCount[$photoId] < $maxRepetitions) {
  1407.                     $distribution[] = $i;
  1408.                     $photoUsageCount[$photoId]++;
  1409.                 }
  1410.             }
  1411.             $round++;
  1412.         }
  1413.         // Étape 3: Compléter avec des marqueurs pour photos du séjour
  1414.         while (count($distribution) < $totalSlots) {
  1415.             $distribution[] = -1// Marqueur pour photo du séjour
  1416.         }
  1417.         // Mélange intelligent en préservant la règle "favoris d'abord"
  1418.         $this->smartShufflePreservingFirst($distribution$nbFavorites);
  1419.         return $distribution;
  1420.     }
  1421.     /**
  1422.      * Mélange intelligent pour éviter les répétitions consécutives
  1423.      */
  1424.     private function smartShuffle(&$distribution$nbFavorites)
  1425.     {
  1426.         $maxAttempts 100;
  1427.         $attempts 0;
  1428.         do {
  1429.             shuffle($distribution);
  1430.             $attempts++;
  1431.             $hasConsecutive false;
  1432.             // Vérifier s'il y a des répétitions consécutives
  1433.             for ($i 1$i count($distribution); $i++) {
  1434.                 if ($distribution[$i] === $distribution[$i 1]) {
  1435.                     $hasConsecutive true;
  1436.                     break;
  1437.                 }
  1438.             }
  1439.             if (!$hasConsecutive) {
  1440.                 break;
  1441.             }
  1442.         } while ($attempts $maxAttempts);
  1443.         // Si on n'arrive pas à éviter toutes les répétitions consécutives,
  1444.         // on fait un arrangement manuel intelligent
  1445.         if ($hasConsecutive && $nbFavorites 1) {
  1446.             $this->manualArrangement($distribution$nbFavorites);
  1447.         }
  1448.     }
  1449.     /**
  1450.      * Mélange intelligent qui préserve l'apparition de toutes les photos favorites d'abord
  1451.      * 🎯 GARANTIT: Toutes les photos favorites apparaissent avant les répétitions
  1452.      */
  1453.     private function smartShufflePreservingFirst(&$distribution$nbFavorites)
  1454.     {
  1455.         if (count($distribution) <= $nbFavorites) {
  1456.             // Si on n'a que les photos favorites, mélange léger
  1457.             shuffle($distribution);
  1458.             return;
  1459.         }
  1460.         // Séparer les premières occurrences des répétitions
  1461.         $firstOccurrences array_slice($distribution0$nbFavorites);
  1462.         $repetitions array_slice($distribution$nbFavorites);
  1463.         // Mélanger légèrement les premières occurrences pour éviter un ordre prévisible
  1464.         shuffle($firstOccurrences);
  1465.         // Mélanger les répétitions
  1466.         shuffle($repetitions);
  1467.         // Recombiner en évitant les répétitions consécutives
  1468.         $distribution $firstOccurrences;
  1469.         // Ajouter les répétitions en évitant les consécutives
  1470.         foreach ($repetitions as $rep) {
  1471.             $lastIndex count($distribution) - 1;
  1472.             $lastUsed $distribution[$lastIndex];
  1473.             if ($rep === $lastUsed) {
  1474.                 // Insérer à une position antérieure pour éviter la consécutive
  1475.                 $insertPos max(0$lastIndex 1);
  1476.                 array_splice($distribution$insertPos0, [$rep]);
  1477.             } else {
  1478.                 $distribution[] = $rep;
  1479.             }
  1480.         }
  1481.     }
  1482.     /**
  1483.      * 🧪 VALIDATION STRICTE BASÉE SUR LES IDS RÉELS DES PHOTOS
  1484.      * Expert PHP Senior - Garantit la distribution correcte
  1485.      */
  1486.     private function validateDistributionWithIds($distribution$photoIds$maxRepetitions)
  1487.     {
  1488.         if (empty($distribution) || empty($photoIds)) {
  1489.             return true;
  1490.         }
  1491.         $nbFavorites count($photoIds);
  1492.         $photoUsageTracking = []; // Tracking par ID réel de photo
  1493.         $photoFirstAppearance = []; // Index de première apparition par ID réel
  1494.         $photoRepetitionStart = []; // Index de première répétition par ID réel
  1495.         // Analyser la distribution
  1496.         foreach ($distribution as $slotIndex => $photoIndex) {
  1497.             if ($photoIndex >= $nbFavorites) {
  1498.                 error_log("⚠️ ERREUR: Index photo invalide $photoIndex >= $nbFavorites");
  1499.                 return false;
  1500.             }
  1501.             $photoId $photoIds[$photoIndex];
  1502.             // Compter les utilisations
  1503.             $photoUsageTracking[$photoId] = ($photoUsageTracking[$photoId] ?? 0) + 1;
  1504.             // Marquer la première apparition
  1505.             if (!isset($photoFirstAppearance[$photoId])) {
  1506.                 $photoFirstAppearance[$photoId] = $slotIndex;
  1507.             } else {
  1508.                 // C'est une répétition - marquer si c'est la première répétition
  1509.                 if (!isset($photoRepetitionStart[$photoId])) {
  1510.                     $photoRepetitionStart[$photoId] = $slotIndex;
  1511.                 }
  1512.             }
  1513.         }
  1514.         // ✅ Vérification 1: Toutes les photos favorites utilisées au moins une fois
  1515.         foreach ($photoIds as $photoId) {
  1516.             if (!isset($photoUsageTracking[$photoId]) || $photoUsageTracking[$photoId] < 1) {
  1517.                 error_log("⚠️ ERREUR: Photo ID $photoId non utilisée");
  1518.                 return false;
  1519.             }
  1520.         }
  1521.         // ✅ Vérification 2: Aucune photo ne dépasse la limite de répétitions
  1522.         foreach ($photoUsageTracking as $photoId => $count) {
  1523.             if ($count $maxRepetitions) {
  1524.                 error_log("⚠️ ERREUR: Photo ID $photoId utilisée $count fois (limite: $maxRepetitions)");
  1525.                 return false;
  1526.             }
  1527.         }
  1528.         // ✅ Vérification 3: Toutes les photos apparaissent avant toute répétition
  1529.         $lastFirstAppearance 0;
  1530.         foreach ($photoFirstAppearance as $photoId => $firstIndex) {
  1531.             $lastFirstAppearance max($lastFirstAppearance$firstIndex);
  1532.         }
  1533.         $earliestRepetition PHP_INT_MAX;
  1534.         foreach ($photoRepetitionStart as $photoId => $repetitionIndex) {
  1535.             $earliestRepetition min($earliestRepetition$repetitionIndex);
  1536.         }
  1537.         if ($earliestRepetition !== PHP_INT_MAX && $earliestRepetition <= $lastFirstAppearance) {
  1538.             error_log("⚠️ ERREUR: Répétition détectée avant que toutes les favorites soient utilisées");
  1539.             error_log("Dernière première apparition: $lastFirstAppearance, Première répétition: $earliestRepetition");
  1540.             return false;
  1541.         }
  1542.         // ✅ Vérification 4: Pas de répétitions consécutives
  1543.         for ($i 1$i count($distribution); $i++) {
  1544.             $currentPhotoId $photoIds[$distribution[$i]];
  1545.             $previousPhotoId $photoIds[$distribution[$i 1]];
  1546.             if ($currentPhotoId === $previousPhotoId) {
  1547.                 error_log("⚠️ WARNING: Répétition consécutive détectée aux positions " . ($i 1) . " et $i pour photo ID $currentPhotoId");
  1548.                 // Note: On continue, ce n'est qu'un warning
  1549.             }
  1550.         }
  1551.         return true;
  1552.     }
  1553.     /**
  1554.      * 🧪 FONCTION DE TEST LEGACY - Conservée pour compatibilité
  1555.      */
  1556.     private function validateDistribution($distribution$nbFavorites)
  1557.     {
  1558.         // Fallback vers la nouvelle validation si possible
  1559.         return !empty($distribution) && $nbFavorites 0;
  1560.     }
  1561.     /**
  1562.      * Arrangement manuel pour minimiser les répétitions consécutives
  1563.      */
  1564.     private function manualArrangement(&$distribution$nbFavorites)
  1565.     {
  1566.         $length count($distribution);
  1567.         for ($i 1$i $length$i++) {
  1568.             if ($distribution[$i] === $distribution[$i 1]) {
  1569.                 // Chercher une position différente à échanger
  1570.                 for ($j $i 1$j $length$j++) {
  1571.                     if (
  1572.                         $distribution[$j] !== $distribution[$i 1] &&
  1573.                         ($j === $length || $distribution[$j] !== $distribution[$j 1])
  1574.                     ) {
  1575.                         // Échanger
  1576.                         $temp $distribution[$i];
  1577.                         $distribution[$i] = $distribution[$j];
  1578.                         $distribution[$j] = $temp;
  1579.                         break;
  1580.                     }
  1581.                 }
  1582.             }
  1583.         }
  1584.     }
  1585.     /**
  1586.      * Fonction intelligente de sélection de photos - Remplace random_function
  1587.      */
  1588.     function smart_random_function($listerandom$currentSlot$distribution)
  1589.     {
  1590.         if (empty($listerandom) || empty($distribution) || !isset($distribution[$currentSlot])) {
  1591.             // Fallback sur l'ancien système si problème
  1592.             return $this->random_function($listerandom);
  1593.         }
  1594.         $photoIndex $distribution[$currentSlot];
  1595.         $photos array_values($listerandom); // Réindexer pour avoir des index numériques
  1596.         if (!isset($photos[$photoIndex])) {
  1597.             // Fallback sécurisé
  1598.             return $this->random_function($listerandom);
  1599.         }
  1600.         $photo $photos[$photoIndex];
  1601.         $idelem $photo->getIdSejourAttchment()->getIdAttchment()->getId();
  1602.         $pathelem $photo->getIdSejourAttchment()->getIdAttchment()->getPath();
  1603.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $photoIndex);
  1604.     }
  1605.     /**
  1606.      * Version pour photos sans likes
  1607.      */
  1608.     function smart_random_functionNoLikes($listerandom$currentSlot$distribution)
  1609.     {
  1610.         if (empty($listerandom) || empty($distribution) || !isset($distribution[$currentSlot])) {
  1611.             return $this->random_functionNolikes($listerandom);
  1612.         }
  1613.         $photoIndex $distribution[$currentSlot];
  1614.         $photos array_values($listerandom);
  1615.         if (!isset($photos[$photoIndex])) {
  1616.             return $this->random_functionNolikes($listerandom);
  1617.         }
  1618.         $photo $photos[$photoIndex];
  1619.         $idelem $photo["id"];
  1620.         $pathelem $photo["path"];
  1621.         return array('pathelem' => $pathelem'idelem' => $idelem'elem' => $photoIndex);
  1622.     }
  1623.     /**
  1624.      * Détermine si on doit utiliser une photo du séjour au lieu d'une répétition excessive
  1625.      */
  1626.     private function shouldUseSejourPhoto($currentSlot$distribution$favoritePhotos)
  1627.     {
  1628.         if (empty($distribution) || !isset($distribution[$currentSlot])) {
  1629.             return false;
  1630.         }
  1631.         // Compter combien de fois cette photo favorite a déjà été utilisée
  1632.         $photoIndex $distribution[$currentSlot];
  1633.         $usageCount 0;
  1634.         for ($i 0$i $currentSlot$i++) {
  1635.             if (isset($distribution[$i]) && $distribution[$i] === $photoIndex) {
  1636.                 $usageCount++;
  1637.             }
  1638.         }
  1639.         // Si cette photo a déjà été utilisée 3 fois, utiliser une photo du séjour
  1640.         return $usageCount >= 3;
  1641.     }
  1642.     /**
  1643.      * @Route("Parent/LivrePhotos", name="LivrePhotos")
  1644.      */
  1645.     public function EditionLivrePhotosParent()
  1646.     {
  1647.         $SEjourService $this->sejourService;
  1648.         /** @var \App\Entity\User $user */
  1649.         $user $this->getUser();
  1650.         $userId $user->getId();
  1651.         $session $this->session;
  1652.         $session->set('pageMenu''');
  1653.         $idSejour $session->get("Sejour");
  1654.         $sejour $this->getDoctrine()->getRepository(Sejour::class)->findOneBy(['id' => $idSejour]);
  1655.         $em $this->em;
  1656.         $clipart null;
  1657.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1658.         $nbLikes count($listeattachlikephoto);
  1659.         //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  1660.         $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  1661.         $random true;
  1662.         $allpagesResult = array();
  1663.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomLivre']);
  1664.         $AllPagesTemp $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1665.         // 🚀 CORRECTION CHIRURGICALE : Forcer exactement 20 pages pour l'album standard
  1666.         // Ajustement précis : 18 pages de contenu + 2 pages fixes = 20 pages total
  1667.         $MAX_CONTENT_PAGES 18;
  1668.         $AllPages array_slice($AllPagesTemp0$MAX_CONTENT_PAGES);
  1669.         $part $sejour->getIdPartenaire();
  1670.         $nompart $part->getUsername();
  1671.         $logopart $part->getLogourl();
  1672.         $tabacc = array();
  1673.         $tabacc1 = array();
  1674.         // 🚀 SMART DISTRIBUTION ALGORITHM - Expert UX Implementation
  1675.         $totalSlots 0;
  1676.         foreach ($AllPages as $p) {
  1677.             $slots substr_count($p->getCouleurbordure(), 'randomid');
  1678.             $totalSlots += $slots;
  1679.         }
  1680.         // 🚀 SMART DISTRIBUTION avec gestion mixte favoris + photos séjour
  1681.         $listeattachlikephoto = ($nbLikes != 0) ?
  1682.             $SEjourService->getlikephotosejour($userId$idSejour) : [];
  1683.         $allSejourPhotos $SEjourService->getCombinedattachSejour($idSejour'photo');
  1684.         // 🚀 Distribution intelligente basée sur les IDs réels des photos
  1685.         $smartDistribution $this->calculateOptimalDistribution($listeattachlikephoto$totalSlots);
  1686.         $needsSejourPhotos = ($nbLikes 0) && (count($listeattachlikephoto) * $totalSlots);
  1687.         $currentSlot 0;
  1688.         foreach ($AllPages as $p) {
  1689.             $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1690.             $rr "";
  1691.             for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1692.                 if ($i sizeof($arrayexploded)) {
  1693.                     // ✅ Distribution intelligente avec limite MAX 3 répétitions
  1694.                     if ($nbLikes != 0) {
  1695.                         // Vérifier si on doit utiliser une photo du séjour au lieu d'une répétition excessive
  1696.                         if ($needsSejourPhotos && $this->shouldUseSejourPhoto($currentSlot$smartDistribution$listeattachlikephoto)) {
  1697.                             $arrayRsRandom $this->smart_random_functionNoLikes($allSejourPhotos$currentSlot$smartDistribution);
  1698.                         } else {
  1699.                             $arrayRsRandom $this->smart_random_function($listeattachlikephoto$currentSlot$smartDistribution);
  1700.                         }
  1701.                     } else {
  1702.                         $arrayRsRandom $this->smart_random_functionNoLikes($allSejourPhotos$currentSlot$smartDistribution);
  1703.                     }
  1704.                     array_push($tabacc$arrayRsRandom['idelem']);
  1705.                     $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1706.                     $currentSlot++; // ✅ Performance optimisée - pas de unset
  1707.                 } else {
  1708.                     $rr $rr $arrayexploded[$i];
  1709.                 }
  1710.             }
  1711.             $resultFinal $rr;
  1712.             $p->setCouleurbordure($resultFinal);
  1713.             array_push($allpagesResult$p);
  1714.         }
  1715.         $AllPages $allpagesResult;
  1716.         $tabacc1 array_count_values($tabacc);
  1717.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1718.         $nbPhotos count($listeattach);
  1719.         $nbLike count($listeattachlikephoto);
  1720.         if ($nbLike == 0) {
  1721.             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]);
  1722.         }
  1723.         if ($nbLike != 0) {
  1724.             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]);
  1725.         }
  1726.     }
  1727.     /**
  1728.      * @Route("Parent/AjoutPochettePhotos/{nbr}", name="AjoutPochettePhotos")
  1729.      */
  1730.     public function AjoutPochettePhotosParent($nbr)
  1731.     {
  1732.         $SEjourService $this->sejourService;
  1733.         /** @var \App\Entity\User $user */
  1734.         $user $this->getUser();
  1735.         $userId $user->getId();
  1736.         $user $this->getUser();
  1737.         $session $this->session;
  1738.         $session->set('pageMenu''');
  1739.         $idSejour $session->get("Sejour");
  1740.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1741.         $em $this->em;
  1742.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  1743.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1744.         $nbPhoto count($listeattach);
  1745.         $clipart $em->getRepository(Clipart::class)->findAll();
  1746.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1747.         $nbLikes count($listeattachlikephoto);
  1748.         $listerandom  = array();
  1749.         $listerandom $listeattach;
  1750.         $AllPagesAcc null;
  1751.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1752.         $random true;
  1753.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1754.         $idAcc $sejour->getIdAcommp();
  1755.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1756.         $part $sejour->getIdPartenaire();
  1757.         $nompart $part->getUsername();
  1758.         $logopart $part->getLogourl();
  1759.         if ($albumAcc != null and $albumAcc != "") {
  1760.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1761.         }
  1762.         $allpagesResult = array();
  1763.         if ($random == true) {
  1764.             // 🚀 SMART DISTRIBUTION ALGORITHM pour POCHETTES - Expert UX Implementation
  1765.             $totalSlots 0;
  1766.             foreach ($AllPages as $p) {
  1767.                 $slots substr_count($p->getCouleurbordure(), 'randomid');
  1768.                 $totalSlots += $slots;
  1769.             }
  1770.             // 🚀 Distribution intelligente pour pochettes basée sur les IDs réels
  1771.             $favoritesList = ($nbLikes != 0) ? $listeattachlikephoto : [];
  1772.             $sejourPhotosList $listerandom;
  1773.             $smartDistribution $this->calculateOptimalDistribution($favoritesList$totalSlots);
  1774.             $needsSejourPhotos = ($nbLikes 0) && (count($favoritesList) * $totalSlots);
  1775.             $currentSlot 0;
  1776.             foreach ($AllPages as $p) {
  1777.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1778.                 $rr "";
  1779.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1780.                     if ($i sizeof($arrayexploded)) {
  1781.                         // ✅ Distribution intelligente pour pochettes - MAX 3 répétitions
  1782.                         if ($nbLikes != 0) {
  1783.                             // Vérifier si on doit utiliser une photo du séjour
  1784.                             if ($needsSejourPhotos && $this->shouldUseSejourPhoto($currentSlot$smartDistribution$favoritesList)) {
  1785.                                 $arrayRsRandom $this->smart_random_functionNoLikes($sejourPhotosList$currentSlot$smartDistribution);
  1786.                             } else {
  1787.                                 $arrayRsRandom $this->smart_random_function($favoritesList$currentSlot$smartDistribution);
  1788.                             }
  1789.                         } else {
  1790.                             $arrayRsRandom $this->smart_random_functionNoLikes($sejourPhotosList$currentSlot$smartDistribution);
  1791.                         }
  1792.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1793.                         $currentSlot++; // ✅ Performance optimisée
  1794.                     } else {
  1795.                         $rr $rr $arrayexploded[$i];
  1796.                     }
  1797.                 }
  1798.                 $resultFinal $rr;
  1799.                 $p->setCouleurbordure($resultFinal);
  1800.                 array_push($allpagesResult$p);
  1801.             }
  1802.             $AllPages $allpagesResult;
  1803.         }
  1804.         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]);
  1805.     }
  1806.     /**
  1807.      * @Route("Parent/AjoutPhotosRetrosFavoris/{nbr}", name="AjoutPhotosRetros_Favoris")
  1808.      */
  1809.     public function AjoutPhotosRetrosParentFavoris($nbr)
  1810.     {
  1811.         $SEjourService $this->sejourService;
  1812.         /** @var \App\Entity\User $user */
  1813.         $user $this->getUser();
  1814.         $userId $user->getId();
  1815.         $session $this->session;
  1816.         $session->set('pageMenu''');
  1817.         $idSejour $session->get("Sejour");
  1818.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1819.         $em $this->em;
  1820.         $clipart $em->getRepository(Clipart::class)->findAll();
  1821.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1822.         $nbLikes count($listeattachlikephoto);
  1823.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  1824.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1825.         $listerandom =  $listeattach;
  1826.         $AllPagesAcc null;
  1827.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1828.         $random true;
  1829.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1830.         $idAcc $sejour->getIdAcommp();
  1831.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1832.         $part $sejour->getIdPartenaire();
  1833.         $nompart $part->getUsername();
  1834.         $logopart $part->getLogourl();
  1835.         if ($albumAcc != null and $albumAcc != "") {
  1836.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1837.         }
  1838.         $allpagesResult = array();
  1839.         $j 0;
  1840.         if ($random == true) {
  1841.             foreach ($AllPages as $p) {
  1842.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1843.                 $rr "";
  1844.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1845.                     if ($i sizeof($arrayexploded)) {
  1846.                         if (sizeof($listerandom) == 0) {
  1847.                             //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  1848.                             $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  1849.                         }
  1850.                         if ($nbLikes != 0) {
  1851.                             $listerandom $SEjourService->getlikephotosejour($userId$idSejour);
  1852.                             $arrayRsRandom $this->random_functionPhoto($listerandom);
  1853.                         }
  1854.                         if ($nbLikes == 0) {
  1855.                             $arrayRsRandom $this->random_functionPhotoNolIKES($listerandom$j);
  1856.                         }
  1857.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1858.                         unset($listerandom[$arrayRsRandom['elem']]);
  1859.                     } else {
  1860.                         $rr $rr $arrayexploded[$i];
  1861.                     }
  1862.                     $listerandom $listerandom;
  1863.                 }
  1864.                 $resultFinal $rr;
  1865.                 $p->setCouleurbordure($resultFinal);
  1866.                 array_push($allpagesResult$p);
  1867.                 if ($j sizeof($listeattachlikephoto) - 1) {
  1868.                     $j $j 1;
  1869.                 } else {
  1870.                     $j 0;
  1871.                 }
  1872.             }
  1873.             $AllPages $allpagesResult;
  1874.         }
  1875.         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]);
  1876.     }
  1877.     /**
  1878.      * @Route("Parent/AjoutPhotosRetros/{nbr}", name="AjoutPhotosRetros")
  1879.      */
  1880.     public function AjoutPhotosRetrosParent($nbr)
  1881.     {
  1882.         $SEjourService $this->sejourService;
  1883.         /** @var \App\Entity\User $user */
  1884.         $user $this->getUser();
  1885.         $userId $user->getId();
  1886.         $session $this->session;
  1887.         $session->set('pageMenu''');
  1888.         $idSejour $session->get("Sejour");
  1889.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1890.         $em $this->em;
  1891.         $clipart $em->getRepository(Clipart::class)->findAll();
  1892.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1893.         $nbLikes count($listeattachlikephoto);
  1894.         //$listeattach = $SEjourService->getatachmentsejour($idSejour);
  1895.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  1896.         if ($nbLikes == 0) {
  1897.             $listerandom =  $listeattach;
  1898.         }
  1899.         if ($nbLikes != 0) {
  1900.             $listerandom =  $listeattachlikephoto;
  1901.         }
  1902.         $AllPagesAcc null;
  1903.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPochette' $nbr]);
  1904.         $random true;
  1905.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1906.         $idAcc $sejour->getIdAcommp();
  1907.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1908.         $part $sejour->getIdPartenaire();
  1909.         $nompart $part->getUsername();
  1910.         $logopart $part->getLogourl();
  1911.         if ($albumAcc != null and $albumAcc != "") {
  1912.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1913.         }
  1914.         $allpagesResult = array();
  1915.         $j 0;
  1916.         if ($random == true) {
  1917.             foreach ($AllPages as $p) {
  1918.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  1919.                 $rr "";
  1920.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  1921.                     if ($i sizeof($arrayexploded)) {
  1922.                         if ($nbLikes == 0) {
  1923.                             $arrayRsRandom $this->random_functionPhotoNolIKES($listerandom$j);
  1924.                         }
  1925.                         if ($nbLikes != 0) {
  1926.                             $arrayRsRandom $this->random_functionPhoto($listeattachlikephoto);
  1927.                         }
  1928.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  1929.                         unset($listerandom[$arrayRsRandom['elem']]);
  1930.                     } else {
  1931.                         $rr $rr $arrayexploded[$i];
  1932.                     }
  1933.                     $listerandom $listerandom;
  1934.                 }
  1935.                 $resultFinal $rr;
  1936.                 $p->setCouleurbordure($resultFinal);
  1937.                 array_push($allpagesResult$p);
  1938.                 if ($nbLikes == 0) {
  1939.                     if ($j sizeof($listeattachlikephoto) - 1) {
  1940.                         $j $j 1;
  1941.                     } else {
  1942.                         $j 0;
  1943.                     }
  1944.                 }
  1945.                 if ($nbLikes != 0) {
  1946.                     if ($j sizeof($listeattach) - 1) {
  1947.                         $j $j 1;
  1948.                     } else {
  1949.                         $j 0;
  1950.                     }
  1951.                 }
  1952.                 $AllPages $allpagesResult;
  1953.             }
  1954.         }
  1955.         if ($nbLikes == 0) {
  1956.             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]);
  1957.         }
  1958.         if ($nbLikes != 0) {
  1959.             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]);
  1960.         }
  1961.     }
  1962.     /**
  1963.      * @Route("Parent/CalendrierParent", name="CalendrierParent")
  1964.      */
  1965.     public function CalendrierParent()
  1966.     {
  1967.         $SEjourService $this->sejourService;
  1968.         /** @var \App\Entity\User $user */
  1969.         $user $this->getUser();
  1970.         $userId $user->getId();
  1971.         $user $this->getUser();
  1972.         $session $this->session;
  1973.         $session->set('pageMenu''');
  1974.         $idSejour $session->get("Sejour");
  1975.         $produitcondition $session->get("produit");
  1976.         $produit $session->get("produittype");
  1977.         $sejour $SEjourService->getsejourpourparent($idSejour);
  1978.         $em $this->em;
  1979.         $clipart $em->getRepository(Clipart::class)->findAll();
  1980.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  1981.         $listerandom $listeattachlikephoto;
  1982.         $AllPagesAcc null;
  1983.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomcalendrier']);
  1984.         $random true;
  1985.         //        }
  1986.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  1987.         $idAcc $sejour->getIdAcommp();
  1988.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  1989.         $part $sejour->getIdPartenaire();
  1990.         //$part = $em->getRepository(Etablisment::class)->findOneBy(['id' => $idpart->getId()]);
  1991.         //dd($part);
  1992.         $nompart $part->getUsername();
  1993.         $logopart $part->getLogourl();
  1994.         // dd($Albumproduct);  
  1995.         if ($albumAcc != null and $albumAcc != "") {
  1996.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  1997.         }
  1998.         //        dd($albumAcc);
  1999.         $allpagesResult = array();
  2000.         $tabacc = array();
  2001.         $tabacc1 = array();
  2002.         if ($random == true) {
  2003.             foreach ($AllPages as $p) {
  2004.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  2005.                 //dd($arrayexploded);
  2006.                 $rr "";
  2007.                 $elemPath "";
  2008.                 $elemId "";
  2009.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  2010.                     if ($i sizeof($arrayexploded)) {
  2011.                         if (sizeof($listerandom) == 0) {
  2012.                             $listerandom $SEjourService->getlikephotosejour($userId$idSejour);
  2013.                         }
  2014.                         $arrayRsRandom $this->random_function($listerandom);
  2015.                         array_push($tabacc$arrayRsRandom['idelem']);
  2016.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  2017.                         unset($listerandom[$arrayRsRandom['elem']]);
  2018.                     } else {
  2019.                         $rr $rr $arrayexploded[$i];
  2020.                     }
  2021.                     $listerandom $listerandom;
  2022.                 }
  2023.                 $resultFinal $rr;
  2024.                 $p->setCouleurbordure($resultFinal);
  2025.                 array_push($allpagesResult$p);
  2026.             }
  2027.             $AllPages $allpagesResult;
  2028.         }
  2029.         $tabacc1 array_count_values($tabacc);
  2030.         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]);
  2031.     }
  2032.     /**
  2033.      * @Route("Parent/ListeSejour", name="ListeSejourParent")
  2034.      */
  2035.     public function ListeSejourParent()
  2036.     {
  2037.         return $this->render('Parent/AccueillParent.html.twig', []);
  2038.     }
  2039.     /**
  2040.      * @Route("/parent/couverture", name="choixCouverture")
  2041.      */
  2042.     public function sur5()
  2043.     {
  2044.         return $this->render('Parent/couverture.html.twig');
  2045.     }
  2046.     /**
  2047.      * @Route("/", name="footerparent")
  2048.      */
  2049.     public function footerparent(): Response
  2050.     {
  2051.         $produit $this->typeProduiteService;
  2052.         $liste $produit->produitlistType();
  2053.         // dd($liste);
  2054.         $session $this->session;
  2055.         $destination $session->get("destionation");
  2056.         $nbvocal 0;
  2057.         $nbSlection 0;
  2058.         $nbPhoto 0;
  2059.         $sejour null;
  2060.         $sejourservice $this->sejourService;
  2061.         $idSejour $session->get("Sejour");
  2062.         /** @var \App\Entity\User $user */
  2063.         $user $this->getUser();
  2064.         $userId $user->getId();
  2065.         $albumAcc null;
  2066.         $em $this->em;
  2067.         if ($idSejour != null) {
  2068.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2069.             // Nb favoris 
  2070.             $listeattachlikephoto $sejourservice->getlikephotosejour($userId$idSejour);
  2071.             $nbSlection count($listeattachlikephoto);
  2072.             // Nb photos 
  2073.             $listeattach $sejourservice->getatachmentsejour($idSejour);
  2074.             $nbPhoto count($listeattach);
  2075.             // Nb messages vocaux 
  2076.             $messages $sejourservice->getsejourmessage($idSejour);
  2077.             $nbvocal count($messages);
  2078.             // Rechercher s'il y'a un album acompagnateur 
  2079.             $idAcc $sejour->getIdAcommp();
  2080.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  2081.         }
  2082.         return $this->render('Parent/footerParent.html.twig', [
  2083.             'destionation' =>  $destination,
  2084.             'nbvocal' =>  $nbvocal,
  2085.             'nbSlection' => $nbSlection,
  2086.             'nbPhotos' => $nbPhoto,
  2087.             'albumAcc' => $albumAcc,
  2088.         ]);
  2089.     }
  2090.     /**
  2091.      * @Route("/", name="heedear")
  2092.      */
  2093.     public function headerparenrt(): Response
  2094.     {
  2095.         $produit $this->typeProduiteService;
  2096.         $liste $produit->produitlistType();
  2097.         $nblikes 0;
  2098.         $nbmesssages 0;
  2099.         // dd($liste);
  2100.         $session $this->session;
  2101.         $panierSession $session->get("Panier");
  2102.         $destination $session->get("destionation");
  2103.         $nbvocal 0;
  2104.         $idSejour $session->get("Sejour");
  2105.         $sejour null;
  2106.         if ($idSejour != null) {
  2107.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2108.         }
  2109.         $Products $session->get("Panier");
  2110.         $numSuivi false;
  2111.         if ($sejour != null) {
  2112.             $Products $session->get("Panier");
  2113.             if ($Products == Null) {
  2114.                 $Products = [];
  2115.             }
  2116.             $UserService $this->userService;
  2117.             /** @var \App\Entity\User $user */
  2118.             $user $this->getUser();
  2119.             $iduser $user->getId();
  2120.             $containsProduitType20 false;
  2121.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2122.             $commandes $this->em->getRepository(Commande::class)->findBy(["idSejour" => $idSejour"idUser" => $iduser]);
  2123.             $sejourparent $this->em->getRepository(ParentSejour::class)->findOneBy(['idSejour' => $idSejour"idParent" => $iduser]);
  2124.             $payment $sejourparent->getPayment();
  2125.             // Check commands
  2126.             foreach ($commandes as $commande) {
  2127.                 $commandCondition $commande->getNumSuivi();
  2128.                 $status $commande->getStatut()->getId();
  2129.                 if ($commandCondition == && $status == 33) {
  2130.                     $containsProduitType20 true;
  2131.                     break; // No need to check further if condition is met
  2132.                 }
  2133.             }
  2134.             // Check panierSession if the condition is not met in commandes
  2135.             if (!$containsProduitType20 && is_array($panierSession) && !empty($panierSession)) {
  2136.                 foreach ($panierSession as $item) {
  2137.                     // Access the details of each item in the Panier
  2138.                     $condition $item['condition'];
  2139.                     $codesejour $item['codesejour'];
  2140.                     if ($condition == 16 && $codesejour == $sejour->getCodeSejour()) {
  2141.                         $containsProduitType20 true;
  2142.                         break; // No need to check further if condition is met
  2143.                     }
  2144.                 }
  2145.             }
  2146.             $sejourservice $this->sejourService;
  2147.             //$messages = $sejourservice->getsejourmessage($idSejour);
  2148.             $messages $sejourservice->getCombinedattachSejour($idSejour'message');
  2149.             $nbmessages count($messages);
  2150.             $listeattachlikephoto =  $sejourservice->getlikephotosejour($iduser$idSejour);
  2151.             $nblikes count($listeattachlikephoto);
  2152.             $em $this->em;
  2153.             $label "Livre_sejour" $sejour->getCodeSejour();
  2154.             $idAcc $sejour->getIdAcommp();
  2155.             // Album du séjour : 1) accompagnateur saved, 2) admin Album_sejour (iduser=1), 3) tout album Album_sejour pour ce séjour
  2156.             $albumAcc null;
  2157.             if ($idAcc !== null) {
  2158.                 $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $sejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  2159.             }
  2160.             if ($albumAcc === null) {
  2161.                 $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour], ['id' => 'DESC']);
  2162.             }
  2163.             if ($albumAcc === null) {
  2164.                 $albumAcc $em->getRepository(Produit::class)->findOneBy(['statut' => "Album_sejour"'idsjour' => $sejour], ['id' => 'DESC']);
  2165.             }
  2166.             $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'Livre_sejour']);
  2167.             if ($livreSej == null) {
  2168.                 $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  2169.             } else {
  2170.                 $livreSejour $livreSej;
  2171.             }
  2172.             $code_sejour =  $sejour->getCodeSejour();
  2173.             return $this->render('Parent/headerParent.html.twig', [
  2174.                 'produit' => $liste,
  2175.                 'sejour' => $sejour,
  2176.                 'livreSejour' => $livreSejour,
  2177.                 'Products' => $Products,
  2178.                 'destionation' =>  $destination,
  2179.                 'nbvocal' =>  $nbmessages,
  2180.                 'albumAcc' => $albumAcc,
  2181.                 'nbLikes' => $nblikes,
  2182.                 'code_sejour' => $code_sejour,
  2183.                 'payment' => $payment
  2184.             ]);
  2185.         }
  2186.         if ($sejour == null) {
  2187.             return $this->render('Parent/headerParent2.html.twig');
  2188.         }
  2189.     }
  2190.     /**
  2191.      * @Route("/Parent/disablepack", name="disablePack")
  2192.      */
  2193.     public function disableFreepack()
  2194.     {
  2195.         //this section is used to disale the freePackOffert
  2196.         $em $this->em;
  2197.         $session $this->session;
  2198.         /** @var \App\Entity\User $user */
  2199.         $user $this->getUser();
  2200.         $iduser $user->getId();
  2201.         $idSejour $session->get("Sejour");
  2202.         $SEjourService $this->sejourService;
  2203.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  2204.         $panierSession $session->get("Panier");
  2205.         $containsProduitType20 false;
  2206.         $nbrphoto count($listeattach);
  2207.         /** @var \App\Entity\User $user */
  2208.         $user $this->getUser();
  2209.         $iduser $user->getId();
  2210.         $containsProduitType20 false;
  2211.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2212.         $commandes $this->em->getRepository(Commande::class)->findBy(["idSejour" => $idSejour"idUser" => $iduser]);
  2213.         // Check commands
  2214.         foreach ($commandes as $commande) {
  2215.             $commandCondition $commande->getNumSuivi();
  2216.             $status $commande->getStatut()->getId();
  2217.             // Check if Num Suivi is set one and if payment is completed
  2218.             if ($commandCondition == && $status == 33) {
  2219.                 $containsProduitType20 true;
  2220.                 break; // No need to check further if condition is met
  2221.             }
  2222.         }
  2223.         // Check panierSession if the condition is not met in commandes
  2224.         if (!$containsProduitType20 && is_array($panierSession) && !empty($panierSession)) {
  2225.             foreach ($panierSession as $item) {
  2226.                 // Access the details of each item in the Panier
  2227.                 $condition $item['condition'];
  2228.                 $codesejour $item['codesejour'];
  2229.                 if ($condition == 16 && $codesejour == $sejour->getCodeSejour()) {
  2230.                     $containsProduitType20 true;
  2231.                     break; // No need to check further if condition is met
  2232.                 }
  2233.             }
  2234.         }
  2235.         return new JsonResponse(['containsProduitType20' => $containsProduitType20'idSejour' => $nbrphoto]);
  2236.     }
  2237.     /**
  2238.      * @Route("/Parent/disablepackpanier", name="disablePackpanier")
  2239.      */
  2240.     public function disableFreepackpanier(): JsonResponse
  2241.     {
  2242.         //this section is used to disale the + in the panier for the packOffert
  2243.         $em $this->em;
  2244.         $disabledProductIds = [];
  2245.         $session $this->session;
  2246.         $panierSession $session->get("Panier");
  2247.         $ids = [];
  2248.         foreach ($panierSession as $item) {
  2249.             $ids[] = $item['id'];
  2250.         }
  2251.         if ($panierSession) {
  2252.             foreach ($ids as $id) {
  2253.                 $panierProduits $em->getRepository(PanierProduit::class)->findBy(['idProduit' => $id]);
  2254.                 foreach ($panierProduits as $panierProduit) {
  2255.                     $produit $panierProduit->getIdProduit();
  2256.                     $type $produit->getType();
  2257.                     // Check if the product type is 20 and add to disabledProductIds if true
  2258.                     if ($type && $type->getId() == 20) {
  2259.                         $disabledProductIds[] = $produit->getId();
  2260.                     }
  2261.                 }
  2262.             }
  2263.             return new JsonResponse(['disabledProductIds' => $disabledProductIds]);
  2264.         }
  2265.     }
  2266.     /**
  2267.      * @Route("/", name="heedear2")
  2268.      */
  2269.     public function headerparenrt2(): Response
  2270.     {
  2271.         $session $this->session;
  2272.         $produit $this->typeProduiteService;
  2273.         $nbvocal 0;
  2274.         $idSejour $session->get("Sejour");
  2275.         $liste $produit->produitlistType();
  2276.         $session $this->session;
  2277.         $destination $session->get("destionation");
  2278.         $Products $session->get("Panier");
  2279.         if ($Products == Null) {
  2280.             $Products = [];
  2281.         }
  2282.         return $this->render('Parent/headerParent2.html.twig', [
  2283.             'produit' => $liste,
  2284.             'Products' => $Products,
  2285.             'destionation' =>  $destination,
  2286.             'nbvocal' =>  $nbvocal
  2287.         ]);
  2288.     }
  2289.     /**
  2290.      * @Route("/Parent/ParametresParent", name="ParametresParent")
  2291.      */
  2292.     public function Parametreparent()
  2293.     {
  2294.         // $sejourservice = $this->sejourService;
  2295.         //$sejour = $sejourservice->getparentsejour($id, $this->getUser());
  2296.         ///$session = $this->session;
  2297.         //$session->set('moncompte', 'parametres');
  2298.         $user $this->getUser();
  2299.         $session $this->session;
  2300.         $idSejour $session->get("Sejour");
  2301.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2302.         $ParentSejour $this->em->getRepository(ParentSejour::class)->findBy(['idSejour' => $sejour'idParent' => $user]);
  2303.         //ParentSejour
  2304.         //cablala
  2305.         //dd($ParentSejour[0]);
  2306.         //$listeattach = $sejourservice->getatachmentsejour($id);
  2307.         //$listeattachM = $sejourservice->getsejourmessage($id);
  2308.         return $this->render('Parent/Parentparametre.html.twig', [
  2309.             'user' => $user,
  2310.             'sejour' => $sejour,
  2311.             'ParentSejour' => $ParentSejour[0],
  2312.         ]);
  2313.     }
  2314.     /**
  2315.      * @Route("/Parent/Accueil5sur5/ajouteradresslirison", name="ajouteradress_livrson",methods={"POST"})
  2316.      */
  2317.     public function ajouteradresslivr(Request $request)
  2318.     {
  2319.         $UserService $this->userService;
  2320.         //dd($this->getUser()->getId());
  2321.         /** @var \App\Entity\User $user */
  2322.         $user $this->getUser();
  2323.         $iduser $user->getId();
  2324.         $prenom $request->get("prenom");
  2325.         $nom $request->get("nom");
  2326.         $organism $request->get("organism");
  2327.         $num $request->get("num");
  2328.         $rue $request->get('ruevoi');
  2329.         $ville $request->get("villle");
  2330.         $pays $request->get("pays");
  2331.         $codepostal $request->get("codpostal");
  2332.         //adress facturation if exsist
  2333.         $prenomfacturation $request->get("prenomadressfacturation");
  2334.         $nomfacturation $request->get("nomadressfacturation");
  2335.         $organismfacturation $request->get("etablismadressfacturation");
  2336.         $numfacturation $request->get("numdressfacturation");
  2337.         $ruefacturation $request->get('rueadressfacturation');
  2338.         $villefacturation $request->get("villefacturation");
  2339.         $paysfacturation $request->get("payadressfacturation");
  2340.         $codepostalfacturation $request->get("codepostalfacturation");
  2341.         //modification userPArent
  2342.         $usernomAcommpa $request->get("usernom");
  2343.         $userprenomAcommpa $request->get("userprenom");
  2344.         $userfonctionAcommpa $request->get("userfonction");
  2345.         $useretablismentAcommpa $request->get("useretablisment");
  2346.         $useremailcommpa $request->get("useremail");
  2347.         $sejourthem $request->get("sejourthem");
  2348.         $adresssejour $request->get("sejouradresse");
  2349.         $id $request->get("id");
  2350.         $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);
  2351.         return new JsonResponse('done');
  2352.     }
  2353.     /**
  2354.      * @Route("/Accueil5sur5/ajouteradressfacturation", name="ajouteradress_facturation",methods={"POST","GET"})
  2355.      */
  2356.     public function ajouteradressfacturation(Request $request)
  2357.     {
  2358.         $UserService $this->userService;
  2359.         /** @var \App\Entity\User $user */
  2360.         $user $this->getUser();
  2361.         $iduser $user->getId();
  2362.         $num $request->get("num");
  2363.         $rue $request->get('rue');
  2364.         $ville $request->get("ville");
  2365.         $pays $request->get("pays");
  2366.         $codepostal $request->get("codepostal");
  2367.         $adress $UserService->setadressfacturation($num$rue$ville$pays$codepostal$iduser);
  2368.         return new JsonResponse('done');
  2369.     }
  2370.     /**
  2371.      * @Route("/EntrezCode", name="EntrezCode")
  2372.      */
  2373.     public function EntrezCode(Request $request)
  2374.     {
  2375.         $email $request->get('email');
  2376.         $password $request->get('password');
  2377.         $this->session->set('rout''code');
  2378.         return $this->redirectToRoute('CodeSejour', ['email' => $email'password' => $password]);
  2379.     }
  2380.     /**
  2381.      * @Route("/DemandeCode", name="DemandeCode")
  2382.      */
  2383.     public function DemandeCode(Request $request)
  2384.     {
  2385.         $nomEnfant $request->get('nomEnfant');
  2386.         $prenomEnfant $request->get('prenomEnfant');
  2387.         $votreNom $request->get('votreNom');
  2388.         $votrePrenom $request->get('votrePrenom');
  2389.         $Mail $request->get('Mail');
  2390.         $votreLien $request->get('votreLien');
  2391.         $du $request->get('du');
  2392.         $au $request->get('au');
  2393.         $code $request->get('code');
  2394.         $ville $request->get('ville');
  2395.         $listeSejour $this->em->getRepository(Sejour::class)->listAcco($du$au$code$ville);
  2396.         $RefEmail $this->em->getRepository(Ref::class)->find(23);
  2397.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  2398.         foreach ($listeSejour as $accompagnateur) {
  2399.             $sendTo $accompagnateur->getIdAcommp()->getEmail();
  2400.             $message = (new \Swift_Message('Demande code séjour'))
  2401.                 ->setFrom('contact@5sur5sejour.com')
  2402.                 ->setTo($sendTo);
  2403.             //->setBcc("contact@5sur5sejour.com");
  2404.             $pathImage2 $Email->getIdImage2()->getPath();
  2405.             $pathImage1 $Email->getIdImage1()->getPath();
  2406.             $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2407.             $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2408.             $iconphoto $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_419_pqx0dx._6656d07326a50.png"));
  2409.             $iconloca $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_420_uynuqz._6656d10f4daaf.png"));
  2410.             $iconmsg $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Groupe_418_wbyysk._6656d16240404.png"));
  2411.             $iconfooter $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Picto5sur5_rapbfy._6656d1c1bb536.png"));
  2412.             $iMagesProduits $message->embed(Swift_Image::fromPath("https://media.5sur5sejour.com/upload/original/Picto5sur5_rapbfy._6656d1c1bb536.png"));
  2413.             $message->setBody(
  2414.                 $this->templating->render(
  2415.                     'emails/ParentDemandeCodeSejour.html.twig',
  2416.                     [
  2417.                         "nomAcco" => $accompagnateur->getIdAcommp()->getNom(),
  2418.                         "prenomAcco" => $accompagnateur->getIdAcommp()->getPrenom(),
  2419.                         "nomEnfant" => $nomEnfant,
  2420.                         "prenomEnfant" => $prenomEnfant,
  2421.                         "votreNom" => $votreNom,
  2422.                         "votrePrenom" => $votrePrenom,
  2423.                         "mail" => $Mail,
  2424.                         "votreLien" => $votreLien,
  2425.                         "image1" => $image1,
  2426.                         "image2" => $image2,
  2427.                         "iconfooter" => $iconfooter,
  2428.                         "iconphoto" => $iconphoto,
  2429.                         "iconloca" => $iconloca,
  2430.                         "iconmsg" => $iconmsg,
  2431.                         "du" => $du,
  2432.                         "au" => $au,
  2433.                         "code" => $code,
  2434.                         "ville" => $ville,
  2435.                     ]
  2436.                 ),
  2437.                 'text/html'
  2438.             );
  2439.             try {
  2440.                 $signMail $this->getParameter('signMail');
  2441.                 if ($signMail == 'yes') {
  2442.                     $domainName $this->getParameter('domaine');
  2443.                     $selector $this->getParameter('selector');
  2444.                     $PrivateKey file_get_contents($this->getParameter('pathDKIM'));
  2445.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2446.                     $message->attachSigner($signer);
  2447.                 }
  2448.                 $this->mailer->send($message);
  2449.             } catch (\Swift_SwiftException $ex) {
  2450.                 $ex->getMessage();
  2451.             }
  2452.         }
  2453.         return new JsonResponse(count($listeSejour));
  2454.     }
  2455.     /**
  2456.      * @Route("/Parent/ChoixCouverture", name="ChoixCouvertureParent")
  2457.      */
  2458.     public function Couverture()
  2459.     {
  2460.         return $this->render('Parent/ChoixCouverture.html.twig', []);
  2461.     }
  2462.     /**
  2463.      * @Route("/Parent/couvertureAccompagnateur", name="couvertureAccompagnateur")
  2464.      */
  2465.     public function CouvertureAccompagnateur()
  2466.     {
  2467.         $user $this->getUser();
  2468.         $session $this->session;
  2469.         $idSejour $session->get("Sejour");
  2470.         $listeproduit $prod $this->em->getRepository(Produit::class)->findby(array('idsjour' => $idSejour));
  2471.         return $this->render('Parent/couvertureAccompagnateur.html.twig', []);
  2472.     }
  2473.     /**
  2474.      * @Route("/Parent/Projet", name="projet-Parent")
  2475.      */
  2476.     public function parentTWo()
  2477.     {
  2478.         $this->session->set('rout''rout');
  2479.         /** @var \App\Entity\User $user */
  2480.         $user $this->getUser();
  2481.         $session $this->session;
  2482.         $session->set('pageMenu''projets');
  2483.         $idSejour $session->get("Sejour");
  2484.         $listeproduit $this->em->getRepository(Produit::class)->findby(array('idsjour' => $idSejour'iduser' => $user->getId()), ['id' => 'DESC']);
  2485.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2486.         $parentent_sejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $user->getId(), "idSejour" => $idSejour]);
  2487.         return $this->render('Parent/ProjetsParent.html.twig', ['sejour' => $sejour'parentent_sejour' => $parentent_sejour'listeproduit' => $listeproduit]);
  2488.     }
  2489.     /**
  2490.      * @Route("/Parent/MesProjets", name="MesProjets")
  2491.      */
  2492.     public function MesProjets()
  2493.     {
  2494.         return $this->render('Parent/MesProjetsSauvegardes.html.twig', []);
  2495.     }
  2496.     /**
  2497.      * @Route("/Parent/allSejourparent", name="SejourParent")
  2498.      */
  2499.     public function SejourAccompagnateur()
  2500.     {
  2501.         $sejourservice $this->sejourService;
  2502.         $session $this->session;
  2503.         $idSejour $session->get("Sejour");
  2504.         $session->set('rout''rout');
  2505.         /** @var \App\Entity\User $user */
  2506.         $user $this->getUser();
  2507.         $userId $user->getId();
  2508.         $listeSejour $prod $this->em->getRepository(ParentSejour::class)->findby(array('idParent' => $userId));
  2509.         return $this->render('Parent/Messejours.html.twig', ['listeSejour' => $listeSejour]);
  2510.     }
  2511.     /**
  2512.      * @Route("/Parent/Commander", name="Commander")
  2513.      */
  2514.     public function Commander()
  2515.     {
  2516.         $session $this->session;
  2517.         $idSejour $session->get("Sejour");
  2518.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2519.         $user $this->getUser();
  2520.         $comande $session->get("comande");
  2521.         $panier $session->get("Panier");
  2522.         $nbrprodpromo 0;
  2523.         $nbralbum 0;
  2524.         $nbrlivre 0;
  2525.         $nbrphoto12 0;
  2526.         $nbrphoto24 0;
  2527.         $nbrphoto36 0;
  2528.         $nbrcal 0;
  2529.         $nbrretro12 0;
  2530.         $nbrretro24 0;
  2531.         $nbrretro36 0;
  2532.         $detailsprod = array();
  2533.         $prixalbum 0.0;
  2534.         $prixphoto12 0.0;
  2535.         $prixphoto24 0.0;
  2536.         $prixphoto36 0.0;
  2537.         $prixcal 0.0;
  2538.         $prixalbum 0.0;
  2539.         $prixretro12 0.0;
  2540.         $prixretro24 0.0;
  2541.         $prixretro36 0.0;
  2542.         $prodpanierpromo = array();
  2543.         $promo = array();
  2544.         foreach ($panier as $key => $p) {
  2545.             if ($p['condition'] != 11 && $p['condition'] != 6) {
  2546.                 $promo['condition'] = $p['condition'];
  2547.                 $nbrprodpromo $nbrprodpromo $p['qte'];
  2548.                 array_push($prodpanierpromo$promo);
  2549.                 if ($p['condition'] == 4) {
  2550.                     $nbralbum $nbralbum $p['qte'];
  2551.                     $prixalbum $p['mnt'];
  2552.                 } elseif ($p['condition'] == 1) {
  2553.                     $nbrphoto12 $nbrphoto12 $p['qte'];
  2554.                     $prixphoto12 $p['mnt'];
  2555.                 } elseif ($p['condition'] == 2) {
  2556.                     $nbrphoto24 $nbrphoto24 $p['qte'];
  2557.                     $prixphoto24 $p['mnt'];
  2558.                 } elseif ($p['condition'] == 3) {
  2559.                     $nbrphoto36 $nbrphoto36 $p['qte'];
  2560.                     $prixphoto36  $p['mnt'];
  2561.                 } elseif ($p['condition'] == 5) {
  2562.                     $nbrlivre $nbrlivre $p['qte'];
  2563.                     $prixlivre $p['mnt'];
  2564.                 } elseif ($p['condition'] == 7) {
  2565.                     $nbrcal $nbrcal $p['qte'];
  2566.                     $prixcal $p['mnt'];
  2567.                 } elseif ($p['condition'] == 8) {
  2568.                     $nbrretro36 $nbrretro36 $p['qte'];
  2569.                     $prixretro36 $p['mnt'];
  2570.                 } elseif ($p['condition'] == 9) {
  2571.                     $nbrretro12 $nbrretro12 $p['qte'];
  2572.                     $prixretro12 $p['mnt'];
  2573.                 } elseif ($p['condition'] == 10) {
  2574.                     $nbrretro24 $nbrretro24 $p['qte'];
  2575.                     $prixretro24 $p['mnt'];
  2576.                 }
  2577.             }
  2578.         }
  2579.         $detailsprod['album']['qt'] = $nbralbum;
  2580.         $detailsprod['album']['prix'] = $prixalbum;
  2581.         $detailsprod['photo12']['qt'] = $nbrphoto12;
  2582.         $detailsprod['photo12']['prix'] = $prixphoto12;
  2583.         $detailsprod['photo24']['qt'] = $nbrphoto24;
  2584.         $detailsprod['photo24']['prix'] = $prixphoto24;
  2585.         $detailsprod['photo36']['qt'] = $nbrphoto36;
  2586.         $detailsprod['photo36']['prix'] = $prixphoto36;
  2587.         $detailsprod['cal']['qt'] = $nbrcal;
  2588.         $detailsprod['cal']['prix'] = $prixcal;
  2589.         $detailsprod['livre']['qt'] = $nbrlivre;
  2590.         $detailsprod['livre']['prix'] = $prixalbum;
  2591.         $detailsprod['retro12']['qt'] = $nbrretro12;
  2592.         $detailsprod['retro12']['prix'] = $prixretro12;
  2593.         $detailsprod['retro24']['qt'] = $nbrretro24;
  2594.         $detailsprod['retro24']['prix'] = $prixretro24;
  2595.         $detailsprod['retro36']['qt'] = $nbrretro36;
  2596.         $detailsprod['retro36']['prix'] = $prixretro36;
  2597.         $Panier $session->get("Panier");
  2598.         return $this->render('Parent/commande.html.twig', ["detailsprod" => $detailsprod"nbrprodpromo" => $nbrprodpromo"prodpanierpromo" => $prodpanierpromo"user" => $user"sejour" => $sejour"x" => $panier'Panier' => $Panier]);
  2599.     }
  2600.     /**
  2601.      * @Route("/Parent/MonPanier", name="MonPanier")
  2602.      */
  2603.     public function MonPanier()
  2604.     {
  2605.         /** @var \App\Entity\User $user */
  2606.         $user $this->getUser();
  2607.         $session $this->session;
  2608.         $idSejour $session->get("Sejour");
  2609.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2610.         $listeproduit $prod $this->em->getRepository(Produit::class)->findby(array('iduser' => $user->getId()));
  2611.         $parentent_sejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $user->getId(), "idSejour" => $idSejour]);
  2612.         $Panier $session->get("Panier");
  2613.         //dd($Panier);
  2614.         $prodpanier = array();
  2615.         $nbrprodpromo 0;
  2616.         $nbralbum 0;
  2617.         $nbrlivre 0;
  2618.         $nbrphoto12 0;
  2619.         $nbrphoto24 0;
  2620.         $nbrphoto36 0;
  2621.         $nbrcal 0;
  2622.         $nbrretro12 0;
  2623.         $nbrretro24 0;
  2624.         $nbrretro36 0;
  2625.         $detailsprod = array();
  2626.         $prixalbum 0.0;
  2627.         $prixphoto12 0.0;
  2628.         $prixphoto24 0.0;
  2629.         $prixphoto36 0.0;
  2630.         $prixcal 0.0;
  2631.         $prixalbum 0.0;
  2632.         $prixretro12 0.0;
  2633.         $prixretro24 0.0;
  2634.         $prixretro36 0.0;
  2635.         $prodpanierpromo = array();
  2636.         $promo = array();
  2637.         foreach ($Panier as $key => $p) {
  2638.             if ($p['condition'] != null) {
  2639.                 array_push($prodpanier$p['condition']);
  2640.             }
  2641.             if ($p['condition'] != 11 && $p['condition'] != 6) {
  2642.                 $promo['condition'] = $p['condition'];
  2643.                 $nbrprodpromo $nbrprodpromo $p['qte'];
  2644.                 array_push($prodpanierpromo$promo);
  2645.                 if ($p['condition'] == 4) {
  2646.                     $nbralbum $nbralbum $p['qte'];
  2647.                     $prixalbum $p['mnt'];
  2648.                 } elseif ($p['condition'] == 1) {
  2649.                     $nbrphoto12 $nbrphoto12 $p['qte'];
  2650.                     $prixphoto12 $p['mnt'];
  2651.                 } elseif ($p['condition'] == 2) {
  2652.                     $nbrphoto24 $nbrphoto24 $p['qte'];
  2653.                     $prixphoto24 $p['mnt'];
  2654.                 } elseif ($p['condition'] == 3) {
  2655.                     $nbrphoto36 $nbrphoto36 $p['qte'];
  2656.                     $prixphoto36  $p['mnt'];
  2657.                 } elseif ($p['condition'] == 5) {
  2658.                     $nbrlivre $nbrlivre $p['qte'];
  2659.                     $prixlivre $p['mnt'];
  2660.                 } elseif ($p['condition'] == 7) {
  2661.                     $nbrcal $nbrcal $p['qte'];
  2662.                     $prixcal $p['mnt'];
  2663.                 } elseif ($p['condition'] == 8) {
  2664.                     $nbrretro36 $nbrretro36 $p['qte'];
  2665.                     $prixretro36 $p['mnt'];
  2666.                 } elseif ($p['condition'] == 9) {
  2667.                     $nbrretro12 $nbrretro12 $p['qte'];
  2668.                     $prixretro12 $p['mnt'];
  2669.                 } elseif ($p['condition'] == 10) {
  2670.                     $nbrretro24 $nbrretro24 $p['qte'];
  2671.                     $prixretro24 $p['mnt'];
  2672.                 }
  2673.             }
  2674.         }
  2675.         $detailsprod['album']['qt'] = $nbralbum;
  2676.         $detailsprod['album']['prix'] = $prixalbum;
  2677.         $detailsprod['photo12']['qt'] = $nbrphoto12;
  2678.         $detailsprod['photo12']['prix'] = $prixphoto12;
  2679.         $detailsprod['photo24']['qt'] = $nbrphoto24;
  2680.         $detailsprod['photo24']['prix'] = $prixphoto24;
  2681.         $detailsprod['photo36']['qt'] = $nbrphoto36;
  2682.         $detailsprod['photo36']['prix'] = $prixphoto36;
  2683.         $detailsprod['cal']['qt'] = $nbrcal;
  2684.         $detailsprod['cal']['prix'] = $prixcal;
  2685.         $detailsprod['livre']['qt'] = $nbrlivre;
  2686.         $detailsprod['livre']['prix'] = $prixalbum;
  2687.         $detailsprod['retro12']['qt'] = $nbrretro12;
  2688.         $detailsprod['retro12']['prix'] = $prixretro12;
  2689.         $detailsprod['retro24']['qt'] = $nbrretro24;
  2690.         $detailsprod['retro24']['prix'] = $prixretro24;
  2691.         $detailsprod['retro36']['qt'] = $nbrretro36;
  2692.         $detailsprod['retro36']['prix'] = $prixretro36;
  2693.         $produit $this->typeProduiteService;
  2694.         $produitlist $produit->produitlistTypeConditionnement();
  2695.         //dd( $detailsprod);
  2696.         $this->session->set('rout''rout');
  2697.         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]);
  2698.     }
  2699.     /**
  2700.      * @Route("/Parent/mail", name="mail")
  2701.      */
  2702.     public function mail()
  2703.     {
  2704.         return $this->render('emails/Inscriptionparent.html.twig', []);
  2705.     }
  2706.     /**
  2707.      * @Route("/Parent/AlbummsavealbumParent", name="AlbummsavealbumParent")
  2708.      */
  2709.     public function Albummsavealbum(Request $request)
  2710.     {
  2711.         $session $this->session;
  2712.         $serviceuser $this->etablissementService;
  2713.         $page $request->get("pages");
  2714.         $sejour $request->get("sejour");
  2715.         $prodid $request->get('idProd');
  2716.         $nomprod $request->get('nomprod');
  2717.         $versionalbm $request->get('new');
  2718.         $user $this->getUser();
  2719.         $produittype $session->get("produit");
  2720.         $produit $session->get("produittype");
  2721.         /** @var \App\Entity\User $user */
  2722.         $user $this->getUser();
  2723.         $userEmail $user->getEmail();
  2724.         $Album $serviceuser->savealbumParent($page$user$sejour$prodid$produit$produittype$nomprod$versionalbm);
  2725.         //dd($etablissementDetail);
  2726.         $dateNow = new \Datetime();
  2727.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2728.         // $this->EmailServie->MailRelancePanier($userEmail);
  2729.         return new response();
  2730.     }
  2731.     /**
  2732.      * @Route("/Parent/saveLivrePhotosParent", name="saveLivrePhotosParent")
  2733.      */
  2734.     public function saveLivrePhotos(Request $request)
  2735.     {
  2736.         $session $this->session;
  2737.         $serviceuser $this->etablissementService;
  2738.         $page $request->get("pages");
  2739.         $sejour $request->get("sejour");
  2740.         $prodid $request->get('idProd');
  2741.         $nomprod $request->get('nomprod');
  2742.         $versionalbm $request->get('new');
  2743.         $user $this->getUser();
  2744.         $produitcondition $session->get("produit");
  2745.         $produit $session->get("produittype");
  2746.         $produitcondss $session->get('produitconditionAlbum');
  2747.         $Album $serviceuser->savelivreParent($page$user$sejour$prodid$produitcondss$nomprod$versionalbm);
  2748.         //dd($etablissementDetail);
  2749.         //sendmail_parent
  2750.         $dateNow = new \Datetime();
  2751.         /** @var \App\Entity\User $user */
  2752.         $user $this->getUser();
  2753.         $userEmail $user->getEmail();
  2754.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2755.         // $this->EmailServie->MailRelancePanier($userEmail);
  2756.         return new response('done');
  2757.     }
  2758.     /**
  2759.      * @Route("/Parent/SavePhotosPochette", name="SavePhotosPochetteParent")
  2760.      */
  2761.     public function SavePhotosPochetteParent(Request $request)
  2762.     {
  2763.         $session $this->session;
  2764.         $serviceuser $this->etablissementService;
  2765.         $page $request->get("pages");
  2766.         $sejour $request->get("sejour");
  2767.         $prodid $request->get('idProd');
  2768.         $nomprod $request->get('nomprod');
  2769.         $nbr $request->get('nbr');
  2770.         $user $this->getUser();
  2771.         $nbr strval($nbr);
  2772.         $produittype $session->get("produit");
  2773.         $produit $session->get("produittype");
  2774.         $Album $serviceuser->SavePhotosPochetteParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  2775.         //sendmailparent
  2776.         $dateNow = new \Datetime();
  2777.         /** @var \App\Entity\User $user */
  2778.         $user $this->getUser();
  2779.         $userEmail $user->getEmail();
  2780.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2781.         //$this->EmailServie->MailRelancePanier($userEmail);
  2782.         return new response('done');
  2783.     }
  2784.     /**
  2785.      * @Route("/Parent/RetrosComandeSaveRetros", name="PochettePhotosComandeSave")
  2786.      */
  2787.     public function PochettePhotosComandeSave(Request $request)
  2788.     {
  2789.         $em $this->em;
  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.         $nbr $request->get('nbr');
  2797.         $user $this->getUser();
  2798.         $nbr strval($nbr);
  2799.         $produittype $session->get("produit");
  2800.         $produit $session->get("produittype");
  2801.         $Album $serviceuser->SavePhotosRetrosParents($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  2802.         $inser false;
  2803.         $Products $session->get("Panier");
  2804.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  2805.         //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
  2806.         $user $this->getUser();
  2807.         $typeref $em->getRepository(Typeref::class)->find(8);
  2808.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  2809.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  2810.         //fin
  2811.         if ($panierTrace == null) {
  2812.             $panierTrace = new Panier();
  2813.             $dateNow = new \Datetime();
  2814.             $panierTrace->setDateCreation($dateNow);
  2815.             $panierTrace->setCreerPar($user);
  2816.             $panierTrace->setStatut($statutPanier);
  2817.             $em->getManager()->persist($panierTrace);
  2818.             $em->getManager()->flush();
  2819.         }
  2820.         //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
  2821.         if ($Products == null) {
  2822.             $Products = [];
  2823.         }
  2824.         foreach ($Products as $key => $p) {
  2825.             if ($p['id'] == $produit->getId()) {
  2826.                 $inser true;
  2827.                 $Products[$key]['qte'] = $p['qte'] + 1;
  2828.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  2829.             }
  2830.         }
  2831.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  2832.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  2833.         if ($panierProduit == null) {
  2834.             $panierProduit = new PanierProduit();
  2835.             $panierProduit->setIdProduit($produit);
  2836.             $panierProduit->setIdPanier($panierTrace);
  2837.             $em->getManager()->persist($panierProduit);
  2838.             $em->getManager()->flush();
  2839.         }
  2840.         //fin
  2841.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  2842.         $oldQte $panierProduit->getQuantite();
  2843.         $newQte $oldQte 1;
  2844.         $panierProduit->setQuantite($newQte);
  2845.         $oldTotal $panierProduit->getPrixTotal();
  2846.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  2847.         $panierProduit->setPrixTotal($newTotal);
  2848.         $em->getManager()->persist($panierProduit);
  2849.         $em->getManager()->flush();
  2850.         //fin
  2851.         if ($inser === false) {
  2852.             $p = [];
  2853.             $p["id"] = $produit->getId();
  2854.             $p["nom"] = $produit->getType()->getLabeletype();
  2855.             $p["ident"] = $produit->getLabele();
  2856.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  2857.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  2858.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  2859.             $p["condition"] = $produit->getIdConditionnement()->getId();
  2860.             $p["qte"] = 1;
  2861.             array_push($Products$p);
  2862.         }
  2863.         $session->set('Panier'$Products);
  2864.         //sendmail_parent
  2865.         $dateNow = new \Datetime();
  2866.         /** @var \App\Entity\User $user */
  2867.         $user $this->getUser();
  2868.         $userEmail $user->getEmail();
  2869.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2870.         //$this->EmailServie->MailRelancePanier($userEmail);
  2871.         return new response('done');
  2872.     }
  2873.     //fonction pour pochett photo comande direct au panier 
  2874.     /**
  2875.      * @Route("/Parent/PochetcomdComandeSave", name="PochettePhotosComandeSave_pochet_panier")
  2876.      */
  2877.     public function PochettePhotosComandeSave_pochet_panier(Request $request)
  2878.     {
  2879.         $em $this->em;
  2880.         $session $this->session;
  2881.         $serviceuser $this->etablissementService;
  2882.         $page $request->get("pages");
  2883.         $sejour $request->get("sejour");
  2884.         $prodid $request->get('idProd');
  2885.         $nomprod $request->get('nomprod');
  2886.         $nbr $request->get('nbr');
  2887.         $user $this->getUser();
  2888.         $nbr strval($nbr);
  2889.         $produittype $session->get("produit");
  2890.         $produit $session->get("produittype");
  2891.         $Album $serviceuser->SavePhotosPochetteParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  2892.         $inser false;
  2893.         $Products $session->get("Panier");
  2894.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  2895.         //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
  2896.         $user $this->getUser();
  2897.         $typeref $em->getRepository(Typeref::class)->find(8);
  2898.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  2899.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  2900.         //fin
  2901.         if ($panierTrace == null) {
  2902.             $panierTrace = new Panier();
  2903.             $dateNow = new \Datetime();
  2904.             $panierTrace->setDateCreation($dateNow);
  2905.             $panierTrace->setCreerPar($user);
  2906.             $panierTrace->setStatut($statutPanier);
  2907.             $em->getManager()->persist($panierTrace);
  2908.             $em->getManager()->flush();
  2909.         }
  2910.         //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
  2911.         if ($Products == null) {
  2912.             $Products = [];
  2913.         }
  2914.         foreach ($Products as $key => $p) {
  2915.             if ($p['id'] == $produit->getId()) {
  2916.                 $inser true;
  2917.                 $Products[$key]['qte'] = $p['qte'] + 1;
  2918.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  2919.             }
  2920.         }
  2921.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  2922.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  2923.         if ($panierProduit == null) {
  2924.             $panierProduit = new PanierProduit();
  2925.             $panierProduit->setIdProduit($produit);
  2926.             $panierProduit->setIdPanier($panierTrace);
  2927.             $em->getManager()->persist($panierProduit);
  2928.             $em->getManager()->flush();
  2929.         }
  2930.         //fin
  2931.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  2932.         $oldQte $panierProduit->getQuantite();
  2933.         $newQte $oldQte 1;
  2934.         $panierProduit->setQuantite($newQte);
  2935.         $oldTotal $panierProduit->getPrixTotal();
  2936.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  2937.         $panierProduit->setPrixTotal($newTotal);
  2938.         $em->getManager()->persist($panierProduit);
  2939.         $em->getManager()->flush();
  2940.         //fin
  2941.         if ($inser === false) {
  2942.             $p = [];
  2943.             $p["id"] = $produit->getId();
  2944.             $p["nom"] = $produit->getType()->getLabeletype();
  2945.             $p["ident"] = $produit->getLabele();
  2946.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  2947.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  2948.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  2949.             $p["condition"] = $produit->getIdConditionnement()->getId();
  2950.             $p["qte"] = 1;
  2951.             array_push($Products$p);
  2952.         }
  2953.         $session->set('Panier'$Products);
  2954.         //sendmail_parent
  2955.         $dateNow = new \Datetime();
  2956.         /** @var \App\Entity\User $user */
  2957.         $user $this->getUser();
  2958.         $userEmail $user->getEmail();
  2959.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  2960.         // $this->EmailServie->MailRelancePanier($userEmail);
  2961.         return new response('done');
  2962.     }
  2963.     //Nouvelle fonction ajout pochette
  2964.     /**
  2965.      * @Route("/Parent/TestcreateFilePhotosNew", name="TestcreateFilePhotosNew")
  2966.      */
  2967.     function TestcreateFilePhotosNew(Request $request)
  2968.     {
  2969.         $prdt $request->get("produit");
  2970.         $printerSer $this->printerService;
  2971.         $pages $this->em->getRepository(Page::class)->findBy(array("idproduit" => $prdt));
  2972.         $this->logger->notice('Generating File for Pack photos');
  2973.         $name =  $printerSer->CreerTcpPhotosPochette_Parent($prdt'NumCmd_963''Photo'$pages);
  2974.         dump($name);
  2975.         die();
  2976.         return ("ok");
  2977.     }
  2978.     //Nouvelle fonction ajout pochette
  2979.     /**
  2980.      * @Route("/Parent/AddPochetteAuPanier", name="AddPochetteAuPanier")
  2981.      */
  2982.     public function AddPochetteAuPanier(Request $request)
  2983.     {
  2984.         $em $this->em;
  2985.         $session $this->session;
  2986.         $serviceuser $this->etablissementService;
  2987.         $page $request->get("photos");
  2988.         $sejour $request->get("sejour");
  2989.         $nbr $request->get('nbr');
  2990.         $user $this->getUser();
  2991.         $nbr strval($nbr);
  2992.         //Enregistrement des infos de la pochette dans un produit et les photos dans des pages avec JSON
  2993.         $Pochette_photos $serviceuser->photosPochette_Nouvelle($page$user$sejour$nbr);
  2994.         $produit $em->getRepository(Produit::class)->find($Pochette_photos->getId());
  2995.         // $zipFileName = $this->printerService->CreerTcpPhotosPochette_Parent($Pochette_photos->getId(), "9999999", "pochette_photo");
  2996.         $inser false;
  2997.         $Products $session->get("Panier");
  2998.         $produit $em->getRepository(Produit::class)->find($Pochette_photos->getId());
  2999.         //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
  3000.         $typeref $em->getRepository(Typeref::class)->find(8);
  3001.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3002.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3003.         //fin
  3004.         if ($panierTrace == null) {
  3005.             $panierTrace = new Panier();
  3006.             $dateNow = new \Datetime();
  3007.             $panierTrace->setDateCreation($dateNow);
  3008.             $panierTrace->setCreerPar($user);
  3009.             $panierTrace->setStatut($statutPanier);
  3010.             $em->getManager()->persist($panierTrace);
  3011.             $em->getManager()->flush();
  3012.         }
  3013.         //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
  3014.         if ($Products == null) {
  3015.             $Products = [];
  3016.         }
  3017.         foreach ($Products as $key => $p) {
  3018.             if ($p['id'] == $produit->getId()) {
  3019.                 $inser true;
  3020.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3021.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3022.             }
  3023.         }
  3024.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  3025.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3026.         if ($panierProduit == null) {
  3027.             $panierProduit = new PanierProduit();
  3028.             $panierProduit->setIdProduit($produit);
  3029.             $panierProduit->setIdPanier($panierTrace);
  3030.             $em->getManager()->persist($panierProduit);
  3031.             $em->getManager()->flush();
  3032.         }
  3033.         //fin
  3034.         $oldQte $panierProduit->getQuantite();
  3035.         $newQte $oldQte 1;
  3036.         $panierProduit->setQuantite($newQte);
  3037.         $oldTotal $panierProduit->getPrixTotal();
  3038.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3039.         $panierProduit->setPrixTotal($newTotal);
  3040.         $em->getManager()->persist($panierProduit);
  3041.         $em->getManager()->flush();
  3042.         // Test creation du fichier zip pdf pochette
  3043.         if ($inser === false) {
  3044.             $p = [];
  3045.             $p["id"] = $produit->getId();
  3046.             $p["nom"] = $produit->getType()->getLabeletype();
  3047.             $p["ident"] = $produit->getLabele();
  3048.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3049.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3050.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3051.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3052.             $p["qte"] = 1;
  3053.             array_push($Products$p);
  3054.         }
  3055.         $session->set('Panier'$Products);
  3056.         //sendmail_parent
  3057.         $dateNow = new \Datetime();
  3058.         /** @var \App\Entity\User $user */
  3059.         $user $this->getUser();
  3060.         $userEmail $user->getEmail();
  3061.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3062.         // $this->EmailServie->MailRelancePanier($userEmail);
  3063.         //   $this->TestcreateFilePhotosNew($produit);
  3064.         return new response('done');
  3065.     }
  3066.     /**
  3067.      * @Route("/Parent/AddRetroAuPanier", name="AddRetroAuPanier", methods={"POST"})
  3068.      */
  3069.     public function AddRetroAuPanier(Request $request)
  3070.     {
  3071.         $em       $this->em;        // or getDoctrine()->getManager()
  3072.         $session  $this->session;
  3073.         $user $this->getUser();
  3074.         $service  $this->etablissementService// Same service that had photosPochette_Nouvelle
  3075.         $photos   $request->get('photos');     // base64 data, widths, heights, etc.
  3076.         $sejourId $request->get('sejour');
  3077.         $nbr      strval($request->get('nbr'));
  3078.         // 1) Let the service create the new "Retro" product + store pages
  3079.         //    We’ll define photosRetro_Nouvelle similar to photosPochette_Nouvelle
  3080.         $RetroProduit $service->photosRetro_Nouvelle($photos$user$sejourId$nbr);
  3081.         // 2) Same logic to insert that new product in the user’s Panier
  3082.         //    (Essentially the same as your AddPochetteAuPanier code)
  3083.         $inser false;
  3084.         $Products $session->get("Panier");
  3085.         if (!$Products) {
  3086.             $Products = [];
  3087.         }
  3088.         // The newly created product
  3089.         $produit $em->getRepository(Produit::class)->find($RetroProduit->getId());
  3090.         // A) Check if a "Panier" with status "creer" for this user exists,
  3091.         //    or create one if needed
  3092.         $typeref $em->getRepository(Typeref::class)->find(8);
  3093.         $statutPanier $em->getRepository(Ref::class)->findOneBy([
  3094.             "libiller" => "creer",
  3095.             "typeref" => $typeref
  3096.         ]);
  3097.         $panierTrace $em->getRepository(Panier::class)->findOneBy([
  3098.             "creerPar" => $user,
  3099.             "statut"   => $statutPanier
  3100.         ]);
  3101.         if (!$panierTrace) {
  3102.             $panierTrace = new Panier();
  3103.             $panierTrace->setDateCreation(new \DateTime());
  3104.             $panierTrace->setCreerPar($user);
  3105.             $panierTrace->setStatut($statutPanier);
  3106.             $em->getManager()->persist($panierTrace);
  3107.             $em->getManager()->flush();
  3108.         }
  3109.         // B) Check if this product already exists in $Products
  3110.         foreach ($Products as $key => $p) {
  3111.             if ($p['id'] == $produit->getId()) {
  3112.                 $inser true;
  3113.                 $Products[$key]['qte'] += 1;
  3114.                 $Products[$key]['mnt'] += $produit->getIdConditionnement()->getMontantTTC();
  3115.             }
  3116.         }
  3117.         // C) Check if it also exists in PanierProduit table
  3118.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy([
  3119.             "idProduit" => $produit,
  3120.             "idPanier"  => $panierTrace
  3121.         ]);
  3122.         if (!$panierProduit) {
  3123.             $panierProduit = new PanierProduit();
  3124.             $panierProduit->setIdProduit($produit);
  3125.             $panierProduit->setIdPanier($panierTrace);
  3126.             $em->getManager()->persist($panierProduit);
  3127.             $em->getManager()->flush();
  3128.         }
  3129.         // D) Increase quantity & total
  3130.         $oldQte $panierProduit->getQuantite();
  3131.         $panierProduit->setQuantite($oldQte 1);
  3132.         $oldTotal $panierProduit->getPrixTotal();
  3133.         $panierProduit->setPrixTotal($oldTotal $produit->getIdConditionnement()->getMontantTTC());
  3134.         $em->getManager()->persist($panierProduit);
  3135.         $em->getManager()->flush();
  3136.         // E) If not inserted in $Products above, push new array item
  3137.         if (!$inser) {
  3138.             $p = [
  3139.                 "id"         => $produit->getId(),
  3140.                 "nom"        => $produit->getType()->getLabeletype(),
  3141.                 "ident"      => $produit->getLabele(),
  3142.                 "codesejour" => $produit->getIdsjour()->getcodeSejour(),
  3143.                 "mnt"        => $produit->getIdConditionnement()->getMontantTTC(),
  3144.                 "path"       => $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  3145.                 "condition"  => $produit->getIdConditionnement()->getId(),
  3146.                 "qte"        => 1
  3147.             ];
  3148.             $Products[] = $p;
  3149.         }
  3150.         $session->set('Panier'$Products);
  3151.         /** @var \App\Entity\User $user */
  3152.         $user $this->getUser();
  3153.         $userEmail $user->getEmail();
  3154.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3155.         return new Response('done');
  3156.     }
  3157.     /**
  3158.      * @Route("/Parent/SavePhotosRetros", name="SavePhotosRetrosParent")
  3159.      */
  3160.     public function SavePhotosRetrosParent(Request $request)
  3161.     {
  3162.         $em $this->em;
  3163.         $session $this->session;
  3164.         $serviceuser $this->etablissementService;
  3165.         $page $request->get("pages");
  3166.         $sejour $request->get("sejour");
  3167.         $prodid $request->get('idProd');
  3168.         $nomprod $request->get('nomprod');
  3169.         $nbr $request->get('nbr');
  3170.         $comandePanier $request->get('comandePanier');
  3171.         $user $this->getUser();
  3172.         $nbr strval($nbr);
  3173.         $produittype $session->get("produit");
  3174.         $produit $session->get("produittype");
  3175.         $Album $serviceuser->SavePhotosRetrosParents($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3176.         //dd($etablissementDetail);
  3177.         if ($comandePanier == "comandePanier") {
  3178.             $inser false;
  3179.             $Products $session->get("Panier");
  3180.             $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  3181.             //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
  3182.             $user $this->getUser();
  3183.             $typeref $em->getRepository(Typeref::class)->find(8);
  3184.             $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3185.             $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3186.             //fin
  3187.             if ($panierTrace == null) {
  3188.                 $panierTrace = new Panier();
  3189.                 $dateNow = new \Datetime();
  3190.                 $panierTrace->setDateCreation($dateNow);
  3191.                 $panierTrace->setCreerPar($user);
  3192.                 $panierTrace->setStatut($statutPanier);
  3193.                 $em->getManager()->persist($panierTrace);
  3194.                 $em->getManager()->flush();
  3195.             }
  3196.             //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
  3197.             if ($Products == null) {
  3198.                 $Products = [];
  3199.             }
  3200.             foreach ($Products as $key => $p) {
  3201.                 if ($p['id'] == $produit->getId()) {
  3202.                     $inser true;
  3203.                     $Products[$key]['qte'] = $p['qte'] + 1;
  3204.                     $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3205.                 }
  3206.             }
  3207.             //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  3208.             $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3209.             if ($panierProduit == null) {
  3210.                 $panierProduit = new PanierProduit();
  3211.                 $panierProduit->setIdProduit($produit);
  3212.                 $panierProduit->setIdPanier($panierTrace);
  3213.                 $em->getManager()->persist($panierProduit);
  3214.                 $em->getManager()->flush();
  3215.             }
  3216.             //fin
  3217.             //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  3218.             $oldQte $panierProduit->getQuantite();
  3219.             $newQte $oldQte 1;
  3220.             $panierProduit->setQuantite($newQte);
  3221.             $oldTotal $panierProduit->getPrixTotal();
  3222.             $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3223.             $panierProduit->setPrixTotal($newTotal);
  3224.             $em->getManager()->persist($panierProduit);
  3225.             $em->getManager()->flush();
  3226.             //fin
  3227.             if ($inser === false) {
  3228.                 $p = [];
  3229.                 $p["id"] = $produit->getId();
  3230.                 $p["nom"] = $produit->getType()->getLabeletype();
  3231.                 $p["ident"] = $produit->getLabele();
  3232.                 $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3233.                 $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3234.                 $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3235.                 $p["condition"] = $produit->getIdConditionnement()->getId();
  3236.                 $p["qte"] = 1;
  3237.                 array_push($Products$p);
  3238.             }
  3239.             $session->set('Panier'$Products);
  3240.         }
  3241.         //sendmail_parent
  3242.         $dateNow = new \Datetime();
  3243.         /** @var \App\Entity\User $user */
  3244.         $user $this->getUser();
  3245.         $userEmail $user->getEmail();
  3246.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3247.         // $this->EmailServie->MailRelancePanier($userEmail);
  3248.         return new response($Album->getId());
  3249.     }
  3250.     /**
  3251.      * @Route("/Parent/SaveCalendrierParent", name="SaveCalendrierParent")
  3252.      */
  3253.     public function SaveCalendrierParent(Request $request)
  3254.     {
  3255.         $session $this->session;
  3256.         $serviceuser $this->etablissementService;
  3257.         $page $request->get("pages");
  3258.         $sejour $request->get("sejour");
  3259.         $prodid $request->get('idProd');
  3260.         $nomprod $request->get('nomprod');
  3261.         $nbr $request->get('nbr');
  3262.         $user $this->getUser();
  3263.         $nbr strval($nbr);
  3264.         $produittype $session->get("produit");
  3265.         $produit $session->get("produittype");
  3266.         $Album $serviceuser->SaveCalendrierParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3267.         //sendmail_parent
  3268.         $dateNow = new \Datetime();
  3269.         /** @var \App\Entity\User $user */
  3270.         $user $this->getUser();
  3271.         $userEmail $user->getEmail();
  3272.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3273.         //$this->EmailServie->MailRelancePanier($userEmail);
  3274.         return new response('done');
  3275.     }
  3276.     /**
  3277.      * @Route("/Parent/SaveCommandeCalendrierParent", name="SaveCommandeCalendrierParent")
  3278.      */
  3279.     public function SaveCommandeCalendrierParent(Request $request)
  3280.     {
  3281.         $em $this->em;
  3282.         $session $this->session;
  3283.         $serviceuser $this->etablissementService;
  3284.         $page $request->get("pages");
  3285.         $sejour $request->get("sejour");
  3286.         $prodid $request->get('idProd');
  3287.         $nomprod $request->get('nomprod');
  3288.         $nbr $request->get('nbr');
  3289.         $user $this->getUser();
  3290.         $nbr strval($nbr);
  3291.         $produittype $session->get("produit");
  3292.         $produit $session->get("produittype");
  3293.         $Album $serviceuser->SaveCalendrierParent($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3294.         $inser false;
  3295.         $Products $session->get("Panier");
  3296.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  3297.         //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
  3298.         $user $this->getUser();
  3299.         $typeref $em->getRepository(Typeref::class)->find(8);
  3300.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3301.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3302.         //fin
  3303.         if ($panierTrace == null) {
  3304.             $panierTrace = new Panier();
  3305.             $dateNow = new \Datetime();
  3306.             $panierTrace->setDateCreation($dateNow);
  3307.             $panierTrace->setCreerPar($user);
  3308.             $panierTrace->setStatut($statutPanier);
  3309.             $em->getManager()->persist($panierTrace);
  3310.             $em->getManager()->flush();
  3311.         }
  3312.         //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
  3313.         if ($Products == null) {
  3314.             $Products = [];
  3315.         }
  3316.         foreach ($Products as $key => $p) {
  3317.             if ($p['id'] == $produit->getId()) {
  3318.                 $inser true;
  3319.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3320.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3321.             }
  3322.         }
  3323.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  3324.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3325.         if ($panierProduit == null) {
  3326.             $panierProduit = new PanierProduit();
  3327.             $panierProduit->setIdProduit($produit);
  3328.             $panierProduit->setIdPanier($panierTrace);
  3329.             $em->getManager()->persist($panierProduit);
  3330.             $em->getManager()->flush();
  3331.         }
  3332.         //fin
  3333.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  3334.         $oldQte $panierProduit->getQuantite();
  3335.         $newQte $oldQte 1;
  3336.         $panierProduit->setQuantite($newQte);
  3337.         $oldTotal $panierProduit->getPrixTotal();
  3338.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3339.         $panierProduit->setPrixTotal($newTotal);
  3340.         $em->getManager()->persist($panierProduit);
  3341.         $em->getManager()->flush();
  3342.         //fin
  3343.         if ($inser === false) {
  3344.             $p = [];
  3345.             $p["id"] = $produit->getId();
  3346.             $p["nom"] = $produit->getType()->getLabeletype();
  3347.             $p["ident"] = $produit->getLabele();
  3348.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3349.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3350.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3351.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3352.             $p["qte"] = 1;
  3353.             array_push($Products$p);
  3354.         }
  3355.         $session->set('Panier'$Products);
  3356.         //sendmail_parent
  3357.         $dateNow = new \Datetime();
  3358.         /** @var \App\Entity\User $user */
  3359.         $user $this->getUser();
  3360.         $userEmail $user->getEmail();
  3361.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  3362.         // $this->EmailServie->MailRelancePanier($userEmail);
  3363.         return new response('done');
  3364.     }
  3365.     /**
  3366.      * @Route("/Parent/SavePdfParent", name="SavePdfParent")
  3367.      */
  3368.     public function SavePdfParent(Request $request)
  3369.     {
  3370.         //        $blob = $request->get("blob");
  3371.         if (!empty($_POST['blob'])) {
  3372.             $data $_POST['blob'];
  3373.             $fname "test.pdf"// name the file
  3374.             $file fopen("pdf/" $fname'w'); // open the file path
  3375.             fwrite($file$data); //save data
  3376.             fclose($file);
  3377.         } else {
  3378.             echo "No Data Sent";
  3379.         }
  3380.         return new response('ok');
  3381.     }
  3382.     /**
  3383.      * @Route("/Parent/infosphp", name="infos")
  3384.      */
  3385.     public function infos()
  3386.     {
  3387.         echo phpinfo();
  3388.     }
  3389.     /**
  3390.      * @Route("/Parent/RetrosComandeSaveRetros", name="RetrosComandeSaveRetros")
  3391.      */
  3392.     public function RetrosComandeSaveRetros(Request $request)
  3393.     {
  3394.         $em $this->em;
  3395.         $session $this->session;
  3396.         $serviceuser $this->etablissementService;
  3397.         $page $request->get("pages");
  3398.         $sejour $request->get("sejour");
  3399.         $prodid $request->get('idProd');
  3400.         $nomprod $request->get('nomprod');
  3401.         $nbr $request->get('nbr');
  3402.         $user $this->getUser();
  3403.         $nbr strval($nbr);
  3404.         $produittype $session->get("produit");
  3405.         $produit $session->get("produittype");
  3406.         $Album $serviceuser->SavePhotosRetrosParents($page$user$sejour$prodid$produit$produittype$nbr$nomprod);
  3407.         $inser false;
  3408.         $Products $session->get("Panier");
  3409.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  3410.         //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
  3411.         $user $this->getUser();
  3412.         $typeref $em->getRepository(Typeref::class)->find(8);
  3413.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3414.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3415.         //fin
  3416.         if ($panierTrace == null) {
  3417.             $panierTrace = new Panier();
  3418.             $dateNow = new \Datetime();
  3419.             $panierTrace->setDateCreation($dateNow);
  3420.             $panierTrace->setCreerPar($user);
  3421.             $panierTrace->setStatut($statutPanier);
  3422.             $em->getManager()->persist($panierTrace);
  3423.             $em->getManager()->flush();
  3424.         }
  3425.         //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
  3426.         if ($Products == null) {
  3427.             $Products = [];
  3428.         }
  3429.         foreach ($Products as $key => $p) {
  3430.             if ($p['id'] == $produit->getId()) {
  3431.                 $inser true;
  3432.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3433.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  3434.             }
  3435.         }
  3436.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  3437.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3438.         if ($panierProduit == null) {
  3439.             $panierProduit = new PanierProduit();
  3440.             $panierProduit->setIdProduit($produit);
  3441.             $panierProduit->setIdPanier($panierTrace);
  3442.             $em->getManager()->persist($panierProduit);
  3443.             $em->getManager()->flush();
  3444.         }
  3445.         //fin
  3446.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  3447.         $oldQte $panierProduit->getQuantite();
  3448.         $newQte $oldQte 1;
  3449.         $panierProduit->setQuantite($newQte);
  3450.         $oldTotal $panierProduit->getPrixTotal();
  3451.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3452.         $panierProduit->setPrixTotal($newTotal);
  3453.         $em->getManager()->persist($panierProduit);
  3454.         $em->getManager()->flush();
  3455.         //fin
  3456.         if ($inser === false) {
  3457.             $p = [];
  3458.             $p["id"] = $produit->getId();
  3459.             $p["nom"] = $produit->getType()->getLabeletype();
  3460.             $p["ident"] = $produit->getLabele();
  3461.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3462.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3463.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3464.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3465.             $p["qte"] = 1;
  3466.             array_push($Products$p);
  3467.         }
  3468.         $session->set('Panier'$Products);
  3469.         return new response('done');
  3470.     }
  3471.     /**
  3472.      * @Route("/Parent/nbvisite", name="nbvisite",methods={"POST","GET"})
  3473.      */
  3474.     public function ajouternombrevisite(Request $request)
  3475.     {
  3476.         $SejourService $this->sejourService;
  3477.         $CarteService $this->carteService;
  3478.         $typevisite $request->get("typevisite");
  3479.         $idsejour $request->get("idsejour");
  3480.         $idattach $request->get("idattachement");
  3481.         if ($typevisite == "carte") {
  3482.             $nbvisite $CarteService->carteVisite($idsejour);
  3483.         } else {
  3484.             $nbvisite $SejourService->affectationnbvisiteattachement($idsejour$idattach);
  3485.         }
  3486.         return new JsonResponse('done');
  3487.     }
  3488.     /**
  3489.      * @Route("/Parent/ajouterauPanier_Parent", name="Ajouter_MonPanier")
  3490.      */
  3491.     public function Ajouter_MonPanier(Request $request)
  3492.     {
  3493.         $inser false;
  3494.         $session $this->session;
  3495.         $em $this->em;
  3496.         $Products $session->get("Panier");
  3497.         $id $request->get("id");
  3498.         //Touhemi :Rechercher  si l'utilisateur a déja un panier avec statut créer ds la bd , sinon on écrit un panier
  3499.         $user $this->getUser();
  3500.         $typeref $em->getRepository(Typeref::class)->find(8);
  3501.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3502.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3503.         //fin
  3504.         if ($panierTrace == null) {
  3505.             $panierTrace = new Panier();
  3506.             $dateNow = new \Datetime();
  3507.             $panierTrace->setDateCreation($dateNow);
  3508.             $panierTrace->setCreerPar($user);
  3509.             $panierTrace->setStatut($statutPanier);
  3510.             $em->getManager()->persist($panierTrace);
  3511.             $em->getManager()->flush();
  3512.         }
  3513.         $produit $this->em->getRepository(Produit::class)->find($id);
  3514.         if ($Products == null) {
  3515.             $Products = [];
  3516.         }
  3517.         //Touhemi :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.         foreach ($Products as $key => $p) {
  3528.             if ($p['id'] == $produit->getId()) {
  3529.                 $inser true;
  3530.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3531.             }
  3532.         }
  3533.         //Touhemi ajouter plus un au produit et modifier prixTotal
  3534.         $oldQte $panierProduit->getQuantite();
  3535.         $newQte $oldQte 1;
  3536.         $panierProduit->setQuantite($newQte);
  3537.         $oldTotal $panierProduit->getPrixTotal();
  3538.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3539.         $panierProduit->setPrixTotal($newTotal);
  3540.         $this->em->getManager()->persist($panierProduit);
  3541.         $this->em->getManager()->flush();
  3542.         //fin
  3543.         if ($inser === false) {
  3544.             //get nessaisire element
  3545.             $p = [];
  3546.             $p["id"] = $produit->getId();
  3547.             $p["nom"] = $produit->getType()->getLabeletype();
  3548.             $p["ident"] = $produit->getLabele();
  3549.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  3550.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  3551.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  3552.             $p["condition"] = $produit->getIdConditionnement()->getId();
  3553.             $p["qte"] = 1;
  3554.             array_push($Products$p);
  3555.         }
  3556.         $session->set('Panier'$Products);
  3557.         return new JsonResponse(['success' => true'message' => 'Produit ajouté au panier']);
  3558.     }
  3559.     /**
  3560.      * Ajoute l'album du séjour au panier et redirige vers la page commande.
  3561.      * @Route("/Parent/Ajouter_Album_Sejour_Et_Commander", name="Ajouter_Album_Sejour_Et_Commander", methods={"GET"})
  3562.      */
  3563.     public function Ajouter_Album_Sejour_Et_Commander(Request $request)
  3564.     {
  3565.         $id $request->query->get('id');
  3566.         if (!$id) {
  3567.             $this->addFlash('warning''Album non spécifié.');
  3568.             return $this->redirectToRoute('Album_du_Sejour');
  3569.         }
  3570.         $session $this->session;
  3571.         $em $this->em;
  3572.         $user $this->getUser();
  3573.         if (!$user) {
  3574.             return $this->redirectToRoute('app_login');
  3575.         }
  3576.         $Products $session->get('Panier');
  3577.         if ($Products === null) {
  3578.             $Products = [];
  3579.         }
  3580.         $typeref $em->getRepository(Typeref::class)->find(8);
  3581.         $statutPanier $em->getRepository(Ref::class)->findOneBy(['libiller' => 'creer''typeref' => $typeref]);
  3582.         $panierTrace $em->getRepository(Panier::class)->findOneBy(['creerPar' => $user'statut' => $statutPanier]);
  3583.         if ($panierTrace === null) {
  3584.             $panierTrace = new Panier();
  3585.             $panierTrace->setDateCreation(new \DateTime());
  3586.             $panierTrace->setCreerPar($user);
  3587.             $panierTrace->setStatut($statutPanier);
  3588.             $em->getManager()->persist($panierTrace);
  3589.             $em->getManager()->flush();
  3590.         }
  3591.         $produit $em->getRepository(Produit::class)->find($id);
  3592.         if (!$produit) {
  3593.             $this->addFlash('error''Album introuvable.');
  3594.             return $this->redirectToRoute('Album_du_Sejour');
  3595.         }
  3596.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(['idProduit' => $produit'idPanier' => $panierTrace]);
  3597.         if ($panierProduit === null) {
  3598.             $panierProduit = new PanierProduit();
  3599.             $panierProduit->setIdProduit($produit);
  3600.             $panierProduit->setIdPanier($panierTrace);
  3601.             $em->getManager()->persist($panierProduit);
  3602.             $em->getManager()->flush();
  3603.         }
  3604.         $oldQte $panierProduit->getQuantite();
  3605.         $panierProduit->setQuantite($oldQte 1);
  3606.         $oldTotal $panierProduit->getPrixTotal();
  3607.         $panierProduit->setPrixTotal($oldTotal $produit->getIdConditionnement()->getMontantTTC());
  3608.         $em->getManager()->persist($panierProduit);
  3609.         $em->getManager()->flush();
  3610.         $inser false;
  3611.         foreach ($Products as $key => $p) {
  3612.             if (isset($p['id']) && (int) $p['id'] === (int) $produit->getId()) {
  3613.                 $inser true;
  3614.                 $Products[$key]['qte'] = ($p['qte'] ?? 1) + 1;
  3615.                 $Products[$key]['mnt'] = ($p['mnt'] ?? 0) + $produit->getIdConditionnement()->getMontantTTC();
  3616.                 break;
  3617.             }
  3618.         }
  3619.         if (!$inser) {
  3620.             $attachments $produit->getType()->getAttachements();
  3621.             $path $attachments && $attachments->count() > 0
  3622.                 $attachments->get(0)->getIdAttachement()->getPath()
  3623.                 : '';
  3624.             $Products[] = [
  3625.                 'id' => $produit->getId(),
  3626.                 'nom' => $produit->getType()->getLabeletype(),
  3627.                 'ident' => $produit->getLabele(),
  3628.                 'codesejour' => $produit->getIdsjour()->getcodeSejour(),
  3629.                 'mnt' => $produit->getIdConditionnement()->getMontantTTC(),
  3630.                 'path' => $path,
  3631.                 'condition' => $produit->getIdConditionnement()->getId(),
  3632.                 'qte' => 1,
  3633.             ];
  3634.         }
  3635.         $session->set('Panier'$Products);
  3636.         return $this->redirectToRoute('Commander');
  3637.     }
  3638.     /**
  3639.      * @Route("/Parent/Ajouter_Album_Parent", name="Ajouter_Album_Parent_Alb")
  3640.      */
  3641.     public function Ajouter_Album(Request $request)
  3642.     {
  3643.         $session $this->session;
  3644.         $id $request->get("id");
  3645.         $typeProdcondition $this->em->getRepository(TypeProduitConditionnement::class)->find($id);
  3646.         $typeprod $typeProdcondition->getIdTypeProduit()->getId();
  3647.         $session->set('produit'$id);
  3648.         $session->set('produitconditionAlbum'$id);
  3649.         $session->set('produittype'$typeprod);
  3650.         return new JsonResponse('done');
  3651.     }
  3652.     /**
  3653.      * @Route("/Parent/ComandeParent", name="ComandeParent")
  3654.      */
  3655.     public function comande_Parent(Request $request)
  3656.     {
  3657.         $session $this->session;
  3658.         // $comande = $request->get("p");
  3659.         $Panier $session->get("Panier");
  3660.         $session->set('comande'$Panier);
  3661.         return new JsonResponse('done');
  3662.     }
  3663.     /**
  3664.      * @Route("/Parent/Accueil5sur5/adresse_comande", name="adresse_comande",methods={"POST"})
  3665.      */
  3666.     public function adresse_comande(Request $request)
  3667.     {
  3668.         $UserService $this->userService;
  3669.         /** @var \App\Entity\User $user */
  3670.         $user $this->getUser();
  3671.         $iduser $user->getId();
  3672.         $idCommande $request->get("idCommande");
  3673.         $prenom $request->get("prenom");
  3674.         $nom $request->get("nom");
  3675.         $organism $request->get("organism");
  3676.         $rue $request->get('ruevoi');
  3677.         $ville $request->get("villle");
  3678.         $pays $request->get("pays");
  3679.         $codepostal $request->get("codpostal");
  3680.         //adress facturation if exsist
  3681.         $prenomfacturation $request->get("prenomadressfacturation");
  3682.         $nomfacturation $request->get("nomadressfacturation");
  3683.         $organismfacturation $request->get("etablismadressfacturation");
  3684.         $ruefacturation $request->get('rueadressfacturation');
  3685.         $villefacturation $request->get("villefacturation");
  3686.         $paysfacturation $request->get("payadressfacturation");
  3687.         $codepostalfacturation $request->get("codepostalfacturation");
  3688.         //modification userPArent
  3689.         $em $this->em;
  3690.         $adress $UserService->modifieradress_comande($rue$ville$pays$codepostal$iduser$prenom$nom$organism$prenomfacturation$nomfacturation$organismfacturation$ruefacturation$villefacturation$paysfacturation$codepostalfacturation);
  3691.         $commande $em->getRepository(Commande::class)->findOneBy(array("id" => $idCommande));
  3692.         $commande->setAdresslivraison($adress);
  3693.         $commande->setAddresseLivraison($ville);
  3694.         $commande->setAdressfactoration($adress);
  3695.         $em->getManager()->persist($commande);
  3696.         $em->getManager()->flush();
  3697.         return new JsonResponse('Adresse Enregitrée');
  3698.     }
  3699.     /**
  3700.      * @Route("/Parent/Accueil5sur5/codesecuriter", name="codesecuriter",methods={"POST"})
  3701.      */
  3702.     public function codesecuriter(Request $request)
  3703.     {
  3704.         $UserService $this->userService;
  3705.         /** @var \App\Entity\User $user */
  3706.         $user $this->getUser();
  3707.         $iduser $user->getId();
  3708.         $code1 $request->get("code1");
  3709.         $code2 $request->get("code2");
  3710.         $code3 $request->get("code3");
  3711.         $set1 $request->get("set");
  3712.         if ($set1 == 1) {
  3713.             if ($code1 == "") {
  3714.                 return new Response('erore');
  3715.             }
  3716.             $adress $UserService->codesecuriter($code1$iduser);
  3717.         }
  3718.         if ($set1 == 2) {
  3719.             if ($code2 == "") {
  3720.                 return new Response('erore');
  3721.             }
  3722.             $adress $UserService->codesecuriter($code2$iduser);
  3723.         }
  3724.         if ($set1 == 3) {
  3725.             if ($code3 == "") {
  3726.                 return new Response('erore');
  3727.             }
  3728.             $adress $UserService->codesecuriter($code3$iduser);
  3729.         }
  3730.         return new Response('done');
  3731.     }
  3732.     /**
  3733.      * @Route("/Parent/Accueil5sur5/suprimer_Album_panier", name="suprimer_Album_panier",methods={"POST"})
  3734.      */
  3735.     public function suprimer_Album_panier(Request $request)
  3736.     {
  3737.         $session $this->session;
  3738.         $Products $session->get("Panier");
  3739.         $id $request->get("p");
  3740.         foreach ($Products as $key => $p) {
  3741.             if ($p['id'] == $id) {
  3742.                 unset($Products[$key]);
  3743.             }
  3744.         }
  3745.         $session->set('Panier'$Products);
  3746.         $em $this->em;
  3747.         $user $this->getUser();
  3748.         $produit $em->getRepository(Produit::class)->find($id);
  3749.         $typeref $em->getRepository(Typeref::class)->find(8);
  3750.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3751.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3752.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3753.         $em->getManager()->remove($panierProduit);
  3754.         $em->getManager()->flush();
  3755.         return new Response('done');
  3756.     }
  3757.     /**
  3758.      * @Route("/Parent/Accueil5sur5/additiondproduit_parent", name="additiondproduit_parent",methods={"POST"})
  3759.      */
  3760.     public function additiondproduit_parent(Request $request)
  3761.     {
  3762.         $session $this->session;
  3763.         $Products $session->get("Panier");
  3764.         $id $request->get("p");
  3765.         foreach ($Products as $key => $p) {
  3766.             if ($p['id'] == $id) {
  3767.                 $qte_dans_panier $Products[$key]['qte'];
  3768.                 $mnt_dans_panier $Products[$key]['mnt'] / $qte_dans_panier;
  3769.                 $Products[$key]['qte'] = $p['qte'] + 1;
  3770.                 // $Products[$key]['mnt']=$p['mnt']+$mnt_dans_panier;
  3771.             }
  3772.         }
  3773.         $session->set('Panier'$Products);
  3774.         //Touhemi addition au panier produit ds bd
  3775.         $em $this->em;
  3776.         $user $this->getUser();
  3777.         $produit $em->getRepository(Produit::class)->find($id);
  3778.         $typeref $em->getRepository(Typeref::class)->find(8);
  3779.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3780.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3781.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3782.         if ($panierProduit != null) {
  3783.             $oldQte $panierProduit->getQuantite();
  3784.             $newQte $oldQte 1;
  3785.             $panierProduit->setQuantite($newQte);
  3786.             $oldTotal $panierProduit->getPrixTotal();
  3787.             $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3788.             $panierProduit->setPrixTotal($newTotal);
  3789.             $em->getManager()->persist($panierProduit);
  3790.             $em->getManager()->flush();
  3791.         }
  3792.         return new Response('done');
  3793.     }
  3794.     /**
  3795.      * @Route("/Parent/Accueil5sur5/sousstractionproduit_parent", name="sousstractionproduit_parent",methods={"POST"})
  3796.      */
  3797.     public function sousstractionproduit_parent(Request $request)
  3798.     {
  3799.         $session $this->session;
  3800.         $Products $session->get("Panier");
  3801.         $id $request->get("p");
  3802.         foreach ($Products as $key => $p) {
  3803.             if ($p['id'] == $id) {
  3804.                 $qte_dans_panier $Products[$key]['qte'];
  3805.                 $mnt_dans_panier $Products[$key]['mnt'] / $qte_dans_panier;
  3806.                 $Products[$key]['qte'] = $p['qte'] - 1;
  3807.                 // $Products[$key]['mnt']=$p['mnt']-$mnt_dans_panier;
  3808.                 $set $Products[$key];
  3809.             }
  3810.             if ($Products[$key]['qte'] == 0) {
  3811.                 unset($Products[$key]);
  3812.             }
  3813.         }
  3814.         $session->set('Panier'$Products);
  3815.         $em $this->em;
  3816.         $user $this->getUser();
  3817.         $produit $em->getRepository(Produit::class)->find($id);
  3818.         $typeref $em->getRepository(Typeref::class)->find(8);
  3819.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  3820.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  3821.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  3822.         if ($panierProduit != null) {
  3823.             $oldQte $panierProduit->getQuantite();
  3824.             $newQte $oldQte 1;
  3825.             if ($newQte 0) {
  3826.                 $panierProduit->setQuantite($newQte);
  3827.                 $oldTotal $panierProduit->getPrixTotal();
  3828.                 $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  3829.                 $panierProduit->setPrixTotal($newTotal);
  3830.                 $em->getManager()->persist($panierProduit);
  3831.                 $em->getManager()->flush();
  3832.             }
  3833.             if ($newQte == 0) {
  3834.                 $em->getManager()->remove($panierProduit);
  3835.                 $em->getManager()->flush();
  3836.             }
  3837.         }
  3838.         return new Response('done');
  3839.     }
  3840.     /**
  3841.      * @Route("Parent/AjoutAlbum_parent/{idAlbm}", name="EditionAlbumfrompanier")
  3842.      */
  3843.     public function EditionAlbumParent_panier($idAlbm)
  3844.     {
  3845.         $SEjourService $this->sejourService;
  3846.         /** @var \App\Entity\User $user */
  3847.         $user $this->getUser();
  3848.         $userId $user->getId();
  3849.         $user $this->getUser();
  3850.         $session $this->session;
  3851.         $session->set('pageMenu''');
  3852.         $idSejour $session->get("Sejour");
  3853.         $produitcondition $session->get("produit");
  3854.         $produit $session->get("produittype");
  3855.         $sejour $SEjourService->getsejourpourparent($idSejour);
  3856.         $em $this->em;
  3857.         $clipart null;
  3858.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  3859.         $nbLikes 0;
  3860.         if ($listeattachlikephoto) {
  3861.             $nbLikes count($listeattachlikephoto);
  3862.         }
  3863.         $AllPages null;
  3864.         $Albumproduct null;
  3865.         $AllPagesAcc null;
  3866.         $random false;
  3867.         $Albumproduct $em->getRepository(Produit::class)->find($idAlbm);
  3868.         if ($Albumproduct == null || $Albumproduct == "") {
  3869.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
  3870.             $random true;
  3871.         }
  3872.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  3873.         $idAcc $sejour->getIdAcommp();
  3874.         $albumAcc null;
  3875.         $allpagesResult = array();
  3876.         $tabacc = array();
  3877.         $tabacc1 = array();
  3878.         foreach ($AllPages as $page) {
  3879.             $pageJ json_decode($page->getCouleurbordure());
  3880.             $pageDec json_decode($pageJ[0]);
  3881.             $attache json_decode($pageDec->attache);
  3882.             foreach ($attache as $att) {
  3883.                 $attachDec json_decode($att);
  3884.                 if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  3885.                     $idAttach json_decode($attachDec->id);
  3886.                     array_push($tabacc$idAttach);
  3887.                 }
  3888.             }
  3889.         }
  3890.         $tabacc1 array_count_values($tabacc);
  3891.         $part $sejour->getIdPartenaire();
  3892.         $nompart $part->getUsername();
  3893.         $logopart $part->getLogourl();
  3894.         $session->set('produit'$Albumproduct->gettype());
  3895.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  3896.         $nbphoto count($listeattach);
  3897.         if ($Albumproduct->getVersion() === 'new') {
  3898.             if ($nbLikes != 0) {
  3899.                 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]);
  3900.             }
  3901.             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]);
  3902.         } else {
  3903.             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]);
  3904.         }
  3905.     }
  3906.     /**
  3907.      * @Route("/Parent/Accueil5sur5/modifierLabel_produit_parent", name="modifierLabel_produit_parent",methods={"POST"})
  3908.      */
  3909.     public function modifierLabel_produit_parent(Request $request)
  3910.     {
  3911.         $SEjourService $this->sejourService;
  3912.         /** @var \App\Entity\User $user */
  3913.         $user $this->getUser();
  3914.         $userId $user->getId();
  3915.         $session $this->session;
  3916.         $idPrd $request->get("id");
  3917.         $description $request->get("description");
  3918.         $SEjourService->modif_lbel_Produit($idPrd$description);
  3919.         $Products $session->get("Panier");
  3920.         if ($Products != null) {
  3921.             foreach ($Products as $key => $p) {
  3922.                 if ($idPrd == $p['id']) {
  3923.                     $Products[$key]["ident"] = $description;
  3924.                 }
  3925.             }
  3926.         }
  3927.         $session->set('Panier'$Products);
  3928.         return new Response('done');
  3929.     }
  3930.     /**
  3931.      * @Route("/Parent/checkCodePromoParents", name="checkCodePromoParents")
  3932.      */
  3933.     public function checkCodePromoParents(Request $request)
  3934.     {
  3935.         $em $this->em;
  3936.         $SejourService $this->sejourService;
  3937.         $session $this->get('session');
  3938.         $code $request->get('code');
  3939.         $idUser $request->get('idUser');
  3940.         $user $em->getRepository(User::class)->findOneBy(['id' => $idUser]);
  3941.         $CodePromoUtilisse "";
  3942.         $totalpanier  $request->get('totalPanier');
  3943.         $infosPromo $SejourService->checkCodePromoPrents($code$user);
  3944.         $remise 0;
  3945.         $pourcentage 0;
  3946.         if (isset($infosPromo['remise'])) {
  3947.             $remise =  $infosPromo['remise'];
  3948.         }
  3949.         if (isset($infosPromo['pourcentage'])) {
  3950.             $pourcentage =  $infosPromo['pourcentage'];
  3951.         }
  3952.         $totalRemise $totalpanier $pourcentage;
  3953.         $totalRemise = ($totalRemise) / 100;
  3954.         $totalpanierNew $totalpanier $totalRemise;
  3955.         $tvaTotalRemise =   ($totalpanierNew 20) / 100;
  3956.         $user->setShowdetailsphotos("4");
  3957.         $em->getManager()->persist($user);
  3958.         $em->getManager()->flush();
  3959.         return new JsonResponse(array('message' =>  $infosPromo['test'], 'pourcentage' => intval($infosPromo['pourcentage']), 'remise' => $remise'totalDupanier' => $totalpanierNew'totalRemise' => $totalRemise"tvaTotalRemise" => $tvaTotalRemise"CodePromoUtilisse" => $CodePromoUtilisse), 200);
  3960.     }
  3961.     /**
  3962.      * @Route("/Parent/Accueil5sur5/ParentcomandeProduit", name="ParentcomandeProduit",methods={"POST"})
  3963.      */
  3964.     public function ParentcomandeProduit(Request $request)
  3965.     {
  3966.         $em $this->em;
  3967.         $comandeservice $this->commandeService;
  3968.         $sejourService $this->sejourService;
  3969.         /** @var \App\Entity\User $user */
  3970.         $user $this->getUser();
  3971.         $userId $user->getId();
  3972.         $session $this->session;
  3973.         $frais $request->get("fraiEnvoi");
  3974.         $Products $session->get("Panier");
  3975.         $totalepanier $request->get("totalepanier");
  3976.         $envoipost $request->get("envoipost");
  3977.         $remise $request->get("remise");
  3978.         $totalBlackFriday $request->get("totalBlackFriday");
  3979.         $session->set('envoipost'$envoipost);
  3980.         $containsProduitType20 false;
  3981.         $comand $comandeservice->addcomande_parent($Products$userId$frais$totalepanier$envoipost$remise$containsProduitType20);
  3982.         $codePromo $request->get('codePromo');
  3983.         $test $sejourService->checkCodePromo($codePromo);
  3984.         if (isset($test['test'])) {
  3985.             if ($test['test'] == true) {
  3986.                 $promotion $sejourService->findPromotionByCode($codePromo);
  3987.                 if ($promotion) {
  3988.                     $listeProduitsCommande $em->getRepository(ComandeProduit::class)->findBy(array('idComande' => $comand->getId()));
  3989.                     $pourcentage intval($promotion->getPourcentage());
  3990.                     if ($promotion->getNbreApplicable() == 1) {
  3991.                         foreach ($listeProduitsCommande as $cmdProduit) {
  3992.                             $cmdProduit->setPourcentage($pourcentage);
  3993.                             $em->getManager()->persist($cmdProduit);
  3994.                             $em->getManager()->flush();
  3995.                         }
  3996.                     } else {
  3997.                         foreach ($listeProduitsCommande as $cmdProduit) {
  3998.                             $qte $cmdProduit->getQuantiter();
  3999.                             for ($i 0$i $qte$i++) {
  4000.                                 $ligneCmdProd = new ComandeProduit();
  4001.                                 $ligneCmdProd->setQuantiter(1);
  4002.                                 $ligneCmdProd->setIdProduit($cmdProduit->getIdProduit());
  4003.                                 $ligneCmdProd->setIdComande($cmdProduit->getIdComande());
  4004.                                 $ligneCmdProd->setDate($cmdProduit->getDate());
  4005.                                 $em->getManager()->persist($ligneCmdProd);
  4006.                                 $em->getManager()->remove($cmdProduit);
  4007.                             }
  4008.                             $em->getManager()->flush();
  4009.                         }
  4010.                         $listeProduitsCommande $em->getRepository(ComandeProduit::class)->findBy(array('idComande' => $comand->getId()));
  4011.                         $qte 0;
  4012.                         $tabPrices = [];
  4013.                         foreach ($listeProduitsCommande as $cmdProduit) {
  4014.                             $ligne = array('idCmdProduit' => $cmdProduit->getId(), 'price' => $cmdProduit->getIdProduit()->getIdConditionnement()->getMontantTTC());
  4015.                             $qte += $cmdProduit->getQuantiter();
  4016.                             array_push($tabPrices$ligne);
  4017.                         }
  4018.                         $x intval($qte $promotion->getNbreApplicable());
  4019.                         $this->aasort($tabPrices"price");
  4020.                         $tabPricesPromo =   array_slice($tabPrices, -$x$xtrue);
  4021.                         foreach ($tabPricesPromo as $item) {
  4022.                             $cp $em->getRepository(ComandeProduit::class)->find($item['idCmdProduit']);
  4023.                             $cp->setPourcentage($pourcentage);
  4024.                             $em->getManager()->persist($cp);
  4025.                             $em->getManager()->flush();
  4026.                         }
  4027.                     }
  4028.                     $comand->setIdPromotion($promotion);
  4029.                 }
  4030.             }
  4031.         }
  4032.         $session->set('commandeActual'$comand->getId());
  4033.         return new Response($comand->getId());
  4034.     }
  4035.     function aasort(&$array$key)
  4036.     {
  4037.         $sorter = array();
  4038.         $ret = array();
  4039.         reset($array);
  4040.         foreach ($array as $ii => $va) {
  4041.             $sorter[$ii] = $va[$key];
  4042.         }
  4043.         arsort($sorter);
  4044.         foreach ($sorter as $ii => $va) {
  4045.             $ret[$ii] = $array[$ii];
  4046.         }
  4047.         $array $ret;
  4048.     }
  4049.     /**
  4050.      * @Route("Parent/LivreSejourParent", name="Livre_du_Sejour")
  4051.      */
  4052.     public function LivreSejourParent()
  4053.     {
  4054.         $SEjourService $this->sejourService;
  4055.         /** @var \App\Entity\User $user */
  4056.         $user $this->getUser();
  4057.         $userId $user->getId();
  4058.         $user $this->getUser();
  4059.         $session $this->session;
  4060.         $idSejour $session->get("Sejour");
  4061.         $session->set('LivreSejour''LivreSejour');
  4062.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4063.         $em $this->em;
  4064.         $clipart null;
  4065.         $AllPages null;
  4066.         $AllPagesAcc null;
  4067.         $random false;
  4068.         $codeSejour $sejour->getCodeSejour();
  4069.         $nomprod "Livre_Sejour" $codeSejour;
  4070.         $sejour $em->getRepository(Sejour::class)->findOneBy(['id' => $idSejour]);
  4071.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['version' => 'Livre_Sejour_Admin''labele' => $nomprod'idsjour' => $idSejour]);
  4072.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4073.         $tabacc = array();
  4074.         $tabacc1 = array();
  4075.         foreach ($AllPages as $page) {
  4076.             $pageJ json_decode($page->getCouleurbordure());
  4077.             $pageDec json_decode($pageJ[0]);
  4078.             $attache json_decode($pageDec->attache);
  4079.             foreach ($attache as $att) {
  4080.                 $attachDec json_decode($att);
  4081.                 if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  4082.                     $idAttach json_decode($attachDec->id);
  4083.                     array_push($tabacc$idAttach);
  4084.                 }
  4085.             }
  4086.         }
  4087.         $tabacc1 array_count_values($tabacc);
  4088.         $part $sejour->getIdPartenaire();
  4089.         $nompart $part->getUsername();
  4090.         $logopart $part->getLogourl();
  4091.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4092.         $nbPhoto count($listeattach);
  4093.         //  $session->set('produit', $Albumproduct->gettype());
  4094.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4095.         $nbLikes count($listeattachlikephoto);
  4096.         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]);
  4097.     }
  4098.     /**
  4099.      * @Route("Parent/LivrePhotos_Parent/{idAlbm}", name="Editionlivrefrompanier")
  4100.      */
  4101.     public function EditionLivrePhotosParentparId($idAlbm)
  4102.     {
  4103.         $SEjourService $this->sejourService;
  4104.         /** @var \App\Entity\User $user */
  4105.         $user $this->getUser();
  4106.         $userId $user->getId();
  4107.         $user $this->getUser();
  4108.         $session $this->session;
  4109.         $session->set('pageMenu''');
  4110.         $idSejour $session->get("Sejour");
  4111.         $produit $session->get("produit");
  4112.         // $sejour = $SEjourService->getsejourpourparent($idSejour);
  4113.         $sejour $this->em->getRepository(Sejour::class)->findOneBy(["id" => $idSejour]);
  4114.         $em $this->em;
  4115.         $clipart null;
  4116.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4117.         $nbLikes count($listeattachlikephoto);
  4118.         $AllPages null;
  4119.         $Albumproduct null;
  4120.         $AllPagesAcc null;
  4121.         $random false;
  4122.         $Albumproduct $em->getRepository(Produit::class)->find($idAlbm);
  4123.         if ($Albumproduct == null || $Albumproduct == "") {
  4124.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'random']);
  4125.             $random true;
  4126.         }
  4127.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4128.         $idAcc $sejour->getIdAcommp();
  4129.         $albumAcc null;
  4130.         $allpagesResult = array();
  4131.         $tabacc = array();
  4132.         $tabacc1 = array();
  4133.         foreach ($AllPages as $page) {
  4134.             $pageJ json_decode($page->getCouleurbordure());
  4135.             $pageDec json_decode($pageJ[0]);
  4136.             $attache json_decode($pageDec->attache);
  4137.             foreach ($attache as $att) {
  4138.                 $attachDec json_decode($att);
  4139.                 if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  4140.                     $idAttach json_decode($attachDec->id);
  4141.                     array_push($tabacc$idAttach);
  4142.                 }
  4143.             }
  4144.         }
  4145.         $tabacc1 array_count_values($tabacc);
  4146.         $part $sejour->getIdPartenaire();
  4147.         $nompart $part->getUsername();
  4148.         $logopart $part->getLogourl();
  4149.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4150.         $nbPhoto count($listeattach);
  4151.         $session->set('produit'$Albumproduct->gettype());
  4152.         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]);
  4153.     }
  4154.     /**
  4155.      * @Route("Parent/ModificationPochettePhotos/{nbr}/{id}", name="EditionPochettefrompanier")
  4156.      */
  4157.     public function EditionPochetteParentfrompanier($nbr$id)
  4158.     {
  4159.         $SEjourService $this->sejourService;
  4160.         /** @var \App\Entity\User $user */
  4161.         $user $this->getUser();
  4162.         $userId $user->getId();
  4163.         $user $this->getUser();
  4164.         $session $this->session;
  4165.         $session->set('pageMenu''');
  4166.         $idSejour $session->get("Sejour");
  4167.         $produitcondition $session->get("produit");
  4168.         $produit $session->get("produittype");
  4169.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4170.         $em $this->em;
  4171.         $clipart $em->getRepository(Clipart::class)->findAll();
  4172.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4173.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4174.         $nbLikes count($listeattachlikephoto);
  4175.         //Stella
  4176.         $AllPagesAcc null;
  4177.         $random false;
  4178.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  4179.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4180.         $idAcc $sejour->getIdAcommp();
  4181.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4182.         $part $sejour->getIdPartenaire();
  4183.         $nompart $part->getUsername();
  4184.         $logopart $part->getLogourl();
  4185.         $nomProjet $Albumproduct->getLabele();
  4186.         $nbPhoto count($listeattach);
  4187.         $nbLikes count($listeattachlikephoto);
  4188.         if ($nbLikes $nbr) {
  4189.             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]);
  4190.         }
  4191.         if ($nbLikes >= $nbr) {
  4192.             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]);
  4193.         }
  4194.     }
  4195.     /**
  4196.      * @Route("Parent/ModificationCalendrier/{id}", name="EditionCalendrierParentfrompanier")
  4197.      */
  4198.     public function EditionCalendrierParentfrompanier($id)
  4199.     {
  4200.         $SEjourService $this->sejourService;
  4201.         /** @var \App\Entity\User $user */
  4202.         $user $this->getUser();
  4203.         $userId $user->getId();
  4204.         $user $this->getUser();
  4205.         $session $this->session;
  4206.         $session->set('pageMenu''');
  4207.         $idSejour $session->get("Sejour");
  4208.         $produitcondition $session->get("produit");
  4209.         $produit $session->get("produittype");
  4210.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4211.         $em $this->em;
  4212.         $clipart $em->getRepository(Clipart::class)->findAll();
  4213.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4214.         $random false;
  4215.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  4216.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4217.         $part $sejour->getIdPartenaire();
  4218.         $nompart $part->getUsername();
  4219.         $logopart $part->getLogourl();
  4220.         return $this->render('Parent/Calendrier.html.twig', ["nompart" => $nompart"logopart" => $logopart"sejour" => $sejour'like' => $listeattachlikephoto'cliparts' => $clipart'Album' => $Albumproduct'AllPages' => $AllPages'random' => $random]);
  4221.     }
  4222.     /**
  4223.      * @Route("Parent/ModificationPhotosRetros/{nbr}/{id}", name="EditionRetrofrompanier")
  4224.      */
  4225.     public function EditionRetroParentfrompanier($nbr$id)
  4226.     {
  4227.         $SEjourService $this->sejourService;
  4228.         /** @var \App\Entity\User $user */
  4229.         $user $this->getUser();
  4230.         $userId $user->getId();
  4231.         $user $this->getUser();
  4232.         $session $this->session;
  4233.         $session->set('pageMenu''');
  4234.         $idSejour $session->get("Sejour");
  4235.         $produitcondition $session->get("produit");
  4236.         $produit $session->get("produittype");
  4237.         $sejour $SEjourService->getsejourpourparent($idSejour);
  4238.         $em $this->em;
  4239.         $clipart $em->getRepository(Clipart::class)->findAll();
  4240.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4241.         $listerandom $listeattachlikephoto;
  4242.         $nbLikes count($listeattachlikephoto);
  4243.         $AllPagesAcc null;
  4244.         $random false;
  4245.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  4246.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  4247.         $idAcc $sejour->getIdAcommp();
  4248.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4249.         $part $sejour->getIdPartenaire();
  4250.         $nompart $part->getUsername();
  4251.         $logopart $part->getLogourl();
  4252.         //Liste des photos public
  4253.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4254.         $nbPhoto =  $listeattach;
  4255.         if ($nbLikes == 0) {
  4256.             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]);
  4257.         }
  4258.         if ($nbLikes != 0) {
  4259.             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]);
  4260.         }
  4261.     }
  4262.     //CommanderalbumSejour
  4263.     /**
  4264.      * @Route("/Parent/CommanderalbumSejour", name="CommanderalbumSejour")
  4265.      */
  4266.     public function CommanderalbumSejour(Request $request)
  4267.     {
  4268.         $session $this->session;
  4269.         $serviceuser $this->etablissementService;
  4270.         $page $request->get("pages");
  4271.         $sejour $request->get("sejour");
  4272.         $prodid $request->get('idProd');
  4273.         $nomprod $request->get('nomprod');
  4274.         $versionalbm $request->get('new');
  4275.         $user $this->getUser();
  4276.         $em $this->em;
  4277.         //  $AlbumSejour  = $em->getRepository(Produit::class)->findOneBy(array("id" =>$prodid));
  4278.         $produit $session->get("produittype");
  4279.         $produitcondi $session->get("produit");
  4280.         $Album $serviceuser->saveCopyalbumParent($page$user$sejour$prodid$produit$produitcondi$nomprod$versionalbm);
  4281.         $inser false;
  4282.         $session $this->session;
  4283.         $Products $session->get("Panier");
  4284.         $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  4285.         $user $this->getUser();
  4286.         $typeref $em->getRepository(Typeref::class)->find(8);
  4287.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4288.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4289.         //fin
  4290.         if ($panierTrace == null) {
  4291.             $panierTrace = new Panier();
  4292.             $dateNow = new \Datetime();
  4293.             $panierTrace->setDateCreation($dateNow);
  4294.             $panierTrace->setCreerPar($user);
  4295.             $panierTrace->setStatut($statutPanier);
  4296.             $em->getManager()->persist($panierTrace);
  4297.             $em->getManager()->flush();
  4298.         }
  4299.         if ($Products == null) {
  4300.             $Products = [];
  4301.         }
  4302.         foreach ($Products as $key => $p) {
  4303.             if ($p['id'] == $produit->getId()) {
  4304.                 $inser true;
  4305.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4306.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  4307.             }
  4308.         }
  4309.         //Touhemi :Rechercher  si le produti existe déja ds panierProduit
  4310.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $Album"idPanier" => $panierTrace));
  4311.         if ($panierProduit == null) {
  4312.             $panierProduit = new PanierProduit();
  4313.             $panierProduit->setIdProduit($Album);
  4314.             $panierProduit->setIdPanier($panierTrace);
  4315.             $em->getManager()->persist($panierProduit);
  4316.             $em->getManager()->flush();
  4317.         }
  4318.         //fin
  4319.         //Touhemi ajouter plus un au produit et modifier prixTotal
  4320.         $oldQte $panierProduit->getQuantite();
  4321.         $newQte $oldQte 1;
  4322.         $panierProduit->setQuantite($newQte);
  4323.         $oldTotal $panierProduit->getPrixTotal();
  4324.         $newTotal $oldTotal $Album->getIdConditionnement()->getMontantTTC();
  4325.         $panierProduit->setPrixTotal($newTotal);
  4326.         $this->em->getManager()->persist($panierProduit);
  4327.         $this->em->getManager()->flush();
  4328.         //fin
  4329.         if ($inser === false) {
  4330.             //get nessaisire element
  4331.             $p = [];
  4332.             $p["id"] = $produit->getId();
  4333.             $p["nom"] = $produit->getType()->getLabeletype();
  4334.             $p["ident"] = $produit->getLabele();
  4335.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4336.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4337.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4338.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4339.             $p["qte"] = 1;
  4340.             array_push($Products$p);
  4341.         }
  4342.         $session->set('Panier'$Products);
  4343.         //sendemail_parent
  4344.         $dateNow = new \Datetime();
  4345.         /** @var \App\Entity\User $user */
  4346.         $user $this->getUser();
  4347.         $userEmail $user->getEmail();
  4348.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4349.         //$this->EmailServie->MailRelancePanier($userEmail);
  4350.         //dd($etablissementDetail);
  4351.         return new response('done');
  4352.     }
  4353.     /**
  4354.      * @Route("/Parent/AlbummsavealbumcomandeParent", name="AlbummsavealbumcomandeParent")
  4355.      */
  4356.     public function Albummcomandesavealbum(Request $request)
  4357.     {
  4358.         $session $this->session;
  4359.         $serviceuser $this->etablissementService;
  4360.         $page $request->get("pages");
  4361.         $sejour $request->get("sejour");
  4362.         $prodid $request->get('idProd');
  4363.         $nomprod $request->get('nomprod');
  4364.         $versionalbm $request->get('new');
  4365.         $user $this->getUser();
  4366.         $produit $session->get("produittype");
  4367.         $produitcondi $session->get("produit");
  4368.         $Album $serviceuser->savealbumParent($page$user$sejour$prodid$produit$produitcondi$nomprod$versionalbm);
  4369.         $inser false;
  4370.         $session $this->session;
  4371.         $Products $session->get("Panier");
  4372.         $produit $this->em->getRepository(Produit::class)->find($Album->getId());
  4373.         $em $this->em;
  4374.         $user $this->getUser();
  4375.         $typeref $em->getRepository(Typeref::class)->find(8);
  4376.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4377.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4378.         //fin
  4379.         if ($panierTrace == null) {
  4380.             $panierTrace = new Panier();
  4381.             $dateNow = new \Datetime();
  4382.             $panierTrace->setDateCreation($dateNow);
  4383.             $panierTrace->setCreerPar($user);
  4384.             $panierTrace->setStatut($statutPanier);
  4385.             $em->getManager()->persist($panierTrace);
  4386.             $em->getManager()->flush();
  4387.         }
  4388.         if ($Products == null) {
  4389.             $Products = [];
  4390.         }
  4391.         foreach ($Products as $key => $p) {
  4392.             if ($p['id'] == $produit->getId()) {
  4393.                 $inser true;
  4394.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4395.                 $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  4396.             }
  4397.         }
  4398.         //Touhemi :Rechercher  si le produti existe déja ds panierProduit
  4399.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $Album"idPanier" => $panierTrace));
  4400.         if ($panierProduit == null) {
  4401.             $panierProduit = new PanierProduit();
  4402.             $panierProduit->setIdProduit($Album);
  4403.             $panierProduit->setIdPanier($panierTrace);
  4404.             $em->getManager()->persist($panierProduit);
  4405.             $em->getManager()->flush();
  4406.         }
  4407.         //fin
  4408.         //Touhemi ajouter plus un au produit et modifier prixTotal
  4409.         $oldQte $panierProduit->getQuantite();
  4410.         $newQte $oldQte 1;
  4411.         $panierProduit->setQuantite($newQte);
  4412.         $oldTotal $panierProduit->getPrixTotal();
  4413.         $newTotal $oldTotal $Album->getIdConditionnement()->getMontantTTC();
  4414.         $panierProduit->setPrixTotal($newTotal);
  4415.         $this->em->getManager()->persist($panierProduit);
  4416.         $this->em->getManager()->flush();
  4417.         //fin
  4418.         if ($inser === false) {
  4419.             //get nessaisire element
  4420.             $p = [];
  4421.             $p["id"] = $produit->getId();
  4422.             $p["nom"] = $produit->getType()->getLabeletype();
  4423.             $p["ident"] = $produit->getLabele();
  4424.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4425.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4426.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4427.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4428.             $p["qte"] = 1;
  4429.             array_push($Products$p);
  4430.         }
  4431.         $session->set('Panier'$Products);
  4432.         //sendemail_parent
  4433.         $dateNow = new \Datetime();
  4434.         /** @var \App\Entity\User $user */
  4435.         $user $this->getUser();
  4436.         $userEmail $user->getEmail();
  4437.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4438.         //$this->EmailServie->MailRelancePanier($userEmail);
  4439.         //dd($etablissementDetail);
  4440.         return new response('done');
  4441.     }
  4442.     /**
  4443.      * @Route("/Parent/saveLivrePhotosParentPanier", name="saveLivrePhotosParentPanier")
  4444.      */
  4445.     public function saveLivrePhotospuisPanier(Request $request)
  4446.     {
  4447.         $em $this->em;
  4448.         $session $this->session;
  4449.         $produittype $session->get("produit");
  4450.         $produit $session->get("produittype");
  4451.         $serviceuser $this->etablissementService;
  4452.         $page $request->get("pages");
  4453.         $sejour $request->get("sejour");
  4454.         $prodid $request->get('idProd');
  4455.         $nomprod $request->get('nomprod');
  4456.         $versionalbm $request->get('new');
  4457.         $user $this->getUser();
  4458.         $Album $serviceuser->savelivreParent($page$user$sejour$prodid$produittype$nomprod$versionalbm);
  4459.         //dd($etablissementDetail);
  4460.         $inser false;
  4461.         $session $this->session;
  4462.         $Products $session->get("Panier");
  4463.         $produit $em->getRepository(Produit::class)->find($Album->getId());
  4464.         //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
  4465.         $user $this->getUser();
  4466.         $typeref $em->getRepository(Typeref::class)->find(8);
  4467.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4468.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4469.         //fin
  4470.         if ($panierTrace == null) {
  4471.             $panierTrace = new Panier();
  4472.             $dateNow = new \Datetime();
  4473.             $panierTrace->setDateCreation($dateNow);
  4474.             $panierTrace->setCreerPar($user);
  4475.             $panierTrace->setStatut($statutPanier);
  4476.             $em->getManager()->persist($panierTrace);
  4477.             $em->getManager()->flush();
  4478.         }
  4479.         //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
  4480.         if ($Products == null) {
  4481.             $Products = [];
  4482.         }
  4483.         foreach ($Products as $key => $p) {
  4484.             if ($p['id'] == $produit->getId()) {
  4485.                 $inser true;
  4486.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4487.                 // $Products[$key]['mnt'] = $p['mnt'] + $produit->getType()->getTraif();
  4488.             }
  4489.         }
  4490.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  4491.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  4492.         if ($panierProduit == null) {
  4493.             $panierProduit = new PanierProduit();
  4494.             $panierProduit->setIdProduit($produit);
  4495.             $panierProduit->setIdPanier($panierTrace);
  4496.             $em->getManager()->persist($panierProduit);
  4497.             $em->getManager()->flush();
  4498.         }
  4499.         //fin
  4500.         //   Touhemi 02-07-2020 ajouter plus un au produit et modifier prixTotal
  4501.         $oldQte $panierProduit->getQuantite();
  4502.         $newQte $oldQte 1;
  4503.         $panierProduit->setQuantite($newQte);
  4504.         $oldTotal $panierProduit->getPrixTotal();
  4505.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  4506.         $panierProduit->setPrixTotal($newTotal);
  4507.         $em->getManager()->persist($panierProduit);
  4508.         $em->getManager()->flush();
  4509.         //fin
  4510.         if ($inser === false) {
  4511.             //get nessaisire element
  4512.             $p = [];
  4513.             $p["id"] = $produit->getId();
  4514.             $p["nom"] = $produit->getType()->getLabeletype();
  4515.             $p["ident"] = $produit->getLabele();
  4516.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4517.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4518.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4519.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4520.             $p["qte"] = 1;
  4521.             array_push($Products$p);
  4522.         }
  4523.         $session->set('Panier'$Products);
  4524.         //sendmail_patrent
  4525.         $dateNow = new \Datetime();
  4526.         /** @var \App\Entity\User $user */
  4527.         $user $this->getUser();
  4528.         $userEmail $user->getEmail();
  4529.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4530.         // $this->EmailServie->MailRelancePanier($userEmail);
  4531.         return new response('done');
  4532.     }
  4533.     /**
  4534.      * @Route("parent/condcnx", name="connexionparentsejour",methods={"POST"})
  4535.      */
  4536.     public function condition(Request $request)
  4537.     {
  4538.         $UserService $this->userService;
  4539.         $id $request->get('id');
  4540.         $ParentSejour $UserService->conditioncnxparent($id);
  4541.         return new JsonResponse('done');
  4542.     }
  4543.     /**
  4544.      * @Route("/Parent/MaPropresPhotos", name="MaPropresPhotos")
  4545.      */
  4546.     public function MaPropresPhotos(Request $request)
  4547.     {
  4548.         $path $request->get("path");
  4549.         $type $request->get("type");
  4550.         $sejId $request->get("id");
  4551.         $dateSejour $request->get("date");
  4552.         $SejourServiceattachh $this->sejourService;
  4553.         $Userservicemail $this->userService;
  4554.         $sejourfind $SejourServiceattachh->sejoursansattach($sejId);
  4555.         //$sendmail = $Userservicemail->sendmailuserforfirstattach($sejId);
  4556.         $attachementservice $this->attachementService;
  4557.         foreach ($path as $key => $path) {
  4558.             $src $path['path'];
  4559.             $attachement $attachementservice->creationAttachementS($src$type$dateSejour);
  4560.             $sejourservice $this->sejourService;
  4561.             $sejAttach $sejourservice->monpropreattachement($sejId$attachement$this->getUser());
  4562.             if ((array_key_exists("latitude"$path)) && ($path['latitude'] != null)) {
  4563.                 $lat $path['latitude'];
  4564.                 $lng $path['longitude'];
  4565.                 $Cartervice $this->carteService;
  4566.                 $position $Cartervice->create_newPositionImage($this->getUser(), $lat$lng);
  4567.                 $Cartervice->affecterPosition($attachement$position);
  4568.                 $FindSejour $this->em->getRepository(Sejour::class)->find($sejId);
  4569.                 $FindSejour->setEtatAdresseCarte(true);
  4570.                 $this->em->getManager()->persist($FindSejour);
  4571.                 $this->em->getManager()->flush();
  4572.             }
  4573.             //Ajouter les photos aux favoris
  4574.             $Like $this->photosFavorisService;
  4575.             $Like->AddFavoris($this->getUser(), $attachement$sejId);
  4576.         }
  4577.         return new JsonResponse(["id" => $attachement->getId()]);;
  4578.     }
  4579.     /**
  4580.      * @Route("/Parent/Ajouter_photo_sejour", name="pathadddnewphotos")
  4581.      */
  4582.     public function pathaddnewphotos()
  4583.     {
  4584.         /** @var \App\Entity\User $user */
  4585.         $user $this->getUser();
  4586.         $userId $user->getId();
  4587.         $session $this->session;
  4588.         $idParent $session->get("Sejour");
  4589.         $idSejour $session->get("Sejour");
  4590.         $conxparent $this->sejourService;
  4591.         $sejour1 $conxparent->sejourParentcnx($idSejour$idParent);
  4592.         //dd($sejour1);
  4593.         $SEjourService $this->sejourService;
  4594.         $sejour $SEjourService->getsejour($idSejour);
  4595.         //  dd($sejour);
  4596.         //Liste des photos public
  4597.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4598.         //Liste des photos privé
  4599.         //        $listeattachPrivate = $SEjourService->getatachmentsejourparent($idSejour, $this->getUser()->getId());
  4600.         //        $AllPhotosParent = array_merge_recursive($listeattach, $listeattachPrivate);
  4601.         $listeVideo $SEjourService->getVideosejour($idSejour);
  4602.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  4603.         $nbImages count($listeattach);
  4604.         $positions $SEjourService->getsejourposition($idSejour);
  4605.         $messages $SEjourService->getsejourmessage($idSejour);
  4606.         $em $this->em;
  4607.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  4608.         //dd($parentsejour);
  4609.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4610.         $produits $this->typeProduiteService;
  4611.         $liste $produits->produitlistTypeConditionnement();
  4612.         $pubProd $user->getShowpubprod();
  4613.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4614.         if ($albumAcc == null) {
  4615.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  4616.         }
  4617.         return $this->render('Parent/DetailsSejour.html.twig', [
  4618.             "sejour" => $sejour,
  4619.             'listeattach' => $AllAttachements,
  4620.             'nbImages' => $nbImages,
  4621.             'albumAcc' => $albumAcc,
  4622.             'positions' => $positions,
  4623.             'messages' => $messages,
  4624.             'like' => $listeattachlikephoto,
  4625.             "parentsejour" => $parentsejour,
  4626.             'prod' => $liste,
  4627.             'smsnotif' => $parentsejour->getSmsnotif(),
  4628.             'showpub' => $pubProd
  4629.         ]);
  4630.     }
  4631.     /**
  4632.      * @Route("/Parent/ajouterauPanier_Parent_coffret", name="comandercoffre")
  4633.      */
  4634.     public function Ajouter_MonPanier_Coffret()
  4635.     {
  4636.         $em $this->em;
  4637.         $inser false;
  4638.         $session $this->session;
  4639.         $idSejour $session->get("Sejour");
  4640.         $userId $this->getUser();
  4641.         /** @var \App\Entity\User $user */
  4642.         $user $this->getUser();
  4643.         $userIdCom $user->getId();
  4644.         $sejourobj $this->em->getRepository(Sejour::class)->find($idSejour);
  4645.         $prodct $this->em->getRepository(Typeproduit::class)->find(15);
  4646.         $version $this->em->getRepository(Produit::class)->SearchVersionproduit($userIdCom);
  4647.         $Conditionnement $this->em->getRepository(TypeProduitConditionnement::class)->find(6);
  4648.         $Products $session->get("Panier");
  4649.         //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
  4650.         $user $this->getUser();
  4651.         $typeref $em->getRepository(Typeref::class)->find(8);
  4652.         $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  4653.         $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  4654.         //fin
  4655.         if ($panierTrace == null) {
  4656.             $panierTrace = new Panier();
  4657.             $dateNow = new \Datetime();
  4658.             $panierTrace->setDateCreation($dateNow);
  4659.             $panierTrace->setCreerPar($user);
  4660.             $panierTrace->setStatut($statutPanier);
  4661.             $em->getManager()->persist($panierTrace);
  4662.             $em->getManager()->flush();
  4663.         }
  4664.         //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
  4665.         $produit $em->getRepository(Produit::class)->findOneBy(array("type" => $prodct'idConditionnement' => $Conditionnement'idsjour' => $sejourobj'iduser' => $user));
  4666.         if ($produit == null) {
  4667.             $produit = new Produit;
  4668.             $produit->setLabele("Coffret cadeau");
  4669.             $produit->setIduser($userId);
  4670.             $produit->setIdsjour($sejourobj);
  4671.             $produit->setDate(new \DateTime());
  4672.             $produit->setIdConditionnement($Conditionnement);
  4673.             $produit->setType($prodct);
  4674.             $em->getManager()->persist($produit);
  4675.             $em->getManager()->flush();
  4676.         }
  4677.         if ($Products == null) {
  4678.             $Products = [];
  4679.         }
  4680.         foreach ($Products as $key => $p) {
  4681.             if ($p['id'] == $produit->getId()) {
  4682.                 $inser true;
  4683.                 $Products[$key]['qte'] = $p['qte'] + 1;
  4684.                 // $Products[$key]['mnt'] = $p['mnt'] + $produit->getType()->getTraif();
  4685.             }
  4686.         }
  4687.         //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  4688.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  4689.         if ($panierProduit == null) {
  4690.             $panierProduit = new PanierProduit();
  4691.             $panierProduit->setIdProduit($produit);
  4692.             $panierProduit->setIdPanier($panierTrace);
  4693.             $em->getManager()->persist($panierProduit);
  4694.             $em->getManager()->flush();
  4695.         }
  4696.         //fin
  4697.         //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  4698.         $oldQte $panierProduit->getQuantite();
  4699.         $newQte $oldQte 1;
  4700.         $panierProduit->setQuantite($newQte);
  4701.         $oldTotal $panierProduit->getPrixTotal();
  4702.         $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  4703.         $panierProduit->setPrixTotal($newTotal);
  4704.         $em->getManager()->persist($panierProduit);
  4705.         $em->getManager()->flush();
  4706.         //fin
  4707.         if ($inser === false) {
  4708.             //get nessaisire element
  4709.             $p = [];
  4710.             $p["id"] = $produit->getId();
  4711.             $p["nom"] = $produit->getType()->getLabeletype();
  4712.             $p["ident"] = $produit->getLabele();
  4713.             $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  4714.             $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  4715.             $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  4716.             $p["condition"] = $produit->getIdConditionnement()->getId();
  4717.             $p["qte"] = 1;
  4718.             array_push($Products$p);
  4719.         }
  4720.         //sendmailproduct_parent
  4721.         $dateNow = new \Datetime();
  4722.         /** @var \App\Entity\User $user */
  4723.         $user $this->getUser();
  4724.         $userEmail $user->getEmail();
  4725.         $userId $user->getId();
  4726.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  4727.         //$this->EmailServie->MailRelancePanier($userEmail);
  4728.         $listeproduit $prod $this->em->getRepository(Produit::class)->findby(array('iduser' => $userId));
  4729.         $session->set('Panier'$Products);
  4730.         $Panier $session->get("Panier");
  4731.         $produit $this->typeProduiteService;
  4732.         $produitlist $produit->produitlistTypeConditionnement();
  4733.         $this->session->set('rout''rout');
  4734.         $parentent_sejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idParent" => $this->getUser(), "idSejour" => $sejourobj]);
  4735.         $prodpanier = array();
  4736.         $nbrprodpromo 0;
  4737.         $nbralbum 0;
  4738.         $nbrlivre 0;
  4739.         $nbrphoto12 0;
  4740.         $nbrphoto24 0;
  4741.         $nbrphoto36 0;
  4742.         $nbrcal 0;
  4743.         $nbrretro12 0;
  4744.         $nbrretro24 0;
  4745.         $nbrretro36 0;
  4746.         $detailsprod = array();
  4747.         $prixalbum 0.0;
  4748.         $prixphoto12 0.0;
  4749.         $prixphoto24 0.0;
  4750.         $prixphoto36 0.0;
  4751.         $prixcal 0.0;
  4752.         $prixalbum 0.0;
  4753.         $prixretro12 0.0;
  4754.         $prixretro24 0.0;
  4755.         $prixretro36 0.0;
  4756.         $prodpanierpromo = array();
  4757.         $promo = array();
  4758.         foreach ($Panier as $key => $p) {
  4759.             if ($p['condition'] != null) {
  4760.                 array_push($prodpanier$p['condition']);
  4761.             }
  4762.             if ($p['condition'] != 11 && $p['condition'] != 6) {
  4763.                 $promo['condition'] = $p['condition'];
  4764.                 $nbrprodpromo $nbrprodpromo $p['qte'];
  4765.                 array_push($prodpanierpromo$promo);
  4766.                 if ($p['condition'] == 4) {
  4767.                     $nbralbum $nbralbum $p['qte'];
  4768.                     $prixalbum $p['mnt'];
  4769.                 } elseif ($p['condition'] == 1) {
  4770.                     $nbrphoto12 $nbrphoto12 $p['qte'];
  4771.                     $prixphoto12 $p['mnt'];
  4772.                 } elseif ($p['condition'] == 2) {
  4773.                     $nbrphoto24 $nbrphoto24 $p['qte'];
  4774.                     $prixphoto24 $p['mnt'];
  4775.                 } elseif ($p['condition'] == 3) {
  4776.                     $nbrphoto36 $nbrphoto36 $p['qte'];
  4777.                     $prixphoto36  $p['mnt'];
  4778.                 } elseif ($p['condition'] == 5) {
  4779.                     $nbrlivre $nbrlivre $p['qte'];
  4780.                     $prixlivre $p['mnt'];
  4781.                 } elseif ($p['condition'] == 7) {
  4782.                     $nbrcal $nbrcal $p['qte'];
  4783.                     $prixcal $p['mnt'];
  4784.                 } elseif ($p['condition'] == 8) {
  4785.                     $nbrretro36 $nbrretro36 $p['qte'];
  4786.                     $prixretro36 $p['mnt'];
  4787.                 } elseif ($p['condition'] == 9) {
  4788.                     $nbrretro12 $nbrretro12 $p['qte'];
  4789.                     $prixretro12 $p['mnt'];
  4790.                 } elseif ($p['condition'] == 10) {
  4791.                     $nbrretro24 $nbrretro24 $p['qte'];
  4792.                     $prixretro24 $p['mnt'];
  4793.                 }
  4794.             }
  4795.         }
  4796.         $detailsprod['album']['qt'] = $nbralbum;
  4797.         $detailsprod['album']['prix'] = $prixalbum;
  4798.         $detailsprod['photo12']['qt'] = $nbrphoto12;
  4799.         $detailsprod['photo12']['prix'] = $prixphoto12;
  4800.         $detailsprod['photo24']['qt'] = $nbrphoto24;
  4801.         $detailsprod['photo24']['prix'] = $prixphoto24;
  4802.         $detailsprod['photo36']['qt'] = $nbrphoto36;
  4803.         $detailsprod['photo36']['prix'] = $prixphoto36;
  4804.         $detailsprod['cal']['qt'] = $nbrcal;
  4805.         $detailsprod['cal']['prix'] = $prixcal;
  4806.         $detailsprod['livre']['qt'] = $nbrlivre;
  4807.         $detailsprod['livre']['prix'] = $prixalbum;
  4808.         $detailsprod['retro12']['qt'] = $nbrretro12;
  4809.         $detailsprod['retro12']['prix'] = $prixretro12;
  4810.         $detailsprod['retro24']['qt'] = $nbrretro24;
  4811.         $detailsprod['retro24']['prix'] = $prixretro24;
  4812.         $detailsprod['retro36']['qt'] = $nbrretro36;
  4813.         $detailsprod['retro36']['prix'] = $prixretro36;
  4814.         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]);
  4815.     }
  4816.     /**
  4817.      * @Route("/Parent/Boite_vocale", name="Boite_vocale")
  4818.      */
  4819.     public function Boite_Vocale()
  4820.     {
  4821.         /** @var \App\Entity\User $user */
  4822.         $user $this->getUser();
  4823.         $userId $user->getId();
  4824.         $session $this->session;
  4825.         $session->set('pageMenu''BoiteVocale');
  4826.         $idSejour $session->get("Sejour");
  4827.         $SEjourService $this->sejourService;
  4828.         $sejour $SEjourService->getsejour($idSejour);
  4829.         /*         $listeattach = $SEjourService->getatachmentsejour($idSejour);
  4830.         $listeVideo = $SEjourService->getVideosejour($idSejour);
  4831.         $AllAttachements = array_merge_recursive($listeattach, $listeVideo); */
  4832.         $AllAttachements $SEjourService->getCombinedattachSejour($idSejour'photoVideo');
  4833.         $attachementsCount $AllAttachements['total'];
  4834.         unset($AllAttachements['total']);
  4835.         $nbImages count($AllAttachements);
  4836.         $positions $SEjourService->getsejourposition($idSejour);
  4837.         $messages $SEjourService->getsejourmessage($idSejour);
  4838.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  4839.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4840.         // test if sejour est vide ou non 
  4841.         if (sizeof($sejour->getAttachements()) == 0) {
  4842.             $this->session->set('rout''rout');
  4843.             return $this->render('Parent/Aucunphoto.html.twig', [
  4844.                 "sejour" => $sejour,
  4845.                 "parentsejour" => $parentsejour
  4846.             ]);
  4847.         }
  4848.         // Déterminer le type de code (PF = gratuit, PP/EP = payant)
  4849.         $codePrefix substr($sejour->getCodeSejour(), 02);
  4850.         $isFreeAccess = ($codePrefix === 'PF' || $codePrefix === 'EF' || $sejour->getPaym() == 0);
  4851.         
  4852.         // PP ou EP : vérifier le paiement
  4853.         if (!$isFreeAccess && ($codePrefix === 'PP' || $codePrefix === 'EP')) {
  4854.             $ParentSejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  4855.             if ($ParentSejour && $ParentSejour->getPayment() == 0) {
  4856.                 $this->session->set('rout''rout');
  4857.                 $ses_id session_id();
  4858.                 return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $AllAttachements"session_id" => $ses_id'ParentSejour' => $ParentSejour]);
  4859.             }
  4860.             if ($ParentSejour && $ParentSejour->getPayment() == 1) {
  4861.                 $produits $this->typeProduiteService;
  4862.                 $liste $produits->produitlistTypeConditionnement();
  4863.                 $em $this->em;
  4864.                 $idAcc $sejour->getIdAcommp();
  4865.                 $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4866.                 $pubProd $user->getShowpubprod();
  4867.                 $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4868.                 if ($albumAcc == null) {
  4869.                     $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  4870.                 }
  4871.                 return $this->render('Parent/DetailsSejour.html.twig', [
  4872.                     "sejour" => $sejour,
  4873.                     'albumAcc' => $albumAcc,
  4874.                     'listeattach' => $AllAttachements,
  4875.                     'prod' => $liste,
  4876.                     'nbImages' => $nbImages,
  4877.                     'attachementsCount' => $attachementsCount,
  4878.                     'positions' => $positions,
  4879.                     'messages' => $messages,
  4880.                     'albumAcc' => $albumAcc,
  4881.                     'like' => $listeattachlikephoto,
  4882.                     "parentsejour" => $parentsejour,
  4883.                     'smsnotif' => $parentsejour->getSmsnotif(),
  4884.                     'showpub' => $pubProd
  4885.                 ]);
  4886.             }
  4887.         }
  4888.         $produits $this->typeProduiteService;
  4889.         $liste $produits->produitlistTypeConditionnement();
  4890.         $pubProd $user->getShowpubprod();
  4891.         $em $this->em;
  4892.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  4893.         if ($albumAcc == null) {
  4894.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  4895.         }
  4896.         return $this->render('Parent/DetailsSejour.html.twig', [
  4897.             "sejour" => $sejour,
  4898.             'albumAcc' => $albumAcc,
  4899.             'prod' => $liste,
  4900.             'listeattach' => $AllAttachements,
  4901.             'nbImages' => $nbImages,
  4902.             'attachementsCount' => $attachementsCount,
  4903.             'positions' => $positions,
  4904.             'messages' => $messages,
  4905.             'like' => $listeattachlikephoto,
  4906.             "parentsejour" => $parentsejour,
  4907.             'smsnotif' => $parentsejour->getSmsnotif(),
  4908.             'showpub' => $pubProd
  4909.         ]);
  4910.     }
  4911.     /**
  4912.      * @Route("/Parent/Mon_Sejour_parent", name="Mon_Sejour_parent")
  4913.      */
  4914.     public function Mon_Sejour_parent()
  4915.     {
  4916.         /** @var \App\Entity\User $user */
  4917.         $user $this->getUser();
  4918.         $userId $user->getId();
  4919.         $session $this->session;
  4920.         // $idParent=$this->getUser()->getId();
  4921.         $idSejour $session->get("Sejour");
  4922.         $session->set('pageMenu''Monsejour');
  4923.         $conxparent $this->sejourService;
  4924.         //$sejour1 = $conxparent->sejourParentcnx($idSejour,$idParent);
  4925.         //
  4926.         $SEjourService $this->sejourService;
  4927.         $sejour $SEjourService->getsejour($idSejour);
  4928.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  4929.         //Liste des photos privé
  4930.         //        $listeattachPrivate = $SEjourService->getatachmentsejourparent($idSejour, $this->getUser()->getId());
  4931.         //        $AllPhotosParent = array_merge_recursive($listeattach, $listeattachPrivate);
  4932.         $listeVideo $SEjourService->getVideosejour($idSejour);
  4933.         $AllAttachements array_merge_recursive($listeattach$listeVideo);
  4934.         $nbImages count($listeattach);
  4935.         $positions $SEjourService->getsejourposition($idSejour);
  4936.         $messages $SEjourService->getsejourmessage($idSejour);
  4937.         $parentsejour $SEjourService->getparentsejour($userId$idSejour);
  4938.         //dd($parentsejour);
  4939.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  4940.         // test if sejour est vide ou non 
  4941.         if (sizeof($sejour->getAttachements()) == 0) {
  4942.             $this->session->set('rout''rout');
  4943.             return $this->render('Parent/Aucunphoto.html.twig', [
  4944.                 "sejour" => $sejour,
  4945.                 "parentsejour" => $parentsejour
  4946.             ]);
  4947.         }
  4948.         // Déterminer le type de code (PF = gratuit, PP/EP = payant)
  4949.         $codePrefix substr($sejour->getCodeSejour(), 02);
  4950.         $isFreeAccess = ($codePrefix === 'PF' || $codePrefix === 'EF' || $sejour->getPaym() == 0);
  4951.         
  4952.         // PP ou EP : vérifier le paiement
  4953.         if (!$isFreeAccess && ($codePrefix === 'PP' || $codePrefix === 'EP')) {
  4954.             /** @var \App\Entity\User $user */
  4955.             $user $this->getUser();
  4956.             $userid $user->getId();
  4957.             //findlinge
  4958.             $ParentSejour $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $userid]);
  4959.             if ($ParentSejour && $ParentSejour->getPayment() == 0) {
  4960.                 $this->session->set('rout''rout');
  4961.                 $ses_id session_id();
  4962.                 return $this->render('Parent/achatsejour.html.twig', ["sejour" => $sejour'images' => $listeattach"session_id" => $ses_id'ParentSejour' => $ParentSejour]);
  4963.             }
  4964.             if ($ParentSejour && $ParentSejour->getPayment() == 1) {
  4965.                 $produits $this->typeProduiteService;
  4966.                 $liste $produits->produitlistTypeConditionnement();
  4967.                 $pubProd $user->getShowpubprod();
  4968.                 return $this->render('Parent/DetailsSejour.html.twig', [
  4969.                     "sejour" => $sejour,
  4970.                     'listeattach' => $AllAttachements,
  4971.                     'prod' => $liste,
  4972.                     'nbImages' => $nbImages,
  4973.                     'positions' => $positions,
  4974.                     'messages' => $messages,
  4975.                     'like' => $listeattachlikephoto,
  4976.                     "parentsejour" => $parentsejour,
  4977.                     'smsnotif' => $parentsejour->getSmsnotif()
  4978.                 ]);
  4979.             }
  4980.         }
  4981.         //  dd($sejour);
  4982.         //Liste des photos public
  4983.         $produits $this->typeProduiteService;
  4984.         $liste $produits->produitlistTypeConditionnement();
  4985.         $pubProd $user->getShowpubprod();
  4986.         return $this->render('Parent/DetailsSejour.html.twig', [
  4987.             "sejour" => $sejour,
  4988.             'prod' => $liste,
  4989.             'listeattach' => $AllAttachements,
  4990.             'nbImages' => $nbImages,
  4991.             'positions' => $positions,
  4992.             'messages' => $messages,
  4993.             'like' => $listeattachlikephoto,
  4994.             "parentsejour" => $parentsejour,
  4995.             'smsnotif' => $parentsejour->getSmsnotif(),
  4996.             'showpub' => $pubProd
  4997.         ]);
  4998.     }
  4999.     /**
  5000.      * @Route("/Parent/Besoindaide", name="Besoindaide_Parent")
  5001.      */
  5002.     public function Besoindaide(): Response
  5003.     {
  5004.         $produit $this->typeProduiteService;
  5005.         $liste $produit->produitlistType();
  5006.         // dd($liste);
  5007.         return $this->render('Parent/footer/Besoindaide.html.twig', [
  5008.             'produit' => $liste,
  5009.         ]);
  5010.     }
  5011.     /**
  5012.      * @Route("/Parent/About", name="About_Parent")
  5013.      */
  5014.     public function AboutParent(): Response
  5015.     {
  5016.         return $this->render('Parent/AboutParent.html.twig', []);
  5017.     }
  5018.     /**
  5019.      * @Route("/Parent/Besoindaide_5sur5", name="Besoindaide_5sur5")
  5020.      */
  5021.     public function Besoindaide_5sur5(): Response
  5022.     {
  5023.         $produit $this->typeProduiteService;
  5024.         $liste $produit->produitlistType();
  5025.         // dd($liste);
  5026.         $session $this->session;
  5027.         $idSejour $session->get("Sejour");
  5028.         $sejour null;
  5029.         if ($idSejour != null) {
  5030.             $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  5031.         }
  5032.         return $this->render('Parent/footer/5sur5Help.html.twig', [
  5033.             'produit' => $liste,
  5034.             'sejour' => $sejour
  5035.         ]);
  5036.     }
  5037.     /**
  5038.      * @Route("/Parent/Mentionlegale", name="Mentionlegale_Parent")
  5039.      */
  5040.     public function MentionlegaleParent()
  5041.     {
  5042.         return $this->render('Parent/footer/mentionlegal.html.twig', []);
  5043.     }
  5044.     /**
  5045.      * @Route("/Parent/Conditongeneral", name="Conditongeneral_Parent")
  5046.      */
  5047.     public function ConditongeneralParent()
  5048.     {
  5049.         return $this->render('Parent/footer/Condition.html.twig', []);
  5050.     }
  5051.     /**
  5052.      * @Route("/Parent/Politique", name="Politique_Parent")
  5053.      */
  5054.     public function PolitiqueParent()
  5055.     {
  5056.         return $this->render('Parent/footer/politique.html.twig', []);
  5057.     }
  5058.     /**
  5059.      * @Route("/Parent/Commande_groupee", name="Commande_groupee")
  5060.      * */
  5061.     public function  Commande_groupee()
  5062.     {
  5063.         $produit $this->typeProduiteService;
  5064.         $liste $produit->produitlistType();
  5065.         // dd($liste);
  5066.         return $this->render('Parent/footer/GroupeeCommande.html.twig', [
  5067.             'showArt' => 'ALL',
  5068.             'produit' => $liste
  5069.         ]);
  5070.     }
  5071.     /**
  5072.      * @Route("/Parent/partenaires", name="nosPartenaires")
  5073.      * */
  5074.     public function nosPartenaires()
  5075.     {
  5076.         return $this->render('Parent/footer/Partenaires.html.twig');
  5077.     }
  5078.     /**
  5079.      * @Route("/Parent/produits5sur5", name="produits5sur5")
  5080.      * */
  5081.     public function produits5sur5()
  5082.     {
  5083.         $produit $this->typeProduiteService;
  5084.         $liste $produit->produitlistType();
  5085.         // dd($liste);
  5086.         return $this->render('Parent/produitscinqsurcinq.html.twig', [
  5087.             'showArt' => 'ALL',
  5088.             'produit' => $liste
  5089.         ]);
  5090.     }
  5091.     /**
  5092.      * @Route("/Parent/Nous_Connaitre_5sur5", name="NousConnaitre")
  5093.      * */
  5094.     public function Nous_Connaitre_5sur5()
  5095.     {
  5096.         $produit $this->typeProduiteService;
  5097.         $liste $produit->produitlistType();
  5098.         // dd($liste);
  5099.         return $this->render('Parent/footer/5sur5.html.twig', [
  5100.             'produit' => $liste,
  5101.         ]);
  5102.     }
  5103.     /**
  5104.      * @Route("/Parent/ServiceClient", name="ServiceClient_Parent")
  5105.      * */
  5106.     public function ServiceClient()
  5107.     {
  5108.         $produit $this->typeProduiteService;
  5109.         $liste $produit->produitlistType();
  5110.         // dd($liste);
  5111.         return $this->render('Parent/footer/ServiceClient.html.twig', [
  5112.             'produit' => $liste,
  5113.         ]);
  5114.     }
  5115.     /**
  5116.      * @Route("/Parent/delateSession_parents", name="delateSession_parent")
  5117.      * */
  5118.     public function delateSession_parents()
  5119.     {
  5120.         $session $this->session;
  5121.         $em $this->em;
  5122.         $Products = [];
  5123.         if ($session->get("paymentmoniteco") == "succses") {
  5124.             $Products = [];
  5125.             $session->set('Panier'$Products);
  5126.             $user $this->getUser();
  5127.             $typeref $em->getRepository(Typeref::class)->find(8);
  5128.             $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  5129.             $payer $em->getRepository(Ref::class)->findOneBy(array("libiller" => "payer""typeref" => $typeref));
  5130.             $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  5131.             if ($panierTrace) {
  5132.                 $panierTrace->setStatut($payer);
  5133.                 $em->getManager()->persist($panierTrace);
  5134.                 $em->getManager()->flush();
  5135.             }
  5136.         }
  5137.         $this->session->remove('paymentmoniteco');
  5138.         $this->session->remove('montanttotalcomande');
  5139.         $this->session->remove('Panierlength');
  5140.         $this->session->remove('envoipost');
  5141.         return new Response('done');
  5142.     }
  5143.     /**
  5144.      * @Route("/Parent/chargement_form_conn_up2pay", name="chargement_form_conn_up2pay")
  5145.      */
  5146.     function chargeFormup2payAction(Request $request)
  5147.     {
  5148.         $session $this->session;
  5149.         $em $this->container->get('doctrine')->getManager();
  5150.         $idSejour $session->get("Sejour");
  5151.         /** @var \App\Entity\User $user */
  5152.         $user $this->getUser();
  5153.         $user $user->getId();
  5154.         $comande $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  5155.         $firstName $comande->getIdParent()->getNom();
  5156.         if ($firstName == null || $firstName == '') {
  5157.             $firstName "john";
  5158.         }
  5159.         $lastName $comande->getIdParent()->getPrenom();
  5160.         if ($lastName == null || $lastName == '') {
  5161.             $lastName "Doe";
  5162.         }
  5163.         $addressLine1 "3 rue de l'église";
  5164.         $city "Ostheim";
  5165.         $postalCode "68150";
  5166.         $pbx_site '6062073';                              //variable de test 9999999
  5167.         $pbx_rang '001';                                    //variable de test 95
  5168.         $pbx_identifiant '38027616';                      //variable de test 123456789
  5169.         $pbx_cmd 'REFCN' $comande->getId();
  5170.         $pbx_effectue $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5171.         $pbx_annule $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5172.         $pbx_refuse $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5173.         // Paramétrage de l'url de retour back office site (notification de paiement IPN) :
  5174.         $pbx_repondre_a "";
  5175.         //$pbx_repondre_a = $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5176.         $mail  $comande->getIdParent()->getEmail();
  5177.         $pbx_porteur $mail;                    //variable de test test@test.fr
  5178.         // Paramétrage des données retournées via l'IPN :
  5179.         $pbx_retour 'Mt:M;Ref:R;Auto:A;Erreur:E';
  5180.         // On récupére la date au format ISO-8601 :
  5181.         $dateTime date("c");
  5182.         //$montant = $comande->getMontantrth() . "EUR";
  5183.         $pbx_total $comande->getIdSejour()->getPrixcnxparent();
  5184.         $pbx_total = (int)((string)($pbx_total 100));
  5185.         // Suppression des points ou virgules dans le montant                        
  5186.         $pbx_total str_replace(","""$pbx_total);
  5187.         $pbx_total str_replace("."""$pbx_total);
  5188.         // Nombre de produit envoyé dans PBX_SHOPPINGCART :
  5189.         $pbx_nb_produit '1';                                    //variable de test 5
  5190.         // Construction de PBX_SHOPPINGCART :
  5191.         $pbx_shoppingcart "<?xml version=\"1.0\" encoding=\"utf-8\"?><shoppingcart><total><totalQuantity>" $pbx_nb_produit "</totalQuantity></total></shoppingcart>";
  5192.         // Choix de l'authentification dans PBX_SOUHAITAUTHENT
  5193.         $pbx_souhaitauthent '01';        //variable de test authentification 3DS (1 par défaut, 2 pour exemption 3DS)
  5194.         // Valeurs envoyes dans PBX_BILLING :
  5195.         $pbx_prenom_fact $firstName;                                                             //variable de test Jean-Marie
  5196.         $pbx_nom_fact $lastName;                                                                 //variable de test Thomson
  5197.         $pbx_adresse1_fact $addressLine1;                                                         //variable de test 1 rue de Paris
  5198.         $pbx_adresse2_fact '';                                                                 //variable de test <vide>
  5199.         $pbx_zipcode_fact $postalCode;                                                         //variable de test 75001
  5200.         $pbx_city_fact $city;                                     //variable de test Paris
  5201.         $pbx_country_fact '250';        //variable de test 250 (pour la France)
  5202.         // Construction de PBX_BILLING :
  5203.         $pbx_billing "<?xml version=\"1.0\" encoding=\"utf-8\"?><Billing><Address><FirstName>" $pbx_prenom_fact "</FirstName>" .
  5204.             "<LastName>" $pbx_nom_fact "</LastName><Address1>" $pbx_adresse1_fact "</Address1>" .
  5205.             "<Address2>" $pbx_adresse2_fact "</Address2><ZipCode>" $pbx_zipcode_fact "</ZipCode>" .
  5206.             "<City>" $pbx_city_fact "</City><CountryCode>" $pbx_country_fact "</CountryCode>" .
  5207.             "</Address></Billing>";
  5208.         // Recette (paiements de test)  :
  5209.         //$urletrans ="https://recette-tpeweb.e-transactions.fr/php/";
  5210.         // Production (paiements réels) :
  5211.         // URL principale :
  5212.         $urletrans "https://tpeweb.e-transactions.fr/php/";
  5213.         // URL secondaire :
  5214.         // $urletrans ="https://tpeweb1.e-transactions.fr/php/";
  5215.         // $hmackey = 'A5FD6D11DA2B9C4112201B4D797EC2B32B877C09A0CF56CE8007D91ACBA9A6D9E026149A7E8441D39A9F52C61E0D250ACC6DEC6815EA02621AEE525576CF4DAE';
  5216.         $hmackey 'A5FD6D11DA2B9C4112201B4D797EC2B32B877C09A0CF56CE8007D91ACBA9A6D9E026149A7E8441D39A9F52C61E0D250ACC6DEC6815EA02621AEE525576CF4DAE';
  5217.         $pbx_prenom_fact strtoupper($pbx_prenom_fact);
  5218.         $pbx_nom_fact strtoupper($pbx_nom_fact);
  5219.         $pbx_adresse1_fact strtoupper($pbx_adresse1_fact);
  5220.         $pbx_adresse2_fact strtoupper($pbx_adresse2_fact);
  5221.         $pbx_city_fact strtoupper($pbx_city_fact);
  5222.         $pbx_country_fact strtoupper($pbx_country_fact);
  5223.         // --------------- TRAITEMENT DES VARIABLES ---------------
  5224.         // On crée la chaéne a hacher sans URLencodage
  5225.         $msg "PBX_SITE=" $pbx_site .
  5226.             "&PBX_RANG=" $pbx_rang .
  5227.             "&PBX_IDENTIFIANT=" $pbx_identifiant .
  5228.             "&PBX_SOURCE=RWD" .
  5229.             "&PBX_TOTAL=" $pbx_total .
  5230.             "&PBX_DEVISE=978" .
  5231.             "&PBX_CMD=" $pbx_cmd .
  5232.             "&PBX_PORTEUR=" $pbx_porteur .
  5233.             "&PBX_REPONDRE_A=" $pbx_repondre_a .
  5234.             "&PBX_RETOUR=" $pbx_retour .
  5235.             "&PBX_EFFECTUE=" $pbx_effectue .
  5236.             "&PBX_ANNULE=" $pbx_annule .
  5237.             "&PBX_REFUSE=" $pbx_refuse .
  5238.             "&PBX_HASH=SHA512" .
  5239.             "&PBX_TIME=" $dateTime .
  5240.             "&PBX_SHOPPINGCART=" $pbx_shoppingcart .
  5241.             "&PBX_BILLING=" $pbx_billing .
  5242.             "&PBX_SOUHAITAUTHENT=" $pbx_souhaitauthent;
  5243.         $binKey pack("H*"$hmackey);
  5244.         $hmac strtoupper(hash_hmac('sha512'$msg$binKey));
  5245.         return new JsonResponse(array(
  5246.             'urletrans' => $urletrans,
  5247.             'pbx_site' => $pbx_site,
  5248.             'pbx_rang' => $pbx_rang,
  5249.             'pbx_identifiant' => $pbx_identifiant,
  5250.             'pbx_total' => $pbx_total,
  5251.             'pbx_cmd' => $pbx_cmd,
  5252.             'pbx_porteur' => $pbx_porteur,
  5253.             'pbx_repondre_a' => $pbx_repondre_a,
  5254.             'pbx_retour' => $pbx_retour,
  5255.             'pbx_effectue' => $pbx_effectue,
  5256.             'pbx_annule' => $pbx_annule,
  5257.             'pbx_refuse' => $pbx_refuse,
  5258.             'dateTime' => $dateTime,
  5259.             'pbx_shoppingcart' => $pbx_shoppingcart,
  5260.             'pbx_billing' => $pbx_billing,
  5261.             'pbx_souhaitauthent' => $pbx_souhaitauthent,
  5262.             'hmac' => $hmac
  5263.         ));
  5264.         // 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));
  5265.     }
  5266.     /**
  5267.      * @Route("/Parent/chargement_form_connx", name="chargement_form__Connx")
  5268.      */
  5269.     function chargeFormOgoneAction_Connx(Request $request)
  5270.     {
  5271.         $session $this->session;
  5272.         $em $this->container->get('doctrine')->getManager();
  5273.         $idSejour $session->get("Sejour");
  5274.         /** @var \App\Entity\User $user */
  5275.         $user $this->getUser();
  5276.         $user $user->getId();
  5277.         $comande $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  5278.         $firstName $comande->getIdParent()->getNom();
  5279.         if ($firstName == null || $firstName == '') {
  5280.             $firstName "john";
  5281.         }
  5282.         $lastName $comande->getIdParent()->getPrenom();
  5283.         if ($lastName == null || $lastName == '') {
  5284.             $lastName "Doe";
  5285.         }
  5286.         $addressLine1 "3 rue de l'église";
  5287.         $city $city "Ostheim";
  5288.         $postalCode "68150";
  5289.         //      $postalCode= trim ($postalCode) ;
  5290.         $country "FR";
  5291.         $contexte = array("billing" => array("firstName" => $firstName"lastName" => $lastName"addressLine1" => $addressLine1"city" => $city"postalCode" => $postalCode"country" => $country));
  5292.         //param de payement
  5293.         $contexte_commande base64_encode(json_encode($contexte));
  5294.         $PayementService $this->container->get("App\Service\PayementService");
  5295.         $version $this->getParameter('version'); //done
  5296.         $TPE $this->getParameter('TPE'); //done
  5297.         $dateTime $dateNow = new \DateTime();
  5298.         $date $dateTime->format("d/m/Y:H:i:s");
  5299.         //"05/05/2019:11:55:23" ;
  5300.         $montant $comande->getIdSejour()->getPrixcnxparent() . "EUR";
  5301.         $reference 'REFCN' $comande->getId();
  5302.         $url_retour_ok $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5303.         $url_retour_err $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5304.         $desactivemoyenpaiement "paypal";
  5305.         $lgue "FR"//done
  5306.         $societe "5sur5sejou"//done
  5307.         $textelibre "5sur5sejour"//
  5308.         $mail $this->getUser(); //
  5309.         $SHAIN $this->getParameter('shain');
  5310.         $param = array(
  5311.             'version' => $version,
  5312.             'TPE' => $TPE,
  5313.             'date' => $date,
  5314.             'montant' => $montant,
  5315.             'reference' => $reference,
  5316.             'url_retour_ok' => $url_retour_ok,
  5317.             'url_retour_err' => $url_retour_err,
  5318.             'lgue' => $lgue,
  5319.             'societe' => $societe,
  5320.             'contexte_commande' => $contexte_commande,
  5321.             'texte-libre' => $textelibre,
  5322.             'mail' => $mail,
  5323.             'desactivemoyenpaiement' => $desactivemoyenpaiement
  5324.         );
  5325.         $MAC $PayementService->monetico_hash_parameters('sha1'$param$SHAIN);
  5326.         //utf8_encode
  5327.         return new JsonResponse(array(
  5328.             'version' => $version,
  5329.             'TPE' => $TPE,
  5330.             'date' => $date,
  5331.             'montant' => $montant,
  5332.             'reference' => $reference,
  5333.             'MAC' => $MAC,
  5334.             'url_retour_ok' => utf8_encode($url_retour_ok),
  5335.             'url_retour_err' => utf8_encode($url_retour_err),
  5336.             'lgue' => $lgue,
  5337.             'societe' => $societe,
  5338.             'contexte_commande' => utf8_encode($contexte_commande),
  5339.             'textelibre' => utf8_encode($textelibre),
  5340.             'mail' => $mail,
  5341.             'desactivemoyenpaiement' => $desactivemoyenpaiement
  5342.         ));
  5343.         // 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));
  5344.     }
  5345.     /**
  5346.      * @Route("/Parent/chargement_form_connx_paypal", name="chargement_form__Connx_PayPal")
  5347.      */
  5348.     function chargeFormOgoneAction_Connx_PayPal(Request $request)
  5349.     {
  5350.         $session $this->session;
  5351.         $em $this->container->get('doctrine')->getManager();
  5352.         $idSejour $session->get("Sejour");
  5353.         /** @var \App\Entity\User $user */
  5354.         $user $this->getUser();
  5355.         $user $user->getId();
  5356.         $comande $this->em->getRepository(ParentSejour::class)->findOneBy(["idSejour" => $idSejour"idParent" => $user]);
  5357.         $firstName $comande->getIdParent()->getNom();
  5358.         if ($firstName == null || $firstName == '') {
  5359.             $firstName "john";
  5360.         }
  5361.         $lastName $comande->getIdParent()->getPrenom();
  5362.         if ($lastName == null || $lastName == '') {
  5363.             $lastName "Doe";
  5364.         }
  5365.         $addressLine1 "3 rue de l'église";
  5366.         $city $city "Ostheim";
  5367.         $postalCode "68150";
  5368.         //      $postalCode= trim ($postalCode) ;
  5369.         $country "FR";
  5370.         $contexte = array("billing" => array("firstName" => $firstName"lastName" => $lastName"addressLine1" => $addressLine1"city" => $city"postalCode" => $postalCode"country" => $country));
  5371.         $protocole "paypal";
  5372.         //param de payement
  5373.         $contexte_commande base64_encode(json_encode($contexte));
  5374.         $PayementService $this->container->get("App\Service\PayementService");
  5375.         $version $this->getParameter('version'); //done
  5376.         $TPE $this->getParameter('TPE'); //done
  5377.         $dateTime $dateNow = new \DateTime();
  5378.         $date $dateTime->format("d/m/Y:H:i:s");
  5379.         //"05/05/2019:11:55:23" ;
  5380.         $montant $comande->getIdSejour()->getPrixcnxparent() . "EUR";
  5381.         $reference 'REFCN' $comande->getId();
  5382.         $url_retour_ok $this->generateUrl("moneticoAcceptUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5383.         $url_retour_err $this->generateUrl("moneticoExceptionUrl_parentcnxx", array('id' => $comande->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
  5384.         $lgue "FR"//done
  5385.         $societe "5sur5sejou"//done
  5386.         $textelibre "5sur5sejour"//
  5387.         $mail $this->getUser(); //
  5388.         $SHAIN $this->getParameter('shain');
  5389.         $param = array(
  5390.             'version' => $version,
  5391.             'TPE' => $TPE,
  5392.             'date' => $date,
  5393.             'montant' => $montant,
  5394.             'reference' => $reference,
  5395.             'url_retour_ok' => $url_retour_ok,
  5396.             'url_retour_err' => $url_retour_err,
  5397.             'lgue' => $lgue,
  5398.             'societe' => $societe,
  5399.             'contexte_commande' => $contexte_commande,
  5400.             'texte-libre' => $textelibre,
  5401.             'mail' => $mail,
  5402.             'protocole' => $protocole
  5403.         );
  5404.         $MAC $PayementService->monetico_hash_parameters('sha1'$param$SHAIN);
  5405.         //utf8_encode
  5406.         return new JsonResponse(array(
  5407.             'version' => $version,
  5408.             'TPE' => $TPE,
  5409.             'date' => $date,
  5410.             'montant' => $montant,
  5411.             'reference' => $reference,
  5412.             'MAC' => $MAC,
  5413.             'url_retour_ok' => utf8_encode($url_retour_ok),
  5414.             'url_retour_err' => utf8_encode($url_retour_err),
  5415.             'lgue' => $lgue,
  5416.             'societe' => $societe,
  5417.             'contexte_commande' => utf8_encode($contexte_commande),
  5418.             'textelibre' => utf8_encode($textelibre),
  5419.             'mail' => $mail,
  5420.             'protocole' => $protocole
  5421.         ));
  5422.         // 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));
  5423.     }
  5424.     /**
  5425.      * @Route("/Parent/SupprimerCommande", name="Supprimer_CommandeParent")
  5426.      */
  5427.     function RemoveCommandeParent(Request $request)
  5428.     {
  5429.         $CommandeService $this->commandeService;
  5430.         $idCmd $request->get('id');
  5431.         $result $CommandeService->CommandeCloture($idCmd);
  5432.         return new Response($result);
  5433.     }
  5434.     /**
  5435.      * @Route("/Parent/accept_url_parentcnxx/{id}", name="moneticoAcceptUrl_parentcnxx")
  5436.      */
  5437.     function moneticoAcceptUrl_parent($id)
  5438.     {
  5439.         $em $this->container->get('doctrine')->getManager();
  5440.         $comande $this->em->getRepository(ParentSejour::class)->find($id);
  5441.         if ($comande->getPayment() != 1) {
  5442.             $typ $this->em->getRepository(Typeproduit::class)->find(1);
  5443.             $condit $this->em->getRepository(TypeProduitConditionnement::class)->find(11);
  5444.             $produit = new Produit();
  5445.             $produit->setIdConditionnement($condit);
  5446.             $produit->setType($typ);
  5447.             $produit->setDate(new \DateTime());
  5448.             $produit->setLabele("Connexion");
  5449.             $produit->setIduser($this->getUser());
  5450.             $sats $this->em->getRepository(Ref::class)->find(33);
  5451.             //$ComandeService = $this->container->get("App\Service\ComandeService");
  5452.             $ComandeService $this->commandeService;
  5453.             $comande->setPayment(1);
  5454.             $this->em->getManager()->persist($comande);
  5455.             $this->em->getManager()->flush();
  5456.             $produit->setIdsjour($comande->getIdSejour());
  5457.             $this->em->getManager()->persist($produit);
  5458.             $this->em->getManager()->flush();
  5459.             $bytes random_int(10009999);
  5460.             $pass bin2hex($bytes);
  5461.             //generate Num facture
  5462.             $dateSJoue = new \Datetime();
  5463.             $annes $dateSJoue->format('y');
  5464.             $moi $dateSJoue->format('m');
  5465.             $val $this->em->getRepository(Commande::class)->serachNombreFacture();
  5466.             $val $val 1;
  5467.             $valx sprintf('%04d'$val);
  5468.             $valx1 "20" $annes $moi $valx;
  5469.             $cmdpaym = new Commande();
  5470.             $cmdpaym->setMontantrth($comande->getIdSejour()->getPrixcnxparent());
  5471.             $cmdpaym->setNumComande($pass);
  5472.             $cmdpaym->getIdSejour($pass);
  5473.             $cmdpaym->setNumfacture($valx1);
  5474.             $cmdpaym->setDateCreateCommande(new \DateTime());
  5475.             $cmdpaym->setDateFacture(new \DateTime());
  5476.             $cmdpaym->setStatut($sats);
  5477.             $cmdpaym->setIdSejour($comande->getIdSejour());
  5478.             $cmdpaym->setIdUser($this->getUser());
  5479.             $this->em->getManager()->persist($cmdpaym);
  5480.             $this->em->getManager()->flush();
  5481.             $cmdpaym->setNumfacture(substr($cmdpaym->getNumfacture(), '0'6) . $cmdpaym->getId());
  5482.             $this->em->getManager()->persist($cmdpaym);
  5483.             $this->em->getManager()->flush();
  5484.             $cpmd = new ComandeProduit();
  5485.             $cpmd->setIdComande($cmdpaym);
  5486.             $cpmd->setIdProduit($produit);
  5487.             $cpmd->setQuantiter(1);
  5488.             $cpmd->setDate(new \DateTime());
  5489.             //stille reversment par prod
  5490.             $this->em->getManager()->persist($cpmd);
  5491.             $this->em->getManager()->flush();
  5492.             $pdfOptions = new Options();
  5493.             $pdfOptions->set('isRemoteEnabled'TRUE);
  5494.             $pdfOptions->set('defaultFont''Arial');
  5495.             // Instantiate Dompdf with our options
  5496.             $dompdf = new Dompdf($pdfOptions);
  5497.             $dompdf->set_option('isRemoteEnabled'TRUE);
  5498.             // Retrieve the HTML generated in our twig file
  5499.             $html $this->renderView('Admin/pdfFactureparent.html.twig', [
  5500.                 "Commande" => $cmdpaym,
  5501.             ]);
  5502.             // Load HTML to Dompdf
  5503.             $dompdf->loadHtml($html);
  5504.             // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  5505.             $dompdf->setPaper('A4''portrait');
  5506.             // Render the HTML as PDF
  5507.             $dompdf->render();
  5508.             // Store PDF Binary Data
  5509.             $output $dompdf->output();
  5510.             // In this case, we want to write the file in the public directory
  5511.             $publicDirectory $this->getParameter('kernel.project_dir') . '/public/backupFacture/';
  5512.             // e.g /var/www/project/public/mypdf.pdf
  5513.             $pdfFilepath $publicDirectory "Facture" $cmdpaym->getId() . '-' $cmdpaym->getNumComande() . ".pdf";
  5514.             // Write file to the desired path
  5515.             file_put_contents($pdfFilepath$output);
  5516.         }
  5517.         $jetonService = new JetonService($this->em);
  5518.         if ($jetonService->checkUserFiveConnexion($comande->getIdSejour()->getIdAcommp(), $comande->getIdSejour())) {
  5519.             $jetonService->newJetonForUser($comande->getIdSejour()->getIdAcommp());
  5520.         }
  5521.         $session $this->session;
  5522.         $session->set('paymentmoniteco''succses');
  5523.         $resulat $session->get("paymentmoniteco");
  5524.         //dd($montanttotalcomande);
  5525.         return $this->redirectToRoute('AccueilParent');
  5526.     }
  5527.     /**
  5528.      * @Route("/Parent/accept_url_parentcnxxVirgo/{id}", name="moneticoAcceptUrl_parentcnxxVirgo")
  5529.      */
  5530.     function moneticoAcceptUrl_parentVirgo($id)
  5531.     {
  5532.         $em $this->container->get('doctrine')->getManager();
  5533.         $comande $this->em->getRepository(ParentSejour::class)->find($id);
  5534.         if ($comande->getPayment() != 1) {
  5535.             $typ $this->em->getRepository(Typeproduit::class)->find(1);
  5536.             $condit $this->em->getRepository(TypeProduitConditionnement::class)->find(11);
  5537.             $produit = new Produit();
  5538.             $produit->setIdConditionnement($condit);
  5539.             $produit->setType($typ);
  5540.             $produit->setLabele("Connexion");
  5541.             $produit->setIduser($this->getUser());
  5542.             $produit->setDate(new \DateTime());
  5543.             $sats $this->em->getRepository(Ref::class)->find(33);
  5544.             $ComandeService $this->container->get("App\Service\ComandeService");
  5545.             $comande->setPayment(1);
  5546.             $this->em->getManager()->persist($comande);
  5547.             $this->em->getManager()->flush();
  5548.             $produit->setIdsjour($comande->getIdSejour());
  5549.             $this->em->getManager()->persist($produit);
  5550.             $this->em->getManager()->flush();
  5551.             $bytes random_int(10009999);
  5552.             $pass bin2hex($bytes);
  5553.             //generate Num facture
  5554.             $dateSJoue = new \Datetime();
  5555.             $annes $dateSJoue->format('y');
  5556.             $moi $dateSJoue->format('m');
  5557.             $val $this->em->getRepository(Commande::class)->serachNombreFacture();
  5558.             $val $val 1;
  5559.             $valx sprintf('%04d'$val);
  5560.             $valx1 "20" $annes $moi $valx;
  5561.             $cmdpaym = new Commande();
  5562.             $cmdpaym->setMontantrth($comande->getIdSejour()->getPrixcnxparent());
  5563.             $cmdpaym->setNumComande($pass);
  5564.             $cmdpaym->getIdSejour($pass);
  5565.             $cmdpaym->setNumfacture($valx1);
  5566.             $cmdpaym->setDateFacture(new \DateTime());
  5567.             $cmdpaym->setDateCreateCommande(new \DateTime());
  5568.             $cmdpaym->setStatut($sats);
  5569.             $cmdpaym->setPaymentType("Mobile");
  5570.             $cmdpaym->setIdSejour($comande->getIdSejour());
  5571.             $cmdpaym->setIdUser($this->getUser());
  5572.             $this->em->getManager()->persist($cmdpaym);
  5573.             $this->em->getManager()->flush();
  5574.             $cmdpaym->setNumfacture(substr($cmdpaym->getNumfacture(), '0'6) . $cmdpaym->getId());
  5575.             $this->em->getManager()->persist($cmdpaym);
  5576.             $this->em->getManager()->flush();
  5577.             $cpmd = new ComandeProduit();
  5578.             $cpmd->setIdComande($cmdpaym);
  5579.             $cpmd->setIdProduit($produit);
  5580.             $cpmd->setQuantiter(1);
  5581.             $cpmd->setDate(new \DateTime());
  5582.             //stille reversment par prod
  5583.             $this->em->getManager()->persist($cpmd);
  5584.             $this->em->getManager()->flush();
  5585.             $pdfOptions = new Options();
  5586.             $pdfOptions->set('isRemoteEnabled'TRUE);
  5587.             $pdfOptions->set('defaultFont''Arial');
  5588.             // Instantiate Dompdf with our options
  5589.             $dompdf = new Dompdf($pdfOptions);
  5590.             $dompdf->set_option('isRemoteEnabled'TRUE);
  5591.             // Retrieve the HTML generated in our twig file
  5592.             $html $this->renderView('Admin/pdfFactureparent.html.twig', [
  5593.                 "Commande" => $cmdpaym,
  5594.             ]);
  5595.             // Load HTML to Dompdf
  5596.             $dompdf->loadHtml($html);
  5597.             // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  5598.             $dompdf->setPaper('A4''portrait');
  5599.             // Render the HTML as PDF
  5600.             $dompdf->render();
  5601.             // Store PDF Binary Data
  5602.             $output $dompdf->output();
  5603.             // In this case, we want to write the file in the public directory
  5604.             $publicDirectory $this->getParameter('kernel.project_dir') . '/public/backupFacture/';
  5605.             // e.g /var/www/project/public/mypdf.pdf
  5606.             $pdfFilepath $publicDirectory "Facture" $cmdpaym->getId() . '-' $cmdpaym->getNumComande() . ".pdf";
  5607.             // Write file to the desired path
  5608.             file_put_contents($pdfFilepath$output);
  5609.         }
  5610.         $jetonService = new JetonService($this->em);
  5611.         if ($jetonService->checkUserFiveConnexion($comande->getIdSejour()->getIdAcommp(), $comande->getIdSejour())) {
  5612.             $jetonService->newJetonForUser($comande->getIdSejour()->getIdAcommp());
  5613.         }
  5614.         $session $this->session;
  5615.         $session->set('paymentmoniteco''succses');
  5616.         $resulat $session->get("paymentmoniteco");
  5617.         //dd($montanttotalcomande);
  5618.         return $this->redirectToRoute('AccueilParent');
  5619.     }
  5620.     /**
  5621.      * @Route("/error_url_parentcnxx/{id}", name="moneticoExceptionUrl_parentcnxx")
  5622.      */
  5623.     function moneticoExceptionUrl_parentcnxx($id)
  5624.     {
  5625.         $em $this->container->get('doctrine')->getManager();
  5626.         $comande $this->em->getRepository(ParentSejour::class)->find($id);
  5627.         $session $this->session;
  5628.         $session->set('paymentmoniteco''echec');
  5629.         $comande->setPayment(0);
  5630.         $this->em->getManager()->persist($comande);
  5631.         $this->em->getManager()->flush();
  5632.         $resulat $session->get("paymentmoniteco");
  5633.         //dd($montanttotalcomande);
  5634.         return $this->redirectToRoute('AccueilParent');
  5635.     }
  5636.     /**
  5637.      * @Route("/Parent/SuiviCommande", name="SuiviCommande")
  5638.      * */
  5639.     public function SuiviCommande()
  5640.     {
  5641.         // dd($liste);
  5642.         $user $this->getUser();
  5643.         $session $this->session;
  5644.         $idSejour $session->get("Sejour");
  5645.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  5646.         $ParentSejour $this->em->getRepository(ParentSejour::class)->findBy(['idSejour' => $sejour'idParent' => $user]);
  5647.         //ParentSejour
  5648.         //cablala
  5649.         //dd($ParentSejour[0]);
  5650.         //$listeattach = $sejourservice->getatachmentsejour($id);
  5651.         //$listeattachM = $sejourservice->getsejourmessage($id);
  5652.         return $this->render('Parent/suivicommande.html.twig', [
  5653.             'user' => $user,
  5654.             'sejour' => $sejour,
  5655.             'ParentSejour' => $ParentSejour[0],
  5656.         ]);
  5657.     }
  5658.     /**
  5659.      * @Route("/Parent/SuiviCommandeparent", name="SuiviCommandeparent")
  5660.      * */
  5661.     public function SuiviCommandeparent()
  5662.     {
  5663.         // dd($liste);
  5664.         $user $this->getUser();
  5665.         //dd($user);
  5666.         $cmdservice $this->commandeService;
  5667.         $session $this->session;
  5668.         $idSejour $session->get("Sejour");
  5669.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  5670.         $listeCmd $cmdservice->listerCommandeParent($user);
  5671.         return $this->render('Parent/suivicommande.html.twig', [
  5672.             'user' => $user,
  5673.             'sejour' => $sejour,
  5674.             'listeCmd' => $listeCmd
  5675.         ]);
  5676.     }
  5677.     private function envoieMailPackNumerique($nameZip$email$commande)
  5678.     {
  5679.         // Utiliser directement le numéro de commande comme identifiant de téléchargement
  5680.         $downloadLink =  $nameZip;
  5681.         $this->emailsCmdService->MailPackPhotosNumerique(
  5682.             $email,
  5683.             $downloadLink,
  5684.             $commande->getId(),
  5685.         );
  5686.         // Marquer comme envoyé
  5687.         $commande->setEnvoi(1);
  5688.         $this->em->getManager()->persist($commande);
  5689.         $this->em->getManager()->flush();
  5690.         $this->logger->info("Email sent for order: ");
  5691.         return true;
  5692.     }
  5693.     /**
  5694.      * @Route("/Parent/telechargerPack/{idCommande}", name="telechargerPack")
  5695.      */
  5696.     public function TelechagerPackNumerique($idCommande): Response
  5697.     {
  5698.         $this->logger->info("Tentative de téléchargement du pack pour la commande numérique ID: {$idCommande}");
  5699.         // Récupérer la commande numérique
  5700.         $commandeNumerique $this->em->getRepository(CommandeNumerique::class)->find($idCommande);
  5701.         // Vérifier si la commande existe
  5702.         if (!$commandeNumerique) {
  5703.             $this->logger->error("Commande numérique introuvable - ID: {$idCommande}");
  5704.             return new JsonResponse(["message" => "Commande introuvable"], 404);
  5705.         }
  5706.         // Récupérer les informations associées
  5707.         $commande $commandeNumerique->getIdCommande();
  5708.         $idcommande $commande->getId();
  5709.         $user $commande->getIdUser();
  5710.         $iduser $user->getId();
  5711.         $sejour $commande->getIdSejour();
  5712.         $this->logger->info("Commande numérique {$commandeNumerique->getId()} trouvée, commande parent ID: {$idcommande}, utilisateur: {$user->getEmail()},ETAT: {$commandeNumerique->getEtat()}");
  5713.         $idCmdNumerique $commandeNumerique->getId();
  5714.         // Vérifier si le lien de téléchargement existe
  5715.         $refcmdnum $commandeNumerique->getLinkdownload();
  5716.         $this->logger->info("Lien de téléchargement: {$refcmdnum}");
  5717.         if (!$refcmdnum) {
  5718.             // Envoyer un email d'alerte à l'administrateur
  5719.             $email = (new Email())
  5720.                 ->from('noreply@5sur5sejour.com')
  5721.                 ->to('yousra.tlich@gmail.com')
  5722.                 ->subject('ALERTE - Lien de téléchargement corrompu')
  5723.                 ->text(
  5724.                     "Le lien de téléchargement est corrompu pour la commande suivante:\n" .
  5725.                         "ID Commande Numérique: " $idCmdNumerique "\n" .
  5726.                         "ID Commande: " $idcommande "\n" .
  5727.                         "Utilisateur: " $user->getEmail() . "\n" .
  5728.                         "Séjour: " $sejour->getLibelleSejour() . "\n" .
  5729.                         "Date: " . (new \DateTime())->format('Y-m-d H:i:s')
  5730.                 );
  5731.             $this->symfonyMailer->send($email);
  5732.             $this->logger->error("Lien de téléchargement corrompu pour la commande numérique {$idCommande}");
  5733.             return new JsonResponse(["message" => "Lien de téléchargement non disponible"], 404);
  5734.         }
  5735.         $this->logger->info("Lien de téléchargement trouvé pour la commande numérique {$idCommande}{$refcmdnum}");
  5736.         // Vérifier que l'utilisateur et le séjour existent
  5737.         if (!$user || !$sejour) {
  5738.             $this->logger->error("Utilisateur ou séjour manquant pour la commande numérique {$idCommande}");
  5739.             return new JsonResponse(['message' => 'Lien invalide - utilisateur ou séjour manquant'], 400);
  5740.         }
  5741.         // Vérifier l'état de la commande
  5742.         if ($commandeNumerique->getEtat() === 1) {
  5743.             // Construire le chemin du fichier
  5744.             $filePath $this->getParameter('kernel.project_dir') . '/public/ParentPhotosNumerique/' $refcmdnum '.zip';
  5745.             // Vérifier si le fichier existe
  5746.             if (file_exists($filePath)) {
  5747.                 $this->logger->info("Fichier trouvé, téléchargement démarré pour la commande numérique {$idCmdNumerique}");
  5748.                 return $this->file($filePath$refcmdnum '.zip'ResponseHeaderBag::DISPOSITION_ATTACHMENT);
  5749.             } else {
  5750.                 // Envoyer un email d'alerte pour fichier manquant
  5751.                 $email = (new Email())
  5752.                     ->from('noreply@5sur5sejour.com')
  5753.                     ->to('yousra.tlich@gmail.com')
  5754.                     ->subject('ALERTE - Fichier ZIP manquant')
  5755.                     ->text(
  5756.                         "Le fichier ZIP est manquant pour la commande suivante:\n" .
  5757.                             "ID Commande Numérique: " $idCommande "\n" .
  5758.                             "ID Commande: " $idcommande "\n" .
  5759.                             "Lien de téléchargement: " $refcmdnum "\n" .
  5760.                             "Chemin attendu: " $filePath "\n" .
  5761.                             "Date: " . (new \DateTime())->format('Y-m-d H:i:s')
  5762.                     );
  5763.                 $this->symfonyMailer->send($email);
  5764.                 $this->logger->error("Fichier ZIP manquant pour la commande numérique {$idCommande} - chemin: {$filePath}");
  5765.                 return new JsonResponse(['message' => 'Fichier non trouvé'], 404);
  5766.             }
  5767.         } elseif ($commandeNumerique->getEtat() == 2) {
  5768.             $this->logger->warning("Tentative de téléchargement d'une commande déjà livrée - ID: {$idCommande}");
  5769.             return new JsonResponse(['message' => 'Commande déjà livrée'], 400);
  5770.         } else {
  5771.             $this->logger->warning("État de commande invalide pour la commande numérique {$idCmdNumerique} - état: {$commandeNumerique->getEtat()}");
  5772.             return new JsonResponse(['message' => 'Commande invalide'], 400);
  5773.         }
  5774.     }
  5775.     /**
  5776.      * @Route("/Parent/disableTelecharge/{idCommande}" , name="disableTelecharge" )
  5777.      */
  5778.     public function disableTelecharge($idCommande)
  5779.     {
  5780.         $commandenumerique $this->em->getRepository(CommandeNumerique::class)->findOneBy(['id' => $idCommande]);
  5781.         $commandenumerique->setEtat(2);
  5782.         $commandenumerique->setDateTelechargement(new \DateTime());
  5783.         $this->em->getManager()->persist($commandenumerique);
  5784.         $this->em->getManager()->flush();
  5785.         return "ok";
  5786.     }
  5787.     /**
  5788.      * @Route("/Accompagnateur/pdffacturetest/{id}", name="pdffacturetest")
  5789.      */
  5790.     public function pdffactureAccomptest($id)
  5791.     {
  5792.         $em $this->em;
  5793.         $cmd $em->getRepository(Commande::class)->find($id);
  5794.         return $this->render('Parent/pdfFactureParent.html.twig', [
  5795.             "comande" => $cmd,
  5796.         ]);
  5797.     }
  5798.     /**
  5799.      * @Route("/Parent/pdffacture/{id}", name="pdffacture")
  5800.      */
  5801.     public function pdffacture($id)
  5802.     {
  5803.         $user $this->getUser();
  5804.         $cmd $this->em->getRepository(Commande::class)->find($id);
  5805.         //   $result=   $this->EmailServie->MailCommandeSuivieParent($user->getEmail(),$cmd );
  5806.         // Configure Dompdf according to your needs
  5807.         $pdfOptions = new Options();
  5808.         $pdfOptions->set('isRemoteEnabled'TRUE);
  5809.         $pdfOptions->set('defaultFont''Arial');
  5810.         // Instantiate Dompdf with our options
  5811.         $dompdf = new Dompdf($pdfOptions);
  5812.         $dompdf->set_option('isRemoteEnabled'TRUE);
  5813.         // Retrieve the HTML generated in our twig file
  5814.         $html $this->renderView('Parent/pdfFactureParent.html.twig', [
  5815.             "comande" => $cmd,
  5816.         ]);
  5817.         // Load HTML to Dompdf
  5818.         $dompdf->loadHtml($html);
  5819.         // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
  5820.         $dompdf->setPaper('A4''portrait');
  5821.         // Render the HTML as PDF
  5822.         $dompdf->render();
  5823.         // Output the generated PDF to Browser (force download)
  5824.         $dompdf->stream("facture.pdf", [
  5825.             "Attachment" => true
  5826.         ]);
  5827.         return new Response('yoopi');
  5828.     }
  5829.     /**
  5830.      * @Route("/Parent/testPDF/{idPrdt}", name="TcPdf")
  5831.      */
  5832.     public function TcPdf($idPrdt)
  5833.     {
  5834.         ini_set("max_execution_time", -1);
  5835.         $pageLayout = array(2115);
  5836.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  5837.         // set document information
  5838.         $pdf->SetCreator(PDF_CREATOR);
  5839.         $pdf->SetAuthor('Nicola Asuni');
  5840.         $pdf->SetTitle('TCPDF Example 009');
  5841.         $pdf->SetSubject('TCPDF Tutorial');
  5842.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  5843.         $pdf->SetSubject('TCPDF Tutorial');
  5844.         $pdf->setPrintHeader(false);
  5845.         $pdf->setPrintFooter(false);
  5846.         // set image scale factor
  5847.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  5848.         //        $pdf->AddPage();
  5849.         $pdf->setJPEGQuality(100);
  5850.         $horizontal_alignments = array('L''C''R');
  5851.         $vertical_alignments = array('T''M''B');
  5852.         //var_dump($pdf->getPageWidth());
  5853.         //var_dump($pdf->getPageHeight());die();
  5854.         $em $this->em;
  5855.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  5856.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  5857.         //dd($AllPages);
  5858.         //        $fP=[];
  5859.         //        array_push($fP,$AllPages[0]);
  5860.         //dd($AllPages);
  5861.         foreach ($AllPages as $p) {
  5862.             $pdf->AddPage();
  5863.             $pdf->setJPEGQuality(100);
  5864.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  5865.             $nbatach $contenu->nbrAttc;
  5866.             $nbatach intval(str_replace('"'''$nbatach));
  5867.             $color =  $contenu->color;
  5868.             // $color="rgb(255,255,255)";
  5869.             $color str_replace('"rgb('''$color);
  5870.             $color str_replace(')"'''$color);
  5871.             $color explode(","$color);
  5872.             $colorp = array(intval($color[0]), intval($color[1]), intval($color[2]));
  5873.             $tabtxt json_decode($contenu->txt);
  5874.             $tabphoto json_decode($contenu->attache);
  5875.             //
  5876.             //dd($tabtxt);
  5877.             //         dd($tabtxt);
  5878.             //dd($tabphoto);
  5879.             $tabClips json_decode($contenu->clips);
  5880.             // dd($tabClips);
  5881.             $x 0.6;
  5882.             $y 0.8;
  5883.             $w 19.8;
  5884.             $h 13.4;
  5885.             // get the current page break margin
  5886.             $bMargin $pdf->getBreakMargin();
  5887.             // get current auto-page-break mode
  5888.             $auto_page_break $pdf->getAutoPageBreak();
  5889.             // disable auto-page-break
  5890.             $pdf->SetAutoPageBreak(false0);
  5891.             // test all combinations of alignments
  5892.             $fitbox $horizontal_alignments[1] . ' ';
  5893.             $fitbox[1] = $vertical_alignments[1];
  5894.             $pdf->Rect(002115'F', array(), $colorp);
  5895.             //    sizeof($tabphoto)
  5896.             for ($i 0$i sizeof($tabphoto); $i++) {
  5897.                 $photo json_decode($tabphoto[$i]);
  5898.                 //les coordonnées de l'image réel:
  5899.                 $hght $photo->height;
  5900.                 $top $photo->top;
  5901.                 $left $photo->left;
  5902.                 $width $photo->width;
  5903.                 $ordre $photo->ordre;
  5904.                 $zoom $photo->zoom;
  5905.                 $path $photo->path;
  5906.                 $hght floatval(str_replace('cm'''$hght));
  5907.                 $top floatval(str_replace('cm'''$top));
  5908.                 $left floatval(str_replace('cm'''$left));
  5909.                 $width floatval(str_replace('cm'''$width));
  5910.                 //les coordonnées dropzone:
  5911.                 $heightOriginal $photo->height;
  5912.                 $widthOriginal $photo->width;
  5913.                 $top $photo->top;
  5914.                 $left $photo->left;
  5915.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  5916.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  5917.                 $top floatval(str_replace('cm'''$top));
  5918.                 $left floatval(str_replace('cm'''$left));
  5919.                 $heightOriginal $heightOriginal 37.7952755906;
  5920.                 $widthOriginal $widthOriginal 37.7952755906;
  5921.                 $topOriginal $top 37.7952755906;
  5922.                 $leftOriginal $left 37.7952755906;
  5923.                 $heightCrop $photo->heightCrop;
  5924.                 $topCrop $photo->topCrop;
  5925.                 $leftCrop $photo->leftCrop;
  5926.                 $widthCrop $photo->widthCrop;
  5927.                 $path $photo->path;
  5928.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  5929.                 $topCrop floatval(str_replace('cm'''$topCrop));
  5930.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  5931.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  5932.                 $widthCropPX $widthCrop 37.7952755906;
  5933.                 $heightCropPX $heightCrop 37.7952755906;
  5934.                 $topCropPX $topCrop 37.7952755906;
  5935.                 $leftCropPX $leftCrop 37.7952755906;
  5936.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  5937.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  5938.                 // var_dump("//00");
  5939.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  5940.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  5941.                 //Calculer position des images selon nombres images par page:
  5942.                 $positionX 0;
  5943.                 $positionY 0;
  5944.                 $widthImg 0;
  5945.                 $heightImg 0;
  5946.                 if ($nbatach == 1) {
  5947.                     $positionX 1.5;
  5948.                     $positionY 1.5;
  5949.                     $widthImg 18;
  5950.                     $heightImg 12;
  5951.                 } elseif ($nbatach == 2) {
  5952.                     if ($ordre == 1) {
  5953.                         $positionX 1.5;
  5954.                         $positionY 1.5;
  5955.                         $widthImg 8.7;
  5956.                         $heightImg 12;
  5957.                     }
  5958.                     if ($ordre == 2) {
  5959.                         $positionX 10.8;
  5960.                         $positionY 1.5;
  5961.                         $widthImg 8.7;
  5962.                         $heightImg 12;
  5963.                     }
  5964.                 } elseif ($nbatach == 3) {
  5965.                     if ($ordre == 1) {
  5966.                         $positionX 1.5;
  5967.                         $positionY 1.5;
  5968.                         $widthImg 8.7;
  5969.                         $heightImg 12;
  5970.                     }
  5971.                     if ($ordre == 2) {
  5972.                         $positionX 10.8;
  5973.                         $positionY 1.5;
  5974.                         $widthImg 8.7;
  5975.                         $heightImg 5.7;
  5976.                     }
  5977.                     if ($ordre == 3) {
  5978.                         $positionX 10.8;
  5979.                         $positionY 7.8;
  5980.                         $widthImg 8.7;
  5981.                         $heightImg 5.7;
  5982.                     }
  5983.                 } elseif ($nbatach == 4) {
  5984.                     if ($ordre == 1) {
  5985.                         $positionX 1.5;
  5986.                         $positionY 1.5;
  5987.                         $widthImg 8.7;
  5988.                         $heightImg 5.7;
  5989.                     }
  5990.                     if ($ordre == 2) {
  5991.                         $positionX 1.5;
  5992.                         $positionY 7.8;
  5993.                         $widthImg 8.7;
  5994.                         $heightImg 5.7;
  5995.                     }
  5996.                     if ($ordre == 3) {
  5997.                         $positionX 10.8;
  5998.                         $positionY 1.5;
  5999.                         $widthImg 8.7;
  6000.                         $heightImg 5.7;
  6001.                     }
  6002.                     if ($ordre == 4) {
  6003.                         $positionX 10.8;
  6004.                         $positionY 7.8;
  6005.                         $widthImg 8.7;
  6006.                         $heightImg 5.7;
  6007.                     }
  6008.                 } elseif ($nbatach == 5) {
  6009.                     if ($ordre == 1) {
  6010.                         $positionX 1.5;
  6011.                         $positionY 1.5;
  6012.                         $widthImg 18;
  6013.                         $heightImg 8;
  6014.                     }
  6015.                     if ($ordre == 2) {
  6016.                         $positionX 1.5;
  6017.                         $positionY 10.1;
  6018.                         $widthImg 4.05;
  6019.                         $heightImg 3.4;
  6020.                     }
  6021.                     if ($ordre == 3) {
  6022.                         $positionX 6.15;
  6023.                         $positionY 10.1;
  6024.                         $widthImg 4.05;
  6025.                         $heightImg 3.4;
  6026.                     }
  6027.                     if ($ordre == 4) {
  6028.                         $positionX 10.8;
  6029.                         $positionY 10.1;
  6030.                         $widthImg 4.05;
  6031.                         $heightImg 3.4;
  6032.                     }
  6033.                     if ($ordre == 5) {
  6034.                         $positionX 15.45;
  6035.                         $positionY 10.1;
  6036.                         $widthImg 4.05;
  6037.                         $heightImg 3.4;
  6038.                     }
  6039.                 } elseif ($nbatach == 6) {
  6040.                     if ($ordre == 1) {
  6041.                         $positionX 1.5;
  6042.                         $positionY 1.5;
  6043.                         $widthImg 5.53;
  6044.                         $heightImg 3.6;
  6045.                     }
  6046.                     if ($ordre == 2) {
  6047.                         $positionX 1.5;
  6048.                         $positionY 5.7;
  6049.                         $widthImg 5.53;
  6050.                         $heightImg 3.6;
  6051.                     }
  6052.                     if ($ordre == 3) {
  6053.                         $positionX 1.5;
  6054.                         $positionY 9.9;
  6055.                         $widthImg 5.53;
  6056.                         $heightImg 3.6;
  6057.                     }
  6058.                     if ($ordre == 4) {
  6059.                         $positionX 7.63;
  6060.                         $positionY 1.5;
  6061.                         $widthImg 5.53;
  6062.                         $heightImg 3.6;
  6063.                     }
  6064.                     if ($ordre == 5) {
  6065.                         $positionX 7.63;
  6066.                         $positionY 5.7;
  6067.                         $widthImg 5.53;
  6068.                         $heightImg 3.6;
  6069.                     }
  6070.                     if ($ordre == 6) {
  6071.                         $positionX 7.63;
  6072.                         $positionY 9.9;
  6073.                         $widthImg 5.53;
  6074.                         $heightImg 3.6;
  6075.                     }
  6076.                 } elseif ($nbatach == 12) {
  6077.                     if ($ordre == 1) {
  6078.                         $positionX 1.5;
  6079.                         $positionY 1.5;
  6080.                         $widthImg 4.05;
  6081.                         $heightImg 3.6;
  6082.                     }
  6083.                     if ($ordre == 2) {
  6084.                         $positionX 1.5;
  6085.                         $positionY 5.7;
  6086.                         $widthImg 4.05;
  6087.                         $heightImg 3.6;
  6088.                     }
  6089.                     if ($ordre == 3) {
  6090.                         $positionX 1.5;
  6091.                         $positionY 9.9;
  6092.                         $widthImg 4.05;
  6093.                         $heightImg 3.6;
  6094.                     }
  6095.                     if ($ordre == 4) {
  6096.                         $positionX 6.15;
  6097.                         $positionY 1.5;
  6098.                         $widthImg 4.05;
  6099.                         $heightImg 3.6;
  6100.                     }
  6101.                     if ($ordre == 5) {
  6102.                         $positionX 6.15;
  6103.                         $positionY 5.7;
  6104.                         $widthImg 4.05;
  6105.                         $heightImg 3.6;
  6106.                     }
  6107.                     if ($ordre == 6) {
  6108.                         $positionX 6.15;
  6109.                         $positionY 9.9;
  6110.                         $widthImg 4.05;
  6111.                         $heightImg 3.6;
  6112.                     }
  6113.                     if ($ordre == 7) {
  6114.                         $positionX 10.8;
  6115.                         $positionY 1.5;
  6116.                         $widthImg 4.05;
  6117.                         $heightImg 3.6;
  6118.                     }
  6119.                     if ($ordre == 8) {
  6120.                         $positionX 10.8;
  6121.                         $positionY 5.7;
  6122.                         $widthImg 4.05;
  6123.                         $heightImg 3.6;
  6124.                     }
  6125.                     if ($ordre == 9) {
  6126.                         $positionX 10.8;
  6127.                         $positionY 9.9;
  6128.                         $widthImg 4.05;
  6129.                         $heightImg 3.6;
  6130.                     }
  6131.                     if ($ordre == 10) {
  6132.                         $positionX 15.45;
  6133.                         $positionY 1.5;
  6134.                         $widthImg 4.05;
  6135.                         $heightImg 3.6;
  6136.                     }
  6137.                     if ($ordre == 11) {
  6138.                         $positionX 15.45;
  6139.                         $positionY 5.7;
  6140.                         $widthImg 4.05;
  6141.                         $heightImg 3.6;
  6142.                     }
  6143.                     if ($ordre == 12) {
  6144.                         $positionX 15.45;
  6145.                         $positionY 9.9;
  6146.                         $widthImg 4.05;
  6147.                         $heightImg 3.6;
  6148.                     }
  6149.                 }
  6150.                 //Recarder l'image :
  6151.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  6152.                 //                $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);
  6153.                 $pathArray explode("/"$path);
  6154.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  6155.                 $idImage "";
  6156.                 foreach ($idsArray as $key => $elem) {
  6157.                     if ($key != (sizeof($idsArray) - 1)) {
  6158.                         $idImage $idImage $elem;
  6159.                     }
  6160.                 }
  6161.                 //   $cloudinaryWidht=$widthOriginal;
  6162.                 // $cloudinaryHeight=$widthOriginal;
  6163.                 $idImage 'newprod/' $idImage;
  6164.                 //var_dump($idImage);
  6165.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  6166.                 $headers = array('Accept' => 'application/json');
  6167.                 $data = array("public_ids" => array($idImage));
  6168.                 $body Unirest\Request\Body::form($data);
  6169.                 Unirest\Request::verifyPeer(false);
  6170.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  6171.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  6172.                 //  var_dump($url);
  6173.                 //https://media.5sur5sejour.com/api/upload/a_exif/original/
  6174.                 $resultMetadata Unirest\Request::post($url$headers$body);
  6175.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  6176.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  6177.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  6178.                 } else {
  6179.                     $cloudinaryWidht $widthOriginal;
  6180.                     $cloudinaryHeight $heightOriginal;
  6181.                 }
  6182.                 $ratiohight $cloudinaryWidht $widthOriginal;
  6183.                 $ratioHight $cloudinaryHeight $heightOriginal;
  6184.                 //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  6185.                 //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  6186.                 var_dump($cloudinaryWidht);
  6187.                 var_dump($cloudinaryHeight);
  6188.                 var_dump($ratioHight);
  6189.                 var_dump($zoom);
  6190.                 var_dump($leftOriginal);
  6191.                 var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  6192.                 var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  6193.                 var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  6194.                 var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  6195.                 //var_dump($path);i
  6196.                 $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);
  6197.                 //var_dump($path);i
  6198.                 //                $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);
  6199.                 //var_dump($path);
  6200.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  6201.                 //  var_dump("//00");
  6202.                 //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  6203.                 //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  6204.                 //    var_dump("//00");
  6205.                 //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  6206.                 //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  6207.                 var_dump($zoom);
  6208.                 var_dump($path);
  6209.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  6210.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  6211.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  6212.                 //
  6213.             }
  6214.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  6215.             for ($i 0$i sizeof($tabtxt); $i++) {
  6216.                 $txt json_decode($tabtxt[$i]);
  6217.                 $fontSize floatval(str_replace('px'''$txt->fontSize)) * 0.75;
  6218.                 //$txt->rotation
  6219.                 $check explode(','$txt->fontFamily);
  6220.                 if (sizeof($check) > 1) {
  6221.                     //default
  6222.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 400)) {
  6223.                         $finalFont "helvetica";
  6224.                         $weight '';
  6225.                     }
  6226.                     //classique
  6227.                     if (($check[0] == "Georgia") && ($txt->fontWeight == 400)) {
  6228.                         $finalFont "times";
  6229.                         $weight '';
  6230.                     }
  6231.                     //creative
  6232.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 700)) {
  6233.                         $finalFont "helveticaB";
  6234.                         $weight '';
  6235.                     }
  6236.                     // manuscrite
  6237.                     if (($check[0] == "Comic Sans") && ($txt->fontWeight == 400)) {
  6238.                         $finalFont "Courier";
  6239.                         $weight '';
  6240.                     }
  6241.                     //c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff2
  6242.                 } else {
  6243.                     //baton
  6244.                     if (($txt->fontFamily == 'Impact') && ($txt->fontWeight == 400)) {
  6245.                         $finalFont "helveticaB";
  6246.                         $weight 'B';
  6247.                     }
  6248.                 }
  6249.                 $pdf->SetFont($finalFont$weight$fontSize);
  6250.                 $leftTxt $txt->left;
  6251.                 $topTxt $txt->top;
  6252.                 $heightClips $txt->height;
  6253.                 $widthClips $txt->width;
  6254.                 $heightTxt floatval(str_replace('cm'''$heightClips));
  6255.                 $topTxt floatval(str_replace('cm'''$topTxt));
  6256.                 $leftTxt floatval(str_replace('cm'''$leftTxt));
  6257.                 $widthTxt floatval(str_replace('cm'''$widthClips));
  6258.                 $pdf->SetXY($leftTxt$topTxttrue);
  6259.                 //                    var_dump($leftTxt);
  6260.                 //                  var_dump($topTxt);
  6261.                 // var_dump(floatval(str_replace('rad','',$txt->rotation))*57,2958);
  6262.                 //                var_dump("text");
  6263.                 $pdf->StartTransform();
  6264.                 var_dump($txt->rotation);
  6265.                 var_dump(str_replace('rad'''$txt->rotation));
  6266.                 var_dump(floatval(str_replace('rad'''$txt->rotation)) * 57.2958);
  6267.                 $pdf->Rotate((floatval(str_replace('rad'''$txt->rotation)) * 57.2958) * -1$leftTxt + ($widthTxt 2), $topTxt + ($heightTxt 2));
  6268.                 // $pdf->Rotate(45);
  6269.                 //   $pdf->Text($leftTxt, $topTxt, $txt->contenu);
  6270.                 //$pdf->SetTextColor(200);
  6271.                 //$pdf->Text($leftTxt, $topTxt, $txt->contenu);
  6272.                 // $pdf->MultiCell($leftTxt, $topTxt,  $txt->contenu, 0, $ln=0, 'C', 0, '', 0, false, 'C', 'C');
  6273.                 $pdf->Write(str_replace('cm'''$txt->height), trim($txt->contenu));
  6274.                 // $pdf->writeHTML("<p>".$txt->contenu."</p>", true, false, false, false, '');
  6275.                 $pdf->StopTransform();
  6276.             }
  6277.             //Positionner text
  6278.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  6279.             //Positionner clipart
  6280.             //            dd($tabClips);
  6281.             for ($i 0$i sizeof($tabClips); $i++) {
  6282.                 $Clips json_decode($tabClips[$i]);
  6283.                 $heightClips $Clips->height;
  6284.                 $topClips $Clips->top;
  6285.                 $leftClips $Clips->left;
  6286.                 $widthClips $Clips->width;
  6287.                 $path $Clips->path;
  6288.                 $pathClips str_replace('"'''$path);
  6289.                 $heightClips floatval(str_replace('cm'''$heightClips));
  6290.                 $topClips floatval(str_replace('cm'''$topClips));
  6291.                 $leftClips floatval(str_replace('cm'''$leftClips));
  6292.                 $widthClips floatval(str_replace('cm'''$widthClips));
  6293.                 $heightClipsPX round($heightClips 37.7952755906);
  6294.                 $widthClipsPX round($widthClips 37.7952755906);
  6295.                 ////                $positionXclips = $positionX + $leftClips;
  6296.                 ////                $positionYclips = $positionY + $topClips;
  6297.                 //
  6298.                 //$pdf->ImageSVG("images/ClipArt_SVG/Ete4.svg",$leftClips,$topClips,$widthClips, $heightClips);
  6299.                 //https://res.cloudinary.com/apss-factory/image/private/s--EdExAzx8--/v1588758453/GlobeFooter_c4duua.svg
  6300.                 // https://res.cloudinary.com/apss-factory/image/upload/v1588764528/Groupe_113_pcjyj4.png
  6301.                 var_dump($pathClips);
  6302.                 $pdf->StartTransform();
  6303.                 $pdf->Rotate((floatval(str_replace('rad'''$Clips->rotation)) * 57.2958) * -1$leftClips + ($widthClips 2), $topClips + ($heightClips 2));
  6304.                 $pdf->Image($this->newPAthCLipart($pathClips$heightClipsPX$widthClipsPX), $leftClips,  $topClips$widthClips$heightClips''''''false300);
  6305.                 $pdf->StopTransform();
  6306.             }
  6307.         }
  6308.         // echo '</pre>';
  6309.         //return new response("yezi");
  6310.         $projectRoot $this->getParameter('kernel.project_dir');
  6311.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  6312.         return new response("yezi");
  6313.         //return $pdf->Output('example_009.pdf', 'I');
  6314.     }
  6315.     /**
  6316.      * @Route("/Parent/testPDFphoto/{idPrdt}", name="TcPdfphoto")
  6317.      */
  6318.     public function TcPdfPhoto($idPrdt)
  6319.     {
  6320.         ini_set("max_execution_time", -1);
  6321.         $pageLayout = array(1510);
  6322.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  6323.         // set document information
  6324.         $pdf->SetCreator(PDF_CREATOR);
  6325.         $pdf->SetAuthor('Nicola Asuni');
  6326.         $pdf->SetTitle('TCPDF Example 009');
  6327.         $pdf->SetSubject('TCPDF Tutorial');
  6328.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  6329.         $pdf->SetSubject('TCPDF Tutorial');
  6330.         $pdf->setPrintHeader(false);
  6331.         $pdf->setPrintFooter(false);
  6332.         // set image scale factor
  6333.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  6334.         //        $pdf->AddPage();
  6335.         $pdf->setJPEGQuality(100);
  6336.         $horizontal_alignments = array('L''C''R');
  6337.         $vertical_alignments = array('T''M''B');
  6338.         //var_dump($pdf->getPageWidth());
  6339.         //var_dump($pdf->getPageHeight());die();
  6340.         $em $this->em;
  6341.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  6342.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  6343.         //dd($AllPages);
  6344.         //        $fP=[];
  6345.         //        array_push($fP,$AllPages[0]);
  6346.         //dd($AllPages);
  6347.         foreach ($AllPages as $p) {
  6348.             $pdf->AddPage();
  6349.             $pdf->setJPEGQuality(100);
  6350.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  6351.             $nbatach $contenu->nbrAttc;
  6352.             $nbatach intval(str_replace('"'''$nbatach));
  6353.             $color =  $contenu->color;
  6354.             // $color="rgb(255,255,255)";
  6355.             $tabphoto json_decode($contenu->attache);
  6356.             //
  6357.             //dd($tabtxt);
  6358.             //         dd($tabtxt);
  6359.             //dd($tabphoto);
  6360.             // dd($tabClips);
  6361.             // get the current page break margin
  6362.             $bMargin $pdf->getBreakMargin();
  6363.             // get current auto-page-break mode
  6364.             $auto_page_break $pdf->getAutoPageBreak();
  6365.             // disable auto-page-break
  6366.             $pdf->SetAutoPageBreak(false0);
  6367.             // test all combinations of alignments
  6368.             $fitbox $horizontal_alignments[1] . ' ';
  6369.             $fitbox[1] = $vertical_alignments[1];
  6370.             //    sizeof($tabphoto)
  6371.             for ($i 0$i sizeof($tabphoto); $i++) {
  6372.                 $photo json_decode($tabphoto[$i]);
  6373.                 //les coordonnées de l'image réel:
  6374.                 $hght $photo->height;
  6375.                 $top $photo->top;
  6376.                 $left $photo->left;
  6377.                 $width $photo->width;
  6378.                 $ordre $photo->ordre;
  6379.                 $zoom $photo->zoom;
  6380.                 $path $photo->path;
  6381.                 $hght floatval(str_replace('cm'''$hght));
  6382.                 $top floatval(str_replace('cm'''$top));
  6383.                 $left floatval(str_replace('cm'''$left));
  6384.                 $width floatval(str_replace('cm'''$width));
  6385.                 //les coordonnées dropzone:
  6386.                 $heightOriginal $photo->height;
  6387.                 $widthOriginal $photo->width;
  6388.                 $top $photo->top;
  6389.                 $left $photo->left;
  6390.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  6391.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  6392.                 $top floatval(str_replace('cm'''$top));
  6393.                 $left floatval(str_replace('cm'''$left));
  6394.                 $heightOriginal $heightOriginal 37.7952755906;
  6395.                 $widthOriginal $widthOriginal 37.7952755906;
  6396.                 $topOriginal $top 37.7952755906;
  6397.                 $leftOriginal $left 37.7952755906;
  6398.                 $heightCrop $photo->heightCrop;
  6399.                 $topCrop $photo->topCrop;
  6400.                 $leftCrop $photo->leftCrop;
  6401.                 $widthCrop $photo->widthCrop;
  6402.                 $path $photo->path;
  6403.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  6404.                 $topCrop floatval(str_replace('cm'''$topCrop));
  6405.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  6406.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  6407.                 $widthCropPX $widthCrop 37.7952755906;
  6408.                 $heightCropPX $heightCrop 37.7952755906;
  6409.                 $topCropPX $topCrop 37.7952755906;
  6410.                 $leftCropPX $leftCrop 37.7952755906;
  6411.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  6412.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  6413.                 // var_dump("//00");
  6414.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  6415.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  6416.                 //Calculer position des images selon nombres images par page:
  6417.                 $positionX 0;
  6418.                 $positionY 0;
  6419.                 $widthImg 0;
  6420.                 $heightImg 0;
  6421.                 if ($nbatach == 1) {
  6422.                     $positionX 0.3;
  6423.                     $positionY 0.3;
  6424.                     $widthImg 14.4;
  6425.                     $heightImg 9.4;
  6426.                 }
  6427.                 //Recarder l'image :
  6428.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  6429.                 //                $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);
  6430.                 $pathArray explode("/"$path);
  6431.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  6432.                 $idImage "";
  6433.                 foreach ($idsArray as $key => $elem) {
  6434.                     if ($key != (sizeof($idsArray) - 1)) {
  6435.                         $idImage $idImage $elem;
  6436.                     }
  6437.                 }
  6438.                 //   $cloudinaryWidht=$widthOriginal;
  6439.                 // $cloudinaryHeight=$widthOriginal;
  6440.                 $idImage 'newprod/' $idImage;
  6441.                 //var_dump($idImage);
  6442.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  6443.                 $headers = array('Accept' => 'application/json');
  6444.                 $data = array("public_ids" => array($idImage));
  6445.                 $body Unirest\Request\Body::form($data);
  6446.                 Unirest\Request::verifyPeer(false);
  6447.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  6448.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  6449.                 //  var_dump($url);
  6450.                 $resultMetadata Unirest\Request::post($url$headers$body);
  6451.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  6452.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  6453.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  6454.                 } else {
  6455.                     $cloudinaryWidht $widthOriginal;
  6456.                     $cloudinaryHeight $heightOriginal;
  6457.                 }
  6458.                 $ratiohight $cloudinaryWidht $widthOriginal;
  6459.                 $ratioHight $cloudinaryHeight $heightOriginal;
  6460.                 //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  6461.                 //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  6462.                 $zoom 1;
  6463.                 var_dump($cloudinaryWidht);
  6464.                 var_dump($cloudinaryHeight);
  6465.                 var_dump($ratioHight);
  6466.                 var_dump($zoom);
  6467.                 var_dump($leftOriginal);
  6468.                 var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  6469.                 var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  6470.                 var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  6471.                 var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  6472.                 //var_dump($path);i
  6473.                 $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);
  6474.                 //var_dump($path);i
  6475.                 //                $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);
  6476.                 //var_dump($path);
  6477.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  6478.                 //  var_dump("//00");
  6479.                 //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  6480.                 //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  6481.                 //    var_dump("//00");
  6482.                 //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  6483.                 //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  6484.                 var_dump($zoom);
  6485.                 var_dump($path);
  6486.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  6487.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  6488.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  6489.                 //
  6490.             }
  6491.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  6492.             //Positionner text
  6493.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  6494.             //Positionner clipart
  6495.             //            dd($tabClips);
  6496.         }
  6497.         // echo '</pre>';
  6498.         //return new response("yezi");
  6499.         $projectRoot $this->getParameter('kernel.project_dir');
  6500.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  6501.         return new response("yezi");
  6502.         //return $pdf->Output('example_009.pdf', 'I');
  6503.     }
  6504.     /**
  6505.      * @Route("/Parent/testPDFphotoR/{idPrdt}", name="TcPdfphotoR")
  6506.      */
  6507.     public function TcPdfPhotoR($idPrdt)
  6508.     {
  6509.         ini_set("max_execution_time", -1);
  6510.         $pageLayout = array(910);
  6511.         $pdf $this->get("white_october.tcpdf")->create('P''CM'$pageLayouttrue'UTF-8'false);
  6512.         // set document information
  6513.         $pdf->SetCreator(PDF_CREATOR);
  6514.         $pdf->SetAuthor('Nicola Asuni');
  6515.         $pdf->SetTitle('TCPDF Example 009');
  6516.         $pdf->SetSubject('TCPDF Tutorial');
  6517.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  6518.         $pdf->SetSubject('TCPDF Tutorial');
  6519.         $pdf->setPrintHeader(false);
  6520.         $pdf->setPrintFooter(false);
  6521.         // set image scale factor
  6522.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  6523.         //        $pdf->AddPage();
  6524.         $pdf->setJPEGQuality(100);
  6525.         $horizontal_alignments = array('L''C''R');
  6526.         $vertical_alignments = array('T''M''B');
  6527.         //var_dump($pdf->getPageWidth());
  6528.         //var_dump($pdf->getPageHeight());die();
  6529.         $em $this->em;
  6530.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  6531.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  6532.         //dd($AllPages);
  6533.         //        $fP=[];
  6534.         //        array_push($fP,$AllPages[0]);
  6535.         //dd($AllPages);
  6536.         foreach ($AllPages as $p) {
  6537.             $pdf->AddPage();
  6538.             $pdf->setJPEGQuality(100);
  6539.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  6540.             $nbatach $contenu->nbrAttc;
  6541.             $nbatach intval(str_replace('"'''$nbatach));
  6542.             $color =  $contenu->color;
  6543.             // $color="rgb(255,255,255)";
  6544.             $tabphoto json_decode($contenu->attache);
  6545.             //
  6546.             //dd($tabtxt);
  6547.             //         dd($tabtxt);
  6548.             //dd($tabphoto);
  6549.             // dd($tabClips);
  6550.             // get the current page break margin
  6551.             $bMargin $pdf->getBreakMargin();
  6552.             // get current auto-page-break mode
  6553.             $auto_page_break $pdf->getAutoPageBreak();
  6554.             // disable auto-page-break
  6555.             $pdf->SetAutoPageBreak(false0);
  6556.             // test all combinations of alignments
  6557.             $fitbox $horizontal_alignments[1] . ' ';
  6558.             $fitbox[1] = $vertical_alignments[1];
  6559.             //    sizeof($tabphoto)
  6560.             for ($i 0$i sizeof($tabphoto); $i++) {
  6561.                 $photo json_decode($tabphoto[$i]);
  6562.                 //les coordonnées de l'image réel:
  6563.                 $hght $photo->height;
  6564.                 $top $photo->top;
  6565.                 $left $photo->left;
  6566.                 $width $photo->width;
  6567.                 $ordre $photo->ordre;
  6568.                 $zoom $photo->zoom;
  6569.                 $path $photo->path;
  6570.                 $hght floatval(str_replace('cm'''$hght));
  6571.                 $top floatval(str_replace('cm'''$top));
  6572.                 $left floatval(str_replace('cm'''$left));
  6573.                 $width floatval(str_replace('cm'''$width));
  6574.                 //les coordonnées dropzone:
  6575.                 $heightOriginal $photo->height;
  6576.                 $widthOriginal $photo->width;
  6577.                 $top $photo->top;
  6578.                 $left $photo->left;
  6579.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  6580.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  6581.                 $top floatval(str_replace('cm'''$top));
  6582.                 $left floatval(str_replace('cm'''$left));
  6583.                 $heightOriginal $heightOriginal 37.7952755906;
  6584.                 $widthOriginal $widthOriginal 37.7952755906;
  6585.                 $topOriginal $top 37.7952755906;
  6586.                 $leftOriginal $left 37.7952755906;
  6587.                 $heightCrop $photo->heightCrop;
  6588.                 $topCrop $photo->topCrop;
  6589.                 $leftCrop $photo->leftCrop;
  6590.                 $widthCrop $photo->widthCrop;
  6591.                 $path $photo->path;
  6592.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  6593.                 $topCrop floatval(str_replace('cm'''$topCrop));
  6594.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  6595.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  6596.                 $widthCropPX $widthCrop 37.7952755906;
  6597.                 $heightCropPX $heightCrop 37.7952755906;
  6598.                 $topCropPX $topCrop 37.7952755906;
  6599.                 $leftCropPX $leftCrop 37.7952755906;
  6600.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  6601.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  6602.                 // var_dump("//00");
  6603.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  6604.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  6605.                 //Calculer position des images selon nombres images par page:
  6606.                 $positionX 0;
  6607.                 $positionY 0;
  6608.                 $widthImg 0;
  6609.                 $heightImg 0;
  6610.                 $positionX 0.55;
  6611.                 $positionY 0.5;
  6612.                 $widthImg 7.9;
  6613.                 $heightImg 6.9;
  6614.                 //Recarder l'image :
  6615.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  6616.                 //                $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);
  6617.                 $pathArray explode("/"$path);
  6618.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  6619.                 $idImage "";
  6620.                 foreach ($idsArray as $key => $elem) {
  6621.                     if ($key != (sizeof($idsArray) - 1)) {
  6622.                         $idImage $idImage $elem;
  6623.                     }
  6624.                 }
  6625.                 //   $cloudinaryWidht=$widthOriginal;
  6626.                 // $cloudinaryHeight=$widthOriginal;
  6627.                 $idImage 'newprod/' $idImage;
  6628.                 //var_dump($idImage);
  6629.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  6630.                 $headers = array('Accept' => 'application/json');
  6631.                 $data = array("public_ids" => array($idImage));
  6632.                 $body Unirest\Request\Body::form($data);
  6633.                 Unirest\Request::verifyPeer(false);
  6634.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  6635.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  6636.                 //  var_dump($url);
  6637.                 $resultMetadata Unirest\Request::post($url$headers$body);
  6638.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  6639.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  6640.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  6641.                 } else {
  6642.                     $cloudinaryWidht $widthOriginal;
  6643.                     $cloudinaryHeight $heightOriginal;
  6644.                 }
  6645.                 $ratiohight $cloudinaryWidht $widthOriginal;
  6646.                 $ratioHight $cloudinaryHeight $heightOriginal;
  6647.                 //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  6648.                 //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  6649.                 $zoom 1;
  6650.                 var_dump($cloudinaryWidht);
  6651.                 var_dump($cloudinaryHeight);
  6652.                 var_dump($ratioHight);
  6653.                 var_dump($zoom);
  6654.                 var_dump($leftOriginal);
  6655.                 var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  6656.                 var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  6657.                 var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  6658.                 var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  6659.                 //var_dump($path);i
  6660.                 $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);
  6661.                 //var_dump($path);i
  6662.                 //                $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);
  6663.                 //var_dump($path);
  6664.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  6665.                 //  var_dump("//00");
  6666.                 //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  6667.                 //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  6668.                 //    var_dump("//00");
  6669.                 //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  6670.                 //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  6671.                 var_dump($zoom);
  6672.                 var_dump($path);
  6673.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  6674.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  6675.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  6676.                 //
  6677.             }
  6678.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  6679.             //Positionner text
  6680.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  6681.             //Positionner clipart
  6682.             //            dd($tabClips);
  6683.         }
  6684.         // echo '</pre>';
  6685.         //return new response("yezi");
  6686.         $projectRoot $this->getParameter('kernel.project_dir');
  6687.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  6688.         return new response("yezi");
  6689.         //return $pdf->Output('example_009.pdf', 'I');
  6690.     }
  6691.     /**
  6692.      * @Route("/Parent/testPDFCal/{idPrdt}", name="TcPdfCal")
  6693.      */
  6694.     public function TcPdfCalendrier($idPrdt)
  6695.     {
  6696.         ini_set("max_execution_time", -1);
  6697.         $pageLayout = array(2115);
  6698.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  6699.         // set document information
  6700.         $pdf->SetCreator(PDF_CREATOR);
  6701.         $pdf->SetAuthor('Nicola Asuni');
  6702.         $pdf->SetTitle('TCPDF Example 009');
  6703.         $pdf->SetSubject('TCPDF Tutorial');
  6704.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  6705.         $pdf->SetSubject('TCPDF Tutorial');
  6706.         $pdf->setPrintHeader(false);
  6707.         $pdf->setPrintFooter(false);
  6708.         // set image scale factor
  6709.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  6710.         //        $pdf->AddPage();
  6711.         $pdf->setJPEGQuality(100);
  6712.         $horizontal_alignments = array('L''C''R');
  6713.         $vertical_alignments = array('T''M''B');
  6714.         //var_dump($pdf->getPageWidth());
  6715.         //var_dump($pdf->getPageHeight());die();
  6716.         $em $this->em;
  6717.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  6718.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  6719.         //dd($AllPages);
  6720.         //        $fP=[];
  6721.         //        array_push($fP,$AllPages[0]);
  6722.         //dd($AllPages);
  6723.         foreach ($AllPages as $key => $p) {
  6724.             $pdf->AddPage();
  6725.             $pdf->setJPEGQuality(100);
  6726.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  6727.             $nbatachS $contenu->nbrAttc;
  6728.             $nbatach intval(str_replace('"'''$nbatachS));
  6729.             if (strpos($nbatachS"H")) {
  6730.                 $nbatach $nbatach 'H';
  6731.             }
  6732.             $tabtxt json_decode($contenu->txt);
  6733.             $tabphoto json_decode($contenu->attache);
  6734.             //
  6735.             //dd($tabtxt);
  6736.             //         dd($tabtxt);
  6737.             //dd($tabphoto);
  6738.             $tabClips json_decode($contenu->clips);
  6739.             // dd($tabClips);
  6740.             $x 0.6;
  6741.             $y 0.8;
  6742.             $w 19.8;
  6743.             $h 13.4;
  6744.             // get the current page break margin
  6745.             $bMargin $pdf->getBreakMargin();
  6746.             // get current auto-page-break mode
  6747.             $auto_page_break $pdf->getAutoPageBreak();
  6748.             // disable auto-page-break
  6749.             $pdf->SetAutoPageBreak(false0);
  6750.             // test all combinations of alignments
  6751.             $fitbox $horizontal_alignments[1] . ' ';
  6752.             $fitbox[1] = $vertical_alignments[1];
  6753.             //    sizeof($tabphoto)
  6754.             for ($i 0$i sizeof($tabphoto); $i++) {
  6755.                 $photo json_decode($tabphoto[$i]);
  6756.                 //les coordonnées de l'image réel:
  6757.                 $hght $photo->height;
  6758.                 $top $photo->top;
  6759.                 $left $photo->left;
  6760.                 $width $photo->width;
  6761.                 $ordre $photo->ordre;
  6762.                 $zoom $photo->zoom;
  6763.                 $path $photo->path;
  6764.                 $hght floatval(str_replace('cm'''$hght));
  6765.                 $top floatval(str_replace('cm'''$top));
  6766.                 $left floatval(str_replace('cm'''$left));
  6767.                 $width floatval(str_replace('cm'''$width));
  6768.                 //les coordonnées dropzone:
  6769.                 $heightOriginal $photo->height;
  6770.                 $widthOriginal $photo->width;
  6771.                 $top $photo->top;
  6772.                 $left $photo->left;
  6773.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  6774.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  6775.                 $top floatval(str_replace('cm'''$top));
  6776.                 $left floatval(str_replace('cm'''$left));
  6777.                 $heightOriginal $heightOriginal 37.7952755906;
  6778.                 $widthOriginal $widthOriginal 37.7952755906;
  6779.                 $topOriginal $top 37.7952755906;
  6780.                 $leftOriginal $left 37.7952755906;
  6781.                 $heightCrop $photo->heightCrop;
  6782.                 $topCrop $photo->topCrop;
  6783.                 $leftCrop $photo->leftCrop;
  6784.                 $widthCrop $photo->widthCrop;
  6785.                 $path $photo->path;
  6786.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  6787.                 $topCrop floatval(str_replace('cm'''$topCrop));
  6788.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  6789.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  6790.                 $widthCropPX $widthCrop 37.7952755906;
  6791.                 $heightCropPX $heightCrop 37.7952755906;
  6792.                 $topCropPX $topCrop 37.7952755906;
  6793.                 $leftCropPX $leftCrop 37.7952755906;
  6794.                 // var_dump("original widh: ".$widthCrop." "."original height : ".$heightCrop);
  6795.                 // var_dump("original left: ".$topCrop." "."original top : ".$leftCrop);
  6796.                 // var_dump("//00");
  6797.                 // var_dump("multip 37 widh: ".$widthCropPX." "."multip 37 height : ".$heightCropPX);
  6798.                 // var_dump("multip 37 top: ".$topCropPX." "."multip 37 left : ".$leftCropPX);
  6799.                 //Calculer position des images selon nombres images par page:
  6800.                 $positionX 0;
  6801.                 $positionY 0;
  6802.                 $widthImg 0;
  6803.                 $heightImg 0;
  6804.                 var_dump('nbr_attach ' $nbatach);
  6805.                 if ($nbatach == 1) {
  6806.                     if ($key == 0) {
  6807.                         $positionX 1.5;
  6808.                         $positionY 1.5;
  6809.                         $widthImg 18;
  6810.                         $heightImg 10;
  6811.                     } else {
  6812.                         $positionX 1.5;
  6813.                         $positionY 1.5;
  6814.                         $widthImg 8.7;
  6815.                         $heightImg 12;
  6816.                     }
  6817.                 } elseif (($nbatach == 2) && ($nbatach == '2V')) {
  6818.                     if ($ordre == 1) {
  6819.                         $positionX 1.5;
  6820.                         $positionY 1.5;
  6821.                         $widthImg 4.05;
  6822.                         $heightImg 12;
  6823.                     }
  6824.                     if ($ordre == 2) {
  6825.                         $positionX 6.15;
  6826.                         $positionY 1.5;
  6827.                         $widthImg 4.05;
  6828.                         $heightImg 12;
  6829.                     }
  6830.                 } elseif ($nbatach == '2H') {
  6831.                     if ($ordre == 1) {
  6832.                         $positionX 1.5;
  6833.                         $positionY 1.5;
  6834.                         $widthImg 8.7;
  6835.                         $heightImg 5.7;
  6836.                     }
  6837.                     if ($ordre == 2) {
  6838.                         $positionX 1.5;
  6839.                         $positionY 7.8;
  6840.                         $widthImg 8.7;
  6841.                         $heightImg 5.7;
  6842.                     }
  6843.                 } elseif (($nbatach == 3) && ($nbatach == "3V")) {
  6844.                     if ($ordre == 1) {
  6845.                         $positionX 1.5;
  6846.                         $positionY 1.5;
  6847.                         $widthImg 4.05;
  6848.                         $heightImg 12;
  6849.                     }
  6850.                     if ($ordre == 2) {
  6851.                         $positionX 6.15;
  6852.                         $positionY =  1.5;
  6853.                         $widthImg 4.05;
  6854.                         $heightImg 5.7;
  6855.                     }
  6856.                     if ($ordre == 3) {
  6857.                         $positionX =  6.15;
  6858.                         $positionY 7.8;
  6859.                         $widthImg 4.05;
  6860.                         $heightImg 5.7;
  6861.                     }
  6862.                 } elseif ($nbatach == '3H') {
  6863.                     if ($ordre == 1) {
  6864.                         $positionX 1.5;
  6865.                         $positionY 1.5;
  6866.                         $widthImg 8.7;
  6867.                         $heightImg 5.7;
  6868.                     }
  6869.                     if ($ordre == 2) {
  6870.                         $positionX 1.5;
  6871.                         $positionY 7.8;
  6872.                         $widthImg 4.05;
  6873.                         $heightImg 5.7;
  6874.                     }
  6875.                     if ($ordre == 3) {
  6876.                         $positionX 6.15;
  6877.                         $positionY 7.8;
  6878.                         $widthImg 4.05;
  6879.                         $heightImg 5.7;
  6880.                     }
  6881.                 } elseif ($nbatach == 4) {
  6882.                     if ($ordre == 1) {
  6883.                         $positionX 1.5;
  6884.                         $positionY 1.5;
  6885.                         $widthImg 4.05;
  6886.                         $heightImg 5.7;
  6887.                     }
  6888.                     if ($ordre == 2) {
  6889.                         $positionX 1.5;
  6890.                         $positionY 7.8;
  6891.                         $widthImg 4.05;
  6892.                         $heightImg 5.7;
  6893.                     }
  6894.                     if ($ordre == 3) {
  6895.                         $positionX 6.15;
  6896.                         $positionY =  1.5;
  6897.                         $widthImg 4.05;
  6898.                         $heightImg 5.7;
  6899.                     }
  6900.                     if ($ordre == 4) {
  6901.                         $positionX =  6.15;
  6902.                         $positionY 7.8;
  6903.                         $widthImg 4.05;
  6904.                         $heightImg 5.7;
  6905.                     }
  6906.                 }
  6907.                 //nop
  6908.                 elseif ($nbatach == 5) {
  6909.                     if ($ordre == 1) {
  6910.                         $positionX 1.5;
  6911.                         $positionY 1.5;
  6912.                         $widthImg 18;
  6913.                         $heightImg 8;
  6914.                     }
  6915.                     if ($ordre == 2) {
  6916.                         $positionX 1.5;
  6917.                         $positionY 10.5;
  6918.                         $widthImg 3.75;
  6919.                         $heightImg 3;
  6920.                     }
  6921.                     if ($ordre == 3) {
  6922.                         $positionX 6.25;
  6923.                         $positionY 10.5;
  6924.                         $widthImg 3.75;
  6925.                         $heightImg 3;
  6926.                     }
  6927.                     if ($ordre == 4) {
  6928.                         $positionX 11;
  6929.                         $positionY 10.5;
  6930.                         $widthImg 3.75;
  6931.                         $heightImg 3;
  6932.                     }
  6933.                     if ($ordre == 5) {
  6934.                         $positionX 15.75;
  6935.                         $positionY 10.5;
  6936.                         $widthImg 3.75;
  6937.                         $heightImg 3;
  6938.                     }
  6939.                 } elseif ($nbatach == 6) {
  6940.                     if ($ordre == 1) {
  6941.                         $positionX 1.5;
  6942.                         $positionY 1.5;
  6943.                         $widthImg 4.05;
  6944.                         $heightImg 3.6;
  6945.                     }
  6946.                     if ($ordre == 2) {
  6947.                         $positionX 1.5;
  6948.                         $positionY 5.7;
  6949.                         $widthImg 4.05;
  6950.                         $heightImg 3.6;
  6951.                     }
  6952.                     if ($ordre == 3) {
  6953.                         $positionX 1.5;
  6954.                         $positionY 9.9;
  6955.                         $widthImg 4.05;
  6956.                         $heightImg 3.6;
  6957.                     }
  6958.                     if ($ordre == 4) {
  6959.                         $positionX =  6.15;
  6960.                         $positionY 1.5;
  6961.                         $widthImg 4.05;
  6962.                         $heightImg 3.6;
  6963.                     }
  6964.                     if ($ordre == 5) {
  6965.                         $positionX =  6.15;
  6966.                         $positionY 5.7;
  6967.                         $widthImg 4.05;
  6968.                         $heightImg 3.6;
  6969.                     }
  6970.                     if ($ordre == 6) {
  6971.                         $positionX =  6.15;
  6972.                         $positionY 9.9;
  6973.                         $widthImg 4.05;
  6974.                         $heightImg 3.6;
  6975.                     }
  6976.                 }
  6977.                 //nop
  6978.                 elseif ($nbatach == 12) {
  6979.                     if ($ordre == 1) {
  6980.                         $positionX 1.5;
  6981.                         $positionY 1.5;
  6982.                         $widthImg 3.75;
  6983.                         $heightImg 3.33;
  6984.                     }
  6985.                     if ($ordre == 2) {
  6986.                         $positionX 1.5;
  6987.                         $positionY 5.83;
  6988.                         $widthImg 3.75;
  6989.                         $heightImg 3.33;
  6990.                     }
  6991.                     if ($ordre == 3) {
  6992.                         $positionX 1.5;
  6993.                         $positionY 10.16;
  6994.                         $widthImg 3.75;
  6995.                         $heightImg 3.33;
  6996.                     }
  6997.                     if ($ordre == 4) {
  6998.                         $positionX 6.25;
  6999.                         $positionY 1.5;
  7000.                         $widthImg 3.75;
  7001.                         $heightImg 3.33;
  7002.                     }
  7003.                     if ($ordre == 5) {
  7004.                         $positionX 6.25;
  7005.                         $positionY 5.83;
  7006.                         $widthImg 3.75;
  7007.                         $heightImg 3.33;
  7008.                     }
  7009.                     if ($ordre == 6) {
  7010.                         $positionX 6.25;
  7011.                         $positionY 10.16;
  7012.                         $widthImg 3.75;
  7013.                         $heightImg 3.33;
  7014.                     }
  7015.                     if ($ordre == 7) {
  7016.                         $positionX 11;
  7017.                         $positionY 1.5;
  7018.                         $widthImg 3.75;
  7019.                         $heightImg 3.33;
  7020.                     }
  7021.                     if ($ordre == 8) {
  7022.                         $positionX 11;
  7023.                         $positionY 5.83;
  7024.                         $widthImg 3.75;
  7025.                         $heightImg 3.33;
  7026.                     }
  7027.                     if ($ordre == 9) {
  7028.                         $positionX 11;
  7029.                         $positionY 10.16;
  7030.                         $widthImg 3.75;
  7031.                         $heightImg 3.33;
  7032.                     }
  7033.                     if ($ordre == 10) {
  7034.                         $positionX 15.75;
  7035.                         $positionY 1.5;
  7036.                         $widthImg 3.75;
  7037.                         $heightImg 3.33;
  7038.                     }
  7039.                     if ($ordre == 11) {
  7040.                         $positionX 15.75;
  7041.                         $positionY 5.83;
  7042.                         $widthImg 3.75;
  7043.                         $heightImg 3.33;
  7044.                     }
  7045.                     if ($ordre == 12) {
  7046.                         $positionX 15.75;
  7047.                         $positionY 10.16;
  7048.                         $widthImg 3.75;
  7049.                         $heightImg 3.33;
  7050.                     }
  7051.                 } elseif ($nbatach == 15) {
  7052.                     if ($ordre == 1) {
  7053.                         $positionX 1.5;
  7054.                         $positionY 1.5;
  7055.                         $widthImg 2.5;
  7056.                         $heightImg 1.92;
  7057.                     }
  7058.                     if ($ordre == 2) {
  7059.                         $positionX 1.5;
  7060.                         $positionY 4.2;
  7061.                         $widthImg 2.5;
  7062.                         $heightImg 1.92;
  7063.                     }
  7064.                     if ($ordre == 3) {
  7065.                         $positionX 1.5;
  7066.                         $positionY 6.54;
  7067.                         $widthImg 2.5;
  7068.                         $heightImg 1.92;
  7069.                     }
  7070.                     if ($ordre == 4) {
  7071.                         $positionX 1.5;
  7072.                         $positionY 9.06;
  7073.                         $widthImg 2.5;
  7074.                         $heightImg =  1.92;
  7075.                     }
  7076.                     if ($ordre == 5) {
  7077.                         $positionX 1.5;
  7078.                         $positionY 11.58;
  7079.                         $widthImg 2.5;
  7080.                         $heightImg =  1.92;
  7081.                     }
  7082.                     if ($ordre == 6) {
  7083.                         $positionX 4.6;
  7084.                         $positionY 1.5;
  7085.                         $widthImg 2.5;
  7086.                         $heightImg 1.92;
  7087.                     }
  7088.                     if ($ordre == 7) {
  7089.                         $positionX 4.6;
  7090.                         $positionY 4.2;
  7091.                         $widthImg 2.5;
  7092.                         $heightImg =  1.92;
  7093.                     }
  7094.                     if ($ordre == 8) {
  7095.                         $positionX 4.6;
  7096.                         $positionY 6.54;
  7097.                         $widthImg 2.5;
  7098.                         $heightImg =  1.92;
  7099.                     }
  7100.                     if ($ordre == 9) {
  7101.                         $positionX 4.6;
  7102.                         $positionY 9.06;
  7103.                         $widthImg 2.5;
  7104.                         $heightImg =  1.92;
  7105.                     }
  7106.                     if ($ordre == 10) {
  7107.                         $positionX 4.6;
  7108.                         $positionY 11.58;
  7109.                         $widthImg 2.5;
  7110.                         $heightImg =  1.92;
  7111.                     }
  7112.                     if ($ordre == 11) {
  7113.                         $positionX 7.7;
  7114.                         $positionY 1.5;
  7115.                         $widthImg 2.5;
  7116.                         $heightImg =  1.92;
  7117.                     }
  7118.                     if ($ordre == 12) {
  7119.                         $positionX 7.7;
  7120.                         $positionY 4.2;
  7121.                         $widthImg 2.5;
  7122.                         $heightImg 1.92;
  7123.                     }
  7124.                     if ($ordre == 13) {
  7125.                         $positionX 7.7;
  7126.                         $positionY 6.54;
  7127.                         $widthImg 2.5;
  7128.                         $heightImg =  1.92;
  7129.                     }
  7130.                     if ($ordre == 14) {
  7131.                         $positionX 7.7;
  7132.                         $positionY 9.06;
  7133.                         $widthImg 2.5;
  7134.                         $heightImg =  1.92;
  7135.                     }
  7136.                     if ($ordre == 15) {
  7137.                         $positionX 7.7;
  7138.                         $positionY 11.58;
  7139.                         $widthImg 2.5;
  7140.                         $heightImg =  1.92;
  7141.                     }
  7142.                 }
  7143.                 if (($i == sizeof($tabphoto) - 1) && ($key != 0)) {
  7144.                     $path 'https://demo.appsfactor.fr/' $path;
  7145.                     $positionX 10.8;
  7146.                     $positionY 1.5;
  7147.                     $widthImg 8.7;
  7148.                     $heightImg 12;
  7149.                     $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  7150.                 } else {
  7151.                     //Recarder l'image :
  7152.                     // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  7153.                     //                $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);
  7154.                     $pathArray explode("/"$path);
  7155.                     $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  7156.                     $idImage "";
  7157.                     foreach ($idsArray as $key2 => $elem) {
  7158.                         if ($key2 != (sizeof($idsArray) - 1)) {
  7159.                             $idImage $idImage $elem;
  7160.                         }
  7161.                     }
  7162.                     //   $cloudinaryWidht=$widthOriginal;
  7163.                     // $cloudinaryHeight=$widthOriginal;
  7164.                     $idImage 'newprod/' $idImage;
  7165.                     //var_dump($idImage);
  7166.                     Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  7167.                     $headers = array('Accept' => 'application/json');
  7168.                     $data = array("public_ids" => array($idImage));
  7169.                     $body Unirest\Request\Body::form($data);
  7170.                     Unirest\Request::verifyPeer(false);
  7171.                     $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  7172.                     // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  7173.                     //  var_dump($url);
  7174.                     $resultMetadata Unirest\Request::post($url$headers$body);
  7175.                     var_dump($resultMetadata);
  7176.                     if (isset(json_decode($resultMetadata->raw_body)->width)) {
  7177.                         $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  7178.                         $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  7179.                     } else {
  7180.                         $cloudinaryWidht $widthOriginal;
  7181.                         $cloudinaryHeight $heightOriginal;
  7182.                     }
  7183.                     $ratiohight $cloudinaryWidht $widthOriginal;
  7184.                     $ratioHight $cloudinaryHeight $heightOriginal;
  7185.                     //$cloudinaryHeight=$cloudinaryHeight*$zoom;
  7186.                     //$cloudinaryWidht=$cloudinaryWidht*$zoom;
  7187.                     var_dump($cloudinaryWidht);
  7188.                     var_dump($cloudinaryHeight);
  7189.                     var_dump($ratioHight);
  7190.                     var_dump($zoom);
  7191.                     $zoom 1;
  7192.                     var_dump($leftOriginal);
  7193.                     var_dump('x_' round(abs($leftOriginal $zoom) * $ratioHight));
  7194.                     var_dump('y_' round(abs($topOriginal $zoom) * $ratiohight));
  7195.                     var_dump('w_' round(($widthCropPX $zoom) * $ratioHight));
  7196.                     var_dump('h_' round(($heightCropPX $zoom) * $ratiohight));
  7197.                     //var_dump($path);i
  7198.                     $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);
  7199.                     //var_dump($path);i
  7200.                     //                $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);
  7201.                     //var_dump($path);
  7202.                     $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  7203.                     //  var_dump("//00");
  7204.                     //  var_dump("avant 1.4 widh: ".round($widthCropPX)." "."avant 1.4 height : ".round($heightCropPX));
  7205.                     //  var_dump("avant 1.4 top: ".round(abs($top*37.7952755906))." avant 1.4 final left : ".round(abs($left*37.7952755906)));
  7206.                     //    var_dump("//00");
  7207.                     //   var_dump("final widh: ".round($widthCropPX*1.4)." "."final height : ".round($heightCropPX*1.4));
  7208.                     //  var_dump("final top: ".round(abs($top*37.7952755906*1.4))." "."final left : ".round(abs($left*37.7952755906*1.4)));
  7209.                     var_dump($zoom);
  7210.                     var_dump($path);
  7211.                     // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  7212.                     $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false1000''falsefalse0falsefalsefalse);
  7213.                     //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  7214.                     //
  7215.                 }
  7216.             }
  7217.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  7218.             for ($i 0$i sizeof($tabtxt); $i++) {
  7219.                 $txt json_decode($tabtxt[$i]);
  7220.                 $fontSize floatval(str_replace('px'''$txt->fontSize)) * 0.75;
  7221.                 //$txt->rotation
  7222.                 $check explode(','$txt->fontFamily);
  7223.                 if (sizeof($check) > 1) {
  7224.                     //default
  7225.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 400)) {
  7226.                         $finalFont "helvetica";
  7227.                         $weight '';
  7228.                     }
  7229.                     //classique
  7230.                     if (($check[0] == "Georgia") && ($txt->fontWeight == 400)) {
  7231.                         $finalFont "times";
  7232.                         $weight '';
  7233.                     }
  7234.                     //creative
  7235.                     if (($check[0] == "-apple-system") && ($txt->fontWeight == 700)) {
  7236.                         $finalFont "helveticaB";
  7237.                         $weight '';
  7238.                     }
  7239.                     // manuscrite
  7240.                     if (($check[0] == "Comic Sans") && ($txt->fontWeight == 400)) {
  7241.                         $finalFont "Courier";
  7242.                         $weight '';
  7243.                     }
  7244.                     //c.s-microsoft.com/static/fonts/segoe-ui/west-european/light/latest.woff2
  7245.                 } else {
  7246.                     //baton
  7247.                     if (($txt->fontFamily == 'Impact') && ($txt->fontWeight == 400)) {
  7248.                         $finalFont "helveticaB";
  7249.                         $weight 'B';
  7250.                     }
  7251.                 }
  7252.                 $pdf->SetFont($finalFont$weight$fontSize);
  7253.                 $leftTxt $txt->left;
  7254.                 $topTxt $txt->top;
  7255.                 $heightClips $txt->height;
  7256.                 $widthClips $txt->width;
  7257.                 $heightTxt floatval(str_replace('cm'''$heightClips));
  7258.                 $topTxt floatval(str_replace('cm'''$topTxt));
  7259.                 $leftTxt floatval(str_replace('cm'''$leftTxt));
  7260.                 $widthTxt floatval(str_replace('cm'''$widthClips));
  7261.                 if ($key == 0) {
  7262.                     $heightTxt 2;
  7263.                     $widthTxt 7;
  7264.                     $leftTxt = (21) - ($widthTxt 2);
  7265.                     $topTxt 11.8;
  7266.                     $pdf->SetXY(0$topTxttrue);
  7267.                     $pdf->Cell(210trim($txt->contenu), 00'C'0''0);
  7268.                 } else {
  7269.                     $heightTxt 2;
  7270.                     $widthTxt 7;
  7271.                     $leftTxt = (21) - ($widthTxt 2);
  7272.                     $topTxt 11.8;
  7273.                     $pdf->SetXY(13.612.4true);
  7274.                     $pdf->Cell(60trim($txt->contenu), 00'L'0''0);
  7275.                 }
  7276.                 //                    var_dump($leftTxt);
  7277.                 //                  var_dump($topTxt);
  7278.                 // var_dump(floatval(str_replace('rad','',$txt->rotation))*57,2958);
  7279.                 //                var_dump("text");
  7280.                 //$pdf->StartTransform();
  7281.                 //$txt->rotation=0;
  7282.                 //var_dump($txt->rotation);
  7283.                 //var_dump(str_replace('rad','',$txt->rotation));
  7284.                 //var_dump(floatval(str_replace('rad','',$txt->rotation))*57.2958);
  7285.                 // $pdf->Rotate((floatval(str_replace('rad','',$txt->rotation))*57.2958)*-1,$leftTxt+($widthTxt/2),$topTxt+($heightTxt/2));
  7286.                 // $pdf->Rotate(45);
  7287.                 //   $pdf->Text($leftTxt, $topTxt, $txt->contenu);
  7288.                 //$pdf->SetTextColor(200);
  7289.                 //$pdf->Text($leftTxt, $topTxt, $txt->contenu);
  7290.                 // $pdf->MultiCell($leftTxt, $topTxt,  $txt->contenu, 0, $ln=0, 'C', 0, '', 0, false, 'C', 'C');
  7291.                 //                $pdf->Write(str_replace('cm','',$txt->height),trim($txt->contenu));
  7292.                 // $pdf->writeHTML("<p>".$txt->contenu."</p>", true, false, false, false, '');
  7293.                 //$pdf->StopTransform();
  7294.             }
  7295.             //Positionner text
  7296.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  7297.             //Positionner clipart
  7298.             //            dd($tabClips);
  7299.             for ($i 0$i sizeof($tabClips); $i++) {
  7300.                 $Clips json_decode($tabClips[$i]);
  7301.                 $heightClips $Clips->height;
  7302.                 $topClips $Clips->top;
  7303.                 $leftClips $Clips->left;
  7304.                 $widthClips $Clips->width;
  7305.                 $path $Clips->path;
  7306.                 $pathClips str_replace('"'''$path);
  7307.                 $heightClips floatval(str_replace('cm'''$heightClips));
  7308.                 $topClips floatval(str_replace('cm'''$topClips));
  7309.                 $leftClips floatval(str_replace('cm'''$leftClips));
  7310.                 $widthClips floatval(str_replace('cm'''$widthClips));
  7311.                 $heightClipsPX round($heightClips 37.7952755906);
  7312.                 $widthClipsPX round($widthClips 37.7952755906);
  7313.                 ////                $positionXclips = $positionX + $leftClips;
  7314.                 ////                $positionYclips = $positionY + $topClips;
  7315.                 //
  7316.                 //$pdf->ImageSVG("images/ClipArt_SVG/Ete4.svg",$leftClips,$topClips,$widthClips, $heightClips);
  7317.                 //https://res.cloudinary.com/apss-factory/image/private/s--EdExAzx8--/v1588758453/GlobeFooter_c4duua.svg
  7318.                 // https://res.cloudinary.com/apss-factory/image/upload/v1588764528/Groupe_113_pcjyj4.png
  7319.                 var_dump($pathClips);
  7320.                 $pdf->StartTransform();
  7321.                 $pdf->Rotate((floatval(str_replace('rad'''$Clips->rotation)) * 57.2958) * -1$leftClips + ($widthClips 2), $topClips + ($heightClips 2));
  7322.                 $pdf->Image($this->newPAthCLipart($pathClips$heightClipsPX$widthClipsPX), $leftClips,  $topClips$widthClips$heightClips''''''false300);
  7323.                 $pdf->StopTransform();
  7324.             }
  7325.         }
  7326.         // echo '</pre>';
  7327.         //return new response("yezi");
  7328.         $projectRoot $this->getParameter('kernel.project_dir');
  7329.         $pdf->Output($projectRoot '/public/pdfDocs/example_' $idPrdt '.pdf''F');
  7330.         return new response("yezi");
  7331.         //return $pdf->Output('example_009.pdf', 'I');
  7332.     }
  7333.     function newPAthCLipart($url$heigh$width)
  7334.     {
  7335.         $allImage = [
  7336.             'Eclaire.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143379/newprod/clipart/Eclaire_pr0ecu.png',
  7337.             'ARcenciel.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143391/newprod/clipart/ARcenciel_grkyap.png',
  7338.             'Drapeaux.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Drapeaux_zqo8v3.png',
  7339.             'Annif.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143391/newprod/clipart/Annif_ihvyoo.png',
  7340.             'Basquettes.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Basquettes_znjd41.png',
  7341.             'Foot.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143382/newprod/clipart/Foot_az6bct.png',
  7342.             'Hello.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143383/newprod/clipart/Hello_njqifl.png',
  7343.             'Love.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143386/newprod/clipart/Love_q39usk.png',
  7344.             'LICORNE.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143385/newprod/clipart/LICORNE_hpomru.png',
  7345.             'Noeud.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143388/newprod/clipart/Noeud_mw5a4j.png',
  7346.             'Etoilerose.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143380/newprod/clipart/Etoilerose_ewrzff.png',
  7347.             'Ete4.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143379/newprod/clipart/Ete4_pdxadk.png',
  7348.             'Ete6.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143380/newprod/clipart/Ete6_a3xgpd.png',
  7349.             'Ete9.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143380/newprod/clipart/Ete9_s4vllm.png',
  7350.             'Hiver1.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143384/newprod/clipart/Hiver1_fekrjz.png',
  7351.             'Hiver2.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143384/newprod/clipart/Hiver2_e9iygg.png',
  7352.             'Noel2.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143387/newprod/clipart/Noel2_eqvdzr.png',
  7353.             'Hiver.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143383/newprod/clipart/Hiver_et04e1.png',
  7354.             'Sapin.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143390/newprod/clipart/Sapin_qjkxz6.png',
  7355.             'Chaussetet.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Chaussetet_xfpt6t.png',
  7356.             'Cloches.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143377/newprod/clipart/Cloches_x2v3eo.png',
  7357.             'Like.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143387/newprod/clipart/Like_ynxb2u.png',
  7358.             'coeurlike.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143379/newprod/clipart/coeurlike_ferv9y.png',
  7359.             'Fetedesmeres.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/w_' $width '/upload/v1589143383/newprod/clipart/Fetedesmeres_ud9vac.png',
  7360.             'Fetedesperes.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/w_' $width '/upload/v1589143384/newprod/clipart/Fetedesperes_mltjmo.png',
  7361.             'OOPS.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143389/newprod/clipart/OOPS_gj9p1c.png',
  7362.             'OOPS_1.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143389/newprod/clipart/OOPS_1_r9a7l6.png',
  7363.             'WoW.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143393/newprod/clipart/WoW_ljlqjm.png',
  7364.             'Nuage.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143387/newprod/clipart/Nuage_fgomd0.png',
  7365.             'Pingouin.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143389/newprod/clipart/Pingouin_ogxb6e.png',
  7366.             'Renard.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143378/newprod/clipart/Chouette_mc1ik2.png',
  7367.             'Chouette.svg' => 'https://res.cloudinary.com/af5sur5sejour/image/upload/w_' $width '/v1589143390/newprod/clipart/Renard_mlhrxt.png'
  7368.         ];
  7369.         //http://127.0.0.1:8000/images/ClipArt_SVG/LICORNE.svg
  7370.         $arryUrls explode('/'$url);
  7371.         return ($allImage[$arryUrls[sizeof($arryUrls) - 1]]);
  7372.     }
  7373.     /**
  7374.      * @Route("/Parent/TcPdfCalcul/{idPrdt}", name="TcPdfCalc")
  7375.      */
  7376.     public function TcPdfCalcule($idPrdt)
  7377.     {
  7378.         echo '<pre>';
  7379.         ini_set("max_execution_time", -1);
  7380.         $pageLayout = array(2115);
  7381.         $pdf $this->get("white_october.tcpdf")->create('L''CM'$pageLayouttrue'UTF-8'false);
  7382.         // set document information
  7383.         $pdf->SetCreator(PDF_CREATOR);
  7384.         $pdf->SetAuthor('Nicola Asuni');
  7385.         $pdf->SetTitle('TCPDF Example 009');
  7386.         $pdf->SetSubject('TCPDF Tutorial');
  7387.         $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
  7388.         $pdf->SetSubject('TCPDF Tutorial');
  7389.         $pdf->setPrintHeader(false);
  7390.         $pdf->setPrintFooter(false);
  7391.         // set image scale factor
  7392.         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  7393.         //        $pdf->AddPage();
  7394.         $pdf->setJPEGQuality(100);
  7395.         $horizontal_alignments = array('L''C''R');
  7396.         $vertical_alignments = array('T''M''B');
  7397.         //var_dump($pdf->getPageWidth());
  7398.         //var_dump($pdf->getPageHeight());die();
  7399.         $em $this->em;
  7400.         $Album $em->getRepository(Produit::class)->findOneBy(['id' => $idPrdt]);
  7401.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Album]);
  7402.         //dd($AllPages);
  7403.         //        $fP=[];
  7404.         //        array_push($fP,$AllPages[0]);
  7405.         //dd($AllPages);
  7406.         foreach ($AllPages as $p) {
  7407.             $pdf->AddPage();
  7408.             $pdf->setJPEGQuality(100);
  7409.             $contenu json_decode(json_decode($p->getCouleurbordure())[0]);
  7410.             $nbatach $contenu->nbrAttc;
  7411.             $nbatach intval(str_replace('"'''$nbatach));
  7412.             $color =  $contenu->color;
  7413.             // $color="rgb(255,255,255)";
  7414.             $color str_replace('"rgb('''$color);
  7415.             $color str_replace(')"'''$color);
  7416.             $color explode(","$color);
  7417.             $colorp = array(intval($color[0]), intval($color[1]), intval($color[2]));
  7418.             $tabtxt json_decode($contenu->txt);
  7419.             $tabphoto json_decode($contenu->attache);
  7420.             //
  7421.             //dd($tabtxt);
  7422.             //         dd($tabtxt);
  7423.             //dd($tabphoto);
  7424.             $tabClips json_decode($contenu->clips);
  7425.             // dd($tabClips);
  7426.             $x 0.6;
  7427.             $y 0.8;
  7428.             $w 19.8;
  7429.             $h 13.4;
  7430.             // get the current page break margin
  7431.             $bMargin $pdf->getBreakMargin();
  7432.             // get current auto-page-break mode
  7433.             $auto_page_break $pdf->getAutoPageBreak();
  7434.             // disable auto-page-break
  7435.             $pdf->SetAutoPageBreak(false0);
  7436.             // test all combinations of alignments
  7437.             $fitbox $horizontal_alignments[1] . ' ';
  7438.             $fitbox[1] = $vertical_alignments[1];
  7439.             $pdf->Rect(002115'F', array(), $colorp);
  7440.             //    sizeof($tabphoto)
  7441.             for ($i 0$i sizeof($tabphoto); $i++) {
  7442.                 $photo json_decode($tabphoto[$i]);
  7443.                 //les coordonnées de l'image réel:
  7444.                 $hght $photo->height;
  7445.                 $top $photo->top;
  7446.                 $left $photo->left;
  7447.                 $width $photo->width;
  7448.                 $ordre $photo->ordre;
  7449.                 $zoom $photo->zoom;
  7450.                 $path $photo->path;
  7451.                 $hght floatval(str_replace('cm'''$hght));
  7452.                 $top floatval(str_replace('cm'''$top));
  7453.                 $left floatval(str_replace('cm'''$left));
  7454.                 $width floatval(str_replace('cm'''$width));
  7455.                 //les coordonnées dropzone:
  7456.                 $heightOriginal $photo->height;
  7457.                 $widthOriginal $photo->width;
  7458.                 $top $photo->top;
  7459.                 $left $photo->left;
  7460.                 $heightOriginal floatval(str_replace('cm'''$heightOriginal));
  7461.                 $widthOriginal floatval(str_replace('cm'''$widthOriginal));
  7462.                 $top floatval(str_replace('cm'''$top));
  7463.                 $left floatval(str_replace('cm'''$left));
  7464.                 $heightOriginal $heightOriginal 37.7952755906;
  7465.                 $widthOriginal $widthOriginal 37.7952755906;
  7466.                 $topOriginal $top 37.7952755906;
  7467.                 $leftOriginal $left 37.7952755906;
  7468.                 $heightCrop $photo->heightCrop;
  7469.                 $topCrop $photo->topCrop;
  7470.                 $leftCrop $photo->leftCrop;
  7471.                 $widthCrop $photo->widthCrop;
  7472.                 $path $photo->path;
  7473.                 $heightCrop floatval(str_replace('cm'''$heightCrop));
  7474.                 $topCrop floatval(str_replace('cm'''$topCrop));
  7475.                 $leftCrop floatval(str_replace('cm'''$leftCrop));
  7476.                 $widthCrop floatval(str_replace('cm'''$widthCrop));
  7477.                 $widthCropPX $widthCrop 37.7952755906;
  7478.                 $heightCropPX $heightCrop 37.7952755906;
  7479.                 $topCropPX $topCrop 37.7952755906;
  7480.                 $leftCropPX $leftCrop 37.7952755906;
  7481.                 var_dump("original widh: " $widthCrop " " "original height : " $heightCrop);
  7482.                 var_dump("original left: " $topCrop " " "original top : " $leftCrop);
  7483.                 var_dump("//00");
  7484.                 var_dump("multip 37 widh: " $widthCropPX " " "multip 37 height : " $heightCropPX);
  7485.                 var_dump("multip 37 top: " $topOriginal " " "multip 37 left : " $leftOriginal);
  7486.                 //Calculer position des images selon nombres images par page:
  7487.                 $positionX 0;
  7488.                 $positionY 0;
  7489.                 $widthImg 0;
  7490.                 $heightImg 0;
  7491.                 if ($nbatach == 1) {
  7492.                     $positionX 1.5;
  7493.                     $positionY 1.5;
  7494.                     $widthImg 18;
  7495.                     $heightImg 12;
  7496.                 } elseif ($nbatach == 2) {
  7497.                     if ($ordre == 1) {
  7498.                         $positionX 1.5;
  7499.                         $positionY 1.5;
  7500.                         $widthImg 8.5;
  7501.                         $heightImg 12;
  7502.                     }
  7503.                     if ($ordre == 2) {
  7504.                         $positionX 11;
  7505.                         $positionY 1.5;
  7506.                         $widthImg 8.5;
  7507.                         $heightImg 12;
  7508.                     }
  7509.                 } elseif ($nbatach == 3) {
  7510.                     if ($ordre == 1) {
  7511.                         $positionX 1.5;
  7512.                         $positionY 1.5;
  7513.                         $widthImg 8.5;
  7514.                         $heightImg 12;
  7515.                     }
  7516.                     if ($ordre == 2) {
  7517.                         $positionX 11;
  7518.                         $positionY 1.5;
  7519.                         $widthImg 8.5;
  7520.                         $heightImg 5.5;
  7521.                     }
  7522.                     if ($ordre == 3) {
  7523.                         $positionX 11;
  7524.                         $positionY 8;
  7525.                         $widthImg 8.5;
  7526.                         $heightImg 5.5;
  7527.                     }
  7528.                 } elseif ($nbatach == 4) {
  7529.                     if ($ordre == 1) {
  7530.                         $positionX 1.5;
  7531.                         $positionY 1.5;
  7532.                         $widthImg 8.5;
  7533.                         $heightImg 5.5;
  7534.                     }
  7535.                     if ($ordre == 2) {
  7536.                         $positionX 1.5;
  7537.                         $positionY 8;
  7538.                         $widthImg 8.5;
  7539.                         $heightImg 5.5;
  7540.                     }
  7541.                     if ($ordre == 3) {
  7542.                         $positionX 11;
  7543.                         $positionY 1.5;
  7544.                         $widthImg 8.5;
  7545.                         $heightImg 5.5;
  7546.                     }
  7547.                     if ($ordre == 4) {
  7548.                         $positionX 11;
  7549.                         $positionY 8;
  7550.                         $widthImg 8.5;
  7551.                         $heightImg 5.5;
  7552.                     }
  7553.                 } elseif ($nbatach == 5) {
  7554.                     if ($ordre == 1) {
  7555.                         $positionX 1.5;
  7556.                         $positionY 1.5;
  7557.                         $widthImg 18;
  7558.                         $heightImg 8;
  7559.                     }
  7560.                     if ($ordre == 2) {
  7561.                         $positionX 1.5;
  7562.                         $positionY 10.5;
  7563.                         $widthImg 3.75;
  7564.                         $heightImg 4;
  7565.                     }
  7566.                     if ($ordre == 3) {
  7567.                         $positionX 6.25;
  7568.                         $positionY 10.5;
  7569.                         $widthImg 3.75;
  7570.                         $heightImg 4;
  7571.                     }
  7572.                     if ($ordre == 4) {
  7573.                         $positionX 11;
  7574.                         $positionY 10.5;
  7575.                         $widthImg 3.75;
  7576.                         $heightImg 4;
  7577.                     }
  7578.                     if ($ordre == 5) {
  7579.                         $positionX 15.75;
  7580.                         $positionY 10.5;
  7581.                         $widthImg 3.75;
  7582.                         $heightImg 4;
  7583.                     }
  7584.                 } elseif ($nbatach == 6) {
  7585.                     if ($ordre == 1) {
  7586.                         $positionX 1.5;
  7587.                         $positionY 1.5;
  7588.                         $widthImg 5.33;
  7589.                         $heightImg 3.33;
  7590.                     }
  7591.                     if ($ordre == 2) {
  7592.                         $positionX 1.5;
  7593.                         $positionY 5.83;
  7594.                         $widthImg == 5.33;
  7595.                         $heightImg 3.33;
  7596.                     }
  7597.                     if ($ordre == 3) {
  7598.                         $positionX 1.5;
  7599.                         $positionY 10.16;
  7600.                         $widthImg 5.33;
  7601.                         $heightImg 3.33;
  7602.                     }
  7603.                     if ($ordre == 4) {
  7604.                         $positionX 7.83;
  7605.                         $positionY 1.5;
  7606.                         $widthImg == 5.33;
  7607.                         $heightImg 3.33;
  7608.                     }
  7609.                     if ($ordre == 5) {
  7610.                         $positionX 7.83;
  7611.                         $positionY 5.83;
  7612.                         $widthImg == 5.33;
  7613.                         $heightImg 3.33;
  7614.                     }
  7615.                     if ($ordre == 6) {
  7616.                         $positionX 7.83;
  7617.                         $positionY 10.16;
  7618.                         $widthImg == 5.33;
  7619.                         $heightImg 3.33;
  7620.                     }
  7621.                 } elseif ($nbatach == 12) {
  7622.                     if ($ordre == 1) {
  7623.                         $positionX 1.5;
  7624.                         $positionY 1.5;
  7625.                         $widthImg 3.75;
  7626.                         $heightImg 3.33;
  7627.                     }
  7628.                     if ($ordre == 2) {
  7629.                         $positionX 1.5;
  7630.                         $positionY 5.83;
  7631.                         $widthImg 3.75;
  7632.                         $heightImg 3.33;
  7633.                     }
  7634.                     if ($ordre == 3) {
  7635.                         $positionX 1.5;
  7636.                         $positionY 10.16;
  7637.                         $widthImg 3.75;
  7638.                         $heightImg 3.33;
  7639.                     }
  7640.                     if ($ordre == 4) {
  7641.                         $positionX 6.25;
  7642.                         $positionY 1.5;
  7643.                         $widthImg 3.75;
  7644.                         $heightImg 3.33;
  7645.                     }
  7646.                     if ($ordre == 5) {
  7647.                         $positionX 6.25;
  7648.                         $positionY 5.83;
  7649.                         $widthImg 3.75;
  7650.                         $heightImg 3.33;
  7651.                     }
  7652.                     if ($ordre == 6) {
  7653.                         $positionX 6.25;
  7654.                         $positionY 10.16;
  7655.                         $widthImg 3.75;
  7656.                         $heightImg 3.33;
  7657.                     }
  7658.                     if ($ordre == 7) {
  7659.                         $positionX 11;
  7660.                         $positionY 1.5;
  7661.                         $widthImg 3.75;
  7662.                         $heightImg 3.33;
  7663.                     }
  7664.                     if ($ordre == 8) {
  7665.                         $positionX 11;
  7666.                         $positionY 5.83;
  7667.                         $widthImg 3.75;
  7668.                         $heightImg 3.33;
  7669.                     }
  7670.                     if ($ordre == 9) {
  7671.                         $positionX 11;
  7672.                         $positionY 10.16;
  7673.                         $widthImg 3.75;
  7674.                         $heightImg 3.33;
  7675.                     }
  7676.                     if ($ordre == 10) {
  7677.                         $positionX 15.75;
  7678.                         $positionY 1.5;
  7679.                         $widthImg 3.75;
  7680.                         $heightImg 3.33;
  7681.                     }
  7682.                     if ($ordre == 11) {
  7683.                         $positionX 15.75;
  7684.                         $positionY 5.83;
  7685.                         $widthImg 3.75;
  7686.                         $heightImg 3.33;
  7687.                     }
  7688.                     if ($ordre == 12) {
  7689.                         $positionX 15.75;
  7690.                         $positionY 10.16;
  7691.                         $widthImg 3.75;
  7692.                         $heightImg 3.33;
  7693.                     }
  7694.                 }
  7695.                 //Recarder l'image :
  7696.                 // $path=str_replace( 'upload/', 'upload/ar_1.1'.',c_crop/q_auto:good/',$path);<
  7697.                 //                $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);
  7698.                 $path str_replace("l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled,"''$path);
  7699.                 //var_dump($api);
  7700.                 $pathArray explode("/"$path);
  7701.                 $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  7702.                 $idImage "";
  7703.                 foreach ($idsArray as $key2 => $elem) {
  7704.                     if ($key2 != (sizeof($idsArray) - 1)) {
  7705.                         $idImage $idImage $elem;
  7706.                     }
  7707.                 }
  7708.                 $idImage 'newprod/' $idImage;
  7709.                 var_dump($idImage);
  7710.                 Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  7711.                 $headers = array('Accept' => 'application/json');
  7712.                 $data = array("public_ids" => array($idImage));
  7713.                 $body Unirest\Request\Body::form($data);
  7714.                 Unirest\Request::verifyPeer(false);
  7715.                 $url 'https://api.cloudinary.com/v1_1/apss-factory/resources/image/upload/' $idImage;
  7716.                 // $resultMetadata=  \Cloudinary::Api.resources_by_ids([$idImage]);
  7717.                 var_dump($url);
  7718.                 $resultMetadata Unirest\Request::post($url$headers$body);
  7719.                 var_dump($resultMetadata->raw_body);
  7720.                 if (isset(json_decode($resultMetadata->raw_body)->width)) {
  7721.                     $cloudinaryWidht json_decode($resultMetadata->raw_body)->width;
  7722.                     $cloudinaryHeight json_decode($resultMetadata->raw_body)->height;
  7723.                 } else {
  7724.                     $cloudinaryWidht $widthOriginal;
  7725.                     $cloudinaryHeight $heightOriginal;
  7726.                 }
  7727.                 $ratiohight $cloudinaryWidht $widthOriginal;
  7728.                 $ratioHight $cloudinaryHeight $heightOriginal;
  7729.                 $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);
  7730.                 //var_dump($path);i
  7731.                 var_dump("//00");
  7732.                 var_dump("avant 1.4 widh: " round($widthCropPX) . " " "avant 1.4 height : " round($heightCropPX));
  7733.                 var_dump("avant 1.4 top: " round(abs($top 37.7952755906)) . " avant 1.4 final left : " round(abs($left 37.7952755906)));
  7734.                 var_dump("//00");
  7735.                 var_dump("final widh: " round($widthCropPX 1.4) . " " "final height : " round($heightCropPX 1.4));
  7736.                 var_dump("final top: " round(abs($top 37.7952755906 1.4)) . " " "final left : " round(abs($left 37.7952755906 1.4)));
  7737.                 var_dump("//00");
  7738.                 var_dump($path);
  7739.                 // $path="https://res.cloudinary.com/apss-factory/image/upload/w_691,h_356,c_crop/a_exif/v1587482806/newprod/crepes-au-chocolat_re9wvk.jpg";
  7740.                 $pdf->Image($path$positionX$positionY$widthImg$heightImg'JPG'''''false300''falsefalse0$fitboxfalsefalse);
  7741.                 //                $pdf->Rect($positionX,$positionY ,$widthImg, $heightImg, 'F', array(), array(264,200,67));
  7742.                 //
  7743.                 $pdf->SetY(-6);
  7744.                 // Set font
  7745.                 $pdf->SetFont('helvetica''I'8);
  7746.                 // Page number
  7747.                 $pdf->Cell(010'Page ' $pdf->getAliasNumPage() . '/' $pdf->getAliasNbPages(), 0false'C'0''0false'T''M');
  7748.                 $pdf->SetFont('helvetica''B'8);
  7749.                 $pdf->SetXY(11);
  7750.             }
  7751.             //    $pdf->Image('https://demo.appsfactor.fr/images/ClipArt_SVG/Etoilerose.svg',3,  2, 19, 13, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  7752.             for ($i 0$i sizeof($tabtxt); $i++) {
  7753.                 $txt json_decode($tabtxt[$i]);
  7754.                 $pdf->SetFont('helvetica''B'$txt->fontSize);
  7755.                 $leftTxt $txt->left;
  7756.                 $topTxt $txt->top;
  7757.                 //                $heightClips = floatval(str_replace('cm', '', $heightClips));
  7758.                 $topTxt floatval(str_replace('cm'''$topTxt));
  7759.                 $leftTxt floatval(str_replace('cm'''$leftTxt));
  7760.                 //                $widthClips = floatval(str_replace('cm', '', $widthClips));
  7761.                 $pdf->SetXY($leftTxt 1.2$topTxt 1);
  7762.                 $pdf->Write(0$txt->contenu''0'L'true0falsefalse0);
  7763.             }
  7764.             //Positionner text
  7765.             //            $pdf->ImageSVG("C:\\Users\\AppsFactor12\\Desktop\\5sur5\\5sur5Sejour\\public\\images\\ClipArt_SVG\\Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  7766.             //Positionner clipart
  7767.             //            dd($tabClips);
  7768.             //            for($i=0;$i <sizeof($tabClips);$i++) {
  7769.             //                $Clips = json_decode($tabClips[$i]);
  7770.             //                $heightClips = $Clips->height;
  7771.             //                $topClips = $Clips->top;
  7772.             //                $leftClips = $Clips->left;
  7773.             //                $widthClips = $Clips->width;
  7774.             //                $path = $Clips->path;
  7775.             //                $pathClips = str_replace('http://127.0.0.1:8000/', 'https://demo.appsfactor.fr/', $path);
  7776.             //
  7777.             //                $heightClips = floatval(str_replace('cm', '', $heightClips));
  7778.             //                $topClips = floatval(str_replace('cm', '', $topClips));
  7779.             //                $leftClips = floatval(str_replace('cm', '', $leftClips));
  7780.             //                $widthClips = floatval(str_replace('cm', '', $widthClips));
  7781.             //
  7782.             ////                $positionXclips = $positionX + $leftClips;
  7783.             ////                $positionYclips = $positionY + $topClips;
  7784.             //
  7785.             //              $pdf->ImageSVG("images/ClipArt_SVG/Etoilerose.svg",100,200,500, 500, '', '', '', 0, false);
  7786.             //
  7787.             ////                $pdf->Image($path,$leftClips,  $topClips, $widthClips, $heightClips, 'SVG', '', '', false, 300, '', false, false, 0, $fitbox, false, false);
  7788.             //
  7789.             //            }
  7790.         }
  7791.         echo '</pre>';
  7792.         return new response("yezi");
  7793.         //  return $pdf->Output('example_009.pdf', 'I');
  7794.     }
  7795.     /**
  7796.      * @Route("/Parent/suprimerproduitAcompa", name="suprimerproduitAcompa_parent")
  7797.      */
  7798.     public function suprimerproduitAcompa(Request $request)
  7799.     {
  7800.         $em $this->em;
  7801.         $user $this->getUser();
  7802.         $p $request->get("p");
  7803.         $Album $em->getRepository(Produit::class)->find($p);
  7804.         $Album->setDelated(1);
  7805.         $em->getManager()->persist($Album);
  7806.         $em->getManager()->flush();
  7807.         return new Response('yoopi');
  7808.     }
  7809.     /**
  7810.      * @Route("/Parent/saveDiaporamaParent", name="saveDiaporamaParent")
  7811.      */
  7812.     public function saveDiaporamaParent()
  7813.     {
  7814.         $session $this->session;
  7815.         $idSejour $session->get("Sejour");
  7816.         /** @var \App\Entity\User $userId */
  7817.         $userId $this->getUser();
  7818.         $sejourobj $this->em->getRepository(Sejour::class)->find($idSejour);
  7819.         $prodct $this->em->getRepository(Typeproduit::class)->find(19);
  7820.         $produit $this->em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $userId->getId()]);
  7821.         if ($produit !== null && $produit !== "") {
  7822.             $produit->setLabele("Diaporama");
  7823.             $produit->setIduser($userId);
  7824.             $produit->setIdsjour($sejourobj);
  7825.             $produit->setType($prodct);
  7826.         } else {
  7827.             $produit = new Produit;
  7828.             $produit->setLabele("Diaporama");
  7829.             $produit->setIduser($userId);
  7830.             $produit->setIdsjour($sejourobj);
  7831.             $produit->setType($prodct);
  7832.             $produit->setDate(new \DateTime());
  7833.         }
  7834.         $this->em->getManager()->persist($produit);
  7835.         $this->em->getManager()->flush();
  7836.         return new Response('disporama saved');
  7837.     }
  7838.     /**
  7839.      * @Route("/Parent/appActiveAcompt/{id}", name="appActiveAcompt")
  7840.      */
  7841.     public function ActiveAcounnt($id)
  7842.     {
  7843.         $user $this->em->getRepository(User::class)->find($id);
  7844.         $user->setActivatemail(1);
  7845.         $this->em->getManager()->persist($user);
  7846.         $this->em->getManager()->flush();
  7847.         // AUTO-LOGIN DIRECT (même implémentation que les accompagnateurs)
  7848.         $providerKey 'main_Parent'// your firewall name
  7849.         $token = new UsernamePasswordToken($usernull$providerKey$user->getRoles());
  7850.         $this->container->get('security.token_storage')->setToken($token);
  7851.         return $this->redirectToRoute('CodeSejour');
  7852.     }
  7853.     /**
  7854.      * @Route("/Parent/Album_du_Sejour", name="Album_du_Sejour")
  7855.      */
  7856.     function ActiverSessionAlbum()
  7857.     {
  7858.         $SEjourService $this->sejourService;
  7859.         /** @var \App\Entity\User $user */
  7860.         $user $this->getUser();
  7861.         $userId $user->getId();
  7862.         $session $this->session;
  7863.         $session->set('pageMenu''');
  7864.         $idSejour $session->get("Sejour");
  7865.         $sejour $SEjourService->getsejourpourparent($idSejour);
  7866.         $em $this->em;
  7867.         $AllPages null;
  7868.         $random false;
  7869.         $idAcc $sejour->getIdAcommp();
  7870.         $Albumproduct null;
  7871.         if ($idAcc !== null) {
  7872.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['idsjour' => $sejour'iduser' => $idAcc'statut' => 'Album_sejour'], ['id' => 'DESC']);
  7873.         }
  7874.         if ($Albumproduct === null) {
  7875.             $Albumproduct $this->em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour], ['id' => 'DESC']);
  7876.         }
  7877.         if ($Albumproduct === null) {
  7878.             $Albumproduct $this->em->getRepository(Produit::class)->findOneBy(['statut' => "Album_sejour"'idsjour' => $sejour], ['id' => 'DESC']);
  7879.         }
  7880.         if ($Albumproduct != null && $Albumproduct != "") {
  7881.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  7882.         }
  7883.         $allPagesDecoded = [];
  7884.         if ($AllPages) {
  7885.             foreach ($AllPages as $p) {
  7886.                 $dec json_decode($p->getCouleurbordure(), true);
  7887.                 $allPagesDecoded[] = \is_array($dec) ? $dec : (array) $dec;
  7888.             }
  7889.         }
  7890.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  7891.         $nbLikes count($listeattachlikephoto);
  7892.         if ($Albumproduct === null) {
  7893.             $this->addFlash('warning''Aucun album du séjour n\'est disponible pour l\'instant.');
  7894.             return $this->redirectToRoute('CodeSejour');
  7895.         }
  7896.         $session->set('produit'$Albumproduct->getType());
  7897.         // Load album data from pathpdf (new album builder JSON format)
  7898.         $existingAlbumData null;
  7899.         if ($Albumproduct->getPathpdf()) {
  7900.             $decodedData json_decode($Albumproduct->getPathpdf(), true);
  7901.             if ($decodedData && isset($decodedData['pages'])) {
  7902.                 $existingAlbumData $decodedData;
  7903.             }
  7904.         }
  7905.         $part $sejour->getIdPartenaire();
  7906.         $partnerName $part $part->getUsername() : '';
  7907.         $partnerLogo $part $part->getLogourl() : null;
  7908.         $sejourId = (int) $idSejour;
  7909.         // Format liked photos for template (same structure as albumBuilder)
  7910.         $likedPhotosFormatted = [];
  7911.         foreach ($listeattachlikephoto as $likePhoto) {
  7912.             $attachment $likePhoto->getIdSejourAttchment();
  7913.             if ($attachment) {
  7914.                 $likedPhotosFormatted[] = [
  7915.                     'id' => $attachment->getId(),
  7916.                     'path' => $this->getAttachmentPath($attachment),
  7917.                     'nom' => $this->getAttachmentName($attachment),
  7918.                 ];
  7919.             }
  7920.         }
  7921.         return $this->render('Parent/album_Sejour.html.twig', [
  7922.             'sejour' => $sejour,
  7923.             'sejourId' => $sejourId,
  7924.             'partnerName' => $partnerName,
  7925.             'partnerLogo' => $partnerLogo,
  7926.             'likedPhotos' => $likedPhotosFormatted,
  7927.             'like' => $listeattachlikephoto,
  7928.             'nbLikes' => $nbLikes,
  7929.             'existingAlbum' => $Albumproduct,
  7930.             'existingAlbumData' => $existingAlbumData,
  7931.             'mode' => 'view',
  7932.             'albumId' => $Albumproduct->getId(),
  7933.             'viewOnly' => true,
  7934.         ]);
  7935.     }
  7936.     /**
  7937.      * @Route("/Parent/Editer_Album_du_Sejour", name="Editer_Album_du_Sejour")
  7938.      */
  7939.     function EditerSessionAlbum()
  7940.     {
  7941.         $SEjourService $this->sejourService;
  7942.         /** @var \App\Entity\User $user */
  7943.         $user $this->getUser();
  7944.         $userId $user->getId();
  7945.         $session $this->session;
  7946.         $session->set('pageMenu''');
  7947.         $idSejour $session->get("Sejour");
  7948.         $sejour $SEjourService->getsejourpourparent($idSejour);
  7949.         $em $this->em;
  7950.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  7951.         $nbLikes count($listeattachlikephoto);
  7952.         $AllPages null;
  7953.         $random false;
  7954.         $idAcc $sejour->getIdAcommp();
  7955.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'Album_sejour']);
  7956.         if ($Albumproduct == null) {
  7957.             $Albumproduct $this->em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  7958.         }
  7959.         if ($Albumproduct != null and $Albumproduct != "") {
  7960.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  7961.         }
  7962.         $allpagesResult = array();
  7963.         $tabacc = array();
  7964.         $tabacc1 = array();
  7965.         foreach ($AllPages as $page) {
  7966.             $pageJ json_decode($page->getCouleurbordure());
  7967.             $pageDec json_decode($pageJ[0]);
  7968.             $attache json_decode($pageDec->attache);
  7969.             if (isset($attache[0])) {
  7970.                 $attachDec json_decode($attache[0]);
  7971.             }
  7972.             //var_dump($attachDec);
  7973.             //var_dump(json_decode($attachDec->id));
  7974.             if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  7975.                 $idAttach json_decode($attachDec->id);
  7976.                 array_push($tabacc$idAttach);
  7977.             }
  7978.         }
  7979.         $tabacc1 array_count_values($tabacc);
  7980.         $part $sejour->getIdPartenaire();
  7981.         $nompart $part->getUsername();
  7982.         $logopart $part->getLogourl();
  7983.         $session->set('produit'$Albumproduct->gettype());
  7984.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  7985.         $nbPhoto count($listeattach);
  7986.         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]);
  7987.     }
  7988.     /**
  7989.      * @Route("/Parent/Editer_Livre_du_Sejour", name="Editer_Livre_du_Sejour")
  7990.      */
  7991.     function EditerSessionLivre()
  7992.     {
  7993.         $SEjourService $this->sejourService;
  7994.         /** @var \App\Entity\User $user */
  7995.         $user $this->getUser();
  7996.         $userId $user->getId();
  7997.         $session $this->session;
  7998.         $session->set('pageMenu''');
  7999.         $idSejour $session->get("Sejour");
  8000.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8001.         $em $this->em;
  8002.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  8003.         $nbLikes count($listeattachlikephoto);
  8004.         $AllPages null;
  8005.         $random false;
  8006.         $idAcc $sejour->getIdAcommp();
  8007.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  8008.         if ($Albumproduct == null) {
  8009.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['version' => 'Livre_Sejour_Admin''idsjour' =>   $idSejour]);
  8010.         }
  8011.         if ($Albumproduct == null) {
  8012.             $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'randomLivre']);
  8013.         }
  8014.         if ($Albumproduct != null and $Albumproduct != "") {
  8015.             $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  8016.         }
  8017.         $allpagesResult = array();
  8018.         $tabacc = array();
  8019.         $tabacc1 = array();
  8020.         foreach ($AllPages as $page) {
  8021.             $pageJ json_decode($page->getCouleurbordure());
  8022.             $pageDec json_decode($pageJ[0]);
  8023.             $attache json_decode($pageDec->attache);
  8024.             if (isset($attache[0])) {
  8025.                 $attachDec json_decode($attache[0]);
  8026.             }
  8027.             //var_dump($attachDec);
  8028.             //var_dump(json_decode($attachDec->id));
  8029.             if (isset($attachDec->id) && json_decode($attachDec->id) !== null && $attachDec->id !== '') {
  8030.                 $idAttach json_decode($attachDec->id);
  8031.                 array_push($tabacc$idAttach);
  8032.             }
  8033.         }
  8034.         $tabacc1 array_count_values($tabacc);
  8035.         $part $sejour->getIdPartenaire();
  8036.         $nompart $part->getUsername();
  8037.         $logopart $part->getLogourl();
  8038.         $session->set('produit'$Albumproduct->gettype());
  8039.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  8040.         $nbPhoto count($listeattach);
  8041.         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]);
  8042.     }
  8043.     /**
  8044.      * @Route("/Parent/DesactiverSessionAlbum", name="DesactiverSessionAlbum")
  8045.      */
  8046.     function DesactiverSessionAlbum()
  8047.     {
  8048.         $session $this->session;
  8049.         $session->remove('sessionalbm');
  8050.         return new Response('session removed');
  8051.     }
  8052.     /**
  8053.      * @Route("/Parent/Mon_Compte_Activer", name="Mon_Compte_Activer")
  8054.      */
  8055.     public function Mon_Compte_Activer(Request $request)
  8056.     {
  8057.         $em $this->em;
  8058.         return $this->render('Parent/activeMoncompte.html.twig');
  8059.     }
  8060.     /**
  8061.      * @Route("/Parent/swuitchSejour/{id}", name="swuitchSejour")
  8062.      */
  8063.     public function swuitchSejour($id)
  8064.     {
  8065.         $em $this->em;
  8066.         $sejourobj $this->em->getRepository(Sejour::class)->find($id);
  8067.         $this->session->set('Sejour'$sejourobj->getId());
  8068.         return $this->redirectToRoute('AccueilParent');
  8069.     }
  8070.     /**
  8071.      * @Route("/migrationCloudinary", name="migrationCloudinary")
  8072.      */
  8073.     public function cloudinaryMigration()
  8074.     {
  8075.         $em $this->em;
  8076.         //        $path="https://res.cloudinary.com/apss-factory/image/upload/a_exif/v1588979564/newprod/JUEGOS-EN-LA-PLAYA5_dnvgj8.jpg";
  8077.         $attachement = [
  8078.             'Eclaire.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/Eclaire_pr0ecu.svg',
  8079.             'ARcenciel.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143391/newprod/clipart/ARcenciel_grkyap.svg',
  8080.             'Drapeaux.svg' => 'https://res.cloudinary.com/apss-factory/image/uploadv/1589143377/newprod/clipart/Drapeaux_zqo8v3.svg',
  8081.             'Annif.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143391/newprod/clipart/Annif_ihvyoo.svg',
  8082.             'Basquettes.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Basquettes_znjd41.svg',
  8083.             'Foot.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143382/newprod/clipart/Foot_az6bct.svg',
  8084.             'Hello.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Hello_njqifl.svg',
  8085.             'Love.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143386/newprod/clipart/Love_q39usk.svg',
  8086.             'LICORNE.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143385/newprod/clipart/LICORNE_hpomru.svg',
  8087.             'Noeud.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143388/newprod/clipart/Noeud_mw5a4j.svg',
  8088.             'Etoilerose.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Etoilerose_ewrzff.svg',
  8089.             'Ete4.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/Ete4_pdxadk.svg',
  8090.             'Ete6.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Ete6_a3xgpd.svg',
  8091.             'Ete9.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143380/newprod/clipart/Ete9_s4vllm.svg',
  8092.             'Hiver1.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Hiver1_fekrjz.svg',
  8093.             'Hiver2.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Hiver2_e9iygg.svg',
  8094.             'Noel2.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Noel2_eqvdzr.svg',
  8095.             'Hiver.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Hiver_et04e1.svg',
  8096.             'Sapin.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143390/newprod/clipart/Sapin_qjkxz6.svg',
  8097.             'Chaussetet.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Chaussetet_xfpt6t.svg',
  8098.             'Cloches.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143377/newprod/clipart/Cloches_x2v3eo.svg',
  8099.             'Like.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Like_ynxb2u.svg',
  8100.             'coeurlike.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143379/newprod/clipart/coeurlike_ferv9y.svg',
  8101.             'Fetedesmeres.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143383/newprod/clipart/Fetedesmeres_ud9vac.svg',
  8102.             'Fetedesperes.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143384/newprod/clipart/Fetedesperes_mltjmo.svg',
  8103.             'OOPS.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/OOPS_gj9p1c.svg',
  8104.             'OOPS_1.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/OOPS_1_r9a7l6.svg',
  8105.             'WoW.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143393/newprod/clipart/WoW_ljlqjm.svg',
  8106.             'Nuage.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143387/newprod/clipart/Nuage_fgomd0.svg',
  8107.             'Pingouin.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143389/newprod/clipart/Pingouin_ogxb6e.svg',
  8108.             'Renard.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143378/newprod/clipart/Chouette_mc1ik2.svg',
  8109.             'Chouette.svg' => 'https://res.cloudinary.com/apss-factory/image/upload/v1589143390/newprod/clipart/Renard_mlhrxt.svg'
  8110.         ];
  8111.         foreach ($attachement as $at) {
  8112.             $exif false;
  8113.             $path $at;
  8114.             $pathArray explode("/"$path);
  8115.             $idsArray explode("."$pathArray[sizeof($pathArray) - 1]);
  8116.             $idImage "";
  8117.             foreach ($idsArray as $key2 => $elem) {
  8118.                 if ($key2 != (sizeof($idsArray) - 1)) {
  8119.                     $idImage $idImage $elem;
  8120.                 }
  8121.             }
  8122.             $idImage 'clipart/' $idImage;
  8123.             \Cloudinary::config(array(
  8124.                 "cloud_name" => "af5sur5sejour",
  8125.                 "api_key" => "263346742199243",
  8126.                 "api_secret" => "jYw-jg0FOJGv89-o5Wo0Fa3rQWU",
  8127.                 "secure" => true
  8128.             ));
  8129.             Unirest\Request::auth('263346742199243''jYw-jg0FOJGv89-o5Wo0Fa3rQWU');
  8130.             Unirest\Request::verifyPeer(false);
  8131.             $url 'https://api.cloudinary.com/v1_1/af5sur5sejour/image/upload';
  8132.             $headers = array('Accept' => 'application/json');
  8133.             $data = array("file" => $path"public_id" => $idImage"upload_preset" => 'ml_default');
  8134.             $body Unirest\Request\Body::form($data);
  8135.             $resultMetadata Unirest\Request::post($url$headers$body);
  8136.             var_dump($resultMetadata);
  8137.             if (isset(json_decode($resultMetadata->raw_body)->secure_url)) {
  8138.                 var_dump(json_decode($resultMetadata->raw_body)->secure_url);
  8139.             }
  8140.         }
  8141.         $em->getManager()->flush();
  8142.         return new response("done");
  8143.     }
  8144.     /**
  8145.      * @Route("/Parent/virgoPAss", name="virgopass")
  8146.      */
  8147.     public function virgopass()
  8148.     {
  8149.         return $this->render('Parent/virgo.html.twig');
  8150.     }
  8151.     /**
  8152.      * @Route("/Parent/interfaceUpdatePassorwdParent", name="interfaceUpdatePassorwdParent")
  8153.      */
  8154.     public function interfaceUpdatePassorwdParent(Request $request)
  8155.     {
  8156.         $user $this->getUser();
  8157.         return $this->render('Parent/interfaceUpdatePassorwdParent.html.twig', ["userToSetPassword" => $user]);
  8158.     }
  8159.     /**
  8160.      * @Route("/Parent/updatePassorwdParent", name="updatePassorwd_parent")
  8161.      */
  8162.     public function updatePassorwdParent(Request $request)
  8163.     {
  8164.         $em $this->em;
  8165.         $serviceuser $this->userService;
  8166.         $id $request->get("userID");
  8167.         $password $request->get("password");
  8168.         $result $serviceuser->ModifierPwdParent($id$password);
  8169.         return new Response('pwd modifié');
  8170.     }
  8171.     /**
  8172.      * @Route("/Parent/sauthentifierAuto/{token}/{idUser}/{userHash}",name="sauthentifierAuto")
  8173.      */
  8174.     function sauthentifierAuto($token$idUser$userHash)
  8175.     {
  8176.         $parent $this->em->getRepository(User::class)->find($idUser);
  8177.         if ((hash("sha256"$parent->getUsername() . $parent->getId()) == $userHash)) {
  8178.             $providerKey 'main_Parent'// your firewall name
  8179.             $token = new UsernamePasswordToken($parentnull$providerKey$parent->getRoles());
  8180.             $this->container->get('security.token_storage')->setToken($token);
  8181.             return $this->redirectToRoute("CodeSejour");
  8182.         } else {
  8183.             return $this->redirectToRoute("app_back_Parent");
  8184.         }
  8185.     }
  8186.     /**
  8187.      * @Route("/loginAutotoAlbumAcco/{token}/{idUser}/{userHash}/{albumAcco}",name="loginAutotoAlbumAcco")
  8188.      */
  8189.     function loginAutotoAlbumAcco($token$idUser$userHash$albumAcco)
  8190.     {
  8191.         $parent $this->em->getRepository(User::class)->find($idUser);
  8192.         if ((hash("sha256"$parent->getUsername() . $parent->getId()) == $userHash)) {
  8193.             //            return $this->render('security/DemandePasswordParentv.html.twig', ["userToSetPassword" => $use
  8194.             //dd('im herge');             
  8195.             $providerKey 'main_Parent'// your firewall name
  8196.             $token = new UsernamePasswordToken($parentnull$providerKey$parent->getRoles());
  8197.             //dd($token);  
  8198.             $this->container->get('security.token_storage')->setToken($token);
  8199.             $session $this->session;
  8200.             $produit $this->em->getRepository(Produit::class)->find($albumAcco);
  8201.             // dd($produit->getIdsjour()->getId());    
  8202.             $session->set("Sejour"$produit->getIdsjour()->getId());
  8203.             return $this->redirectToRoute("ActiverSessionAlbum");
  8204.         } else {
  8205.             return $this->redirectToRoute("app_back_Parent");
  8206.         }
  8207.     }
  8208.     /**
  8209.      * @Route("/Parent/respondNotifSms",name="respondNotifSms")
  8210.      */
  8211.     function respondNotifSms(Request $request)
  8212.     {
  8213.         $resp $request->get("resp");
  8214.         /** @var \App\Entity\User $user */
  8215.         $user $this->getUser();
  8216.         $user->setSmsnotif($resp);
  8217.         $this->em->getManager()->persist($user);
  8218.         $parentsejour $this->em->getRepository(ParentSejour::class)->findBy(['idParent' => $user]);
  8219.         foreach ($parentsejour as $sejr) {
  8220.             $sejr->setSmsnotif($resp);
  8221.             if (strpos($sejr->getIdSejour()->getCodeSejour(), "EF") !== false) {
  8222.                 $sejr->setSmsnotif(0);
  8223.             }
  8224.             $this->em->getManager()->persist($sejr);
  8225.         }
  8226.         $this->em->getManager()->flush();
  8227.         return new Response('smsnotifmodifié');
  8228.     }
  8229.     /**
  8230.      * @Route("/Parent/CheckRandomNotice",name="CheckRandomNotice")
  8231.      */
  8232.     function CheckRandomNotice(Request $request)
  8233.     {
  8234.         $val $request->get("val");
  8235.         /** @var \App\Entity\User $user */
  8236.         $user $this->getUser();
  8237.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8238.         $parent->setRandomnotice($val);
  8239.         $this->em->getManager()->persist($parent);
  8240.         $this->em->getManager()->flush();
  8241.         return new Response('ok');
  8242.     }
  8243.     /**
  8244.      * @Route("/Parent/CheckalbumNotif",name="CheckalbumNotif")
  8245.      */
  8246.     function CheckalbumNotif(Request $request)
  8247.     {
  8248.         $val $request->get("val");
  8249.         /** @var \App\Entity\User $user */
  8250.         $user $this->getUser();
  8251.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8252.         $parent->setShowdetailsalbum($val);
  8253.         $this->em->getManager()->persist($parent);
  8254.         $this->em->getManager()->flush();
  8255.         return new Response('ok');
  8256.     }
  8257.     /**
  8258.      * @Route("/Parent/ChecklivreNotif",name="ChecklivreNotif")
  8259.      */
  8260.     function ChecklivreNotif(Request $request)
  8261.     {
  8262.         $val $request->get("val");
  8263.         /** @var \App\Entity\User $user */
  8264.         $user $this->getUser();
  8265.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8266.         $parent->setShowdetailslivre($val);
  8267.         $this->em->getManager()->persist($parent);
  8268.         $this->em->getManager()->flush();
  8269.         return new Response('ok');
  8270.     }
  8271.     /**
  8272.      * @Route("/Parent/CheckphotosNotif",name="CheckphotosNotif")
  8273.      */
  8274.     function CheckphotosNotif(Request $request)
  8275.     {
  8276.         $val $request->get("val");
  8277.         /** @var \App\Entity\User $user */
  8278.         $user $this->getUser();
  8279.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8280.         $parent->setShowdetailsphotos($val);
  8281.         $this->em->getManager()->persist($parent);
  8282.         $this->em->getManager()->flush();
  8283.         return new Response('ok');
  8284.     }
  8285.     /**
  8286.      * @Route("/Parent/CheckcalNotif",name="CheckcalNotif")
  8287.      */
  8288.     function CheckcalNotif(Request $request)
  8289.     {
  8290.         $val $request->get("val");
  8291.         /** @var \App\Entity\User $user */
  8292.         $user $this->getUser();
  8293.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8294.         $parent->setShowdetailscal($val);
  8295.         $this->em->getManager()->persist($parent);
  8296.         $this->em->getManager()->flush();
  8297.         return new Response('ok');
  8298.     }
  8299.     /**
  8300.      * @Route("/Parent/CheckretrosNotif",name="CheckretrosNotif")
  8301.      */
  8302.     function CheckretrosNotif(Request $request)
  8303.     {
  8304.         $val $request->get("val");
  8305.         /** @var \App\Entity\User $user */
  8306.         $user $this->getUser();
  8307.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8308.         $parent->setShowdetailsretros($val);
  8309.         $this->em->getManager()->persist($parent);
  8310.         $this->em->getManager()->flush();
  8311.         return new Response('ok');
  8312.     }
  8313.     /**
  8314.      * @Route("/Parent/hidePubProd",name="hidePubProd")
  8315.      */
  8316.     function hidePubProd(Request $request)
  8317.     {
  8318.         $val $request->get("val");
  8319.         /** @var \App\Entity\User $user */
  8320.         $user $this->getUser();
  8321.         $parent $this->em->getRepository(User::class)->find($user->getId());
  8322.         $parent->setShowpubprod('false');
  8323.         $this->em->getManager()->persist($parent);
  8324.         $this->em->getManager()->flush();
  8325.         return new Response('ok');
  8326.     }
  8327.     /**
  8328.      * @Route("/Parent/PackPhotosNumerique_Modifier/{nbr}/{id}", name="PackPhotosNumerique_Modifier")
  8329.      */
  8330.     public function PackPhotosNumerique_Modifier($nbr$id)
  8331.     {
  8332.         $SEjourService $this->sejourService;
  8333.         /** @var \App\Entity\User $user */
  8334.         $user $this->getUser();
  8335.         $userId $user->getId();
  8336.         $user $this->getUser();
  8337.         $session $this->session;
  8338.         $session->set('pageMenu''');
  8339.         $idSejour $session->get("Sejour");
  8340.         $produitcondition $session->get("produit");
  8341.         $produit $session->get("produittype");
  8342.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8343.         $em $this->em;
  8344.         $clipart $em->getRepository(Clipart::class)->findAll();
  8345.         $listeattachlikephoto $SEjourService->getlikephotosejour($userId$idSejour);
  8346.         $listeattach $SEjourService->getatachmentsejour($idSejour);
  8347.         $nbLikes count($listeattachlikephoto);
  8348.         //Stella
  8349.         $AllPagesAcc null;
  8350.         $random false;
  8351.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['id' => $id]);
  8352.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  8353.         $idAcc $sejour->getIdAcommp();
  8354.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  8355.         $part $sejour->getIdPartenaire();
  8356.         $nompart $part->getUsername();
  8357.         $logopart $part->getLogourl();
  8358.         $nbPhoto count($listeattach);
  8359.         // die();
  8360.         if ($nbLikes == 0) {
  8361.             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]);
  8362.         }
  8363.         if ($nbLikes != 0) {
  8364.             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]);
  8365.         }
  8366.     }
  8367.     /**
  8368.      * @Route("Parent/PackPhotosNumerique_Favoris/{nbr}", name="PackPhotosNumerique_Favoris")
  8369.      */
  8370.     public function PackPhotosNumerique_Favoris($nbr)
  8371.     {
  8372.         $SEjourService $this->sejourService;
  8373.         $user $this->getUser();
  8374.         $userId $this->getUser()->getId();
  8375.         $session $this->get('session');
  8376.         $session->set('pageMenu''');
  8377.         $idSejour $session->get("Sejour");
  8378.         $produitcondition $session->get("produit");
  8379.         $produit $session->get("produittype");
  8380.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8381.         $em $this->getDoctrine()->getManager();
  8382.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' =>  $userId'idSejour' =>  $idSejour]);
  8383.         foreach ($listeattachlikephoto as $photo) {
  8384.             $idattach $photo->getIdSejourAttchment();
  8385.             $SejattachPhoto  $photo->getIdSejourAttchment();
  8386.             $urlPhoto  =   $SejattachPhoto->getIdAttchment()->getPath();
  8387.             //$urlPhoto =   $attachPhoto->getPath();
  8388.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/',  $urlPhoto);
  8389.             $photosData[] = [
  8390.                 'id' => $photo->getId(),
  8391.                 'url' =>    $new_url,
  8392.                 'caption' => "",
  8393.             ];
  8394.         }
  8395.         $nbLikes count($listeattachlikephoto);
  8396.         // Convertir le tableau PHP en JSON
  8397.         $photosDataJSON json_encode($photosData);
  8398.         return $this->render('Parent/PackPhotosNumerique_Favoris.html.twig', [
  8399.             "nbr" => $nbr,
  8400.             "sejour" => $sejour,
  8401.             "nbLikes" => $nbLikes,
  8402.             'photosFav' =>    $photosDataJSON
  8403.         ]);
  8404.     }
  8405.     /**
  8406.      * @Route("Parent/PackPhotosNumerique_Offert/{nbr}", name="PackPhotosNumerique_Offert")
  8407.      */
  8408.     public function PackPhotosNumerique_Offert($nbr)
  8409.     {
  8410.         $SEjourService $this->sejourService;
  8411.         $user $this->getUser();
  8412.         $userId $this->getUser()->getId();
  8413.         $session $this->get('session');
  8414.         $session->set('pageMenu''');
  8415.         $idSejour $session->get("Sejour");
  8416.         $produitcondition $session->get("produit");
  8417.         $produit $session->get("produittype");
  8418.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8419.         $em $this->getDoctrine()->getManager();
  8420.         $listeattachlikephoto $em->getRepository(Likephoto::class)->findBy(['idUser' => $userId'idSejour' => $idSejour]);
  8421.         foreach ($listeattachlikephoto as $photo) {
  8422.             $idattach $photo->getIdSejourAttchment();
  8423.             $SejattachPhoto $photo->getIdSejourAttchment();
  8424.             $urlPhoto $SejattachPhoto->getIdAttchment()->getPath();
  8425.             //$urlPhoto = $attachPhoto->getPath();
  8426.             $new_url str_replace('upload/''upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled/'$urlPhoto);
  8427.             $photosData[] = [
  8428.                 'id' => $photo->getId(),
  8429.                 'url' => $new_url,
  8430.                 'caption' => "",
  8431.             ];
  8432.         }
  8433.         $nbLikes count($listeattachlikephoto);
  8434.         // Convertir le tableau PHP en JSON
  8435.         $photosDataJSON json_encode($photosData);
  8436.         return $this->render('Parent/PackPhotosNumerique_Favoris.html.twig', [
  8437.             "nbr" => $nbr,
  8438.             "sejour" => $sejour,
  8439.             "nbLikes" => $nbLikes,
  8440.             'photosFav' => $photosDataJSON
  8441.         ]);
  8442.     }
  8443.     /**
  8444.      * @Route("Parent/AjoutPackPhotosNum/{nbr}", name="AjoutPackPhotosNum")
  8445.      */
  8446.     public function AjoutPackPhotosNumParent($nbr)
  8447.     {
  8448.         $SEjourService $this->sejourService;
  8449.         /** @var \App\Entity\User $user */
  8450.         $user $this->getUser();
  8451.         $userId $user->getId();
  8452.         $user $this->getUser();
  8453.         $session $this->session;
  8454.         $session->set('pageMenu''');
  8455.         $idSejour $session->get("Sejour");
  8456.         $sejour $SEjourService->getsejourpourparent($idSejour);
  8457.         $em $this->em;
  8458.         $clipart $em->getRepository(Clipart::class)->findAll();
  8459.         //  $listeattachlikephoto = $SEjourService->getlikephotosejour($userId, $idSejour);
  8460.         //$listerandom =  $SEjourService->getatachmentsejour($idSejour);
  8461.         $listeattach $SEjourService->getCombinedattachSejour($idSejour'photo');
  8462.         $listerandom =  $listeattach;
  8463.         $AllPagesAcc null;
  8464.         $Albumproduct $em->getRepository(Produit::class)->findOneBy(['labele' => 'RandomPackPhotosNum' $nbr]);
  8465.         $random true;
  8466.         $AllPages $em->getRepository(Page::class)->findBy(['idproduit' => $Albumproduct]);
  8467.         $idAcc $sejour->getIdAcommp();
  8468.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  8469.         $part $sejour->getIdPartenaire();
  8470.         $nompart $part->getUsername();
  8471.         $logopart $part->getLogourl();
  8472.         if ($albumAcc != null and $albumAcc != "") {
  8473.             $AllPagesAcc $em->getRepository(Page::class)->findBy(['idproduit' => $albumAcc]);
  8474.         }
  8475.         $allpagesResult = array();
  8476.         $j 0;
  8477.         if ($random == true) {
  8478.             foreach ($AllPages as $p) {
  8479.                 $arrayexploded preg_split('[randomid|randompath]'$p->getCouleurbordure());
  8480.                 $rr "";
  8481.                 for ($i 0$i sizeof($arrayexploded); $i $i 2) {
  8482.                     if ($i sizeof($arrayexploded)) {
  8483.                         if (sizeof($listerandom) == 0) {
  8484.                             //$listerandom = $SEjourService->getatachmentsejour($idSejour);
  8485.                             $listerandom $SEjourService->getCombinedattachSejour($idSejour'photo');
  8486.                         }
  8487.                         $arrayRsRandom $this->random_functionNolikes($listerandom);
  8488.                         $rr $rr $arrayexploded[$i] . $arrayRsRandom['idelem'] . $arrayexploded[$i 1] . $arrayRsRandom['pathelem'];
  8489.                         unset($listerandom[$arrayRsRandom['elem']]);
  8490.                     } else {
  8491.                         $rr $rr $arrayexploded[$i];
  8492.                     }
  8493.                     $listerandom $listerandom;
  8494.                 }
  8495.                 $resultFinal $rr;
  8496.                 $p->setCouleurbordure($resultFinal);
  8497.                 array_push($allpagesResult$p);
  8498.                 if ($j sizeof($listeattach) - 1) {
  8499.                     $j $j 1;
  8500.                 } else {
  8501.                     $j 0;
  8502.                 }
  8503.             }
  8504.             $AllPages $allpagesResult;
  8505.         }
  8506.         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]);
  8507.     }
  8508.     /**
  8509.      * @Route("/Parent/SavePackPhotosNumerique", name="SavePackPhotosNumeriqueParent")
  8510.      */
  8511.     public function SavePackPhotosNumeriqueParent(Request $request)
  8512.     {
  8513.         $session $this->session;
  8514.         $serviceuser $this->etablissementService;
  8515.         $page $request->get("pages");
  8516.         $sejour $request->get("sejour");
  8517.         $prodid $request->get('idProd');
  8518.         $nomprod $request->get('nomprod');
  8519.         $nbr $request->get('nbr');
  8520.         $user $this->getUser();
  8521.         $nbr strval($nbr);
  8522.         $produittype $session->get("produit");
  8523.         $produit $session->get("produittype");
  8524.         //  $Album = $serviceuser->SavePhotosPochetteParent($page, $user, $sejour, $prodid, $produit, $produittype, $nbr,$nomprod);
  8525.         $refPackNum null;
  8526.         if ($sejour) {
  8527.             $refPackNum $this->generateRefPackPhotosNum($sejour$user);
  8528.         }
  8529.         $Album $serviceuser->SavePackPhotosNumerique($page$user$sejour$prodid$produit$produittype$nbr$nomprod$refPackNum);
  8530.         //sendmailparent
  8531.         $dateNow = new \Datetime();
  8532.         /** @var \App\Entity\User $user */
  8533.         $user $this->getUser();
  8534.         $userEmail $user->getEmail();
  8535.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  8536.         //$this->EmailServie->MailRelancePanier($userEmail);
  8537.         return new response('done');
  8538.     }
  8539.     /**
  8540.      * @Route("/Parent/CommandeDirecteAddPackNumeriqueAuPanier", name="CommandeDirecteAddPackNumeriqueAuPanier")
  8541.      */
  8542.     public function CommandeDirecteAddPackNumeriqueAuPanier(Request $request)
  8543.     {
  8544.         $em $this->em->getManager();
  8545.         $session $this->session;
  8546.         $this->logger->info('Début CommandeDirecteAddPackNumeriqueAuPanier');
  8547.         $serviceuser $this->etablissementService;
  8548.         $photos $request->get("photos");
  8549.         $sejour $request->get("sejour");
  8550.         $nbr $request->get('nbr');
  8551.         $user $this->getUser();
  8552.         $nbr strval($nbr);
  8553.         $nomprod "Pack Photos Numerique - " $nbr;
  8554.         // Créer le produit pack photos
  8555.         $packPhotos $serviceuser->SavePackPhotosNumerique($photos$user$sejour$nbr$nomprod);
  8556.         $product $em->getRepository(Produit::class)->find($packPhotos->getId());
  8557.         // Récupérer ou créer le panier
  8558.         $typeref $em->getRepository(Typeref::class)->find(8);
  8559.         $statutPanier $em->getRepository(Ref::class)->findOneBy(["libiller" => "creer""typeref" => $typeref]);
  8560.         $panierTrace $em->getRepository(Panier::class)->findOneBy(["creerPar" => $user"statut" => $statutPanier]);
  8561.         if ($panierTrace === null) {
  8562.             $panierTrace = new Panier();
  8563.             $panierTrace->setDateCreation(new \DateTime());
  8564.             $panierTrace->setCreerPar($user);
  8565.             $panierTrace->setStatut($statutPanier);
  8566.             $em->persist($panierTrace);
  8567.             $em->flush();
  8568.         }
  8569.         $this->logger->info('Panier récupéré', ['panier_id' => $panierTrace $panierTrace->getId() : 'null']);
  8570.         // Récupérer les produits du panier en session
  8571.         $Products $session->get("Panier", []);
  8572.         $inser false;
  8573.         // Vérifier si le panier est vide (pas de produits en session)
  8574.         if (count($Products) == 0) {
  8575.             // Créer directement une commande et une commande numérique
  8576.             $commande = new Commande();
  8577.             $commande->setDateCreation(new \DateTime());
  8578.             $commande->setCreerPar($user);
  8579.             $commande->setStatut($statutPanier);
  8580.             $commande->setTyperef($typeref);
  8581.             $commande->setMontantTTC($product->getIdConditionnement()->getMontantTTC());
  8582.             $commande->setIdsjour($sejour);
  8583.             $commande->setIdpanier($panierTrace->getId());
  8584.             $commande->setNumComande($this->generateUniqueOrderNumber());
  8585.             $em->persist($commande);
  8586.             $em->flush();
  8587.             $commandeNumerique = new CommandeNumerique();
  8588.             $commandeNumerique->setDateCreation(new \DateTime());
  8589.             $commandeNumerique->setCreerPar($user);
  8590.             $commandeNumerique->setIdCommande($commande);
  8591.             $commandeNumerique->setStatut($statutPanier);
  8592.             $commandeNumerique->setLinkdownload($product->getId());
  8593.             $commandeNumerique->setEtat(0); // État en attente de paiement
  8594.             $em->persist($commandeNumerique);
  8595.             $em->flush();
  8596.             // Ajouter le produit au panier en session pour le paiement
  8597.             $p = [
  8598.                 "id" => $product->getId(),
  8599.                 "nom" => $product->getType()->getLabeletype(),
  8600.                 "ident" => $product->getLabele(),
  8601.                 "codesejour" => $product->getIdsjour()->getcodeSejour(),
  8602.                 "mnt" => $product->getIdConditionnement()->getMontantTTC(),
  8603.                 "path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  8604.                 "condition" => $product->getIdConditionnement()->getId(),
  8605.                 "qte" => 1
  8606.             ];
  8607.             array_push($Products$p);
  8608.             $session->set('Panier'$Products);
  8609.             // Ajouter le produit au panier en base de données
  8610.             $panierProduit = new PanierProduit();
  8611.             $panierProduit->setIdProduit($product);
  8612.             $panierProduit->setIdPanier($panierTrace);
  8613.             $panierProduit->setQuantite(1);
  8614.             $panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
  8615.             $em->persist($panierProduit);
  8616.             $em->flush();
  8617.             // Rediriger vers la page de paiement
  8618.             return $this->redirectToRoute('paiement_commande_directe', [
  8619.                 'id' => $commande->getId()
  8620.             ]);
  8621.         } else {
  8622.             // Il y a déjà des produits dans le panier
  8623.             // Ajouter le produit au panier existant
  8624.             // Vérifier si le produit existe déjà dans le panier en session
  8625.             foreach ($Products as $key => $p) {
  8626.                 if ($p['id'] === $product->getId()) {
  8627.                     $inser true;
  8628.                     $Products[$key]['qte'] += 1;
  8629.                     $Products[$key]['mnt'] += $product->getIdConditionnement()->getMontantTTC();
  8630.                 }
  8631.             }
  8632.             // Vérifier si le produit existe dans PanierProduit en base de données
  8633.             $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(["idProduit" => $product"idPanier" => $panierTrace]);
  8634.             if ($panierProduit === null) {
  8635.                 $panierProduit = new PanierProduit();
  8636.                 $panierProduit->setIdProduit($product);
  8637.                 $panierProduit->setIdPanier($panierTrace);
  8638.                 $panierProduit->setQuantite(1);
  8639.                 $panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
  8640.                 $em->persist($panierProduit);
  8641.                 $em->flush();
  8642.             } else {
  8643.                 // Mettre à jour la quantité et le prix total
  8644.                 $panierProduit->setQuantite($panierProduit->getQuantite() + 1);
  8645.                 $panierProduit->setPrixTotal($panierProduit->getPrixTotal() + $product->getIdConditionnement()->getMontantTTC());
  8646.                 $em->persist($panierProduit);
  8647.                 $em->flush();
  8648.             }
  8649.             // Si le produit n'est pas déjà dans le panier en session, l'ajouter
  8650.             if (!$inser) {
  8651.                 $p = [
  8652.                     "id" => $product->getId(),
  8653.                     "nom" => $product->getType()->getLabeletype(),
  8654.                     "ident" => $product->getLabele(),
  8655.                     "codesejour" => $product->getIdsjour()->getcodeSejour(),
  8656.                     "mnt" => $product->getIdConditionnement()->getMontantTTC(),
  8657.                     "path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  8658.                     "condition" => $product->getIdConditionnement()->getId(),
  8659.                     "qte" => 1
  8660.                 ];
  8661.                 array_push($Products$p);
  8662.             }
  8663.             // Mettre à jour le panier en session
  8664.             $session->set('Panier'$Products);
  8665.             // Ajouter un message flash pour informer l'utilisateur
  8666.             $this->addFlash('success''Le pack photos a été ajouté à votre panier.');
  8667.             // Rediriger vers le panier
  8668.             $this->logger->info('Redirection vers le panier');
  8669.             return new Response('done');
  8670.         }
  8671.     }
  8672.     /**
  8673.      * Génère un numéro de commande unique
  8674.      */
  8675.     private function generateUniqueOrderNumber()
  8676.     {
  8677.         // Générer un numéro de commande basé sur la date et un nombre aléatoire
  8678.         return date('YmdHis') . rand(10009999);
  8679.     }
  8680.     /**
  8681.      * @Route("/Parent/confirmation-pack-photos/{id}", name="confirmation_pack_photos")
  8682.      */
  8683.     public function confirmationPackPhotos($id): Response
  8684.     {
  8685.         $commandeNumerique $this->em->getRepository(CommandeNumerique::class)->find($id);
  8686.         if (!$commandeNumerique) {
  8687.             throw $this->createNotFoundException('Commande numérique introuvable');
  8688.         }
  8689.         $commande $commandeNumerique->getIdCommande();
  8690.         $user $commande->getCreerPar();
  8691.         $sejour $commande->getIdsjour();
  8692.         return $this->render('Parent/confirmation_pack_photos.html.twig', [
  8693.             'commandeNumerique' => $commandeNumerique,
  8694.             'commande' => $commande,
  8695.             'user' => $user,
  8696.             'sejour' => $sejour,
  8697.             'downloadUrl' => $this->generateUrl('telechargerPack', ['idCommande' => $commandeNumerique->getId()])
  8698.         ]);
  8699.     }
  8700.     /**
  8701.      * @Route("/Parent/SavePackPhotosNumeriqueComandeSave_panier", name="SavePackPhotosNumeriqueComandeSave_panier")
  8702.      */
  8703.     public function AddPackNumeriqueAuPanier(Request $request)
  8704.     {
  8705.         $em $this->em->getManager();
  8706.         $session $this->session;
  8707.         $serviceuser $this->etablissementService;
  8708.         $photos $request->get("photos");
  8709.         $sejour $request->get("sejour");
  8710.         $nbr $request->get('nbr');
  8711.         $user $this->getUser();
  8712.         $nbr strval($nbr);
  8713.         $nomprod "Pack Photos Numerique - " $nbr;
  8714.         //test de la fonction envoieMailPackNumerique
  8715.         $packPhotos $serviceuser->SavePackPhotosNumerique($photos$user$sejour$nbr$nomprod);
  8716.         $product $em->getRepository(Produit::class)->find($packPhotos->getId());
  8717.         // ---  Test pour envoyer le mail pak numerique ---// 
  8718.         //   $this->emailsCmdService->envoieMailPackNumerique($packPhotos->getId());
  8719.         // $this->printerService->PackPhotosNumerique($packPhotos->getId(),20);
  8720.         $typeref $em->getRepository(Typeref::class)->find(8);
  8721.         $statutPanier $em->getRepository(Ref::class)->findOneBy(["libiller" => "creer""typeref" => $typeref]);
  8722.         $panierTrace $em->getRepository(Panier::class)->findOneBy(["creerPar" => $user"statut" => $statutPanier]);
  8723.         if ($panierTrace === null) {
  8724.             $panierTrace = new Panier();
  8725.             $panierTrace->setDateCreation(new \DateTime());
  8726.             $panierTrace->setCreerPar($user);
  8727.             $panierTrace->setStatut($statutPanier);
  8728.             $em->persist($panierTrace);
  8729.             $em->flush();
  8730.         }
  8731.         // Add product to cart session
  8732.         $Products $session->get("Panier", []);
  8733.         $inser false;
  8734.         foreach ($Products as $key => $p) {
  8735.             if ($p['id'] === $product->getId()) {
  8736.                 $inser true;
  8737.                 $Products[$key]['qte'] += 1;
  8738.                 $Products[$key]['mnt'] += $product->getIdConditionnement()->getMontantTTC();
  8739.             }
  8740.         }
  8741.         // Check if product exists in PanierProduit
  8742.         $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(["idProduit" => $product"idPanier" => $panierTrace]);
  8743.         if ($panierProduit === null) {
  8744.             $panierProduit = new PanierProduit();
  8745.             $panierProduit->setIdProduit($product);
  8746.             $panierProduit->setIdPanier($panierTrace);
  8747.             $panierProduit->setQuantite(1);
  8748.             $panierProduit->setPrixTotal($product->getIdConditionnement()->getMontantTTC());
  8749.             $em->persist($panierProduit);
  8750.             $em->flush();
  8751.         } else {
  8752.             // Update existing product quantity and total price
  8753.             $panierProduit->setQuantite($panierProduit->getQuantite() + 1);
  8754.             $panierProduit->setPrixTotal($panierProduit->getPrixTotal() + $product->getIdConditionnement()->getMontantTTC());
  8755.             $em->persist($panierProduit);
  8756.             $em->flush();
  8757.         }
  8758.         if (!$inser) {
  8759.             $p = [
  8760.                 "id" => $product->getId(),
  8761.                 "nom" => $product->getType()->getLabeletype(),
  8762.                 "ident" => $product->getLabele(),
  8763.                 "codesejour" => $product->getIdsjour()->getcodeSejour(),
  8764.                 "mnt" => $product->getIdConditionnement()->getMontantTTC(),
  8765.                 "path" => $product->getType()->getAttachements()[0]->getIdAttachement()->getPath(),
  8766.                 "condition" => $product->getIdConditionnement()->getId(),
  8767.                 "qte" => 1
  8768.             ];
  8769.             array_push($Products$p);
  8770.         }
  8771.         $session->set('Panier'$Products);
  8772.         // Send reminder email
  8773.         /** @var \App\Entity\User $user */
  8774.         $userEmail $user->getEmail();
  8775.         $this->EmailServie->SaveMailRelancePanier($userEmail);
  8776.         return new Response('done');
  8777.     }
  8778.     /* public function SavePackPhotosNumeriqueComandeSave_panier(PrinterService $PrinterService, Request $request)
  8779.     {
  8780.         $em = $this->em;
  8781.         var_dump("Debut Creation du pack numerique ");
  8782.         $session = $this->session;
  8783.         $serviceuser = $this->etablissementService;
  8784.         $attachements = $request->get('attachements');
  8785.         $page = $request->get("pages");
  8786.         $sejour = $request->get("sejour");
  8787.         $prodid = $request->get('idProd');
  8788.         var_dump($prodid);
  8789.         $nomprod = $request->get('nomprod');
  8790.         $nbr = $request->get('nbr');
  8791.         $user = $this->getUser();
  8792.         $nbr = strval($nbr);
  8793.         $produittype = $session->get("produit");
  8794.         $produit = $session->get("produittype");
  8795.         if ($sejour !== null) {
  8796.             $refPackNum = $this->generateRefPackPhotosNum($sejour, $user);
  8797.             $Album = $serviceuser->SavePackPhotosNumerique($page, $user, $sejour, $prodid, $produit, $produittype, $nbr, $nomprod, $refPackNum);
  8798.             $produit = $em->getRepository(Produit::class)->find($Album->getId());
  8799.             $serviceuser->commandepackphotoNum($attachements, $sejour, $user, $Album);
  8800.             //   $PrinterService->PackPhotosNumerique($sejour,$refPackNum,$Album);
  8801.             $inser = false;
  8802.             $Products = $session->get("Panier");
  8803.             //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
  8804.             $user = $this->getUser();
  8805.             $typeref = $em->getRepository(Typeref::class)->find(8);
  8806.             $statutPanier = $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer", "typeref" => $typeref));
  8807.             $panierTrace = $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user, "statut" => $statutPanier));
  8808.             //fin
  8809.             if ($panierTrace == null) {
  8810.                 $panierTrace = new Panier();
  8811.                 $dateNow = new \Datetime();
  8812.                 $panierTrace->setDateCreation($dateNow);
  8813.                 $panierTrace->setCreerPar($user);
  8814.                 $panierTrace->setStatut($statutPanier);
  8815.                 $em->getManager()->persist($panierTrace);
  8816.                 $em->getManager()->flush();
  8817.             }
  8818.             //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
  8819.             if ($Products == null) {
  8820.                 $Products = [];
  8821.             }
  8822.             if ($Products != null) {
  8823.                 foreach ($Products as $key => $p) {
  8824.                     if ($p['id'] == $produit->getId()) {
  8825.                         $inser = true;
  8826.                         $Products[$key]['qte'] = $p['qte'] + 1;
  8827.                         $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  8828.                     }
  8829.                 }
  8830.             }
  8831.             //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  8832.             $panierProduit = $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit, "idPanier" => $panierTrace));
  8833.             if ($panierProduit == null) {
  8834.                 $panierProduit = new PanierProduit();
  8835.                 $panierProduit->setIdProduit($produit);
  8836.                 $panierProduit->setIdPanier($panierTrace);
  8837.                 $em->getManager()->persist($panierProduit);
  8838.                 $em->getManager()->flush();
  8839.             }
  8840.             //fin
  8841.             //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  8842.             $oldQte = $panierProduit->getQuantite();
  8843.             $newQte = $oldQte + 1;
  8844.             $panierProduit->setQuantite($newQte);
  8845.             $oldTotal = $panierProduit->getPrixTotal();
  8846.             $newTotal = $oldTotal + $produit->getIdConditionnement()->getMontantTTC();
  8847.             $panierProduit->setPrixTotal($newTotal);
  8848.             $em->getManager()->persist($panierProduit);
  8849.             $em->getManager()->flush();
  8850.             //fin
  8851.             if ($inser === false) {
  8852.                 $p = [];
  8853.                 $p["id"] = $produit->getId();
  8854.                 $p["nom"] = $produit->getType()->getLabeletype();
  8855.                 $p["ident"] = $produit->getLabele();
  8856.                 $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  8857.                 $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  8858.                 $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  8859.                 $p["condition"] = $produit->getIdConditionnement()->getId();
  8860.                 $p["qte"] = 1;
  8861.                 array_push($Products, $p);
  8862.             }
  8863.             $session->set('Panier', $Products);
  8864.             //sendmail_parent
  8865.             $dateNow = new \Datetime();
  8866.             $user = $this->getUser();
  8867.             $userEmail = $user->getEmail();
  8868.             $this->EmailServie->SaveMailRelancePanier($userEmail);
  8869.             // $this->EmailServie->MailRelancePanier($userEmail);
  8870.         }
  8871.         return new response('done');
  8872.     }
  8873. */
  8874.     /**
  8875.      * @Route("/Parent/SavePackPhotosNumeriqueComandeSave_panierfree", name="SavePackPhotosNumeriqueComandeSave_panierfree")
  8876.      */
  8877.     public function SavePackPhotosNumeriqueComandeSave_panierfree(PrinterService $PrinterServiceRequest $request)
  8878.     {
  8879.         $em $this->em;
  8880.         var_dump("Debut Creation du pack numerique ");
  8881.         $session $this->session;
  8882.         $serviceuser $this->etablissementService;
  8883.         $attachements $request->get('attachements');
  8884.         $page $request->get("pages");
  8885.         $sejour $request->get("sejour");
  8886.         $prodid $request->get('idProd');
  8887.         var_dump($prodid);
  8888.         $nomprod $request->get('nomprod');
  8889.         $nbr $request->get('nbr');
  8890.         $user $this->getUser();
  8891.         $nbr strval($nbr);
  8892.         $produittype $session->get("produit");
  8893.         $produit $session->get("produittype");
  8894.         if ($sejour !== null) {
  8895.             $refPackNum $this->generateRefPackPhotosNum($sejour$user);
  8896.             $Album $serviceuser->SavePackPhotosNumeriquefree($page$user$sejour$prodid$produit$produittype$nbr$nomprod$refPackNum);
  8897.             $produit $em->getRepository(Produit::class)->find($Album->getId());
  8898.             $serviceuser->commandepackphotoNum($attachements$sejour$user$Album);
  8899.             //   $PrinterService->PackPhotosNumerique($sejour,$refPackNum,$Album);
  8900.             $inser false;
  8901.             $Products $session->get("Panier");
  8902.             //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
  8903.             $user $this->getUser();
  8904.             $typeref $em->getRepository(Typeref::class)->find(8);
  8905.             $statutPanier $em->getRepository(Ref::class)->findOneBy(array("libiller" => "creer""typeref" => $typeref));
  8906.             $panierTrace $em->getRepository(Panier::class)->findOneBy(array("creerPar" => $user"statut" => $statutPanier));
  8907.             //fin
  8908.             if ($panierTrace == null) {
  8909.                 $panierTrace = new Panier();
  8910.                 $dateNow = new \Datetime();
  8911.                 $panierTrace->setDateCreation($dateNow);
  8912.                 $panierTrace->setCreerPar($user);
  8913.                 $panierTrace->setStatut($statutPanier);
  8914.                 $em->getManager()->persist($panierTrace);
  8915.                 $em->getManager()->flush();
  8916.             }
  8917.             //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
  8918.             if ($Products == null) {
  8919.                 $Products = [];
  8920.             }
  8921.             if ($Products != null) {
  8922.                 foreach ($Products as $key => $p) {
  8923.                     if ($p['id'] == $produit->getId()) {
  8924.                         $inser true;
  8925.                         $Products[$key]['qte'] = $p['qte'] + 1;
  8926.                         $Products[$key]['mnt'] = $p['mnt'] + $produit->getIdConditionnement()->getMontantTTC();
  8927.                     }
  8928.                 }
  8929.             }
  8930.             //Touhemi 03-07-2020 :Rechercher  si le produti existe déja ds panierProduit
  8931.             $panierProduit $em->getRepository(PanierProduit::class)->findOneBy(array("idProduit" => $produit"idPanier" => $panierTrace));
  8932.             if ($panierProduit == null) {
  8933.                 $panierProduit = new PanierProduit();
  8934.                 $panierProduit->setIdProduit($produit);
  8935.                 $panierProduit->setIdPanier($panierTrace);
  8936.                 $em->getManager()->persist($panierProduit);
  8937.                 $em->getManager()->flush();
  8938.             }
  8939.             //fin
  8940.             //   Touhemi 03-07-2020 ajouter plus un au produit et modifier prixTotal
  8941.             $oldQte $panierProduit->getQuantite();
  8942.             $newQte $oldQte 1;
  8943.             $panierProduit->setQuantite($newQte);
  8944.             $oldTotal $panierProduit->getPrixTotal();
  8945.             $newTotal $oldTotal $produit->getIdConditionnement()->getMontantTTC();
  8946.             $panierProduit->setPrixTotal($newTotal);
  8947.             $em->getManager()->persist($panierProduit);
  8948.             $em->getManager()->flush();
  8949.             //fin
  8950.             if ($inser === false) {
  8951.                 $p = [];
  8952.                 $p["id"] = $produit->getId();
  8953.                 $p["nom"] = $produit->getType()->getLabeletype();
  8954.                 $p["ident"] = $produit->getLabele();
  8955.                 $p["codesejour"] = $produit->getIdsjour()->getcodeSejour();
  8956.                 $p["mnt"] = $produit->getIdConditionnement()->getMontantTTC();
  8957.                 $p["path"] = $produit->getType()->getAttachements()[0]->getIdAttachement()->getPath();
  8958.                 $p["condition"] = $produit->getIdConditionnement()->getId();
  8959.                 $p["qte"] = 1;
  8960.                 array_push($Products$p);
  8961.             }
  8962.             $session->set('Panier'$Products);
  8963.             //sendmail_parent
  8964.             $dateNow = new \Datetime();
  8965.             /** @var \App\Entity\User $user */
  8966.             $user $this->getUser();
  8967.             $userEmail $user->getEmail();
  8968.             $this->EmailServie->SaveMailRelancePanier($userEmail);
  8969.             // $this->EmailServie->MailRelancePanier($userEmail);
  8970.         }
  8971.         return new response('done');
  8972.     }
  8973.     function generateRefPackPhotosNum($idsejour$user)
  8974.     {
  8975.         //photonum_code_sejour_idparent_random;
  8976.         $em $this->em;
  8977.         $date = new \Datetime();
  8978.         $Milliseconde $date->format('dmYhis');
  8979.         $sejour $this->em->getRepository(Sejour::class)->find($idsejour);
  8980.         $ref "photonum_" $sejour->getCodeSejour() . "_" $user->getId() . "_" $Milliseconde;
  8981.         return $ref;
  8982.     }
  8983.     /**
  8984.      * @Route("/downloadpackphotonum/{refcmdnum}", name="downloadpackphotonum",methods={"GET"})
  8985.      */
  8986.     public function downloadpackphotonumAction($refcmdnumPrinterService $printerService)
  8987.     {
  8988.         // Try to find CommandeNumerique by linkdownload (can be product ID or ZIP name)
  8989.         $commandenumerique $this->em->getRepository(CommandeNumerique::class)->findOneBy(array('linkdownload' => $refcmdnum));
  8990.         if (!$commandenumerique) {
  8991.             return new JsonResponse(array('message' => 'Commande introuvable pour ref: ' $refcmdnum), 404);
  8992.         }
  8993.         // Check if order is paid
  8994.         if ($commandenumerique->getIdCommande()->getStatut()->getId() != 33) {
  8995.             return new JsonResponse(array('message' => 'Commande non payée'), 400);
  8996.         }
  8997.         $linkdownload $commandenumerique->getLinkdownload();
  8998.         // Check if ZIP needs to be generated
  8999.         // If linkdownload is numeric, it's the product ID and ZIP hasn't been generated yet
  9000.         $needsGeneration is_numeric($linkdownload) || $commandenumerique->getEtat() === 0;
  9001.         if (!$needsGeneration) {
  9002.             // ZIP name already set, check if file exists
  9003.             $zipPath $this->getParameter('kernel.project_dir') . '/public/ParentPhotosNumerique/' $linkdownload '.zip';
  9004.             if (!file_exists($zipPath)) {
  9005.                 $needsGeneration true;
  9006.             }
  9007.         }
  9008.         if ($needsGeneration) {
  9009.             try {
  9010.                 // linkdownload contains the product ID when not yet generated
  9011.                 $idProduit is_numeric($linkdownload) ? $linkdownload $linkdownload;
  9012.                 $produit $this->em->getRepository(Produit::class)->find($idProduit);
  9013.                 if (!$produit) {
  9014.                     return new JsonResponse(array('message' => 'Produit introuvable (ID: ' $idProduit ')'), 400);
  9015.                 }
  9016.                 // Generate ZIP using PrinterService (updates linkdownload to ZIP name on success)
  9017.                 $zipResult $printerService->PackPhotosNumerique($produit->getId(), $commandenumerique->getId());
  9018.                 if ($zipResult === null) {
  9019.                     return new JsonResponse(array(
  9020.                         '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.'
  9021.                     ), 500);
  9022.                 }
  9023.                 // Refresh entity to get updated linkdownload value
  9024.                 $this->em->getManager()->refresh($commandenumerique);
  9025.                 // Update state to ready for download
  9026.                 $commandenumerique->setEtat(1);
  9027.                 $this->em->getManager()->persist($commandenumerique);
  9028.                 $this->em->getManager()->flush();
  9029.             } catch (\Exception $e) {
  9030.                 return new JsonResponse(array('message' => 'Erreur lors de la génération du ZIP: ' $e->getMessage()), 500);
  9031.             }
  9032.         }
  9033.         // Get updated linkdownload (now contains ZIP name like "Pack_Numerique-CMD123_2025-12-18")
  9034.         $linkdownload $commandenumerique->getLinkdownload();
  9035.         if (is_numeric($linkdownload)) {
  9036.             return new JsonResponse(array(
  9037.                 'message' => 'La génération du pack n\'a pas pu aboutir. Veuillez réessayer ou contacter le support.'
  9038.             ), 500);
  9039.         }
  9040.         $zipPath $this->getParameter('kernel.project_dir') . '/public/ParentPhotosNumerique/' $linkdownload '.zip';
  9041.         // Download the ZIP (etat 1 or 2)
  9042.         if ($commandenumerique->getEtat() === || $commandenumerique->getEtat() === 2) {
  9043.             if (!file_exists($zipPath)) {
  9044.                 return new JsonResponse(array('message' => 'Fichier ZIP introuvable. Réessayez dans un instant ou contactez le support.'), 404);
  9045.             }
  9046.             // Mark as downloaded if first time
  9047.             if ($commandenumerique->getEtat() === 1) {
  9048.                 $commandenumerique->setEtat(2);
  9049.                 $commandenumerique->setDateTelechargement(new \DateTime());
  9050.                 $this->em->getManager()->persist($commandenumerique);
  9051.                 $this->em->getManager()->flush();
  9052.             }
  9053.             $response = new BinaryFileResponse($zipPath);
  9054.             $response->headers->set('Content-Type'"application/zip");
  9055.             $response->setContentDisposition(
  9056.                 ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  9057.                 basename($zipPath)
  9058.             );
  9059.             return $response;
  9060.         } else {
  9061.             return new JsonResponse(array('message' => 'État de commande invalide: ' $commandenumerique->getEtat()), 400);
  9062.         }
  9063.     }
  9064.     /**
  9065.      * @Route("/Parent/showpub" , name="showpub")
  9066.      */
  9067.     public function showpub()
  9068.     {
  9069.         /** @var User $user */
  9070.         $user $this->getUser();
  9071.         if (!$user) {
  9072.             return new JsonResponse(['status' => 'error''message' => 'User not found'], 400);
  9073.         }
  9074.         // Set showpubprod to true
  9075.         $user->setShowpubprod(1);
  9076.         // Save the changes to the database
  9077.         $this->em->getManager()->persist($user);
  9078.         $this->em->getManager()->flush();
  9079.         // Return a success response
  9080.         return new JsonResponse(['status' => 'success']);
  9081.     }
  9082.     /**
  9083.      * @Route("/Parent/Mentionslegales", name="mentionlegale")
  9084.      */
  9085.     public function Mentionslegales()
  9086.     {
  9087.         return $this->render('Parent/footer/mentionlegal.html.twig', []);
  9088.     }
  9089.     /**
  9090.      * @Route("/Parent/Conditongeneral", name="Conditongeneral")
  9091.      */
  9092.     public function Conditongeneral()
  9093.     {
  9094.         return $this->render('Parent/footer/Condition.html.twig', []);
  9095.     }
  9096.     /**
  9097.      * @Route("/Parent/PdfParentP/{id}", name="PdfParentP_Parent")
  9098.      */
  9099.     public function ExportPdfParentPayeParent(Request $request$id)
  9100.     {
  9101.         $sejourservice $this->sejourService;
  9102.         $session $this->session;
  9103.         // Récupérer le séjour pour un parent
  9104.         $sejour $sejourservice->getsejour($id);
  9105.         // Vérifier que le parent a accès à ce séjour
  9106.         $parentSejour $this->em->getRepository(ParentSejour::class)->findOneBy([
  9107.             'IdParent' => $this->getUser(),
  9108.             'idSejour' => $sejour
  9109.         ]);
  9110.         if (!$parentSejour) {
  9111.             throw $this->createAccessDeniedException('Vous n\'avez pas accès à ce séjour');
  9112.         }
  9113.         $pdf = new Fpdi();
  9114.         $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  9115.         $pdfFilepath $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
  9116.         $pageCount $pdf->setSourceFile($pdfFilepath);
  9117.         $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  9118.         $pdf->AddPage();
  9119.         $pdf->useImportedPage($pageId00);
  9120.         $pdf->SetFont("Arial"""10);
  9121.         $MotPass $sejour->getCodeSejour();
  9122.         $DateDebut $sejour->getDateCreationCode();
  9123.         $DateFin $sejour->getDateFinCode();
  9124.         $pdf->SetFont("Arial"""12);
  9125.         $DateDebutStr = ($DateDebut instanceof \DateTimeInterface) ? $DateDebut->format('d/m/Y') : ((is_string($DateDebut) && $DateDebut !== '') ? (new \DateTime($DateDebut))->format('d/m/Y') : '');
  9126.         $pdf->Text(88242$DateDebutStr);
  9127.         $pdf->SetFont("Arial"""12);
  9128.         $DateFinStr = ($DateFin instanceof \DateTimeInterface) ? $DateFin->format('d/m/Y') : ((is_string($DateFin) && $DateFin !== '') ? (new \DateTime($DateFin))->format('d/m/Y') : '');
  9129.         $pdf->Text(89258$DateFinStr);
  9130.         $pdf->Output("Mode d'emploi Parent 5sur5sejour.pdf""D");
  9131.         return new Response($pdf->Output(), 200, array('Content-Type' => 'application/pdf'));
  9132.     }
  9133.     /**
  9134.      * @Route("/Parent/PdfParentgrat/{id}", name="PdfParentgratt_Parent")
  9135.      */
  9136.     public function ExportPdfParentGratuitParent(Request $request$id)
  9137.     {
  9138.         $sejourservice $this->sejourService;
  9139.         $session $this->session;
  9140.         // Récupérer le séjour pour un parent
  9141.         $sejour $sejourservice->getsejour($id);
  9142.         // Vérifier que le parent a accès à ce séjour
  9143.         $parentSejour $this->em->getRepository(ParentSejour::class)->findOneBy([
  9144.             'IdParent' => $this->getUser(),
  9145.             'idSejour' => $sejour
  9146.         ]);
  9147.         if (!$parentSejour) {
  9148.             throw $this->createAccessDeniedException('Vous n\'avez pas accès à ce séjour');
  9149.         }
  9150.         $pdf = new Fpdi();
  9151.         $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  9152.         $pdfFilepath $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5.pdf";
  9153.         $pageCount $pdf->setSourceFile($pdfFilepath);
  9154.         $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  9155.         $pdf->AddPage();
  9156.         $pdf->useImportedPage($pageId00);
  9157.         $pdf->SetFont("Arial"""10);
  9158.         $MotPass $sejour->getCodeSejour();
  9159.         $DateDebut $sejour->getDateCreationCode();
  9160.         $DateFin $sejour->getDateFinCode();
  9161.         $pdf->SetFont("Arial"""12);
  9162.         $DateDebutStr = ($DateDebut instanceof \DateTimeInterface) ? $DateDebut->format('d/m/Y') : ((is_string($DateDebut) && $DateDebut !== '') ? (new \DateTime($DateDebut))->format('d/m/Y') : '');
  9163.         $pdf->Text(87237$DateDebutStr);
  9164.         $pdf->SetFont("Arial"""12);
  9165.         $DateFinStr = ($DateFin instanceof \DateTimeInterface) ? $DateFin->format('d/m/Y') : ((is_string($DateFin) && $DateFin !== '') ? (new \DateTime($DateFin))->format('d/m/Y') : '');
  9166.         $pdf->Text(88252$DateFinStr);
  9167.         $pdf->Output("Mode d'emploi Parent 5sur5sejour.pdf""D");
  9168.         return new Response($pdf->Output(), 200, array('Content-Type' => 'application/pdf'));
  9169.     }
  9170.     /*** ====================album builder new ============================= */
  9171.     /**
  9172.      * @Route("/Parent/album-builder", name="album_builder", methods={"GET"})
  9173.      */
  9174.     public function albumBuilder(Request $request): Response
  9175.     {
  9176.         // Set page menu in session
  9177.         $this->session->set('pageMenu''AlbumSejour');
  9178.         $random true;
  9179.         // Get current user
  9180.         $user $this->getUser();
  9181.         if (!$user) {
  9182.             $this->addFlash('error''You must be logged in to access the album builder.');
  9183.             return $this->redirectToRoute('app_login');
  9184.         }
  9185.         $userId $user->getId();
  9186.         // Determine mode: 'create' or 'edit'
  9187.         $mode $request->query->get('mode''create'); // default to 'create'
  9188.         $albumId $request->query->get('id'null);
  9189.         $existingAlbum null;
  9190.         $existingAlbumData null;
  9191.         $sejourId null;
  9192.         // EDIT MODE: Load album first to get the sejour ID
  9193.         if ($mode === 'edit' && $albumId) {
  9194.             $existingAlbum $this->em->getRepository(Produit::class)->findOneBy([
  9195.                 'id' => $albumId,
  9196.                 'iduser' => $userId  // Security: ensure album belongs to current user
  9197.             ]);
  9198.             // Verify the album belongs to this user
  9199.             if (!$existingAlbum) {
  9200.                 $this->addFlash('error''Album not found or access denied.');
  9201.                 return $this->redirectToRoute('AccueilParent');
  9202.             }
  9203.             // Get sejour from the album
  9204.             $sejourId $existingAlbum->getIdsjour()->getId();
  9205.             // Update session with this sejour
  9206.             $this->session->set('Sejour'$sejourId);
  9207.             // Load existing album data
  9208.             if ($existingAlbum->getPathpdf()) {
  9209.                 $decodedData json_decode($existingAlbum->getPathpdf(), true);
  9210.                 if ($decodedData && isset($decodedData['pages'])) {
  9211.                     $existingAlbumData $decodedData;
  9212.                 }
  9213.             }
  9214.         } else {
  9215.             // CREATE MODE: Get sejour from session
  9216.             $sejourId $this->session->get('Sejour');
  9217.             if (!$sejourId) {
  9218.                 $this->addFlash('error''No sejour selected. Please select a sejour first.');
  9219.                 return $this->redirectToRoute('AccueilParent');
  9220.             }
  9221.         }
  9222.         // Get sejour details (for both create and edit modes)
  9223.         $sejour $this->sejourService->getsejourpourparent($sejourId);
  9224.         if (!$sejour) {
  9225.             $this->addFlash('error''Sejour not found.');
  9226.             return $this->redirectToRoute('AccueilParent');
  9227.         }
  9228.         // Get partner information
  9229.         $partner $sejour->getIdPartenaire();
  9230.         $partnerName $partner $partner->getUsername() : null;
  9231.         $partnerLogo $partner $partner->getLogourl() : null;
  9232.         // Get liked photos for this user and sejour
  9233.         // These are Likephoto entities with SejourAttachment relationships
  9234.         $likedPhotos $this->sejourService->getlikephotosejour($userId$sejourId);
  9235.         $nbLikes count($likedPhotos);
  9236.         // Get all photos for this sejour (for statistics)
  9237.         $allPhotos $this->sejourService->getCombinedattachSejour($sejourId'photo');
  9238.         $totalPhotos count($allPhotos);
  9239.         // Transform liked photos into format expected by template
  9240.         $likedPhotosFormatted = [];
  9241.         foreach ($likedPhotos as $likePhoto) {
  9242.             // Extract the actual SejourAttachment from the Likephoto entity
  9243.             $attachment $likePhoto->getIdSejourAttchment();
  9244.             if ($attachment) {
  9245.                 $likedPhotosFormatted[] = [
  9246.                     'id' => $attachment->getId(),
  9247.                     'path' => $this->getAttachmentPath($attachment),
  9248.                     'nom' => $this->getAttachmentName($attachment),
  9249.                 ];
  9250.             }
  9251.         }
  9252.         // Check if user has no liked photos
  9253.         if ($nbLikes === 0) {
  9254.             $this->addFlash('warning''You haven\'t liked any photos yet. Like some photos first to add them to your album!');
  9255.         }
  9256.         // CREATE MODE: Don't load any existing data - always start fresh
  9257.         return $this->render('Parent/album_builder.html.twig', [
  9258.             'sejour' => $sejour,
  9259.             'sejourId' => $sejourId,
  9260.             'partnerName' => $partnerName,
  9261.             'partnerLogo' => $partnerLogo,
  9262.             'likedPhotos' => $likedPhotosFormatted,
  9263.             'like' => $likedPhotos,
  9264.             'totalPhotos' => $totalPhotos,
  9265.             'nbLikes' => $nbLikes,
  9266.             'existingAlbum' => $existingAlbum,
  9267.             'existingAlbumData' => $existingAlbumData,
  9268.             'mode' => $mode,
  9269.             'albumId' => $albumId,
  9270.         ]);
  9271.     }
  9272.     /**
  9273.      * @Route("/Parent/album/save", name="album_save", methods={"POST"})
  9274.      */
  9275.     public function saveAlbum(Request $request): JsonResponse
  9276.     {
  9277.         try {
  9278.             // Get current user
  9279.             $user $this->getUser();
  9280.             if (!$user) {
  9281.                 return new JsonResponse([
  9282.                     'success' => false,
  9283.                     'message' => 'You must be logged in to save an album.'
  9284.                 ], Response::HTTP_UNAUTHORIZED);
  9285.             }
  9286.             $userId $user->getId();
  9287.             // Get JSON data from request
  9288.             $data json_decode($request->getContent(), true);
  9289.             if (!$data || !isset($data['sejourId']) || !isset($data['pages'])) {
  9290.                 return new JsonResponse([
  9291.                     'success' => false,
  9292.                     'message' => 'Invalid data format.'
  9293.                 ], Response::HTTP_BAD_REQUEST);
  9294.             }
  9295.             $sejourId $data['sejourId'];
  9296.             $pages $data['pages'];
  9297.             $albumId $data['albumId'] ?? null// Get album ID if in edit mode
  9298.             $albumName $data['albumName'] ?? 'Mon Album'// Get custom name
  9299.             // Get sejour
  9300.             $sejour $this->sejourService->getsejourpourparent($sejourId);
  9301.             if (!$sejour) {
  9302.                 return new JsonResponse([
  9303.                     'success' => false,
  9304.                     'message' => 'Sejour not found.'
  9305.                 ], Response::HTTP_NOT_FOUND);
  9306.             }
  9307.             $album null;
  9308.             // EDIT MODE: Load existing album by ID
  9309.             if ($albumId) {
  9310.                 $album $this->em->getRepository(Produit::class)->findOneBy([
  9311.                     'id' => $albumId,
  9312.                     'iduser' => $userId  // Security: ensure album belongs to current user
  9313.                 ]);
  9314.                 // Verify album exists and belongs to user
  9315.                 if (!$album) {
  9316.                     return new JsonResponse([
  9317.                         'success' => false,
  9318.                         'message' => 'Album not found or access denied.'
  9319.                     ], Response::HTTP_FORBIDDEN);
  9320.                 }
  9321.                 // Update modification date and name
  9322.                 $album->setDate(new \DateTime());
  9323.                 $album->setLabele($albumName);
  9324.             }
  9325.             // CREATE MODE: Always create a new album
  9326.             else {
  9327.                 $album = new Produit();
  9328.                 $album->setIdsjour($sejour);
  9329.                 $album->setIduser($user);
  9330.                 $album->setLabele($albumName);
  9331.                 $album->setStatut('saved');
  9332.                 $album->setDate(new \DateTime());
  9333.                 $album->setType($this->em->getRepository(TypeProduit::class)->findOneBy(['id' => 2]));
  9334.                 $album->setIdConditionnement($this->em->getRepository(TypeProduitConditionnement::class)->findOneBy(['id' => 2]));
  9335.             }
  9336.             // Store album pages as JSON in the pathpdf field (reusing existing field)
  9337.             // This allows us to save complex album data without adding new columns
  9338.             $albumJsonData json_encode([
  9339.                 'sejourId' => $sejourId,
  9340.                 'pages' => $pages,
  9341.                 'savedAt' => (new \DateTime())->format('Y-m-d H:i:s'),
  9342.                 'version' => '2.0' // New album builder version
  9343.             ]);
  9344.             $album->setPathpdf($albumJsonData);
  9345.             $this->em->getManager()->persist($album);
  9346.             $this->em->getManager()->flush();
  9347.             return new JsonResponse([
  9348.                 'success' => true,
  9349.                 'message' => 'Album saved successfully!',
  9350.                 'albumId' => $album->getId()
  9351.             ]);
  9352.         } catch (\Exception $e) {
  9353.             return new JsonResponse([
  9354.                 'success' => false,
  9355.                 'message' => 'An error occurred while saving the album: ' $e->getMessage()
  9356.             ], Response::HTTP_INTERNAL_SERVER_ERROR);
  9357.         }
  9358.     }
  9359.     /**
  9360.      * Get the path for a SejourAttachment
  9361.      * Update this method based on your SejourAttachment entity structure
  9362.      */
  9363.     private function getAttachmentPath($attachment): string
  9364.     {
  9365.         // Common patterns for SejourAttachment - adjust based on your entity:
  9366.         // Option 1: If attachment has a getCheminphoto() method:
  9367.         if (method_exists($attachment'getCheminphoto')) {
  9368.             return $attachment->getCheminphoto();
  9369.         }
  9370.         // Option 2: If attachment has a getPath() method:
  9371.         if (method_exists($attachment'getPath')) {
  9372.             return $attachment->getPath();
  9373.         }
  9374.         // Option 3: If attachment has a getUrl() method:
  9375.         if (method_exists($attachment'getUrl')) {
  9376.             return $attachment->getUrl();
  9377.         }
  9378.         // Option 4: If you need to build the path from filename:
  9379.         if (method_exists($attachment'getFilename')) {
  9380.             return '/uploads/sejours/' $attachment->getFilename();
  9381.         }
  9382.         // Option 5: If attachment has a getCheminfichier() method:
  9383.         if (method_exists($attachment'getCheminfichier')) {
  9384.             return $attachment->getCheminfichier();
  9385.         }
  9386.         // Fallback
  9387.         return '/uploads/photos/default.jpg';
  9388.     }
  9389.     /**
  9390.      * Get the name/label for a SejourAttachment
  9391.      * Update this method based on your SejourAttachment entity structure
  9392.      */
  9393.     private function getAttachmentName($attachment): string
  9394.     {
  9395.         // Try different common method names
  9396.         if (method_exists($attachment'getNom')) {
  9397.             return $attachment->getNom() ?? 'Photo ' $attachment->getId();
  9398.         }
  9399.         if (method_exists($attachment'getLibele')) {
  9400.             return $attachment->getLibele() ?? 'Photo ' $attachment->getId();
  9401.         }
  9402.         if (method_exists($attachment'getFilename')) {
  9403.             return $attachment->getFilename() ?? 'Photo ' $attachment->getId();
  9404.         }
  9405.         if (method_exists($attachment'getLabel')) {
  9406.             return $attachment->getLabel() ?? 'Photo ' $attachment->getId();
  9407.         }
  9408.         // Fallback
  9409.         return 'Photo ' . ($attachment->getId() ?? 'unknown');
  9410.     }
  9411.     /**
  9412.      * View a saved album (read-only by default, with edit mode toggle)
  9413.      * 
  9414.      * @Route("/Parent/album/{id}", name="album_view", methods={"GET"})
  9415.      */
  9416.     public function viewAlbum(int $id): Response
  9417.     {
  9418.         // Check authentication
  9419.         $user $this->getUser();
  9420.         if (!$user) {
  9421.             $this->addFlash('error''You must be logged in to view albums.');
  9422.             return $this->redirectToRoute('app_login');
  9423.         }
  9424.         // Find album and verify ownership
  9425.         $album $this->em->getRepository(Produit::class)->findOneBy([
  9426.             'id' => $id,
  9427.             'iduser' => $user->getId()
  9428.         ]);
  9429.         if (!$album) {
  9430.             $this->addFlash('error''Album not found or you do not have permission to view it.');
  9431.             return $this->redirectToRoute('AccueilParent');
  9432.         }
  9433.         // Load album data from pathpdf field (stored as JSON)
  9434.         $albumJsonData $album->getPathpdf();
  9435.         $albumData null;
  9436.         $hasContent false;
  9437.         if ($albumJsonData) {
  9438.             $decodedData json_decode($albumJsonDatatrue);
  9439.             if ($decodedData && isset($decodedData['pages'])) {
  9440.                 $albumData $decodedData;
  9441.                 // Check if album has any content
  9442.                 $hasContent false;
  9443.                 foreach ($decodedData['pages'] as $page) {
  9444.                     if (!empty($page['photos']) || !empty($page['topText']) || !empty($page['bottomText'])) {
  9445.                         $hasContent true;
  9446.                         break;
  9447.                     }
  9448.                 }
  9449.             }
  9450.         }
  9451.         // If album is empty, show a message
  9452.         if (!$hasContent) {
  9453.             $this->addFlash('info''This album is empty. Click "Edit Album" to add photos.');
  9454.         }
  9455.         return $this->render('Parent/album_view.html.twig', [
  9456.             'album' => $album,
  9457.             'albumData' => $albumData,
  9458.             'hasContent' => $hasContent,
  9459.         ]);
  9460.     }
  9461.     /**
  9462.      * View album in builder/edit mode (alternative route if you want separate edit page)
  9463.      * 
  9464.      * @Route("/Parent/album/{id}/edit", name="album_edit", methods={"GET"})
  9465.      */
  9466.     public function editAlbum(int $id): Response
  9467.     {
  9468.         // Check authentication
  9469.         $user $this->getUser();
  9470.         if (!$user) {
  9471.             $this->addFlash('error''You must be logged in to edit albums.');
  9472.             return $this->redirectToRoute('app_login');
  9473.         }
  9474.         // Find album and verify ownership
  9475.         $album $this->em->getRepository(Produit::class)->findOneBy([
  9476.             'id' => $id,
  9477.             'iduser' => $user->getId()
  9478.         ]);
  9479.         if (!$album) {
  9480.             $this->addFlash('error''Album not found or you do not have permission to edit it.');
  9481.             return $this->redirectToRoute('AccueilParent');
  9482.         }
  9483.         // Get the sejour (trip) associated with this album to load liked photos
  9484.         $sejour $album->getIdSejour(); // Assuming relationship exists
  9485.         if (!$sejour) {
  9486.             $this->addFlash('error''Cannot edit album: associated trip not found.');
  9487.             return $this->redirectToRoute('AccueilParent');
  9488.         }
  9489.         // Load liked photos for this sejour
  9490.         $likedPhotos $this->em->getRepository(\App\Entity\Like::class)->findBy([
  9491.             'idSejour' => $sejour,
  9492.             'idUser' => $user
  9493.         ]);
  9494.         // Load existing album data
  9495.         $albumJsonData $album->getPathpdf();
  9496.         $existingAlbumData null;
  9497.         if ($albumJsonData) {
  9498.             $decodedData json_decode($albumJsonDatatrue);
  9499.             if ($decodedData && isset($decodedData['pages'])) {
  9500.                 $existingAlbumData $decodedData;
  9501.             }
  9502.         }
  9503.         // Render the album builder with edit mode enabled
  9504.         return $this->render('parent/album_builder.html.twig', [
  9505.             'sejour' => $sejour,
  9506.             'sejourId' => $sejour->getId(),
  9507.             'like' => $likedPhotos,
  9508.             'totalPhotos' => count($likedPhotos),
  9509.             'existingAlbum' => $album,
  9510.             'existingAlbumData' => $existingAlbumData,
  9511.             'mode' => 'edit',
  9512.             'albumId' => $id,
  9513.         ]);
  9514.     }
  9515.     /**
  9516.      * Delete an album
  9517.      * 
  9518.      * @Route("/Parent/album/{id}/delete", name="album_delete", methods={"POST"})
  9519.      */
  9520.     public function deleteAlbum(int $id): Response
  9521.     {
  9522.         // Check authentication
  9523.         $user $this->getUser();
  9524.         if (!$user) {
  9525.             $this->addFlash('error''You must be logged in to delete albums.');
  9526.             return $this->redirectToRoute('app_login');
  9527.         }
  9528.         // Find album and verify ownership
  9529.         $album $this->em->getRepository(Produit::class)->findOneBy([
  9530.             'id' => $id,
  9531.             'iduser' => $user->getId()
  9532.         ]);
  9533.         if (!$album) {
  9534.             $this->addFlash('error''Album not found or you do not have permission to delete it.');
  9535.             return $this->redirectToRoute('AccueilParent');
  9536.         }
  9537.         try {
  9538.             $albumName $album->getNom();
  9539.             $this->em->remove($album);
  9540.             $this->em->flush();
  9541.             $this->addFlash('success'"Album '{$albumName}' has been deleted successfully.");
  9542.         } catch (\Exception $e) {
  9543.             $this->addFlash('error''An error occurred while deleting the album. Please try again.');
  9544.         }
  9545.         return $this->redirectToRoute('AccueilParent');
  9546.     }
  9547.     /**=====================================Livre============================================***/
  9548.     /**
  9549.      * @Route("/Parent/livre-builder", name="livre_builder", methods={"GET"})
  9550.      */
  9551.     public function livreBuilder(Request $request): Response
  9552.     {
  9553.         // Set page menu in session
  9554.         $this->session->set('pageMenu''LivreSejour');
  9555.         $random true;
  9556.         // Get current user
  9557.         $user $this->getUser();
  9558.         if (!$user) {
  9559.             $this->addFlash('error''You must be logged in to access the livre builder.');
  9560.             return $this->redirectToRoute('app_login');
  9561.         }
  9562.         $userId $user->getId();
  9563.         // Determine mode: 'create' or 'edit'
  9564.         $mode $request->query->get('mode''create'); // default to 'create'
  9565.         $livreId $request->query->get('id'null);
  9566.         $existingLivre null;
  9567.         $existingLivreData null;
  9568.         $sejourId null;
  9569.         // EDIT MODE: Load livre first to get the sejour ID
  9570.         if ($mode === 'edit' && $livreId) {
  9571.             $existingLivre $this->em->getRepository(Produit::class)->findOneBy([
  9572.                 'id' => $livreId,
  9573.                 'iduser' => $userId  // Security: ensure livre belongs to current user
  9574.             ]);
  9575.             // Verify the livre belongs to this user
  9576.             if (!$existingLivre) {
  9577.                 $this->addFlash('error''Livre not found or access denied.');
  9578.                 return $this->redirectToRoute('AccueilParent');
  9579.             }
  9580.             // Get sejour from the livre
  9581.             $sejourId $existingLivre->getIdsjour()->getId();
  9582.             // Update session with this sejour
  9583.             $this->session->set('Sejour'$sejourId);
  9584.             // Load existing livre data
  9585.             if ($existingLivre->getPathpdf()) {
  9586.                 $decodedData json_decode($existingLivre->getPathpdf(), true);
  9587.                 if ($decodedData && isset($decodedData['pages'])) {
  9588.                     $existingLivreData $decodedData;
  9589.                 }
  9590.             }
  9591.         } else {
  9592.             // CREATE MODE: Get sejour from session
  9593.             $sejourId $this->session->get('Sejour');
  9594.             if (!$sejourId) {
  9595.                 $this->addFlash('error''No sejour selected. Please select a sejour first.');
  9596.                 return $this->redirectToRoute('AccueilParent');
  9597.             }
  9598.         }
  9599.         // Get sejour details (for both create and edit modes)
  9600.         $sejour $this->sejourService->getsejourpourparent($sejourId);
  9601.         if (!$sejour) {
  9602.             $this->addFlash('error''Sejour not found.');
  9603.             return $this->redirectToRoute('AccueilParent');
  9604.         }
  9605.         // Get partner information
  9606.         $partner $sejour->getIdPartenaire();
  9607.         $partnerName $partner $partner->getUsername() : null;
  9608.         $partnerLogo $partner $partner->getLogourl() : null;
  9609.         // Get liked photos for this user and sejour
  9610.         // These are Likephoto entities with SejourAttachment relationships
  9611.         $likedPhotos $this->sejourService->getlikephotosejour($userId$sejourId);
  9612.         $nbLikes count($likedPhotos);
  9613.         // Get all photos for this sejour (for statistics)
  9614.         $allPhotos $this->sejourService->getCombinedattachSejour($sejourId'photo');
  9615.         $totalPhotos count($allPhotos);
  9616.         // Transform liked photos into format expected by template
  9617.         $likedPhotosFormatted = [];
  9618.         foreach ($likedPhotos as $likePhoto) {
  9619.             // Extract the actual SejourAttachment from the Likephoto entity
  9620.             $attachment $likePhoto->getIdSejourAttchment();
  9621.             if ($attachment) {
  9622.                 $likedPhotosFormatted[] = [
  9623.                     'id' => $attachment->getId(),
  9624.                     'path' => $this->getAttachmentPath($attachment),
  9625.                     'nom' => $this->getAttachmentName($attachment),
  9626.                 ];
  9627.             }
  9628.         }
  9629.         // Check if user has no liked photos
  9630.         if ($nbLikes === 0) {
  9631.             $this->addFlash('warning''You haven\'t liked any photos yet. Like some photos first to add them to your livre!');
  9632.         }
  9633.         // CREATE MODE: Don't load any existing data - always start fresh
  9634.         return $this->render('Parent/livre_builder.html.twig', [
  9635.             'sejour' => $sejour,
  9636.             'sejourId' => $sejourId,
  9637.             'partnerName' => $partnerName,
  9638.             'partnerLogo' => $partnerLogo,
  9639.             'likedPhotos' => $likedPhotosFormatted,
  9640.             'like' => $likedPhotos,
  9641.             'totalPhotos' => $totalPhotos,
  9642.             'nbLikes' => $nbLikes,
  9643.             'existingLivre' => $existingLivre,
  9644.             'existingLivreData' => $existingLivreData// Will be null in create mode
  9645.             'mode' => $mode// Pass mode to template
  9646.             'livreId' => $livreId// Pass livre ID for edit mode
  9647.         ]);
  9648.     }
  9649.     /**
  9650.      * @Route("/Parent/livre/save", name="livre_save", methods={"POST"})
  9651.      */
  9652.     public function saveLivre(Request $request): JsonResponse
  9653.     {
  9654.         try {
  9655.             // Get current user
  9656.             $user $this->getUser();
  9657.             if (!$user) {
  9658.                 return new JsonResponse([
  9659.                     'success' => false,
  9660.                     'message' => 'You must be logged in to save a livre.'
  9661.                 ], Response::HTTP_UNAUTHORIZED);
  9662.             }
  9663.             $userId $user->getId();
  9664.             // Get JSON data from request
  9665.             $data json_decode($request->getContent(), true);
  9666.             if (!$data || !isset($data['sejourId']) || !isset($data['pages'])) {
  9667.                 return new JsonResponse([
  9668.                     'success' => false,
  9669.                     'message' => 'Invalid data format.'
  9670.                 ], Response::HTTP_BAD_REQUEST);
  9671.             }
  9672.             $sejourId $data['sejourId'];
  9673.             $pages $data['pages'];
  9674.             $livreId $data['livreId'] ?? null// Get livre ID if in edit mode
  9675.             $livreName $data['livreName'] ?? 'Mon Livre'// Get custom name
  9676.             // Get sejour
  9677.             $sejour $this->sejourService->getsejourpourparent($sejourId);
  9678.             if (!$sejour) {
  9679.                 return new JsonResponse([
  9680.                     'success' => false,
  9681.                     'message' => 'Sejour not found.'
  9682.                 ], Response::HTTP_NOT_FOUND);
  9683.             }
  9684.             $livre null;
  9685.             // EDIT MODE: Load existing livre by ID
  9686.             if ($livreId) {
  9687.                 $livre $this->em->getRepository(Produit::class)->findOneBy([
  9688.                     'id' => $livreId,
  9689.                     'iduser' => $userId  // Security: ensure livre belongs to current user
  9690.                 ]);
  9691.                 // Verify livre exists and belongs to user
  9692.                 if (!$livre) {
  9693.                     return new JsonResponse([
  9694.                         'success' => false,
  9695.                         'message' => 'Livre not found or access denied.'
  9696.                     ], Response::HTTP_FORBIDDEN);
  9697.                 }
  9698.                 // Update modification date and name
  9699.                 $livre->setDate(new \DateTime());
  9700.                 $livre->setLabele($livreName);
  9701.             }
  9702.             // CREATE MODE: Always create a new livre
  9703.             else {
  9704.                 $livre = new Produit();
  9705.                 $livre->setIdsjour($sejour);
  9706.                 $livre->setIduser($user);
  9707.                 $livre->setLabele($livreName);
  9708.                 $livre->setStatut('saved');
  9709.                 $livre->setDate(new \DateTime());
  9710.                 $livre->setType($this->em->getRepository(TypeProduit::class)->findOneBy(['id' => 4]));
  9711.                 $livre->setIdConditionnement($this->em->getRepository(TypeProduitConditionnement::class)->findOneBy(['id' => 5]));
  9712.             }
  9713.             // Store livre pages as JSON in the pathpdf field (reusing existing field)
  9714.             // This allows us to save complex livre data without adding new columns
  9715.             $livreJsonData json_encode([
  9716.                 'sejourId' => $sejourId,
  9717.                 'pages' => $pages,
  9718.                 'savedAt' => (new \DateTime())->format('Y-m-d H:i:s'),
  9719.                 'version' => '2.0' // New livre builder version
  9720.             ]);
  9721.             $livre->setPathpdf($livreJsonData);
  9722.             $this->em->getManager()->persist($livre);
  9723.             $this->em->getManager()->flush();
  9724.             return new JsonResponse([
  9725.                 'success' => true,
  9726.                 'message' => 'Livre saved successfully!',
  9727.                 'livreId' => $livre->getId()
  9728.             ]);
  9729.         } catch (\Exception $e) {
  9730.             return new JsonResponse([
  9731.                 'success' => false,
  9732.                 'message' => 'An error occurred while saving the livre: ' $e->getMessage()
  9733.             ], Response::HTTP_INTERNAL_SERVER_ERROR);
  9734.         }
  9735.     }
  9736.     /**
  9737.      * @Route("/Parent/DetailsSejourAcc/EF171161", name="DetailsSejourAccParentFixed")
  9738.      */
  9739.     public function DetailsSejourAccParentFixed(Request $request)
  9740.     {
  9741.         $session $this->session;
  9742.         /** @var \App\Entity\User $user */
  9743.         $user $this->getUser();
  9744.         $userId $user $user->getId() : null;
  9745.         // Code séjour fixe
  9746.         $codeSejour 'EF171161';
  9747.         
  9748.         // Récupérer le séjour par son code
  9749.         $sejour $this->em->getRepository(Sejour::class)->findOneBy(['codeSejour' => $codeSejour]);
  9750.         
  9751.         if (!$sejour) {
  9752.             throw $this->createNotFoundException('Séjour non trouvé avec le code: ' $codeSejour);
  9753.         }
  9754.         $idSejour $sejour->getId();
  9755.         $dateCreationArch = clone $sejour->getDateFinCode();
  9756.         if ($dateCreationArch <= new \DateTime()) {
  9757.             return $this->render('Parent/SejourDepassee.html.twig');
  9758.         }
  9759.         $SEjourService $this->sejourService;
  9760.         $listeattachlikephoto $userId $SEjourService->getlikephotosejour($userId$idSejour) : [];
  9761.         $this->session->set('Sejour'$idSejour);
  9762.         $dateCreationArch = clone $sejour->getDateFinCode();
  9763.         if ($dateCreationArch <= new \DateTime()) {
  9764.             return $this->render('Parent/SejourDepassee.html.twig');
  9765.         }
  9766.         $session->set('pageMenu''MonSejour');
  9767.         $AllAttachements $SEjourService->getphotosVideosSejour($idSejour'original'$userId);
  9768.         $nbImages count($AllAttachements);
  9769.         $messages $SEjourService->getCombinedattachSejour($idSejour'message');
  9770.         $positions $SEjourService->getsejourposition($idSejour);
  9771.         $photoLikes = [];
  9772.         foreach ($AllAttachements as $attach) {
  9773.             if (!isset($attach['id_attchment'])) {
  9774.                 continue;
  9775.             }
  9776.             $libiller $attach['libiller'] ?? null;
  9777.             if ($libiller !== 'video') {
  9778.                 $photoLikes[$attach['id_attchment']] = $this->sejourService->getTotallikesphotosejour($attach['id_attchment'], $idSejour);
  9779.             }
  9780.         }
  9781.         $em $this->em;
  9782.         $idAcc $sejour->getIdAcommp();
  9783.         
  9784.         //VERIFICATION DE L EXISTANCE DE LIVRE OU D ALBUM SEJOUR 
  9785.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  9786.         if ($albumAcc == null) {
  9787.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  9788.         }
  9789.         $label "Livre_sejour" $sejour->getCodeSejour();
  9790.         $albumAcc $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  9791.         $livreSej $em->getRepository(Produit::class)->findOneBy(['idsjour' => $idSejour'iduser' => $idAcc'statut' => 'saved'], ['id' => 'DESC']);
  9792.         if ($albumAcc == null) {
  9793.             $albumAcc $em->getRepository(Produit::class)->findOneBy(['iduser' => 1'statut' => "Album_sejour"'idsjour' => $sejour]);
  9794.         }
  9795.         if ($livreSej == null) {
  9796.             $livreSejour $em->getRepository(Produit::class)->findOneBy(['statut' => "Livre_sejour"'idsjour' => $sejour'labele' => $label'version' => "Livre_Admin"]);
  9797.         } else {
  9798.             $livreSejour $livreSej;
  9799.         }
  9800.         $attachementsCount $AllAttachements['total'] ?? 0;
  9801.         if (isset($AllAttachements['total'])) {
  9802.             unset($AllAttachements['total']);
  9803.         }
  9804.         $date = new \Datetime("midnight");
  9805.         $date->modify('+1 day');
  9806.         $date->modify('-1 seconds');
  9807.         // Share Booster - Calcul des statistiques du jour
  9808.         $today = new \DateTime('today');
  9809.         $tomorrow = new \DateTime('tomorrow');
  9810.         // Nombre d'uploads aujourd'hui par cet accompagnateur pour ce séjour
  9811.         $todayUploadedCount $em->getRepository(\App\Entity\SejourAttachment::class)
  9812.             ->createQueryBuilder('sa')
  9813.             ->select('COUNT(sa.id)')
  9814.             ->where('sa.idSejour = :sejourId')
  9815.             ->andWhere('sa.dateDepotAttachement >= :today')
  9816.             ->andWhere('sa.dateDepotAttachement < :tomorrow')
  9817.             ->setParameter('sejourId'$idSejour)
  9818.             ->setParameter('today'$today)
  9819.             ->setParameter('tomorrow'$tomorrow)
  9820.             ->getQuery()
  9821.             ->getSingleScalarResult();
  9822.         // Nombre total d'uploads aujourd'hui par tous les accompagnateurs (collectif)
  9823.         $collectiveTodayCount $em->getRepository(\App\Entity\SejourAttachment::class)
  9824.             ->createQueryBuilder('sa')
  9825.             ->select('COUNT(sa.id)')
  9826.             ->where('sa.dateDepotAttachement >= :today')
  9827.             ->andWhere('sa.dateDepotAttachement < :tomorrow')
  9828.             ->setParameter('today'$today)
  9829.             ->setParameter('tomorrow'$tomorrow)
  9830.             ->getQuery()
  9831.             ->getSingleScalarResult();
  9832.         // Objectif du jour (peut être personnalisé selon la structure)
  9833.         $targetDaily 15;
  9834.         // Vérifier si le séjour est terminé
  9835.         $sejourTermine $sejour->getDateFinSejour() < new \DateTime('today');
  9836.         // Vérifier si le séjour n'a pas encore commencé
  9837.         $sejourPasEncoreCommence $sejour->getDateDebutSejour() > new \DateTime('today');
  9838.         // Vérifier si on est après J+3 (3 jours après la fin du séjour)
  9839.         $dateFinSejourPlus3 = clone $sejour->getDateFinSejour();
  9840.         $dateFinSejourPlus3->modify('+3 days');
  9841.         $afterJplus3 = new \DateTime('today') > $dateFinSejourPlus3;
  9842.         // Calculer le total des parents et likes
  9843.         $totalParent $SEjourService->getTotalParent($idSejour);
  9844.         $totalLikes $SEjourService->getTotalLikesSejour($idSejour);
  9845.         $counts $SEjourService->countAll($idSejour);
  9846.         // Calculer les photos et messages du jour
  9847.         $photosDuJour 0;
  9848.         $messagesDuJour 0;
  9849.         foreach ($AllAttachements as $attach) {
  9850.             if (isset($attach['date_depot_attachement']) && $attach['date_depot_attachement'] instanceof \DateTime) {
  9851.                 if ($attach['date_depot_attachement']->format('Y-m-d') === $today->format('Y-m-d')) {
  9852.                     $photosDuJour++;
  9853.                 }
  9854.             }
  9855.         }
  9856.         foreach ($messages as $message) {
  9857.             if (isset($message['date_depot_attachement']) && $message['date_depot_attachement'] instanceof \DateTime) {
  9858.                 if ($message['date_depot_attachement']->format('Y-m-d') === $today->format('Y-m-d')) {
  9859.                     $messagesDuJour++;
  9860.                 }
  9861.             }
  9862.         }
  9863.         return $this->render('Parent/DetailsSejourAcc.html.twig', [
  9864.             "sejour" => $sejour,
  9865.             'listeattach' => $AllAttachements,
  9866.             'attachementsCount' => $attachementsCount,
  9867.             'albumAcc' => $albumAcc,
  9868.             "livreSejour" => $livreSejour,
  9869.             'nbImages' => $nbImages,
  9870.             'positions' => $positions,
  9871.             'dateexpretise' => $date,
  9872.             'messages' => $messages,
  9873.             'like' => $listeattachlikephoto,
  9874.             'nblike' => count($listeattachlikephoto),
  9875.             'photoLikes' => $photoLikes,
  9876.             'datefincode' => $sejour->getDateFinCode(),
  9877.             // Share Booster variables
  9878.             'targetDaily' => $targetDaily,
  9879.             'todayUploadedCount' => $todayUploadedCount,
  9880.             'collectiveTodayCount' => $collectiveTodayCount,
  9881.             // Variables Dashboard
  9882.             'sejourTermine' => $sejourTermine,
  9883.             'sejourPasEncoreCommence' => $sejourPasEncoreCommence,
  9884.             'afterJplus3' => $afterJplus3,
  9885.             'totalParent' => $totalParent,
  9886.             'totalLikes' => $totalLikes,
  9887.             'counts' => $counts,
  9888.             'photosDuJour' => $photosDuJour,
  9889.             'messagesDuJour' => $messagesDuJour,
  9890.         ]);
  9891.     }
  9892. }