src/Controller/MainController.php line 171

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Entity\Etablissement;
  7. use App\Repository\EtablissementRepository;
  8. use App\Entity\Domicile;
  9. use App\Repository\DomicileRepository;
  10. use App\Entity\Seminaire;
  11. use App\Repository\SeminaireRepository;
  12. use App\Entity\Temoignages;
  13. use App\Repository\TemoignagesRepository;
  14. use App\Entity\Habitat;
  15. use App\Repository\HabitatRepository;
  16. use App\Entity\ResidenseService;
  17. use App\Repository\ResidenseServiceRepository;
  18. use App\Entity\Satisfactions;
  19. use App\Repository\SatisfactionsRepository;
  20. use App\Entity\FilesFormations;
  21. use App\Repository\FilesFormationsRepository;
  22. use App\Entity\Certifications;
  23. use App\Repository\CertificationsRepository;
  24. use App\Entity\AccueilVideos;
  25. use App\Repository\AccueilVideosRepository;
  26. use App\Entity\Contact;
  27. use App\Repository\ContactRepository;
  28. use App\Entity\DocumentsCGVReglement;
  29. use App\Repository\DocumentsCGVReglementRepository;
  30. use App\Entity\CatalogueCategories;
  31. use App\Repository\CatalogueCategoriesRepository;
  32. use App\Entity\DocumentaireCategories;
  33. use App\Repository\DocumentaireCategoriesRepository;
  34. use App\Entity\BandeauAccueil;
  35. use App\Repository\BandeauAccueilRepository;
  36. use App\Entity\Flyers;
  37. use App\Repository\FlyersRepository;
  38. use App\Entity\Equipe;
  39. use App\Repository\EquipeRepository;
  40. use App\Repository\FormsInscriptionRepository;
  41. use Symfony\Component\Mailer\MailerInterface;
  42. use Symfony\Component\Mime\Email;
  43. use Symfony\Component\HttpFoundation\Request;
  44. use App\Form\ContactType;
  45. class MainController extends AbstractController
  46. {
  47.     /**
  48.      * @Route("/", name="accueil")
  49.      */
  50.     public function index(
  51.         EtablissementRepository $etablissementRepository,
  52.         DomicileRepository $domicileRepository,
  53.         SeminaireRepository $seminaireRepository,
  54.         TemoignagesRepository $temoignagesRepository,
  55.         ResidenseServiceRepository $residenseServiceRepository,
  56.         SatisfactionsRepository $satisfactionsRepository,
  57.         DocumentsCGVReglementRepository $documentsCGVReglementRepository,
  58.         CertificationsRepository $certificationsRepository,
  59.         AccueilVideosRepository $accueilVideosRepository,
  60.         BandeauAccueilRepository $bandeauAccueilRepository
  61.     ): Response
  62.     {
  63.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  64.         $etablissements $etablissementRepository->findAll();
  65.         $domiciles $domicileRepository->findAll();
  66.         $seminaires $seminaireRepository->findAll();
  67.         $residense $residenseServiceRepository->findAll();
  68.         $temoignages $temoignagesRepository->findBy([] , [] , 8);
  69.         $satisfactions $satisfactionsRepository->findAll();
  70.         $certifications $certificationsRepository->findAll();
  71.         $videoPresentation $accueilVideosRepository->findAll();
  72.         $bandeauAccueils $bandeauAccueilRepository->findBy(["isActive" => true]);
  73.         return $this->render('main/index.html.twig', [
  74.             'etablissements' => $etablissements,
  75.             'domiciles' => $domiciles,
  76.             'seminaires' => $seminaires,
  77.             'temoignages' => $temoignages,
  78.             "residense" => $residense,
  79.             "satisfactions" => $satisfactions,
  80.             "documentCGVReglement" => $documentCGVReglement,
  81.             "certifications" => $certifications,
  82.             "videopresentations" => $videoPresentation,
  83.             "bandeauAccueils" => $bandeauAccueils
  84.         ]);
  85.     }
  86.     /**
  87.      * @Route("/apropos", name="apropos")
  88.      */
  89.     public function apropos(DocumentsCGVReglementRepository $documentsCGVReglementRepositoryCertificationsRepository $certificationsRepositoryEquipeRepository $equipeRepository): Response
  90.     {
  91.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  92.         $equipe $equipeRepository->findBy(["isActif" => true]);
  93.         $certifications $certificationsRepository->findAll();
  94.         return $this->render('main/apropos.html.twig', [
  95.             'controller_name' => 'MainController',
  96.             "documentCGVReglement" => $documentCGVReglement,
  97.             "certifications" => $certifications,
  98.             "equipe" => $equipe,
  99.         ]);
  100.     }
  101.     /**
  102.      * @Route("/catalogue", name="catalogue")
  103.      */
  104.     public function catalogue(
  105.         CatalogueCategoriesRepository $catalogueCategoriesRepository,
  106.         SeminaireRepository $seminaireRepository,
  107.         EtablissementRepository $etablissementRepository,
  108.         DomicileRepository $domicileRepository,
  109.         HabitatRepository $habitatRepository,
  110.         ResidenseServiceRepository $residenseServiceRepository,
  111.         DocumentsCGVReglementRepository $documentsCGVReglementRepository,
  112.         CertificationsRepository $certificationsRepository,
  113.         FormsInscriptionRepository $formsInscriptionRepository
  114.       ): Response
  115.     {
  116.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  117.         $categories $catalogueCategoriesRepository->findAll();
  118.         $certifications $certificationsRepository->findAll();
  119.         
  120.         // Récupérer le formulaire d'inscription pour les catalogues (s'il existe)
  121.         $catalogueForm $formsInscriptionRepository->findCatalogueForm();
  122.         return $this->render('main/catalogue.html.twig', [
  123.             "categories" => $categories,
  124.             "documentCGVReglement" => $documentCGVReglement,
  125.             "certifications" => $certifications,
  126.             "catalogueForm" => $catalogueForm
  127.     ]);
  128.     }
  129.     /**
  130.      * @Route("/documentaire", name="documentaire")
  131.      */
  132.     public function documentaire(CertificationsRepository $certificationsRepository,DocumentaireCategoriesRepository $documentaireCategoriesRepository,DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  133.     {
  134.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  135.         $certifications $certificationsRepository->findAll();
  136.         $categories $documentaireCategoriesRepository->findAll();
  137.         return $this->render('main/documentaire.html.twig', ["categories" => $categories"documentCGVReglement" => $documentCGVReglement"certifications" => $certifications]);
  138.     }
  139.     /**
  140.      * @Route("/etablissement", name="etablissement")
  141.      */
  142.     public function etablissement(CertificationsRepository $certificationsRepository,EtablissementRepository $etablissementRepositoryDocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  143.     {
  144.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  145.         $certifications $certificationsRepository->findAll();
  146.         $formations $etablissementRepository->findBy(["isActif" => true]);
  147.         return $this->render('main/etablissement.html.twig', [
  148.             'formations' => $formations,
  149.             "documentCGVReglement" => $documentCGVReglement,
  150.             "certifications" => $certifications
  151.         ]);
  152.     }
  153.     /**
  154.      * @Route("/domicile", name="domicile")
  155.      */
  156.     public function domicile(CertificationsRepository $certificationsRepository,DomicileRepository $domicileRepositoryDocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  157.     {
  158.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  159.         $certifications $certificationsRepository->findAll();
  160.         $formations $domicileRepository->findBy(["isActif" => true]);
  161.         return $this->render('main/domicile.html.twig', [
  162.             'formations' => $formations,
  163.             "documentCGVReglement" => $documentCGVReglement,
  164.             "certifications" => $certifications
  165.         ]);
  166.     }
  167.     /**
  168.      * @Route("/habitat", name="habitat")
  169.      */
  170.     public function habitat(CertificationsRepository $certificationsRepository,HabitatRepository $habitatRepository,  DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  171.     {
  172.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  173.         $certifications $certificationsRepository->findAll();
  174.         $formations $habitatRepository->findBy(["isActif" => true]);
  175.         return $this->render('main/habitat.html.twig', [
  176.             'formations' => $formations,
  177.             "documentCGVReglement" => $documentCGVReglement,
  178.             "certifications" => $certifications
  179.         ]);
  180.     }
  181.     /**
  182.      * @Route("/residenceservice", name="residenseservice")
  183.      */
  184.     public function residenseService(CertificationsRepository $certificationsRepository,ResidenseServiceRepository $residenseServiceRepositoryDocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  185.     {
  186.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  187.         $certifications $certificationsRepository->findAll();
  188.         $formations $residenseServiceRepository->findBy(["isActif" => true]);
  189.         return $this->render('main/residenseService.html.twig', [
  190.             'formations' => $formations,
  191.             "documentCGVReglement" => $documentCGVReglement,
  192.             "certifications" => $certifications
  193.         ]);
  194.     }
  195.     /**
  196.      * @Route("/seminaire", name="seminaire")
  197.      */
  198.     public function seminaire(CertificationsRepository $certificationsRepository,SeminaireRepository $seminaireRepositoryDocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  199.     {
  200.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  201.         $certifications $certificationsRepository->findAll();
  202.         $formations $seminaireRepository->findBy(["isActif" => true]);
  203.         return $this->render('main/seminaire.html.twig', [
  204.             'formations' => $formations,
  205.             "documentCGVReglement" => $documentCGVReglement,
  206.             "certifications" => $certifications
  207.         ]);
  208.     }
  209.     /**
  210.      * @Route("/contact", name="contact")
  211.      */
  212.     public function contact(CertificationsRepository $certificationsRepository,MailerInterface $mailerRequest $requestDocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  213.     {
  214.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  215.         $certifications $certificationsRepository->findAll();
  216.         $contact = new Contact();
  217.         $form $this->createForm(ContactType::class, $contact);
  218.         $form->handleRequest($request);
  219.         
  220.         if($request->isMethod('POST')){
  221.             //var_dump("premier if");
  222.             //var_dump($form->isSubmitted());
  223.             //dd($form->getData());
  224.             //$form->submit($request->request->get($form->getName()));
  225.             //$form->submit(array_merge($json, $request->request->all()));
  226.             
  227.             if ($form->isSubmitted() && $form->isValid()) {
  228.                 //dd($form->getData());
  229.                 $contact $form->getData();
  230.                 $nom $contact->getNomprenom();
  231.                 $societe $contact->getSociete();
  232.                 $adresse $contact->getAdresse();
  233.                 $mail $contact->getMail();
  234.                 $num $contact->getNum();
  235.                 $formation $contact->getFormation();
  236.                 $message $contact->getMessage();
  237.     
  238.     
  239.                 $email = (new Email(/*$transport*/))
  240.     
  241.                     ->from('ilex.fc@gmail.com')
  242.                     ->to('ilex.fc@gmail.com')
  243.                     ->subject('CONTACT ILEX')
  244.                     ->html('<p>
  245.                     Nom prenom : '.$nom.'<br><br>
  246.                     Établissement / Société : '.$societe.'<br><br>
  247.                     Adresse : '.$adresse.'<br><br>
  248.                     email : '.$mail.'<br><br>
  249.                     Numero : '.$num.'<br><br>
  250.                     Formation : '.$formation.'<br><br>
  251.                     Message : '.$message.'<br><br>
  252.                     </p>');
  253.     
  254.                     $mailer->send($email);  
  255.     
  256.     
  257.                     return $this->renderForm('mailer/contactvalidation.html.twig');
  258.             }
  259.         }
  260.         
  261.         
  262.         $form $this->createForm(ContactType::class);
  263.         
  264.         return $this->renderForm('main/contact.html.twig', [
  265.             'controller_name' => 'MainController',
  266.             'form' => $form,
  267.             "documentCGVReglement" => $documentCGVReglement,
  268.             "certifications" => $certifications
  269.         ]);
  270.     }
  271.     /**
  272.      * @Route("/mentionlegales", name="mentionlegales")
  273.      */
  274.     public function mentionlegalesCertificationsRepository $certificationsRepositoryDocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  275.     {
  276.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  277.         $certifications $certificationsRepository->findAll();
  278.         return $this->render('main/mentionlegales.html.twig', ["documentCGVReglement" => $documentCGVReglement"certifications" => $certifications]);
  279.     }
  280.     /**
  281.      * @Route("/cgv", name="cgv")
  282.      */
  283.     public function cgv(CertificationsRepository $certificationsRepository,DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  284.     {
  285.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  286.         $certifications $certificationsRepository->findAll();
  287.         return $this->render('main/cgv.html.twig', ["documentCGVReglement" => $documentCGVReglement"certifications" => $certifications]);
  288.     }
  289.     /**
  290.      * @Route("/reglement-interieur", name="reglement-interieur")
  291.      */
  292.     public function reglementInterieur(CertificationsRepository $certificationsRepository,DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  293.     {
  294.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  295.         $certifications $certificationsRepository->findAll();
  296.         return $this->render('main/reglementInterieur.html.twig', ["documentCGVReglement" => $documentCGVReglement"certifications" => $certifications]);
  297.     }
  298.     /**
  299.      * @Route("/codefichier", name="codefichier")
  300.      */
  301.     public function codefichier(CertificationsRepository $certificationsRepository,FilesFormationsRepository $filesFormationsRepositoryRequest $requestDocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  302.     {
  303.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  304.         $certifications $certificationsRepository->findAll();
  305.         $code =$request->get("code");
  306.         $formations $filesFormationsRepository->findBy(["Code" => $code]);
  307.         return $this->render('main/codefichier.html.twig', ["formations" => $formations"documentCGVReglement" => $documentCGVReglement"certifications" => $certifications]);
  308.     }
  309.     /**
  310.      * @Route("/bandeau/{id}", name="bandeaupage")
  311.      */
  312.     public function bandeaupage(Request $request,BandeauAccueilRepository $bandeauAccueilRepositoryCertificationsRepository $certificationsRepositoryDocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
  313.     {
  314.         $bandeauAccueil $bandeauAccueilRepository->findOneBy(["id" => $request->get("id")]);
  315.         $certifications $certificationsRepository->findAll();
  316.         $documentCGVReglement $documentsCGVReglementRepository->findAll();
  317.         return $this->render('main/bandeaupage.html.twig', ["bandeauAccueil" => $bandeauAccueil"certifications" => $certifications"documentCGVReglement" => $documentCGVReglement]);
  318.     }
  319.     /**
  320.      * @Route("/flyer", name="flyer")
  321.      */
  322.     public function flyer(FlyersRepository $flyersRepository): Response
  323.     {
  324.         // Récupérer le premier enregistrement dans la table Flyers
  325.         $flyer $flyersRepository->findOneBy([], ['id' => 'ASC']);
  326.         // Si aucun flyer n'est trouvé, afficher une erreur 404
  327.         if (!$flyer || !$flyer->getPdf()) {
  328.             throw $this->createNotFoundException("Aucun flyer disponible.");
  329.         }
  330.         // Rediriger l'utilisateur vers le PDF
  331.         return $this->redirect('/uploads/flyers_pdfs/' $flyer->getPdf());
  332.     }
  333.     
  334. }