src/Service/SejourService.php line 1703

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. /**
  4.  * Created by PhpStorm.
  5.  * desc:  Service Sejout  ;
  6.  *
  7.  */
  8. use App\Entity\Emailing;
  9. use App\Entity\SejourAttachment;
  10. use App\Service\EmailsCmdService;
  11. use Swift_Image;
  12. use Twig\Environment;
  13. use App\Entity\Sejour;
  14. use App\Entity\Produit;
  15. use App\Entity\Attachment;
  16. use App\Entity\Commande;
  17. use App\Entity\PromoParents;
  18. use App\Entity\PromoSejour;
  19. use App\Entity\ComandeProduit;
  20. use App\Entity\ParentSejour;
  21. use App\Entity\Ref;
  22. use App\Entity\Position;
  23. use App\Entity\Likephoto;
  24. use App\Entity\User;
  25. use App\Entity\Etablisment;
  26. use App\Entity\Jourdescripdate;
  27. use App\Entity\LogPromotions;
  28. use App\Entity\PanierProduit;
  29. use App\Entity\Promotions;
  30. use Swift_Attachment;
  31. use setasign\Fpdi\Fpdi;
  32. use setasign\Fpdi\PdfReader;
  33. use Symfony\Component\HttpKernel\KernelInterface;
  34. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  35. use \DatePeriod;
  36. use \DateInterval;
  37. use DateTime;
  38. use Doctrine\Persistence\ManagerRegistry;
  39. use Symfony\Contracts\HttpClient\HttpClientInterface;
  40. use App\Repository\AttachmentRepository;
  41. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  42. use Symfony\Component\Mailer\MailerInterface;
  43. use Symfony\Component\Mime\Address;
  44. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  45. class SejourService
  46. {
  47.     private $em;
  48.     private $mailer;
  49.  
  50.     private $templating;
  51.     private $projectDir;
  52.     private $params;
  53.     private $client;
  54.     private $emailsCmdService;
  55.     private $sejourAttachmentRepository;
  56.     private $mailerInterface;
  57.     public function __construct(ManagerRegistry $em\Swift_Mailer $mailerEnvironment $templatingKernelInterface $kernelParameterBagInterface $paramsHttpClientInterface $clientAttachmentRepository $sejourAttachmentRepositoryEmailsCmdService $emailsCmdService\Swift_Mailer $mailerInterface)
  58.     {
  59.         $this->em $em;
  60.         $this->mailer $mailer;
  61.       
  62.         $this->templating $templating;
  63.         $this->projectDir $kernel->getProjectDir();
  64.         $this->params $params;
  65.       
  66.         $this->client $client;
  67.         $this->sejourAttachmentRepository $sejourAttachmentRepository;
  68.         $this->emailsCmdService $emailsCmdService;
  69.         $this->mailerInterface $mailerInterface;
  70.     }
  71.     function CreationNouveauSejour($themSejour$adressSejour$codePostal$dateDebut$FinSejour$AgeDugroupe$type$userid$NbEnfant$connpay$pays$ville$prixcnxparent null$prixcnxpartenaire null$reversecnxpart null$reverseventepart null)
  72.     {
  73.         $sejour = new Sejour();
  74.         $sejour->setCodeSejour($this->GenrateCodeSejour($type$connpay));
  75.         $sejour->setDateCreationCode(new \DateTime());
  76.         $sejour->setThemSejour($themSejour);
  77.         $sejour->setAdresseSejour($adressSejour);
  78.         if ($codePostal == "") {
  79.             $codePostal 0;
  80.         }
  81.         $sejour->setCodePostal($codePostal);
  82.         $dateDebutFormat date_create_from_format('Y-m-d'$dateDebut);
  83.         $sejour->setDateDebutSejour($dateDebutFormat);
  84.         $FinSejourSejour date_create_from_format('Y-m-d'$FinSejour);
  85.         $sejour->setDateFinSejour($FinSejourSejour);
  86.         $FinSejourSejour->modify('+2 month');
  87.         $sejour->setDateFinCode($FinSejourSejour);
  88.         $Statut $this->em->getRepository(Ref::class)->findOneBy(array('libiller' => "Crée"));
  89.         $sejour->setStatut($Statut);
  90.         $AgeDugroupeRef $this->em->getRepository(Ref::class)->findOneBy(array('libiller' => $AgeDugroupe));
  91.         $sejour->setAgeGroup($AgeDugroupeRef);
  92.         $sejour->setNbenfan($NbEnfant);
  93.         $sejour->setNbenfantencours($NbEnfant);
  94.         $sejour->setPays($pays);
  95.         $sejour->setVille($ville);
  96.         $sejour->setPrixcnxparent($prixcnxparent);
  97.         $sejour->setPrixcnxpartenaire($prixcnxpartenaire);
  98.         $sejour->setReversecnxpart($reversecnxpart);
  99.         $sejour->setReverseventepart($reverseventepart);
  100.         //setif sejour gratuie ou non
  101.         $sejour->setPaym($connpay);
  102.         $this->em->getManager()->persist($sejour);
  103.         $this->em->getManager()->flush();
  104.         return $sejour;
  105.     }
  106.     function CreationNouveauSejourParAccompagnateur($themSejour$adressSejour$dateDebut$FinSejour$AgeDugroupe$type$NbEnfant$connpay$pays$ville$prixcnxparent$prixcnxpartenaire$reversecnxpart$reverseventepart)
  107.     {
  108.         $sejour = new Sejour();
  109.         $sejour->setCodeSejour($this->GenrateCodeSejour($type$connpay));
  110.         $sejour->setDateCreationCode(new \DateTime());
  111.         $sejour->setThemSejour($themSejour);
  112.         $sejour->setAdresseSejour($adressSejour);
  113.         $dateDebutFormat date_create_from_format('Y-m-d'$dateDebut);
  114.         $sejour->setDateDebutSejour($dateDebutFormat);
  115.         $FinSejourSejour date_create_from_format('Y-m-d'$FinSejour);
  116.         $dateFinCode = new \DateTime($FinSejour);
  117.         $dateFinCode->modify('+2 month');
  118.         $sejour->setDateFinCode($dateFinCode);
  119.         $sejour->setDateFinSejour($FinSejourSejour);
  120.         $Statut $this->em->getRepository(Ref::class)->findOneBy(array('libiller' => "Crée"));
  121.         $sejour->setStatut($Statut);
  122.         $AgeDugroupeRef $this->em->getRepository(Ref::class)->findOneBy(array('libiller' => $AgeDugroupe));
  123.         $sejour->setAgeGroup($AgeDugroupeRef);
  124.         $sejour->setNbenfan($NbEnfant);
  125.         $sejour->setNbenfantencours($NbEnfant);
  126.         $sejour->setPays($pays);
  127.         $sejour->setVille($ville);
  128.         $sejour->setPrixcnxparent($prixcnxparent);
  129.         $sejour->setPrixcnxpartenaire($prixcnxpartenaire);
  130.         $sejour->setReversecnxpart($reversecnxpart);
  131.         $sejour->setReverseventepart($reverseventepart);
  132.         //set if sejour gratuie ou non 
  133.         $sejour->setPaym($connpay);
  134.         $this->em->getManager()->persist($sejour);
  135.         $this->em->getManager()->flush();
  136.         return $sejour;
  137.     }
  138.     function EnvoyerEmailCodeSejour($idSejour$TypeSejour)
  139.     {
  140.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  141.         $RefEmail $this->em->getRepository(Ref::class)->find(28);
  142.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  143.         $sendTo $Sejour->getIdEtablisment()->getEmail();
  144.         $message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
  145.             ->setFrom('contact@5sur5sejour.com')
  146.             ->setTo($sendTo);
  147.         //->setBcc(["contact@5sur5sejour.com"]);
  148.         $pathImage2 $Email->getIdImage2()->getPath();
  149.         $pathImage1 $Email->getIdImage1()->getPath();
  150.         $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  151.         $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  152.         $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  153.         $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  154.         $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  155.         $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  156.         $message->setBody(
  157.             $this->templating->render(
  158.                 'emails/SendCode.html.twig',
  159.                 [
  160.                     "code" => $Sejour->getCodeSejour(),
  161.                     "dateCreation" => $Sejour->getDateCreationCode(),
  162.                     "dateFinCode" => $Sejour->getDateFinCode(),
  163.                     "lieu" => $Sejour->getAdresseSejour(),
  164.                     "image1" => $image1,
  165.                     "image2" => $image2,
  166.                     "iconfooter" => $iconfooter,
  167.                     "iconphoto" => $iconphoto,
  168.                     "iconloca" => $iconloca,
  169.                     "iconmsg" => $iconmsg,
  170.                     "destinataire" => $Sejour->getIdEtablisment()->getNometab()
  171.                 ]
  172.             ),
  173.             'text/html'
  174.         );
  175.         $signMail $this->params->get('signMail');
  176.         if ($signMail == 'yes') {
  177.             $domainName $this->params->get('domaine');
  178.             $selector $this->params->get('selector');
  179.             $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  180.             $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  181.             $message->attachSigner($signer);
  182.         }
  183.         try {
  184.             $done $this->mailer->send($message);
  185.             //var_dump($done);  
  186.             // var_dump("send it ");
  187.         } catch (\Swift_SwiftException $ex) {
  188.             //var_dump( $ex->getMessage());
  189.         }
  190.     }
  191.     function EnvoyerEmailCodeSejourAccompagnateur($idSejour)
  192.     {
  193.         $logo '';
  194.         $nom '';
  195.         $RefEmail $this->em->getRepository(Ref::class)->find(21);
  196.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  197.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  198.         if ($Sejour) {
  199.             //dd($sejour);
  200.             $pdf1 = new Fpdi();
  201.             $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  202.             $pdfFilepath1 $publicDirectory "Mode_emploi_5sur5sejour_v5_.pdf";
  203.             $pageCount $pdf1->setSourceFile($pdfFilepath1);
  204.             $pageId $pdf1->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  205.             $pdf1->addPage();
  206.             $pdf1->useImportedPage($pageId0.50.50.5);
  207.             $testText  "abcdefghijklmnopqrstuvwxyz0123456789";
  208.             $current_date date('d-M-Y');
  209.             $DateDebut =  "";
  210.             $DateFin "";
  211.             $Theme "";
  212.             $Lieu "";
  213.             $CodeSejour =  "";
  214.             $MotPass =  "";
  215.             $Ville "";
  216.             $Paye "";
  217.             if ($Sejour) {
  218.                 $DateDebut $Sejour->getDateDebutSejour();
  219.                 $DateFin $Sejour->getDateFinSejour();
  220.                 $Theme $Sejour->getThemSejour();
  221.                 $Lieu $Sejour->getAdresseSejour();
  222.                 $CodeSejour $Sejour->getCodeSejour();
  223.                 $MotPass $Sejour->getIdAcommp()->getPasswordNonCripted();
  224.                 $Ville $Sejour->getVille();
  225.                 $Paye $Sejour->getPays();
  226.             }
  227.             for ($i 0$i $pageCount$i++) {
  228.                 $tplIdx $pdf->importPage($i 1);
  229.                 $pdf->useTemplate($tplIdx00200300true);
  230.                 $theme $Theme;
  231.                 if (strlen($theme) > 25) {
  232.                     $pdf->SetFont("Arial"""5);
  233.                 } else {
  234.                     $pdf->SetFont("Arial"""7);
  235.                 }
  236.                 $strTheme iconv("UTF-8""WINDOWS-1252"$theme);
  237.                 $pdf->Text(35268$strTheme);
  238.                 $pdf->SetFont("Arial"""8);
  239.                 $lieu $Lieu;
  240.                 $ville $Ville;
  241.                 $paye $Paye;
  242.                 if ($Paye && $Ville) {
  243.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville "  " $paye);
  244.                     $pdf->Text(125268$strLieu);
  245.                 } else if ($Paye) {
  246.                     $strLieu iconv("UTF-8""WINDOWS-1252"$paye);
  247.                     $pdf->Text(125268$strLieu);
  248.                 } else {
  249.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville);
  250.                     $pdf->Text(125268$strLieu);
  251.                 }
  252.                 $pdf->SetFont("Arial"""10);
  253.                 $pdf->Text(80279$CodeSejour);
  254.                 $pdf->SetFont("Arial"""10);
  255.                 $pdf->Text(48258$DateDebut->format('d/m/Y'));
  256.                 $pdf->SetFont("Arial"""10);
  257.                 $pdf->Text(89258$DateFin->format('d/m/Y'));
  258.             }
  259.             if ($paym == 1) {
  260.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  261.                 $pdfFilepath $publicDirectory "Mode d'emploi parent  5sur5séjour" $idSejour ".pdf";
  262.                 $pdf->Output($pdfFilepath"F");
  263.             } else {
  264.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  265.                 $pdfFilepath $publicDirectory "Mode d'emploi parent G 5sur5séjour " $idSejour ".pdf";
  266.                 $pdf->Output($pdfFilepath"F");
  267.             }
  268.             $logo $Sejour->getIdEtablisment()->getLogo();
  269.             $nom $Sejour->getIdEtablisment()->getNometab();
  270.             $sendTo $Sejour->getIdAcommp()->getReponseemail();
  271.             $message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
  272.                 ->setFrom('contact@5sur5sejour.com')
  273.                 ->setTo($sendTo);
  274.             //->setBcc(["contact@5sur5sejour.com"]);
  275.             $pathImage2 $Email->getIdImage2()->getPath();
  276.             $pathImage1 $Email->getIdImage1()->getPath();
  277.             $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  278.             $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  279.             $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  280.             $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  281.             $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  282.             $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  283.             if ($paym == 1) {
  284.                 $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  285.                 $message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
  286.             } else {
  287.                 $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  288.                 $message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
  289.             }
  290.             $message->setBody(
  291.                 $this->templating->render(
  292.                     'emails/SendCode.html.twig',
  293.                     [
  294.                         "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  295.                         "code" => $Sejour->getCodeSejour(),
  296.                         "dateCreation" => $Sejour->getDateCreationCode(),
  297.                         "dateFinCode" => $Sejour->getDateFinCode(),
  298.                         "lieu" => $Sejour->getAdresseSejour(),
  299.                         "image1" => $image1,
  300.                         "image2" => $image2,
  301.                         "iconfooter" => $iconfooter,
  302.                         "iconphoto" => $iconphoto,
  303.                         "iconloca" => $iconloca,
  304.                         "iconmsg" => $iconmsg,
  305.                         'logo' => $logo,
  306.                         'nom' => $nom,
  307.                         "identifiant" => $Sejour->getCodeSejour(),
  308.                         'roles' => $Sejour->getIdAcommp()->getRoles(),
  309.                     ]
  310.                 ),
  311.                 'text/html'
  312.             );
  313.             $signMail $this->params->get('signMail');
  314.             if ($signMail == 'yes') {
  315.                 $domainName $this->params->get('domaine');
  316.                 $selector $this->params->get('selector');
  317.                 $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  318.                 $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  319.                 $message->attachSigner($signer);
  320.             }
  321.             try {
  322.                 $this->mailer->send($message);
  323.             } catch (\Swift_SwiftException $ex) {
  324.                 $ex->getMessage();
  325.             }
  326.         }
  327.     }
  328.     function EnvoyerEmailNewAcco($emailsend$accompagnateur$idSejour$passAcommpa)
  329.     {
  330.         $RefEmail $this->em->getRepository(Ref::class)->find(16);
  331.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  332.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  333.         $sendTo $accompagnateur->getEmail();
  334.         $message = (new \Swift_Message('Bienvenue à 5sur5 séjour '))
  335.             ->setFrom('contact@5sur5sejour.com')
  336.             ->setTo($emailsend);
  337.         //->setBcc(["contact@5sur5sejour.com"]);
  338.         $pathImage2 $Email->getIdImage2()->getPath();
  339.         $pathImage1 $Email->getIdImage1()->getPath();
  340.         $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  341.         $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  342.         $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  343.         $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  344.         $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  345.         $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  346.         $message->setBody(
  347.             $this->templating->render(
  348.                 'emails/DemandeCreationAcc.html.twig',
  349.                 [
  350.                     "Nomdestinataire" => $accompagnateur->getNom(),
  351.                     "Predestinataire" => $accompagnateur->getPrenom(),
  352.                     "code" => $Sejour->getCodeSejour(),
  353.                     "image1" => $image1,
  354.                     "image2" => $image2,
  355.                     "iconfooter" => $iconfooter,
  356.                     "iconphoto" => $iconphoto,
  357.                     "iconloca" => $iconloca,
  358.                     "iconmsg" => $iconmsg,
  359.                     "identifiant" => $sendTo,
  360.                     "roles" => $accompagnateur->getRoles(),
  361.                     'accompagnateur' => $accompagnateur,
  362.                     "passAcommpa" => $passAcommpa,
  363.                 ]
  364.             ),
  365.             'text/html'
  366.         );
  367.         $signMail $this->params->get('signMail');
  368.         if ($signMail == 'yes') {
  369.             $domainName $this->params->get('domaine');
  370.             $selector $this->params->get('selector');
  371.             $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  372.             $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  373.             $message->attachSigner($signer);
  374.         }
  375.         try {
  376.             $this->mailer->send($message);
  377.         } catch (\Swift_SwiftException $ex) {
  378.             $ex->getMessage();
  379.         }
  380.     }
  381.     function EnvoyerEmailNewPartenaire($partenaire)
  382.     {
  383.         $logo '';
  384.         $nom '';
  385.         if ($partenaire->hasRole('ROLE_PARTENAIRE')) {
  386.             $logo $partenaire->getLogourl();
  387.             $nom $partenaire->getNometablisment();
  388.         }
  389.         $RefEmail $this->em->getRepository(Ref::class)->find(17);
  390.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail));
  391.         $sendTo $partenaire->getEmail();
  392.         $message = (new \Swift_Message('Nouveau partenaire'))
  393.             ->setFrom('partenariat-contact@5sur5sejour.com')
  394.             ->setTo($sendTo)
  395.             ->setBcc(["contact@5sur5sejour.com"]);
  396.         $pathImage2 $Email->getIdImage2()->getPath();
  397.         $pathImage1 $Email->getIdImage1()->getPath();
  398.         $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  399.         $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  400.         $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  401.         $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  402.         $icon2 $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  403.         $icon3 $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  404.         $message->setBody(
  405.             $this->templating->render(
  406.                 'emails/NewPartenaireEmail.html.twig',
  407.                 [
  408.                     "Nomdestinataire" => $partenaire->getNom(),
  409.                     "Predestinataire" => $partenaire->getPrenom(),
  410.                     "password" => $partenaire->getPasswordNonCripted(),
  411.                     "image1" => $image1,
  412.                     "image2" => $image2,
  413.                     "icon2" => $icon2,
  414.                     "icon3" => $icon3,
  415.                     "iconfooter" => $iconfooter,
  416.                     "iconmsg" => $iconmsg,
  417.                     "idPartenaire" => $partenaire->getId(),
  418.                     "identifiant" => $sendTo,
  419.                     "password" => $partenaire->getPasswordNonCripted(),
  420.                     'logo' => $logo,
  421.                     'nom' => $nom,
  422.                 ]
  423.             ),
  424.             'text/html'
  425.         );
  426.         $signMail $this->params->get('signMail');
  427.         if ($signMail == 'yes') {
  428.             $domainName $this->params->get('domaine');
  429.             $selector $this->params->get('selector');
  430.             $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  431.             $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  432.             $message->attachSigner($signer);
  433.         }
  434.         try {
  435.             $this->mailer->send($message);
  436.         } catch (\Swift_SwiftException $ex) {
  437.             $ex->getMessage();
  438.         }
  439.     }
  440.     function affecterEtablissement($sejour$etablissement)
  441.     {
  442.         $sejour->setIdEtablisment($etablissement);
  443.         $this->em->getManager()->persist($sejour);
  444.         $this->em->getManager()->flush();
  445.     }
  446.     function affecterAccompaniateur($sejour$accomp)
  447.     {
  448.         $sejour->setIdAcommp($accomp);
  449.         $this->em->getManager()->persist($sejour);
  450.         $this->em->getManager()->flush();
  451.     }
  452.     function affecterPartenaire($sejour$etabUser)
  453.     {
  454.         $sejour->setIdPartenaire($etabUser);
  455.         $this->em->getManager()->persist($sejour);
  456.         $this->em->getManager()->flush();
  457.     }
  458.     function affecteretablisment($sejour$Etablisment)
  459.     {
  460.         $sejour->setIdEtablisment($Etablisment);
  461.         $this->em->getManager()->persist($sejour);
  462.         $this->em->getManager()->flush();
  463.     }
  464.     function GenrateCodeSejour($type$connpay)
  465.     {
  466.         $Typeabr "IN";
  467.         $pay "";
  468.         if ($type == "ECOLES/AUTRES") {
  469.             $Typeabr "E";
  470.         } elseif ($type == "PARTENAIRES/VOYAGISTES") {
  471.             $Typeabr "P";
  472.         } elseif ($type == "CSE") {
  473.             $Typeabr "C";
  474.         }
  475.         if ($connpay == 0) {
  476.             $pay "F";
  477.         }
  478.         if ($connpay == 1) {
  479.             $pay "P";
  480.         }
  481.         $date = new \Datetime();
  482.         $Milliseconde $date->format('u');
  483.         $code $Typeabr $pay $Milliseconde;
  484.         return $code;
  485.     }
  486.     function index($dateTimeDebut$dateTimeFin)
  487.     {
  488.         if ($dateTimeDebut == null) {
  489.             $Sejours $this->em->getRepository(Sejour::class)->searshAllSejour();
  490.             //  dd(count($Sejours));
  491.         } else {
  492.             $Sejours $this->em->getRepository(Sejour::class)->searshDate($dateTimeDebut$dateTimeFin);
  493.         }
  494.         return $Sejours;
  495.     }
  496.     function getsejour($id)
  497.     {
  498.         $Sejour $this->em->getRepository(Sejour::class)->find($id);
  499.         return $Sejour;
  500.     }
  501.     function getsejourByAcc($id$user)
  502.     {
  503.         $Sejour $this->em->getRepository(Sejour::class)->findOneBy(array("id" => $id"idAcommp" => $user));
  504.         return $Sejour;
  505.     }
  506.     function getsejourByItab($idEtablisment)
  507.     {
  508.         $Sejour $this->em->getRepository(Sejour::class)->findBy(array("idEtablisment" => $idEtablisment));
  509.         return $Sejour;
  510.     }
  511.     function getNbreconnxparsejour($id)
  512.     {
  513.         $Sejourfind $this->em->getRepository(Sejour::class)->find($id);
  514.         if ((substr($Sejourfind->getCodeSejour(), 11) == 'P')) {
  515.             $Sejour $this->em->getRepository(ParentSejour::class)->findby(['idSejour' => $id'payment' => 1]);
  516.         } elseif ((substr($Sejourfind->getCodeSejour(), 11) == 'F')) {
  517.             $Sejour $this->em->getRepository(ParentSejour::class)->findby(['idSejour' => $id]);
  518.         }
  519.         $NB sizeof($Sejour);
  520.         return $NB;
  521.     }
  522.     //a terminier le nombre enfant par sejour
  523.     function Nbpersonnecnnx($id)
  524.     {
  525.         $Nbpconnx $this->em->getRepository(ComandeProduit::class)->searshNbpersoneparNbcnnx($id);
  526.         return $Nbpconnx;
  527.     }
  528.     function Nbpersonnesejour($id)
  529.     {
  530.         $Nbpersone $this->em->getRepository(ParentSejour::class)->searshNbperpersonneSjour($id);
  531.         return $Nbpersone;
  532.     }
  533.     function nombreenfantparsejour($id)
  534.     {
  535.         $Nbenfant $this->em->getRepository(sejour::class)->searshNbperson($id);
  536.         return $Nbenfant;
  537.     }
  538.     function Nbpecnnxsejourtype($type$date null)
  539.     {
  540.         if ($date == null) {
  541.             $Nbcnxnxpartype $this->em->getRepository(ParentSejour::class)->searshNBcnnxParSejour($type);
  542.         } else {
  543.             $Nbcnxnxpartype $this->em->getRepository(ParentSejour::class)->searshNBcnnxParSejourByDate($type$date);
  544.         }
  545.         return $Nbcnxnxpartype;
  546.     }
  547.     function Nbcommandepartypesejour($type$date null)
  548.     {
  549.         if ($date == null) {
  550.             $Nbdemandpartype $this->em->getRepository(ParentSejour::class)->searshNBcommandeParSejour($type);
  551.         } else {
  552.             $Nbdemandpartype $this->em->getRepository(ParentSejour::class)->searshNBcommandeParSejourByDate($type$date);
  553.         }
  554.         return $Nbdemandpartype;
  555.     }
  556.     function Moyenpainierpartypesejour($type$dateTimeDebut$dateTimeFin)
  557.     {
  558.         if ($dateTimeDebut == null || $dateTimeFin == null) {
  559.             $panier $this->em->getRepository(Produit::class)->searshPanierMoyen($type);
  560.         } else {
  561.             $panier $this->em->getRepository(Produit::class)->searshPanierMoyenByDate($type$dateTimeDebut$dateTimeFin);
  562.         }
  563.         return $panier;
  564.     }
  565.     public function typeproduitsevice($id)
  566.     {
  567.         $prod $this->em->getRepository(Produit::class)->findby(array('idsjour' => $id));
  568.         return $prod;
  569.     }
  570.     public function getatachmentsejour($id): array
  571.     {
  572.         $liste $this->em->getRepository(Attachment::class)->searshSejourAtachment($id);
  573.         return $liste;
  574.     }
  575.     /**
  576.      * Gets the list of attachements based on the sejour id and attachement type
  577.      * @param string $id The sejour id
  578.      * @param string $type The attachement type
  579.      * @return array The list of photos avec pagination
  580.      */
  581.     public function getCombinedattachSejourPaginee(string $idstring $type 'photo')
  582.     {
  583.         $liste = [];
  584.         $results $this->em->getRepository(SejourAttachment::class)->getSejourAttachByPhotoPagination($id$type);
  585.         return $results;
  586.     }
  587.     /**
  588.      * Gets the list of attachements based on the sejour id and attachement type
  589.      * @param string $id The sejour id
  590.      * @param string $type The attachement type
  591.      * @return array The list of attachements
  592.      */
  593.     /**
  594.      * Gets the list of attachements based on the sejour id, attachement type, and user id.
  595.      * 
  596.      * @param string $id The sejour id
  597.      * @param string $type The attachement type ('photo', 'photoVideo', 'message')
  598.      * @param int|null $userId The user id (optional, for checking favorites)
  599.      * @return array The list of attachements
  600.      */
  601.     public function getCombinedattachSejour_REVISION(string $idstring $type 'photo', ?int $userId null): array
  602.     {
  603.         // Récupérer les attachements pour le type 'photoVideo'
  604.         if ($type === 'photoVideo') {
  605.             $groupedAttachments = [];
  606.             $results $this->em->getRepository(SejourAttachment::class)->getSejourAttachById($id$type);
  607.             $attachCount count($results);
  608.             // Récupérer les favoris de l'utilisateur pour ces attachements
  609.             // Ajouter un champ 'isFavorite' à chaque photo
  610.             //$favorites = $this->em->getRepository(Likephoto::class)->searshlikephotousersejour($userId, $id);
  611.             foreach ($results as $result) {
  612.                 $attachmentId $result->getIdAttchment()->getId();
  613.                 $date $result->getDateDepotAttachement()->format('Y-m-d');
  614.                 $preListe = [
  615.                     'date_depot_attachement' => $result->getDateDepotAttachement(),
  616.                     'path'          => $result->getIdAttchment()->getPath(),
  617.                     'id_attchment'  => $attachmentId,
  618.                     'idposition'    => $result->getIdAttchment()->getIdposition(),
  619.                     'libiller'      => $result->getIdAttchment()->getIdref()->getLibiller(),
  620.                     'descreption'   => $result->getIdAttchment()->getDescreption(),
  621.                     'is_favorite'   => "",
  622.                 ];
  623.                 // Grouper par date
  624.                 if (!isset($groupedAttachments[$date])) {
  625.                     $groupedAttachments[$date] = [];
  626.                 }
  627.                 $groupedAttachments[$date][] = $preListe;
  628.             }
  629.             // Définir toujours 'total'
  630.             $groupedAttachments['total'] = $attachCount;
  631.             // Trier par date décroissante
  632.             uksort($groupedAttachments, fn($a$b) => strtotime($b) - strtotime($a));
  633.             return $groupedAttachments;
  634.         }
  635.         // Pour les types 'photo' et 'message'
  636.         $liste = [];
  637.         $results $type === 'photo' ?
  638.             $this->em->getRepository(SejourAttachment::class)->getSejourAttachByPhoto($id$type) :
  639.             $this->em->getRepository(SejourAttachment::class)->getSejourAttachByMessage($id$type);
  640.         // Récupérer les favoris de l'utilisateur
  641.         $favorites $this->getUserFavorites($userIdarray_map(fn($r) => $r->getIdAttchment()->getId(), $results));
  642.         foreach ($results as $result) {
  643.             $attachmentId $result->getIdAttchment()->getId();
  644.             $preListe = [
  645.                 'id' => $attachmentId,
  646.                 'date_depot_attachement' => $result->getDateDepotAttachement(),
  647.                 'path' => $result->getIdAttchment()->getPath(),
  648.                 'libiller' => $type,
  649.                 'descreption' => $type === 'message' $result->getIdAttchment()->getDescreption() : null,
  650.                 'is_favorite' => in_array($attachmentId$favorites)
  651.             ];
  652.             $liste[] = $preListe;
  653.         }
  654.         return ['total' => count($liste), 'attachments' => $liste];
  655.     }
  656.     /**
  657.      * Gets the list of attachements based on the sejour id, attachement type, and user id.
  658.      * 
  659.      * @param string $id The sejour id
  660.      * @param string $type The attachement type ('watermark', 'original', '900')
  661.      * @param int|null $userId The user id (optional, for checking favorites)
  662.      * @return array The list of attachements
  663.      */
  664.     public function getphotosVideosSejour(string $idstring $typeint $userId): array
  665.     {
  666.         $groupedAttachments = [];
  667.         $sejour $this->em->getRepository(Sejour::class)->findOneBy(['id' => $id]);
  668.         $dateDebut $sejour->getDateDebutSejour()->format('Y-m-d');
  669.         $dateFin $sejour->getDateFinSejour()->format('Y-m-d');
  670.         // Récupérer les messages audio
  671.         $messages $this->em->getRepository(SejourAttachment::class)->getSejourAttachByMessage($id"message");
  672.         // Récupérer les photos/vidéos
  673.         $results $this->em->getRepository(SejourAttachment::class)->getSejourAttachById($id"photoVideo");
  674.         $attachCount count($results);
  675.         // Récupérer les favoris de l'utilisateur
  676.         $favorites $this->getlikephotosejour($userId$id);
  677.         $favoritePhotoIds array_map(function ($fav) {
  678.             return $fav->getIdSejourAttchment()->getIdAttchment()->getId();
  679.         }, $favorites);
  680.         // Fusionner les messages audio avec les photos/vidéos
  681.         foreach (array_merge($messages$results) as $result) {
  682.             $attachmentId $result->getIdAttchment()->getId();
  683.             $date $result->getDateDepotAttachement()->format('Y-m-d');
  684.             $attchmentType $result->getIdAttchment()->getIdref()->getLibiller();
  685.             $path $result->getIdAttchment()->getPath();
  686.             if ($type == 'watermark' && $attchmentType == 'photo') {
  687.                 $path preg_replace(
  688.                     '/upload/',
  689.                     'upload/f_auto,q_auto,h_900/l_Logo5Sur5White_nh6tyk,o_10,fl_relative.tiled',
  690.                     $result->getIdAttchment()->getPath()
  691.                 );
  692.             } elseif ($type == 'original') {
  693.                 $path $result->getIdAttchment()->getPath();
  694.             }
  695.             $preListe = [
  696.                 'date_depot_attachement' => $result->getDateDepotAttachement(),
  697.                 'path' => $path,
  698.                 'id_attchment' => $attachmentId,
  699.                 'idposition' => $result->getIdAttchment()->getIdposition(),
  700.                 'libiller' => $result->getIdAttchment()->getIdref()->getLibiller(),
  701.                 'descreption' => $result->getIdAttchment()->getDescreption(),
  702.                 'is_favorite' => in_array($attachmentId$favoritePhotoIds),
  703.             ];
  704.             // Initialiser le groupe de la date si nécessaire
  705.             if (!isset($groupedAttachments[$date])) {
  706.                 $groupedAttachments[$date] = [
  707.                     'attachments' => [],
  708.                     'countPhotos' => 0,
  709.                     'countAudio' => 0,
  710.                     'countVideos' => 0,
  711.                     'isFirstDay' => ($date === $dateDebut) ? "yes" "no",
  712.                     'isLastDay' => ($date === $dateFin) ? "yes" "no",
  713.                 ];
  714.             }
  715.             $groupedAttachments[$date]['attachments'][] = $preListe;
  716.             // Incrémenter les compteurs en fonction du type d'attachement
  717.             $attachmentType $result->getIdAttchment()->getIdref()->getLibiller();
  718.             if ($attachmentType === 'photo') {
  719.                 $groupedAttachments[$date]['countPhotos']++;
  720.             } elseif ($attachmentType === 'video') {
  721.                 $groupedAttachments[$date]['countVideos']++;
  722.             } elseif ($attachmentType === 'message') {
  723.                 $groupedAttachments[$date]['countAudio']++;
  724.             }
  725.         }
  726.         // Trier les jours par date
  727.         uksort($groupedAttachments, function ($a$b) {
  728.             return strtotime($a) - strtotime($b); // Ascendant (pour descendant : strtotime($b) - strtotime($a))
  729.         });
  730.         // Ajouter le total des attachements
  731.         $groupedAttachments['total'] = $attachCount;
  732.         return $groupedAttachments;
  733.     }
  734.     /**
  735.      * Récupérer les favoris pour un utilisateur donné.
  736.      *
  737.      * @param int|null $userId
  738.      * @param array $attachmentIds
  739.      * @return array
  740.      */
  741.     private function getUserFavorites(?int $userId, array $attachmentIds): array
  742.     {
  743.         if (is_null($userId) || empty($attachmentIds)) {
  744.             return [];
  745.         }
  746.         $qb $this->em->createQueryBuilder()
  747.             ->select('l.idSejourAttchment')
  748.             ->from(Likephoto::class, 'l')
  749.             ->where('l.idUser = :userId')
  750.             ->andWhere('l.idSejourAttchment IN (:attachmentIds)')
  751.             ->setParameter('userId'$userId)
  752.             ->setParameter('attachmentIds'$attachmentIds);
  753.         $results $qb->getQuery()->getResult();
  754.         return array_map(fn($r) => $r['idSejourAttchment'], $results);
  755.     }
  756.     /**
  757.      * Gets the list of attachments based on the sejour id and attachment type
  758.      * @param string $id The sejour id
  759.      * @param string $type The attachment type
  760.      * @return array The list of attachments
  761.      */ /**
  762.      * Gets the list of attachements based on the sejour id and attachement type
  763.      * @param string $id The sejour id
  764.      * @param string $type The attachement type
  765.      * @return array The list of attachements
  766.      */
  767.     public function getCombinedattachSejour(string $idstring $type 'photo'): array
  768.     {
  769.         if ($type == 'photoVideo') {
  770.             $groupedAttachments = [];
  771.             $results $this->em->getRepository(SejourAttachment::class)->getSejourAttachById($id$type);
  772.             $attachCount count($results);
  773.             foreach ($results as $result) {
  774.                 $date $result->getDateDepotAttachement()->format('Y-m-d');
  775.                 $preListe = [
  776.                     'date_depot_attachement' => $result->getDateDepotAttachement(),
  777.                     'path'          => $result->getIdAttchment()->getPath(),
  778.                     'id_attchment'  => $result->getIdAttchment()->getId(),
  779.                     'idposition'    => $result->getIdAttchment()->getIdposition(),
  780.                     'libiller'      => $result->getIdAttchment()->getIdref()->getLibiller(),
  781.                     'descreption'   => $result->getIdAttchment()->getDescreption()
  782.                 ];
  783.                 // Group attachments by date
  784.                 if (!isset($groupedAttachments[$date])) {
  785.                     $groupedAttachments[$date] = [];
  786.                 }
  787.                 $groupedAttachments[$date][] = $preListe;
  788.             }
  789.             uksort($groupedAttachments, function ($a$b) {
  790.                 return strtotime($b) - strtotime($a);
  791.             });
  792.             if ($attachCount 0) {
  793.                 $groupedAttachments['total'] = $attachCount;
  794.             }
  795.             return $groupedAttachments;
  796.         }
  797.         if ($type == 'photo') {
  798.             $liste = [];
  799.             $results $this->em->getRepository(SejourAttachment::class)->getSejourAttachByPhoto($id$type);
  800.             foreach ($results as $result) {
  801.                 $preListe = [
  802.                     'id' => $result->getIdAttchment()->getId(),
  803.                     'date_depot_attachement' => $result->getDateDepotAttachement(),
  804.                     'path' => $result->getIdAttchment()->getPath()
  805.                 ];
  806.                 $liste[] = $preListe;
  807.             }
  808.             return $liste;
  809.         }
  810.         if ($type == 'message') {
  811.             $liste = [];
  812.             $results $this->em->getRepository(SejourAttachment::class)->getSejourAttachByMessage($id$type);
  813.             foreach ($results as $result) {
  814.                 $preListe = [
  815.                     'date_depot_attachement' => $result->getDateDepotAttachement(),
  816.                     'path' => $result->getIdAttchment()->getPath(),
  817.                     'id_attchment' => $result->getIdAttchment()->getId(),
  818.                     'idposition' => $result->getIdAttchment()->getIdposition(),
  819.                     'libiller' => $result->getIdAttchment()->getIdref()->getLibiller(),
  820.                     'descreption' => $result->getIdAttchment()->getDescreption()
  821.                 ];
  822.                 $liste[] = $preListe;
  823.             }
  824.             return $liste;
  825.         }
  826.     }
  827.     public function getatachmentsejourparent($id$idParent)
  828.     {
  829.         //$liste = $this->em->getRepository(SejourAttachment::class)->findBy(array('idSejour' => $id,'idParent'=>$idParent,'statut'=>"private"));
  830.         $liste $this->em->getRepository(Attachment::class)->searshSejourAtachmentEpaceParent($id$idParent);
  831.         return $liste;
  832.     }
  833.     public function getVideosejour($id)
  834.     {
  835.         $liste $this->em->getRepository(Attachment::class)->searshSejourVideo($id);
  836.         return $liste;
  837.     }
  838.     public function getsejourposition($id)
  839.     {
  840.         $liste $this->em->getRepository(Position::class)->searshSejourPosition($id);
  841.         return $liste;
  842.     }
  843.     public function getTotalParent($id)
  844.     {
  845.         $liste $this->em->getRepository(ParentSejour::class)->searshNbperpersonneSjour($id);
  846.         return $liste;
  847.     }
  848.     public function getTotalLikesSejour($id)
  849.     {
  850.         $liste $this->em->getRepository(Likephoto::class)->getTotalLikes($id);
  851.         return $liste;
  852.     }
  853.     public function countPhotos(int $sejourId): int
  854.     {
  855.         $result $this->sejourAttachmentRepository->CountsearshSejourAtachment($sejourId);
  856.         return isset($result[0]['COUNT(*)']) ? (int) $result[0]['COUNT(*)'] : 0;
  857.     }
  858.     public function countVideos(int $sejourId): int
  859.     {
  860.         $result $this->sejourAttachmentRepository->CountsearshSejourVideo($sejourId);
  861.         return isset($result[0]['COUNT(*)']) ? (int) $result[0]['COUNT(*)'] : 0;
  862.     }
  863.     public function countMessages(int $sejourId): int
  864.     {
  865.         $result $this->sejourAttachmentRepository->CountsearshSejourMessage($sejourId);
  866.         return isset($result[0]['COUNT(*)']) ? (int) $result[0]['COUNT(*)'] : 0;
  867.     }
  868.     /**
  869.      * Return all counts as an associative array.
  870.      */
  871.     public function countAll(int $sejourId): array
  872.     {
  873.         return [
  874.             'photos'   => $this->countPhotos($sejourId),
  875.             'videos'   => $this->countVideos($sejourId),
  876.             'messages' => $this->countMessages($sejourId),
  877.         ];
  878.     }
  879.     public function getsejourmessage($id)
  880.     {
  881.         $listeaudio $this->em->getRepository(Attachment::class)->searshSejourMessage($id);
  882.         return $listeaudio;
  883.     }
  884.     function NBpersonnayaoncomande($id)
  885.     {
  886.         $Nbpconnx $this->em->getRepository(ComandeProduit::class)->searshNbpersoneayontcomande($id);
  887.         return $Nbpconnx;
  888.     }
  889.     function montantttc($id)
  890.     {
  891.         $somme $this->em->getRepository(Commande::class)->searshMttc($id);
  892.         return $somme;
  893.     }
  894.     function affectationAttachement($idSejou$attachement)
  895.     {
  896.         $sejour $this->em->getRepository(Sejour::class)->find($idSejou);
  897.         $sejAattch = new SejourAttachment();
  898.         $sejAattch->setIdSejour($sejour);
  899.         $sejAattch->setIdAttchment($attachement);
  900.         $sejAattch->setDateDepotAttachement($attachement->getDate());
  901.         $sejAattch->setStatut("public");
  902.         $this->em->getManager()->persist($sejAattch);
  903.         $this->em->getManager()->flush();
  904.         return $sejAattch;
  905.     }
  906.     function monpropreattachement($idSejou$attachement$user)
  907.     {
  908.         $sejour $this->em->getRepository(Sejour::class)->find($idSejou);
  909.         $sejAattch = new SejourAttachment();
  910.         $sejAattch->setIdSejour($sejour);
  911.         $sejAattch->setIdAttchment($attachement);
  912.         $sejAattch->setDateDepotAttachement($attachement->getDate());
  913.         $sejAattch->setIdParent($user);
  914.         $sejAattch->setStatut("private");
  915.         $this->em->getManager()->persist($sejAattch);
  916.         $this->em->getManager()->flush();
  917.         return $sejAattch;
  918.     }
  919.     function affectationnbvisiteattachement($idSejou$idattachement)
  920.     {
  921.         $nbs 0;
  922.         $sejour $this->em->getRepository(Sejour::class)->find($idSejou);
  923.         $attachement $this->em->getRepository(Attachment::class)->find($idattachement);
  924.         $sejAattch $this->em->getRepository(SejourAttachment::class)->findOneBy(array('idAttchment' => $attachement'idSejour' => $sejour));
  925.         if ($sejAattch->getNbpartenaireattch() === null) {
  926.             $nbs 0;
  927.         } else {
  928.             $nbs $sejAattch->getNbpartenaireattch();
  929.         }
  930.         $sejAattch->setNbpartenaireattch($nbs 1);
  931.         $this->em->getManager()->persist($sejAattch);
  932.         $this->em->getManager()->flush();
  933.         return $sejAattch;
  934.     }
  935.     function EnvoyerEmailNewAccoNewSejour($emailacc$accompagnateur$idSejour$passAcommpa)
  936.     {
  937.         $RefEmail $this->em->getRepository(Ref::class)->find(21);
  938.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  939.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  940.         $sendTo $accompagnateur->getEmail();
  941.         $message = (new \Swift_Message('Bienvenue à 5sur5 séjour '))
  942.             ->setFrom('contact@5sur5sejour.com')
  943.             ->setTo($emailacc);
  944.         //->setBcc(["contact@5sur5sejour.com"]);
  945.         $pathImage2 $Email->getIdImage2()->getPath();
  946.         $pathImage1 $Email->getIdImage1()->getPath();
  947.         $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  948.         $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  949.         $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  950.         $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  951.         $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  952.         $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  953.         $message->setBody(
  954.             $this->templating->render(
  955.                 'emails/DemandeCreationAcc.html.twig',
  956.                 [
  957.                     "Nomdestinataire" => $accompagnateur->getNom(),
  958.                     "Predestinataire" => $accompagnateur->getPrenom(),
  959.                     "code" => $Sejour->getCodeSejour(),
  960.                     "dateCreation" => $Sejour->getDateCreationCode(),
  961.                     "dateFinCode" => $Sejour->getDateFinCode(),
  962.                     "lieu" => $Sejour->getAdresseSejour(),
  963.                     "image1" => $image1,
  964.                     "image2" => $image2,
  965.                     "iconfooter" => $iconfooter,
  966.                     "iconphoto" => $iconphoto,
  967.                     "iconloca" => $iconloca,
  968.                     "iconmsg" => $iconmsg,
  969.                     'roles' => $accompagnateur->getRoles(),
  970.                     "identifiant" => $Sejour->getCodeSejour(),
  971.                     'accompagnateur' => $accompagnateur,
  972.                     "passAcommpa" => $passAcommpa,
  973.                 ]
  974.             ),
  975.             'text/html'
  976.         );
  977.         $signMail $this->params->get('signMail');
  978.         if ($signMail == 'yes') {
  979.             $domainName $this->params->get('domaine');
  980.             $selector $this->params->get('selector');
  981.             $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  982.             $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  983.             $message->attachSigner($signer);
  984.         }
  985.         try {
  986.             $this->mailer->send($message);
  987.         } catch (\Swift_SwiftException $ex) {
  988.             $ex->getMessage();
  989.         }
  990.     }
  991.     // authentification parent 
  992.     function getsejourpourparent($id)
  993.     {
  994.         $Sejour $this->em->getRepository(Sejour::class)->find($id);
  995.         return $Sejour;
  996.     }
  997.     function getparentsejour($userId$idSejour)
  998.     {
  999.         $Sejour $this->em->getRepository(ParentSejour::class)->findOneBy(array('idParent' => $userId'idSejour' => $idSejour));
  1000.         return $Sejour;
  1001.     }
  1002.     function getlikephotosejour($userId$idSejour)
  1003.     {
  1004.         $liste $this->em->getRepository(Likephoto::class)->searshlikephotousersejour($userId$idSejour);
  1005.         return $liste;
  1006.     }
  1007.     function getTotallikesphotosejour($photoId$idSejour)
  1008.     {
  1009.         $liste $this->em->getRepository(Likephoto::class)->getTotalLikesForPhoto($photoId$idSejour);
  1010.         return $liste;
  1011.     }
  1012.     function getToutesLesphotoSejour($userId$idSejour)
  1013.     {
  1014.         $liste $this->em->getRepository(Likephoto::class)->searshlikephotousersejour($userId$idSejour);
  1015.         return $liste;
  1016.     }
  1017.     function inserparentsejour($userId$idSejour)
  1018.     {
  1019.         $user $this->em->getRepository(User::class)->find($userId);
  1020.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  1021.         $notifsms $user->getSmsnotif();
  1022.         $notifmail  $user->getMailnotif();
  1023.         $ParentSejour = new ParentSejour();
  1024.         if ($sejour->getNbenfan() == null || $sejour->getNbenfan() == || $sejour->getNbenfan() == NULL) {
  1025.             $ParentSejour->setFlagPrix(1);
  1026.         } else {
  1027.             if ((sizeof($sejour->getParentSejour()) < $sejour->getNbenfan()) && ((substr($sejour->getCodeSejour(), 11) == 'F'))) {
  1028.                 $ParentSejour->setFlagPrix(1);
  1029.             } elseif (substr($sejour->getCodeSejour(), 11) == 'F') {
  1030.                 $ParentSejour->setFlagPrix(0);
  1031.             }
  1032.         }
  1033.         $ParentSejour->setIdSejour($sejour);
  1034.         $ParentSejour->setIdParent($user);
  1035.         $ParentSejour->setSmsnotif($notifsms);
  1036.         if (strpos($sejour->getCodeSejour(), "EF") !== false) {
  1037.             $ParentSejour->setSmsnotif(0);
  1038.         }
  1039.         $ParentSejour->setMailnotif($notifmail);
  1040.         $ParentSejour->setDateCreation(new \DateTime());
  1041.         $ParentSejour->setPayment(0);
  1042.         $this->em->getManager()->persist($ParentSejour);
  1043.         $this->em->getManager()->flush();
  1044.         return $ParentSejour;
  1045.     }
  1046.     function inserparentsejourPayenet($userId$idSejour)
  1047.     {
  1048.         $parntsejour $this->em->getRepository(ParentSejour::class)->findOneBy(array('idParent' => $userId'idSejour' => $idSejour));
  1049.         if ($parntsejour == NULL) {
  1050.         }
  1051.         $parntsejour->setPayment(1);
  1052.         $this->em->getManager()->persist($parntsejour);
  1053.         $this->em->getManager()->flush();
  1054.         return $parntsejour;
  1055.     }
  1056.     function sejoursansattach($sejId)
  1057.     {
  1058.         $sejour $this->em->getRepository(Sejour::class)->find($sejId);
  1059.         return $sejour;
  1060.     }
  1061.     function EnvoyerEmailCodeSejourAccompagnateurviapartenaireenmasse($emailAcommpa$idSejour$TypeSejour$passAcommpa)
  1062.     {
  1063.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  1064.         $RefEmail $this->em->getRepository(Ref::class)->find(29);
  1065.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  1066.         $sendTo $emailAcommpa;
  1067.         $message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
  1068.             ->setFrom('contact@5sur5sejour.com')
  1069.             ->setTo($sendTo);
  1070.         // ->setBcc(["contact@5sur5sejour.com"]);
  1071.         $pathImage2 $Email->getIdImage2()->getPath();
  1072.         $pathImage1 $Email->getIdImage1()->getPath();
  1073.         $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  1074.         $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  1075.         $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  1076.         $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  1077.         $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  1078.         $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  1079.         $message->setBody(
  1080.             $this->templating->render(
  1081.                 'emails/Demandecreationacompaviapartenaire.html.twig',
  1082.                 [
  1083.                     "code" => $Sejour->getCodeSejour(),
  1084.                     "dateCreation" => $Sejour->getDateCreationCode(),
  1085.                     "dateFinCode" => $Sejour->getDateFinCode(),
  1086.                     "lieu" => $Sejour->getAdresseSejour(),
  1087.                     "image1" => $image1,
  1088.                     "image2" => $image2,
  1089.                     "iconfooter" => $iconfooter,
  1090.                     "iconphoto" => $iconphoto,
  1091.                     "iconloca" => $iconloca,
  1092.                     "iconmsg" => $iconmsg,
  1093.                     'passAcommpa' => $passAcommpa,
  1094.                     "destinataire" => $Sejour->getIdAcommp()->getUsername()
  1095.                 ]
  1096.             ),
  1097.             'text/html'
  1098.         );
  1099.         $signMail $this->params->get('signMail');
  1100.         if ($signMail == 'yes') {
  1101.             $domainName $this->params->get('domaine');
  1102.             $selector $this->params->get('selector');
  1103.             $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  1104.             $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  1105.             $message->attachSigner($signer);
  1106.         }
  1107.         try {
  1108.             $this->mailer->send($message);
  1109.         } catch (\Swift_SwiftException $ex) {
  1110.             $ex->getMessage();
  1111.         }
  1112.     }
  1113.     function EnvoyerEmailSejourAccompa($emailAcommpa$idSejour$TypeSejour$passAcommpa)
  1114.     {
  1115.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  1116.         $RefEmail $this->em->getRepository(Ref::class)->find(29);
  1117.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  1118.         $sendTo $emailAcommpa;
  1119.         $message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
  1120.             ->setFrom('contact@5sur5sejour.com')
  1121.             ->setTo($sendTo);
  1122.         //->setBcc(["contact@5sur5sejour.com"]);
  1123.         $pathImage2 $Email->getIdImage2()->getPath();
  1124.         $pathImage1 $Email->getIdImage1()->getPath();
  1125.         $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  1126.         $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  1127.         $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  1128.         $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  1129.         $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  1130.         $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  1131.         $message->setBody(
  1132.             $this->templating->render(
  1133.                 // Firas : completer Twig
  1134.                 'emails/EnvoyerEmailSejourAccompa.html.twig',
  1135.                 [
  1136.                     "code" => $Sejour->getCodeSejour(),
  1137.                     "dateCreation" => $Sejour->getDateCreationCode(),
  1138.                     "dateFinCode" => $Sejour->getDateFinCode(),
  1139.                     "lieu" => $Sejour->getAdresseSejour(),
  1140.                     "image1" => $image1,
  1141.                     "image2" => $image2,
  1142.                     "iconfooter" => $iconfooter,
  1143.                     "iconphoto" => $iconphoto,
  1144.                     "iconloca" => $iconloca,
  1145.                     "iconmsg" => $iconmsg,
  1146.                     'passAcommpa' => $passAcommpa,
  1147.                     "destinataire" => $Sejour->getIdAcommp()->getUsername()
  1148.                 ]
  1149.             ),
  1150.             'text/html'
  1151.         );
  1152.         $signMail $this->params->get('signMail');
  1153.         if ($signMail == 'yes') {
  1154.             $domainName $this->params->get('domaine');
  1155.             $selector $this->params->get('selector');
  1156.             $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  1157.             $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  1158.             $message->attachSigner($signer);
  1159.         }
  1160.         try {
  1161.             $this->mailer->send($message);
  1162.         } catch (\Swift_SwiftException $ex) {
  1163.             $ex->getMessage();
  1164.         }
  1165.     }
  1166.     function EnvoyerEmailSejourPartnaire($partnaire$etab2$err$ok$nomfilevalid$nomfileinvalid)
  1167.     {
  1168.         $logo '';
  1169.         $nom '';
  1170.         if ($partnaire->hasRole('ROLE_PARTENAIRE')) {
  1171.             $logo $partnaire->getLogourl();
  1172.             $nom $partnaire->getNometablisment();
  1173.         }
  1174.         $RefEmail $this->em->getRepository(Ref::class)->find(29);
  1175.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  1176.         $sendTo $partnaire->getEmail();
  1177.         $message = (new \Swift_Message('Vos codes séjour  5sur5Séjour'))
  1178.             ->setFrom('partenariat-contact@5sur5sejour.com')
  1179.             ->setTo($sendTo)
  1180.             ->setBcc(["contact@5sur5sejour.com"]);
  1181.         $pathImage2 $Email->getIdImage2()->getPath();
  1182.         $pathImage1 $Email->getIdImage1()->getPath();
  1183.         $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  1184.         $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  1185.         $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  1186.         $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  1187.         $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  1188.         $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  1189.         if ($ok 1) {
  1190.             $message->attach(Swift_Attachment::fromPath($this->projectDir '/public/message//' $nomfilevalid)->setFilename('Recap_Excel_' $etab2->getNometab() . '.xlsx'));
  1191.         }
  1192.         if ($err 1) {
  1193.             $message->attach(Swift_Attachment::fromPath($this->projectDir '/public/message//' $nomfileinvalid)->setFilename('Liste_Sejour_Invalide_' $etab2->getNometab() . '.xlsx'));
  1194.         }
  1195.         $message->setBody(
  1196.             $this->templating->render(
  1197.                 // Firas : completer Twig
  1198.                 'emails/EnvoyerEmailSejourPartnaire.html.twig',
  1199.                 [
  1200.                     "image1" => $image1,
  1201.                     "image2" => $image2,
  1202.                     "iconfooter" => $iconfooter,
  1203.                     "iconphoto" => $iconphoto,
  1204.                     "iconloca" => $iconloca,
  1205.                     "iconmsg" => $iconmsg,
  1206.                     'logo' => $logo,
  1207.                     'nom' => $nom,
  1208.                 ]
  1209.             ),
  1210.             'text/html'
  1211.         );
  1212.         $signMail $this->params->get('signMail');
  1213.         if ($signMail == 'yes') {
  1214.             $domainName $this->params->get('domaine');
  1215.             $selector $this->params->get('selector');
  1216.             $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  1217.             $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  1218.             $message->attachSigner($signer);
  1219.         }
  1220.         try {
  1221.             $this->mailer->send($message);
  1222.         } catch (\Swift_SwiftException $ex) {
  1223.             $ex->getMessage();
  1224.         }
  1225.     }
  1226.     function modif_lbel_Produit($id$lbel)
  1227.     {
  1228.         $Album $this->em->getRepository(Produit::class)->find($id);
  1229.         $Album->setLabele($lbel);
  1230.         $this->em->getManager()->persist($Album);
  1231.         $this->em->getManager()->flush();
  1232.     }
  1233.     function AugmenterNombreVu($array)
  1234.     {
  1235.         $sejourPartenaire $array[0]->getIdSejour()->getIdPartenaire();
  1236.         $etablism $this->em->getRepository(Etablisment::class)->findby(['user' => $sejourPartenaire]);
  1237.         $type $etablism[0]->getTypeetablisment();
  1238.         foreach ($array as $e) {
  1239.             if ($type == "ECOLES/AUTRES") {
  1240.                 if ($e->getNbecoleattch() == NULL) {
  1241.                     $e->setNbecoleattch(1);
  1242.                     $this->em->getManager()->persist($e);
  1243.                     $this->em->getManager()->flush();
  1244.                 } else {
  1245.                     $e->setNbecoleattch($e->getNbecoleattch() + 1);
  1246.                     $this->em->getManager()->persist($e);
  1247.                     $this->em->getManager()->flush();
  1248.                 }
  1249.             }
  1250.             if ($type == "CSE") {
  1251.                 if ($e->getNbconsomateurattch() == NULL) {
  1252.                     $e->setNbconsomateurattch(1);
  1253.                     $this->em->getManager()->persist($e);
  1254.                     $this->em->getManager()->flush();
  1255.                 } else {
  1256.                     $e->setNbconsomateurattch($e->getNbconsomateurattch() + 1);
  1257.                     $this->em->getManager()->persist($e);
  1258.                     $this->em->getManager()->flush();
  1259.                 }
  1260.             }
  1261.             if ($type == "PARTENAIRES/VOYAGISTES") {
  1262.                 if ($e->getNbpartenaireattch() == NULL) {
  1263.                     $e->setNbpartenaireattch(1);
  1264.                     $this->em->getManager()->persist($e);
  1265.                     $this->em->getManager()->flush();
  1266.                 } else {
  1267.                     $e->setNbpartenaireattch($e->getNbpartenaireattch() + 1);
  1268.                     $this->em->getManager()->persist($e);
  1269.                     $this->em->getManager()->flush();
  1270.                 }
  1271.             }
  1272.         }
  1273.     }
  1274.     function Nbrephotosejour($id)
  1275.     {
  1276.         $nombre $this->em->getRepository(SejourAttachment::class)->SearchNombrephotoonsejour($id);
  1277.         return $nombre;
  1278.     }
  1279.     function NombreMessageSejour($id)
  1280.     {
  1281.         $nombre $this->em->getRepository(SejourAttachment::class)->NombreMessageSejour($id);
  1282.         return $nombre;
  1283.     }
  1284.     function Nbpersone_commandepartypesejour($type$dateTimeDebut$dateTimeFin)
  1285.     {
  1286.         if ($dateTimeDebut == null || $dateTimeFin == null) {
  1287.             $Nbcnxnxpartype $this->em->getRepository(ComandeProduit::class)->Nbpersone_commandepartypesejoursansdate($type);
  1288.         } else {
  1289.             $Nbcnxnxpartype $this->em->getRepository(ComandeProduit::class)->Nbpersone_commandepartypesejourAvecdate($type$dateTimeDebut$dateTimeFin);
  1290.         }
  1291.         return $Nbcnxnxpartype;
  1292.     }
  1293.     function NombreConnexionParSejour($Sejours)
  1294.     {
  1295.         $NbParent $this->em->getRepository(ParentSejour::class)->findBy(array('idSejour' => $Sejours));
  1296.         return $NbParent;
  1297.     }
  1298.     function rechercheLesCommandesParSejour($Sejours)
  1299.     {
  1300.         $Commandes $this->em->getRepository(Commande::class)->findBy(array('idSejour' => $Sejours));
  1301.         return $Commandes;
  1302.     }
  1303.     function sejourParentcnx($idSejour$idParent)
  1304.     {
  1305.         $Sejour $this->em->getRepository(ParentSejour::class)->findOneBy(array("idSejour" => $idSejour"idParent" => $idParent));
  1306.         return $Sejour;
  1307.     }
  1308.     function EnvoyerEmailCodeSejourToPartenaireAndAcco($idSejour)
  1309.     {
  1310.         $logo '';
  1311.         $nom '';
  1312.         $RefEmail $this->em->getRepository(Ref::class)->find(21);
  1313.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  1314.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  1315.         
  1316.         if ($sejour) {
  1317.             // Génération des PDFs
  1318.             $pdf1 = new Fpdi();
  1319.             $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  1320.             $pdfFilepath1 $publicDirectory "Mode_emploi_5sur5sejour_v5_.pdf";
  1321.             $pageCount $pdf1->setSourceFile($pdfFilepath1);
  1322.             
  1323.             // Pour chaque page du PDF source
  1324.             for ($i 1$i <= $pageCount$i++) {
  1325.                 $pageId $pdf1->importPage($iPdfReader\PageBoundaries::MEDIA_BOX);
  1326.                 $pdf1->addPage();
  1327.                 $pdf1->useImportedPage($pageId);
  1328.                 
  1329.                 // Ajouter le contenu uniquement sur la première page
  1330.                 if ($i === 1) {
  1331.                     $pdf1->SetFont('Helvetica'''12);
  1332.                     $pdf1->SetTextColor(000);
  1333.                     
  1334.                     // Position pour le code séjour
  1335.                     $pdf1->SetXY(50100);
  1336.                     $pdf1->Write(0"Code séjour : " $sejour->getCodeSejour());
  1337.                     
  1338.                     // Position pour le mot de passe
  1339.                     $pdf1->SetXY(50120);
  1340.                     $pdf1->Write(0"Mot de passe : " $sejour->getIdAcommp()->getPasswordNonCripted());
  1341.                     
  1342.                     // Informations du séjour
  1343.                     $pdf1->SetXY(50140);
  1344.                     $pdf1->Write(0"Dates : du " $sejour->getDateDebutSejour()->format('d/m/Y') . " au " $sejour->getDateFinSejour()->format('d/m/Y'));
  1345.                     
  1346.                     $pdf1->SetXY(50160);
  1347.                     $pdf1->Write(0"Thème : " $sejour->getThemSejour());
  1348.                     
  1349.                     $pdf1->SetXY(50180);
  1350.                     $pdf1->Write(0"Lieu : " $sejour->getAdresseSejour());
  1351.                     
  1352.                     $pdf1->SetXY(50200);
  1353.                     $pdf1->Write(0"Ville : " $sejour->getVille());
  1354.                     
  1355.                     $pdf1->SetXY(50220);
  1356.                     $pdf1->Write(0"Pays : " $sejour->getPays());
  1357.                 }
  1358.             }
  1359.             
  1360.             $pdfFilepath1Output $publicDirectory "Mode d'emploi 5sur5sejour" $sejour->getId() . ".pdf";
  1361.             $pdf1->Output($pdfFilepath1Output"F");
  1362.             
  1363.             // Génération du deuxième PDF
  1364.             $pdf = new Fpdi();
  1365.             $paym $sejour->getPaym();
  1366.             
  1367.             if ($paym == 1) {
  1368.                 $pdfFilepathSource $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
  1369.             } else {
  1370.                 $pdfFilepathSource $publicDirectory "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
  1371.             }
  1372.             
  1373.             $pageCount $pdf->setSourceFile($pdfFilepathSource);
  1374.             
  1375.             // Pour chaque page du PDF source
  1376.             for ($i 1$i <= $pageCount$i++) {
  1377.                 $pageId $pdf->importPage($iPdfReader\PageBoundaries::MEDIA_BOX);
  1378.                 $pdf->addPage();
  1379.                 $pdf->useImportedPage($pageId);
  1380.                 
  1381.                 // Ajouter le contenu uniquement sur la première page
  1382.                 if ($i === 1) {
  1383.                     $pdf->SetFont('Helvetica'''12);
  1384.                     $pdf->SetTextColor(000);
  1385.                     
  1386.                     // Position pour le code séjour
  1387.                     $pdf->SetXY(50100);
  1388.                     $pdf->Write(0"Code séjour : " $sejour->getCodeSejour());
  1389.                     
  1390.                     // Informations du séjour
  1391.                     $pdf->SetXY(50120);
  1392.                     $pdf->Write(0"Dates : du " $sejour->getDateDebutSejour()->format('d/m/Y') . " au " $sejour->getDateFinSejour()->format('d/m/Y'));
  1393.                     
  1394.                     $pdf->SetXY(50140);
  1395.                     $pdf->Write(0"Thème : " $sejour->getThemSejour());
  1396.                     
  1397.                     $pdf->SetXY(50160);
  1398.                     $pdf->Write(0"Lieu : " $sejour->getAdresseSejour());
  1399.                     
  1400.                     $pdf->SetXY(50180);
  1401.                     $pdf->Write(0"Ville : " $sejour->getVille());
  1402.                     
  1403.                     $pdf->SetXY(50200);
  1404.                     $pdf->Write(0"Pays : " $sejour->getPays());
  1405.                 }
  1406.             }
  1407.             
  1408.             if ($paym == 1) {
  1409.                 $pdfFilepathOutput $publicDirectory "Mode d'emploi parent 5sur5séjour" $sejour->getId() . ".pdf";
  1410.             } else {
  1411.                 $pdfFilepathOutput $publicDirectory "Mode d'emploi parent G 5sur5séjour " $sejour->getId() . ".pdf";
  1412.             }
  1413.             $pdf->Output($pdfFilepathOutput"F");
  1414.             
  1415.             // Envoi des emails avec EmailsCmdService
  1416.             if ($sejour->getIdEtablisment()) {
  1417.                 // Déterminer l'email du partenaire
  1418.                 if (!is_null($sejour->getIdEtablisment()->getEmail())) {
  1419.                     $emailPartenaire $sejour->getIdEtablisment()->getEmail();
  1420.                 } else {
  1421.                     $emailPartenaire $sejour->getIdPartenaire()->getEmail();
  1422.                 }
  1423.                 
  1424.                 // Récupérer le logo et le nom
  1425.                 $logo $sejour->getIdEtablisment()->getLogo();
  1426.                 $nom $sejour->getIdEtablisment()->getNometab();
  1427.                 
  1428.                 // Préparer les données pour le template
  1429.                 $extraDataPartenaire = [
  1430.                     "Password" => $sejour->getIdAcommp()->getPasswordNonCripted(),
  1431.                     "code" => $sejour->getCodeSejour(),
  1432.                     "dateCreation" => $sejour->getDateCreationCode(),
  1433.                     "dateFinCode" => $sejour->getDateFinCode(),
  1434.                     "lieu" => $sejour->getAdresseSejour(),
  1435.                     "identifiant" => $sejour->getCodeSejour(),
  1436.                     "theme" => $sejour->getThemSejour(),
  1437.                     "ville" => $sejour->getVille(),
  1438.                     "pays" => $sejour->getPays(),
  1439.                     "dateDebut" => $sejour->getDateDebutSejour(),
  1440.                     "dateFin" => $sejour->getDateFinSejour(),
  1441.                     "motPass" => $sejour->getIdAcommp()->getPasswordNonCripted(),
  1442.                    
  1443.                     'roles' => $sejour->getIdEtablisment()->getUser()->getRoles(),
  1444.                     'fichiers' => [
  1445.                         $pdfFilepathOutput,
  1446.                         $pdfFilepath1Output
  1447.                     ]
  1448.                 ];
  1449.                 
  1450.                 // Envoyer l'email au partenaire
  1451.                 $this->emailsCmdService->sendMail(
  1452.                     $emailPartenaire,
  1453.                     '🔐 Code séjour + mot de passe – Connectez-vous à votre espace 5sur5séjour',
  1454.                     'EnvoiCodeSejourUniquementToAccoAndPartenaire',
  1455.                     $extraDataPartenaire,
  1456.                     ['bcc' => 'contact@5sur5sejour.com']
  1457.                 );
  1458.                 
  1459.                 // Envoyer l'email à l'accompagnateur si différent du partenaire
  1460.                 if ($emailPartenaire != $sejour->getIdAcommp()->getReponseemail()) {
  1461.                     $emailAcco $sejour->getIdAcommp()->getReponseemail();
  1462.                     
  1463.                     // Préparer les données pour l'accompagnateur
  1464.                     $extraDataAcco = [
  1465.                         "Password" => $sejour->getIdAcommp()->getPasswordNonCripted(),
  1466.                         "code" => $sejour->getCodeSejour(),
  1467.                         "dateCreation" => $sejour->getDateCreationCode(),
  1468.                         "dateFinCode" => $sejour->getDateFinCode(),
  1469.                         "lieu" => $sejour->getAdresseSejour(),
  1470.                         'theme' => $sejour->getThemSejour(),
  1471.                         'ville' => $sejour->getVille(),
  1472.                         'pays' => $sejour->getPays(),   
  1473.                         'dateDebut' => $sejour->getDateDebutSejour(),
  1474.                         'dateFin' => $sejour->getDateFinSejour(),
  1475.                         "identifiant" => $sejour->getCodeSejour(),
  1476.                         "motPass" => $sejour->getIdAcommp()->getPasswordNonCripted(),
  1477.                         
  1478.                         'logo' => $logo,
  1479.                         'nom' => $nom,
  1480.                         'image1' => $image1,
  1481.                         'image2' => $image2,
  1482.                         'iconphoto' => $iconphoto,
  1483.                         'iconfooter' => $iconfooter,
  1484.                         'iconmsg' => $iconmsg,
  1485.                         'roles' => $sejour->getIdAcommp()->getRoles(),
  1486.                         'fichiers' => [
  1487.                             $pdfFilepathOutput,
  1488.                             $pdfFilepath1Output
  1489.                         ]
  1490.                     ];
  1491.                     
  1492.                     // Envoyer l'email à l'accompagnateur
  1493.                     $this->emailsCmdService->sendMail(
  1494.                         $emailAcco,
  1495.                         '🔐 Code séjour + mot de passe – Connectez-vous à votre espace 5sur5séjour',
  1496.                         'EnvoiCodeSejourUniquementToAccoAndPartenaire',
  1497.                         $extraDataAcco
  1498.                     );
  1499.                 }
  1500.             }
  1501.         }
  1502.         
  1503.         return true;
  1504.     }
  1505.     function EnvoyerEmailOKActivation_CompteAcc($idSejour)
  1506.     {
  1507.         $logo '';
  1508.         $nom '';
  1509.         $RefEmail $this->em->getRepository(Ref::class)->find(21);
  1510.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  1511.         $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  1512.         
  1513.         if ($sejour) {
  1514.             // Génération des PDFs
  1515.             $pdf1 = new Fpdi();
  1516.             $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  1517.             $pdfFilepath1 $publicDirectory "Mode_emploi_5sur5sejour_v5_.pdf";
  1518.             $pageCount $pdf1->setSourceFile($pdfFilepath1);
  1519.             
  1520.             // Pour chaque page du PDF source
  1521.             for ($i 1$i <= $pageCount$i++) {
  1522.                 $pageId $pdf1->importPage($iPdfReader\PageBoundaries::MEDIA_BOX);
  1523.                 $pdf1->addPage();
  1524.                 $pdf1->useImportedPage($pageId);
  1525.                 
  1526.                 // Ajouter le contenu uniquement sur la première page
  1527.                 if ($i === 1) {
  1528.                     $pdf1->SetFont('Helvetica'''12);
  1529.                     $pdf1->SetTextColor(000);
  1530.                     
  1531.                     // Position pour le code séjour
  1532.                     $pdf1->SetXY(50100);
  1533.                     $pdf1->Write(0"Code séjour : " $sejour->getCodeSejour());
  1534.                     
  1535.                     // Position pour le mot de passe
  1536.                     $pdf1->SetXY(50120);
  1537.                     $pdf1->Write(0"Mot de passe : " $sejour->getIdAcommp()->getPasswordNonCripted());
  1538.                     
  1539.                     // Informations du séjour
  1540.                     $pdf1->SetXY(50140);
  1541.                     $pdf1->Write(0"Dates : du " $sejour->getDateDebutSejour()->format('d/m/Y') . " au " $sejour->getDateFinSejour()->format('d/m/Y'));
  1542.                     
  1543.                     $pdf1->SetXY(50160);
  1544.                     $pdf1->Write(0"Thème : " $sejour->getThemSejour());
  1545.                     
  1546.                     $pdf1->SetXY(50180);
  1547.                     $pdf1->Write(0"Lieu : " $sejour->getAdresseSejour());
  1548.                     
  1549.                     $pdf1->SetXY(50200);
  1550.                     $pdf1->Write(0"Ville : " $sejour->getVille());
  1551.                     
  1552.                     $pdf1->SetXY(50220);
  1553.                     $pdf1->Write(0"Pays : " $sejour->getPays());
  1554.                 }
  1555.             }
  1556.             
  1557.             $pdfFilepath1Output $publicDirectory "Mode d'emploi 5sur5sejour" $sejour->getId() . ".pdf";
  1558.             $pdf1->Output($pdfFilepath1Output"F");
  1559.             
  1560.             // Génération du deuxième PDF
  1561.             $pdf = new Fpdi();
  1562.             $paym $sejour->getPaym();
  1563.             
  1564.             if ($paym == 1) {
  1565.                 $pdfFilepathSource $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
  1566.             } else {
  1567.                 $pdfFilepathSource $publicDirectory "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
  1568.             }
  1569.             
  1570.             $pageCount $pdf->setSourceFile($pdfFilepathSource);
  1571.             
  1572.             // Pour chaque page du PDF source
  1573.             for ($i 1$i <= $pageCount$i++) {
  1574.                 $pageId $pdf->importPage($iPdfReader\PageBoundaries::MEDIA_BOX);
  1575.                 $pdf->addPage();
  1576.                 $pdf->useImportedPage($pageId);
  1577.                 
  1578.                 // Ajouter le contenu uniquement sur la première page
  1579.                 if ($i === 1) {
  1580.                     $pdf->SetFont('Helvetica'''12);
  1581.                     $pdf->SetTextColor(000);
  1582.                     
  1583.                     // Position pour le code séjour
  1584.                     $pdf->SetXY(50100);
  1585.                     $pdf->Write(0"Code séjour : " $sejour->getCodeSejour());
  1586.                     
  1587.                     // Informations du séjour
  1588.                     $pdf->SetXY(50120);
  1589.                     $pdf->Write(0"Dates : du " $sejour->getDateDebutSejour()->format('d/m/Y') . " au " $sejour->getDateFinSejour()->format('d/m/Y'));
  1590.                     
  1591.                     $pdf->SetXY(50140);
  1592.                     $pdf->Write(0"Thème : " $sejour->getThemSejour());
  1593.                     
  1594.                     $pdf->SetXY(50160);
  1595.                     $pdf->Write(0"Lieu : " $sejour->getAdresseSejour());
  1596.                     
  1597.                     $pdf->SetXY(50180);
  1598.                     $pdf->Write(0"Ville : " $sejour->getVille());
  1599.                     
  1600.                     $pdf->SetXY(50200);
  1601.                     $pdf->Write(0"Pays : " $sejour->getPays());
  1602.                 }
  1603.             }
  1604.             
  1605.             if ($paym == 1) {
  1606.                 $pdfFilepathOutput $publicDirectory "Mode d'emploi parent 5sur5séjour" $sejour->getId() . ".pdf";
  1607.             } else {
  1608.                 $pdfFilepathOutput $publicDirectory "Mode d'emploi parent G 5sur5séjour " $sejour->getId() . ".pdf";
  1609.             }
  1610.             $pdf->Output($pdfFilepathOutput"F");
  1611.             $loginUrl "5sur5sejour.com";
  1612.             $accomp $this->em->getRepository(User::class)->find($sejour->getIdAcommp());
  1613.             if ($accomp != null) {
  1614.                 $loginUrl $this->emailsCmdService->requestLoginLink($accomp);
  1615.             }
  1616.           
  1617.                 // Récupérer le logo et le nom
  1618.                 $logo $sejour->getIdEtablisment()->getLogo();
  1619.                 $nom $sejour->getIdEtablisment()->getNometab();
  1620.                 
  1621.                 // Préparer les données pour le template
  1622.                 $extraDataEmail = [
  1623.                     "Password" => $sejour->getIdAcommp()->getPasswordNonCripted(),
  1624.                     "code" => $sejour->getCodeSejour(),
  1625.                     "dateCreation" => $sejour->getDateCreationCode(),
  1626.                     "dateFinCode" => $sejour->getDateFinCode(),
  1627.                     "lieu" => $sejour->getAdresseSejour(),
  1628.                     "identifiant" => $sejour->getCodeSejour(),
  1629.                     "theme" => $sejour->getThemSejour(),
  1630.                     "ville" => $sejour->getVille(),
  1631.                     "pays" => $sejour->getPays(),
  1632.                     "dateDebut" => $sejour->getDateDebutSejour(),
  1633.                     "dateFin" => $sejour->getDateFinSejour(),
  1634.                     "motPass" => $sejour->getIdAcommp()->getPasswordNonCripted(),
  1635.                      "codeSejour" => $sejour->getCodeSejour(),
  1636.                     'idSejour' => $sejour->getId(),
  1637.                     "loginUrl" =>  $loginUrl ,
  1638.                     'roles' => $sejour->getIdEtablisment()->getUser()->getRoles(),
  1639.                     'fichiers' => [
  1640.                         $pdfFilepathOutput,
  1641.                         $pdfFilepath1Output
  1642.                     ]
  1643.                 ];
  1644.                 $emailAcco $sejour->getIdAcommp()->getReponseemail();
  1645.                 // Envoyer l'email au partenaire
  1646.                 $this->emailsCmdService->sendMail(
  1647.                     $emailAcco,
  1648.                     '✅  Votre compte 5sur5séjour est activé ! - Commencez à partager votre séjour',
  1649.                     'ConfirmationActivationAccomp',
  1650.                     $extraDataEmail,
  1651.                     ['bcc' => 'contact@5sur5sejour.com']
  1652.                 );
  1653.                 
  1654.               
  1655.             }
  1656.         
  1657.         
  1658.         return true;
  1659.     }
  1660.     //cette fonction envoi seulement le code sejour aux partenaire et acco s'il existe
  1661.     function EnvoyerEmailCodeSejourToPartenaireAndAcco_old($idSejour)
  1662.     {
  1663.         $logo '';
  1664.         $nom '';
  1665.         $RefEmail $this->em->getRepository(Ref::class)->find(21);
  1666.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  1667.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  1668.         if ($Sejour) {
  1669.             //dd($sejour);
  1670.             $pdf1 = new Fpdi();
  1671.             $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  1672.             $pdfFilepath1 $publicDirectory "Mode_emploi_5sur5sejour_v5_.pdf";
  1673.             $pageCount $pdf1->setSourceFile($pdfFilepath1);
  1674.             $pageId $pdf1->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  1675.             $pdf1->addPage();
  1676.             $pdf1->useImportedPage($pageId0.50.50.5);
  1677.             $testText  "abcdefghijklmnopqrstuvwxyz0123456789";
  1678.             $current_date date('d-M-Y');
  1679.             $DateDebut =  "";
  1680.             $DateFin "";
  1681.             $Theme "";
  1682.             $Lieu "";
  1683.             $CodeSejour =  "";
  1684.             $MotPass =  "";
  1685.             $Ville "";
  1686.             $Paye "";
  1687.             if ($Sejour) {
  1688.                 $DateDebut $Sejour->getDateDebutSejour();
  1689.                 $DateFin $Sejour->getDateFinSejour();
  1690.                 $Theme $Sejour->getThemSejour();
  1691.                 $Lieu $Sejour->getAdresseSejour();
  1692.                 $CodeSejour $Sejour->getCodeSejour();
  1693.                 $MotPass $Sejour->getIdAcommp()->getPasswordNonCripted();
  1694.                 $Ville $Sejour->getVille();
  1695.                 $Paye $Sejour->getPays();
  1696.             }
  1697.             for ($i 0$i $pageCount$i++) {
  1698.                 $tplIdx $pdf1->importPage($i);
  1699.                 $pdf1->useTemplate($tplIdx00200300true);
  1700.                 $theme $Theme;
  1701.                 if (strlen($theme) > 25) {
  1702.                     $pdf1->SetFont("Arial"""5);
  1703.                 } else {
  1704.                     $pdf1->SetFont("Arial"""7);
  1705.                 }
  1706.                 $strTheme iconv("UTF-8""WINDOWS-1252"$theme);
  1707.                 $pdf1->Text(35262$strTheme);
  1708.                 $pdf1->SetFont("Arial"""8);
  1709.                 $lieu $Lieu;
  1710.                 $ville $Ville;
  1711.                 $paye $Paye;
  1712.                 if ($Paye && $Ville) {
  1713.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville "  " $paye);
  1714.                     $pdf1->Text(125262$strLieu);
  1715.                 } else if ($Paye) {
  1716.                     $strLieu iconv("UTF-8""WINDOWS-1252"$paye);
  1717.                     $pdf1->Text(125262$strLieu);
  1718.                 } else {
  1719.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville);
  1720.                     $pdf1->Text(125262$strLieu);
  1721.                 }
  1722.                 $pdf1->SetFont("Arial"""10);
  1723.                 $pdf1->Text(50252$DateDebut->format('d/m/Y'));
  1724.                 $pdf1->SetFont("Arial"""10);
  1725.                 $pdf1->Text(90252$DateFin->format('d/m/Y'));
  1726.                 $pdf1->SetFont("Arial"""10);
  1727.                 $pdf1->Text(90271$CodeSejour);
  1728.                 $pdf1->SetFont("Arial"""10);
  1729.                 $pdf1->Text(75279$MotPass);
  1730.             }
  1731.             $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  1732.             $pdfFilepath1 $publicDirectory "Mode d'emploi 5sur5sejour" $idSejour ".pdf";
  1733.             $pdf1->Output($pdfFilepath1"F");
  1734.             $pdf = new Fpdi();
  1735.             $paym $Sejour->getPaym();
  1736.             if ($paym == 1) {
  1737.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  1738.                 $pdfFilepath $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
  1739.                 $pageCount $pdf->setSourceFile($pdfFilepath);
  1740.             } else {
  1741.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  1742.                 $pdfFilepath $publicDirectory "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
  1743.                 $pageCount $pdf->setSourceFile($pdfFilepath);
  1744.             }
  1745.             $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  1746.             $pdf->addPage();
  1747.             $pdf->useImportedPage($pageId0.50.50.5);
  1748.             $testText  "abcdefghijklmnopqrstuvwxyz0123456789";
  1749.             $current_date date('d-M-Y');
  1750.             $DateDebut =  "";
  1751.             $DateFin "";
  1752.             $Theme "";
  1753.             $Lieu "";
  1754.             $CodeSejour =  "";
  1755.             $Ville "";
  1756.             $Paye "";
  1757.             if ($Sejour) {
  1758.                 $DateDebut $Sejour->getDateDebutSejour();
  1759.                 $DateFin $Sejour->getDateFinSejour();
  1760.                 $Theme $Sejour->getThemSejour();
  1761.                 $Lieu $Sejour->getAdresseSejour();
  1762.                 $CodeSejour $Sejour->getCodeSejour();
  1763.                 $Ville $Sejour->getVille();
  1764.                 $Paye $Sejour->getPays();
  1765.             }
  1766.             for ($i 0$i $pageCount$i++) {
  1767.                 $tplIdx $pdf->importPage($i 1);
  1768.                 $pdf->useTemplate($tplIdx00200300true);
  1769.                 $theme $Theme;
  1770.                 if (strlen($theme) > 25) {
  1771.                     $pdf->SetFont("Arial"""5);
  1772.                 } else {
  1773.                     $pdf->SetFont("Arial"""7);
  1774.                 }
  1775.                 $strTheme iconv("UTF-8""WINDOWS-1252"$theme);
  1776.                 $pdf->Text(35268$strTheme);
  1777.                 $pdf->SetFont("Arial"""8);
  1778.                 $lieu $Lieu;
  1779.                 $ville $Ville;
  1780.                 $paye $Paye;
  1781.                 if ($Paye && $Ville) {
  1782.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville "  " $paye);
  1783.                     $pdf->Text(125268$strLieu);
  1784.                 } else if ($Paye) {
  1785.                     $strLieu iconv("UTF-8""WINDOWS-1252"$paye);
  1786.                     $pdf->Text(125268$strLieu);
  1787.                 } else {
  1788.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville);
  1789.                     $pdf->Text(125268$strLieu);
  1790.                 }
  1791.                 $pdf->SetFont("Arial"""10);
  1792.                 $pdf->Text(80279$CodeSejour);
  1793.                 $pdf->SetFont("Arial"""10);
  1794.                 $pdf->Text(48258$DateDebut->format('d/m/Y'));
  1795.                 $pdf->SetFont("Arial"""10);
  1796.                 $pdf->Text(89258$DateFin->format('d/m/Y'));
  1797.             }
  1798.             if ($paym == 1) {
  1799.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  1800.                 $pdfFilepath $publicDirectory "Mode d'emploi parent  5sur5séjour" $idSejour ".pdf";
  1801.                 $pdf->Output($pdfFilepath"F");
  1802.             } else {
  1803.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  1804.                 $pdfFilepath $publicDirectory "Mode d'emploi parent G 5sur5séjour " $idSejour ".pdf";
  1805.                 $pdf->Output($pdfFilepath"F");
  1806.             }
  1807.             if ($Sejour->getIdEtablisment()) {
  1808.                 if (!is_null($Sejour->getIdEtablisment()->getEmail())) {
  1809.                     $emailPartenaire $Sejour->getIdEtablisment()->getEmail();
  1810.                 } else {
  1811.                     $emailPartenaire $Sejour->getIdPartenaire()->getEmail();
  1812.                 }
  1813.                 $partenaire $Sejour->getIdEtablisment()->getNometab();
  1814.                 $partenaire $Sejour->getIdEtablisment()->getLogo();
  1815.                 $logo $Sejour->getIdEtablisment()->getLogo();
  1816.                 $nom $Sejour->getIdEtablisment()->getNometab();
  1817.                 $message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
  1818.                     ->setFrom('partenariat-contact@5sur5sejour.com')
  1819.                     ->setTo($emailPartenaire)
  1820.                     ->setBcc(["contact@5sur5sejour.com"]);
  1821.                 $pathImage2 $Email->getIdImage2()->getPath();
  1822.                 $pathImage1 $Email->getIdImage1()->getPath();
  1823.                 $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  1824.                 $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  1825.                 $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  1826.                 $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  1827.                 $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  1828.                 $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  1829.                 if ($paym == 1) {
  1830.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  1831.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
  1832.                 } else {
  1833.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  1834.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
  1835.                 }
  1836.                 $message->setBody(
  1837.                     $this->templating->render(
  1838.                         'emails/EnvoiCodeSejourUniquementToAccoAndPartenaire.html.twig',
  1839.                         [
  1840.                             "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  1841.                             "code" => $Sejour->getCodeSejour(),
  1842.                             "dateCreation" => $Sejour->getDateCreationCode(),
  1843.                             "dateFinCode" => $Sejour->getDateFinCode(),
  1844.                             "lieu" => $Sejour->getAdresseSejour(),
  1845.                             "image1" => $image1,
  1846.                             "image2" => $image2,
  1847.                             "iconfooter" => $iconfooter,
  1848.                             "iconphoto" => $iconphoto,
  1849.                             "iconloca" => $iconloca,
  1850.                             "iconmsg" => $iconmsg,
  1851.                             "identifiant" => $Sejour->getCodeSejour(),
  1852.                             'logo' => $logo,
  1853.                             'nom' => $nom,
  1854.                             'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
  1855.                         ]
  1856.                     ),
  1857.                     'text/html'
  1858.                 );
  1859.                 $signMail $this->params->get('signMail');
  1860.                 if ($signMail == 'yes') {
  1861.                     $domainName $this->params->get('domaine');
  1862.                     $selector $this->params->get('selector');
  1863.                     $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  1864.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  1865.                     $message->attachSigner($signer);
  1866.                 }
  1867.                 try {
  1868.                     $this->mailer->send($message);
  1869.                 } catch (\Swift_SwiftException $ex) {
  1870.                     $ex->getMessage();
  1871.                 }
  1872.                 if ($emailPartenaire != $Sejour->getIdAcommp()->getReponseemail()) {
  1873.                     $emailAcco $Sejour->getIdAcommp()->getReponseemail();
  1874.                     $message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
  1875.                         ->setFrom('contact@5sur5sejour.com')
  1876.                         ->setTo($emailAcco);
  1877.                     //->setBcc(["contact@5sur5sejour.com"]);
  1878.                     $pathImage2 $Email->getIdImage2()->getPath();
  1879.                     $pathImage1 $Email->getIdImage1()->getPath();
  1880.                     $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  1881.                     $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  1882.                     $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  1883.                     $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  1884.                     $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  1885.                     $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  1886.                     if ($paym == 1) {
  1887.                         $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  1888.                         $message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
  1889.                     } else {
  1890.                         $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  1891.                         $message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
  1892.                     }
  1893.                     $message->setBody(
  1894.                         $this->templating->render(
  1895.                             'emails/EnvoiCodeSejourUniquementToAccoAndPartenaire.html.twig',
  1896.                             [
  1897.                                 "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  1898.                                 "code" => $Sejour->getCodeSejour(),
  1899.                                 "dateCreation" => $Sejour->getDateCreationCode(),
  1900.                                 "dateFinCode" => $Sejour->getDateFinCode(),
  1901.                                 "lieu" => $Sejour->getAdresseSejour(),
  1902.                                 "image1" => $image1,
  1903.                                 "image2" => $image2,
  1904.                                 "iconfooter" => $iconfooter,
  1905.                                 "iconphoto" => $iconphoto,
  1906.                                 "iconloca" => $iconloca,
  1907.                                 "iconmsg" => $iconmsg,
  1908.                                 'logo' => $logo,
  1909.                                 'nom' => $nom,
  1910.                                 "identifiant" => $Sejour->getCodeSejour(),
  1911.                                 'roles' => $Sejour->getIdAcommp()->getRoles(),
  1912.                             ]
  1913.                         ),
  1914.                         'text/html'
  1915.                     );
  1916.                     $signMail $this->params->get('signMail');
  1917.                     if ($signMail == 'yes') {
  1918.                         $domainName $this->params->get('domaine');
  1919.                         $selector $this->params->get('selector');
  1920.                         $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  1921.                         $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  1922.                         $message->attachSigner($signer);
  1923.                     }
  1924.                     try {
  1925.                         $this->mailer->send($message);
  1926.                     } catch (\Swift_SwiftException $ex) {
  1927.                         $ex->getMessage();
  1928.                     }
  1929.                 }
  1930.             }
  1931.         }
  1932.     }
  1933.     //cette fonction envoi seulement le password sejour aux partenaire et acco s'il existe
  1934.     function EnvoyerEmailPasswordSejourToPartenaireAndAcco($idSejour)
  1935.     {
  1936.         $logo '';
  1937.         $nom '';
  1938.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  1939.         $RefEmail $this->em->getRepository(Ref::class)->find(28);
  1940.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  1941.         if ($Sejour) {
  1942.             if ($Sejour->getIdEtablisment()) {
  1943.                 $emailPartenaire $Sejour->getIdEtablisment()->getEmail();
  1944.                 $partenaire $Sejour->getIdEtablisment()->getNometab();
  1945.                 $partenaire $Sejour->getIdEtablisment()->getLogo();
  1946.                 $logo $Sejour->getIdEtablisment()->getLogo();
  1947.                 $nom $Sejour->getIdEtablisment()->getNometab();
  1948.                 $message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
  1949.                     ->setFrom('partenariat-contact@5sur5sejour.com')
  1950.                     ->setTo($emailPartenaire);
  1951.                 //->setBcc(["contact@5sur5sejour.com"]);
  1952.                 $pathImage2 $Email->getIdImage2()->getPath();
  1953.                 $pathImage1 $Email->getIdImage1()->getPath();
  1954.                 $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  1955.                 $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  1956.                 $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  1957.                 $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  1958.                 $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  1959.                 $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  1960.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  1961.                 $pdfFilepath $publicDirectory "Mode d'emploi 5sur5sejour" $idSejour ".pdf";
  1962.                 $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  1963.                 $message->setBody(
  1964.                     $this->templating->render(
  1965.                         'emails/SendPasswordSejour.html.twig',
  1966.                         [
  1967.                             "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  1968.                             "image1" => $image1,
  1969.                             "image2" => $image2,
  1970.                             "iconfooter" => $iconfooter,
  1971.                             "iconphoto" => $iconphoto,
  1972.                             "iconloca" => $iconloca,
  1973.                             "iconmsg" => $iconmsg,
  1974.                             'logo' => $logo,
  1975.                             'nom' => $nom,
  1976.                             'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
  1977.                         ]
  1978.                     ),
  1979.                     'text/html'
  1980.                 );
  1981.                 $signMail $this->params->get('signMail');
  1982.                 if ($signMail == 'yes') {
  1983.                     $domainName $this->params->get('domaine');
  1984.                     $selector $this->params->get('selector');
  1985.                     $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  1986.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  1987.                     $message->attachSigner($signer);
  1988.                 }
  1989.                 try {
  1990.                     $this->mailer->send($message);
  1991.                 } catch (\Swift_SwiftException $ex) {
  1992.                     $ex->getMessage();
  1993.                 }
  1994.                 if ($emailPartenaire != $Sejour->getIdAcommp()->getReponseemail()) {
  1995.                     $emailAcco $Sejour->getIdAcommp()->getReponseemail();
  1996.                     $message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
  1997.                         ->setFrom('contact@5sur5sejour.com')
  1998.                         ->setTo($emailAcco);
  1999.                     // ->setBcc(["contact@5sur5sejour.com"]);
  2000.                     $pathImage2 $Email->getIdImage2()->getPath();
  2001.                     $pathImage1 $Email->getIdImage1()->getPath();
  2002.                     $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2003.                     $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2004.                     $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  2005.                     $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  2006.                     $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  2007.                     $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  2008.                     $message->attach(\Swift_Attachment::fromPath('pdf/'));
  2009.                     $message->setBody(
  2010.                         $this->templating->render(
  2011.                             'emails/SendPasswordSejour.html.twig',
  2012.                             [
  2013.                                 "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  2014.                                 "image1" => $image1,
  2015.                                 "image2" => $image2,
  2016.                                 "iconfooter" => $iconfooter,
  2017.                                 "iconphoto" => $iconphoto,
  2018.                                 "iconloca" => $iconloca,
  2019.                                 "iconmsg" => $iconmsg,
  2020.                                 'logo' => $logo,
  2021.                                 'nom' => $nom,
  2022.                                 'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
  2023.                             ]
  2024.                         ),
  2025.                         'text/html'
  2026.                     );
  2027.                     $signMail $this->params->get('signMail');
  2028.                     if ($signMail == 'yes') {
  2029.                         $domainName $this->params->get('domaine');
  2030.                         $selector $this->params->get('selector');
  2031.                         $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  2032.                         $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2033.                         $message->attachSigner($signer);
  2034.                     }
  2035.                     try {
  2036.                         $done $this->mailer->send($message);
  2037.                         //var_dump($done);
  2038.                         // var_dump("send it ");
  2039.                     } catch (\Swift_SwiftException $ex) {
  2040.                         //var_dump( $ex->getMessage());
  2041.                     }
  2042.                 }
  2043.             }
  2044.         }
  2045.     }
  2046.     //cette fonction envoi seulement le code sejour aux partenaire
  2047.     function EnvoyerEmailCodeSejourToPartenaire($idSejour)
  2048.     {
  2049.         $logo '';
  2050.         $nom '';
  2051.         $RefEmail $this->em->getRepository(Ref::class)->find(21);
  2052.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  2053.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2054.         if ($Sejour) {
  2055.             //dd($sejour);
  2056.             $pdf = new Fpdi();
  2057.             $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2058.             $pdfFilepath $publicDirectory "Mode_emploi_5sur5sejour_v5_.pdf";
  2059.             $pageCount $pdf->setSourceFile($pdfFilepath);
  2060.             $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  2061.             $pdf->addPage();
  2062.             $pdf->useImportedPage($pageId0.50.50.5);
  2063.             $testText  "abcdefghijklmnopqrstuvwxyz0123456789";
  2064.             $current_date date('d-M-Y');
  2065.             $DateDebut =  "";
  2066.             $DateFin "";
  2067.             $Theme "";
  2068.             $Lieu "";
  2069.             $CodeSejour =  "";
  2070.             $MotPass =  "";
  2071.             $Ville "";
  2072.             $Paye "";
  2073.             if ($Sejour) {
  2074.                 $DateDebut $Sejour->getDateDebutSejour();
  2075.                 $DateFin $Sejour->getDateFinSejour();
  2076.                 $Theme $Sejour->getThemSejour();
  2077.                 $Lieu $Sejour->getAdresseSejour();
  2078.                 $CodeSejour $Sejour->getCodeSejour();
  2079.                 $MotPass $Sejour->getIdAcommp()->getPasswordNonCripted();
  2080.                 $Ville $Sejour->getVille();
  2081.                 $Paye $Sejour->getPays();
  2082.             }
  2083.             for ($i 0$i $pageCount$i++) {
  2084.                 $tplIdx $pdf->importPage($i);
  2085.                 $pdf->useTemplate($tplIdx00200300true);
  2086.                 $theme $Theme;
  2087.                 if (strlen($theme) > 25) {
  2088.                     $pdf->SetFont("Arial"""5);
  2089.                 } else {
  2090.                     $pdf->SetFont("Arial"""7);
  2091.                 }
  2092.                 $strTheme iconv("UTF-8""WINDOWS-1252"$theme);
  2093.                 $pdf->Text(35262$strTheme);
  2094.                 $pdf->SetFont("Arial"""10);
  2095.                 $pdf->Text(50252$DateDebut->format('d/m/Y'));
  2096.                 $pdf->SetFont("Arial"""10);
  2097.                 $pdf->Text(90252$DateFin->format('d/m/Y'));
  2098.                 $pdf->SetFont("Arial"""8);
  2099.                 $lieu $Lieu;
  2100.                 $ville $Ville;
  2101.                 $paye $Paye;
  2102.                 if ($Paye && $Ville) {
  2103.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville "  " $paye);
  2104.                     $pdf->Text(125262$strLieu);
  2105.                 } else if ($Paye) {
  2106.                     $strLieu iconv("UTF-8""WINDOWS-1252"$paye);
  2107.                     $pdf->Text(125262$strLieu);
  2108.                 } else {
  2109.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville);
  2110.                     $pdf->Text(125262$strLieu);
  2111.                 }
  2112.                 $pdf->SetFont("Arial"""10);
  2113.                 $pdf->Text(90271$CodeSejour);
  2114.                 $pdf->SetFont("Arial"""10);
  2115.                 $pdf->Text(75279$MotPass);
  2116.             }
  2117.             $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2118.             $pdfFilepath $publicDirectory "Mode d'emploi 5sur5sejour" $idSejour ".pdf";
  2119.             $pdf->Output($pdfFilepath"F");
  2120.             $pdf = new Fpdi();
  2121.             $paym $Sejour->getPaym();
  2122.             if ($paym == 1) {
  2123.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2124.                 $pdfFilepath $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
  2125.                 $pageCount $pdf->setSourceFile($pdfFilepath);
  2126.             } else {
  2127.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2128.                 $pdfFilepath $publicDirectory "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
  2129.                 $pageCount $pdf->setSourceFile($pdfFilepath);
  2130.             }
  2131.             $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  2132.             $pdf->addPage();
  2133.             $pdf->useImportedPage($pageId0.50.50.5);
  2134.             $testText  "abcdefghijklmnopqrstuvwxyz0123456789";
  2135.             $current_date date('d-M-Y');
  2136.             $DateDebut =  "";
  2137.             $DateFin "";
  2138.             $Theme "";
  2139.             $Lieu "";
  2140.             $CodeSejour =  "";
  2141.             $Ville "";
  2142.             $Paye "";
  2143.             if ($Sejour) {
  2144.                 $DateDebut $Sejour->getDateDebutSejour();
  2145.                 $DateFin $Sejour->getDateFinSejour();
  2146.                 $Theme $Sejour->getThemSejour();
  2147.                 $Lieu $Sejour->getAdresseSejour();
  2148.                 $CodeSejour $Sejour->getCodeSejour();
  2149.                 $Ville $Sejour->getVille();
  2150.                 $Paye $Sejour->getPays();
  2151.             }
  2152.             for ($i 0$i $pageCount$i++) {
  2153.                 $tplIdx $pdf->importPage($i 1);
  2154.                 $pdf->useTemplate($tplIdx00200300true);
  2155.                 $theme $Theme;
  2156.                 if (strlen($theme) > 25) {
  2157.                     $pdf->SetFont("Arial"""5);
  2158.                 } else {
  2159.                     $pdf->SetFont("Arial"""7);
  2160.                 }
  2161.                 $strTheme iconv("UTF-8""WINDOWS-1252"$theme);
  2162.                 $pdf->Text(35268$strTheme);
  2163.                 $pdf->SetFont("Arial"""8);
  2164.                 $lieu $Lieu;
  2165.                 $ville $Ville;
  2166.                 $paye $Paye;
  2167.                 if ($Paye  && $Ville) {
  2168.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville "  " $paye);
  2169.                     $pdf->Text(125268$strLieu);
  2170.                 } else if ($Paye) {
  2171.                     $strLieu iconv("UTF-8""WINDOWS-1252"$paye);
  2172.                     $pdf->Text(125268$strLieu);
  2173.                 } else {
  2174.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville);
  2175.                     $pdf->Text(125268$strLieu);
  2176.                 }
  2177.                 $pdf->SetFont("Arial"""10);
  2178.                 $pdf->Text(80279$CodeSejour);
  2179.                 $pdf->SetFont("Arial"""10);
  2180.                 $pdf->Text(48258$DateDebut->format('d/m/Y'));
  2181.                 $pdf->SetFont("Arial"""10);
  2182.                 $pdf->Text(89258$DateFin->format('d/m/Y'));
  2183.             }
  2184.             if ($paym == 1) {
  2185.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2186.                 $pdfFilepath $publicDirectory "Mode d'emploi parent  5sur5séjour" $idSejour ".pdf";
  2187.                 $pdf->Output($pdfFilepath"F");
  2188.             } else {
  2189.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2190.                 $pdfFilepath $publicDirectory "Mode d'emploi parent  5sur5séjour" $idSejour ".pdf";
  2191.                 $pdf->Output($pdfFilepath"F");
  2192.             }
  2193.             if ($Sejour->getIdEtablisment()) {
  2194.                 $emailPartenaire $Sejour->getIdEtablisment()->getEmail();
  2195.                 $partenaire $Sejour->getIdEtablisment()->getNometab();
  2196.                 $partenaire $Sejour->getIdEtablisment()->getLogo();
  2197.                 $logo $Sejour->getIdEtablisment()->getLogo();
  2198.                 $nom $Sejour->getIdEtablisment()->getNometab();
  2199.                 $message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
  2200.                     ->setFrom('partenariat-contact@5sur5sejour.com')
  2201.                     ->setTo($emailPartenaire);
  2202.                 //->setBcc(["contact@5sur5sejour.com"]);
  2203.                 $pathImage2 $Email->getIdImage2()->getPath();
  2204.                 $pathImage1 $Email->getIdImage1()->getPath();
  2205.                 $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2206.                 $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2207.                 $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  2208.                 $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  2209.                 $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  2210.                 $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  2211.                 if ($paym == 1) {
  2212.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2213.                 } else {
  2214.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2215.                 }
  2216.                 $message->setBody(
  2217.                     $this->templating->render(
  2218.                         'emails/EnvoiCodeSejourUniquementToAccoAndPartenaire.html.twig',
  2219.                         [
  2220.                             "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  2221.                             "code" => $Sejour->getCodeSejour(),
  2222.                             "dateCreation" => $Sejour->getDateCreationCode(),
  2223.                             "dateFinCode" => $Sejour->getDateFinCode(),
  2224.                             "lieu" => $Sejour->getAdresseSejour(),
  2225.                             "image1" => $image1,
  2226.                             "image2" => $image2,
  2227.                             "iconfooter" => $iconfooter,
  2228.                             "iconphoto" => $iconphoto,
  2229.                             "iconloca" => $iconloca,
  2230.                             "iconmsg" => $iconmsg,
  2231.                             "identifiant" => $Sejour->getCodeSejour(),
  2232.                             'logo' => $logo,
  2233.                             'nom' => $nom,
  2234.                             'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
  2235.                         ]
  2236.                     ),
  2237.                     'text/html'
  2238.                 );
  2239.                 $signMail $this->params->get('signMail');
  2240.                 if ($signMail == 'yes') {
  2241.                     $domainName $this->params->get('domaine');
  2242.                     $selector $this->params->get('selector');
  2243.                     $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  2244.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2245.                     $message->attachSigner($signer);
  2246.                 }
  2247.                 try {
  2248.                     $this->mailer->send($message);
  2249.                 } catch (\Swift_SwiftException $ex) {
  2250.                     $ex->getMessage();
  2251.                 }
  2252.             }
  2253.         }
  2254.     }
  2255.     //cette fonction envoi seulement le code sejour aux acccompagnateur
  2256.     function EnvoyerEmailCodeSejourToAccomp($idSejour)
  2257.     {
  2258.         $RefEmail $this->em->getRepository(Ref::class)->find(21);
  2259.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  2260.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2261.         if ($Sejour) {
  2262.             $pdf = new Fpdi();
  2263.             $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2264.             $pdfFilepath $publicDirectory "Mode_emploi_5sur5sejour_v5_.pdf";
  2265.             $pageCount $pdf->setSourceFile($pdfFilepath);
  2266.             $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  2267.             $pdf->addPage();
  2268.             $pdf->useImportedPage($pageId0.50.50.5);
  2269.             $testText  "abcdefghijklmnopqrstuvwxyz0123456789";
  2270.             $current_date date('d-M-Y');
  2271.             $DateDebut =  "";
  2272.             $DateFin "";
  2273.             $Theme "";
  2274.             $Lieu "";
  2275.             $CodeSejour =  "";
  2276.             $MotPass =  "";
  2277.             $Ville "";
  2278.             $Paye "";
  2279.             if ($Sejour) {
  2280.                 $DateDebut $Sejour->getDateDebutSejour();
  2281.                 $DateFin $Sejour->getDateFinSejour();
  2282.                 $Theme $Sejour->getThemSejour();
  2283.                 $Lieu $Sejour->getAdresseSejour();
  2284.                 $CodeSejour $Sejour->getCodeSejour();
  2285.                 $MotPass $Sejour->getIdAcommp()->getPasswordNonCripted();
  2286.                 $Ville $Sejour->getVille();
  2287.                 $Paye $Sejour->getPays();
  2288.             }
  2289.             for ($i 0$i $pageCount$i++) {
  2290.                 $tplIdx $pdf->importPage($i);
  2291.                 $pdf->useTemplate($tplIdx00200300true);
  2292.                 $theme $Theme;
  2293.                 if (strlen($theme) > 25) {
  2294.                     $pdf->SetFont("Arial"""5);
  2295.                 } else {
  2296.                     $pdf->SetFont("Arial"""7);
  2297.                 }
  2298.                 $strTheme iconv("UTF-8""WINDOWS-1252"$theme);
  2299.                 $pdf->Text(35262$strTheme);
  2300.                 $pdf->SetFont("Arial"""8);
  2301.                 $lieu $Lieu;
  2302.                 $ville $Ville;
  2303.                 $paye $Paye;
  2304.                 if ($Paye  && $Ville) {
  2305.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville "  " $paye);
  2306.                     $pdf->Text(125262$strLieu);
  2307.                 } elseif ($Paye) {
  2308.                     $strLieu iconv("UTF-8""WINDOWS-1252"$paye);
  2309.                     $pdf->Text(125262$strLieu);
  2310.                 } else {
  2311.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville);
  2312.                     $pdf->Text(125262$strLieu);
  2313.                 }
  2314.                 $pdf->SetFont("Arial"""10);
  2315.                 $pdf->Text(50252$DateDebut->format('d/m/Y'));
  2316.                 $pdf->SetFont("Arial"""10);
  2317.                 $pdf->Text(90252$DateFin->format('d/m/Y'));
  2318.                 $pdf->SetFont("Arial"""10);
  2319.                 $pdf->Text(90271$CodeSejour);
  2320.                 $pdf->SetFont("Arial"""10);
  2321.                 $pdf->Text(75279$MotPass);
  2322.             }
  2323.             $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2324.             $pdfFilepath $publicDirectory "Mode d'emploi 5sur5sejour" $idSejour ".pdf";
  2325.             // $filename= $this->params->get('kernel.project_dir').'/public/pdf/pdfaccompagnateur.pdf';
  2326.             $pdf->Output($pdfFilepath"F");
  2327.             $pdf = new Fpdi();
  2328.             $paym $Sejour->getPaym();
  2329.             if ($paym == 1) {
  2330.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2331.                 $pdfFilepath $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
  2332.                 $pageCount $pdf->setSourceFile($pdfFilepath);
  2333.             } else {
  2334.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2335.                 $pdfFilepath $publicDirectory "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
  2336.                 $pageCount $pdf->setSourceFile($pdfFilepath);
  2337.             }
  2338.             $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  2339.             $pdf->addPage();
  2340.             $pdf->useImportedPage($pageId0.50.50.5);
  2341.             $testText  "abcdefghijklmnopqrstuvwxyz0123456789";
  2342.             $current_date date('d-M-Y');
  2343.             $DateDebut =  "";
  2344.             $DateFin "";
  2345.             $Theme "";
  2346.             $Lieu "";
  2347.             $CodeSejour =  "";
  2348.             $Ville "";
  2349.             $Paye "";
  2350.             if ($Sejour) {
  2351.                 $DateDebut $Sejour->getDateDebutSejour();
  2352.                 $DateFin $Sejour->getDateFinSejour();
  2353.                 $Theme $Sejour->getThemSejour();
  2354.                 $Lieu $Sejour->getAdresseSejour();
  2355.                 $CodeSejour $Sejour->getCodeSejour();
  2356.                 $Ville $Sejour->getVille();
  2357.                 $Paye $Sejour->getPays();
  2358.             }
  2359.             for ($i 0$i $pageCount$i++) {
  2360.                 $tplIdx $pdf->importPage($i 1);
  2361.                 $pdf->useTemplate($tplIdx00200300true);
  2362.                 $theme $Theme;
  2363.                 if (strlen($theme) > 25) {
  2364.                     $pdf->SetFont("Arial"""5);
  2365.                 } else {
  2366.                     $pdf->SetFont("Arial"""7);
  2367.                 }
  2368.                 $strTheme iconv("UTF-8""WINDOWS-1252"$theme);
  2369.                 $pdf->Text(35268$strTheme);
  2370.                 $pdf->SetFont("Arial"""8);
  2371.                 $lieu $Lieu;
  2372.                 $ville $Ville;
  2373.                 $paye $Paye;
  2374.                 if ($Paye  && $Ville) {
  2375.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville "  " $paye);
  2376.                     $pdf->Text(125268$strLieu);
  2377.                 } else if ($Paye) {
  2378.                     $strLieu iconv("UTF-8""WINDOWS-1252"$paye);
  2379.                     $pdf->Text(125268$strLieu);
  2380.                 } else {
  2381.                     $strLieu iconv("UTF-8""WINDOWS-1252"$ville);
  2382.                     $pdf->Text(125268$strLieu);
  2383.                 }
  2384.                 $pdf->SetFont("Arial"""10);
  2385.                 $pdf->Text(80279$CodeSejour);
  2386.                 $pdf->SetFont("Arial"""10);
  2387.                 $pdf->Text(48258$DateDebut->format('d/m/Y'));
  2388.                 $pdf->SetFont("Arial"""10);
  2389.                 $pdf->Text(89258$DateFin->format('d/m/Y'));
  2390.             }
  2391.             if ($paym == 1) {
  2392.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2393.                 $pdfFilepath $publicDirectory "Mode d'emploi parent  5sur5séjour" $idSejour ".pdf";
  2394.                 $pdf->Output($pdfFilepath"F");
  2395.             } else {
  2396.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2397.                 $pdfFilepath $publicDirectory "Mode d'emploi parent  5sur5séjour" $idSejour ".pdf";
  2398.                 $pdf->Output($pdfFilepath"F");
  2399.             }
  2400.             if ($Sejour->getIdAcommp()->getReponseemail()) {
  2401.                 $emailAcco $Sejour->getIdAcommp()->getReponseemail();
  2402.                 $partenaire $Sejour->getIdEtablisment()->getNometab();
  2403.                 $partenaire $Sejour->getIdEtablisment()->getLogo();
  2404.                 $logo $Sejour->getIdEtablisment()->getLogo();
  2405.                 $nom $Sejour->getIdEtablisment()->getNometab();
  2406.                 $message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
  2407.                     ->setFrom('contact@5sur5sejour.com')
  2408.                     ->setTo($emailAcco);
  2409.                 //->setBcc(["contact@5sur5sejour.com"]);
  2410.                 $pathImage2 $Email->getIdImage2()->getPath();
  2411.                 $pathImage1 $Email->getIdImage1()->getPath();
  2412.                 $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2413.                 $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2414.                 $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  2415.                 $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  2416.                 $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  2417.                 $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  2418.                 if ($paym == 1) {
  2419.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2420.                 } else {
  2421.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2422.                 }
  2423.                 $message->setBody(
  2424.                     $this->templating->render(
  2425.                         'emails/EnvoiCodeSejourUniquementToAccoAndPartenaire.html.twig',
  2426.                         [
  2427.                             "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  2428.                             "code" => $Sejour->getCodeSejour(),
  2429.                             "dateCreation" => $Sejour->getDateCreationCode(),
  2430.                             "dateFinCode" => $Sejour->getDateFinCode(),
  2431.                             "lieu" => $Sejour->getAdresseSejour(),
  2432.                             "image1" => $image1,
  2433.                             "image2" => $image2,
  2434.                             "iconfooter" => $iconfooter,
  2435.                             "iconphoto" => $iconphoto,
  2436.                             "iconloca" => $iconloca,
  2437.                             "iconmsg" => $iconmsg,
  2438.                             'logo' => $logo,
  2439.                             'nom' => $nom,
  2440.                             "identifiant" => $Sejour->getCodeSejour(),
  2441.                             'roles' => $Sejour->getIdAcommp()->getRoles(),
  2442.                         ]
  2443.                     ),
  2444.                     'text/html'
  2445.                 );
  2446.                 $signMail $this->params->get('signMail');
  2447.                 if ($signMail == 'yes') {
  2448.                     $domainName $this->params->get('domaine');
  2449.                     $selector $this->params->get('selector');
  2450.                     $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  2451.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2452.                     $message->attachSigner($signer);
  2453.                 }
  2454.                 try {
  2455.                     $this->mailer->send($message);
  2456.                 } catch (\Swift_SwiftException $ex) {
  2457.                     $ex->getMessage();
  2458.                 }
  2459.             }
  2460.         }
  2461.     }
  2462.     //cette fonction envoi seulement le password sejour aux partenaire et acco s'il existe
  2463.     function EnvoyerEmailPasswordSejourToPartenaire($idSejour)
  2464.     {
  2465.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2466.         $RefEmail $this->em->getRepository(Ref::class)->find(28);
  2467.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  2468.         if ($Sejour) {
  2469.             if ($Sejour->getIdEtablisment()) {
  2470.                 $emailPartenaire $Sejour->getIdEtablisment()->getEmail();
  2471.                 $partenaire $Sejour->getIdEtablisment()->getNometab();
  2472.                 $partenaire $Sejour->getIdEtablisment()->getLogo();
  2473.                 $logo $Sejour->getIdEtablisment()->getLogo();
  2474.                 $nom $Sejour->getIdEtablisment()->getNometab();
  2475.                 $message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
  2476.                     ->setFrom('partenariat-contact@5sur5sejour.com')
  2477.                     ->setTo($emailPartenaire);
  2478.                 //->setBcc(["contact@5sur5sejour.com"]);
  2479.                 $pathImage2 $Email->getIdImage2()->getPath();
  2480.                 $pathImage1 $Email->getIdImage1()->getPath();
  2481.                 $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2482.                 $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2483.                 $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  2484.                 $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  2485.                 $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  2486.                 $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  2487.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2488.                 $pdfFilepath $publicDirectory "Mode d'emploi 5sur5sejour" $idSejour ".pdf";
  2489.                 $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2490.                 $message->setBody(
  2491.                     $this->templating->render(
  2492.                         'emails/SendPasswordSejour.html.twig',
  2493.                         [
  2494.                             "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  2495.                             "image1" => $image1,
  2496.                             "image2" => $image2,
  2497.                             "iconfooter" => $iconfooter,
  2498.                             "iconphoto" => $iconphoto,
  2499.                             "iconloca" => $iconloca,
  2500.                             "iconmsg" => $iconmsg,
  2501.                             'logo' => $logo,
  2502.                             'nom' => $nom,
  2503.                             'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
  2504.                         ]
  2505.                     ),
  2506.                     'text/html'
  2507.                 );
  2508.                 $signMail $this->params->get('signMail');
  2509.                 if ($signMail == 'yes') {
  2510.                     $domainName $this->params->get('domaine');
  2511.                     $selector $this->params->get('selector');
  2512.                     $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  2513.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2514.                     $message->attachSigner($signer);
  2515.                 }
  2516.                 try {
  2517.                     $this->mailer->send($message);
  2518.                 } catch (\Swift_SwiftException $ex) {
  2519.                     $ex->getMessage();
  2520.                 }
  2521.             }
  2522.         }
  2523.     }
  2524.     //cette fonction envoi seulement le password sejour aux partenaire et acco s'il existe
  2525.     function EnvoyerEmailPasswordSejourToAcco($idSejour)
  2526.     {
  2527.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2528.         $RefEmail $this->em->getRepository(Ref::class)->find(28);
  2529.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  2530.         if ($Sejour) {
  2531.             if ($Sejour->getIdAcommp()->getReponseemail()) {
  2532.                 $emailAcco $Sejour->getIdAcommp()->getReponseemail();
  2533.                 $partenaire $Sejour->getIdEtablisment()->getNometab();
  2534.                 $partenaire $Sejour->getIdEtablisment()->getLogo();
  2535.                 $logo $Sejour->getIdEtablisment()->getLogo();
  2536.                 $nom $Sejour->getIdEtablisment()->getNometab();
  2537.                 $message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
  2538.                     ->setFrom('contact@5sur5sejour.com')
  2539.                     ->setTo($emailAcco);
  2540.                 //->setBcc(["contact@5sur5sejour.com"]);
  2541.                 $pathImage2 $Email->getIdImage2()->getPath();
  2542.                 $pathImage1 $Email->getIdImage1()->getPath();
  2543.                 $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2544.                 $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2545.                 $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  2546.                 $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  2547.                 $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  2548.                 $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  2549.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2550.                 $pdfFilepath $publicDirectory "Mode d'emploi 5sur5sejour" $idSejour ".pdf";
  2551.                 $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2552.                 $message->setBody(
  2553.                     $this->templating->render(
  2554.                         'emails/SendPasswordSejour.html.twig',
  2555.                         [
  2556.                             "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  2557.                             "image1" => $image1,
  2558.                             "image2" => $image2,
  2559.                             "iconfooter" => $iconfooter,
  2560.                             "iconphoto" => $iconphoto,
  2561.                             "iconloca" => $iconloca,
  2562.                             "iconmsg" => $iconmsg,
  2563.                             'logo' => $logo,
  2564.                             'nom' => $nom,
  2565.                             'roles' => $Sejour->getIdAcommp()->getRoles(),
  2566.                         ]
  2567.                     ),
  2568.                     'text/html'
  2569.                 );
  2570.                 $signMail $this->params->get('signMail');
  2571.                 if ($signMail == 'yes') {
  2572.                     $domainName $this->params->get('domaine');
  2573.                     $selector $this->params->get('selector');
  2574.                     $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  2575.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2576.                     $message->attachSigner($signer);
  2577.                 }
  2578.                 try {
  2579.                     $done $this->mailer->send($message);
  2580.                     //var_dump($done);
  2581.                     // var_dump("send it ");
  2582.                 } catch (\Swift_SwiftException $ex) {
  2583.                     //var_dump( $ex->getMessage());
  2584.                 }
  2585.             }
  2586.         }
  2587.     }
  2588.     //Touhemi 03-07: Modifier les services et les twig des mails séjour en masse pour afficher le logo et le nom de partenaire.
  2589.     //Fonction 1:cette fonction envoi seulement le code sejour aux partenaire et acco s'il existe
  2590.     function EnvoyerEmailCodeSejourToPartenaireAndAccoAvecNomLogoPartenaire($idSejour)
  2591.     {
  2592.         $logo '';
  2593.         $nom '';
  2594.         $RefEmail $this->em->getRepository(Ref::class)->find(21);
  2595.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  2596.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2597.         if ($Sejour) {
  2598.             if ($Sejour->getIdEtablisment()) {
  2599.                 $pdf1 = new Fpdi();
  2600.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2601.                 $pdfFilepath1 $publicDirectory "Mode_emploi_5sur5sejour_v5_.pdf";
  2602.                 $pageCount $pdf1->setSourceFile($pdfFilepath1);
  2603.                 $pageId $pdf1->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  2604.                 $pdf1->addPage();
  2605.                 $pdf1->useImportedPage($pageId0.50.50.5);
  2606.                 $testText  "abcdefghijklmnopqrstuvwxyz0123456789";
  2607.                 $current_date date('d-M-Y');
  2608.                 $DateDebut =  "";
  2609.                 $DateFin "";
  2610.                 $Theme "";
  2611.                 $Lieu "";
  2612.                 $CodeSejour =  "";
  2613.                 $MotPass =  "";
  2614.                 $Ville "";
  2615.                 $Paye "";
  2616.                 if ($Sejour) {
  2617.                     $DateDebut $Sejour->getDateDebutSejour();
  2618.                     $DateFin $Sejour->getDateFinSejour();
  2619.                     $Theme $Sejour->getThemSejour();
  2620.                     $Lieu $Sejour->getAdresseSejour();
  2621.                     $CodeSejour $Sejour->getCodeSejour();
  2622.                     $MotPass $Sejour->getIdAcommp()->getPasswordNonCripted();
  2623.                     $Ville $Sejour->getVille();
  2624.                     $Paye $Sejour->getPays();
  2625.                 }
  2626.                 for ($i 0$i $pageCount$i++) {
  2627.                     $tplIdx $pdf1->importPage($i);
  2628.                     $pdf1->useTemplate($tplIdx00200300true);
  2629.                     $theme $Theme;
  2630.                     if (strlen($theme) > 25) {
  2631.                         $pdf1->SetFont("Arial"""5);
  2632.                     } else {
  2633.                         $pdf1->SetFont("Arial"""7);
  2634.                     }
  2635.                     $strTheme iconv("UTF-8""WINDOWS-1252"$theme);
  2636.                     $pdf1->Text(35262$strTheme);
  2637.                     $pdf1->SetFont("Arial"""8);
  2638.                     $lieu $Lieu;
  2639.                     $ville $Ville;
  2640.                     $paye $Paye;
  2641.                     if ($Paye  && $Ville) {
  2642.                         $strLieu iconv("UTF-8""WINDOWS-1252"$ville "  " $paye);
  2643.                         $pdf1->Text(125262$strLieu);
  2644.                     } elseif ($Paye) {
  2645.                         $strLieu iconv("UTF-8""WINDOWS-1252"$paye);
  2646.                         $pdf1->Text(125262$strLieu);
  2647.                     } else {
  2648.                         $strLieu iconv("UTF-8""WINDOWS-1252"$ville);
  2649.                         $pdf1->Text(125262$strLieu);
  2650.                     }
  2651.                     $pdf1->SetFont("Arial"""10);
  2652.                     $pdf1->Text(50252$DateDebut->format('d/m/Y'));
  2653.                     $pdf1->SetFont("Arial"""10);
  2654.                     $pdf1->Text(90252$DateFin->format('d/m/Y'));
  2655.                     $pdf1->SetFont("Arial"""10);
  2656.                     $pdf1->Text(90271$CodeSejour);
  2657.                     $pdf1->SetFont("Arial"""10);
  2658.                     $pdf1->Text(75279$MotPass);
  2659.                 }
  2660.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2661.                 $pdfFilepath1 $publicDirectory "Mode d'emploi 5sur5sejour" $idSejour ".pdf";
  2662.                 // $filename= $this->params->get('kernel.project_dir').'/public/pdf/pdfaccompagnateur.pdf';
  2663.                 $pdf1->Output($pdfFilepath1"F");
  2664.                 $emailPartenaire $Sejour->getIdEtablisment()->getEmail();
  2665.                 $logo $Sejour->getIdEtablisment()->getLogo();
  2666.                 $nom $Sejour->getIdEtablisment()->getNometab();
  2667.                 $pdf = new Fpdi();
  2668.                 $paym $Sejour->getPaym();
  2669.                 if ($paym == 1) {
  2670.                     $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2671.                     $pdfFilepath $publicDirectory "Mode_emploi_Parent_5sur5sejour_v5_.pdf";
  2672.                     $pageCount $pdf->setSourceFile($pdfFilepath);
  2673.                 } else {
  2674.                     $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2675.                     $pdfFilepath $publicDirectory "Mode_emploi_Parent_G_5sur5sejou_v5_.pdf";
  2676.                     $pageCount $pdf->setSourceFile($pdfFilepath);
  2677.                 }
  2678.                 $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  2679.                 $pdf->addPage();
  2680.                 $pdf->useImportedPage($pageId0.50.50.5);
  2681.                 $testText  "abcdefghijklmnopqrstuvwxyz0123456789";
  2682.                 $current_date date('d-M-Y');
  2683.                 $DateDebut =  "";
  2684.                 $DateFin "";
  2685.                 $Theme "";
  2686.                 $Lieu "";
  2687.                 $CodeSejour =  "";
  2688.                 $Ville "";
  2689.                 $Paye "";
  2690.                 if ($Sejour) {
  2691.                     $DateDebut $Sejour->getDateDebutSejour();
  2692.                     $DateFin $Sejour->getDateFinSejour();
  2693.                     $Theme $Sejour->getThemSejour();
  2694.                     $Lieu $Sejour->getAdresseSejour();
  2695.                     $CodeSejour $Sejour->getCodeSejour();
  2696.                     $Ville $Sejour->getVille();
  2697.                     $Paye $Sejour->getPays();
  2698.                 }
  2699.                 for ($i 0$i $pageCount$i++) {
  2700.                     $tplIdx $pdf->importPage($i 1);
  2701.                     $pdf->useTemplate($tplIdx00200300true);
  2702.                     $theme $Theme;
  2703.                     if (strlen($theme) > 25) {
  2704.                         $pdf->SetFont("Arial"""5);
  2705.                     } else {
  2706.                         $pdf->SetFont("Arial"""7);
  2707.                     }
  2708.                     $strTheme iconv("UTF-8""WINDOWS-1252"$theme);
  2709.                     $pdf->Text(35268$strTheme);
  2710.                     $pdf->SetFont("Arial"""8);
  2711.                     $lieu $Lieu;
  2712.                     $ville $Ville;
  2713.                     $paye $Paye;
  2714.                     if ($Paye  && $Ville) {
  2715.                         $strLieu iconv("UTF-8""WINDOWS-1252"$ville "  " $paye);
  2716.                         $pdf->Text(125268$strLieu);
  2717.                     } else if ($Paye) {
  2718.                         $strLieu iconv("UTF-8""WINDOWS-1252"$paye);
  2719.                         $pdf->Text(125268$strLieu);
  2720.                     } else {
  2721.                         $strLieu iconv("UTF-8""WINDOWS-1252"$ville);
  2722.                         $pdf->Text(125268$strLieu);
  2723.                     }
  2724.                     $pdf->SetFont("Arial"""10);
  2725.                     $pdf->Text(80279$CodeSejour);
  2726.                     $pdf->SetFont("Arial"""10);
  2727.                     $pdf->Text(48258$DateDebut->format('d/m/Y'));
  2728.                     $pdf->SetFont("Arial"""10);
  2729.                     $pdf->Text(89258$DateFin->format('d/m/Y'));
  2730.                 }
  2731.                 if ($paym == 1) {
  2732.                     $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2733.                     $pdfFilepath $publicDirectory "Mode d'emploi parent  5sur5séjour" $idSejour ".pdf";
  2734.                     $pdf->Output($pdfFilepath"F");
  2735.                 } else {
  2736.                     $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2737.                     $pdfFilepath $publicDirectory "Mode d'emploi parent  5sur5séjour" $idSejour ".pdf";
  2738.                     $pdf->Output($pdfFilepath"F");
  2739.                 }
  2740.                 $message = (new \Swift_Message('🔐 Code séjour + mot de passe – Connectez-vous à votre espace 5sur5séjour'))
  2741.                     ->setFrom('partenariat-contact@5sur5sejour.com')
  2742.                     ->setTo($emailPartenaire);
  2743.                 //->setBcc(["contact@5sur5sejour.com"]);
  2744.                 $pathImage2 $Email->getIdImage2()->getPath();
  2745.                 $pathImage1 $Email->getIdImage1()->getPath();
  2746.                 $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2747.                 $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2748.                 $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  2749.                 $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  2750.                 $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  2751.                 $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  2752.                 if ($paym == 1) {
  2753.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2754.                 } else {
  2755.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2756.                 }
  2757.                 $message->setBody(
  2758.                     $this->templating->render(
  2759.                         'emails/EnvoiCodeSejourEnMassAcc.html.twig',
  2760.                         [
  2761.                             "code" => $Sejour->getCodeSejour(),
  2762.                             "dateCreation" => $Sejour->getDateCreationCode(),
  2763.                             "dateFinCode" => $Sejour->getDateFinCode(),
  2764.                             "lieu" => $Sejour->getAdresseSejour(),
  2765.                             "image1" => $image1,
  2766.                             "image2" => $image2,
  2767.                             "iconfooter" => $iconfooter,
  2768.                             "iconphoto" => $iconphoto,
  2769.                             "iconloca" => $iconloca,
  2770.                             "iconmsg" => $iconmsg,
  2771.                             "identifiant" => $Sejour->getCodeSejour(),
  2772.                             'logo' => $logo,
  2773.                             'nom' => $nom,
  2774.                             'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
  2775.                         ]
  2776.                     ),
  2777.                     'text/html'
  2778.                 );
  2779.                 $signMail $this->params->get('signMail');
  2780.                 if ($signMail == 'yes') {
  2781.                     $domainName $this->params->get('domaine');
  2782.                     $selector $this->params->get('selector');
  2783.                     $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  2784.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2785.                     $message->attachSigner($signer);
  2786.                 }
  2787.                 try {
  2788.                     $this->mailer->send($message);
  2789.                 } catch (\Swift_SwiftException $ex) {
  2790.                     $ex->getMessage();
  2791.                 }
  2792.                 if ($emailPartenaire != $Sejour->getIdAcommp()->getReponseemail()) {
  2793.                     $emailAcco $Sejour->getIdAcommp()->getReponseemail();
  2794.                     $message = (new \Swift_Message('Votre code séjour 5sur5sejour'))
  2795.                         ->setFrom('contact@5sur5sejour.com')
  2796.                         ->setTo($emailAcco);
  2797.                     //->setBcc(["contact@5sur5sejour.com"]);
  2798.                     $pathImage2 $Email->getIdImage2()->getPath();
  2799.                     $pathImage1 $Email->getIdImage1()->getPath();
  2800.                     $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2801.                     $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2802.                     $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  2803.                     $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  2804.                     $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  2805.                     $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  2806.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath1));
  2807.                     if ($paym == 1) {
  2808.                         $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2809.                     } else {
  2810.                         $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2811.                     }
  2812.                     $message->setBody(
  2813.                         $this->templating->render(
  2814.                             'emails/EnvoiCodeSejourUniquementToAccoAndPartenaire.html.twig',
  2815.                             [
  2816.                                 "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  2817.                                 "code" => $Sejour->getCodeSejour(),
  2818.                                 "dateCreation" => $Sejour->getDateCreationCode(),
  2819.                                 "dateFinCode" => $Sejour->getDateFinCode(),
  2820.                                 "lieu" => $Sejour->getAdresseSejour(),
  2821.                                 "image1" => $image1,
  2822.                                 "image2" => $image2,
  2823.                                 "iconfooter" => $iconfooter,
  2824.                                 "iconphoto" => $iconphoto,
  2825.                                 "iconloca" => $iconloca,
  2826.                                 "iconmsg" => $iconmsg,
  2827.                                 "identifiant" => $Sejour->getCodeSejour(),
  2828.                                 'logo' => $logo,
  2829.                                 'nom' => $nom,
  2830.                                 'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
  2831.                             ]
  2832.                         ),
  2833.                         'text/html'
  2834.                     );
  2835.                     $signMail $this->params->get('signMail');
  2836.                     if ($signMail == 'yes') {
  2837.                         $domainName $this->params->get('domaine');
  2838.                         $selector $this->params->get('selector');
  2839.                         $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  2840.                         $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2841.                         $message->attachSigner($signer);
  2842.                     }
  2843.                     try {
  2844.                         $this->mailer->send($message);
  2845.                     } catch (\Swift_SwiftException $ex) {
  2846.                         $ex->getMessage();
  2847.                     }
  2848.                 }
  2849.             }
  2850.         }
  2851.     }
  2852.     // Fonction 2: cette fonction envoi seulement le password sejour aux partenaire et acco s'il existe
  2853.     function EnvoyerEmailPasswordSejourToPartenaireAndAccoAvecNomLogoPartenaire($idSejour)
  2854.     {
  2855.         $logo '';
  2856.         $nom '';
  2857.         $Sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  2858.         $RefEmail $this->em->getRepository(Ref::class)->find(28);
  2859.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  2860.         if ($Sejour) {
  2861.             if ($Sejour->getIdEtablisment()) {
  2862.                 $emailPartenaire $Sejour->getIdEtablisment()->getEmail();
  2863.                 $logo $Sejour->getIdEtablisment()->getLogo();
  2864.                 $nom $Sejour->getIdEtablisment()->getNometab();
  2865.                 //dd($sejour);
  2866.                 $pdf = new Fpdi();
  2867.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2868.                 $pdfFilepath $publicDirectory "Mode_emploi_5sur5sejour_v5_.pdf";
  2869.                 $pageCount $pdf->setSourceFile($pdfFilepath);
  2870.                 $pageId $pdf->importPage(1PdfReader\PageBoundaries::MEDIA_BOX);
  2871.                 $pdf->addPage();
  2872.                 $pdf->useImportedPage($pageId0.50.50.5);
  2873.                 $testText  "abcdefghijklmnopqrstuvwxyz0123456789";
  2874.                 $current_date date('d-M-Y');
  2875.                 $DateDebut =  "";
  2876.                 $DateFin "";
  2877.                 $Theme "";
  2878.                 $Lieu "";
  2879.                 $CodeSejour =  "";
  2880.                 $MotPass =  "";
  2881.                 $Ville "";
  2882.                 $Paye "";
  2883.                 if ($Sejour) {
  2884.                     $DateDebut $Sejour->getDateDebutSejour();
  2885.                     $DateFin $Sejour->getDateFinSejour();
  2886.                     $Theme $Sejour->getThemSejour();
  2887.                     $Lieu $Sejour->getAdresseSejour();
  2888.                     $CodeSejour $Sejour->getCodeSejour();
  2889.                     $MotPass $Sejour->getIdAcommp()->getPasswordNonCripted();
  2890.                     $Ville $Sejour->getVille();
  2891.                     $Paye $Sejour->getPays();
  2892.                 }
  2893.                 for ($i 0$i $pageCount$i++) {
  2894.                     $tplIdx $pdf->importPage($i);
  2895.                     $pdf->useTemplate($tplIdx00200300true);
  2896.                     $theme $Theme;
  2897.                     if (strlen($theme) > 25) {
  2898.                         $pdf->SetFont("Arial"""5);
  2899.                     } else {
  2900.                         $pdf->SetFont("Arial"""7);
  2901.                     }
  2902.                     $strTheme iconv("UTF-8""WINDOWS-1252"$theme);
  2903.                     $pdf->Text(35262$strTheme);
  2904.                     $pdf->SetFont("Arial"""8);
  2905.                     $lieu $Lieu;
  2906.                     $ville $Ville;
  2907.                     $paye $Paye;
  2908.                     if ($Paye && $Ville) {
  2909.                         $strLieu iconv("UTF-8""WINDOWS-1252"$ville "  " $paye);
  2910.                         $pdf->Text(125262$strLieu);
  2911.                     } else if ($Paye) {
  2912.                         $strLieu iconv("UTF-8""WINDOWS-1252"$paye);
  2913.                         $pdf->Text(125262$strLieu);
  2914.                     } else {
  2915.                         $strLieu iconv("UTF-8""WINDOWS-1252"$ville);
  2916.                         $pdf->Text(125262$strLieu);
  2917.                     }
  2918.                     $pdf->SetFont("Arial"""10);
  2919.                     $pdf->Text(50252$DateDebut->format('d/m/Y'));
  2920.                     $pdf->SetFont("Arial"""10);
  2921.                     $pdf->Text(90252$DateFin->format('d/m/Y'));
  2922.                     $pdf->SetFont("Arial"""10);
  2923.                     $pdf->Text(90271$CodeSejour);
  2924.                     $pdf->SetFont("Arial"""10);
  2925.                     $pdf->Text(75279$MotPass);
  2926.                 }
  2927.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2928.                 $pdfFilepath $publicDirectory "Mode d'emploi 5sur5sejour" $idSejour ".pdf";
  2929.                 // $filename= $this->params->get('kernel.project_dir').'/public/pdf/pdfaccompagnateur.pdf';
  2930.                 $pdf->Output($pdfFilepath"F");
  2931.                 $message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
  2932.                     ->setFrom('partenariat-contact@5sur5sejour.com')
  2933.                     ->setTo($emailPartenaire);
  2934.                 //->setBcc(["contact@5sur5sejour.com"]);
  2935.                 $pathImage2 $Email->getIdImage2()->getPath();
  2936.                 $pathImage1 $Email->getIdImage1()->getPath();
  2937.                 $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2938.                 $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2939.                 $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  2940.                 $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  2941.                 $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  2942.                 $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  2943.                 $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2944.                 $pdfFilepath $publicDirectory "Mode d'emploi 5sur5sejour" $idSejour ".pdf";
  2945.                 $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2946.                 $message->setBody(
  2947.                     $this->templating->render(
  2948.                         'emails/EnvoiMotdePassSejouEnMassAcc.html.twig',
  2949.                         [
  2950.                             "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  2951.                             "image1" => $image1,
  2952.                             "image2" => $image2,
  2953.                             "iconfooter" => $iconfooter,
  2954.                             "iconphoto" => $iconphoto,
  2955.                             "iconloca" => $iconloca,
  2956.                             "iconmsg" => $iconmsg,
  2957.                             'logo' => $logo,
  2958.                             'nom' => $nom,
  2959.                             'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
  2960.                         ]
  2961.                     ),
  2962.                     'text/html'
  2963.                 );
  2964.                 $signMail $this->params->get('signMail');
  2965.                 if ($signMail == 'yes') {
  2966.                     $domainName $this->params->get('domaine');
  2967.                     $selector $this->params->get('selector');
  2968.                     $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  2969.                     $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  2970.                     $message->attachSigner($signer);
  2971.                 }
  2972.                 try {
  2973.                     $this->mailer->send($message);
  2974.                 } catch (\Swift_SwiftException $ex) {
  2975.                     $ex->getMessage();
  2976.                 }
  2977.                 if ($emailPartenaire != $Sejour->getIdAcommp()->getReponseemail()) {
  2978.                     $emailAcco $Sejour->getIdAcommp()->getReponseemail();
  2979.                     $message = (new \Swift_Message('Votre mot de passe 5sur5sejour'))
  2980.                         ->setFrom('contact@5sur5sejour.com')
  2981.                         ->setTo($emailAcco);
  2982.                     // ->setBcc(["contact@5sur5sejour.com"]);
  2983.                     $pathImage2 $Email->getIdImage2()->getPath();
  2984.                     $pathImage1 $Email->getIdImage1()->getPath();
  2985.                     $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  2986.                     $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  2987.                     $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  2988.                     $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  2989.                     $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  2990.                     $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  2991.                     $publicDirectory $this->params->get('kernel.project_dir') . '/public/pdf/';
  2992.                     $pdfFilepath $publicDirectory "Mode d'emploi 5sur5sejour" $idSejour ".pdf";
  2993.                     $message->attach(\Swift_Attachment::fromPath($pdfFilepath));
  2994.                     $message->setBody(
  2995.                         $this->templating->render(
  2996.                             'emails/EnvoiMotdePassSejouEnMassAcc.html.twig',
  2997.                             [
  2998.                                 "Password" => $Sejour->getIdAcommp()->getPasswordNonCripted(),
  2999.                                 "image1" => $image1,
  3000.                                 "image2" => $image2,
  3001.                                 "iconfooter" => $iconfooter,
  3002.                                 "iconphoto" => $iconphoto,
  3003.                                 "iconloca" => $iconloca,
  3004.                                 "iconmsg" => $iconmsg,
  3005.                                 'logo' => $logo,
  3006.                                 'nom' => $nom,
  3007.                                 'roles' => $Sejour->getIdEtablisment()->getUser()->getRoles(),
  3008.                             ]
  3009.                         ),
  3010.                         'text/html'
  3011.                     );
  3012.                     $signMail $this->params->get('signMail');
  3013.                     if ($signMail == 'yes') {
  3014.                         $domainName $this->params->get('domaine');
  3015.                         $selector $this->params->get('selector');
  3016.                         $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  3017.                         $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  3018.                         $message->attachSigner($signer);
  3019.                     }
  3020.                     try {
  3021.                         $done $this->mailer->send($message);
  3022.                         //var_dump($done);
  3023.                         // var_dump("send it ");
  3024.                     } catch (\Swift_SwiftException $ex) {
  3025.                         //var_dump( $ex->getMessage());
  3026.                     }
  3027.                 }
  3028.             }
  3029.         }
  3030.     }
  3031.     //Le nombre de séjours créés
  3032.     public function getNbrSejourCree($dateDeb$dateFin)
  3033.     {
  3034.         $nbrSejourCree $this->em->getRepository(Sejour::class)->getNbrSejourCree($dateDeb$dateFin);
  3035.         return $nbrSejourCree;
  3036.     }
  3037.     public function getNbrSejourCreeParPart($dateDeb$dateFin$part)
  3038.     {
  3039.         $nbrSejourCree $this->em->getRepository(Sejour::class)->getNbrSejourCreeParPart($dateDeb$dateFin$part);
  3040.         return $nbrSejourCree;
  3041.     }
  3042.     public function getNbrSejourCreeParTypePart($dateDeb$dateFin$type)
  3043.     {
  3044.         $nbrSejourCree $this->em->getRepository(Sejour::class)->getNbrSejourCreeParTypePart($dateDeb$dateFin$type);
  3045.         return $nbrSejourCree;
  3046.     }
  3047.     //Le nombre de séjours actifs
  3048.     public function findSejourEncourBetween($dateDeb$dateFin)
  3049.     {
  3050.         $SejourEncourBetween $this->em->getRepository(Sejour::class)->findSejourEncourBetween($dateDeb$dateFin);
  3051.         return $SejourEncourBetween;
  3052.     }
  3053.     public function findSejourEncourBetweenParPart($dateDeb$dateFin$part)
  3054.     {
  3055.         $SejourEncourBetween $this->em->getRepository(Sejour::class)->findSejourEncourBetweenParPart($dateDeb$dateFin$part);
  3056.         return $SejourEncourBetween;
  3057.     }
  3058.     //nommbre de sejour encour
  3059.     public function findSejourActiveBetween($dateDeb$dateFin)
  3060.     {
  3061.         $SejourActiveBetween $this->em->getRepository(Sejour::class)->findSejourActiveBetween($dateDeb$dateFin);
  3062.         return $SejourActiveBetween;
  3063.     }
  3064.     public function findSejourActiveBetweenParPart($dateDeb$dateFin$part)
  3065.     {
  3066.         $SejourActiveBetween $this->em->getRepository(Sejour::class)->findSejourActiveBetweenParPart($dateDeb$dateFin$part);
  3067.         return $SejourActiveBetween;
  3068.     }
  3069.     public function findSejourActiveBetweenParTypePart($dateDeb$dateFin$type)
  3070.     {
  3071.         $SejourActiveBetween $this->em->getRepository(Sejour::class)->findSejourActiveBetweenParTypePart($dateDeb$dateFin$type);
  3072.         return $SejourActiveBetween;
  3073.     }
  3074.     //Le nombre d'enfant declare  moyen par séjour encour
  3075.     public function enfantsdeclarer($sejours)
  3076.     {
  3077.         $nbrEnfantSejours 0;
  3078.         foreach ($sejours as $sejour) {
  3079.             $nbrEnfantSejours $nbrEnfantSejours $sejour->getNbenfan();
  3080.         }
  3081.         return $nbrEnfantSejours;
  3082.     }
  3083.     public function parentConnecte($sejours)
  3084.     {
  3085.         $nbrPArentSejours 0;
  3086.         foreach ($sejours as $sejour) {
  3087.             $parent_Sejour $this->em->getRepository(ParentSejour::class)->findBy(array('idSejour' => $sejour));
  3088.             $nbrPArentSejours $nbrPArentSejours sizeof($parent_Sejour);
  3089.         }
  3090.         return $nbrPArentSejours;
  3091.     }
  3092.     public function findParentDateBetween($dateDeb$dateFin)
  3093.     {
  3094.         $findParentDateBetween $this->em->getRepository(ParentSejour::class)->findParentDateBetween($dateDeb$dateFin);
  3095.         return $findParentDateBetween;
  3096.     }
  3097.     public function findParentDateBetweenParPart($dateDeb$dateFin$part)
  3098.     {
  3099.         $findParentDateBetween $this->em->getRepository(ParentSejour::class)->findParentDateBetweenParPart($dateDeb$dateFin$part);
  3100.         return $findParentDateBetween;
  3101.     }
  3102.     public function findParentDateBetweenParTypePart($dateDeb$dateFin$type)
  3103.     {
  3104.         $findParentDateBetween $this->em->getRepository(ParentSejour::class)->findParentDateBetweenParTypePart($dateDeb$dateFin$type);
  3105.         return $findParentDateBetween;
  3106.     }
  3107.     public function FindeUSerParentBetween($dateDeb$dateFin)
  3108.     {
  3109.         $users $this->em->getRepository(User::class)->FindeUSerParentBetween($dateDeb$dateFin);
  3110.         return $users;
  3111.     }
  3112.     public function FindeUSerParentActiveBetween($dateDeb$dateFin)
  3113.     {
  3114.         $users $this->em->getRepository(User::class)->FindeUSerParentActiveBetween($dateDeb$dateFin);
  3115.         return $users;
  3116.     }
  3117.     public function FindeUSerParentActiveBetweenParPart($dateDeb$dateFin$part)
  3118.     {
  3119.         $users $this->em->getRepository(ParentSejour::class)->FindeUSerParentActiveBetweenParPart($dateDeb$dateFin$part);
  3120.         return $users;
  3121.     }
  3122.     public function FindeUSerParentActiveBetweenParTypePart($dateDeb$dateFin$type)
  3123.     {
  3124.         $users $this->em->getRepository(ParentSejour::class)->FindeUSerParentActiveBetweenParTypePart($dateDeb$dateFin$type);
  3125.         return $users;
  3126.     }
  3127.     public function findSejourEncourBetweenParTypePart($dateDeb$dateFin$type)
  3128.     {
  3129.         $users $this->em->getRepository(ParentSejour::class)->FindeUSerParentActiveBetweenParPart($dateDeb$dateFin$type);
  3130.         return $users;
  3131.     }
  3132.     function caConnexionTotalFree()
  3133.     {
  3134.         $etabs $this->em->getRepository(Etablisment::class)->findAll();
  3135.         $cconnexionFree 0;
  3136.         $nbrConexxion 0;
  3137.         foreach ($etabs as $etab) {
  3138.             $sejours $this->em->getRepository(Sejour::class)->findBy(array("idEtablisment" => $etab));
  3139.             $prixtotPArt 0;
  3140.             $flag false;
  3141.             foreach ($sejours as $sejour) {
  3142.                 $lastday \DateTime::createFromFormat("Y-m-d H:i:s"date("Y-08-01 00:00:00"));
  3143.                 if ((substr($sejour->getCodeSejour(), 11) == 'F')) {
  3144.                     $flag true;
  3145.                     $parent_sejours $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour));
  3146.                     $prixConnPArt $sejour->getPrixcnxpartenaire();
  3147.                     $nbrConexxion $nbrConexxion sizeof($parent_sejours);
  3148.                     $prixtotal $prixConnPArt sizeof($parent_sejours);
  3149.                     $prixtotPArt $prixtotPArt $prixtotal;
  3150.                 }
  3151.             }
  3152.             $cconnexionFree $cconnexionFree $prixtotPArt;
  3153.         }
  3154.         return [$cconnexionFree$nbrConexxion];
  3155.     }
  3156.     function caConnexionTotalFreeParPart($part)
  3157.     {
  3158.         $etabs $this->em->getRepository(Etablisment::class)->findAll();
  3159.         $cconnexionFree 0;
  3160.         $nbrConexxion 0;
  3161.         foreach ($etabs as $etab) {
  3162.             if ($etab->getId() == $part) {
  3163.                 $sejours $this->em->getRepository(Sejour::class)->findBy(array("idEtablisment" => $etab));
  3164.                 $prixtotPArt 0;
  3165.                 $flag false;
  3166.                 foreach ($sejours as $sejour) {
  3167.                     $lastday \DateTime::createFromFormat("Y-m-d H:i:s"date("Y-08-01 00:00:00"));
  3168.                     if ((substr($sejour->getCodeSejour(), 11) == 'F')) {
  3169.                         $flag true;
  3170.                         $parent_sejours $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour));
  3171.                         $prixConnPArt $sejour->getPrixcnxpartenaire();
  3172.                         $nbrConexxion $nbrConexxion sizeof($parent_sejours);
  3173.                         $prixtotal $prixConnPArt sizeof($parent_sejours);
  3174.                         $prixtotPArt $prixtotPArt $prixtotal;
  3175.                     }
  3176.                 }
  3177.                 $cconnexionFree $cconnexionFree $prixtotPArt;
  3178.             }
  3179.         }
  3180.         return [$cconnexionFree$nbrConexxion];
  3181.     }
  3182.     function caConnexionTotalPaye()
  3183.     {
  3184.         $prixtotPArt 0;
  3185.         $flag false;
  3186.         $parent_sejours $this->em->getRepository(ParentSejour::class)->findBy(array("payment" => 1));
  3187.         $prixConnPArt 2.9;
  3188.         $nbrConexxion sizeof($parent_sejours);
  3189.         $prixtotal $prixConnPArt sizeof($parent_sejours);
  3190.         $prixtotPArt $prixtotPArt $prixtotal;
  3191.         return [$prixtotPArt$nbrConexxion];
  3192.     }
  3193.     function caConnexionTotalPayeParPart($part)
  3194.     {
  3195.         $prixtotPArt 0;
  3196.         $flag false;
  3197.         $parent_sejours $this->em->getRepository(ParentSejour::class)->findBy(array("payment" => 1));
  3198.         $prixConnPArt 2.9;
  3199.         $nbrConexxion 0;
  3200.         foreach ($parent_sejours as $sej) {
  3201.             if ($sej->getIdSejour()->getIdEtablisment()->getId() == $part) {
  3202.                 $nbrConexxion $nbrConexxion 1;
  3203.             }
  3204.         }
  3205.         $prixtotal $prixConnPArt $nbrConexxion;
  3206.         $prixtotPArt $prixtotPArt $prixtotal;
  3207.         return [$prixtotPArt$nbrConexxion];
  3208.     }
  3209.     function caConnexionTotal()
  3210.     {
  3211.         return [$this->caConnexionTotalPaye()[0] + $this->caConnexionTotalFree()[0], $this->caConnexionTotalPaye()[1] + $this->caConnexionTotalFree()[1]];
  3212.     }
  3213.     function caConnexionTotalParPart($part)
  3214.     {
  3215.         return [$this->caConnexionTotalPayeParPart($part)[0] + $this->caConnexionTotalFreeParPart($part)[0], $this->caConnexionTotalPayeParPart($part)[1] + $this->caConnexionTotalFreeParPart($part)[1]];
  3216.     }
  3217.     function caProduit()
  3218.     {
  3219.         return $this->em->getRepository(Commande::class)->caProduit();
  3220.     }
  3221.     //Le nombre de comptes ouverts
  3222.     //Le nombre comptes activés
  3223.     //Le nombre de commande en cours
  3224.     //Le nombre de commande moyen par sejour
  3225.     //Le CA connexion en cours (décomposé en connexion payé partenaire et connexion payé par parent)
  3226.     //Le montant du panier moyen
  3227.     //Le nombre moyen de produits par commande
  3228.     //Montant du reversement connexion
  3229.     //Montant de reversement commande
  3230.     function caConnexionTotalFreeEncour()
  3231.     {
  3232.         $cconnexionFree 0;
  3233.         $nbrConexxion 0;
  3234.         $sejours $this->em->getRepository(Sejour::class)->findSejourListEncourFree();
  3235.         // dd($sejours);
  3236.         $prixtotPArt 0;
  3237.         $flag false;
  3238.         foreach ($sejours as $sejour) {
  3239.             if ((substr($sejour->getCodeSejour(), 11) == 'F')) {
  3240.                 $flag true;
  3241.                 $parent_sejours $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour->getId()));
  3242.                 $prixConnPArt $sejour->getPrixcnxpartenaire();
  3243.                 $nbrConexxion $nbrConexxion sizeof($parent_sejours);
  3244.                 $prixtotal $prixConnPArt sizeof($parent_sejours);
  3245.                 $prixtotPArt $prixtotPArt $prixtotal;
  3246.             }
  3247.         }
  3248.         return $prixtotPArt;
  3249.     }
  3250.     function caConnexionTotalFreeEncourParPart($part)
  3251.     {
  3252.         $cconnexionFree 0;
  3253.         $nbrConexxion 0;
  3254.         $sejours $this->em->getRepository(Sejour::class)->findSejourListEncourFreeParPart($part);
  3255.         // dd($sejours);
  3256.         $prixtotPArt 0;
  3257.         $flag false;
  3258.         foreach ($sejours as $sejour) {
  3259.             if ((substr($sejour->getCodeSejour(), 11) == 'F')) {
  3260.                 $flag true;
  3261.                 $parent_sejours $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour->getId()));
  3262.                 $prixConnPArt $sejour->getPrixcnxpartenaire();
  3263.                 $nbrConexxion $nbrConexxion sizeof($parent_sejours);
  3264.                 $prixtotal $prixConnPArt sizeof($parent_sejours);
  3265.                 $prixtotPArt $prixtotPArt $prixtotal;
  3266.             }
  3267.         }
  3268.         return $prixtotPArt;
  3269.     }
  3270.     function caConnexionTotalPayEncour()
  3271.     {
  3272.         $sejours $this->em->getRepository(Sejour::class)->findSejourListEncourPay();
  3273.         $someparsejour 0;
  3274.         foreach ($sejours as $sejour) {
  3275.             $parent_sejours $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour->getId(), 'payment' => 1));
  3276.             $someparsejour $someparsejour + (sizeof($parent_sejours) * 2.9);
  3277.         }
  3278.         //    var_dump($someparsejour);
  3279.         return $someparsejour;
  3280.     }
  3281.     function caConnexionTotalPayEncourParPart($part)
  3282.     {
  3283.         $sejours $this->em->getRepository(Sejour::class)->findSejourListEncourPay();
  3284.         $someparsejour 0;
  3285.         foreach ($sejours as $sejour) {
  3286.             // var_dump($sejour);
  3287.             if ($sejour->getIdEtablisment()->getId() == $part) {
  3288.                 $parent_sejours $this->em->getRepository(ParentSejour::class)->findBy(array("idSejour" => $sejour->getId(), 'payment' => 1));
  3289.                 $someparsejour $someparsejour + (sizeof($parent_sejours) * 2.9);
  3290.             }
  3291.         }
  3292.         //    var_dump($someparsejour);
  3293.         return $someparsejour;
  3294.     }
  3295.     public function Formaterarraydate($arraytoFormat$chantest)
  3296.     {
  3297.         $arrayFInal = array();
  3298.         foreach ($arraytoFormat as $entit) {
  3299.             // var_dump($entit->$chantest()->format('d/m/Y'));
  3300.             if (array_key_exists($entit->$chantest()->format('d/m/Y'), $arrayFInal)) {
  3301.                 array_push($arrayFInal$entit);
  3302.             } else {
  3303.                 $arrayFInal[$entit->$chantest()->format('d/m/Y')] = array($entit);
  3304.             }
  3305.         }
  3306.         return $arrayFInal;
  3307.     }
  3308.     public function FormaterarraydateBetween($arraytoFormat$chanttestDEb$chantestEnd$dateDEbut$dateFinoriginal)
  3309.     {
  3310.         //         var_dump("dateFin1");
  3311.         //         var_dump($dateFin);
  3312.         $arrayFInal = array();
  3313.         $dateFin = clone $dateFinoriginal;
  3314.         $dateFin->modify('+1 day');
  3315.         $period = new DatePeriod(
  3316.             $dateDEbut,
  3317.             new DateInterval('P1D'),
  3318.             $dateFin
  3319.         );
  3320.         foreach ($period as $key => $value) {
  3321.             $arrayFInal[$value->format('d/m/Y')] = array();
  3322.             foreach ($arraytoFormat as $entit) {
  3323.                 if ($value <= $entit->$chantestEnd() && $value >= $entit->$chanttestDEb())
  3324.                     if (array_key_exists($value->format('d/m/Y'), $arrayFInal)) {
  3325.                         array_push($arrayFInal[$value->format('d/m/Y')], $entit->getCodeSejour());
  3326.                     } else {
  3327.                         $arrayFInal[$value->format('d/m/Y')] = array($entit->getCodeSejour());
  3328.                     }
  3329.             }
  3330.         }
  3331.         return $arrayFInal;
  3332.     }
  3333.     public function FormaterarraydateBetweennbrEnfant($arraytoFormat$chanttestDEb$chantestEnd$dateDEbut$dateFin)
  3334.     {
  3335.         $arrayFInal = array();
  3336.         $totalenf 0;
  3337.         foreach ($arraytoFormat as $entit) {
  3338.             if (array_key_exists($entit->getCodeSejour(), $arrayFInal)) {
  3339.                 $arrayFInal[$entit->getCodeSejour()]['nbrenfdec'] = $arrayFInal[$entit->getCodeSejour()]['nbrenfdec'] + $entit->getNbenfan();
  3340.                 $arrayFInal[$entit->getCodeSejour()]['nbrParentCncte'] = $arrayFInal[$entit->getCodeSejour()]['nbrParentCncte'] + $entit->getCountParentSejour();
  3341.             } else {
  3342.                 $arrayFInal[$entit->getCodeSejour()] = array('nbrenfdec' => $entit->getNbenfan(), 'nbrParentCncte' => $entit->getCountParentSejour());
  3343.             }
  3344.             $totalenf $totalenf $entit->getNbenfan();
  3345.         }
  3346.         $arrayFInal $this->sort_col($arrayFInal'nbrParentCncte');
  3347.         $arrayFInal['totenf'] = $totalenf;
  3348.         return  $arrayFInal;
  3349.     }
  3350.     public function FormaterarraydateBetweennbrPArentCncte($arraytoFormat$chanttest$dateDEbut$dateFinoriginal)
  3351.     {
  3352.         $arrayFInal = array();
  3353.         $dateFin = clone $dateFinoriginal;
  3354.         $dateFin->modify('+1 day');
  3355.         $period = new DatePeriod(
  3356.             $dateDEbut,
  3357.             new DateInterval('P1D'),
  3358.             $dateFin
  3359.         );
  3360.         foreach ($period as $key => $value) {
  3361.             $arrayFInal[$value->format('d/m/Y')] = 0;
  3362.             foreach ($arraytoFormat as $entit) {
  3363.                 if ($value->format('d/m/Y') == $entit->$chanttest()->format('d/m/Y')) {
  3364.                     if (array_key_exists($value->format('d/m/Y'), $arrayFInal)) {
  3365.                         $arrayFInal[$value->format('d/m/Y')] = $arrayFInal[$value->format('d/m/Y')] + 1;
  3366.                     } else {
  3367.                         $arrayFInal[$value->format('d/m/Y')] = 1;
  3368.                     }
  3369.                 }
  3370.             }
  3371.         }
  3372.         return $arrayFInal;
  3373.     }
  3374.     function sort_col($table$colname)
  3375.     {
  3376.         $tn $ts $temp_num $temp_str = array();
  3377.         //    dd($table);
  3378.         foreach ($table as $key => $row) {
  3379.             /*        var_dump($colname);
  3380.         var_dump($key);
  3381.         var_dump($row[$colname]);
  3382.         var_dump(substr($row[$colname],0,1));
  3383.         var_dump(is_numeric(substr($row[$colname],0,1)));
  3384.         var_dump($key);
  3385.  
  3386.         echo '<br>';
  3387.  */
  3388.             if (is_numeric(substr($row[$colname], 01))) {
  3389.                 $tn[$key] = $row[$colname];
  3390.                 $temp_num[$key] = $row;
  3391.             } else {
  3392.                 $ts[$key] = $row[$colname];
  3393.                 $temp_str[$key] = $row;
  3394.             }
  3395.         }
  3396.         unset($table);
  3397.         array_multisort($tnSORT_DESCSORT_NUMERIC$temp_num);
  3398.         array_multisort($tsSORT_DESCSORT_STRING$temp_str);
  3399.         return array_merge($temp_num$temp_str);
  3400.     }
  3401.     function EnvoyerEmailNewAccompagnateurPlus($partenaire)
  3402.     {
  3403.         $logo '';
  3404.         $nom '';
  3405.         if ($partenaire->hasRole('ROLE_PARTENAIRE')) {
  3406.             $logo $partenaire->getLogourl();
  3407.             $nom $partenaire->getNometablisment();
  3408.         }
  3409.         $RefEmail $this->em->getRepository(Ref::class)->find(17);
  3410.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail));
  3411.         $sendTo $partenaire->getEmail();
  3412.         $message = (new \Swift_Message('Nouveau partenaire'))
  3413.             ->setFrom('partenariat-contact@5sur5sejour.com')
  3414.             ->setTo($sendTo);
  3415.         //->setBcc(["contact@5sur5sejour.com"]);
  3416.         $pathImage2 $Email->getIdImage2()->getPath();
  3417.         $pathImage1 $Email->getIdImage1()->getPath();
  3418.         $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  3419.         $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  3420.         $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  3421.         $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  3422.         $icon2 $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  3423.         $icon3 $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  3424.         $message->setBody(
  3425.             $this->templating->render(
  3426.                 'emails/AccompagnateurPlusNew.html.twig',
  3427.                 [
  3428.                     "Nomdestinataire" => $partenaire->getNom(),
  3429.                     "Predestinataire" => $partenaire->getPrenom(),
  3430.                     "password" => $partenaire->getPasswordNonCripted(),
  3431.                     "image1" => $image1,
  3432.                     "image2" => $image2,
  3433.                     "icon2" => $icon2,
  3434.                     "icon3" => $icon3,
  3435.                     "iconfooter" => $iconfooter,
  3436.                     "iconmsg" => $iconmsg,
  3437.                     "idPartenaire" => $partenaire->getId(),
  3438.                     "identifiant" => $sendTo,
  3439.                     "password" => $partenaire->getPasswordNonCripted(),
  3440.                     'logo' => $logo,
  3441.                     'nom' => $nom,
  3442.                 ]
  3443.             ),
  3444.             'text/html'
  3445.         );
  3446.         $signMail $this->params->get('signMail');
  3447.         if ($signMail == 'yes') {
  3448.             $domainName $this->params->get('domaine');
  3449.             $selector $this->params->get('selector');
  3450.             $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  3451.             $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  3452.             $message->attachSigner($signer);
  3453.         }
  3454.         try {
  3455.             $this->mailer->send($message);
  3456.         } catch (\Swift_SwiftException $ex) {
  3457.             $ex->getMessage();
  3458.         }
  3459.     }
  3460.     function EnvoyerEmailSejourRecapProduitsSansCommandes($nomfilevalid)
  3461.     {
  3462.         $logo '';
  3463.         $nom '';
  3464.         $RefEmail $this->em->getRepository(Ref::class)->find(29);
  3465.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  3466.         $sendTo "touhemib@gmail.com";
  3467.         $message = (new \Swift_Message('Produits sans commanes'))
  3468.             ->setFrom('touhemib@gmail.com')
  3469.             ->setTo($sendTo);
  3470.         $pathImage2 $Email->getIdImage2()->getPath();
  3471.         $pathImage1 $Email->getIdImage1()->getPath();
  3472.         $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  3473.         $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  3474.         $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  3475.         $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  3476.         $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  3477.         $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  3478.         $message->attach(Swift_Attachment::fromPath($this->projectDir '/public/message//' $nomfilevalid)->setFilename('Recap_Excel_ProduitsSansCommandes.xlsx'));
  3479.         $message->setBody(
  3480.             $this->templating->render(
  3481.                 // Firas : completer Twig
  3482.                 'emails/RecapParentsCreerProduitsSansCommande.html.twig',
  3483.                 [
  3484.                     "image1" => $image1,
  3485.                     "image2" => $image2,
  3486.                     "iconfooter" => $iconfooter,
  3487.                     "iconphoto" => $iconphoto,
  3488.                     "iconloca" => $iconloca,
  3489.                     "iconmsg" => $iconmsg,
  3490.                     'logo' => $logo,
  3491.                     'nom' => $nom,
  3492.                 ]
  3493.             ),
  3494.             'text/html'
  3495.         );
  3496.         $signMail $this->params->get('signMail');
  3497.         if ($signMail == 'yes') {
  3498.             $domainName $this->params->get('domaine');
  3499.             $selector $this->params->get('selector');
  3500.             $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  3501.             $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  3502.             $message->attachSigner($signer);
  3503.         }
  3504.         try {
  3505.             $this->mailer->send($message);
  3506.         } catch (\Swift_SwiftException $ex) {
  3507.             $ex->getMessage();
  3508.         }
  3509.     }
  3510.     function EnvoyerMailExport($nomfilevalid)
  3511.     {
  3512.         $logo '';
  3513.         $nom '';
  3514.         $RefEmail $this->em->getRepository(Ref::class)->find(29);
  3515.         $Email $this->em->getRepository(Emailing::class)->findOneBy(array('typeemail' => $RefEmail'statut' => 9));
  3516.         $sendTo "touhemib@gmail.com";
  3517.         $message = (new \Swift_Message('Export'))
  3518.             ->setFrom('contact@5sur5sejour.com')
  3519.             ->setTo(['touhemib@gmail.com''yousra.tlich@gmail.com']);
  3520.         $pathImage2 $Email->getIdImage2()->getPath();
  3521.         $pathImage1 $Email->getIdImage1()->getPath();
  3522.         $image1 $message->embed(Swift_Image::fromPath("$pathImage1"));
  3523.         $image2 $message->embed(Swift_Image::fromPath("$pathImage2"));
  3524.         $iconphoto $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_419_pqx0dx.png"));
  3525.         $iconloca $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719650/Groupe_420_uynuqz.png"));
  3526.         $iconmsg $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Groupe_418_wbyysk.png"));
  3527.         $iconfooter $message->embed(Swift_Image::fromPath("https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png"));
  3528.         $message->attach(Swift_Attachment::fromPath($this->projectDir '/public/message//' $nomfilevalid)->setFilename('Recap_Excel_ProduitsSansCommandes.xlsx'));
  3529.         $message->setBody(
  3530.             $this->templating->render(
  3531.                 // Firas : completer Twig
  3532.                 'emails/RecapParentsCreerProduitsSansCommande.html.twig',
  3533.                 [
  3534.                     "image1" => $image1,
  3535.                     "image2" => $image2,
  3536.                     "iconfooter" => $iconfooter,
  3537.                     "iconphoto" => $iconphoto,
  3538.                     "iconloca" => $iconloca,
  3539.                     "iconmsg" => $iconmsg,
  3540.                     'logo' => $logo,
  3541.                     'nom' => $nom,
  3542.                 ]
  3543.             ),
  3544.             'text/html'
  3545.         );
  3546.         $signMail $this->params->get('signMail');
  3547.         if ($signMail == 'yes') {
  3548.             $domainName $this->params->get('domaine');
  3549.             $selector $this->params->get('selector');
  3550.             $PrivateKey file_get_contents($this->params->get('pathDKIM'));
  3551.             $signer = new \Swift_Signers_DKIMSigner($PrivateKey$domainName$selector);
  3552.             $message->attachSigner($signer);
  3553.         }
  3554.         try {
  3555.             $this->mailer->send($message);
  3556.         } catch (\Swift_SwiftException $ex) {
  3557.             $ex->getMessage();
  3558.         }
  3559.     }
  3560.     public function creationPromotion($code$type$nbreMaxGeneral$nbreMaxParUser$dateDebut$dateFin$etat$pourcentage$nbreApplique$strategie)
  3561.     {
  3562.         $statutCreate $this->em->getRepository(Ref::class)->find(1);
  3563.         $promotion = new Promotions();
  3564.         $promotion->setCode($code);
  3565.         $promotion->setType($type);
  3566.         $promotion->setNbreMaxGeneral(intval($nbreMaxGeneral));
  3567.         $promotion->setNbreMaxParUser(intval($nbreMaxParUser));
  3568.         $promotion->setDateCreation(new \DateTime());
  3569.         $promotion->setStatut($statutCreate);
  3570.         $dateDebutFormat date_create_from_format('Y-m-d'$dateDebut);
  3571.         $promotion->setDateDebut($dateDebutFormat);
  3572.         $dateFinFormat date_create_from_format('Y-m-d'$dateFin);
  3573.         $promotion->setDateFin($dateFinFormat);
  3574.         $promotion->setEtat(intval($etat));
  3575.         $promotion->setPourcentage(intval($pourcentage));
  3576.         $promotion->setStrategie($strategie);
  3577.         $promotion->setNbreApplicable($nbreApplique);
  3578.         $this->em->getManager()->persist($promotion);
  3579.         $this->em->getManager()->flush();
  3580.         return $promotion;
  3581.     }
  3582.     public function listePromotions()
  3583.     {
  3584.         $promotions $this->em->getRepository(Promotions::class)->findBy(array('statut' => 1));
  3585.         return $promotions;
  3586.     }
  3587.     public function detailsPromotion($idPromo)
  3588.     {
  3589.         $promotion $this->em->getRepository(Promotions::class)->find($idPromo);
  3590.         return $promotion;
  3591.     }
  3592.     public  function deletePromotion($idPromo)
  3593.     {
  3594.         $promotion $this->em->getRepository(Promotions::class)->find($idPromo);
  3595.         $statutDelete $this->em->getRepository(Ref::class)->find(39);
  3596.         if ($promotion) {
  3597.             $promotion->setStatut($statutDelete);
  3598.             $this->em->getManager()->persist($promotion);
  3599.             $this->em->getManager()->flush();
  3600.         }
  3601.         return $promotion;
  3602.     }
  3603.     public function updatePromotion($idPromo$type$nbreMaxGeneral$nbreMaxParUser$dateDebut$dateFin$etat$pourcentage$nbreApplique)
  3604.     {
  3605.         $promotion $this->em->getRepository(Promotions::class)->find($idPromo);
  3606.         if ($promotion) {
  3607.             if ($promotion->getType() == "parents") {
  3608.                 $tabParentsPromo $this->em->getRepository(PromoParents::class)->findBy(array('promotion' => $promotion));
  3609.                 if (sizeof($tabParentsPromo)) {
  3610.                     foreach ($tabParentsPromo as $pp) {
  3611.                         $this->em->remove($pp);
  3612.                         $this->em->getManager()->flush();
  3613.                     }
  3614.                 }
  3615.             }
  3616.             if ($promotion->getType() == "codeSejour") {
  3617.                 $tabSejourParents $this->em->getRepository(PromoSejour::class)->findBy(array('promotion' => $promotion));
  3618.                 if (sizeof($tabSejourParents)) {
  3619.                     foreach ($tabSejourParents as $pp) {
  3620.                         $this->em->remove($pp);
  3621.                         $this->em->getManager()->flush();
  3622.                     }
  3623.                 }
  3624.             }
  3625.             $promotion->setType($type);
  3626.             $promotion->setNbreMaxGeneral(intval($nbreMaxGeneral));
  3627.             $promotion->setNbreMaxParUser(intval($nbreMaxParUser));
  3628.             $dateDebutFormat date_create_from_format('Y-m-d'$dateDebut);
  3629.             $promotion->setDateDebut($dateDebutFormat);
  3630.             $dateFinFormat date_create_from_format('Y-m-d'$dateFin);
  3631.             $promotion->setDateFin($dateFinFormat);
  3632.             $promotion->setEtat(intval($etat));
  3633.             $promotion->setPourcentage(intval($pourcentage));
  3634.             $promotion->setNbreApplicable($nbreApplique);
  3635.             $this->em->getManager()->persist($promotion);
  3636.             $this->em->getManager()->flush();
  3637.         }
  3638.         return $promotion;
  3639.     }
  3640.     public function findPromotionByCode($code)
  3641.     {
  3642.         $promotion $this->em->getRepository(Promotions::class)->findOneBy(array('code' => $code'etat' => 1));
  3643.         return $promotion;
  3644.     }
  3645.     public function checkCodePromoForCreation($code)
  3646.     {
  3647.         $promotion $this->em->getRepository(Promotions::class)->findOneBy(array('code' => $code));
  3648.         if ($promotion) {
  3649.             $tab['test'] = true;
  3650.             $tab['pourcentage'] = $promotion->getPourcentage();
  3651.             return $tab;
  3652.         } else {
  3653.             $tab['test'] = false;
  3654.             $tab['pourcentage'] = 0;
  3655.             return $tab;
  3656.         }
  3657.     }
  3658.     public function checkCodePromoPrents($code$user)
  3659.     {
  3660.         $promotion $this->em->getRepository(Promotions::class)->findOneBy(array('code' => $code'etat' => 1));
  3661.         if ($promotion && $user->getShowdetailsphotos() != "4") {
  3662.             $tab['test'] = true;
  3663.             $tab['pourcentage'] = $promotion->getPourcentage();
  3664.             return $tab;
  3665.         } else {
  3666.             $tab['test'] = false;
  3667.             $tab['pourcentage'] = 0;
  3668.             return $tab;
  3669.         }
  3670.     }
  3671.     public function checkCodePromo($code)
  3672.     {
  3673.         $promotion $this->em->getRepository(Promotions::class)->findOneBy(array('code' => $code'etat' => 1));
  3674.         if ($promotion) {
  3675.             $tab['test'] = true;
  3676.             $tab['pourcentage'] = $promotion->getPourcentage();
  3677.             return $tab;
  3678.         } else {
  3679.             $tab['test'] = false;
  3680.             $tab['pourcentage'] = 0;
  3681.             return $tab;
  3682.         }
  3683.     }
  3684.     public function changerEtatPromotion($idPromotion$etat)
  3685.     {
  3686.         $promotion $this->em->getRepository(Promotions::class)->find($idPromotion);
  3687.         if ($promotion) {
  3688.             $promotion->setEtat(intval($etat));
  3689.             $this->em->getManager()->persist($promotion);
  3690.             $this->em->getManager()->flush();
  3691.         }
  3692.         return $promotion;
  3693.     }
  3694.     public function createLogPromotion($idPromotion$idCommande$idClient)
  3695.     {
  3696.         $logPromotion = new LogPromotions();
  3697.         $logPromotion->setIdPromotion($idPromotion);
  3698.         $logPromotion->setIdClient($idClient);
  3699.         $logPromotion->setIdCommande($idCommande);
  3700.         $logPromotion->setDateCreation(new \DateTime());
  3701.         $this->em->getManager()->persist($logPromotion);
  3702.         $this->em->getManager()->flush();
  3703.         return $logPromotion;
  3704.     }
  3705.     public function checkCodePromoParUser($idPromo$idClient)
  3706.     {
  3707.         $promotion $this->em->getRepository(Promotions::class)->find($idPromo);
  3708.         $tabLogPromo $this->em->getRepository(LogPromotions::class)->findBy(array('idPromotion' => $idPromo'idClient' => $idClient));
  3709.         $nbreMaxParUser $promotion->getNbreMaxParUser();
  3710.         $nbreLog sizeOf($tabLogPromo);
  3711.         if ($nbreLog == $nbreMaxParUser) {
  3712.             return false;
  3713.         } else {
  3714.             return true;
  3715.         }
  3716.     }
  3717.     public function checkCodePromoAvance($code$idClient$idSejour$role$panier)
  3718.     {
  3719.         $panierElPromo = [];
  3720.         $promotion $this->em->getRepository(Promotions::class)->findOneBy(array('code' => $code'etat' => 1));
  3721.         if ($promotion) {
  3722.             $type $promotion->getType();
  3723.             $affectedProducts $promotion->getStrategie();
  3724.             if ($affectedProducts != 'all' && trim($affectedProducts) != null) {
  3725.                 foreach ($panier as $element) {
  3726.                     $panierProduit $this->em->getRepository(PanierProduit::class)->findOneBy(array('idPanier' => $element['id']));
  3727.                     if ($panierProduit) {
  3728.                         $produit $panierProduit->getIdProduit();
  3729.                         if ($produit->getType()->getId() == $affectedProducts) {
  3730.                             $panierElPromo[] = $element['id'];
  3731.                         }
  3732.                     }
  3733.                 }
  3734.                 if (!$panierElPromo) {
  3735.                     $tab['test'] = false;
  3736.                     $tab['pourcentage'] = 0;
  3737.                     return $tab;
  3738.                 }
  3739.             }
  3740.             if (($role == "ROLE_ACC" && $type == "accompagnateur") || ($type == "parent" && $role == "ROLE_PARENT")) {
  3741.                 $tabLogPromo $this->em->getRepository(LogPromotions::class)->findBy(array('idPromotion' => $promotion'idClient' => $idClient));
  3742.                 $nbreMaxParUser $promotion->getNbreMaxParUser();
  3743.                 $nbreLog sizeOf($tabLogPromo);
  3744.                 if ($nbreMaxParUser != && $nbreLog == $nbreMaxParUser) {
  3745.                     $tab['test'] = false;
  3746.                     $tab['pourcentage'] = 0;
  3747.                     return $tab;
  3748.                 } else {
  3749.                     $tab['test'] = true;
  3750.                     $tab['pourcentage'] = $promotion->getPourcentage();
  3751.                     $tab['remise'] = $this->caclRemiseInPanier($panier$promotion->getStrategie(), $promotion->getNbreApplicable(), $promotion->getPourcentage());
  3752.                     return $tab;
  3753.                 }
  3754.             } elseif ($type == "parents" || $type == "Parents") {
  3755.                 $client $this->em->getRepository(User::class)->find($idClient);
  3756.                 $promoParents $this->em->getRepository(PromoParents::class)->findOneBy(array('promotion' => $promotion'parent' => $client));
  3757.                 if ($promoParents) {
  3758.                     $tabLogPromo $this->em->getRepository(LogPromotions::class)->findBy(array('idPromotion' => $promotion'idClient' => $idClient));
  3759.                     $nbreMaxParUser $promotion->getNbreMaxParUser();
  3760.                     $nbreLog sizeOf($tabLogPromo);
  3761.                     if ($nbreMaxParUser != && $nbreLog == $nbreMaxParUser) {
  3762.                         $tab['test'] = false;
  3763.                         $tab['pourcentage'] = 0;
  3764.                         return $tab;
  3765.                     } else {
  3766.                         $tab['test'] = true;
  3767.                         $tab['pourcentage'] = $promotion->getPourcentage();
  3768.                         $tab['remise'] = $this->caclRemiseInPanier($panier$promotion->getStrategie(), $promotion->getNbreApplicable(), $promotion->getPourcentage());
  3769.                         return $tab;
  3770.                     }
  3771.                 } else {
  3772.                     $tab['test'] = false;
  3773.                     $tab['pourcentage'] = 0;
  3774.                     return $tab;
  3775.                 }
  3776.             } elseif ($type == "codeSejour") {
  3777.                 $sejour $this->em->getRepository(Sejour::class)->find($idSejour);
  3778.                 $PromoSejour $this->em->getRepository(PromoSejour::class)->findOneBy(array('promotion' => $promotion'sejour' => $sejour));
  3779.                 if ($PromoSejour) {
  3780.                     $tabLogPromo $this->em->getRepository(LogPromotions::class)->findBy(array('idPromotion' => $promotion'idClient' => $idClient));
  3781.                     $nbreMaxParUser $promotion->getNbreMaxParUser();
  3782.                     $nbreLog sizeOf($tabLogPromo);
  3783.                     if ($nbreMaxParUser != && $nbreLog == $nbreMaxParUser) {
  3784.                         $tab['test'] = false;
  3785.                         $tab['pourcentage'] = 0;
  3786.                         return $tab;
  3787.                     } else {
  3788.                         $tab['test'] = true;
  3789.                         $tab['pourcentage'] = $promotion->getPourcentage();
  3790.                         $tab['remise'] = $this->caclRemiseInPanier($panier$promotion->getStrategie(), $promotion->getNbreApplicable(), $promotion->getPourcentage());
  3791.                         return $tab;
  3792.                     }
  3793.                 } else {
  3794.                     $tab['test'] = false;
  3795.                     $tab['pourcentage'] = 0;
  3796.                     return $tab;
  3797.                 }
  3798.             } else {
  3799.                 $tab['test'] = false;
  3800.                 $tab['pourcentage'] = 0;
  3801.                 return $tab;
  3802.             }
  3803.         } else {
  3804.             $tab['test'] = false;
  3805.             $tab['pourcentage'] = 0;
  3806.             return $tab;
  3807.         }
  3808.     }
  3809.     public function caclRemiseInPanier($panier$strategie$nbreApplique$pourcentage)
  3810.     {
  3811.         $ttc 0;
  3812.         $qte 0;
  3813.         $tabPrices = array();
  3814.         $remise 0;
  3815.         if ($nbreApplique == 1) {
  3816.             foreach ($panier as $item) {
  3817.                 $ttc += $item['mnt'] * $item['qte'];
  3818.             }
  3819.             $remise = ($ttc 100) * $pourcentage;
  3820.         } else {
  3821.             foreach ($panier as $item) {
  3822.                 // $ttc += $item['mnt'] * $item['qte'];
  3823.                 for ($i 0$i <  $item['qte']; $i++) {
  3824.                     array_push($tabPrices$item['mnt']);
  3825.                 }
  3826.                 $qte += $item['qte'];
  3827.             }
  3828.             //    dd($tabPrices);
  3829.             rsort($tabPrices);
  3830.             //    dd($tabPrices);
  3831.             $x intval($qte $nbreApplique);
  3832.             $tabPricesPromo =   array_slice($tabPrices, -$x$xtrue);
  3833.             //    $tabPricesSansPromo=   array_slice($tabPrices,0,sizeof($tabPrices)-$x,true);
  3834.             foreach ($tabPricesPromo as $p) {
  3835.                 $remise += ($p 100) * $pourcentage;
  3836.             }
  3837.         }
  3838.         return $remise;
  3839.     }
  3840.     public function getInfoSejour($sejour)
  3841.     {
  3842.         //info sejour
  3843.         $infoSejour = array(
  3844.             'code_sejour' => $sejour->getCodeSejour(),
  3845.             'date_debut_sejour' => $sejour->getDateDebutSejour(),
  3846.             'date_fin_sejour' => $sejour->getDateFinSejour(),
  3847.             'theme_sejour' => $sejour->getThemSejour(),
  3848.             'nombre_enfants' => $sejour->getNbenfan()
  3849.         );
  3850.         $adresseSejour = array(
  3851.             'code_postale' => $sejour->getCodePostal(),
  3852.             'adresse' => $sejour->getAdresseSejour(),
  3853.             'ville' => $sejour->getVille(),
  3854.             'pays' => $sejour->getPays()
  3855.         );
  3856.         //info acco
  3857.         $accompagnateur $this->em->getRepository(User::class)->find($sejour->getIdAcommp());
  3858.         $detailsAccompagnateur = array(
  3859.             'nom' => $accompagnateur->getNom(),
  3860.             'prenom' => $accompagnateur->getPrenom(),
  3861.             'email' => $accompagnateur->getEmail()
  3862.         );
  3863.         //info partenaire
  3864.         $partenaire $this->em->getRepository(User::class)->find($sejour->getIdPartenaire());
  3865.         $detailsPartenaire = array(
  3866.             'nom' => $partenaire->getNom(),
  3867.             'prenom' => $partenaire->getPrenom(),
  3868.             'email' => $partenaire->getEmail()
  3869.         );
  3870.         //info etablissement
  3871.         $etablissement $this->em->getRepository(Etablisment::class)->find($sejour->getIdEtablisment());
  3872.         $detailsEtablissement = array(
  3873.             'nom' => $etablissement->getNometab(),
  3874.             'type' => $etablissement->getTypeetablisment(),
  3875.             'codePostale' => $etablissement->getCodepostaleatb(),
  3876.             'adresse' => $etablissement->getAdresseetab(),
  3877.             'ville' => $etablissement->getVille(),
  3878.             'pays' => $etablissement->getPays(),
  3879.         );
  3880.         $nombrePhotos $this->em->getRepository(SejourAttachment::class)->SearchNombrephotoonsejour($sejour->getId());
  3881.         $nombreAudio $this->em->getRepository(SejourAttachment::class)->NombreMessageSejour($sejour->getId());
  3882.         $listeDescription $this->em->getRepository(Jourdescripdate::class)->findBy(array('idsejour' => $sejour));
  3883.         $nombreDescriptions sizeof($listeDescription);
  3884.         $detailsSejour = array(
  3885.             'info_sejour' => $infoSejour,
  3886.             'adresse_sejour' => $adresseSejour,
  3887.             'info_accompagnateur' => $detailsAccompagnateur,
  3888.             'info_partenaire' => $detailsPartenaire,
  3889.             'info_etablissement' => $detailsEtablissement,
  3890.             'nombrePhotos' => $nombrePhotos,
  3891.             'nombreAudio' => $nombreAudio,
  3892.             'nombreDescriptions' => $nombreDescriptions,
  3893.             'listeDescriptions' => $listeDescription
  3894.         );
  3895.         return  $detailsSejour;
  3896.     }
  3897.     /**
  3898.      * Service that generate a random list of photos
  3899.      * @author Firas Belhadj firasbelhadj686@gmail.com
  3900.      * @param array $listeFavorites The list of favorites
  3901.      * @param array $listAlbum The list of sejour photos
  3902.      * @param int $number The number of photos to generate
  3903.      * @param string $strategy The generation strategy (optional)
  3904.      * @return array $randomList
  3905.      */
  3906.     public function generateRandomAlbum(array $listeFavorites, array $listAlbumint $numberstring $strategy 'FAVORITES_FIRST'): array
  3907.     {
  3908.         $randomList = [];
  3909.         $randFave = [];
  3910.         foreach ($listeFavorites as $key => $fav) {
  3911.             $randFave[$key]['id'] = $fav->getIdSejourAttchment()->getIdAttchment()->getId();
  3912.             $randFave[$key]['path'] = $fav->getIdSejourAttchment()->getIdAttchment()->getPath();
  3913.         }
  3914.         if ($strategy == 'FAVORITES_FIRST') {
  3915.             shuffle($listAlbum);
  3916.             if ($randFave) {
  3917.                 shuffle($randFave);
  3918.                 if (count($randFave) < $number) {
  3919.                     $remaining $number count($randFave);
  3920.                     $randomList array_merge($randFavearray_slice($listAlbum0$remaining));
  3921.                 } else {
  3922.                     $randomList array_slice($randFave0$number);
  3923.                 }
  3924.                 return $randomList;
  3925.             }
  3926.             $randomList array_slice($listAlbum0$number);
  3927.         }
  3928.         return $randomList;
  3929.     }
  3930.     function EnvoyerEmailRappelActivation($accompagnateur$sejour)
  3931.     {
  3932.         try {
  3933.             return $this->emailsCmdService->sendMail(
  3934.                 $accompagnateur->getEmail(),
  3935.                 'Rappel : Activez votre séjour sur 5sur5sejour',
  3936.                 'rappel-activation-sejour',
  3937.                 [
  3938.                     'accompagnateur' => $accompagnateur,
  3939.                     'sejour' => $sejour,
  3940.                     'password' => $accompagnateur->getPasswordNonCripted(),
  3941.                     'image1' => 'https://res.cloudinary.com/apss-factory/image/upload/a_exif/v1582274063/qw7csxayektmq1leqjpp.png',
  3942.                     'iconfooter' => 'https://res.cloudinary.com/apss-factory/image/upload/v1582719651/Picto5sur5_rapbfy.png'
  3943.                 ],
  3944.                 [], // pas de pièces jointes
  3945.                 true // mettre en queue
  3946.             );
  3947.         } catch (\Exception $e) {
  3948.             return false;
  3949.         }
  3950.     }
  3951.   
  3952. }