<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\Etablissement;
use App\Repository\EtablissementRepository;
use App\Entity\Domicile;
use App\Repository\DomicileRepository;
use App\Entity\Seminaire;
use App\Repository\SeminaireRepository;
use App\Entity\Temoignages;
use App\Repository\TemoignagesRepository;
use App\Entity\Habitat;
use App\Repository\HabitatRepository;
use App\Entity\ResidenseService;
use App\Repository\ResidenseServiceRepository;
use App\Entity\Satisfactions;
use App\Repository\SatisfactionsRepository;
use App\Entity\FilesFormations;
use App\Repository\FilesFormationsRepository;
use App\Entity\Certifications;
use App\Repository\CertificationsRepository;
use App\Entity\AccueilVideos;
use App\Repository\AccueilVideosRepository;
use App\Entity\Contact;
use App\Repository\ContactRepository;
use App\Entity\DocumentsCGVReglement;
use App\Repository\DocumentsCGVReglementRepository;
use App\Entity\CatalogueCategories;
use App\Repository\CatalogueCategoriesRepository;
use App\Entity\DocumentaireCategories;
use App\Repository\DocumentaireCategoriesRepository;
use App\Entity\BandeauAccueil;
use App\Repository\BandeauAccueilRepository;
use App\Entity\Flyers;
use App\Repository\FlyersRepository;
use App\Entity\Equipe;
use App\Repository\EquipeRepository;
use App\Repository\FormsInscriptionRepository;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\HttpFoundation\Request;
use App\Form\ContactType;
class MainController extends AbstractController
{
/**
* @Route("/", name="accueil")
*/
public function index(
EtablissementRepository $etablissementRepository,
DomicileRepository $domicileRepository,
SeminaireRepository $seminaireRepository,
TemoignagesRepository $temoignagesRepository,
ResidenseServiceRepository $residenseServiceRepository,
SatisfactionsRepository $satisfactionsRepository,
DocumentsCGVReglementRepository $documentsCGVReglementRepository,
CertificationsRepository $certificationsRepository,
AccueilVideosRepository $accueilVideosRepository,
BandeauAccueilRepository $bandeauAccueilRepository
): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$etablissements = $etablissementRepository->findAll();
$domiciles = $domicileRepository->findAll();
$seminaires = $seminaireRepository->findAll();
$residense = $residenseServiceRepository->findAll();
$temoignages = $temoignagesRepository->findBy([] , [] , 8);
$satisfactions = $satisfactionsRepository->findAll();
$certifications = $certificationsRepository->findAll();
$videoPresentation = $accueilVideosRepository->findAll();
$bandeauAccueils = $bandeauAccueilRepository->findBy(["isActive" => true]);
return $this->render('main/index.html.twig', [
'etablissements' => $etablissements,
'domiciles' => $domiciles,
'seminaires' => $seminaires,
'temoignages' => $temoignages,
"residense" => $residense,
"satisfactions" => $satisfactions,
"documentCGVReglement" => $documentCGVReglement,
"certifications" => $certifications,
"videopresentations" => $videoPresentation,
"bandeauAccueils" => $bandeauAccueils
]);
}
/**
* @Route("/apropos", name="apropos")
*/
public function apropos(DocumentsCGVReglementRepository $documentsCGVReglementRepository, CertificationsRepository $certificationsRepository, EquipeRepository $equipeRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$equipe = $equipeRepository->findBy(["isActif" => true]);
$certifications = $certificationsRepository->findAll();
return $this->render('main/apropos.html.twig', [
'controller_name' => 'MainController',
"documentCGVReglement" => $documentCGVReglement,
"certifications" => $certifications,
"equipe" => $equipe,
]);
}
/**
* @Route("/catalogue", name="catalogue")
*/
public function catalogue(
CatalogueCategoriesRepository $catalogueCategoriesRepository,
SeminaireRepository $seminaireRepository,
EtablissementRepository $etablissementRepository,
DomicileRepository $domicileRepository,
HabitatRepository $habitatRepository,
ResidenseServiceRepository $residenseServiceRepository,
DocumentsCGVReglementRepository $documentsCGVReglementRepository,
CertificationsRepository $certificationsRepository,
FormsInscriptionRepository $formsInscriptionRepository
): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$categories = $catalogueCategoriesRepository->findAll();
$certifications = $certificationsRepository->findAll();
// Récupérer le formulaire d'inscription pour les catalogues (s'il existe)
$catalogueForm = $formsInscriptionRepository->findCatalogueForm();
return $this->render('main/catalogue.html.twig', [
"categories" => $categories,
"documentCGVReglement" => $documentCGVReglement,
"certifications" => $certifications,
"catalogueForm" => $catalogueForm
]);
}
/**
* @Route("/documentaire", name="documentaire")
*/
public function documentaire(CertificationsRepository $certificationsRepository,DocumentaireCategoriesRepository $documentaireCategoriesRepository,DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
$categories = $documentaireCategoriesRepository->findAll();
return $this->render('main/documentaire.html.twig', ["categories" => $categories, "documentCGVReglement" => $documentCGVReglement, "certifications" => $certifications]);
}
/**
* @Route("/etablissement", name="etablissement")
*/
public function etablissement(CertificationsRepository $certificationsRepository,EtablissementRepository $etablissementRepository, DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
$formations = $etablissementRepository->findBy(["isActif" => true]);
return $this->render('main/etablissement.html.twig', [
'formations' => $formations,
"documentCGVReglement" => $documentCGVReglement,
"certifications" => $certifications
]);
}
/**
* @Route("/domicile", name="domicile")
*/
public function domicile(CertificationsRepository $certificationsRepository,DomicileRepository $domicileRepository, DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
$formations = $domicileRepository->findBy(["isActif" => true]);
return $this->render('main/domicile.html.twig', [
'formations' => $formations,
"documentCGVReglement" => $documentCGVReglement,
"certifications" => $certifications
]);
}
/**
* @Route("/habitat", name="habitat")
*/
public function habitat(CertificationsRepository $certificationsRepository,HabitatRepository $habitatRepository, DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
$formations = $habitatRepository->findBy(["isActif" => true]);
return $this->render('main/habitat.html.twig', [
'formations' => $formations,
"documentCGVReglement" => $documentCGVReglement,
"certifications" => $certifications
]);
}
/**
* @Route("/residenceservice", name="residenseservice")
*/
public function residenseService(CertificationsRepository $certificationsRepository,ResidenseServiceRepository $residenseServiceRepository, DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
$formations = $residenseServiceRepository->findBy(["isActif" => true]);
return $this->render('main/residenseService.html.twig', [
'formations' => $formations,
"documentCGVReglement" => $documentCGVReglement,
"certifications" => $certifications
]);
}
/**
* @Route("/seminaire", name="seminaire")
*/
public function seminaire(CertificationsRepository $certificationsRepository,SeminaireRepository $seminaireRepository, DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
$formations = $seminaireRepository->findBy(["isActif" => true]);
return $this->render('main/seminaire.html.twig', [
'formations' => $formations,
"documentCGVReglement" => $documentCGVReglement,
"certifications" => $certifications
]);
}
/**
* @Route("/contact", name="contact")
*/
public function contact(CertificationsRepository $certificationsRepository,MailerInterface $mailer, Request $request, DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
$contact = new Contact();
$form = $this->createForm(ContactType::class, $contact);
$form->handleRequest($request);
if($request->isMethod('POST')){
//var_dump("premier if");
//var_dump($form->isSubmitted());
//dd($form->getData());
//$form->submit($request->request->get($form->getName()));
//$form->submit(array_merge($json, $request->request->all()));
if ($form->isSubmitted() && $form->isValid()) {
//dd($form->getData());
$contact = $form->getData();
$nom = $contact->getNomprenom();
$societe = $contact->getSociete();
$adresse = $contact->getAdresse();
$mail = $contact->getMail();
$num = $contact->getNum();
$formation = $contact->getFormation();
$message = $contact->getMessage();
$email = (new Email(/*$transport*/))
->from('ilex.fc@gmail.com')
->to('ilex.fc@gmail.com')
->subject('CONTACT ILEX')
->html('<p>
Nom prenom : '.$nom.'<br><br>
Établissement / Société : '.$societe.'<br><br>
Adresse : '.$adresse.'<br><br>
email : '.$mail.'<br><br>
Numero : '.$num.'<br><br>
Formation : '.$formation.'<br><br>
Message : '.$message.'<br><br>
</p>');
$mailer->send($email);
return $this->renderForm('mailer/contactvalidation.html.twig');
}
}
$form = $this->createForm(ContactType::class);
return $this->renderForm('main/contact.html.twig', [
'controller_name' => 'MainController',
'form' => $form,
"documentCGVReglement" => $documentCGVReglement,
"certifications" => $certifications
]);
}
/**
* @Route("/mentionlegales", name="mentionlegales")
*/
public function mentionlegales( CertificationsRepository $certificationsRepository, DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
return $this->render('main/mentionlegales.html.twig', ["documentCGVReglement" => $documentCGVReglement, "certifications" => $certifications]);
}
/**
* @Route("/cgv", name="cgv")
*/
public function cgv(CertificationsRepository $certificationsRepository,DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
return $this->render('main/cgv.html.twig', ["documentCGVReglement" => $documentCGVReglement, "certifications" => $certifications]);
}
/**
* @Route("/reglement-interieur", name="reglement-interieur")
*/
public function reglementInterieur(CertificationsRepository $certificationsRepository,DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
return $this->render('main/reglementInterieur.html.twig', ["documentCGVReglement" => $documentCGVReglement, "certifications" => $certifications]);
}
/**
* @Route("/codefichier", name="codefichier")
*/
public function codefichier(CertificationsRepository $certificationsRepository,FilesFormationsRepository $filesFormationsRepository, Request $request, DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
$certifications = $certificationsRepository->findAll();
$code =$request->get("code");
$formations = $filesFormationsRepository->findBy(["Code" => $code]);
return $this->render('main/codefichier.html.twig', ["formations" => $formations, "documentCGVReglement" => $documentCGVReglement, "certifications" => $certifications]);
}
/**
* @Route("/bandeau/{id}", name="bandeaupage")
*/
public function bandeaupage(Request $request,BandeauAccueilRepository $bandeauAccueilRepository, CertificationsRepository $certificationsRepository, DocumentsCGVReglementRepository $documentsCGVReglementRepository): Response
{
$bandeauAccueil = $bandeauAccueilRepository->findOneBy(["id" => $request->get("id")]);
$certifications = $certificationsRepository->findAll();
$documentCGVReglement = $documentsCGVReglementRepository->findAll();
return $this->render('main/bandeaupage.html.twig', ["bandeauAccueil" => $bandeauAccueil, "certifications" => $certifications, "documentCGVReglement" => $documentCGVReglement]);
}
/**
* @Route("/flyer", name="flyer")
*/
public function flyer(FlyersRepository $flyersRepository): Response
{
// Récupérer le premier enregistrement dans la table Flyers
$flyer = $flyersRepository->findOneBy([], ['id' => 'ASC']);
// Si aucun flyer n'est trouvé, afficher une erreur 404
if (!$flyer || !$flyer->getPdf()) {
throw $this->createNotFoundException("Aucun flyer disponible.");
}
// Rediriger l'utilisateur vers le PDF
return $this->redirect('/uploads/flyers_pdfs/' . $flyer->getPdf());
}
}