src/Controller/FrontController.php line 705

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Faqs;
  4. use App\Entity\Blogs;
  5. use App\Entity\Avis;
  6. use App\Entity\Themes;
  7. use App\Entity\Galeries;
  8. use App\Entity\Villes;
  9. use App\Entity\Thematiques;
  10. use App\Entity\Actualites;
  11. use App\Entity\Formations;
  12. use App\Entity\References;
  13. use App\Entity\Mentions;
  14. use App\Entity\Managements;
  15. use App\Entity\Bannieres;
  16. use App\Entity\Demandeformations;
  17. use App\Entity\Expertises;
  18. use App\Entity\Themeshanghai;
  19. use App\Entity\Newsletters;
  20. use App\Entity\Inscriptions;
  21. use App\Entity\Popups;
  22. use App\Entity\Videos;
  23. use App\Entity\Albums;
  24. use App\Form\RechercheFormType;
  25. use App\Form\RechercheNatFormType;
  26. use Doctrine\ORM\EntityManager;
  27. use App\Form\BlogFormType;
  28. use App\Form\ProduitFormType;
  29. use App\Form\InscriptionFormType;
  30. use App\Form\NewInscriptionFormType;
  31. use App\Service\GeoIpService;
  32. use App\Repository\BlogsRepository;
  33. use App\Repository\DemandeformationsRepository;
  34. use App\Repository\InscriptionsRepository;
  35. use App\Repository\AvisRepository;
  36. use App\Repository\ManagementsRepository;
  37. use App\Repository\MentionsRepository;
  38. use App\Repository\VillesRepository;
  39. use App\Repository\GaleriesRepository;
  40. use App\Repository\ThemesRepository;
  41. use App\Repository\FormationsRepository;
  42. use App\Repository\AboutsRepository;
  43. use App\Repository\ThematiquesRepository;
  44. use App\Repository\ValeursRepository;
  45. use App\Repository\BannieresRepository;
  46. use App\Repository\ActualitesRepository;
  47. use App\Repository\PartenairesRepository;
  48. use App\Repository\ReferenceclientsRepository;
  49. use App\Repository\InformationsRepository;
  50. use App\Repository\AlbumsRepository;
  51. use App\Repository\VideosRepository;
  52. use App\Repository\ExpertisesRepository;
  53. use App\Repository\ThemeshanghaiRepository;
  54. use App\Repository\NewslettersRepository;
  55. use App\Entity\Certificats;
  56. use App\Form\CertificatFormType;
  57. use App\Form\EditCertificatFormType;
  58. use App\Repository\CertificatsRepository;
  59. //use Symfony\Component\Mime\Email;
  60. use Symfony\Component\HttpFoundation\Request;
  61. use Symfony\Component\HttpFoundation\Response;
  62. use Symfony\Component\Routing\Annotation\Route;
  63. use Symfony\Component\String\Slugger\SluggerInterface;
  64. use App\Form\ContactFormType;
  65. use App\Form\NewsletterFormType;
  66. use App\Form\DevisFormType;
  67. use App\Form\CombinedFormType;
  68. use App\Form\DemandeformationFormType;
  69. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  70. use Symfony\Component\Mime\Email;
  71. use Symfony\Component\Mailer\MailerInterface;
  72. use Symfony\Component\HttpFoundation\JsonResponse;
  73. use Knp\Component\Pager\PaginatorInterface;
  74. use Doctrine\ORM\EntityManagerInterface;
  75. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  76. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  77. use App\Entity\Certyous;
  78. use App\Form\CertyouFormType;
  79. use App\Entity\Inscriptionpersos;
  80. use App\Form\EditCertyouFormType;
  81. use App\Repository\CertyousRepository;
  82. use App\Form\InscriptionCertyouFormType;
  83. use App\Repository\InscriptionpersosRepository;
  84. use App\Repository\PopupsRepository;
  85. use App\Repository\ChatbotConversationRepository;
  86. use App\Repository\ChatbotSessionRepository;
  87. use App\Service\Chatbot\ChatbotTrackingService;
  88. use App\Entity\Sessions;
  89. use App\Form\SessionFormType;
  90. use App\Form\EditSessionFormType;
  91. use App\Repository\SessionsRepository;
  92. use Symfony\Contracts\HttpClient\HttpClientInterface;
  93. class FrontController extends AbstractController
  94. {
  95.     private HttpClientInterface $client;
  96.     public function __construct(HttpClientInterface $client)
  97.     {
  98.         $this->client = $client;
  99.     }
  100.    
  101.     #[Route('/', name: 'front.inter.index', methods:['GET'])]
  102.     public function index(
  103.         Request $request, 
  104.         MentionsRepository $mentionRepository,
  105.         ThematiquesRepository $thematiqueRepository, 
  106.         BannieresRepository $banniereRepository,
  107.         ReferenceclientsRepository $referenceRepository, 
  108.         EntityManagerInterface $entityManager
  109.     ): Response
  110.     {
  111.         $thematiqueLimit = $thematiqueRepository->findBy([], ['id' => 'DESC'], 20 );
  112.         //dd($thematiqueLimit);
  113.         $annee = date('Y');
  114.        // 1️⃣ Requête Doctrine (sans tri sur dates_session)
  115.         $queryBuilder = $entityManager->createQueryBuilder();
  116.         $queryBuilder
  117.             ->select(
  118.                 'for.id','for.image','for.dates_session','for.prix','for.devise','for.annee','th.nom',
  119.                 'th.slug','thm.nom AS thmnom','vil.nom AS vilnom','vil.pays'
  120.             )
  121.             ->from(Formations::class, 'for')
  122.             ->innerJoin(Themes::class, 'th', 'WITH', 'for.theme = th.id')
  123.             ->innerJoin(Villes::class, 'vil', 'WITH', 'for.ville = vil.id')
  124.             ->innerJoin(Thematiques::class, 'thm', 'WITH', 'th.thematique = thm.id');
  125.         $formations = $queryBuilder->getQuery()->getResult();
  126.         
  127.         $today = new \DateTimeImmutable('today');
  128.         $moisFr = [
  129.             'janv' => 1, 'janvier' => 1,
  130.             'févr' => 2, 'fevr' => 2, 'février' => 2,
  131.             'mars' => 3,
  132.             'avr' => 4, 'avril' => 4,
  133.             'mai' => 5,
  134.             'juin' => 6,
  135.             'juil' => 7, 'juillet' => 7,
  136.             'août' => 8, 'aout' => 8,
  137.             'sept' => 9, 'septembre' => 9,
  138.             'oct' => 10, 'octobre' => 10,
  139.             'nov' => 11, 'novembre' => 11,
  140.             'déc' => 12, 'dec' => 12, 'décembre' => 12
  141.         ];
  142.         // Extraire la date réelle de début
  143.         $formationsAvecDate = [];
  144.         foreach ($formations as $formation) {
  145.         
  146.             $text = mb_strtolower(trim($formation['dates_session']), 'UTF-8');
  147.         
  148.             $text = preg_replace('/^du\s+/u', '', $text);
  149.             $text = str_replace('.', '', $text);
  150.         
  151.             if (!preg_match(
  152.                 '/(\d{1,2})(?:\s+([a-zéûôî]+))?\s+au\s+(\d{1,2})\s+([a-zéûôî]+)/iu',
  153.                 $text,
  154.                 $m
  155.             )) {
  156.                 continue;
  157.             }
  158.         
  159.             $jour = (int) $m[1];
  160.         
  161.             // Si le mois de début est absent, utiliser le mois de fin.
  162.             $moisTexte = !empty($m[2]) ? $m[2] : $m[4];
  163.         
  164.             $mois = $moisFr[$moisTexte] ?? null;
  165.         
  166.             if (!$mois) {
  167.                 continue;
  168.             }
  169.         
  170.             // Utiliser directement l'année de la base de données.
  171.             $annee = (int) $formation['annee'];
  172.         
  173.             if ($annee <= 0) {
  174.                 continue;
  175.             }
  176.         
  177.             $dateString = sprintf('%04d-%02d-%02d', $annee, $mois, $jour);
  178.         
  179.             $dateDebut = \DateTimeImmutable::createFromFormat(
  180.                 '!Y-m-d',
  181.                 $dateString
  182.             );
  183.         
  184.             if (!$dateDebut || $dateDebut->format('Y-m-d') !== $dateString) {
  185.                 continue;
  186.             }
  187.         
  188.             // Ne conserver que les formations dont le début est à venir.
  189.             if ($dateDebut < $today) {
  190.                 continue;
  191.             }
  192.         
  193.             $formationsAvecDate[] = [
  194.                 'formation' => $formation,
  195.                 'date' => $dateDebut
  196.             ];
  197.         }
  198.         // Trier par date croissante.
  199.         usort($formationsAvecDate, function ($a, $b) {
  200.             return $a['date'] <=> $b['date'];
  201.         });
  202.         // Récupérer les 3 formations les plus proches.
  203.         $formations = array_map(
  204.             fn($item) => $item['formation'],
  205.             array_slice($formationsAvecDate, 0, 3)
  206.         );
  207.         
  208.         
  209.         
  210.         $queryBuilder = $entityManager->createQueryBuilder();
  211.         $queryBuilder
  212.         ->select('actu')
  213.         ->from(Actualites::class, 'actu')
  214.         ->orderBy('actu.createdat', 'DESC')
  215.         ->setMaxResults(2);
  216.         $actualite = $queryBuilder->getQuery()->getResult();
  217.         $reference = $referenceRepository->findAll();
  218.         $mentions = $mentionRepository->findAll();
  219.         
  220.         $bannieres = $banniereRepository->findAll();
  221.         // dd($mentions);
  222.         
  223.         return $this->render('front/index.html.twig',[
  224.             'annee' => $annee,
  225.             'banniere' => $bannieres,
  226.             'mentions' => $mentions,
  227.             'reference' => $reference,
  228.             'formations' => $formations,
  229.             'thematiqueLimit' => $thematiqueLimit,
  230.             'actualite' => $actualite
  231.         ]);
  232.     }
  233.     
  234.     #[Route('/mediatheque/albums', name: 'front.inter.album', methods:['GET'])]
  235.     public function album(
  236.         Request $request, 
  237.         PaginatorInterface $paginator,
  238.         AlbumsRepository $albumRepository,
  239.         VideosRepository $videoRepository,
  240.         MentionsRepository $mentionRepository,
  241.         EntityManagerInterface $entityManager
  242.     ): Response
  243.     {
  244.         $queryBuilder = $entityManager->createQueryBuilder();
  245.         $queryBuilder
  246.             ->select('al, MIN(g.imgGal) AS image')
  247.             ->from(Albums::class, 'al')
  248.             ->innerJoin(Galeries::class, 'g', 'WITH', 'al.slug = g.nom')
  249.             ->where('al.statut = :statut')
  250.             ->setParameter('statut', 'Publié')
  251.             ->groupBy('al.id')
  252.             ->orderBy('al.createdat', 'DESC');
  253.         $albums = $queryBuilder->getQuery()->getResult();
  254.         //dd($albums);
  255.         $pagination = $paginator->paginate(
  256.             $queryBuilder,
  257.             $request->query->getInt('page', 1),
  258.             12
  259.         );  
  260.         /*$albums = $albumRepository->findAll();
  261.         $videos = $videoRepository->findAll();*/
  262.         $mentions = $mentionRepository->findAll();
  263.         return $this->render('front/multimedia/album.html.twig',[
  264.             'pagination' => $pagination,
  265.             'mentions' => $mentions
  266.         ]);
  267.     }
  268.     
  269.     #[Route('/notre-expertise', name: 'front.inter.expertise', methods:['GET'])]
  270.     public function expertise(
  271.         Request $request, 
  272.         ReferenceclientsRepository $referenceRepository,
  273.         ExpertisesRepository $expertiseRepository,
  274.         MentionsRepository $mentionRepository,
  275.         EntityManagerInterface $entityManager
  276.     ): Response
  277.     {
  278.         $expertise = $expertiseRepository->findBy(['statut' => 'Publié']);
  279.         //dd($expertise);
  280.         $mentions = $mentionRepository->findAll();
  281.         $reference = $referenceRepository->findAll();
  282.         //dd($reference);
  283.         return $this->render('front/expertise.html.twig',[
  284.             'reference' => $reference,
  285.             'expertise' => $expertise,
  286.             'mentions' => $mentions
  287.         ]);
  288.     }
  289.     
  290.     #[Route('/mediatheque/album/{slug}', name: 'front.inter.image', methods:['GET'])]
  291.     public function galerie(
  292.         $slug,
  293.         Request $request, 
  294.         AlbumsRepository $albumRepository,
  295.         GaleriesRepository $galerieRepository,
  296.         MentionsRepository $mentionRepository,
  297.         EntityManagerInterface $entityManager
  298.     ): Response
  299.     {
  300.         //$galerie = $galerieRepository->findBy(['nom' => $slug]);
  301.         $queryBuilder = $entityManager->createQueryBuilder()
  302.             ->select('gal.nom, gal.imgGal AS image')
  303.             ->from(Galeries::class, 'gal')
  304.             ->where('gal.nom = :slug')
  305.             ->setParameter('slug', $slug);
  306.         $galerie = $queryBuilder->getQuery()->getArrayResult(); // retourne un tableau
  307.         $mentions = $mentionRepository->findAll();
  308.         return $this->render('front/multimedia/galerie.html.twig',[
  309.             'slug' => $slug,
  310.             'galeries' => $galerie,
  311.             'mentions' => $mentions
  312.         ]);
  313.     }
  314.     #[Route('/mediatheque/video', name: 'front.inter.video', methods:['GET'])]
  315.     public function video(
  316.         Request $request, 
  317.         VideosRepository $videoRepository,
  318.         MentionsRepository $mentionRepository,
  319.         EntityManagerInterface $entityManager
  320.     ): Response
  321.     {
  322.         $videos = $videoRepository->findBy(
  323.             ['statut' => 'Publié'],
  324.             ['createdat' => 'DESC']
  325.         );
  326.         //dd($videos);
  327.         $mentions = $mentionRepository->findAll();
  328.         return $this->render('front/multimedia/video.html.twig',[
  329.             'videos' => $videos,
  330.             'mentions' => $mentions
  331.         ]);
  332.     }
  333.     
  334.     //-----------------------------------------------------------------------------------------------------
  335.     
  336.     #[Route('/formations/certificats/certificats-internationaux-II', name: 'front.inter.certificat.certyou', methods:['GET'])]
  337.     public function certificat_certyou(
  338.         Request $request, 
  339.         PaginatorInterface $paginator,
  340.         CertyousRepository $certyouRepository,
  341.         ManagementsRepository $managementRepository,
  342.         MentionsRepository $mentionRepository,
  343.         EntityManagerInterface $entityManager
  344.     ): Response
  345.     {
  346.         $certyou = $certyouRepository->findAll();
  347.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  348.         
  349.         $queryBuilder = $entityManager->createQueryBuilder();
  350.         $queryBuilder
  351.         ->select(
  352.             'cert.id','cert.prixpresentiel','cert.prixvirtuelle',
  353.             'cert.devise','cert.theme','cert.duree','cert.slug',
  354.             'cert.type','cert.createdat'
  355.         )
  356.         ->from(Certyous::class, 'cert');
  357.         $certyous = $queryBuilder->getQuery()->getResult();
  358.         
  359.         $pagination = $paginator->paginate(
  360.             $queryBuilder,
  361.             $request->query->getInt('page', 1),
  362.             12
  363.         );  
  364.         
  365.         $mentions = $mentionRepository->findAll();
  366.         return $this->render('front/certyou.html.twig',[
  367.             'manageLimit' => $manageLimit,
  368.             'pagination' => $certyous,
  369.             'mentions' => $mentions,
  370.         ]);
  371.     }
  372.     
  373.     ///---------------------------------------------------------------------------------------------------
  374.     
  375.     #[Route('/formations/certificats/certificats-internationaux-II/{slug}/code{id}', name: 'front.inter.certificat.certyou.inscription', methods:['GET','POST'])]
  376.     public function certificat_certyou_inscription(
  377.         $id,
  378.         $slug,
  379.         Request $request, 
  380.         MailerInterface $mailer,
  381.         PaginatorInterface $paginator,
  382.         CertyousRepository $certyouRepository,
  383.         SessionsRepository $sessionRepository,
  384.         ManagementsRepository $managementRepository,
  385.         MentionsRepository $mentionRepository,
  386.         EntityManagerInterface $entityManager
  387.     ): Response
  388.     {
  389.         //$certyou = $certyouRepository->findAll();
  390.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  391.         
  392.         $queryBuilder = $entityManager->createQueryBuilder();
  393.         $queryBuilder
  394.             ->select('cert')
  395.             ->from(Certyous::class, 'cert')
  396.             ->where('cert.slug = :slug')
  397.             ->setParameter('slug', $slug);
  398.         $certyou = $queryBuilder->getQuery()->getOneOrNullResult();
  399.         if (!$certyou) {
  400.             $this->addFlash('danger','Certificat introuvable');
  401.         }
  402.         $nomTheme = $certyou?->getTheme();
  403.         $Inscriptionpersos = new Inscriptionpersos();
  404.         $InscriptionCertyouForm = $this->createForm(InscriptionCertyouFormType::class,null, [
  405.             'certyou' => $certyou
  406.         ]);
  407.         $InscriptionCertyouForm->handleRequest($request);
  408.         
  409.         if($InscriptionCertyouForm->isSubmitted()){
  410.             $theme = str_replace('-', ' ', $slug);
  411.             $choix = htmlspecialchars($InscriptionCertyouForm->get('choix')->getData());
  412.             $type = htmlspecialchars($InscriptionCertyouForm->get('type')->getData());
  413.             $lieux = htmlspecialchars($InscriptionCertyouForm->get('lieu')->getData());
  414.             $sessionEntity = $InscriptionCertyouForm->get('session')->getData();
  415.             $session = $sessionEntity ? $sessionEntity->getSession() : '';
  416.             //$choix = $certyou->getType();
  417.             $duree = $certyou->getDuree();
  418.             $devise = $certyou->getDevise();
  419.             
  420.             //$duree = htmlspecialchars($InscriptionCertyouForm->get('duree')->getData());
  421.             //$prixvirtuelle = htmlspecialchars($InscriptionCertyouForm->get('prixvirtuelle')->getData());
  422.             //$prixpresentiel = htmlspecialchars($InscriptionCertyouForm->get('prixpresentiel')->getData());
  423.             //$prixVirtuelle   = $certificat->getPrixvirtuelle();
  424.             //$prixPresentiel  = $certificat->getPrixpresentiel();
  425.             $civilite = $InscriptionCertyouForm->get('civilite')->getData();
  426.             $nom = $InscriptionCertyouForm->get('nom')->getData();
  427.             $prenoms = $InscriptionCertyouForm->get('prenoms')->getData();
  428.             $fonction = $InscriptionCertyouForm->get('fonction')->getData();
  429.             $adresse = $InscriptionCertyouForm->get('adresse')->getData();
  430.             $mail = $InscriptionCertyouForm->get('mail')->getData();
  431.             $entreprise = $InscriptionCertyouForm->get('entreprise')->getData();
  432.             
  433.             $siteweb = $InscriptionCertyouForm->get('siteweb')->getData();
  434.             $nbparticipant = $InscriptionCertyouForm->get('nbparticipant')->getData();
  435.             $pays = $InscriptionCertyouForm->get('pays')->getData();
  436.             $ville = $InscriptionCertyouForm->get('ville')->getData();
  437.             $boitepostale = $InscriptionCertyouForm->get('boitepostale')->getData();
  438.             $whatsapp = $InscriptionCertyouForm->get('whatsapp')->getData();            
  439.             
  440.             $telephone = $InscriptionCertyouForm->get('telephone')->getData();
  441.             $commentaire = $InscriptionCertyouForm->get('commentaire')->getData(); 
  442.             
  443.             $token = $InscriptionCertyouForm->get('recaptchaToken')->getData();
  444.             
  445.             if ($type === 'presentiel') {
  446.                 //$prix = 'presentiel ' . $InscriptionCertyouForm->get('prixpresentiel')->getData();
  447.                 $prix = $certyou->getPrixpresentiel();
  448.             } else {
  449.                 //$prix = 'virtuelle ' . $InscriptionCertyouForm->get('prixvirtuelle')->getData();
  450.                 $prix = $certyou->getPrixvirtuelle();
  451.             }
  452.             
  453.             if ($lieux === '') {
  454.                 $lieu = 'classe uniquement virtuelle';
  455.             } else {
  456.                 $lieu = $lieux;
  457.             }
  458.             
  459.             if(!$commentaire){
  460.                 $commentaire = " ";
  461.             }else{
  462.                 $commentaire = $InscriptionCertyouForm->get('commentaire')->getData();
  463.             }
  464.             
  465.             /*dd($nom ,$prenoms ,$fonction ,$adresse ,$mail ,$entreprise ,$siteweb ,$nbparticipant ,$pays ,$ville ,$boitepostale ,
  466.             $whatsapp, $telephone, $theme, $type, $duree, $lieu, $prix, $session, $commentaire);*/
  467.             
  468.             $destinataire = 'mailinscriptions@cimef-international.org';
  469.             $expediteur   = $mail;
  470.             $reponse      = $expediteur;
  471.             $suj = "INSCRIPTION FORMATION 2026";
  472.             
  473.             $codehtml = '<html><body>'.
  474.             '<table width="100%" cellpadding="0" cellspacing="0" style="background-color:#f4f6f8; padding:20px;">
  475.             <tr>
  476.             <td align="center">
  477.             <table width="600" cellpadding="0" cellspacing="0" style="background-color:#ffffff; border-radius:6px; overflow:hidden; box-shadow:0 2px 6px rgba(0,0,0,0.08);">
  478.             <tr>
  479.             <td style="background-color:#051a53; padding:20px; color:#ffffff; text-align:center;">
  480.             <h2 style="margin:0;">Confirmation d\'inscription</h2>
  481.             </td>
  482.             </tr>
  483.             <tr>
  484.             <td style="padding:25px; color:#333333; font-size:14px; line-height:1.6;">
  485.             <p>Inscription de '.$civilite.' '.$prenoms.' '.$nom.' à la formation <strong>'.$theme.'</strong> organisée par <strong>CIMEF International</strong>.</p>
  486.             <p>Veuillez trouver ci-dessous le récapitulatif :</p>
  487.             <hr style="border:none; border-top:1px solid #e0e0e0; margin:20px 0;">
  488.             <h4 style="margin-bottom:8px; color:#0d6efd;">Informations personnelles</h4>
  489.             <p>
  490.             <strong>Nom & Prénoms :</strong> '.$prenoms.' '.$nom.'<br>
  491.             <strong>Fonction :</strong> '.$fonction.'<br>
  492.             <strong>Entreprise :</strong> '.$entreprise.'<br>
  493.             <strong>Adresse :</strong> '.$adresse.'<br>
  494.             <strong>Pays / Ville :</strong> '.$pays.' / '.$ville.'<br>
  495.             <strong>Boîte postale :</strong> '.$boitepostale.'
  496.             </p>
  497.             <h4 style="margin-bottom:8px; color:#0d6efd;">Coordonnées</h4>
  498.             <p>
  499.             <strong>Email :</strong> '.$mail.'<br>
  500.             <strong>Téléphone :</strong> '.$telephone.'<br>
  501.             <strong>WhatsApp :</strong> '.$whatsapp.'<br>
  502.             <strong>Site web :</strong> '.$siteweb.'
  503.             </p>
  504.             <h4 style="margin-bottom:8px; color:#0d6efd;">Détails de participation</h4>
  505.             <p>
  506.             <strong>Nombre de participants :</strong> '.$nbparticipant.'<br>
  507.             <strong>Commentaire :</strong> '.$commentaire.'
  508.             </p>
  509.             <h4 style="margin-bottom:8px; color:#0d6efd;">Détail de la formation</h4>
  510.             <p>
  511.             <strong>Thème :</strong> '.$theme.'<br>
  512.             <strong>Type :</strong> '.$type.'<br>
  513.             <strong>Durée :</strong> '.$duree.'<br>
  514.             <strong>Lieu :</strong> '.$lieu.'<br>
  515.             <strong>Prix :</strong> '.$prix.' '.$devise.'<br>
  516.             <strong>Session :</strong> '.$session.'
  517.             </p>
  518.             </td>
  519.             </tr>
  520.             <tr>
  521.             <td style="background-color:#f1f1f1; padding:15px; text-align:center; font-size:12px; color:#777777;">
  522.             © '.date("Y").' CIMEF International — Tous droits réservés
  523.             </td>
  524.             </tr>
  525.             </table>
  526.             </td>
  527.             </tr>
  528.             </table>
  529.             </body></html>';
  530.             
  531.             $response = $this->client->request(
  532.                 'POST',
  533.                 'https://www.google.com/recaptcha/api/siteverify',
  534.                 [
  535.                     'body' => [
  536.                         'secret' => $_ENV['RECAPTCHA_SECRET_KEY'],
  537.                         'response' => $token,
  538.                     ]
  539.                 ]
  540.             );
  541.             $result = $response->toArray();
  542.             if (!$result['success'] || !isset($result['score']) || $result['score'] < 0.5) {
  543.                 return $this->addFlash('warning','Vérification reCAPTCHA échouée.');
  544.             }   
  545.             
  546.             /*
  547.             $secretKey = '6LfPYkosAAAAAJQFLCC-9U5bF6KdFTPrgmbxg5Ux';
  548.             $value = $request->get('g-recaptcha-response');
  549.             if (!$value) { 
  550.                 $this->addFlash('warning', 'Veuillez cocher le reCAPTCHA'); 
  551.                 return $this->redirectToRoute('front.seminaire.nationaux',['seminaires' => $seminaires,'slug' => $slug]);
  552.             }
  553.             $userIP = $_SERVER['REMOTE_ADDR'];
  554.             $url = "https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$value&remoteip=$userIP";
  555.             $response = \file_get_contents($url);
  556.             $response = json_decode((string)$response);
  557.             //dd($response);
  558.             if(!$response->success){
  559.                 $this->addFlash('warning','Cocher le champs recaptcha svp!');
  560.                 return $this->redirectToRoute('front.seminaire.nationaux',['seminaires' => $seminaires,'slug' => $slug]);
  561.             }
  562.             */
  563.            
  564.             $email = (new Email())
  565.             ->from('CIMEF International <mailinscriptions@cimef-international.org>')
  566.             ->to($destinataire)                 // destinataire principal
  567.             ->cc('medias@cimef-international.com') // COPIE
  568.             ->replyTo($expediteur)              // Reply-To:
  569.             ->subject($suj)     
  570.             ->text(strip_tags($codehtml))
  571.             ->html($codehtml);// Subject:
  572.             //->html($codehtml, 'text/html');   // Content-Type + charset utf-8
  573.             $mailer->send($email);
  574.             
  575.             
  576.             $Inscriptionpersos->setNom($nom);
  577.             $Inscriptionpersos->setPrenoms($prenoms);
  578.             $Inscriptionpersos->setFonction($fonction);
  579.             $Inscriptionpersos->setAdresse($adresse);
  580.             $Inscriptionpersos->setMail($mail);
  581.             $Inscriptionpersos->setEntreprise($entreprise);
  582.             $Inscriptionpersos->setSiteweb($siteweb);
  583.             $Inscriptionpersos->setNbparticipant($nbparticipant);
  584.             $Inscriptionpersos->setPays($pays);
  585.             $Inscriptionpersos->setVille($ville);
  586.             $Inscriptionpersos->setBoitepostale($boitepostale);
  587.             $Inscriptionpersos->setWhatsapp($whatsapp);
  588.             $Inscriptionpersos->setTelephone($telephone);
  589.             $Inscriptionpersos->setCommentaire($commentaire);
  590.             $Inscriptionpersos->setTheme($theme);
  591.             $Inscriptionpersos->setType($type);
  592.             $Inscriptionpersos->setDuree($duree);
  593.             $Inscriptionpersos->setLieu($lieu);
  594.             $Inscriptionpersos->setPrix($prix);
  595.             $Inscriptionpersos->setSession($session);
  596.             
  597.             $entityManager->persist($Inscriptionpersos);
  598.             $entityManager->flush();
  599.             $this->addFlash(
  600.             'success',
  601.             'Votre inscription à été bien enregistrée');
  602.             return $this->redirectToRoute('front.inter.certificat.certyou',['slug' => $slug,'id' => $id]);
  603.         }
  604.         
  605.         //dd($nomTheme);
  606.    
  607.         $mentions = $mentionRepository->findAll();
  608.         return $this->render('front/inscriptions/inscription-certyou.html.twig',[
  609.             'id' => $id,
  610.             'slug' => $slug,
  611.             'theme' => $nomTheme,
  612.             'certyou' => $certyou,
  613.             'mentions' => $mentions,
  614.             'manageLimit' => $manageLimit,
  615.             'inscriptionCertyouForm' => $InscriptionCertyouForm->createView(),
  616.         ]);
  617.     }
  618.     //-----------------------------------------------------------------------------------------------------
  619.     
  620.     #[Route('/formations/certificats/certificats-internationaux-I', name: 'front.inter.certificat.inter', methods:['GET'])]
  621.     public function certificat(
  622.         Request $request, 
  623.         PaginatorInterface $paginator,
  624.         CertificatsRepository $certificatRepository,
  625.         ManagementsRepository $managementRepository,
  626.         MentionsRepository $mentionRepository,
  627.         EntityManagerInterface $entityManager
  628.     ): Response
  629.     {
  630.         $certificat = $certificatRepository->findAll();
  631.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  632.         
  633.         $queryBuilder = $entityManager->createQueryBuilder();
  634.         $sub = $entityManager->createQueryBuilder()
  635.             ->select('MAX(c2.createdat)')
  636.             ->from(Certificats::class, 'c2')
  637.             ->where('c2.theme = cert.theme');
  638.         $queryBuilder
  639.             ->select('cert.id','cert.session','cert.prix','cert.slug','cert.devise',
  640.                 'vil.nom AS vilnom','vil.pays','cert.createdat','cert.type','cert.theme')
  641.             ->from(Certificats::class, 'cert')
  642.             ->innerJoin(Villes::class, 'vil', 'WITH', 'cert.ville = vil.id')
  643.             ->where($queryBuilder->expr()->eq('cert.createdat', '(' . $sub->getDQL() . ')'))
  644.             ->orderBy('cert.createdat', 'DESC');
  645.         $certificat = $queryBuilder->getQuery()->getResult();
  646.         $pagination = $paginator->paginate(
  647.             $queryBuilder,
  648.             $request->query->getInt('page', 1),
  649.             12
  650.         );  
  651.             
  652.         $mentions = $mentionRepository->findAll();
  653.         return $this->render('front/certificat.html.twig',[
  654.             'manageLimit' => $manageLimit,
  655.             'pagination' => $certificat,
  656.             'mentions' => $mentions,
  657.         ]);
  658.     }
  659.     #[Route('/formtaions/certificats/certificats-internationaux-I/{slug}', name: 'front.inter.detail.certificat', methods:['GET'])]
  660.     public function detail_certificat(
  661.         $slug,
  662.         Request $request, 
  663.         PaginatorInterface $paginator,
  664.         CertificatsRepository $certificatRepository,
  665.         ManagementsRepository $managementRepository,
  666.         MentionsRepository $mentionRepository,
  667.         EntityManagerInterface $entityManager
  668.     ): Response
  669.     {
  670.         $certificat = $certificatRepository->findAll();
  671.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  672.         
  673.         $queryBuilder = $entityManager->createQueryBuilder();
  674.         $queryBuilder
  675.             ->select(
  676.                 'cert.id','cert.session','cert.prix','cert.slug',
  677.                 'cert.devise','cert.theme','vil.nom AS vilnom',
  678.                 'vil.pays','cert.createdat','cert.type'
  679.             )
  680.             ->from(Certificats::class, 'cert')
  681.             ->innerJoin(Villes::class, 'vil', 'WITH', 'cert.ville = vil.id')
  682.             ->where('cert.slug = :slug')
  683.             ->setParameter('slug', $slug);
  684.         $certificat = $queryBuilder->getQuery()->getResult();
  685.         $pagination = $paginator->paginate(
  686.             $queryBuilder,
  687.             $request->query->getInt('page', 1),
  688.             12
  689.         ); 
  690.             
  691.         $mentions = $mentionRepository->findAll();
  692.         return $this->render('front/liste-certificat.html.twig',[
  693.             'manageLimit' => $manageLimit,
  694.             'pagination' => $pagination,
  695.             'mentions' => $mentions,
  696.             'slug' => $slug
  697.         ]);
  698.     }
  699.     
  700.     #[Route('/presentation', name: 'front.inter.presentation', methods:['GET'])]
  701.     public function presentation(
  702.         Request $request, 
  703.         PartenairesRepository $partenaireRepository,
  704.         FormationsRepository $formationRepository,
  705.         AboutsRepository $aboutRepository, 
  706.         ValeursRepository $valeurRepository,
  707.         AvisRepository $avisRepository,
  708.         MentionsRepository $mentionRepository,
  709.         EntityManagerInterface $entityManager
  710.     ): Response
  711.     {
  712.         $avis = $avisRepository->findAll();
  713.         $All_partenaire = $partenaireRepository->findAll();
  714.         $All_about = $aboutRepository->findAll();
  715.         $All_valeur = $valeurRepository->findAll();
  716.         $mentions = $mentionRepository->findAll();
  717.         return $this->render('front/qui-sommes-nous.html.twig',[
  718.             'partenaires' => $All_partenaire,
  719.             'valeur' => $All_valeur,
  720.             'mentions' => $mentions,
  721.             'about' => $All_about,
  722.             'avis' => $avis,
  723.         ]);
  724.     }
  725.     #[Route('/formations/rencontre-top-management', name: 'front.top.management', methods:['GET'])]
  726.     public function management(
  727.         Request $request, 
  728.         PaginatorInterface $paginator,
  729.         MentionsRepository $mentionRepository,
  730.         ManagementsRepository $managementRepository,
  731.         EntityManagerInterface $entityManager
  732.     ): Response
  733.     {
  734.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  735.         // dd($manageLimit);
  736.         $queryBuilder = $entityManager->createQueryBuilder();
  737.         $queryBuilder
  738.         ->select('man')
  739.         ->from(Managements::class, 'man')
  740.         ->orderBy('man.createdat', 'DESC');
  741.         $listmanagement = $queryBuilder->getQuery()->getResult();
  742.         
  743.         $pagination = $paginator->paginate(
  744.             $queryBuilder,
  745.             $request->query->getInt('page', 1),
  746.             10
  747.         );  
  748.         $mentions = $mentionRepository->findAll();
  749.         return $this->render('front/rencontre-management.html.twig',[
  750.             'mentions' => $mentions,
  751.             'pagination' => $listmanagement,
  752.             'manageLimit' => $manageLimit
  753.         ]);
  754.     }
  755.     
  756.     #[Route('/formations/rencontre-top-management/{slug}', name: 'front.seminaire.management.detail', methods:['GET'])]
  757.     public function detail_management(
  758.         $slug,
  759.         Request $request, 
  760.         ManagementsRepository $managementRepository,
  761.         MentionsRepository $mentionRepository,
  762.         EntityManagerInterface $entityManager
  763.     ): Response
  764.     {
  765.         $query = $managementRepository->findOneBy(array('slug' => $slug));
  766.         $mentions = $mentionRepository->findAll();
  767.         // dd($query);
  768.         return $this->render('front/detail/detail-rencontre.html.twig',[
  769.             'mentions' => $mentions,
  770.             'query' => $query,
  771.             'slug' => $slug
  772.         ]);
  773.     }
  774.     
  775.     #[Route('/formations/seminaires/internationaux', name: 'front.seminaire.internationaux', methods:['GET'])]
  776.     public function sem_inter(
  777.         Request $request,
  778.         PaginatorInterface $paginator,
  779.         MentionsRepository $mentionRepository,
  780.         EntityManagerInterface $entityManager
  781.     ): Response
  782.     {
  783.         $recherche = $this->createForm(RechercheFormType::class);
  784.         $recherche->handleRequest($request);
  785.         $annee    = (int) date('Y');
  786.         $today    = new \DateTime('today');
  787.         $mentions = $mentionRepository->findAll();
  788.         $qb = $entityManager->createQueryBuilder();
  789.         $qb->select('for', 'th', 'thm', 'vil')
  790.             ->from(Formations::class, 'for')
  791.             ->innerJoin('for.theme', 'th')
  792.             ->innerJoin('th.thematique', 'thm')
  793.             ->innerJoin('for.ville', 'vil')
  794.             ->where('vil.nom != :excluded')
  795.             ->setParameter('excluded', 'SHANGHAI')
  796.             ->orderBy('for.created_at', 'DESC');
  797.         if ($recherche->isSubmitted() && $recherche->isValid()) {
  798.             $mot = $recherche->get('mot')->getData();
  799.             if (empty($mot)) {
  800.                 $this->addFlash('warning', 'Veuillez sélectionner un thème pour la recherche.');
  801.                 return $this->redirectToRoute('front.seminaire.internationaux');
  802.             }
  803.             $ville = $recherche->get('ville')->getData();
  804.             if ($ville && strtoupper($ville->getNom()) === 'SHANGHAI') {
  805.                 $ville = null;
  806.             }
  807.             $nom = $mot->getNom();
  808.             $qb->andWhere($qb->expr()->orX('th.nom LIKE :mot', 'thm.nom LIKE :mot'))
  809.                ->setParameter('mot', '%' . $nom . '%');
  810.             if ($ville) {
  811.                 $qb->andWhere('vil = :ville')
  812.                    ->setParameter('ville', $ville);
  813.             }
  814.         }
  815.         $formations = $qb->getQuery()->getResult();
  816.         // Extrait la date de début à partir de "du 20 sept. au 01 oct." et de l'année de la formation
  817.         $extractDateDebut = function (?string $datesSession, ?int $anneeFormation): ?\DateTime {
  818.             if (!$datesSession) {
  819.                 return null;
  820.             }
  821.             $mois = [
  822.                 'janv'=>1,'janvier'=>1,
  823.                 'févr'=>2,'fevr'=>2,'février'=>2,
  824.                 'mars'=>3,
  825.                 'avr'=>4,'avril'=>4,
  826.                 'mai'=>5,
  827.                 'juin'=>6,
  828.                 'juil'=>7,'juillet'=>7,
  829.                 'août'=>8,'aout'=>8,
  830.                 'sept'=>9,'septembre'=>9,
  831.                 'oct'=>10,'octobre'=>10,
  832.                 'nov'=>11,'novembre'=>11,
  833.                 'déc'=>12,'dec'=>12,'décembre'=>12
  834.             ];
  835.             $text = mb_strtolower(str_replace(['.', ','], '', trim($datesSession)));
  836.             if (!preg_match(
  837.                 '/(\d{1,2})\s*(janv|févr|fevr|mars|avr|mai|juin|juil|août|aout|sept|oct|nov|déc)?\s*au\s*\d{1,2}\s*(janv|févr|fevr|mars|avr|mai|juin|juil|août|aout|sept|oct|nov|déc)/iu',
  838.                 $text,
  839.                 $m
  840.             )) {
  841.                 return null;
  842.             }
  843.             $jour    = (int) $m[1];
  844.             $moisTxt = $m[2] ?: $m[3];
  845.             $moisNum = $mois[$moisTxt] ?? null;
  846.             if (!$moisNum) {
  847.                 return null;
  848.             }
  849.             $an = $anneeFormation ?: (int) date('Y');
  850.             return new \DateTime(sprintf('%d-%02d-%02d', $an, $moisNum, $jour));
  851.         };
  852.         // Une seule session par thème : la plus proche à venir
  853.         $formationsParTheme = [];
  854.         foreach ($formations as $formation) {
  855.             $dateDebut = $extractDateDebut($formation->getDatesSession(), $formation->getAnnee());
  856.             if (!$dateDebut || $dateDebut < $today) {
  857.                 continue;
  858.             }
  859.             $themeId = $formation->getTheme()->getId();
  860.             if (
  861.                 !isset($formationsParTheme[$themeId]) ||
  862.                 $dateDebut < $formationsParTheme[$themeId]['date']
  863.             ) {
  864.                 $formationsParTheme[$themeId] = [
  865.                     'formation' => $formation,
  866.                     'date'      => $dateDebut,
  867.                 ];
  868.             }
  869.         }
  870.         // Tri par date de début croissante
  871.         uasort($formationsParTheme, fn($a, $b) => $a['date'] <=> $b['date']);
  872.         $formationsFinales = array_column($formationsParTheme, 'formation');
  873.         $pagination = $paginator->paginate(
  874.             $formationsFinales,
  875.             $request->query->getInt('page', 1),
  876.             12
  877.         );
  878.         return $this->render('front/seminaire_inter.html.twig', [
  879.             'annee'      => $annee,
  880.             'mentions'   => $mentions,
  881.             'pagination' => $pagination,
  882.             'recherche'  => $recherche->createView(),
  883.         ]);
  884.     }
  885.     
  886.     #[Route('/formations/seminaires/nationaux', name: 'front.seminaire.nationaux', methods:['GET'])]
  887.     public function semNat(
  888.         Request $request,
  889.         GeoIpService $geo,
  890.         PaginatorInterface $paginator,
  891.         MentionsRepository $mentionRepository,
  892.         EntityManagerInterface $entityManager
  893.     ): Response
  894.     {
  895.         $annee = date('Y');
  896.         $today = new \DateTime();
  897.     
  898.         // 🌍 Géo IP
  899.         $geoData = $geo->getGeoData($request->getClientIp());
  900.         $pays = $geoData['country'] ?? '';
  901.         $ville = $geoData['city'] ?? '';
  902.     
  903.     
  904.         // Correction du nom du pays
  905.         if ($pays === 'Local' || $pays === 'Ivory Coast') {
  906.             $getpays = "Côte d'ivoire";
  907.         } else {
  908.             $getpays = $pays;
  909.         }
  910.     
  911.         // 🔍 Formulaire de recherche
  912.         $rechercheNat = $this->createForm(RechercheNatFormType::class);
  913.         $rechercheNat->handleRequest($request);
  914.     
  915.         // 🔹 Requête pour récupérer les formations nationales
  916.         /*
  917.         $qb = $entityManager->createQueryBuilder()
  918.             ->select('f', 'th', 'thm', 'vil')
  919.             ->from(Formations::class, 'f')
  920.             ->innerJoin('f.theme', 'th')
  921.             ->innerJoin('th.thematique', 'thm')
  922.             ->innerJoin('f.ville', 'vil')
  923.             ->where('vil.pays = :pays')
  924.             ->setParameter('pays', $getpays);*/
  925.             
  926.         $qb = $entityManager->createQueryBuilder();
  927.         $qb->select('for', 'th', 'thm', 'vil')
  928.             ->from(Formations::class, 'for')
  929.             ->innerJoin('for.theme', 'th')
  930.             ->innerJoin('th.thematique', 'thm')
  931.             ->innerJoin('for.ville', 'vil')
  932.             ->where('vil.nom != :ville')
  933.             ->andWhere('for.annee != :annee')
  934.             ->setParameter('ville', 'SHANGHAI')
  935.             ->setParameter('annee', '2026')
  936.             ->orderBy('for.created_at', 'DESC');            
  937.             
  938.         // 🔍 Filtrer par recherche si soumise
  939.         if ($rechercheNat->isSubmitted() && $rechercheNat->isValid()) {
  940.             $mot = $rechercheNat->get('mot')->getData() ?? '';
  941.             if(empty($mot)){
  942.                 // Aucun thème sélectionné
  943.                 $this->addFlash('warning', 'Veuillez sélectionner un thème pour la recherche.');
  944.                 return $this->redirectToRoute('front.seminaire.nationaux'); // ou autre redirection
  945.             }
  946.             $nom = $mot->getNom();
  947.             if ($mot) {
  948.                 $qb->andWhere(
  949.                     $qb->expr()->orX(
  950.                         'th.nom LIKE :mot',
  951.                         'thm.nom LIKE :mot'
  952.                     )
  953.                 )->setParameter('mot', '%' . $nom . '%');
  954.             }
  955.         }
  956.     
  957.         // 📄 Récupération des formations
  958.         $formations = $qb->getQuery()->getResult();
  959.     
  960.         $extractDates = function(?string $datesSession): ?array {
  961.         if (!$datesSession) return null;
  962.     
  963.             $moisFr = [
  964.                 'janv'=>1,'janvier'=>1,'févr'=>2,'fevr'=>2,'février'=>2,
  965.                 'mars'=>3,'avr'=>4,'avril'=>4,'mai'=>5,'juin'=>6,
  966.                 'juil'=>7,'juillet'=>7,'août'=>8,'aout'=>8,
  967.                 'sept'=>9,'septembre'=>9,'oct'=>10,'octobre'=>10,
  968.                 'nov'=>11,'novembre'=>11,'déc'=>12,'dec'=>12,'décembre'=>12
  969.             ];
  970.         
  971.             $text = strtolower(trim($datesSession));
  972.             $text = str_replace(['.', ','], '', $text);
  973.         
  974.             if (preg_match('/(\d{1,2})\s*(\w+)?\s*au\s*(\d{1,2})\s*(\w+)?/i', $text, $m)) {
  975.                 $jourDebut = (int)$m[1];
  976.                 $moisDebut = $moisFr[$m[2] ?? ''] ?? null;
  977.                 $jourFin = (int)$m[3];
  978.                 $moisFin = $moisFr[$m[4] ?? ''] ?? $moisDebut;
  979.         
  980.                 if (!$moisDebut || !$moisFin) return null;
  981.         
  982.                 $annee = (int)date('Y');
  983.                 $dateDebut = new \DateTime(sprintf('%04d-%02d-%02d', $annee, $moisDebut, $jourDebut));
  984.                 $dateFin = new \DateTime(sprintf('%04d-%02d-%02d', $annee, $moisFin, $jourFin));
  985.         
  986.                 if ($dateFin < $dateDebut) $dateFin->modify('+1 year');
  987.         
  988.                 return ['debut' => $dateDebut, 'fin' => $dateFin];
  989.             }
  990.         
  991.             return null;
  992.         };
  993.         // 🔹 Filtrer uniquement les formations à venir
  994.         $today = new \DateTime('today');
  995.         
  996.         $formations = array_filter($formations, function($f) use ($extractDates, $today) {
  997.             $dates = $extractDates($f->getDatesSession());
  998.             if (!$dates) return false;
  999.         
  1000.             // garder uniquement les formations dont la date de début est après aujourd'hui
  1001.             return $dates['debut'] > $today;
  1002.         });
  1003.         // 🔹 Trier par date la plus proche
  1004.         usort($formations, function($a, $b) use ($extractDates) {
  1005.             return $extractDates($a->getDatesSession())['debut'] <=> $extractDates($b->getDatesSession())['debut'];
  1006.         });
  1007.         // 📄 Pagination
  1008.         $pagination = $paginator->paginate(
  1009.             $formations,
  1010.             $request->query->getInt('page', 1),
  1011.             12
  1012.         );
  1013.     
  1014.         $mentions = $mentionRepository->findAll();
  1015.     
  1016.         // 🔹 Rendu Twig
  1017.         return $this->render('front/seminaire_nat.html.twig', [
  1018.             'annee' => $annee,
  1019.             'mentions' => $mentions,
  1020.             'recherche' => $rechercheNat->createView(),
  1021.             'pagination' => $pagination,
  1022.             'ville' => $ville,
  1023.             'pays' => $getpays,
  1024.         ]);
  1025.     }
  1026.     
  1027.     #[Route('/formations/{seminaires}/{slug}/{id}code/inscription', name: 'front.inscription', methods:['GET','POST'])]
  1028.     public function inscription_sem(
  1029.         $slug,
  1030.         $seminaires,
  1031.         $id,
  1032.         Request $request,
  1033.         MailerInterface $mailer,
  1034.         InscriptionsRepository $inscriptionRepository,
  1035.         ThemeshanghaiRepository $themeshanghaiRepository,
  1036.         VillesRepository $villeRepository,
  1037.         ThemesRepository $themeRepository,
  1038.         FormationsRepository $formationRepository,
  1039.         MentionsRepository $mentionRepository,
  1040.         ChatbotSessionRepository $chatbotSessionRepository,
  1041.         ChatbotConversationRepository $chatbotConversationRepository,
  1042.         ChatbotTrackingService $chatbotTrackingService,
  1043.         EntityManagerInterface $entityManager
  1044.     ): Response
  1045.     {
  1046.         // ============================================================
  1047.         // SOURCE DE L'INSCRIPTION : chatbot ou site
  1048.         // ============================================================
  1049.         $httpSession = $request->getSession();
  1050.         if ($request->query->get('source') === 'chatbot') {
  1051.             $httpSession->set('cimef_inscription_source', 'chatbot');
  1052.             $httpSession->set(
  1053.                 'cimef_inscription_formation_id',
  1054.                 (int) $id
  1055.             );
  1056.         }
  1057.         // Par défaut : inscription directe depuis le site
  1058.         $source = 'site';
  1059.         // Si l'utilisateur vient du chatbot ET qu'il s'agit
  1060.         // de la même formation
  1061.         if (
  1062.             $httpSession->get('cimef_inscription_source') === 'chatbot'
  1063.             &&
  1064.             (int) $httpSession->get('cimef_inscription_formation_id') === (int) $id
  1065.         ) {
  1066.             $source = 'chatbot';
  1067.         }
  1068.     
  1069.         // ============================================================
  1070.         // TRACKING : INSCRIPTION COMMENCÉE
  1071.         // ============================================================
  1072.         if ($source === 'chatbot') {
  1073.             $chatbotSessionId = $httpSession->get('cimef_chatbot_session_id');
  1074.             $chatbotConversationId = $httpSession->get('cimef_chatbot_conversation_id');
  1075.             $trackingKey = 'cimef_registration_started_' . (int) $id;
  1076.             if (!$httpSession->has($trackingKey) && !empty($chatbotSessionId) && !empty($chatbotConversationId)) {
  1077.                 $chatbotSession = $chatbotSessionRepository->findBySessionId($chatbotSessionId);
  1078.                 $chatbotConversation = $chatbotConversationRepository->find((int) $chatbotConversationId);
  1079.                 if ($chatbotSession && $chatbotConversation && $chatbotConversation->getSession()->getId() === $chatbotSession->getId()) {
  1080.                     $chatbotTrackingService->trackRegistrationStarted($chatbotSession,$chatbotConversation,(int) $id);
  1081.                     $httpSession->set($trackingKey,true);
  1082.                 }
  1083.             }
  1084.         }
  1085.         $annee = date('Y');
  1086.         $queryBuilder = $entityManager->createQueryBuilder();
  1087.         $queryBuilder
  1088.         ->select('for.id', 'for.dates_session', 'for.prix','for.annee', 'for.devise', 'th.nom', 
  1089.             'thm.nom AS thmnom','vil.nom AS vilnom','vil.pays','for.created_at',
  1090.             'th.slug','th.description','for.devise','vil.longitude','vil.latitude'
  1091.         )
  1092.         ->from(Formations::class, 'for')
  1093.         ->innerJoin(Themes::class, 'th', 'WITH', 'for.theme = th.id')
  1094.         ->innerJoin(Villes::class,  'vil', 'WITH', 'for.ville = vil.id')
  1095.         ->innerJoin(Thematiques::class, 'thm', 'WITH', 'th.thematique= thm.id')
  1096.         ->where('th.slug = :theme')
  1097.         ->andwhere('for.id = :forid')
  1098.         ->setParameter('theme', $slug)
  1099.         ->setParameter('forid', $id);
  1100.         $query = $queryBuilder->getQuery()->getResult();
  1101.         $mentions = $mentionRepository->findAll();
  1102.         
  1103.         $queryBuilder1 = $entityManager->createQueryBuilder();
  1104.         $queryBuilder1
  1105.             ->select(
  1106.                 'cert.id','cert.session','cert.prix','cert.slug',
  1107.                 'cert.devise','cert.theme','vil.nom AS vilnom',
  1108.                 'vil.pays','cert.createdat','cert.type'
  1109.             )
  1110.             ->from(Certificats::class, 'cert')
  1111.             ->innerJoin(Villes::class, 'vil', 'WITH', 'cert.ville = vil.id')
  1112.             ->where('cert.slug = :slug')
  1113.             ->andwhere('cert.id = :id')
  1114.             ->setParameter('slug', $slug)
  1115.             ->setParameter('id', $id);
  1116.         $certificat = $queryBuilder1->getQuery()->getOneOrNullResult();
  1117.         
  1118.         $queryBuilder2 = $entityManager->createQueryBuilder();
  1119.         $queryBuilder2
  1120.             ->select(
  1121.                 'shan.id','shan.session','shan.prix','shan.slug',
  1122.                 'shan.devise','shan.theme','shan.ville','shan.createdat','shan.updatedat'
  1123.             )
  1124.             ->from(Themeshanghai::class, 'shan')
  1125.             ->where('shan.slug = :slug')
  1126.             ->andwhere('shan.id = :id')
  1127.             ->setParameter('slug', $slug)
  1128.             ->setParameter('id', $id);
  1129.         $shanghai = $queryBuilder2->getQuery()->getOneOrNullResult();
  1130.         
  1131.         $inscription = new Inscriptions();
  1132.         $inscriptionForm = $this->createForm(InscriptionFormType::class, $inscription);
  1133.         $inscriptionForm->handleRequest($request);
  1134.         
  1135.         
  1136.         if ($inscriptionForm->isSubmitted() && $inscriptionForm->isValid()) {
  1137.             $civilite = $inscriptionForm->get('civilite')->getData();
  1138.             $nom = $inscriptionForm->get('nom')->getData();
  1139.             $prenoms = $inscriptionForm->get('prenoms')->getData();
  1140.             $fonction = $inscriptionForm->get('fonction')->getData();
  1141.             $adresse = $inscriptionForm->get('adresse')->getData();
  1142.             $mail = $inscriptionForm->get('mail')->getData();
  1143.             $entreprise = $inscriptionForm->get('entreprise')->getData();
  1144.             
  1145.             $site = $inscriptionForm->get('siteweb')->getData();
  1146.             $nbparticipant = $inscriptionForm->get('nbparticipant')->getData();
  1147.             $pays = $inscriptionForm->get('pays')->getData();
  1148.             $ville = $inscriptionForm->get('ville')->getData();
  1149.             $boitepostale = $inscriptionForm->get('boitepostale')->getData();
  1150.             $whatsapp = $inscriptionForm->get('whatsapp')->getData();            
  1151.             
  1152.             $telephone = $inscriptionForm->get('telephone')->getData();
  1153.             $commentaire = $inscriptionForm->get('commentaire')->getData(); 
  1154.             $formation = $formationRepository->find($id);
  1155.             $formationShanghai = $themeshanghaiRepository->find($id);
  1156.             
  1157.             $token = $inscriptionForm->get('recaptchaToken')->getData();
  1158.  
  1159.             if($query){
  1160.                 $theme = $formation->getTheme();
  1161.                 $idville = $formation->getVille();
  1162.                 $session = $formation->getDatesSession();
  1163.                 $prix = $formation->getPrix();
  1164.                 $devise = $formation->getDevise();
  1165.                 
  1166.                 $villes = $villeRepository->find($idville);
  1167.                 $nomtheme = $theme->getNom();
  1168.                 $nomville = $villes->getNom();
  1169.             }
  1170.             
  1171.             if(!$site){
  1172.                 $siteweb = 'Pas renseigné';
  1173.             }else{
  1174.                 $siteweb = $inscriptionForm->get('siteweb')->getData();
  1175.             }
  1176.             
  1177.             if($certificat){
  1178.                 $nomtheme = $certificat['theme'];
  1179.                 $nomville = $certificat['vilnom'];
  1180.                 $nompays = $certificat['pays'];
  1181.                 $session = $certificat['session'];
  1182.                 $prix = $certificat['prix'];
  1183.                 $devise = $certificat['devise'];
  1184.             }
  1185.             if($shanghai){
  1186.                 $nomtheme = $shanghai['theme'];
  1187.                 $nomville = $shanghai['ville'];
  1188.                 $nompays = '';
  1189.                 $session = $shanghai['session'];
  1190.                 $prix = $shanghai['prix'];
  1191.                 $devise = $shanghai['devise'];
  1192.             }
  1193.             
  1194.             //dd($certificat);
  1195.             if(!$commentaire){
  1196.                 $commentaire = " ";
  1197.             }else{
  1198.                 $commentaire = $inscriptionForm->get('commentaire')->getData();
  1199.             }
  1200.             $response = $this->client->request(
  1201.                 'POST',
  1202.                 'https://www.google.com/recaptcha/api/siteverify',
  1203.                 [
  1204.                     'body' => [
  1205.                         'secret' => $_ENV['RECAPTCHA_SECRET_KEY'],
  1206.                         'response' => $token,
  1207.                     ]
  1208.                 ]
  1209.             );
  1210.             $result = $response->toArray();
  1211.             //dd($result);
  1212.             /*
  1213.             if (!$result['success'] || !isset($result['score']) || $result['score'] < 0.5) {
  1214.                  return $this->addFlash('warning','Vérification reCAPTCHA échouée.');
  1215.             }*/
  1216.             
  1217.             
  1218.             $inscription->setNom($nom);
  1219.             $inscription->setPrenoms($prenoms);
  1220.             $inscription->setFonction($fonction);
  1221.             $inscription->setAdresse($adresse ?? '');
  1222.             $inscription->setMail($mail);
  1223.             $inscription->setEntreprise($entreprise);
  1224.             $inscription->setSiteweb($siteweb);
  1225.             $inscription->setNbparticipant($nbparticipant);
  1226.             $inscription->setPays($pays);
  1227.             $inscription->setVille( $ville);
  1228.             $inscription->setBoitepostale($boitepostale ?? '');
  1229.             $inscription->setWhatsapp($whatsapp);
  1230.             $inscription->setTelephone($telephone);
  1231.             $inscription->setCommentaire($commentaire);
  1232.             $inscription->setSource($source);
  1233.             $inscription->setFormation($formation);
  1234.             $entityManager->persist($inscription);
  1235.             $entityManager->flush();
  1236.             
  1237.             
  1238.             // ============================================================
  1239.             // TRACKING : INSCRIPTION TERMINÉE
  1240.             // ============================================================
  1241.             if ($source === 'chatbot') {
  1242.                 $chatbotSessionId = $httpSession->get('cimef_chatbot_session_id');
  1243.                 $chatbotConversationId = $httpSession->get('cimef_chatbot_conversation_id');
  1244.                 if (!empty($chatbotSessionId) && !empty($chatbotConversationId)) {
  1245.                     $chatbotSession =$chatbotSessionRepository->findBySessionId($chatbotSessionId);
  1246.                     $chatbotConversation =$chatbotConversationRepository->find((int) $chatbotConversationId);
  1247.                     if ($chatbotSession && $chatbotConversation && $chatbotConversation->getSession()->getId() === $chatbotSession->getId()) {
  1248.                         $chatbotTrackingService->trackRegistrationCompleted($chatbotSession,$chatbotConversation,(int) $id);
  1249.                     }
  1250.                 }
  1251.             }
  1252.             $httpSession->remove('cimef_chatbot_session_id');
  1253.             $httpSession->remove('cimef_chatbot_conversation_id');
  1254.             $httpSession->remove('cimef_inscription_source');
  1255.             $httpSession->remove('cimef_inscription_formation_id');
  1256.             $httpSession->remove('cimef_registration_started_' . (int) $id);
  1257.             $destinataire = 'mesnouveauxinscripts@cimef-international.org';
  1258.             $expediteur   = $mail;
  1259.             $reponse      = $expediteur;
  1260.             $suj = "INSCRIPTION FORMATION 2026";
  1261.             
  1262.             $codehtml = '<html><body>'.
  1263.             '<table width="100%" cellpadding="0" cellspacing="0" style="background-color:#f4f6f8; padding:20px;">
  1264.             <tr>
  1265.             <td align="center">
  1266.             <table width="600" cellpadding="0" cellspacing="0" style="background-color:#ffffff; border-radius:6px; overflow:hidden; box-shadow:0 2px 6px rgba(0,0,0,0.08);">
  1267.             <tr>
  1268.             <td style="background-color:#051a53; padding:20px; color:#ffffff; text-align:center;">
  1269.             <h2 style="margin:0;">Confirmation d\'inscription</h2>
  1270.             </td>
  1271.             </tr>
  1272.             <tr>
  1273.             <td style="padding:25px; color:#333333; font-size:14px; line-height:1.6;">
  1274.             <p>Inscription de '.$civilite.' '.$prenoms.' '.$nom.' à la formation <strong>'.$nomtheme.'</strong> organisée par <strong>CIMEF International</strong>.</p>
  1275.             <p>Veuillez trouver ci-dessous le récapitulatif :</p>
  1276.             <hr style="border:none; border-top:1px solid #e0e0e0; margin:20px 0;">
  1277.             <h4 style="margin-bottom:8px; color:#0d6efd;">Informations personnelles</h4>
  1278.             <p>
  1279.             <strong>Nom & Prénoms :</strong> '.$prenoms.' '.$nom.'<br>
  1280.             <strong>Fonction :</strong> '.$fonction.'<br>
  1281.             <strong>Entreprise :</strong> '.$entreprise.'<br>
  1282.             <strong>Adresse :</strong> '.$adresse.'<br>
  1283.             <strong>Pays / Ville :</strong> '.$pays.' / '.$ville.'<br>
  1284.             <strong>Boîte postale :</strong> '.$boitepostale.'
  1285.             </p>
  1286.             <h4 style="margin-bottom:8px; color:#0d6efd;">Coordonnées</h4>
  1287.             <p>
  1288.             <strong>Email :</strong> '.$mail.'<br>
  1289.             <strong>Téléphone :</strong> '.$telephone.'<br>
  1290.             <strong>WhatsApp :</strong> '.$whatsapp.'<br>
  1291.             <strong>Site web :</strong> '.$siteweb.'
  1292.             </p>
  1293.             <h4 style="margin-bottom:8px; color:#0d6efd;">Détails de participation</h4>
  1294.             <p>
  1295.             <strong>Nombre de participants :</strong> '.$nbparticipant.'<br>
  1296.             <strong>Commentaire :</strong> '.$commentaire.'
  1297.             </p>
  1298.             <h4 style="margin-bottom:8px; color:#0d6efd;">Détail de la formation</h4>
  1299.             <p>
  1300.             <strong>Thème :</strong> '.$nomtheme.'<br>
  1301.             <strong>Ville :</strong> '.$nomville.'<br>
  1302.             <strong>Prix :</strong> '.$prix.''.$devise.'<br>
  1303.             <strong>Session :</strong> '.$session.'
  1304.             </p>
  1305.             </td>
  1306.             </tr>
  1307.             <tr>
  1308.             <td style="background-color:#f1f1f1; padding:15px; text-align:center; font-size:12px; color:#777777;">
  1309.             © '.date("Y").' CIMEF International — Tous droits réservés
  1310.             </td>
  1311.             </tr>
  1312.             </table>
  1313.             </td>
  1314.             </tr>
  1315.             </table>
  1316.             </body></html>';
  1317.             
  1318.             /*
  1319.             $secretKey = '6LfPYkosAAAAAJQFLCC-9U5bF6KdFTPrgmbxg5Ux';
  1320.             $value = $request->get('g-recaptcha-response');
  1321.             if (!$value) { 
  1322.                 $this->addFlash('warning', 'Veuillez cocher le reCAPTCHA'); 
  1323.                 return $this->redirectToRoute('front.seminaire.nationaux',['seminaires' => $seminaires,'slug' => $slug]);
  1324.             }
  1325.             $userIP = $_SERVER['REMOTE_ADDR'];
  1326.             $url = "https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$value&remoteip=$userIP";
  1327.             $response = \file_get_contents($url);
  1328.             $response = json_decode((string)$response);
  1329.             if(!$response->success){
  1330.                 $this->addFlash('warning','Cocher le champs recaptcha svp!');
  1331.                 return $this->redirectToRoute('front.seminaire.nationaux',['seminaires' => $seminaires,'slug' => $slug]);
  1332.             }
  1333.             */
  1334.  
  1335.             $email = (new Email())
  1336.             ->from('CIMEF International <mesnouveauxinscripts@cimef-international.org>')
  1337.             ->to($destinataire)                 // destinataire principal
  1338.             ->cc('medias@cimef-international.com') // COPIE
  1339.             ->replyTo($expediteur)              // Reply-To:
  1340.             ->subject($suj)     
  1341.             ->text(strip_tags($codehtml))
  1342.             ->html($codehtml);// Subject:
  1343.             //->html($codehtml, 'text/html');   // Content-Type + charset utf-8
  1344.             $mailer->send($email);
  1345.             $this->addFlash(
  1346.             'success',
  1347.             'Votre inscription à été bien enregistrée');
  1348.             return $this->redirectToRoute('front.seminaire.nationaux',['seminaires' => $seminaires,'slug' => $slug]);
  1349.         }
  1350.         
  1351.         
  1352.         
  1353.         
  1354.         //dd($seminaires);
  1355.         if($query){
  1356.             return $this->render('front/inscriptions/inscription-seminaire.html.twig',[
  1357.                 'slug' => $slug,
  1358.                 'query' => $query,
  1359.                 'annee' => $annee,
  1360.                 'type' => $seminaires,
  1361.                 'mentions' => $mentions,
  1362.                 'inscriptionForm' => $inscriptionForm->createView(),
  1363.             ]);
  1364.         }elseif($shanghai){
  1365.                 $nomtheme = $shanghai['theme'];
  1366.                 $nomville = $shanghai['ville'];
  1367.                 $nompays = '';
  1368.                 $session = $shanghai['session'];
  1369.                 $prix = $shanghai['prix'];
  1370.                 $devise = $shanghai['devise'];
  1371.             
  1372.             return $this->render('front/inscriptions/inscription-certificat.html.twig',[
  1373.                 'slug' => $slug,
  1374.                 'prix' => $prix,
  1375.                 'annee' => $annee,
  1376.                 'pays' => $nompays,
  1377.                 'devise' => $devise,
  1378.                 'ville' => $nomville,
  1379.                 'theme' => $nomtheme,
  1380.                 'type' => $seminaires,
  1381.                 'session' => $session,
  1382.                 'mentions' => $mentions,
  1383.                 'certificat' => $shanghai,
  1384.                 'inscriptionForm' => $inscriptionForm->createView(),
  1385.             ]);
  1386.     
  1387.         }else{
  1388.             $nomtheme = $certificat['theme'];
  1389.             $nomville = $certificat['vilnom'];
  1390.             $nompays = $certificat['pays'];
  1391.             $session = $certificat['session'];
  1392.             $prix = $certificat['prix'];
  1393.             $devise = $certificat['devise'];
  1394.             
  1395.             return $this->render('front/inscriptions/inscription-certificat.html.twig',[
  1396.                 'slug' => $slug,
  1397.                 'prix' => $prix,
  1398.                 'annee' => $annee,
  1399.                 'pays' => $nompays,
  1400.                 'devise' => $devise,
  1401.                 'ville' => $nomville,
  1402.                 'theme' => $nomtheme,
  1403.                 'type' => $seminaires,
  1404.                 'session' => $session,
  1405.                 'mentions' => $mentions,
  1406.                 'certificat' => $certificat,
  1407.                 'inscriptionForm' => $inscriptionForm->createView(),
  1408.             ]);
  1409.         }
  1410.     }
  1411.         
  1412.     #[Route('/formations/rencontre-des-top-management/{slug}/{id}code/inscription-manager', name: 'front.inscription.management', methods:['GET','POST'])]
  1413.     public function inscription_man(
  1414.         $slug,
  1415.         $id,
  1416.         Request $request,
  1417.         MailerInterface $mailer,
  1418.         InscriptionsRepository $inscriptionRepository,
  1419.         ManagementsRepository $managementRepository,
  1420.         MentionsRepository $mentionRepository,
  1421.         EntityManagerInterface $entityManager
  1422.     ): Response
  1423.     {
  1424.         $annee = date('Y');
  1425.         $queryBuilder_1 = $entityManager->createQueryBuilder();
  1426.         $queryBuilder_1
  1427.         ->select('man')
  1428.         ->from(Managements::class, 'man')
  1429.         ->where('man.slug = :theme')
  1430.         ->andwhere('man.id = :forid')
  1431.         ->setParameter('theme', $slug)
  1432.         ->setParameter('forid', $id);
  1433.         $query_1 = $queryBuilder_1->getQuery()->getResult();
  1434.         $mentions = $mentionRepository->findAll();
  1435.         $inscription = new Inscriptions();
  1436.         $inscriptionForm = $this->createForm(InscriptionFormType::class, $inscription);
  1437.         $inscriptionForm->handleRequest($request);
  1438.         
  1439.         if ($inscriptionForm->isSubmitted()) {
  1440.             $nom = $inscriptionForm->get('nom')->getData();
  1441.             $prenoms = $inscriptionForm->get('prenoms')->getData();
  1442.             $fonction = $inscriptionForm->get('fonction')->getData();
  1443.             $adresse = $inscriptionForm->get('adresse')->getData();
  1444.             $mail = $inscriptionForm->get('mail')->getData();
  1445.             $entreprise = $inscriptionForm->get('entreprise')->getData();
  1446.             
  1447.             $siteweb = $inscriptionForm->get('siteweb')->getData();
  1448.             $nbparticipant = $inscriptionForm->get('nbparticipant')->getData();
  1449.             $pays = $inscriptionForm->get('pays')->getData();
  1450.             $ville = $inscriptionForm->get('ville')->getData();
  1451.             $boitepostale = $inscriptionForm->get('boitepostale')->getData();
  1452.             $whatsapp = $inscriptionForm->get('whatsapp')->getData();            
  1453.             
  1454.             $telephone = $inscriptionForm->get('telephone')->getData();
  1455.             $commentaire = $inscriptionForm->get('commentaire')->getData(); 
  1456.             $management = $managementRepository->find($id);
  1457.             //dd($formation->getId());
  1458.             $token = $inscriptionForm->get('recaptchaToken')->getData();
  1459.             
  1460.             $theme = $management->getTheme();
  1461.             $ville = $management->getVille();
  1462.             $datedebut = $management->getDateDebut();
  1463.             $datefin = $management->getDateFin();
  1464.             $prix = $management->getPrix();
  1465.             $devise = $management->getDevise();
  1466.             
  1467.             if(!$commentaire){
  1468.                 $commentaire = "...";
  1469.             }else{
  1470.                 $commentaire = $inscriptionForm->get('commentaire')->getData();
  1471.             }
  1472.             
  1473.             $inscription->setNom($nom);
  1474.             $inscription->setPrenoms($prenoms);
  1475.             $inscription->setFonction($fonction);
  1476.             $inscription->setAdresse($adresse);
  1477.             $inscription->setMail($mail);
  1478.             $inscription->setEntreprise($entreprise);
  1479.             $inscription->setSiteweb($siteweb);
  1480.             $inscription->setNbparticipant($nbparticipant);
  1481.             $inscription->setPays($pays);
  1482.             $inscription->setVille( $ville);
  1483.             $inscription->setBoitepostale($boitepostale);
  1484.             $inscription->setWhatsapp($whatsapp);
  1485.             $inscription->setTelephone($telephone);
  1486.             $inscription->setCommentaire($commentaire);
  1487.             $inscription->setFormation($management);
  1488.             $inscription->setSource('site_web');
  1489.             $entityManager->persist($inscription);
  1490.             $entityManager->flush();
  1491.             
  1492.             //$codehtml = "test";
  1493.             
  1494.             $codehtml = '<html><body>'.
  1495.             '<table width="100%" cellpadding="0" cellspacing="0" style="background-color:#f4f6f8; padding:20px;">
  1496.             <tr>
  1497.             <td align="center">
  1498.             <table width="600" cellpadding="0" cellspacing="0" style="background-color:#ffffff; border-radius:6px; overflow:hidden; box-shadow:0 2px 6px rgba(0,0,0,0.08);">
  1499.             <tr>
  1500.             <td style="background-color:#051a53; padding:20px; color:#ffffff; text-align:center;">
  1501.             <h2 style="margin:0;">Confirmation d\'inscription</h2>
  1502.             </td>
  1503.             </tr>
  1504.             <tr>
  1505.             <td style="padding:25px; color:#333333; font-size:14px; line-height:1.6;">
  1506.             <p>Inscription de M/Mme <strong>'.$prenoms.' '.$nom.'</strong> à la formation <strong>'.$nomtheme.'</strong> organisée par <strong>CIMEF International</strong>.</p>
  1507.             <p>Veuillez trouver ci-dessous le récapitulatif :</p>
  1508.             <hr style="border:none; border-top:1px solid #e0e0e0; margin:20px 0;">
  1509.             <h4 style="margin-bottom:8px; color:#0d6efd;">Informations personnelles</h4>
  1510.             <p>
  1511.             <strong>Nom & Prénoms :</strong> '.$prenoms.' '.$nom.'<br>
  1512.             <strong>Fonction :</strong> '.$fonction.'<br>
  1513.             <strong>Entreprise :</strong> '.$entreprise.'<br>
  1514.             <strong>Adresse :</strong> '.$adresse.'<br>
  1515.             <strong>Pays / Ville :</strong> '.$pays.' / '.$ville.'<br>
  1516.             <strong>Boîte postale :</strong> '.$boitepostale.'
  1517.             </p>
  1518.             <h4 style="margin-bottom:8px; color:#0d6efd;">Coordonnées</h4>
  1519.             <p>
  1520.             <strong>Email :</strong> '.$mail.'<br>
  1521.             <strong>Téléphone :</strong> '.$telephone.'<br>
  1522.             <strong>WhatsApp :</strong> '.$whatsapp.'<br>
  1523.             <strong>Site web :</strong> '.$siteweb.'
  1524.             </p>
  1525.             <h4 style="margin-bottom:8px; color:#0d6efd;">Détails de participation</h4>
  1526.             <p>
  1527.             <strong>Nombre de participants :</strong> '.$nbparticipant.'<br>
  1528.             <strong>Commentaire :</strong> '.$commentaire.'
  1529.             </p>
  1530.             <h4 style="margin-bottom:8px; color:#0d6efd;">Détail de la formation</h4>
  1531.             <p>
  1532.             <strong>Thème :</strong> '.$theme.'<br>
  1533.             <strong>Ville :</strong> '.$ville.'<br>
  1534.             <strong>Prix :</strong> '.$prix.''.$devise.'<br>
  1535.             <strong>Date de la rencontre :</strong> Du'.$datedebut.' au '.$datefin.'<br>
  1536.             </p>
  1537.             </td>
  1538.             </tr>
  1539.             <tr>
  1540.             <td style="background-color:#f1f1f1; padding:15px; text-align:center; font-size:12px; color:#777777;">
  1541.             © '.date("Y").' CIMEF International — Tous droits réservés
  1542.             </td>
  1543.             </tr>
  1544.             </table>
  1545.             </td>
  1546.             </tr>
  1547.             </table>
  1548.             </body></html>';
  1549.             /*
  1550.             $secretKey = '6LfPYkosAAAAAJQFLCC-9U5bF6KdFTPrgmbxg5Ux';
  1551.             $value = $request->get('g-recaptcha-response');
  1552.             if (!$value) { 
  1553.                 return $this->addFlash('warning', 'Veuillez cocher le reCAPTCHA'); 
  1554.             }
  1555.             $userIP = $_SERVER['REMOTE_ADDR'];
  1556.             $url = "https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$value&remoteip=$userIP";
  1557.             $response = \file_get_contents($url);
  1558.             $response = json_decode((string)$response);
  1559.             //dd($response);
  1560.             if(!$response->success){
  1561.                 return $this->addFlash('warning','Cocher le champs recaptcha svp!');
  1562.             }
  1563.             */
  1564.             $response = $this->client->request(
  1565.                 'POST',
  1566.                 'https://www.google.com/recaptcha/api/siteverify',
  1567.                 [
  1568.                     'body' => [
  1569.                         'secret' => $_ENV['RECAPTCHA_SECRET_KEY'],
  1570.                         'response' => $token,
  1571.                     ]
  1572.                 ]
  1573.             );
  1574.             $result = $response->toArray();
  1575.             if (!$result['success'] || !isset($result['score']) || $result['score'] < 0.5) {
  1576.                 return $this->addFlash('warning','Vérification reCAPTCHA échouée.');
  1577.             } 
  1578.             $destinataire = 'mailinscriptions@cimef-international.org';
  1579.             $expediteur   = $mail;
  1580.             $reponse      = $expediteur;
  1581.             $suj = "INSCRIPTION FORMATION 2026";
  1582.         
  1583.             $email = (new Email())
  1584.             ->from('CIMEF International <mailinscriptions@cimef-international.org>')
  1585.             ->to($destinataire)                 // destinataire principal
  1586.             ->cc('medias@cimef-international.com') // COPIE
  1587.             ->replyTo($expediteur)              // Reply-To:
  1588.             ->subject($suj)     
  1589.             ->text(strip_tags($codehtml))
  1590.             ->html($codehtml);// Subject:
  1591.             //->html($codehtml, 'text/html');   // Content-Type + charset utf-8
  1592.             $mailer->send($email);
  1593.         
  1594.             $this->addFlash(
  1595.             'success',
  1596.             'Votre inscription à été bien enregistrée');
  1597.             return $this->redirectToRoute('front.top.management');
  1598.         }
  1599.           
  1600.         return $this->render('front/inscriptions/inscription-top-management.html.twig',[
  1601.             'query_1' => $query_1,
  1602.             'annee' => $annee,
  1603.             'mentions' => $mentions,
  1604.             'inscriptionForm' => $inscriptionForm->createView(),
  1605.         ]);    
  1606.     }
  1607.  
  1608.     #[Route('/formations/seminaire-a-la-carte', name: 'front.seminaire-a-la-carte', methods:['GET','POST'])]
  1609.     public function inscription_seminaire_sur_mesure(
  1610.         Request $request,
  1611.         MailerInterface $mailer,
  1612.         InscriptionsRepository $inscriptionRepository,
  1613.         MentionsRepository $mentionRepository,
  1614.         EntityManagerInterface $entityManager
  1615.     ): Response
  1616.     {
  1617.         //dd($seminaires);
  1618.         $annee = date('Y');
  1619.         $mentions = $mentionRepository->findAll();
  1620.         $demandeformation = new Demandeformations();
  1621.         $demandeformationsForm = $this->createForm(DemandeformationFormType::class, $demandeformation);
  1622.         $demandeformationsForm->handleRequest($request);
  1623.         if ($demandeformationsForm->isSubmitted()) {
  1624.             $civilite = $demandeformationsForm->get('civilite')->getData();
  1625.             $nom = $demandeformationsForm->get('nom')->getData();
  1626.             $prenoms = $demandeformationsForm->get('prenoms')->getData();
  1627.             $fonction = $demandeformationsForm->get('fonction')->getData();
  1628.             $adresse = $demandeformationsForm->get('adresse')->getData();
  1629.             $mail = $demandeformationsForm->get('mail')->getData();
  1630.             $entreprise = $demandeformationsForm->get('entreprise')->getData();
  1631.             
  1632.             $siteweb = $demandeformationsForm->get('siteweb')->getData();
  1633.             $nombrepart = $demandeformationsForm->get('nombrepart')->getData();
  1634.             $lieu = $demandeformationsForm->get('lieu')->getData();
  1635.             $theme = $demandeformationsForm->get('theme')->getData();
  1636.             $duree = $demandeformationsForm->get('duree')->getData();
  1637.             
  1638.             $telephone = $demandeformationsForm->get('telephone')->getData();
  1639.             $commentaire = $demandeformationsForm->get('commentaire')->getData(); 
  1640.             //dd($formation->getId());
  1641.             $token = $demandeformationsForm->get('recaptchaToken')->getData();
  1642.             
  1643.             if(!$commentaire){
  1644.                 $commentaire = "...";
  1645.             }else{
  1646.                 $commentaire = $demandeformationsForm->get('commentaire')->getData();
  1647.             }
  1648.             $demandeformation->setNom($nom);
  1649.             $demandeformation->setPrenoms($prenoms);
  1650.             $demandeformation->setFonction($fonction);
  1651.             $demandeformation->setAdresse($adresse);
  1652.             $demandeformation->setMail($mail);
  1653.             $demandeformation->setEntreprise($entreprise);
  1654.             $demandeformation->setSiteweb($siteweb);
  1655.             $demandeformation->setNombrepart($nombrepart);
  1656.             $demandeformation->setLieu($lieu);
  1657.             $demandeformation->setTheme($theme);
  1658.             $demandeformation->setDuree($duree);
  1659.             $demandeformation->setTelephone($telephone);
  1660.             $demandeformation->setCommentaire($commentaire);
  1661.             $entityManager->persist($demandeformation);
  1662.             $entityManager->flush();
  1663.             $destinataire = 'mailinscriptions@cimef-international.org';
  1664.             $expediteur   = $mail;
  1665.             $reponse      = $expediteur;
  1666.             $suj = "INSCRIPTION FORMATION 2026";
  1667.             //$codehtml = "test";
  1668.             
  1669.             $codehtml = '<html><body>'.
  1670.             '<table width="100%" cellpadding="0" cellspacing="0" style="background-color:#f4f6f8; padding:20px;">
  1671.             <tr>
  1672.             <td align="center">
  1673.             <table width="600" cellpadding="0" cellspacing="0" style="background-color:#ffffff; border-radius:6px; overflow:hidden; box-shadow:0 2px 6px rgba(0,0,0,0.08);">
  1674.             <tr>
  1675.             <td style="background-color:#051a53; padding:20px; color:#ffffff; text-align:center;">
  1676.             <h2 style="margin:0;">Demande de dévis</h2>
  1677.             </td>
  1678.             </tr>
  1679.             <tr>
  1680.             <td style="padding:25px; color:#333333; font-size:14px; line-height:1.6;">
  1681.             <p>Demande de dévis de '.$civilite.' <strong>'.$prenoms.' '.$nom.'</strong> pour une formation avec pour thème :<strong>'.$theme.'</strong>.</p>
  1682.             <p>Veuillez trouver ci-dessous le récapitulatif :</p>
  1683.             <hr style="border:none; border-top:1px solid #e0e0e0; margin:20px 0;">
  1684.             <h4 style="margin-bottom:8px; color:#0d6efd;">Informations personnelles</h4>
  1685.             <p>
  1686.             <strong>Nom & Prénoms :</strong> '.$prenoms.' '.$nom.'<br>
  1687.             <strong>Fonction :</strong> '.$fonction.'<br>
  1688.             <strong>Entreprise :</strong> '.$entreprise.'<br>
  1689.             <strong>Adresse :</strong> '.$adresse.'<br>
  1690.             </p>
  1691.             <h4 style="margin-bottom:8px; color:#0d6efd;">Coordonnées</h4>
  1692.             <p>
  1693.             <strong>Email :</strong> '.$mail.'<br>
  1694.             <strong>Téléphone :</strong> '.$telephone.'<br>
  1695.             <strong>Site web :</strong> '.$siteweb.'
  1696.             </p>
  1697.             <h4 style="margin-bottom:8px; color:#0d6efd;">Détails de participation</h4>
  1698.             <p>
  1699.             <strong>Nombre de participants :</strong> '.$nombrepart.'<br>
  1700.             <strong>Commentaire :</strong> '.$commentaire.'
  1701.             </p>
  1702.             <h4 style="margin-bottom:8px; color:#0d6efd;">Détail de la formation</h4>
  1703.             <p>
  1704.             <strong>Thème :</strong> '.$theme.'<br>
  1705.             <strong>Lieu :</strong> '.$lieu.'<br>
  1706.             <strong>Date :</strong> '.$duree.'
  1707.             </p>
  1708.             </td>
  1709.             </tr>
  1710.             <tr>
  1711.             <td style="background-color:#f1f1f1; padding:15px; text-align:center; font-size:12px; color:#777777;">
  1712.             © '.date("Y").' CIMEF International — Tous droits réservés
  1713.             </td>
  1714.             </tr>
  1715.             </table>
  1716.             </td>
  1717.             </tr>
  1718.             </table>
  1719.             </body></html>';
  1720.             /*
  1721.             $secretKey = '6LfPYkosAAAAAJQFLCC-9U5bF6KdFTPrgmbxg5Ux';
  1722.             $value = $request->get('g-recaptcha-response');
  1723.             
  1724.             if (!$value) { $this->addFlash('warning', 'Veuillez cocher le reCAPTCHA'); 
  1725.                 $this->addFlash('warning','Cocher le champs recaptcha svp!');
  1726.                 return $this->render('front/inscriptions/formation-a-la-carte.html.twig',[
  1727.                     'annee' => $annee,
  1728.                     'mentions' => $mentions,
  1729.                     'demandeformationsForm' => $demandeformationsForm->createView(),
  1730.                 ]);
  1731.             }
  1732.             $userIP = $_SERVER['REMOTE_ADDR'];
  1733.             $url = "https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$value&remoteip=$userIP";
  1734.             $response = \file_get_contents($url);
  1735.             $response = json_decode((string)$response);
  1736.             //dd($response);
  1737.             if(!$response->success){
  1738.                 $this->addFlash('warning','Cocher le champs recaptcha svp!');
  1739.                 return $this->render('front/inscriptions/formation-a-la-carte.html.twig',[
  1740.                     'annee' => $annee,
  1741.                     'mentions' => $mentions,
  1742.                     'demandeformationsForm' => $demandeformationsForm->createView(),
  1743.                 ]);
  1744.             } 
  1745.             */
  1746.             $response = $this->client->request(
  1747.                 'POST',
  1748.                 'https://www.google.com/recaptcha/api/siteverify',
  1749.                 [
  1750.                     'body' => [
  1751.                         'secret' => $_ENV['RECAPTCHA_SECRET_KEY'],
  1752.                         'response' => $token,
  1753.                     ]
  1754.                 ]
  1755.             );
  1756.             $result = $response->toArray();
  1757.             if (!$result['success'] || !isset($result['score']) || $result['score'] < 0.5) {
  1758.                 $this->addFlash(
  1759.                     'warning',
  1760.                     'Vérification reCAPTCHA échouée.'
  1761.                 );
  1762.                 return $this->render('front/inscriptions/formation-a-la-carte.html.twig',[
  1763.                     'annee' => $annee,
  1764.                     'mentions' => $mentions,
  1765.                     'demandeformationsForm' => $demandeformationsForm->createView(),
  1766.                 ]);
  1767.             }  
  1768.             
  1769.             $email = (new Email())
  1770.             ->from('CIMEF International <mailinscriptions@cimef-international.org>')
  1771.             ->to($destinataire)                 // destinataire principal
  1772.             ->cc('medias@cimef-international.com') // COPIE
  1773.             ->replyTo($expediteur)              // Reply-To:
  1774.             ->subject($suj)     
  1775.             ->text(strip_tags($codehtml))
  1776.             ->html($codehtml);// Subject:
  1777.             //->html($codehtml, 'text/html');   // Content-Type + charset utf-8
  1778.             $mailer->send($email);
  1779.             $this->addFlash(
  1780.             'success',
  1781.             'Votre inscription à été bien enregistrée');
  1782.             return $this->redirectToRoute('front.inter.index');
  1783.         }
  1784.         
  1785.         return $this->render('front/inscriptions/formation-a-la-carte.html.twig',[
  1786.             'annee' => $annee,
  1787.             'mentions' => $mentions,
  1788.             'demandeformationsForm' => $demandeformationsForm->createView(),
  1789.         ]);
  1790.     }
  1791.     
  1792.     #[Route('/formations/seminaires-internationaux/{slug}/{id}code',name: 'front.seminaire.inter.detail',methods: ['GET'])]
  1793.     public function detail_sem_int(
  1794.         $slug,
  1795.         $id,
  1796.         Request $request,
  1797.         MentionsRepository $mentionRepository,
  1798.         EntityManagerInterface $entityManager,
  1799.         ChatbotSessionRepository $chatbotSessionRepository,
  1800.         ChatbotConversationRepository $chatbotConversationRepository,
  1801.         ChatbotTrackingService $chatbotTrackingService
  1802.     ): Response
  1803.     {
  1804.         // ============================================================
  1805.         // SESSION HTTP
  1806.         // ============================================================
  1807.         $httpSession = $request->getSession();
  1808.         // ============================================================
  1809.         // SOURCE : CHATBOT OU SITE
  1810.         // ============================================================
  1811.         $source = 'site';
  1812.         if ($request->query->get('source') === 'chatbot') {
  1813.             $source = 'chatbot';
  1814.             $httpSession->set('cimef_inscription_source','chatbot');
  1815.             $httpSession->set('cimef_inscription_formation_id',(int) $id);
  1816.             $httpSession->set('cimef_chatbot_session_id',$request->query->get('chatbot_session'));
  1817.             $httpSession->set('cimef_chatbot_conversation_id',(int) $request->query->get('chatbot_conversation'));
  1818.         }
  1819.         // ============================================================
  1820.         // INFORMATIONS FORMATION
  1821.         // ============================================================
  1822.         $type = "Séminaires internationaux";
  1823.         $annee = date('Y');
  1824.         $queryBuilder = $entityManager->createQueryBuilder();
  1825.         $queryBuilder
  1826.             ->select(
  1827.                 'for.id','for.dates_session','for.prix','for.devise','for.annee','th.nom','thm.nom AS thmnom','vil.nom AS vilnom',
  1828.                 'vil.pays','for.created_at','th.slug','th.description','vil.longitude','vil.latitude'
  1829.             )
  1830.             ->from(Formations::class, 'for')
  1831.             ->innerJoin(Themes::class,'th','WITH','for.theme = th.id')
  1832.             ->innerJoin(Villes::class,'vil','WITH','for.ville = vil.id')
  1833.             ->innerJoin(Thematiques::class,'thm','WITH','th.thematique = thm.id')
  1834.             ->where('th.slug = :theme')
  1835.             ->andWhere('for.id = :forid')
  1836.             ->setParameter('theme', $slug)
  1837.             ->setParameter('forid', $id);
  1838.         $query = $queryBuilder->getQuery()->getResult();
  1839.         // ============================================================
  1840.         // TRACKING : FORMATION CONSULTÉE
  1841.         // ============================================================
  1842.         if ($source === 'chatbot'  && !empty($query)) {
  1843.             $chatbotSessionId = $httpSession->get('cimef_chatbot_session_id');
  1844.             $chatbotConversationId = $httpSession->get('cimef_chatbot_conversation_id');
  1845.             if (!empty($chatbotSessionId) && !empty($chatbotConversationId)) {
  1846.                 $chatbotSession = $chatbotSessionRepository->findBySessionId($chatbotSessionId);
  1847.                 $chatbotConversation = $chatbotConversationRepository->find((int) $chatbotConversationId);
  1848.                 // ====================================================
  1849.                 // SÉCURITÉ :
  1850.                 // la conversation doit appartenir à la session
  1851.                 // ====================================================
  1852.                 if ($chatbotSession && $chatbotConversation && $chatbotConversation->getSession()->getId()=== $chatbotSession->getId()) {
  1853.                     $chatbotTrackingService->trackFormationViewed(
  1854.                         $chatbotSession,
  1855.                         $chatbotConversation,
  1856.                         (int) $id
  1857.                     );
  1858.                 }
  1859.             }
  1860.         }
  1861.         // ============================================================
  1862.         // TRACKING : INSCRIPTION COMMENCÉE
  1863.         // ============================================================
  1864.         //
  1865.         // ATTENTION :
  1866.         // Cette étape doit normalement être déclenchée sur la page
  1867.         // d'inscription, pas sur la page de détail.
  1868.         //
  1869.         // On ne la déclenche donc PAS ici.
  1870.         //
  1871.         // ============================================================
  1872.         // ============================================================
  1873.         // FORMATIONS SIMILAIRES
  1874.         // ============================================================
  1875.         $queryBuilder = $entityManager->createQueryBuilder();
  1876.         $queryBuilder
  1877.             ->select(
  1878.                 'for.id','for.dates_session','for.prix','for.devise','th.nom','thm.nom AS thmnom',
  1879.                 'vil.nom AS vilnom','vil.pays','for.created_at','th.slug','th.description',
  1880.                 'vil.longitude','vil.latitude','for.image'
  1881.             )
  1882.             ->from(Formations::class, 'for')
  1883.             ->innerJoin(Themes::class,'th','WITH','for.theme = th.id')
  1884.             ->innerJoin(Villes::class,'vil','WITH','for.ville = vil.id')
  1885.             ->innerJoin(Thematiques::class,'thm','WITH','th.thematique = thm.id')
  1886.             ->where('th.slug = :theme')
  1887.             ->andWhere('for.id != :forid')
  1888.             ->setParameter('theme', $slug)
  1889.             ->setParameter('forid', $id);
  1890.         $formations = $queryBuilder
  1891.             ->getQuery()
  1892.             ->getResult();
  1893.         // ============================================================
  1894.         // MENTIONS
  1895.         // ============================================================
  1896.         $mentions = $mentionRepository->findAll();
  1897.         // ============================================================
  1898.         // LOCATIONS
  1899.         // ============================================================
  1900.         $locations = [];
  1901.         foreach ($query as $row) {
  1902.             if (!empty($row['latitude']) && !empty($row['longitude'])) {
  1903.                 $locations[] = [
  1904.                     'lat' => (float) $row['latitude'],
  1905.                     'lng' => (float) $row['longitude'],
  1906.                     'ville' => strtoupper($row['vilnom']),
  1907.                     'pays' => strtoupper($row['pays']),
  1908.                 ];
  1909.             }
  1910.         }
  1911.         // ============================================================
  1912.         // AFFICHAGE
  1913.         // ============================================================
  1914.         return $this->render(
  1915.             'front/detail/detail-seminaire-inter.html.twig',
  1916.             [
  1917.                 'formations' => $formations,
  1918.                 'locations' => $locations,
  1919.                 'mentions' => $mentions,
  1920.                 'annee' => $annee,
  1921.                 'type' => $type,
  1922.                 'query' => $query,
  1923.                 'slug' => $slug,
  1924.             ]
  1925.         );
  1926.     }
  1927.     
  1928.     #[Route('/formations/seminaires-nationaux/{slug}/{id}code', name: 'front.seminaire.nation.detail', methods:['GET'])]
  1929.     public function detail_sem_nat(
  1930.         $slug,
  1931.         $id,
  1932.         Request $request, 
  1933.         GeoIpService $geo,
  1934.         MentionsRepository $mentionRepository,
  1935.         EntityManagerInterface $entityManager
  1936.     ): Response
  1937.     {
  1938.         $type = "Séminaires nationaux";
  1939.         $annee = date('Y');
  1940.                 // 🌍 Géo IP
  1941.         $geoData = $geo->getGeoData($request->getClientIp());
  1942.         $pays = $geoData['country'] ?? '';
  1943.         $ville = $geoData['city'] ?? '';
  1944.         
  1945.         // Correction du nom du pays
  1946.         if ($pays === 'Local' || $pays === 'Ivory Coast') {
  1947.             $getpays = "Côte d'ivoire";
  1948.         } else {
  1949.             $getpays = $pays;
  1950.         }
  1951.         //dd($getpays);
  1952.         $queryBuilder = $entityManager->createQueryBuilder();
  1953.         $queryBuilder
  1954.         ->select('for.id', 'for.dates_session', 'for.prix', 'for.devise', 'th.nom', 
  1955.             'thm.nom AS thmnom','vil.nom AS vilnom','vil.pays','for.created_at',
  1956.             'th.slug','th.description','for.devise','vil.longitude','vil.latitude'
  1957.         )
  1958.         ->from(Formations::class, 'for')
  1959.         ->innerJoin(Themes::class, 'th', 'WITH', 'for.theme = th.id')
  1960.         ->innerJoin(Villes::class,  'vil', 'WITH', 'for.ville = vil.id')
  1961.         ->innerJoin(Thematiques::class, 'thm', 'WITH', 'th.thematique = thm.id')
  1962.         ->where('th.slug = :theme')
  1963.         ->andwhere('for.id = :forid')
  1964.         ->setParameter('theme', $slug)
  1965.         ->setParameter('forid', $id);
  1966.         $query = $queryBuilder->getQuery()->getResult();
  1967.         $mentions = $mentionRepository->findAll();
  1968.         
  1969.         $locations = [];
  1970.         foreach ($query as $row) {
  1971.             if (!empty($row['latitude']) && !empty($row['longitude'])) {
  1972.                 $locations[] = [
  1973.                     'lat'   => (float) $row['latitude'],
  1974.                     'lng'   => (float) $row['longitude'],
  1975.                     'ville' => strtoupper($row['vilnom']),
  1976.                     'pays'  => strtoupper($row['pays']),
  1977.                 ];
  1978.             }
  1979.         }
  1980.         $today = new \DateTime('today');
  1981.     // Fonction pour extraire date de début et fin depuis dates_session
  1982.     $extractDates = function(?string $datesSession): ?array {
  1983.         if (!$datesSession) return null;
  1984.     $moisFr = [
  1985.         'janv'=>1,'janvier'=>1,'févr'=>2,'fevr'=>2,'février'=>2,
  1986.         'mars'=>3,'avr'=>4,'avril'=>4,'mai'=>5,'juin'=>6,
  1987.         'juil'=>7,'juillet'=>7,'août'=>8,'aout'=>8,
  1988.         'sept'=>9,'septembre'=>9,'oct'=>10,'octobre'=>10,
  1989.         'nov'=>11,'novembre'=>11,'déc'=>12,'dec'=>12,'décembre'=>12
  1990.     ];
  1991.     $text = strtolower(trim($datesSession));
  1992.     $text = str_replace(['.', ','], '', $text);
  1993.     if (preg_match('/(\d{1,2})\s*(\w+)?\s*au\s*(\d{1,2})\s*(\w+)?/i', $text, $m)) {
  1994.         $jourDebut = (int)$m[1];
  1995.         $moisDebut = $moisFr[$m[2] ?? ''] ?? null;
  1996.         $jourFin = (int)$m[3];
  1997.         $moisFin = $moisFr[$m[4] ?? ''] ?? $moisDebut;
  1998.             if (!$moisDebut || !$moisFin) return null;
  1999.     
  2000.             $annee = (int)date('Y');
  2001.             $dateDebut = new \DateTime(sprintf('%04d-%02d-%02d', $annee, $moisDebut, $jourDebut));
  2002.             $dateFin = new \DateTime(sprintf('%04d-%02d-%02d', $annee, $moisFin, $jourFin));
  2003.     
  2004.             if ($dateFin < $dateDebut) $dateFin->modify('+1 year');
  2005.     
  2006.             return ['debut' => $dateDebut, 'fin' => $dateFin];
  2007.         }
  2008.     
  2009.         return null;
  2010.     };
  2011.     
  2012.     // Requête Doctrine
  2013.     $queryBuilder = $entityManager->createQueryBuilder();
  2014.     $queryBuilder
  2015.         ->select('for.id', 'for.dates_session', 'for.prix', 'for.devise', 'th.nom', 
  2016.             'thm.nom AS thmnom','vil.nom AS vilnom','vil.pays','for.created_at',
  2017.             'th.slug','th.description','for.devise','vil.longitude','vil.latitude',
  2018.             'for.image'
  2019.         )
  2020.         ->from(Formations::class, 'for')
  2021.         ->innerJoin(Themes::class, 'th', 'WITH', 'for.theme = th.id')
  2022.         ->innerJoin(Villes::class,  'vil', 'WITH', 'for.ville = vil.id')
  2023.         ->innerJoin(Thematiques::class, 'thm', 'WITH', 'th.thematique = thm.id')
  2024.         ->where('th.slug = :theme')
  2025.         ->andWhere('for.id != :forid')
  2026.         ->andWhere('vil.pays = :pays')
  2027.         ->setParameter('theme', $slug)
  2028.         ->setParameter('forid', $id)
  2029.         ->setParameter('pays', $getpays);
  2030.     
  2031.     $results = $queryBuilder->getQuery()->getResult();
  2032.     
  2033.     // Filtrer uniquement les formations à venir
  2034.     $formations = array_filter($results, function($f) use ($extractDates, $today) {
  2035.         $dates = $extractDates($f['dates_session']);
  2036.         return $dates && $dates['debut'] > $today;
  2037.     });
  2038.     
  2039.     // Trier par date de début la plus proche
  2040.     usort($formations, function($a, $b) use ($extractDates) {
  2041.         return $extractDates($a['dates_session'])['debut'] <=> $extractDates($b['dates_session'])['debut'];
  2042.     });
  2043.     
  2044.     // Maintenant $formationsAvenir contient uniquement les formations à venir
  2045.         return $this->render('front/detail/detail-seminaire-inter.html.twig',[
  2046.             'formations' => $formations,
  2047.             'locations' => $locations,
  2048.             'annee' => $annee,
  2049.             'type' => $type,
  2050.             'mentions' => $mentions,
  2051.             'query' => $query,
  2052.             'slug' => $slug
  2053.         ]);
  2054.     }
  2055.     
  2056.     #[Route('/blogs', name: 'front.blog', methods:['GET'])]
  2057.     public function blog(
  2058.         Request $request, 
  2059.         MentionsRepository $mentionRepository,
  2060.         ManagementsRepository $managementRepository,
  2061.         PaginatorInterface $paginator,
  2062.         BlogsRepository $blogRepository, 
  2063.         EntityManagerInterface $entityManager
  2064.         ): Response
  2065.     {
  2066.         $All_blog = $blogRepository->findBy(['statut' => 'Publié'], ['createdat' => 'DESC']);
  2067.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  2068.         $queryBuilder = $entityManager->createQueryBuilder();
  2069.         $queryBuilder
  2070.         ->select('blog')
  2071.         ->from(Blogs::class, 'blog')
  2072.         ->where('blog.statut = :statut')
  2073.         ->setParameter('statut', 'Publié')
  2074.         ->orderBy('blog.createdat', 'DESC');
  2075.         
  2076.         $pagination = $paginator->paginate(
  2077.             $queryBuilder,
  2078.             $request->query->getInt('page', 1),
  2079.             12
  2080.         ); 
  2081.         
  2082.         $last_blog = $blogRepository->findBy(['statut' => 'Publié'], ['createdat' => 'DESC'],limit: 4);
  2083.         $mentions = $mentionRepository->findAll();
  2084.         return $this->render('front/blog.html.twig',[
  2085.             'mentions' => $mentions,
  2086.             'last_blog' => $last_blog,
  2087.             'pagination' => $pagination,
  2088.             'manageLimit' => $manageLimit
  2089.         ]);
  2090.     }
  2091.     
  2092.     #[Route('/blog/{slug}', name: 'front.detail.blog', methods:['GET','POST'])]
  2093.     public function detailblog(
  2094.         $slug,
  2095.         Request $request, 
  2096.         BlogsRepository $blogRepository,
  2097.         MentionsRepository $mentionRepository,
  2098.         ManagementsRepository $managementRepository,
  2099.         EntityManagerInterface $entityManager
  2100.     ): Response
  2101.     {
  2102.         $Allblog = $blogRepository->findAll();
  2103.         $detblog = $blogRepository->findOneBy(array('slug' => $slug));
  2104.         $last_blog = $blogRepository->findBy([], ['createdat' => 'ASC']);
  2105.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  2106.         $mentions = $mentionRepository->findAll();
  2107.         return $this->render('front/detail/detail-blog.html.twig',[
  2108.             'detblog' => $detblog,
  2109.             'blog' => $Allblog,
  2110.             'mentions' => $mentions,
  2111.             'last_blog' => $last_blog,
  2112.             'manageLimit' => $manageLimit
  2113.         ]);
  2114.     }
  2115.     
  2116.     
  2117.     
  2118.     #[Route('/actualites', name: 'front.actualite', methods:['GET'])]
  2119.     public function actualite(
  2120.         Request $request, 
  2121.         MentionsRepository $mentionRepository,
  2122.         ManagementsRepository $managementRepository,
  2123.         PaginatorInterface $paginator,
  2124.         ActualitesRepository $actualiteRepository, 
  2125.         EntityManagerInterface $entityManager
  2126.         ): Response
  2127.     {
  2128.         $All_actu = $actualiteRepository->findBy(['statut' => 'Publié'], ['createdat' => 'DESC']);
  2129.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  2130.         $queryBuilder = $entityManager->createQueryBuilder();
  2131.         $queryBuilder
  2132.         ->select('actu')
  2133.         ->from(Actualites::class, 'actu')
  2134.         ->where('actu.statut = :statut')
  2135.         ->setParameter('statut', 'Publié')
  2136.         ->orderBy('actu.createdat', 'DESC');
  2137.         
  2138.         $pagination = $paginator->paginate(
  2139.             $queryBuilder,
  2140.             $request->query->getInt('page', 1),
  2141.             12
  2142.         ); 
  2143.         
  2144.         $last_actu = $actualiteRepository->findBy(['statut' => 'Publié'], ['createdat' => 'DESC'],limit: 4);
  2145.         $mentions = $mentionRepository->findAll();
  2146.         return $this->render('front/actualite.html.twig',[
  2147.             'mentions' => $mentions,
  2148.             'last_actu' => $last_actu,
  2149.             'pagination' => $pagination,
  2150.             'manageLimit' => $manageLimit
  2151.         ]);
  2152.     }
  2153.     
  2154.     #[Route('/actualite/{slug}', name: 'front.detail.actu', methods:['GET','POST'])]
  2155.     public function detailactu(
  2156.         $slug,
  2157.         Request $request, 
  2158.         ActualitesRepository $actuRepository,
  2159.         MentionsRepository $mentionRepository,
  2160.         ManagementsRepository $managementRepository,
  2161.         EntityManagerInterface $entityManager
  2162.     ): Response
  2163.     {
  2164.         $Allactu = $actuRepository->findAll();
  2165.         $detactu = $actuRepository->findOneBy(array('slug' => $slug));
  2166.         $last_actu = $actuRepository->findBy([], ['createdat' => 'ASC']);
  2167.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  2168.         $mentions = $mentionRepository->findAll();
  2169.         return $this->render('front/detail/detail-actualite.html.twig',[
  2170.             'detactu' => $detactu,
  2171.             'actualite' => $Allactu,
  2172.             'mentions' => $mentions,
  2173.             'last_actu' => $last_actu,
  2174.             'manageLimit' => $manageLimit
  2175.         ]);
  2176.     }
  2177.     
  2178.     #[Route('/mentions/{slug}', name: 'front.mention.detail', methods:['GET','POST'])]
  2179.     public function detailmention(
  2180.         $slug,
  2181.         Request $request, 
  2182.         MentionsRepository $mentionRepository,
  2183.         EntityManagerInterface $entityManager
  2184.     ): Response
  2185.     {
  2186.         $detmention = $mentionRepository->findOneBy(array('slug' => $slug));
  2187.         $mentions = $mentionRepository->findAll();
  2188.         return $this->render('front/detail/detail-mention.html.twig',[
  2189.             'detmention' => $detmention,
  2190.             'mentions' => $mentions,
  2191.         ]);
  2192.     }
  2193.     
  2194.     #[Route('/presentation/nos-centres', name: 'front.centres', methods:['GET'])]
  2195.     public function centres(
  2196.         Request $request, 
  2197.         VillesRepository $villeRepository,
  2198.         MentionsRepository $mentionRepository,
  2199.         EntityManagerInterface $entityManager
  2200.         ): Response
  2201.     {
  2202.         $Ville = $villeRepository->findAll();
  2203.         $locations = [
  2204.             [
  2205.                 'lat' => 5.399573993486265, 
  2206.                 'lng' => -3.9608326481739446, 
  2207.                 'ville' => 'ABIDJAN',
  2208.                 'Pays' => 'CÔTE D\'IVOIRE',
  2209.             ],
  2210.             [
  2211.                 'lat' => 48.82503553852063, 
  2212.                 'lng' => 2.3943687952459913, 
  2213.                 'ville' => 'PARIS',
  2214.                 'pays' => 'FRANCE',
  2215.             ],
  2216.             [
  2217.                 'lat' => 33.61983014582587, 
  2218.                 'lng' => -7.591902517162099, 
  2219.                 'ville' => 'CASABLANCA',
  2220.                 'pays' => 'MAROC',
  2221.             ],
  2222.             [
  2223.                 'lat' => 14.671959307245515, 
  2224.                 'lng' => -17.428349942742518, 
  2225.                 'ville' => 'DAKAR',
  2226.                 'pays' => 'SENEGAL',
  2227.             ],
  2228.             [
  2229.                 'lat' => 25.222641788192867, 
  2230.                 'lng' =>  55.4419721341237, 
  2231.                 'ville' => 'DUBAI',
  2232.                 'pays' => 'EMIRATS ARABES UNIS',
  2233.             ],
  2234.             [
  2235.                 'lat' => 41.008441347309684, 
  2236.                 'lng' => 28.969801288596543, 
  2237.                 'ville' => 'ISTANBUL',
  2238.                 'pays' => 'TURQUIE',
  2239.             ],
  2240.             [
  2241.                 'lat' => 40.71278802621601, 
  2242.                 'lng' => -74.0050546180957, 
  2243.                 'ville' => 'NEW YORK',
  2244.                 'pays' => 'USA',
  2245.             ],
  2246.             [
  2247.                 'lat' => 45.50191624423104, 
  2248.                 'lng' => -73.57059318260778, 
  2249.                 'ville' => 'MONTREAL',
  2250.                 'pays' => 'CANADA',
  2251.             ],
  2252.             [
  2253.                 'lat' => 31.25354887891074, 
  2254.                 'lng' => 121.44798285112802, 
  2255.                 'ville' => 'SHANGHAI',
  2256.                 'pays' => 'CHNE',
  2257.             ],
  2258.         ];
  2259.         $mentions = $mentionRepository->findAll();
  2260.         return $this->render('front/centres.html.twig',[
  2261.             'locations' => $locations,
  2262.             'mentions' => $mentions,
  2263.             'ville' => $Ville    
  2264.         ]);
  2265.     }
  2266.     
  2267.     #[Route('/presentation/nos-partenaires', name: 'front.nos-partenaires', methods:['GET'])]
  2268.     public function partenaires(
  2269.         Request $request, 
  2270.         PartenairesRepository $partenaireRepository,
  2271.         MentionsRepository $mentionRepository,
  2272.         EntityManagerInterface $entityManager
  2273.         ): Response
  2274.     {
  2275.         $partenaires = $partenaireRepository->findAll();
  2276.         $groupes = [];
  2277.         foreach ($partenaires as $p) {
  2278.             $groupes[$p->getPaysPart()][] = $p;
  2279.         }
  2280.         $mentions = $mentionRepository->findAll();
  2281.         return $this->render('front/partenaire.html.twig',[
  2282.             'mentions' => $mentions,
  2283.             'groupes' => $groupes   
  2284.         ]);
  2285.     }
  2286.     
  2287.     #[Route('/presentation/nos-centres/{slug}', name: 'front.detail.centre', methods:['GET'])]
  2288.     public function detail_centre(
  2289.         $slug,
  2290.         Request $request,
  2291.         GaleriesRepository $galRepository,
  2292.         VillesRepository $villeRepository,
  2293.         MentionsRepository $mentionRepository,
  2294.         EntityManagerInterface $entityManager
  2295.         ): Response
  2296.     {
  2297.         $queryBuilder = $entityManager->createQueryBuilder();
  2298.         $queryBuilder
  2299.         ->select('gal.imgGal', 'gal.nom')
  2300.         ->from(Galeries::class, 'gal')
  2301.         ->where('gal.nom = :nom')
  2302.         ->setParameter('nom', $slug);
  2303.         $detgal = $queryBuilder->getQuery()->getResult();
  2304.         
  2305.         //$detgal = $galRepository->findOneBy(array('nom' => $slug));
  2306.         //$detgal = $galRepository->findAll();
  2307.         $detcentres = $villeRepository->findOneBy(array('slug' => $slug));
  2308.         $mentions = $mentionRepository->findAll();
  2309.         return $this->render('front/detail/detail-centre.html.twig',[
  2310.             'slug' => $slug,
  2311.             'detcentre' => $detcentres,
  2312.             'mentions' => $mentions,
  2313.             'detgal' => $detgal
  2314.         ]);
  2315.     }
  2316.     
  2317.     #[Route('/financement-des-etudes', name: 'front.financement.etude', methods:['GET','POST'])]
  2318.     public function financement(): Response
  2319.     {
  2320.         return $this->render('front/admissions/financement.html.twig');
  2321.     }
  2322.     
  2323.     #[Route('/nos-thematiques', name: 'front.inter.thematique', methods:['GET','POST'])]
  2324.     public function thematiques(
  2325.         Request $request, 
  2326.         PaginatorInterface $paginator,
  2327.         ThematiquesRepository $thematiqueRepository,
  2328.         ManagementsRepository $managementRepository,
  2329.         MentionsRepository $mentionRepository,
  2330.         EntityManagerInterface $entityManager
  2331.     ): Response
  2332.     {
  2333.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  2334.         $queryBuilder = $entityManager->createQueryBuilder();
  2335.         $queryBuilder
  2336.             ->select('thm.id, thm.nom, thm.slug, thm.description, COUNT(th.id) AS nbThemes')
  2337.             ->from(Thematiques::class, 'thm')
  2338.             ->innerJoin(Themes::class, 'th', 'WITH', 'thm.id = th.thematique')
  2339.             ->groupBy('thm.id, thm.nom, thm.slug, thm.description');
  2340.         $query = $queryBuilder->getQuery()->getResult();
  2341.         $pagination = $paginator->paginate(
  2342.             $queryBuilder,
  2343.             $request->query->getInt('page', 1),
  2344.             12
  2345.         ); 
  2346.         //dd($query);
  2347.         $mentions = $mentionRepository->findAll();
  2348.         return $this->render('front/thematique.html.twig',[
  2349.             'manageLimit' => $manageLimit,
  2350.             'pagination' => $query,
  2351.             'mentions' => $mentions
  2352.         ]);
  2353.     }
  2354.     
  2355.     #[Route('/nos-thematiques/{slug}/code{id}', name: 'front.thematique.detail', methods: ['GET'])]
  2356.     public function detail_thematique(
  2357.         $id,
  2358.         $slug,
  2359.         Request $request, 
  2360.         PaginatorInterface $paginator,
  2361.         ThemesRepository $themeRepository,
  2362.         ThematiquesRepository $thematiqueRepository,
  2363.         ManagementsRepository $managementRepository,
  2364.         MentionsRepository $mentionRepository,
  2365.         EntityManagerInterface $entityManager    
  2366.     ): Response
  2367.     {
  2368.         $slug = strtolower(trim($slug));
  2369.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  2370.         $thematique = $thematiqueRepository->findOneBy(['slug' => $slug]);
  2371.         // dd($slug);
  2372.         $nomThematique = $thematique->getNom();
  2373.         
  2374.         if (!$thematique) {
  2375.             $this->addFlash('danger','Cette thématique est introuvable');
  2376.             return $this->redirectToRoute('front.inter.thematique');
  2377.         }
  2378.         
  2379.         $queryBuilder = $entityManager->createQueryBuilder();
  2380.         $queryBuilder
  2381.             ->select('th.id', 'th.nom', 'th.slug' , 'th.description')
  2382.             ->from(Themes::class, 'th')
  2383.             ->where('th.thematique = :id') 
  2384.             ->setParameter('id', $id);
  2385.         $query = $queryBuilder->getQuery()->getResult();
  2386.         $pagination = $paginator->paginate(
  2387.             $queryBuilder,
  2388.             $request->query->getInt('page', 1),
  2389.             12
  2390.         ); 
  2391.         //dd($slug);
  2392.         $mentions = $mentionRepository->findAll();
  2393.         return $this->render('front/detail/detail-thematique.html.twig',[
  2394.             'nomThematique' => $nomThematique,
  2395.             'manageLimit' => $manageLimit,
  2396.             'thematique' => $thematique,
  2397.             'pagination' => $query,
  2398.             'mentions' => $mentions,
  2399.             'slug' => $slug
  2400.         ]);
  2401.     }
  2402.     
  2403.     #[Route('/nos-thematiques/{slugThematique}/{slug}', name: 'front.thematique.date.theme', methods: ['GET'])]
  2404.     public function detail_thematique_theme(
  2405.         $slug,
  2406.         $slugThematique,
  2407.         Request $request, 
  2408.         SluggerInterface $slugger, 
  2409.         PaginatorInterface $paginator,
  2410.         ThemesRepository $themeRepository,
  2411.         ThematiquesRepository $thematiqueRepository,
  2412.         FormationsRepository $formationRepository,
  2413.         ManagementsRepository $managementRepository,
  2414.         MentionsRepository $mentionRepository,
  2415.         EntityManagerInterface $entityManager    
  2416.     ): Response
  2417.     {
  2418.         $annee = date('Y');
  2419.         
  2420.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  2421.         $thematique = $thematiqueRepository->findOneBy(['slug' => $slugThematique]);
  2422.         $theme = $themeRepository->findOneBy(['slug' => $slug]);
  2423.         if (!$theme) {
  2424.             $this->addFlash('danger','Cette thème est introuvable');
  2425.             return $this->redirectToRoute('front.inter.thematique');
  2426.         }
  2427.         $themeId = $theme->getId();
  2428.         $thematiqueId = $theme->getId();
  2429.         
  2430.         $thematique = $thematiqueRepository->findOneBy(['slug' => $slugThematique]);
  2431.         
  2432.         $queryBuilder = $entityManager->createQueryBuilder();
  2433.         $queryBuilder
  2434.             ->select('th.nom','th.slug','thm.slug AS thematiqueSlug',
  2435.                 'th.description','vil.longitude','vil.latitude'
  2436.             )
  2437.             ->from(Formations::class, 'for')
  2438.             ->innerJoin(Themes::class, 'th', 'WITH', 'for.theme = th.id')
  2439.             ->innerJoin(Thematiques::class, 'thm', 'WITH', 'th.thematique = thm.id')
  2440.             ->innerJoin(Villes::class, 'vil', 'WITH', 'for.ville = vil.id')
  2441.             ->where('th.slug = :themeSlug')
  2442.             ->andWhere('thm.slug = :thematiqueSlug')
  2443.             ->setParameter('themeSlug', $slug)
  2444.             ->setParameter('thematiqueSlug', $slugThematique)
  2445.             ->orderBy('for.created_at', 'DESC')
  2446.             ->setMaxResults(1);
  2447.         $query = $queryBuilder->getQuery()->getResult();
  2448.         //dd($query);
  2449.         $queryBuilder = $entityManager->createQueryBuilder();
  2450.         $queryBuilder
  2451.             ->select('for.id','vil.nom AS vilnom','vil.pays')
  2452.             ->from(Formations::class, 'for')
  2453.             ->innerJoin(Themes::class, 'th', 'WITH', 'for.theme = th.id')
  2454.             ->innerJoin(Villes::class,  'vil', 'WITH', 'for.ville = vil.id')
  2455.             ->innerJoin(Thematiques::class, 'thm', 'WITH', 'th.thematique = thm.id')
  2456.             ->where('for.theme = :id') 
  2457.             ->setParameter('id', $themeId);
  2458.         $ville = $queryBuilder->getQuery()->getResult();
  2459.         //dd($query);
  2460.         //dd($thematique);
  2461.         
  2462.         $mentions = $mentionRepository->findAll();
  2463.         return $this->render('front/detail/detail-thematique-theme-date.html.twig',[
  2464.             'manageLimit' => $manageLimit,
  2465.             'thematique' => $thematique,
  2466.             'query' => $query,
  2467.             'ville' => $ville,
  2468.             'annee' => $annee,
  2469.             'mentions' => $mentions,
  2470.             'slug' => $slug,
  2471.             'slugThematique' => $slugThematique
  2472.         ]);
  2473.     }
  2474.     #[Route('/inscription-{annee}', name: 'front.inscriptions', methods: ['GET', 'POST'])]
  2475.     public function inscription(
  2476.         Request $request,
  2477.         MailerInterface $mailer,
  2478.         ThemesRepository $themesRepository,
  2479.         VillesRepository $villesRepository, 
  2480.         EntityManagerInterface $entityManager,
  2481.         MentionsRepository $mentionRepository,
  2482.         FormationsRepository $formationsRepository
  2483.     ): Response {
  2484.         
  2485.         $annee = date('Y');
  2486.         /* =========================
  2487.            AJAX
  2488.         ========================= */
  2489.         if ($request->isXmlHttpRequest()) {
  2490.             /* THÉMATIQUE → THÈMES */
  2491.             if ($request->request->get('action') === 'themes') {
  2492.                 $thematiqueVal = $request->request->get('thematiqueVal');
  2493.                 $themes = $themesRepository->findBy(
  2494.                     ['thematique' => $thematiqueVal],
  2495.                     ['nom' => 'ASC']
  2496.                 );
  2497.                 $data = [];
  2498.                 foreach ($themes as $theme) {
  2499.                     $data[] = [
  2500.                         'id'  => $theme->getId(),
  2501.                         'nom' => $theme->getNom(),
  2502.                     ];
  2503.                 }
  2504.                 return new JsonResponse($data);
  2505.             }
  2506.             /* THÈME → LIEUX */
  2507.             if ($request->request->get('action') === 'lieux') {
  2508.                 $themeId = $request->request->get('themeVal');
  2509.                 $queryBuilder = $entityManager->createQueryBuilder();
  2510.                 $queryBuilder
  2511.                 ->select(
  2512.                     'for.id', 'for.dates_session AS session', 'for.prix', 'for.devise', 'th.nom', 
  2513.                     'vil.nom AS vilnom','vil.pays','for.created_at','th.slug',
  2514.                     'th.description','for.devise'
  2515.                     )
  2516.                 ->from(Formations::class, 'for')
  2517.                 ->innerJoin(Themes::class,'th', 'WITH', 'for.theme = th.id')
  2518.                 ->innerJoin(Villes::class, 'vil', 'WITH', 'for.ville = vil.id')
  2519.                 ->where('th.id = :idtheme')
  2520.                 ->setParameter('idtheme', $themeId);
  2521.                 $formations = $queryBuilder->getQuery()->getResult();
  2522.                 //dump($themeId,$formations);
  2523.                 $data = [];
  2524.                 foreach ($formations as $formation) {
  2525.                     $data[] = [
  2526.                         'id'   => $formation['id'],
  2527.                         'prix' => $formation['prix'],
  2528.                         'lieu' => $formation['vilnom'],
  2529.                         'devise' => $formation['devise'],
  2530.                         'session' => $formation['session'],
  2531.                     ];
  2532.                 }
  2533.                 return new JsonResponse($data);
  2534.             }
  2535.             /* LIEU → SESSION + PRIX */
  2536.             if ($request->request->get('action') === 'lieu_details') {
  2537.                 $formationId = $request->request->get('formationId');
  2538.                 $queryBuilder = $entityManager->createQueryBuilder();
  2539.                 $queryBuilder
  2540.                     ->select(
  2541.                         'for.dates_session AS session',
  2542.                         'for.prix',
  2543.                         'for.devise'
  2544.                     )
  2545.                     ->from(Formations::class, 'for')
  2546.                     ->where('for.id = :id')
  2547.                     ->setParameter('id', $formationId);
  2548.                 $formation = $queryBuilder->getQuery()->getOneOrNullResult();
  2549.                 if (!$formation) {
  2550.                     return new JsonResponse(['error' => 'Formation introuvable'], 404);
  2551.                 }
  2552.                 return new JsonResponse([
  2553.                     'session' => $formation['session'],
  2554.                     'prix'    => $formation['prix'],
  2555.                     'devise'  => $formation['devise'],
  2556.                 ]);
  2557.             }
  2558.         }
  2559.         /* =========================
  2560.            AFFICHAGE NORMAL
  2561.         ========================= */
  2562.         $inscription = new Inscriptions();
  2563.  
  2564.         $form = $this->createForm(NewInscriptionFormType::class);
  2565.         $form->handleRequest($request);
  2566.         if ($form->isSubmitted()) {
  2567.             
  2568.             $civilite = $form->get('civilite')->getData();
  2569.             $nom = $form->get('nom')->getData();
  2570.             $prenoms = $form->get('prenoms')->getData();
  2571.             $fonction = $form->get('fonction')->getData();
  2572.             $telephone = $form->get('telephone')->getData();
  2573.             
  2574.             $adresse = $form->get('adresse')->getData();
  2575.             $mail = $form->get('mail')->getData();
  2576.             $entreprise = $form->get('entreprise')->getData();
  2577.             
  2578.             $siteweb = $form->get('siteweb')->getData();
  2579.             $nombrepart = $form->get('nbparticipant')->getData();
  2580.             
  2581.             $pays = $form->get('pays')->getData();
  2582.             $ville = $form->get('ville')->getData();
  2583.             
  2584.             $boitepostale = $form->get('boitepostale')->getData();
  2585.             $whatsapp = $form->get('whatsapp')->getData();          
  2586.             
  2587.             $theme = $form->get('theme')->getData();
  2588.             //$lieu = $form->get('lieu')->getData();
  2589.             $periode = $form->get('periode')->getData();
  2590.             
  2591.             $telephone = $form->get('telephone')->getData();
  2592.             $commentaire = $form->get('commentaire')->getData(); 
  2593.            
  2594.             $token = $form->get('recaptchaToken')->getData();
  2595.             
  2596.             if(!$commentaire){
  2597.                 $commentaire = "pas renseigné";
  2598.             }else{
  2599.                 $commentaire = $form->get('commentaire')->getData();
  2600.             }
  2601.             
  2602.             if(!$siteweb){
  2603.                 $siteweb = "pas renseigné";
  2604.             }else{
  2605.                 $siteweb = $form->get('siteweb')->getData();
  2606.             }
  2607.             
  2608.             if(!$adresse){
  2609.                 $adresse = "pas renseigné";
  2610.             }else{
  2611.                 $adresse = $form->get('adresse')->getData();
  2612.             }
  2613.             
  2614.             if(!$boitepostale){
  2615.                 $boitepostale = "pas renseigné";
  2616.             }else{
  2617.                 $boitepostale = $form->get('boitepostale')->getData();
  2618.             }
  2619.             
  2620.             $themeId = $theme->getId();
  2621.             $nomtheme = $theme->getNom();
  2622.             //dd($form);
  2623.             
  2624.             $Seminaires = $formationsRepository->findOneBy(array('theme' => $themeId, 'dates_session' => $periode));
  2625.             /*$formationId = $formations->getId();*/
  2626.             
  2627.             $queryBuilder = $entityManager->createQueryBuilder();
  2628.             $queryBuilder
  2629.             ->select(
  2630.                 'for.id', 'for.dates_session AS session', 'for.prix', 'for.devise', 'th.nom', 
  2631.                 'vil.nom AS vilnom','vil.pays','for.created_at','th.slug', 'th.id AS themeId', 
  2632.                 'th.description','for.devise'
  2633.                 )
  2634.             ->from(Formations::class, 'for')
  2635.             ->innerJoin(Themes::class,'th', 'WITH', 'for.theme = th.id')
  2636.             ->innerJoin(Villes::class, 'vil', 'WITH', 'for.ville = vil.id')
  2637.             ->where('th.id = :idtheme')
  2638.             ->andwhere('for.dates_session = :sessions')
  2639.             ->setParameter('idtheme', $themeId)
  2640.             ->setParameter('sessions', $periode);
  2641.             $formations = $queryBuilder->getQuery()->getResult();
  2642.             $villeForm = $formations[0]['vilnom'];
  2643.             $prixForm = $formations[0]['prix'];
  2644.             $deviseForm = $formations[0]['devise'];
  2645.             
  2646.             //dd($villeForm, $villeForm, $prixForm, $deviseForm);
  2647.             
  2648.             try {
  2649.                 $inscription->setNom($nom);
  2650.                 $inscription->setPrenoms($prenoms);
  2651.                 $inscription->setFonction($fonction);
  2652.                 $inscription->setAdresse($adresse);
  2653.                 $inscription->setMail($mail);
  2654.                 $inscription->setEntreprise($entreprise);
  2655.                 $inscription->setSiteweb($siteweb);
  2656.                 $inscription->setNbparticipant($nombrepart);
  2657.                 $inscription->setPays($pays);
  2658.                 $inscription->setVille( $ville);
  2659.                 $inscription->setBoitepostale($boitepostale);
  2660.                 $inscription->setWhatsapp($whatsapp);
  2661.                 $inscription->setTelephone($telephone);
  2662.                 $inscription->setCommentaire($commentaire);
  2663.                 $inscription->setFormation($Seminaires);
  2664.                 $inscription->setSource('site_web');
  2665.                 $entityManager->persist($inscription);
  2666.                 $entityManager->flush();
  2667.             } catch (\Throwable $e) {
  2668.                 $logger->error('Inscription: '.$e->getMessage(), ['exception' => $e]);
  2669.                 $this->addFlash('danger', 'Erreur lors de l\'enregistrement.');
  2670.                 return $this->render(/* ... */);
  2671.             }
  2672.             $destinataire = 'mailinscriptions@cimef-international.org';
  2673.             $expediteur   = $mail;
  2674.             $reponse      = $expediteur;
  2675.             $suj = "INSCRIPTION FORMATION 2026";
  2676.             
  2677.             $codehtml = '<html><body>'.
  2678.             '<table width="100%" cellpadding="0" cellspacing="0" style="background-color:#f4f6f8; padding:20px;">
  2679.             <tr>
  2680.             <td align="center">
  2681.             <table width="600" cellpadding="0" cellspacing="0" style="background-color:#ffffff; border-radius:6px; overflow:hidden; box-shadow:0 2px 6px rgba(0,0,0,0.08);">
  2682.             <tr>
  2683.             <td style="background-color:#051a53; padding:20px; color:#ffffff; text-align:center;">
  2684.             <h2 style="margin:0;">Inscription</h2>
  2685.             </td>
  2686.             </tr>
  2687.             <tr>
  2688.             <td style="padding:25px; color:#333333; font-size:14px; line-height:1.6;">
  2689.             <p>Inscription de '.$civilite.' <strong>'.$prenoms.' '.$nom.'</strong> pour une formation avec pour thème :<strong>'.$nomtheme.'</strong>.</p>
  2690.             <p>Veuillez trouver ci-dessous le récapitulatif :</p>
  2691.             <hr style="border:none; border-top:1px solid #e0e0e0; margin:20px 0;">
  2692.             <h4 style="margin-bottom:8px; color:#0d6efd;">Informations personnelles</h4>
  2693.             <p>
  2694.             <strong>Nom & Prénoms :</strong> '.$prenoms.' '.$nom.'<br>
  2695.             <strong>Fonction :</strong> '.$fonction.'<br>
  2696.             <strong>Entreprise :</strong> '.$entreprise.'<br>
  2697.             <strong>Adresse :</strong> '.$adresse.'<br>
  2698.             <strong>Pays / Ville :</strong> '.$pays.' / '.$ville.'<br>
  2699.             </p>
  2700.             <h4 style="margin-bottom:8px; color:#0d6efd;">Coordonnées</h4>
  2701.             <p>
  2702.             <strong>Email :</strong> '.$mail.'<br>
  2703.             <strong>Téléphone :</strong> '.$telephone.'<br>
  2704.             <strong>Whatsapp :</strong> '.$whatsapp.'<br>
  2705.             <strong>Site web :</strong> '.$siteweb.'
  2706.             </p>
  2707.             <h4 style="margin-bottom:8px; color:#0d6efd;">Détails de participation</h4>
  2708.             <p>
  2709.             <strong>Nombre de participants :</strong> '.$nombrepart.'<br>
  2710.             <strong>Commentaire :</strong> '.$commentaire.'
  2711.             </p>
  2712.             <h4 style="margin-bottom:8px; color:#0d6efd;">Détail de la formation</h4>
  2713.             <p>
  2714.             <strong>Thème :</strong> '.$nomtheme.'<br>
  2715.             <strong>Lieu :</strong> '.$villeForm.'<br>
  2716.             <strong>Période :</strong> '.$periode.'<br>
  2717.             <strong>Prix :</strong> '.$prixForm.' '.$deviseForm.'
  2718.             </p>
  2719.             </td>
  2720.             </tr>
  2721.             <tr>
  2722.             <td style="background-color:#f1f1f1; padding:15px; text-align:center; font-size:12px; color:#777777;">
  2723.             © '.date("Y").' CIMEF International — Tous droits réservés
  2724.             </td>
  2725.             </tr>
  2726.             </table>
  2727.             </td>
  2728.             </tr>
  2729.             </table>
  2730.             </body></html>';
  2731.              
  2732.             $email = (new Email())
  2733.             ->from('CIMEF International <mailinscriptions@cimef-international.org>')
  2734.                 ->to($destinataire)                 // destinataire principal
  2735.                 ->cc('medias@cimef-international.com') // COPIE
  2736.                 ->replyTo($expediteur)              // Reply-To:
  2737.                 ->subject($suj)     
  2738.                 ->text(strip_tags($codehtml))
  2739.                 ->html($codehtml);// Subject:
  2740.                 //->html($codehtml, 'text/html');   // Content-Type + charset utf-8
  2741.                 $mailer->send($email);
  2742.     
  2743.                 $this->addFlash(
  2744.                 'success',
  2745.                 'Votre inscription à été bien enregistrée');
  2746.             }
  2747.         $mentions = $mentionRepository->findAll();
  2748.         return $this->render('front/inscriptions/inscription-index.html.twig', [
  2749.             'annee' => date('Y'),
  2750.             'mentions' => $mentions,
  2751.             'demandeformationsForm' => $form->createView(),
  2752.         ]);
  2753.     }
  2754.     #[Route('/catalogue-CIMEF-INTERNATIONAL-2026', name: 'front.catalogue', methods:['GET'])]
  2755.     public function catalogue(
  2756.         Request $request, 
  2757.         ManagementsRepository $managementRepository,
  2758.         MentionsRepository $mentionRepository,
  2759.         EntityManagerInterface $entityManager
  2760.     ): Response
  2761.     {
  2762.         return $this->render('front/cato.html.twig',[
  2763.             'no_base_style' => true
  2764.         ]);
  2765.     }
  2766.     #[Route('/contact', name: 'front.contact', methods:['GET','POST'])]
  2767.     public function contact(
  2768.         Request $request,
  2769.         MailerInterface $mailer,
  2770.         MentionsRepository $mentionRepository,
  2771.         EntityManagerInterface $entityManager
  2772.     ): Response
  2773.     {
  2774.         $mentions = $mentionRepository->findAll();
  2775.         $contactForm = $this->createForm(ContactFormType::class);
  2776.         $contactForm->handleRequest($request);
  2777.         
  2778.         if($contactForm->isSubmitted()){
  2779.             $nom = htmlspecialchars($contactForm->get('nom')->getData());
  2780.             $mail = htmlspecialchars($contactForm->get('email')->getData());
  2781.             $sujet = htmlspecialchars($contactForm->get('sujet')->getData());
  2782.             $contact = htmlspecialchars($contactForm->get('contact')->getData());
  2783.             $message = htmlspecialchars($contactForm->get('message')->getData());
  2784.             
  2785.             $token = $contactForm->get('recaptchaToken')->getData();
  2786.             
  2787.             $besoinArray = $contactForm->get('besoin')->getData();
  2788.             $besoin = implode(', ', array_map('htmlspecialchars', $besoinArray));
  2789.             $response = $this->client->request(
  2790.                 'POST',
  2791.                 'https://www.google.com/recaptcha/api/siteverify',
  2792.                 [
  2793.                     'body' => [
  2794.                         'secret' => $_ENV['RECAPTCHA_SECRET_KEY'],
  2795.                         'response' => $token,
  2796.                     ]
  2797.                 ]
  2798.             );
  2799.             $result = $response->toArray();
  2800.             if (!$result['success'] || !isset($result['score']) || $result['score'] < 0.5) {
  2801.                 $this->addFlash(
  2802.                     'warning',
  2803.                     'Vérification reCAPTCHA échouée.'
  2804.                 );
  2805.                 return $this->render('front/contact.html.twig',[
  2806.                     'contactForm' => $contactForm->createView(),
  2807.                     'mentions' => $mentions
  2808.                 ]);
  2809.             }            
  2810.             
  2811.             $destinataire = 'contact@cimef-international.org';
  2812.             $expediteur   = $mail;
  2813.             $reponse      = $expediteur;
  2814.             $suj = $sujet;
  2815.             
  2816.             $codehtml = '
  2817.             <!DOCTYPE html>
  2818.                 <html lang="fr">
  2819.                 <head>
  2820.                     <meta charset="UTF-8">
  2821.                     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  2822.                     <title>Nouveau message de contact</title>
  2823.                 </head>
  2824.                 <body style="margin: 0; padding: 20px; font-family: Arial, sans-serif; background-color: #f8f9fa;">
  2825.                     <table width="100%" cellpadding="0" cellspacing="0" style="max-width: 700px; margin: 0 auto; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 12px rgba(5, 26, 83, 0.1);">
  2826.                         <!-- Header -->
  2827.                         <tr>
  2828.                             <td style="background: linear-gradient(135deg, #051a53 0%, #0a2a7a 100%); padding: 30px 30px 25px 30px; text-align: center; border-top: 4px solid #ff6600;">
  2829.                                 <table width="100%" cellpadding="0" cellspacing="0">
  2830.                                     <tr>
  2831.                                         <td style="color: white; font-size: 28px; font-weight: bold; padding-bottom: 10px;">
  2832.                                             CIMEF-INTERNATIONAL
  2833.                                         </td>
  2834.                                     </tr>
  2835.                                     <tr>
  2836.                                         <td style="color: white; font-size: 22px; font-weight: 600; padding-bottom: 8px;">
  2837.                                             Nouveau message de contact
  2838.                                         </td>
  2839.                                     </tr>
  2840.                                     <tr>
  2841.                                         <td style="color: rgba(255, 255, 255, 0.9); font-size: 16px;">
  2842.                                             Formulaire de contact • Site de CIMEF-INTERNATIONAL
  2843.                                         </td>
  2844.                                     </tr>
  2845.                                 </table>
  2846.                             </td>
  2847.                         </tr>
  2848.                         
  2849.                         <!-- Content -->
  2850.                         <tr>
  2851.                             <td style="padding: 30px;">
  2852.                                 <table width="100%" cellpadding="0" cellspacing="0">
  2853.                                     <tr>
  2854.                                         <td style="background-color: rgba(255, 102, 0, 0.1); color: #ff6600; padding: 10px 15px; border-radius: 20px; font-weight: bold; font-size: 14px; text-align: center; margin-bottom: 25px;">
  2855.                                             Nouveau message reçu
  2856.                                         </td>
  2857.                                     </tr>
  2858.                                     
  2859.                                     <tr>
  2860.                                         <td style="padding-bottom: 20px; color: #555; line-height: 1.6;">
  2861.                                             Bonjour,<br>
  2862.                                             Un visiteur a rempli le formulaire de contact de votre site de formation.
  2863.                                         </td>
  2864.                                     </tr>
  2865.                                     
  2866.                                     <!-- Informations -->
  2867.                                     <tr>
  2868.                                         <td>
  2869.                                             <table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 25px;">
  2870.                                                 <tr>
  2871.                                                     <td width="50%" style="padding: 15px; background-color: #f8f9ff; border-left: 4px solid #051a53; border-radius: 5px;">
  2872.                                                         <div style="font-size: 12px; color: #6c757d; font-weight: bold; text-transform: uppercase; margin-bottom: 5px;">
  2873.                                                             Nom complet
  2874.                                                         </div>
  2875.                                                         <div style="font-size: 16px; color: #051a53; font-weight: bold;">
  2876.                                                             '.$nom.'
  2877.                                                         </div>
  2878.                                                     </td>
  2879.                                                     <td width="10"></td>
  2880.                                                     <td width="50%" style="padding: 15px; background-color: #f8f9ff; border-left: 4px solid #ff6600; border-radius: 5px;">
  2881.                                                         <div style="font-size: 12px; color: #6c757d; font-weight: bold; text-transform: uppercase; margin-bottom: 5px;">
  2882.                                                             Adresse email
  2883.                                                         </div>
  2884.                                                         <div style="font-size: 16px; color: #ff6600; font-weight: bold;">
  2885.                                                             <a href="mailto:'.$mail.'" style="color: #ff6600; text-decoration: none;">'.$mail.'</a>
  2886.                                                         </div>
  2887.                                                     </td>
  2888.                                                 </tr>
  2889.                                                 <tr height="15"></tr>
  2890.                                                 <tr>
  2891.                                                     <td width="50%" style="padding: 15px; background-color: #f8f9ff; border-left: 4px solid #051a53; border-radius: 5px;">
  2892.                                                         <div style="font-size: 12px; color: #6c757d; font-weight: bold; text-transform: uppercase; margin-bottom: 5px;">
  2893.                                                             Objet du message
  2894.                                                         </div>
  2895.                                                         <div style="font-size: 16px; color: #051a53; font-weight: bold;">
  2896.                                                             '.$sujet.'
  2897.                                                         </div>
  2898.                                                     </td>
  2899.                                                     <td width="10"></td>
  2900.                                                     <td width="50%" style="padding: 15px; background-color: #f8f9ff; border-left: 4px solid #ff6600; border-radius: 5px;">
  2901.                                                         <div style="font-size: 12px; color: #6c757d; font-weight: bold; text-transform: uppercase; margin-bottom: 5px;">
  2902.                                                             Date d\'envoi
  2903.                                                         </div>
  2904.                                                         <div style="font-size: 16px; color: #051a53; font-weight: bold;">
  2905.                                                             '.$contact.'
  2906.                                                         </div>
  2907.                                                     </td>
  2908.                                                 </tr>
  2909.                                                 <tr height="15"></tr>
  2910.                                                 <tr>
  2911.                                                     <td width="100%" style="padding: 15px; background-color: #f8f9ff; border-left: 4px solid #051a53; border-radius: 5px;">
  2912.                                                         <div style="font-size: 12px; color: #6c757d; font-weight: bold; text-transform: uppercase; margin-bottom: 5px;">
  2913.                                                             Type de besoin
  2914.                                                         </div>
  2915.                                                         <div style="font-size: 16px; color: #051a53; font-weight: bold;">
  2916.                                                             '.$besoin.'
  2917.                                                         </div>
  2918.                                                     </td>
  2919.                                                 </tr>
  2920.                                             </table>
  2921.                                         </td>
  2922.                                     </tr>
  2923.                                     
  2924.                                     <!-- Message -->
  2925.                                     <tr>
  2926.                                         <td>
  2927.                                             <div style="color: #051a53; font-size: 18px; font-weight: bold; padding-bottom: 10px; border-bottom: 2px solid rgba(255, 102, 0, 0.3); margin-bottom: 15px;">
  2928.                                                 Message
  2929.                                             </div>
  2930.                                             <div style="background-color: #f8f9ff; padding: 20px; border-radius: 8px; border: 1px solid rgba(5, 26, 83, 0.1); white-space: pre-wrap; line-height: 1.6;">
  2931.                                                 '.$message.'
  2932.                                             </div>
  2933.                                         </td>
  2934.                                     </tr>
  2935.                                     
  2936.                                     <!-- Info note -->
  2937.                                     <tr>
  2938.                                         <td style="padding-top: 30px;">
  2939.                                             <div style="background-color: rgba(5, 26, 83, 0.05); padding: 15px; border-radius: 8px; font-size: 14px; color: #555; line-height: 1.5;">
  2940.                                                 <strong style="color: #ff6600;">Information :</strong> Cet email a été envoyé automatiquement depuis le formulaire de contact de votre plateforme de formation.
  2941.                                             </div>
  2942.                                         </td>
  2943.                                     </tr>
  2944.                                 </table>
  2945.                             </td>
  2946.                         </tr>
  2947.                         
  2948.                         <!-- Footer -->
  2949.                         <tr>
  2950.                             <td style="background-color: #f8f9ff; padding: 25px 30px; text-align: center; border-top: 1px solid rgba(5, 26, 83, 0.1);">
  2951.                                 <div style="color: #051a53; font-size: 20px; font-weight: bold; margin-bottom: 10px;">
  2952.                                     CIMEF-INTERNATIONAL
  2953.                                 </div>
  2954.                                 <div style="color: #6c757d; font-size: 14px; line-height: 1.5; margin-bottom: 20px;">
  2955.                                     La formation précède la compétitivité
  2956.                                 </div>
  2957.                                 
  2958.                                 <div style="color: #6c757d; font-size: 12px; padding-top: 20px; border-top: 1px solid rgba(5, 26, 83, 0.1);">
  2959.                                     © 2026 CIMEF-INTERNATIONAL. Tous droits réservés.<br>
  2960.                                     Cet email a été généré automatiquement.
  2961.                                 </div>
  2962.                             </td>
  2963.                         </tr>
  2964.                     </table>
  2965.                 </body>
  2966.             </html>';
  2967.             $email = (new Email())
  2968.             ->from('CIMEF International <contact@cimef-international.org>')
  2969.             ->to($destinataire)                 // destinataire principal
  2970.             ->replyTo($expediteur) 
  2971.             ->subject($suj)
  2972.            ->text(strip_tags($codehtml))
  2973.             ->html($codehtml);
  2974.             /*->html('<html><body>'.
  2975.             '<p>Bonjour vous avez un nouveau message de M/Mme <b>'.$nom.' </b><br>'.
  2976.             ''.$message.'<br>'.
  2977.             'Vous pouvez mecm\'écrire à l\'adresse suivante <b>'.$mail.'<br>'.
  2978.             '</p>'.
  2979.             '</body></html>');*/
  2980.             $mailer->send($email);
  2981.     
  2982.             $this->addFlash( 'success','Votre message a été envoyé');
  2983.             return $this->redirectToRoute('front.contact');
  2984.         }
  2985.         
  2986.         $newsletter = new Newsletters();
  2987.         $newsletterForm = $this->createForm(NewsletterFormType::class);
  2988.         $newsletterForm->handleRequest($request);
  2989.         if($newsletterForm->isSubmitted()){
  2990.             $mail = htmlspecialchars($contactForm->get('email')->getData());
  2991.             $token = $contactForm->get('recaptchaToken')->getData();
  2992.             
  2993.             $response = $this->client->request(
  2994.                 'POST',
  2995.                 'https://www.google.com/recaptcha/api/siteverify',
  2996.                 [
  2997.                     'body' => [
  2998.                         'secret' => $_ENV['RECAPTCHA_SECRET_KEY'],
  2999.                         'response' => $token,
  3000.                     ]
  3001.                 ]
  3002.             );
  3003.             $result = $response->toArray();
  3004.             if (!$result['success'] || !isset($result['score']) || $result['score'] < 0.5) {
  3005.                 $this->addFlash(
  3006.                     'warning',
  3007.                     'Vérification reCAPTCHA échouée.'
  3008.                 );
  3009.                 return $this->render('front/contact.html.twig',[
  3010.                     'contactForm' => $contactForm->createView(),
  3011.                     'mentions' => $mentions
  3012.                 ]);
  3013.             }              
  3014.             
  3015.             $newsletter->setEmail($mail);
  3016.             $entityManager->persist($newsletter);
  3017.             $entityManager->flush();
  3018.             $this->addFlash( 'success','Votre email a été enregistré');
  3019.             return $this->redirectToRoute('front.contact');
  3020.         }
  3021.         
  3022.         return $this->render('front/contact.html.twig',[
  3023.             'contactForm' => $contactForm->createView(),
  3024.             'newsletterForm' => $newsletterForm->createView(),
  3025.             'mentions' => $mentions
  3026.         ]);
  3027.     }
  3028.     
  3029.     #[Route('/formations/shanghai', name: 'front.inter.shanghai', methods:['GET'])]
  3030.     public function shanghai(
  3031.         Request $request,
  3032.         MentionsRepository $mentionRepository,
  3033.         ThemeshanghaiRepository $themeshanghaiRepository,
  3034.         ManagementsRepository $managementRepository,
  3035.         EntityManagerInterface $entityManager
  3036.     ): Response
  3037.     {
  3038.         $shanghai = $themeshanghaiRepository->findAll();
  3039.         //dd($shanghai);
  3040.         $manageLimit = $managementRepository->findBy([], ['id' => 'DESC'], 10 );
  3041.         
  3042.         $queryBuilder = $entityManager->createQueryBuilder();
  3043.         $queryBuilder
  3044.         ->select('for','th','thm','vil')
  3045.             ->from(Formations::class, 'for')
  3046.             ->innerJoin('for.theme', 'th')
  3047.             ->innerJoin('th.thematique', 'thm')
  3048.             ->innerJoin('for.ville', 'vil')
  3049.             ->Where('vil = :ville')
  3050.             ->setParameter('ville', 'SHANGHAI');
  3051.         $formationShanghai = $queryBuilder->getQuery()->getResult();
  3052.     
  3053.         $mentions = $mentionRepository->findAll();
  3054.         return $this->render('front/shanghai.html.twig',[
  3055.             'pagination' => $shanghai,
  3056.             'manageLimit' => $manageLimit,
  3057.             'mentions' => $mentions,
  3058.         ]);
  3059.     }
  3060.     
  3061.     #[Route('/formation/dernier-quartile', name: 'front.dernier.quartile', methods:['GET'])]
  3062.     public function quartile(
  3063.         Request $request,
  3064.         PaginatorInterface $paginator,
  3065.         PopupsRepository $popupRepository,
  3066.         MentionsRepository $mentionRepository,
  3067.         ManagementsRepository $managementRepository,
  3068.         EntityManagerInterface $entityManager
  3069.     ): Response
  3070.     {
  3071.         $popup = $popupRepository->findAll();
  3072.         $queryBuilder = $entityManager->createQueryBuilder();
  3073.         $queryBuilder
  3074.         ->select('pop')
  3075.         ->from(Popups::class, 'pop')
  3076.         ->where('pop.statut = :statut')
  3077.         ->setParameter('statut', 1)
  3078.         ->orderBy('pop.createdat', 'DESC');
  3079.         
  3080.         $pagination = $paginator->paginate(
  3081.             $queryBuilder,
  3082.             $request->query->getInt('page', 1),
  3083.             12
  3084.         ); 
  3085.         // dd($popup);
  3086.         $popupLimit = $popupRepository->findBy([], ['id' => 'DESC'], 10 );
  3087.         
  3088.         $queryBuilder = $entityManager->createQueryBuilder();
  3089.         $queryBuilder
  3090.         ->select('for','th','thm','vil')
  3091.             ->from(Formations::class, 'for')
  3092.             ->innerJoin('for.theme', 'th')
  3093.             ->innerJoin('th.thematique', 'thm')
  3094.             ->innerJoin('for.ville', 'vil')
  3095.             ->Where('vil = :ville')
  3096.             ->setParameter('ville', 'SHANGHAI');
  3097.         $formationShanghai = $queryBuilder->getQuery()->getResult();
  3098.     
  3099.         $mentions = $mentionRepository->findAll();
  3100.         return $this->render('front/popup-formation.html.twig',[
  3101.             'pagination' => $pagination,
  3102.             'popupLimit' => $popupLimit,
  3103.             'mentions' => $mentions,
  3104.         ]);
  3105.     }
  3106.     
  3107.     #[Route('/notre-equipe', name: 'front.inter.team', methods:['GET'])]
  3108.     public function team(
  3109.         PartenairesRepository $partenaireRepository,
  3110.         FormationsRepository $formationRepository,
  3111.         AboutsRepository $aboutRepository, 
  3112.         ValeursRepository $valeurRepository,
  3113.         AvisRepository $avisRepository,
  3114.         MentionsRepository $mentionRepository,
  3115.         EntityManagerInterface $entityManager
  3116.     ): Response
  3117.     {
  3118.         $avis = $avisRepository->findAll();
  3119.         $All_partenaire = $partenaireRepository->findAll();
  3120.         $All_about = $aboutRepository->findAll();
  3121.         $All_valeur = $valeurRepository->findAll();
  3122.         $mentions = $mentionRepository->findAll();
  3123.         return $this->render('front/equipe.html.twig',[
  3124.             'partenaires' => $All_partenaire,
  3125.             'valeur' => $All_valeur,
  3126.             'mentions' => $mentions,
  3127.             'about' => $All_about,
  3128.             'avis' => $avis,
  3129.         ]);
  3130.     }
  3131.     
  3132. }