src/Controller/Client/ClientController.php line 73

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Client;
  3. use App\Entity\AccountingFirm;
  4. use App\Entity\ContactCreationSociete;
  5. use App\Entity\ContactInvestissementImmo;
  6. use App\Entity\Page;
  7. use App\Entity\Prescriber;
  8. use App\Entity\RedirectionClient;
  9. use App\Entity\SeoPage;
  10. use App\Repository\RedirectionClientRepository;
  11. use App\Services\MoneticoService;
  12. use App\Services\SendContactEmail;
  13. use App\Services\WebSite;
  14. use App\Entity\Actualiters;
  15. use App\Entity\TypeSeoPage;
  16. use App\Entity\WebsiteNews;
  17. use App\Entity\Announcement;
  18. use App\Entity\ApplyRequest;
  19. use App\Entity\SeoPageClient;
  20. use App\Entity\Actualitecabinet;
  21. use App\Entity\ModuleVideo;
  22. use App\Entity\Qrcode;
  23. use Symfony\Component\Mime\Email;
  24. use App\Services\QueriesV2Manager;
  25. use App\Form\AnnouncementApplyType;
  26. use App\Repository\EbookRepository;
  27. use App\Services\SimulateurManager;
  28. use App\Repository\UsefulLinkRepository;
  29. use App\Repository\ActualitersRepository;
  30. use App\Repository\WebsiteNewsRepository;
  31. use App\Repository\AnnouncementRepository;
  32. use App\Repository\AccountingFirmRepository;
  33. use Symfony\Component\Filesystem\Filesystem;
  34. use Symfony\Component\HttpFoundation\Request;
  35. use App\Repository\ActualitecabinetRepository;
  36. use App\Repository\ModuleVideoRepository;
  37. use Doctrine\ORM\EntityManagerInterface;
  38. use Symfony\Component\HttpFoundation\Response;
  39. use Symfony\Component\Routing\Annotation\Route;
  40. use Symfony\Component\HttpFoundation\JsonResponse;
  41. use Symfony\Component\HttpFoundation\RedirectResponse;
  42. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  43. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  44. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  45. use Symfony\Component\HttpFoundation\File\Exception\FileException;
  46. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  47. use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
  48. /**
  49.  * Class ClientController
  50.  * @package App\Controller\Client
  51.  *
  52.  * TODO :
  53.  *  - ameliorer la partie outil -> texte en dyn
  54.  */
  55. class ClientController extends AbstractClientController
  56. {
  57.     #[Route(name'client')]
  58.     #[Route(path'/preview/{host}'name'previewclient')]
  59.     public function index(): Response
  60.     {
  61.         $entityManager $this->getDoctrine()->getManager();
  62.         // $annonceUne = $entityManager->getRepository(Announcement::class)->findMyAnnouncementMain($this->accountingFirm);
  63.         $annonceUne = [];
  64.         if ($this->accountingFirm) {
  65.             $annonceUne $entityManager->getRepository(Announcement::class)->findMyAnnouncementMain($this->accountingFirm);
  66.         }
  67.         return $this->render('index.html.twig', [
  68.             'controller_name' => 'ClientController',
  69.             'une_annonce' => count($annonceUne) > $annonceUne[0] : null,
  70.         ]);
  71.     }
  72.     #[Route(path'/widget-dates'name'widget_dates')]
  73.     public function dates(QueriesV2Manager $qm)
  74.     {
  75.         $tabData $qm->getDates();
  76.         $tabDates = [];
  77.         foreach ($tabData as $lignes) {
  78.             foreach ($lignes as $ligne) {
  79.                 $key array_search($ligne['date'], array_column($tabDates'date'));
  80.                 if ($key === false) { // cas date jamais ajoutée
  81.                     $tabDates[] = ['date' => $ligne['date'], 'lien' => 'calendrier-fiscal.php?id=' $ligne['id']];
  82.                 } else { // cas date déjà ajoutée, donc plusieurs articles à la même date
  83.                     $tabDates[$key] = ['date' => $ligne['date'], 'lien' => 'actualites-calendrier-fiscal.php?date=' $ligne['date']];
  84.                 }
  85.             }
  86.         }
  87.         return $this->json($tabDates);
  88.     }
  89.     #[Route(path'/sitemap.xml'defaults: ['_format' => 'xml'], name'client_sitemap')]
  90.     #[Route(path'/preview/{host}/sitemap.xml'defaults: ['_format' => 'xml'], name'previewclient_sitemap')]
  91.     public function sitemap(QueriesV2Manager $qm): Response
  92.     {
  93.         $isOnePage false;
  94.         // vars bases
  95.         $modules $this->accountingFirm->getParameters()->getModules();
  96.         $pages $this->accountingFirm->getParameters()->getPages();
  97.         foreach ($modules as $name => $show) {
  98.             if ($show && $name == "OnePage") {
  99.                 $isOnePage true;
  100.             }
  101.         }
  102.         $urls = array(
  103.             'home' => '',
  104.             'primary' => array(),
  105.             'secondary' => array()
  106.         );
  107.         // url de base
  108.         $urls['home'] = $this->sitemapUrl('client');
  109.         if (!$isOnePage)
  110.             array_push($urls['primary'], $this->sitemapUrl('client_contact'));
  111.         // array_push($urls['secondary'], $this->sitemapUrl('client_legal_notice'));
  112.         // array_push($urls['secondary'], $this->sitemapUrl('client_privacy_policy'));
  113.         // url des modules si activés
  114.         foreach ($modules as $name => $show) {
  115.             if ($show) {
  116.                 switch ($name) {
  117.                     case 'Actualites':
  118.                         if (!$isOnePage)
  119.                             array_push($urls['primary'], $this->sitemapUrl('client_website_news_index'));
  120.                         if ($list $this->accountingFirm->getWebsiteNews()) {
  121.                             foreach ($list as $key => $value) {
  122.                                 array_push($urls['secondary'], $this->sitemapUrl('client_website_news_show', array('slug' => $value->getSlug())));
  123.                             }
  124.                         }
  125.                         break;
  126.                     case 'Annonces':
  127.                         if (!$isOnePage)
  128.                             array_push($urls['primary'], $this->sitemapUrl('client_announcement_index'));
  129.                         if ($list $this->accountingFirm->getAnnouncements()) {
  130.                             foreach ($list as $key => $value) {
  131.                                 array_push($urls['secondary'], $this->sitemapUrl('client_announcement_show', array('slug' => $value->getSlug())));
  132.                             }
  133.                         }
  134.                         break;
  135.                     case 'Actualite_du_mois':
  136.                         if (!$isOnePage) {
  137.                             // urls module widget ??
  138.                             array_push($urls['primary'], $this->sitemapUrl('client_widget_news_index'));
  139.                             array_push($urls['primary'], $this->sitemapUrl('client_widget_recherche'));
  140.                         }
  141.                         if ($list $qm->getActualites()) {
  142.                             foreach ($list as $key => $value) {
  143.                                 $id $value['id'] . "-";
  144.                                 $slug explode($id$value['new_slug']);
  145.                                 array_push($urls['secondary'], $this->sitemapUrl('client_widget_news_fisc_show', array('id' => $value['id'])));
  146.                                 array_push($urls['secondary'], $this->sitemapUrl('client_widget_news_juri_show', array('id' => $value['id'], 'slug' => $slug[1])));
  147.                                 array_push($urls['secondary'], $this->sitemapUrl('client_widget_bien_etre_show', array('id' => $value['id'], 'slug' => $slug[1])));
  148.                                 array_push($urls['secondary'], $this->sitemapUrl('client_widget_transformation_digitale_show', array('id' => $value['id'], 'slug' => $slug[1])));
  149.                             }
  150.                         }
  151.                         $dates $qm->getDates();
  152.                         foreach ($dates as $key1 => $val) {
  153.                             foreach ($val as $key2 => $date) {
  154.                                 $tab explode("-"$date['date']);
  155.                                 $month $tab[1];
  156.                                 $date $tab[2] . "-" $tab[1] . "-" $tab[0];
  157.                                 array_push($urls['secondary'], $this->sitemapUrl('client_widget_news_index_past', array('month' => $month)));
  158.                                 array_push($urls['secondary'], $this->sitemapUrl('client_widget_news_fisc_list_show', array('date' => $date)));
  159.                             }
  160.                         }
  161.                         break;
  162.                     case 'Tools':
  163.                         if (!$isOnePage) {
  164.                             array_push($urls['primary'], $this->sitemapUrl('outil_achat'));
  165.                             array_push($urls['primary'], $this->sitemapUrl('outil_analyse_cout_revient'));
  166.                             array_push($urls['primary'], $this->sitemapUrl('outil_banque'));
  167.                             array_push($urls['primary'], $this->sitemapUrl('outil_caisse'));
  168.                             array_push($urls['primary'], $this->sitemapUrl('outil_creation'));
  169.                             array_push($urls['primary'], $this->sitemapUrl('outil_entretien_bilan'));
  170.                             array_push($urls['primary'], $this->sitemapUrl('outil_evaluation_entreprise'));
  171.                             array_push($urls['primary'], $this->sitemapUrl('outil_facturation'));
  172.                             array_push($urls['primary'], $this->sitemapUrl('outil_financement'));
  173.                             array_push($urls['primary'], $this->sitemapUrl('outil_note_de_frais'));
  174.                             array_push($urls['primary'], $this->sitemapUrl('outil_optimisation_financement_vehicule'));
  175.                             array_push($urls['primary'], $this->sitemapUrl('outil_optimisation_investissement_immo'));
  176.                             array_push($urls['primary'], $this->sitemapUrl('outil_suivi_gestion'));
  177.                             array_push($urls['primary'], $this->sitemapUrl('outil_index'));
  178.                         }
  179.                         break;
  180.                     case 'Livre_blanc':
  181.                         if (!$isOnePage) {
  182.                             array_push($urls['primary'], $this->sitemapUrl('client_ebook_index'));
  183.                         }
  184.                         break;
  185.                     default:
  186.                         // NOPE
  187.                         break;
  188.                 }
  189.             }
  190.         }
  191.         if (!$isOnePage) {
  192.             // url des pages customs
  193.             if ($pages $this->accountingFirm->getParameters()->getPages()) {
  194.                 foreach ($pages as $key => $value) {
  195.                     array_push($urls['primary'], $this->sitemapUrl('client_custom_page', array('uri' => $value->getUri())));
  196.                 }
  197.             }
  198.         }
  199.         $this->templateBase '/';
  200.         return $this->render('sitemap.html.twig', [
  201.             'urls' => $urls,
  202.             'lastmod' => date("Y-m-d"),
  203.             'changefreq' => 'monthly'
  204.         ]);
  205.     }
  206.     private function sitemapUrl($path$param null)
  207.     {
  208.         try {
  209.             if (!is_null($param)) {
  210.                 return 'https://www.' $this->accountingFirm->getHost() . $this->generateUrl($path$param);
  211.             } else {
  212.                 return 'https://www.' $this->accountingFirm->getHost() . $this->generateUrl($path);
  213.             }
  214.         } catch (\Throwable $th) {
  215.             return null;
  216.         }
  217.     }
  218.     #[Route(path'/robots.txt'defaults: ['_format' => 'txt'], name'client_robots')]
  219.     #[Route(path'/preview/{host}/robots.txt'defaults: ['_format' => 'txt'], name'previewclient_robots')]
  220.     public function robots(): Response
  221.     {
  222.         $this->templateBase '/';
  223.         return $this->render('robots.html.twig', [
  224.             'sitemap' => 'https://www.' $this->accountingFirm->getHost() . $this->generateUrl('client_sitemap')
  225.         ]);
  226.     }
  227.     #[Route(path'/contact'name'client_contact')]
  228.     #[Route(path'/preview/{host}/contact'name'previewclient_contact')]
  229.     public function contact(Request $request)
  230.     {
  231.         $entityManager $this->getDoctrine()->getManager();
  232.         $seopageclient = new SeoPageClient();
  233.         $parameters $this->accountingFirm->getParameters();
  234.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'name' => 'Contact']);
  235.         return $this->render('/contact.html.twig', [
  236.             'cabinet' => $this->accountingFirm,
  237.             'seopage' => $seopage,
  238.         ]);
  239.     }
  240.     #[Route(path'/contactbis'name'client_contactbis')]
  241.     #[Route(path'/preview/{host}/contactbis'name'previewclient_contactbis')]
  242.     public function contactCustom(Request $request)
  243.     {
  244.         $entityManager $this->getDoctrine()->getManager();
  245.         $seopageclient = new SeoPageClient();
  246.         $parameters $this->accountingFirm->getParameters();
  247.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'name' => 'Contact']);
  248.         return $this->render('/contact.html.twig', [
  249.             'cabinet' => $this->accountingFirm,
  250.             'seopage' => $seopage,
  251.         ]);
  252.     }
  253.     #[Route(path'/contactProfession'name'client_contactprofession')]
  254.     #[Route(path'/preview/{host}/contactprofession'name'previewclient_contactprofession')]
  255.     public function contactProfession(Request $request)
  256.     {
  257.         $entityManager $this->getDoctrine()->getManager();
  258.         $seopageclient = new SeoPageClient();
  259.         $parameters $this->accountingFirm->getParameters();
  260.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'name' => 'Contact']);
  261.         return $this->render('/contact.html.twig', [
  262.             'cabinet' => $this->accountingFirm,
  263.             'seopage' => $seopage,
  264.         ]);
  265.     }
  266.     #[Route(path'/recrutement'name'client_announcement_index')]
  267.     #[Route(path'/preview/{host}/recrutement'name'previewclient_announcement_index')]
  268.     public function announcementIndex(EntityManagerInterface $entityManager): Response
  269.     {
  270.         $seopageclient = new SeoPageClient();
  271.         $parameters $this->accountingFirm->getParameters();
  272.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 10]);
  273.         $announcementRepository $entityManager->getRepository(Announcement::class);
  274.         // dd($announcementRepository->findAll(), $this->accountingFirm->getId());
  275.         return $this->render('announcement/index.html.twig', [
  276.             // 'announcements' => $announcementRepository->findBy(['accountingFirm' => $this->accountingFirm->getId()]),
  277.             'announcements' => $announcementRepository->findMyAnnouncementsOffer($this->accountingFirm),
  278.             'announcementSpontanee' => $announcementRepository->findMyAnnouncementsSpontanee($this->accountingFirm),
  279.             'seopage' => $seopage
  280.         ]);
  281.     }
  282.     #[Route(path'/recrutement/{slug}'name'client_announcement_show')]
  283.     #[Route(path'/preview/{host}/recrutement/{slug}'name'previewclient_announcement_show')]
  284.     public function annoucementShow(string $slugEntityManagerInterface $entityManager): Response
  285.     {
  286.         //$this->applyForm_send = false;
  287.         $announcementRepository $entityManager->getRepository(Announcement::class);
  288.         $announcement $announcementRepository->findOneBy(['slug' => $slug]);
  289.         $request $this->get('request_stack')->getCurrentRequest();
  290.         $host $request->get('host');
  291.         //$host = 'cabinet-za.de';
  292.         $form_send_recrutement $this->form_send_recrutement;
  293.         $form_recrutement $this->createForm(AnnouncementApplyType::class);
  294.         if (($host && $announcement->getAccountingFirm()->getHost() !== $host)
  295.             || ($announcement->getAccountingFirm() !== $this->accountingFirm)
  296.         ) {
  297.             throw new NotFoundHttpException();
  298.         }
  299.         $entityManager $this->getDoctrine()->getManager();
  300.         $seopageclient = new SeoPageClient();
  301.         $parameters $this->accountingFirm->getParameters();
  302.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 32]);
  303.         // $formApply = $this->createForm(AnnouncementApplyType::class, null,['cabinet'=>$this->accountingFirm]);
  304.         // $formApply->handleRequest($this->request->getCurrentRequest());
  305.         // $this->formapplyview = $formApply->createView();
  306.         // $filesystem = new Filesystem();
  307.         // if ($formApply->isSubmitted() && $formApply->isValid()) {
  308.         //     $entityManager = $this->getDoctrine()->getManager();
  309.         //     $configEmail = $this->accountingFirm->getParameters()->getWebMail();
  310.         //     $contact=new ApplyRequest();
  311.         //     $contact->setAnnonce($announcement);
  312.         //     //upload cv
  313.         //     $cv = $formApply['tmpCV']->getData();
  314.         //     if($cv)
  315.         //     {
  316.         //         $directory='../'.$contact->getUploadPath();
  317.         //         try {
  318.         //             if(!$filesystem->exists($directory))
  319.         //                 {
  320.         //                     $filesystem->mkdir($directory);
  321.         //                 }
  322.         //             $originalFilename = pathinfo($cv->getClientOriginalName(), PATHINFO_FILENAME);
  323.         //                 $fileName = $originalFilename.'-'.uniqid().'.'.$cv->guessExtension();
  324.         //             $cv->move($directory, $fileName);
  325.         //                 $contact->setCv($fileName);
  326.         //         } catch (FileException $e) {
  327.         //         }
  328.         //     }
  329.         //     //upload lettre de motivation
  330.         //     $lettre = $formApply['tmpLettre']->getData();
  331.         //     if($lettre)
  332.         //     {
  333.         //         $directory='../'.$contact->getUploadPath();
  334.         //         try {
  335.         //         if(!$filesystem->exists($directory))
  336.         //             {
  337.         //                 $filesystem->mkdir($directory);
  338.         //             }
  339.         //         $originalFilename = pathinfo($lettre->getClientOriginalName(), PATHINFO_FILENAME);
  340.         //             $fileName = $originalFilename.'-'.uniqid().'.'.$lettre->guessExtension();
  341.         //         $lettre->move($directory, $fileName);
  342.         //             $contact->setLettre($fileName);
  343.         //         } catch (FileException $e) {
  344.         //         }
  345.         //     }
  346.         //     if(null != $configEmail) {
  347.         //         $mailbody = '
  348.         //         <p>Bonjour,</p>
  349.         //         <p>Vous avez reçus une réponses a une annonce de recrutement depuis votre site web</p>
  350.         //         <br>
  351.         //         <h1>Annonce :</h1>
  352.         //         <br />
  353.         //         <br />
  354.         //         <p>Nom : '.$formApply['nom']->getData().'</p>
  355.         //         <p>Téléphone : '.$formApply['tel']->getData().'</p>
  356.         //         <p>Email : '.$formApply['email']->getData().'</p>
  357.         //         <p>Message :</p>
  358.         //         <br/>
  359.         //         <p> Vous pouvez consultez ce message directement depuis votre <a href="https://prod.lagence.expert/demanderecrutement/" target=\"_blank\">Espace administration</a></p>
  360.         //         ';
  361.         //         $email = (new Email())
  362.         //         ->from($configEmail)
  363.         //         ->to($configEmail)
  364.         //         //->cc('cc@example.com')
  365.         //
  366.         //         //->replyTo('fabien@example.com')
  367.         //         //->priority(Email::PRIORITY_HIGH)
  368.         //         ->subject('Réponses a une annonce de recrutement')
  369.         //         ->html($mailbody);
  370.         //         $this->mailer->send($email);
  371.         //         $this->formsend = true;
  372.         //         $contact->setNom($formApply['nom']->getData());
  373.         //         $contact->setEmail($formApply['email']->getData());
  374.         //         $contact->setTel($formApply['tel']->getData());
  375.         //         $contact->setMessage($formApply['message']->getData());
  376.         //         $contact->setRgpd($formApply['rgpd']->getData());
  377.         //         $contact->setDate(new \DateTime('now'));
  378.         //         $entityManager->persist($contact);
  379.         //         $entityManager->flush();
  380.         //         $mailbody_confirm = '
  381.         //         <p>Bonjour,</p>
  382.         //         <p>Votre candidature a été envoyée avec succès. Nous allons vous recontacter dans les plus brefs délais. </p>
  383.         //         <p>Merci de votre confiance </p>
  384.         //         ';
  385.         //         $email_confirm = (new Email())
  386.         //         ->from($configEmail)
  387.         //         ->to($formApply['email']->getData())
  388.         //         //->cc('cc@example.com')
  389.         //
  390.         //         //->replyTo('fabien@example.com')
  391.         //         //->priority(Email::PRIORITY_HIGH)
  392.         //         ->subject('Confirmation d\'envoi de votre message')
  393.         //         ->html($mailbody_confirm);
  394.         //         $this->mailer->send($email_confirm);
  395.         //         $this->applyForm_send = true;
  396.         //     }
  397.         // }
  398.         return $this->render('announcement/show.html.twig', [
  399.             'announcement' => $announcement,
  400.             // 'applyForm' => $this->formapplyview,
  401.             // 'applyForm_send' => $this->applyForm_send,
  402.             'seopage' => $seopage,
  403.             'form_send_recrutement' => $form_send_recrutement,
  404.             'form_recrutement' => $form_recrutement,
  405.         ]);
  406.     }
  407.     #[Route(path'/livre-blanc'name'client_ebook_index')]
  408.     #[Route(path'/preview/{host}/livre-blanc'name'previewclient_ebook_index')]
  409.     #[IsGranted('WEBSITE_EBOOK'statusCode404)]
  410.     public function ebookIndex(EbookRepository $ebookRepository): Response
  411.     {
  412.         $entityManager $this->getDoctrine()->getManager();
  413.         $seopageclient = new SeoPageClient();
  414.         $parameters $this->accountingFirm->getParameters();
  415.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 9]);
  416.         return $this->render('ebook/index.html.twig', [
  417.             'ebooks' => $ebookRepository->findMyEbooks($this->accountingFirm),
  418.             'seopage' => $seopage
  419.         ]);
  420.     }
  421.     #[Route(path'/partenaires'name'client_useful_link_index')]
  422.     #[Route(path'/preview/{host}/partenaires'name'previewclient_useful_link_index')]
  423.     #[IsGranted('WEBSITE_USEFUL_LINK'statusCode404)]
  424.     public function UsefulLinkIndex(UsefulLinkRepository $usefulLinkRepository): Response
  425.     {
  426.         $entityManager $this->getDoctrine()->getManager();
  427.         $seopageclient = new SeoPageClient();
  428.         $parameters $this->accountingFirm->getParameters();
  429.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 8]);
  430.         $this->templateBase '/';
  431.         return $this->render('useful_link/website_index.html.twig', [
  432.             'useful_links' => $usefulLinkRepository->findUsefulLinks($this->accountingFirm),
  433.             'seopage' => $seopage
  434.         ]);
  435.     }
  436.     #[Route(path'/news'name'client_website_news_index')]
  437.     #[Route(path'/preview/{host}/news'name'previewclient_website_news_index')]
  438.     #[IsGranted('WEBSITE_NEWS'statusCode404)]
  439.     public function websiteNewsIndex(WebsiteNewsRepository $websiteNewsRepository): Response
  440.     {
  441.         $entityManager $this->getDoctrine()->getManager();
  442.         $seopageclient = new SeoPageClient();
  443.         $parameters $this->accountingFirm->getParameters();
  444.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 31]);
  445.         return $this->render('website_news/index.html.twig', [
  446.             'website_news' => $websiteNewsRepository->findMyWebsiteNews($this->accountingFirm),
  447.             'seopage' => $seopage
  448.         ]);
  449.     }
  450.     #[Route(path'/news/{slug}'name'client_website_news_show')]
  451.     #[Route(path'/preview/{host}/news/{slug}'name'previewclient_website_news_show')]
  452.     #[IsGranted('WEBSITE_NEWS'statusCode404)]
  453.     public function websiteNewsShow(WebsiteNews $websiteNews): Response
  454.     {
  455.         $request $this->get('request_stack')->getCurrentRequest();
  456.         $host $request->get('host');
  457.         // $host = 'cabinet-za.de';
  458.         if (($host && $websiteNews->getAccountingFirm()->getHost() !== $host)
  459.             || ($websiteNews->getAccountingFirm() !== $this->accountingFirm)
  460.         ) {
  461.             throw new NotFoundHttpException();
  462.         }
  463.         $entityManager $this->getDoctrine()->getManager();
  464.         $seopageclient = new SeoPageClient();
  465.         $parameters $this->accountingFirm->getParameters();
  466.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 32]);
  467.         return $this->render('website_news/show.html.twig', [
  468.             'website_news' => $websiteNews,
  469.             'seopage' => $seopage
  470.         ]);
  471.     }
  472.     #[Route(path'/actualite'name'client_actualite_index')]
  473.     #[Route(path'/preview/{host}/actualite'name'previewclient_actualite_index')]
  474.     #[IsGranted('WEBSITE_NEWS'statusCode404)]
  475.     public function actualitecabinetIndex(ActualitecabinetRepository $actualitecabinetRepository): Response
  476.     {
  477.         $entityManager $this->getDoctrine()->getManager();
  478.         $seopageclient = new SeoPageClient();
  479.         $parameters $this->accountingFirm->getParameters();
  480.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 31]);
  481.         return $this->render('actualite_cabinet/index.html.twig', [
  482.             'actualites' => $actualitecabinetRepository->findMyActualites($this->accountingFirm),
  483.             'seopage' => $seopage
  484.         ]);
  485.     }
  486.     #[Route(path'/actualite/{slug}'name'client_actualite_show')]
  487.     #[Route(path'/preview/{host}/actualite/{slug}'name'previewclient_actualite_show')]
  488.     #[IsGranted('WEBSITE_NEWS'statusCode404)]
  489.     public function actualitecabinetShow(Actualitecabinet $actualitecabinet): Response
  490.     {
  491.         $request $this->get('request_stack')->getCurrentRequest();
  492.         $host $request->get('host');
  493.         // $host = 'cabinet-za.de';
  494.         if (($host && $actualitecabinet->getAccountingFirm()->getHost() !== $host)
  495.             || ($actualitecabinet->getAccountingFirm() !== $this->accountingFirm)
  496.         ) {
  497.             throw new NotFoundHttpException();
  498.         }
  499.         $entityManager $this->getDoctrine()->getManager();
  500.         $seopageclient = new SeoPageClient();
  501.         $parameters $this->accountingFirm->getParameters();
  502.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 32]);
  503.         return $this->render('actualite_cabinet/show.html.twig', [
  504.             'actualite' => $actualitecabinet,
  505.             'seopage' => $seopage
  506.         ]);
  507.     }
  508.     #[Route(path'/actu-rs'name'client_website_actu_rs_index')]
  509.     #[Route(path'/preview/{host}/actu-rs'name'previewclient_website_actu_rs_index')]
  510.     #[IsGranted('WEBSITE_ACTU_RS'statusCode404)]
  511.     public function websiteActuRsIndex(ActualitersRepository $acutalitersRepository): Response
  512.     {
  513.         $entityManager $this->getDoctrine()->getManager();
  514.         $seopageclient = new SeoPageClient();
  515.         $parameters $this->accountingFirm->getParameters();
  516.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 35]);
  517.         return $this->render('actu_rs/index.html.twig', [
  518.             'actualiters' => $acutalitersRepository->findMyActuRs($this->accountingFirm),
  519.             'seopage' => $seopage
  520.         ]);
  521.     }
  522.     #[Route(path'/actu-rs/{id}-{slugtxt}'name'client_website_actu_rs_show')]
  523.     #[Route(path'/preview/{host}/actu-rs/{id}-{slugtxt}'name'previewclient_website_actu_rs_show')]
  524.     #[IsGranted('WEBSITE_ACTU_RS'statusCode404)]
  525.     public function websiteActuRsShow(Actualiters $actualiters): Response
  526.     {
  527.         $request $this->get('request_stack')->getCurrentRequest();
  528.         $host $request->get('host');
  529.         // $host = 'cabinet-za.de';
  530.         if (($host && $actualiters->getAccountingFirm()->getHost() !== $host)
  531.             || ($actualiters->getAccountingFirm() !== $this->accountingFirm)
  532.         ) {
  533.             throw new NotFoundHttpException();
  534.         }
  535.         $entityManager $this->getDoctrine()->getManager();
  536.         $seopageclient = new SeoPageClient();
  537.         $parameters $this->accountingFirm->getParameters();
  538.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 36]);
  539.         return $this->render('actu_rs/show.html.twig', [
  540.             'actualiters' => $actualiters,
  541.             'seopage' => $seopage
  542.         ]);
  543.     }
  544.     #[Route(path'/mentions-legales'name'client_legal_notice')]
  545.     #[Route(path'/preview/{host}/mentions-legales'name'previewclient_legal_notice')]
  546.     public function legalNotice(): Response
  547.     {
  548.         $entityManager $this->getDoctrine()->getManager();
  549.         $parameters $this->accountingFirm->getParameters();
  550.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 4]);
  551.         if ($seopage != null) {
  552.             $pageDescription $seopage->getPageDescripion();
  553.             if ($seopage->getPageDescripion() == null) {
  554.                 $pageDescription $seopage->getSeopageId()->getPageDescripion();
  555.             }
  556.             $pageDescription str_replace("#name#"$this->accountingFirm->getName(), $pageDescription);
  557.             $pageDescription str_replace("#zipCode#"$this->accountingFirm->getZipCode(), $pageDescription);
  558.             $pageDescription str_replace("#address#"$this->accountingFirm->getAddress(), $pageDescription);
  559.             $pageDescription str_replace("#city#"$this->accountingFirm->getCity(), $pageDescription);
  560.             $pageDescription str_replace("#url#"$this->accountingFirm->getUrl(), $pageDescription);
  561.             $pageDescription str_replace("#phone#"$this->accountingFirm->getPhone(), $pageDescription);
  562.             $seopage->setPageDescripion($pageDescription);
  563.         }
  564.         return $this->render('mentions_legales.html.twig', [
  565.             'seopage' => $seopage
  566.         ]);
  567.     }
  568.     #[Route(path'/politique-confidentialite'name'client_privacy_policy')]
  569.     #[Route(path'/preview/{host}/politique-confidentialite'name'previewclient_privacy_policy')]
  570.     public function privacyPolicy(): Response
  571.     {
  572.         $entityManager $this->getDoctrine()->getManager();
  573.         $parameters $this->accountingFirm->getParameters();
  574.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 3]);
  575.         if ($seopage != null) {
  576.             $pageDescription $seopage->getPageDescripion();
  577.             if ($seopage->getPageDescripion() == null) {
  578.                 $pageDescription $seopage->getSeopageId()->getPageDescripion();
  579.             }
  580.             $pageDescription str_replace("#name#"$this->accountingFirm->getName(), $pageDescription);
  581.             $pageDescription str_replace("#zipCode#"$this->accountingFirm->getZipCode(), $pageDescription);
  582.             $pageDescription str_replace("#address#"$this->accountingFirm->getAddress(), $pageDescription);
  583.             $pageDescription str_replace("#city#"$this->accountingFirm->getCity(), $pageDescription);
  584.             $pageDescription str_replace("#url#"$this->accountingFirm->getUrl(), $pageDescription);
  585.             $pageDescription str_replace("#phone#"$this->accountingFirm->getPhone(), $pageDescription);
  586.             $seopage->setPageDescripion($pageDescription);
  587.         }
  588.         return $this->render('politique_confidentialite.html.twig', [
  589.             'seopage' => $seopage
  590.         ]);
  591.     }
  592.     #[Route(path'/outil-achat'name'outil_achat')]
  593.     #[Route(path'/preview/{host}/outil-achat'name'previewoutil_achat')]
  594.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  595.     public function OutilAchat(): Response
  596.     {
  597.         $entityManager $this->getDoctrine()->getManager();
  598.         $seopageclient = new SeoPageClient();
  599.         $parameters $this->accountingFirm->getParameters();
  600.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 6]);
  601.         return $this->render('tools/tools_achat.html.twig', ['seopage' => $seopage]);
  602.     }
  603.     #[Route(path'/outil-analyse-cout-revient'name'outil_analyse_cout_revient')]
  604.     #[Route(path'/preview/{host}/outil-analyse-cout-revient'name'previewoutil_analyse_cout_revient')]
  605.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  606.     public function OutilAnalyseCoutRevient(): Response
  607.     {
  608.         $entityManager $this->getDoctrine()->getManager();
  609.         $seopageclient = new SeoPageClient();
  610.         $parameters $this->accountingFirm->getParameters();
  611.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 21]);
  612.         return $this->render('tools/tools_analyse_cout_revient.html.twig', ['seopage' => $seopage]);
  613.     }
  614.     #[Route(path'/outil-banque'name'outil_banque')]
  615.     #[Route(path'/preview/{host}/outil-banque'name'previewoutil_banque')]
  616.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  617.     public function OutilBanque(): Response
  618.     {
  619.         $entityManager $this->getDoctrine()->getManager();
  620.         $seopageclient = new SeoPageClient();
  621.         $parameters $this->accountingFirm->getParameters();
  622.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 7]);
  623.         return $this->render('tools/tools_banque.html.twig', ['seopage' => $seopage]);
  624.     }
  625.     #[Route(path'/outil-caisse'name'outil_caisse')]
  626.     #[Route(path'/preview/{host}/outil-caisse'name'previewoutil_caisse')]
  627.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  628.     public function OutilCaisse(): Response
  629.     {
  630.         $entityManager $this->getDoctrine()->getManager();
  631.         $seopageclient = new SeoPageClient();
  632.         $parameters $this->accountingFirm->getParameters();
  633.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 19]);
  634.         return $this->render('tools/tools_caisse.html.twig', ['seopage' => $seopage]);
  635.     }
  636.     #[Route(path'/outil-creation'name'outil_creation')]
  637.     #[Route(path'/preview/{host}/outil-creation'name'previewoutil_creation')]
  638.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  639.     public function OutilCreation(): Response
  640.     {
  641.         $entityManager $this->getDoctrine()->getManager();
  642.         $seopageclient = new SeoPageClient();
  643.         $parameters $this->accountingFirm->getParameters();
  644.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 20]);
  645.         return $this->render('tools/tools_creation.html.twig', ['seopage' => $seopage]);
  646.     }
  647.     #[Route(path'/outil-entretien-bilan'name'outil_entretien_bilan')]
  648.     #[Route(path'/preview/{host}/outil-entretien-bilan'name'previewoutil_entretien_bilan')]
  649.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  650.     public function OutilEntretienBilan(): Response
  651.     {
  652.         $entityManager $this->getDoctrine()->getManager();
  653.         $seopageclient = new SeoPageClient();
  654.         $parameters $this->accountingFirm->getParameters();
  655.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 23]);
  656.         return $this->render('tools/tools_entretien_bilan.html.twig', ['seopage' => $seopage]);
  657.     }
  658.     #[Route(path'/outil-evaluation-entreprise'name'outil_evaluation_entreprise')]
  659.     #[Route(path'/preview/{host}/outil-evaluation-entreprise'name'previewoutil_evaluation_entreprise')]
  660.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  661.     public function OutilEvaluationEntreprise(): Response
  662.     {
  663.         $entityManager $this->getDoctrine()->getManager();
  664.         $seopageclient = new SeoPageClient();
  665.         $parameters $this->accountingFirm->getParameters();
  666.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 24]);
  667.         return $this->render('tools/tools_evaluation_entreprise.html.twig', ['seopage' => $seopage]);
  668.     }
  669.     #[Route(path'/outil-facturation'name'outil_facturation')]
  670.     #[Route(path'/preview/{host}/outil-facturation'name'previewoutil_facturation')]
  671.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  672.     public function OutilFacturation(): Response
  673.     {
  674.         $entityManager $this->getDoctrine()->getManager();
  675.         $seopageclient = new SeoPageClient();
  676.         $parameters $this->accountingFirm->getParameters();
  677.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 25]);
  678.         return $this->render('tools/tools_facturation.html.twig', ['seopage' => $seopage]);
  679.     }
  680.     #[Route(path'/outil-financement'name'outil_financement')]
  681.     #[Route(path'/preview/{host}/outil-financement'name'previewoutil_financement')]
  682.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  683.     public function OutilFinancement(): Response
  684.     {
  685.         $entityManager $this->getDoctrine()->getManager();
  686.         $seopageclient = new SeoPageClient();
  687.         $parameters $this->accountingFirm->getParameters();
  688.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 26]);
  689.         return $this->render('tools/tools_financement.html.twig', ['seopage' => $seopage]);
  690.     }
  691.     #[Route(path'/outil-note-de-frais'name'outil_note_de_frais')]
  692.     #[Route(path'/preview/{host}/outil-note-de-frais'name'previewoutil_note_de_frais')]
  693.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  694.     public function OutilNoteDeFrais(): Response
  695.     {
  696.         $entityManager $this->getDoctrine()->getManager();
  697.         $seopageclient = new SeoPageClient();
  698.         $parameters $this->accountingFirm->getParameters();
  699.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 27]);
  700.         return $this->render('tools/tools_note_de_frais.html.twig', ['seopage' => $seopage]);
  701.     }
  702.     #[Route(path'/outil-optimisation-financement-vehicule'name'outil_optimisation_financement_vehicule')]
  703.     #[Route(path'/preview/{host}/outil-optimisation-financement-vehicule'name'previewoutil_optimisation_financement_vehicule')]
  704.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  705.     public function OutilOptimisationFinancementVehicule(): Response
  706.     {
  707.         $entityManager $this->getDoctrine()->getManager();
  708.         $seopageclient = new SeoPageClient();
  709.         $parameters $this->accountingFirm->getParameters();
  710.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 28]);
  711.         return $this->render('tools/tools_optimisation_financement_vehicule.html.twig', ['seopage' => $seopage]);
  712.     }
  713.     #[Route(path'/outil-optimisation-investissement-immo'name'outil_optimisation_investissement_immo')]
  714.     #[Route(path'/preview/{host}/outil-optimisation-investissement-immo'name'previewoutil_optimisation_investissement_immo')]
  715.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  716.     public function OutilOptimisationInvestissementImmo(): Response
  717.     {
  718.         $entityManager $this->getDoctrine()->getManager();
  719.         $seopageclient = new SeoPageClient();
  720.         $parameters $this->accountingFirm->getParameters();
  721.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 29]);
  722.         return $this->render('tools/tools_optimisation_investissement_immo.html.twig', ['seopage' => $seopage]);
  723.     }
  724.     #[Route(path'/outil-suivi-gestion'name'outil_suivi_gestion')]
  725.     #[Route(path'/preview/{host}/outil-suivi-gestion'name'previewoutil_suivi_gestion')]
  726.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  727.     public function OutilSuiviGestion(): Response
  728.     {
  729.         $entityManager $this->getDoctrine()->getManager();
  730.         $seopageclient = new SeoPageClient();
  731.         $parameters $this->accountingFirm->getParameters();
  732.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 30]);
  733.         return $this->render('tools/tools_suivi_gestion.html.twig', ['seopage' => $seopage]);
  734.     }
  735.     #[Route(path'/outil-index'name'outil_index')]
  736.     #[Route(path'/preview/{host}/outil-index'name'previewoutil_index')]
  737.     #[IsGranted('WEBSITE_TOOLS'statusCode404)]
  738.     public function OutilIndex(): Response
  739.     {
  740.         $entityManager $this->getDoctrine()->getManager();
  741.         $seopageclient = new SeoPageClient();
  742.         $parameters $this->accountingFirm->getParameters();
  743.         $seopage $entityManager->getRepository(SeoPageClient::class)->findOneBy(['parameter_id' => $parameters->getId(), 'seopage_id' => 5]);
  744.         return $this->render('tools/tools_index.html.twig', ['seopage' => $seopage]);
  745.     }
  746.     #[Route(path'/assets/{folder}/{filename}.{_format}'name'client_assets'requirements: ['folder' => '.+'])]
  747.     #[Route(path'/preview/{host}/assets/{folder}/{filename}.{_format}'name'previewclient_assets'requirements: ['folder' => '.+'])]
  748.     public function assets(Request $requeststring $folderstring $filename): BinaryFileResponse
  749.     {
  750.         $host $this->accountingFirm->getHost();
  751.         $base "clients\\" $host "\\assets";
  752.         if (!is_string($host)) {
  753.             throw new \LogicException('Parameter Host must be defined.');
  754.         }
  755.         $root $request->server->get('DOCUMENT_ROOT');
  756.         $root str_replace('public'''$root);
  757.         if (substr($root, -1) != '/') {
  758.             $root .= "/";
  759.         }
  760.         $workspace $root $base;
  761.         $workspace str_replace("\\""/"$workspace);
  762.         $workspace str_replace("//""/"$workspace);
  763.         if (!is_dir($workspace)) {
  764.             throw new \LogicException('Workspace must be a directory: ' $workspace);
  765.         }
  766.         $filePath sprintf(
  767.             '%s\%s\%s',
  768.             $workspace,
  769.             $folder,
  770.             implode('.', [$filename$request->getRequestFormat()])
  771.         );
  772.         $filePath str_replace("\\""/"$filePath);
  773.         $filePath str_replace("//""/"$filePath);
  774.         if (!file_exists($filePath)) {
  775.             throw $this->createNotFoundException();
  776.         }
  777.         $response = new BinaryFileResponse($filePath);
  778.         if (str_contains($request->getRequestFormat(), 'css') || str_contains($request->getRequestFormat(), 'scss')) {
  779.             $response->headers->set('Content-Type''text/css');
  780.         }
  781.         return $response;
  782.     }
  783.     #[Route(path'/refresh-csrf-contact-creation-societe'name'refresh_csrf_contact_creation_societe')]
  784.     #[Route(path'/preview/{host}/refresh-csrf-contact-creation-societe'name'previewrefresh_csrf_contact_creation_societe')]
  785.     public function refreshCsrfContactCreationSociete(CsrfTokenManagerInterface $csrfTokenManager)
  786.     {
  787.         $token $csrfTokenManager->getToken('contact_creation_societe')->getValue();
  788.         return new JsonResponse([
  789.             'token' => $token
  790.         ]);
  791.     }
  792.     #[Route(path'/refresh-csrf-contact-previ-immo'name'refresh_csrf_contact_creation_previ_immo')]
  793.     #[Route(path'/preview/{host}/refresh-csrf-contact-previ-immo'name'previewrefresh_csrf_contact_creation_previ_immo')]
  794.     public function refreshCsrfContactPreviImmo(CsrfTokenManagerInterface $csrfTokenManager)
  795.     {
  796.         $token $csrfTokenManager->getToken('contact_investissement_immo')->getValue();
  797.         return new JsonResponse([
  798.             'token' => $token
  799.         ]);
  800.     }
  801.     #[Route(path'/qrcode/{id}'name'qrcode_index_redirect_client')]
  802.     #[Route(path'/preview/{host}/qrcode/{id}'name'previewclient_qrcode_index_redirect_client')]
  803.     public function index_client(Qrcode $qrcode): RedirectResponse
  804.     {
  805.         return new RedirectResponse($qrcode->getUrl());
  806.     }
  807.     #[Route(path'/video/{id}-{slug}'name'video_client')]
  808.     #[Route(path'/preview/{host}/video/{id}-{slug}'name'previewoutil_video_client')]
  809.     public function ModuleVideo(moduleVideo $videostring $slug): Response
  810.     {
  811.         if (!$video || $video->getAccountingFirm() !== $this->accountingFirm) {
  812.             throw new NotFoundHttpException();
  813.         }
  814.         return $this->render('video/index.html.twig', ['video' => $video]);
  815.     }
  816.     #[Route(path'/prescripteur/{id}'name'prescripteur_client')]
  817.     #[Route(path'/preview/{host}/prescripteur/{id}'name'previewprescripteur_client')]
  818.     public function prescripteur(Prescriber $prescriber): Response
  819.     {
  820.         if (!$prescriber || $prescriber->getAccountingFirm() !== $this->accountingFirm) {
  821.             throw new NotFoundHttpException();
  822.         }
  823.         return $this->render('prescriber/index.html.twig', ['prescriber' => $prescriber]);
  824.     }
  825.     #[Route('/paiement/retour/{id}'name'monetico_return_client')]
  826.     #[Route('/preview/{host}/paiement/retour/{id}'name'previewmonetico_return_client')]
  827.     public function retourMonetico(Request $requestEntityManagerInterface $emSendContactEmail $cestring $id): Response
  828.     {
  829.         $contact $em->getRepository(ContactCreationSociete::class)->findOneBy(['id' => $id]);
  830.         if (!$contact) {
  831.             $contact $em->getRepository(ContactInvestissementImmo::class)->findOneBy(['id' => $id]);
  832.         }
  833.         $codeRetour $request->get('code-retour'); // "Annulation", "payetest", "paiement"
  834.         if ($codeRetour == 'paiement') {
  835.             if ($contact instanceof ContactCreationSociete) {
  836.                 $this->form_send_previ_creation true;
  837.                 $this->CE->sendPreviCreation($contact);
  838.             } elseif ($contact instanceof ContactInvestissementImmo) {
  839.                 $this->form_send_previ_immo true;
  840.                 $this->CE->sendPreviImmo($contact);
  841.             }
  842.         }
  843.         if (!$contact) {
  844.             return new Response('Contact non trouvé'404);
  845.         }
  846.         if ($contact->getStatus() === 'success') {
  847.             $this->form_send_previ_creation true;
  848.         }
  849.         return $this->render('monetico-payement/return-payement.html.twig');
  850.     }
  851.     #[Route('/paiement/notification'name'monetico_notification'methods: ['POST'])]
  852.     #[Route('/preview/{host}/paiement/notification'name'previewmonetico_notification'methods: ['POST''GET'])]
  853.     public function notificationMonetico(Request $requestEntityManagerInterface $emSendContactEmail $ce): Response
  854.     {
  855.         $logFile '/data/www/prod/var/log/monetico.log';
  856.         // Petite fonction utilitaire pour écrire dans le log
  857.         $log = function (string $message) use ($logFile) {
  858.             $datetime = (new \DateTime())->format('Y-m-d H:i:s');
  859.             file_put_contents($logFile"[$datetime$message\n"FILE_APPEND);
  860.         };
  861.         $reference $request->get('reference');
  862.         $code $request->get('code-retour'); // "Annulation", "payetest", "paiement"
  863.         $log("Notification reçue - reference: $reference | code-retour: $code | method: " $request->getMethod());
  864.         $contact $em->getRepository(ContactCreationSociete::class)->findOneBy(['reference' => $reference]);
  865.         if ($contact) {
  866.             $log("Contact trouvé dans ContactCreationSociete (ID: {$contact->getId()})");
  867.         } else {
  868.             $contact $em->getRepository(ContactInvestissementImmo::class)->findOneBy(['reference' => $reference]);
  869.             if ($contact) {
  870.                 $log("Contact trouvé dans ContactInvestissementImmo (ID: {$contact->getId()})");
  871.             }
  872.         }
  873.         if (!$contact) {
  874.             $log("Aucun contact trouvé pour la référence $reference");
  875.             return new Response('Contact non trouvé'404);
  876.         }
  877.         if ($code === 'paiement' || $code === 'payetest') {
  878.             $log("Paiement validé - envoi du mail");
  879.             // Paiement OK → on envoie le mail
  880.             if ($contact instanceof ContactCreationSociete) {
  881.                 $ce->sendPreviCreation($contact);
  882.                 $log("Email envoyé avec sendPreviCreation");
  883.             } elseif ($contact instanceof ContactInvestissementImmo) {
  884.                 $ce->sendPreviImmo($contact);
  885.                 $log("Email envoyé avec sendPreviImmo");
  886.             }
  887.             // Flag pour dire que le mail est déjà envoyé
  888.             $contact->setStatus("success");
  889.             $em->persist($contact);
  890.             $em->flush();
  891.             $log("Statut du contact mis à jour à 'success' et flush");
  892.         }
  893.         $log("Accusé de réception envoyé à Monetico");
  894.         return new Response("version=2\ncdr=0"200, ['Content-Type' => 'text/plain']);
  895.     }
  896.     #[Route(path'/{_prefix}{url}'name'client_tools_page'requirements: ['_prefix' => 'outil-'])]
  897.     #[Route(path'/preview/{host}/{_prefix}{url}'name'previewclient_tools_page'requirements: ['_prefix' => 'outil-'])]
  898.     #[ParamConverter('page'options: ['mapping' => ['url' => 'url']])]
  899.     public function customToolsPage(SeoPageClient $page): Response
  900.     {
  901.         $entityManager $this->getDoctrine()->getManager();
  902.         $parameters $this->accountingFirm->getParameters();
  903.         $page $entityManager->getRepository(SeoPageClient::class)->findOneBy([
  904.             'parameter_id' => $parameters->getId(),
  905.             'type' => 2'active' => 1'template' => $page->getTemplate(), 'url' => $page->getUrl()
  906.         ]);
  907.         return $this->render($page->getTemplate(), ['accountingFirm' => $this->accountingFirm'seopage' => $page'cabinet' => $this->accountingFirm]);
  908.     }
  909.     #[Route(path'/{uri}'name'client_custom_page')]
  910.     #[Route(path'/preview/{host}/{uri}'name'previewclient_custom_page')]
  911.     public function customPage(Page $pageRedirectionClientRepository $redirectionClientRepository): Response
  912.     {
  913.         $entityManager $this->getDoctrine()->getManager();
  914.         $parameters $this->accountingFirm->getParameters();
  915.         $redirection $redirectionClientRepository->findOneBy(['parameter' => $parameters->getId(), 'oldurl' => $page->getUri()]);
  916.         if ($redirection) {
  917.             return $this->redirect($redirection->getNewurl(), 301);
  918.         }
  919.         $page $entityManager->getRepository(Page::class)->findOneBy(['parameter' => $parameters->getId(), 'template' => $page->getTemplate()]);
  920.         return $this->render($page->getTemplate(), ['page' => $page]);
  921.     }
  922. }