<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Repository\PagesRepository;
use App\Repository\FormationsRepository;
use App\Repository\VersionsFormationsRepository;
use App\Repository\TypesFormationsRepository;
use App\Repository\TemoignagesRepository;
use App\Repository\LieuFormationsRepository;
use App\Repository\TeamsRepository;
use App\Repository\ContenusRepository;
use App\Repository\SujetsFormationsRepository;
use App\Repository\LogicielsFormationsRepository;
use App\Repository\JobsRepository;
use App\Repository\BusinessUnitRepository;
use App\Repository\AdressesRepository;
use App\Repository\LieuxJobsRepository;
use App\Repository\ActualitesRepository;
use App\Repository\SessionsFormationsRepository;
use App\Repository\DocumentsRepository;
use App\Repository\CategoriesActualitesRepository;
use App\Repository\SectionsRepository;
use App\Repository\CarouselsRepository;
use App\Repository\DictionnaireRepository;
use App\Repository\CertificatsFormationsRepository;
use App\Repository\CriteresFormationsRepository;
use App\Repository\CatalogueRepository;
use App\Repository\CategoriesFormationsRepository;
use Mailjet\Api\Client;
use Mailjet\Resources;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Doctrine\ORM\EntityManagerInterface;
use ReCaptcha\ReCaptcha;
use Symfony\Component\HttpFoundation\Request;
use Spipu\Html2Pdf\Html2Pdf;
class DefaultController extends AbstractController
{
/**
* @Route("/", name="app_home")
*/
public function index( ActualitesRepository $actualitesRepository,SessionsFormationsRepository $sessionsFormationsRepository, FormationsRepository $formationsRepository, CarouselsRepository $carouRepo, DictionnaireRepository $dicoRepo,SectionsRepository $sectionsRepository, PagesRepository $pagesRepository): Response
{
$page = $pagesRepository->findOneById(13);
$nb = count($page->getSections()) +1;
$sections = $sectionsRepository->findBy(array('Pages'=>13),array('Ordre'=>'asc'));
$formations = $formationsRepository->findAll();
$sessions = $sessionsFormationsRepository->findAll();
$dates = [];
foreach ($sessions as $session) {
$dates[] = $session->getDate(); // Supposons que "getDate()" soit la méthode pour récupérer la date.
}
$actus = $actualitesRepository->findBy(['Afficher'=>1],['Date'=>'desc'],2);
$lastActus = $actualitesRepository->findBy(['Afficher'=>1],['Date'=>'desc'],10);
$lastFormations = $formationsRepository->findBy(['Afficher'=>1], ['Date' => 'desc'], 10);
return $this->render('default/index.html.twig', [
'actus' => $actus,
'lastActus'=>$lastActus,
'formations' => $formations,
'sessions' => $sessions,
'lastFormations' => $lastFormations,
'sections' => $sections,
'page'=> $page,
'ordreMax' =>$nb,
'carousels' => $carouRepo->findBy(['Contenus'=>367],['Ordre'=>'asc']),
'dico' => $dicoRepo->findAll(),
'dates' => $dates
]);
}
/**
* @Route("/{locale}/industrialisation", name="app_industrialisation")
*/
public function industrialisation($locale, Request $request,SectionsRepository $sectionsRepository, PagesRepository $pagesRepository,TemoignagesRepository $temoignagesRepository): Response
{
$page = $pagesRepository->findOneById(1);
$nb = count($page->getSections()) +1;
$sections = $sectionsRepository->findBy(array('Pages'=>1),array('Ordre'=>'asc'));
return $this->render('default/industrialisation.html.twig', [
'sections' => $sections,
'page'=> $page,
'ordreMax' =>$nb,
'ip' => '90.63.222.84',
'temoignages'=>$temoignagesRepository->findAll()
]);
}
/**
* @Route("{locale}/demo", name="demo")
*/
public function demo(SectionsRepository $sectionsRepository, PagesRepository $pagesRepository, TemoignagesRepository $temoignagesRepository): Response
{
$page = $pagesRepository->findOneById(11);
$nb = count($page->getSections()) +1;
$sections = $sectionsRepository->findBy(array('Pages'=>11),array('Ordre'=>'asc'));
return $this->render('default/demo.html.twig', [
'sections' => $sections,
'page'=> $page,
'ordreMax' =>$nb,
'ip' => '90.63.222.84',
'temoignages'=>$temoignagesRepository->findAll()
]);
}
/**
* @Route("/{locale}/formation", name="app_formation")
*/
public function formation($locale): Response
{
return $this->render('default/formation.html.twig', [
'controller_name' => 'DefaultController',
]);
}
/**
* @Route("/cms/digital-manufacturing-services", name="app_digitalManufacturingServicesCms")
*/
public function app_digitalManufacturingServicesCms(): Response
{
return $this->render('default/digitalManufacturingServicesbackup.html.twig', [
'controller_name' => 'DefaultController',
]);
}
/**
* @Route("/{locale}/digital-manufacturing-services", name="app_digitalManufacturingServices")
*/
public function app_digitalManufacturingServices(SectionsRepository $sectionsRepository, PagesRepository $pagesRepository, TemoignagesRepository $temoignagesRepository): Response
{
$page = $pagesRepository->findOneById(3);
$nb = count($page->getSections()) +1;
$sections = $sectionsRepository->findBy(array('Pages'=>3),array('Ordre'=>'asc'));
return $this->render('default/digitalManufacturingServices.html.twig', [
'sections' => $sections,
'page'=> $page,
'ordreMax' =>$nb,
'ip' => '90.63.222.84',
'temoignages'=>$temoignagesRepository->findAll()
]);
}
/**
* @Route("/cms/presentation-erp", name="app_manufacturingERPCms")
*/
public function app_manufacturingERP(DocumentsRepository $documentRepository): Response
{
$pdfs = $documentRepository->findAll();
return $this->render('default/ERPBackup.html.twig', [
'pdfs' => $pdfs,
]);
}
/**
* @Route("admin/{locale}/presentation-erp", name="app_manufacturingERP")
*/
public function app_manufacturingERPCms( DocumentsRepository $documentRepository, SectionsRepository $sectionsRepository, PagesRepository $pagesRepository, TemoignagesRepository $temoignagesRepository): Response
{
$page = $pagesRepository->findOneById(4);
$nb = count($page->getSections()) +1;
$pdfs = $documentRepository->findAll();
$sections = $sectionsRepository->findBy(array('Pages'=>4),array('Ordre'=>'asc'));
return $this->render('default/manufacturingERP.html.twig', [
'sections' => $sections,
'page'=> $page,
'ordreMax' =>$nb,
'ip' => '90.63.222.84' ,
'pdfs' => $pdfs,
'temoignages'=>$temoignagesRepository->findAll()
]);
}
/**
* @Route("admin/{locale}/fonctionnalites-delmiaworks", name="presentationERP")
*/
public function app_presentationERP(SectionsRepository $sectionsRepository, PagesRepository $pagesRepository, TemoignagesRepository $temoignagesRepository): Response
{
$page = $pagesRepository->findOneById(12);
$nb = count($page->getSections()) +1;
$sections = $sectionsRepository->findBy(array('Pages'=>12),array('Ordre'=>'asc'));
return $this->render('default/presentationERP.html.twig', [
'sections' => $sections,
'page'=> $page,
'ordreMax' =>$nb,
'ip' => '90.63.222.84',
'temoignages'=>$temoignagesRepository->findAll()
]);
}
/**
* @Route("/{locale}/base-outils", name="app_baseOutils")
*/
public function app_baseOutilsCms(SectionsRepository $sectionsRepository, PagesRepository $pagesRepository, TemoignagesRepository $temoignagesRepository): Response
{
$page = $pagesRepository->findOneById(5);
$nb = count($page->getSections()) +1;
$sections = $sectionsRepository->findBy(array('Pages'=>5),array('Ordre'=>'asc'));
return $this->render('default/baseOutils.html.twig', [
'sections' => $sections,
'page'=> $page,
'ordreMax' =>$nb,
'ip' => '90.63.222.84' ,
'temoignages'=>$temoignagesRepository->findAll(),
]);
}
/**
* @Route("/cms/base-outils", name="app_baseOutilsCms")
*/
public function app_baseOutils(): Response
{
return $this->render('default/base-outil-backup.html.twig', [
'controller_name' => 'DefaultController',
]);
}
/**
* @Route("/{locale}/societe", name="app_societe")
*/
public function app_societeCms(SectionsRepository $sectionsRepository, PagesRepository $pagesRepository, TemoignagesRepository $temoignagesRepository): Response
{
$page = $pagesRepository->findOneById(6);
$nb = count($page->getSections()) +1;
$sections = $sectionsRepository->findBy(array('Pages'=>6),array('Ordre'=>'asc'));
return $this->render('default/societe.html.twig', [
'sections' => $sections,
'page'=> $page,
'ordreMax' =>$nb,
'ip' => '90.63.222.84' ,
'temoignages'=>$temoignagesRepository->findAll()
]);
}
/**
* @Route("/cms/societe", name="app_societeCms")
*/
public function app_societe(SectionsRepository $sectionsRepository, PagesRepository $pagesRepository, TemoignagesRepository $temoignagesRepository): Response
{
$page = $pagesRepository->findOneById(6);
$nb = count($page->getSections()) +1;
$sections = $sectionsRepository->findBy(array('Pages'=>6),array('Ordre'=>'asc'));
return $this->render('default/societeBackup.html.twig', [
'sections' => $sections,
'page'=> $page,
'ordreMax' =>$nb,
'ip' => '90.63.222.84' ,
'temoignages'=>$temoignagesRepository->findAll()
]);
}
/**
* @Route("/{locale}/formations", name="formations")
*/
public function formations($locale, CatalogueRepository $catalogueRepository, SessionsFormationsRepository $sessionsFormationsRepository, FormationsRepository $formationsRepository,CertificatsFormationsRepository $certificatsFormations, CriteresFormationsRepository $criteresFormations,VersionsFormationsRepository $versionsFormationsRepository, TypesFormationsRepository $typesFormationsRepository, SujetsFormationsRepository $sujetsFormationsRepository, LogicielsFormationsRepository $logicielsFormationsRepository, Request $request, SectionsRepository $sectionsRepository, PagesRepository $pagesRepository): Response
{
$page = $pagesRepository->findOneById(14);
$nb = count($page->getSections()) + 1;
$sections = $sectionsRepository->findBy(array('Pages' => 14), array('Ordre' => 'asc'));
$typeTitre = $typesFormationsRepository->findBy(['TitreFr' => 'ASC']);
// Initialisation du tableau de critères
$critereFiltre = ['Afficher' => 1];
// Ajout des critères de filtrage
if ($request->query->get('version')) {
$critereFiltre['VersionsFormations'] = $request->query->get('version');
}
$typesFormations = $typesFormationsRepository->findAll();
// Ajoutez le filtre pour le type s'il est spécifié dans la requête
if ($request->query->get('sujet')) {
$critereFiltre['SujetsFormations'] = $request->query->get('sujet');
}
if ($request->query->get('logiciel')) {
$critereFiltre['LogicielsFormations'] = $request->query->get('logiciel');
}
if ($request->query->get('formation')) {
$critereFiltre['TitreFr'] = $request->query->get('formation');
}
$sessions = $sessionsFormationsRepository->findAll();
$dates = [];
foreach ($sessions as $session) {
$dates[] = $session->getDate(); // Supposons que "getDate()" soit la méthode pour récupérer la date.
}
// Requête avec tous les critères
$formations = $formationsRepository->findBy($critereFiltre, ['Ordre' => 'ASC']);
$sessionsFormations = $sessionsFormationsRepository->findAll();
$certificats = $certificatsFormations->findAll();
$criteres = $criteresFormations->findAll();
$cataloguesFormations = $catalogueRepository->findAll();
if ($request->query->has('type')) {
$selectedTypeId = $request->query->get('type');
// Vérifiez si l'option "Tous les Types" est sélectionnée
if ($selectedTypeId !== 'all') {
$formations = $this->filterFormationsByType($formations, (int)$selectedTypeId);
}
// Si "Tous les Types" est sélectionné, n'appliquez pas de filtre par type
}
return $this->render('default/formations.html.twig', [
'formations' => $formations,
'cataloguesFormations' => $cataloguesFormations,
'sessionsFormations' => $sessionsFormations,
'certificats' => $certificats,
'criteres' => $criteres,
'versions' => $versionsFormationsRepository->findBy([], ['TitreFr' => 'ASC']),
'types' => $typesFormationsRepository->findBy([], ['TitreFr' => 'ASC']),
'sujets' => $sujetsFormationsRepository->findBy([], ['TitreFr' => 'ASC']),
'logiciels' => $logicielsFormationsRepository->findBy([], ['TitreFr' => 'ASC']),
'formation' => $formationsRepository->findBy([], ['TitreFr' => 'ASC']),
'sections' => $sections,
'page' => $page,
'ordreMax' => $nb,
'formationSelected' => $request->query->get('formation'),
'ip' => '90.63.222.84',
'dates' => $dates
]);
}
/**
* Filtre les formations par le type spécifié.
*/
private function filterFormationsByType(array $formations, int $typeId): array
{
return array_filter($formations, function ($formation) use ($typeId) {
foreach ($formation->getSessionsFormations() as $session) {
if ($session->getTypesFormations()->getId() === $typeId) {
return true;
}
}
return false;
});
}
/**
* @Route("/{locale}/formations/{ref}", name="detailsFormation")
*/
public function detailsFormation($locale,FormationsRepository $formationsRepository,SessionsFormationsRepository $sessionsFormationsRepository, $ref): Response
{
$sessions = $sessionsFormationsRepository->findAll();
$dates = [];
foreach ($sessions as $session) {
$dates[] = $session->getDate(); // Supposons que "getDate()" soit la méthode pour récupérer la date.
}
return $this->render('default/detailsFormation.html.twig', [
'formation' => $formationsRepository->findOneBy(['Reference'=>$ref]),
'formationsall' => $formationsRepository->findAll(),
'$dates' => $dates,
]);
}
/**
* @Route("/{locale}/actualites", name="app_actualites")
*/
public function actualites(ActualitesRepository $actualitesRepository, CategoriesActualitesRepository $categoriesActualites): Response
{
if(isset($_GET['date']))
{
if($_GET['date'] == 'mois')
{
$debut = date('Y-m-d',strtotime('- 30 day'));
$fin = date('Y-m-d');
}
if($_GET['date'] == 'annee')
{
$debut = date('Y-m-d',strtotime('- 365 day'));
$fin = date('Y-m-d');
}
}
$last = $actualitesRepository->findBy([],['Date'=>'desc'],1);
$two = $actualitesRepository->findBy([],['Date'=>'desc'],2,1);
$all = $actualitesRepository->findBy([],['Date'=>'desc'],10,3);
if(isset($_GET['categorie']))
{
$last = $actualitesRepository->findBy(['CategoriesActualites'=>$_GET['categorie']],['Date'=>'desc'],1);
$two = $actualitesRepository->findBy(['CategoriesActualites'=>$_GET['categorie']],['Date'=>'desc'],2,1);
$all = $actualitesRepository->findBy(['CategoriesActualites'=>$_GET['categorie']],['Date'=>'desc'],10,3);
}
if(isset($_GET['date']))
{
/*$last = $actualitesRepository->findOneBy(['CategoriesActualites'=>$_GET['categorie']],['Date'=>'desc']);
$two = $actualitesRepository->findBy(['CategoriesActualites'=>$_GET['categorie']],['Date'=>'desc'],2,1);*/
$last = $actualitesRepository->findDate1($debut,$fin);
$two = $actualitesRepository->findDate2($debut,$fin);
$all = $actualitesRepository->findDate($debut,$fin);
}
return $this->render('default/actualites.html.twig', [
'lasts' => $last,
'two'=>$two,
'all'=>$all,
'cat'=>$categoriesActualites->findBy([], ['TitreFr' => 'ASC'])
]);
}
/**
* @Route("/{locale}/actualites/{titre}/{id}", name="actualitesD")
*/
public function actualitesD(ActualitesRepository $actualitesRepository, $id, SectionsRepository $sectionsRepository): Response
{
$actu = $actualitesRepository->findOneBy(['id' => $id]);
if (!$actu) {
throw $this->createNotFoundException('Article non trouvé');
}
$nb = $actu->getNbVues() + 1;
$actu->setNbVues($nb);
$actualitesRepository->add($actu, true);
$previousActu = $actualitesRepository->findOneBy(['id' => $id - 1]);
$nextActu = $actualitesRepository->findOneBy(['id' => $id + 1]);
$vues = $actualitesRepository->findBy([], ['NbVues' => 'desc'], 5);
$sections = $sectionsRepository->findBy(array('Actualites'=>$actu),array('Ordre'=>'asc'));
return $this->render('default/detailsActualites.html.twig', [
'actu' => $actu,
'previousActu' => $previousActu,
'nextActu' => $nextActu,
'vues' => $vues,
'sections' => $sections,
'ordreMax' =>$nb
]);
}
/**
* @Route("/{locale}/contact", name="app_contact")
*/
public function contact(AdressesRepository $adressesRepository, TeamsRepository $teams): Response
{
return $this->render('default/contact.html.twig', [
'adresses' => $adressesRepository->findAll(),
'teams'=>$teams->findBy([],['Ordre'=>'asc'])
]);
}
/**
* @Route("/{locale}/join-us", name="app_joinus")
*/
public function joinUs(Request $request, $locale, JobsRepository $JobsRepository, BusinessUnitRepository $businessUnitRepository, LieuxJobsRepository $lieuxJobsRepository): Response
{
$jobsCriteria=[];
$businessUnits = $businessUnitRepository->findAll();
$lieux = $lieuxJobsRepository->findAll();
$jobsListe = $JobsRepository->findAll();
if ($request->query->get('businessUnit')) {
$jobsCriteria['BusinessUnit'] = $request->query->get('businessUnit');
}
if ($request->query->get('lieu')) {
$jobsCriteria['LieuxJobs'] = $request->query->get('lieu');
}
if ($request->query->get('job')) {
$jobsCriteria['TitreFr'] = $request->query->get('job');
}
$jobs = $JobsRepository->findByCriteria($jobsCriteria);
return $this->render('default/joinUs.html.twig', [
'jobs' => $jobs,
'businessUnit' => $businessUnits,
'lieux' => $lieux,
'locale' => $locale,
'jobsL' => $jobsListe
]);
}
/**
* @Route("/{locale}/join-us/{ref}", name="app_joinusD")
*/
public function app_joinusD(JobsRepository $JobsRepository, BusinessUnitRepository $businessUnitRepository, LieuxJobsRepository $lieuxJobsRepository, $ref): Response
{
$jobs=$JobsRepository->findOneBy(['Reference'=>$ref]);
return $this->render('default/joinUsDetails.html.twig', [
'jobs' => $jobs,
]);
}
/**
* @Route("/sendFormJoin", name="sendFormJoin")
*/
public function sendJoinUs(JobsRepository $JobsRepository,Request $request): Response
{
$jobs = $JobsRepository->findOneBy(['id'=>$_POST['job']]);
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$motivation = $_POST['motivation'];
$total_count = count($_FILES['cv']['name']);
// Loop through every file
for( $i=0 ; $i < $total_count ; $i++ ) {
$extension = pathinfo($_FILES['cv']['name'][$i], PATHINFO_EXTENSION);
//The temp file path is obtained
$tmpFilePath = $_FILES['cv']['tmp_name'][$i];
//A file path needs to be present
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "./uploadFiles/" . $_FILES['cv']['name'][$i];
//File is uploaded to temp dir
$nb = rand();
$newfilename = time().$nb.'.'.$extension;
move_uploaded_file($_FILES['cv']['tmp_name'][$i], '/var/www/vhosts/deamonerp.fr/httpdocs/cpi2/public/uploads/cv/'.$newfilename);
$lien = $newfilename;
$content = fread(fopen('uploads/cv/'.$lien, "r"), filesize('uploads/cv/'.$lien));
$doc['ContentType'] = "text/plain";
$doc['Filename'] = $lien;
$doc['Base64Content'] = base64_encode($content);
$docs[$i] = $doc;
}
}
if(isset($_POST['confidentialite']))
{
$confidentialite = 'on';
}
else
{
$confidentialite = 'off';
}
// Verify reCAPTCHA
$recaptchaResponse = $request->request->get('g-recaptcha-response');
$recaptcha = new \ReCaptcha\ReCaptcha('6Lf0RGEnAAAAANFz2iFW62hx189DTGl08c3fYnw4');
$recaptchaResult = $recaptcha->verify($recaptchaResponse);
if (!$recaptchaResult->isSuccess()) {
// La vérification reCAPTCHA a échoué. Redirigez vers le formulaire avec un message d'erreur.
return $this->redirectToRoute('app_joinusD', ['ref' => $jobs->getReference(), 'recaptcha_error' => 'true']);
}
$subject = "CPI - Candidature";
$message = $this->renderView(
'emails/joinus.html.twig',
[
'nom' => strtoupper($nom),
'prenom' => strtoupper($prenom),
'email'=>$email,
'telephone'=>$telephone,
'motivation'=>$motivation,
'flexCheckDefault'=>$confidentialite,
'titre'=>$jobs->getTitreFr(),
'reference'=>$jobs->getReference()
]
);
$userEmail = $_POST['email'];
$mj = new \Mailjet\Client('61722507da55a4f5570d0ad1a5b1435e', '01d31913ab5c0fd4586d08d17d114b8c',true,['version' => 'v3.1']);
$body = [
'Messages' => [
[
'From' => [
'Email' => "recrutement@cpi.lu",
'Name' => "CPI"
],
'To' => [
[
'Email' => 'recrutement@cpi.lu',
]
],
'Bcc' => [
[
'Email' => 'damien@piranha.lu',
],
[
'Email' => 'thomasbregler@protonmail.com',
],
[
'Email' => $userEmail,
],
],
'Attachments' => $docs,
'Subject' => $subject,
'HTMLPart' => $message,
]
]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success();
return $this->redirectToRoute('app_joinusD', ['ref'=>$jobs->getReference(),'send'=>'success'], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/sendFormContact", name="sendFormContact")
*/
public function sendFormContact(Request $request,$locale): Response
{
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$societe = $_POST['societe'];
$bp = $_POST['bp'];
$batiment = $_POST['batiment'];
$cp = $_POST['cp'];
$ville = $_POST['ville'];
$pays = $_POST['pays'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$message = $_POST['message'];
if(isset($_POST['flexCheckDefault']))
{
$flexCheckDefault = 'on';
}
else
{
$flexCheckDefault = 'off';
}
// Verify reCAPTCHA
$recaptchaResponse = $request->request->get('g-recaptcha-response');
$recaptcha = new \ReCaptcha\ReCaptcha('6Lf0RGEnAAAAANFz2iFW62hx189DTGl08c3fYnw4');
$recaptchaResult = $recaptcha->verify($recaptchaResponse);
if (!$recaptchaResult->isSuccess()) {
// La vérification reCAPTCHA a échoué. Redirigez vers le formulaire avec un message d'erreur.
return $this->redirectToRoute('app_contact', ['recaptcha_error' => 'true']);
}
$subject = "CPI - Demande de contact / Contact request";
$message = $this->renderView(
'emails/contact.html.twig',
[
'nom' => strtoupper($nom),
'prenom' => strtoupper($prenom),
'societe'=>$societe,
'bp'=>$bp,
'cp'=>$cp,
'ville'=>$ville,
'pays'=>$pays,
'email'=>$email,
'telephone'=>$telephone,
'message'=>$message,
'batiment'=>$batiment,
'flexCheckDefault'=>$flexCheckDefault,
]
);
$userEmail = $_POST['email'];
$mj = new \Mailjet\Client('61722507da55a4f5570d0ad1a5b1435e', '01d31913ab5c0fd4586d08d17d114b8c',true,['version' => 'v3.1']);
$body = [
'Messages' => [
[
'From' => [
'Email' => "info@cpi.lu",
'Name' => "CPI"
],
'To' => [
[
'Email' => 'info@cpi.lu',
]
],
'Bcc' => [
[
'Email' => 'damien@piranha.lu',
],
[
'Email' => 'thomasbregler@protonmail.com',
],
[
'Email' => $userEmail,
],
],
'Subject' => $subject,
'HTMLPart' => $message,
]
]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success();
return $this->redirectToRoute('app_contact', ['locale' => $locale, 'send' => 'success'], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/sendFormDetailsFormation", name="sendFormDetailsFormation")
*/
public function sendFormDetailsFormation(SessionsFormationsRepository $sessionsFormationsRepository,Request $request) : Response
{
$session = $_POST['session'];
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$societe = $_POST['societe'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$remarque = $_POST['remarque'];
if(isset($_POST['confidentialite']))
{
$confidentialite = 'on';
}
else
{
$confidentialite = 'off';
}
$sess = $sessionsFormationsRepository->findOneById($session);
$subject = "CPI - Demande de formation / Training application";
$message = $this->renderView(
'emails/formation.html.twig',
[
'nom' => strtoupper($nom),
'prenom' => strtoupper($prenom),
'societe'=>$societe,
'email'=>$email,
'telephone'=>$telephone,
'remarque'=>$remarque,
'flexCheckDefault'=>$confidentialite,
'titre'=>$sess->getFormations()->getTitreFr(),
'reference'=>$sess->getFormations()->getReference(),
'session'=>$sess->getDate()
]
);
// Verify reCAPTCHA
$recaptchaResponse = $request->request->get('g-recaptcha-response');
$recaptcha = new \ReCaptcha\ReCaptcha('6Lf0RGEnAAAAANFz2iFW62hx189DTGl08c3fYnw4');
$recaptchaResult = $recaptcha->verify($recaptchaResponse);
if (!$recaptchaResult->isSuccess()) {
// La vérification reCAPTCHA a échoué. Redirigez vers le formulaire avec un message d'erreur.
return $this->redirectToRoute('detailsFormation', ['ref' => $sess->getFormations()->getReference(), 'recaptcha_error' => 'true']);
}
$userEmail = $_POST['email'];
$mj = new \Mailjet\Client('61722507da55a4f5570d0ad1a5b1435e', '01d31913ab5c0fd4586d08d17d114b8c',true,['version' => 'v3.1']);
$body = [
'Messages' => [
[
'From' => [
'Email' => "formations@cpi.lu",
'Name' => "CPI"
],
'To' => [
[
'Email' => 'formations@cpi.lu',
]
],
'Bcc' => [
[
'Email' => 'damien@piranha.lu',
],
[
'Email' => 'thomasbregler@protonmail.com',
],
[
'Email' => $userEmail,
],
],
'Subject' => $subject,
'HTMLPart' => $message,
]
]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success();
return $this->redirectToRoute('detailsFormation', ['ref'=>$sess->getFormations()->getReference(),'send'=>'success'], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/sendDocument", name="sendDocument")
*/
public function sendDocument(Request $request, ContenusRepository $contenusRepository): Response
{
$id = $_POST['document'];
$doc = $contenusRepository->findOneBy(['id' => $id]);
$docName = $doc->getDocument();
$fileUrl = '../uploads/contenus/'.$docName;
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$societe = $_POST['societe'];
$email = $_POST['mail'];
if(isset($_POST['flexCheckDefault']))
{
$flexCheckDefault = 'on';
}
else
{
$flexCheckDefault = 'off';
}
$subject = "CPI - Demande de Documentation / documentation request";
$message = $this->renderView(
'emails/document.html.twig',
[
'nom' => strtoupper($nom),
'prenom' => strtoupper($prenom),
'societe'=>$societe,
'email'=>$email,
'flexCheckDefault'=>$flexCheckDefault,
]
);
$userEmail = $_POST['mail'];
$mj = new \Mailjet\Client('61722507da55a4f5570d0ad1a5b1435e', '01d31913ab5c0fd4586d08d17d114b8c',true,['version' => 'v3.1']);
$body = [
'Messages' => [
[
'From' => [
'Email' => "info@cpi.lu",
'Name' => "CPI"
],
'To' => [
[
'Email' => 'info@cpi.lu',
]
],
'Bcc' => [
[
'Email' => 'damien@piranha.lu',
],
[
'Email' => 'thomasbregler@protonmail.com',
],
[
'Email' => $userEmail,
],
],
'Subject' => $subject,
'HTMLPart' => $message,
]
]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success();
return new RedirectResponse($fileUrl);
//return $this->redirectToRoute('app_contact', ['send'=>'success'], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/sendConsultationERP", name="sendConsultationERP")
*/
public function sendConsultationERP(DocumentsRepository $documentsRepository): Response
{
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$societe = $_POST['societe'];
$email = $_POST['mail'];
if(isset($_POST['flexCheckDefault']))
{
$flexCheckDefault = 'on';
}
else
{
$flexCheckDefault = 'off';
}
$subject = "CPI - Demande de consultation ERP-MES / ERP-MES consultation request";
$message = $this->renderView(
'emails/consultationERP.html.twig',
[
'nom' => strtoupper($nom),
'prenom' => strtoupper($prenom),
'societe'=>$societe,
'email'=>$email,
'flexCheckDefault'=>$flexCheckDefault,
]
);
$userEmail = $_POST['mail'];
$mj = new \Mailjet\Client('61722507da55a4f5570d0ad1a5b1435e', '01d31913ab5c0fd4586d08d17d114b8c',true,['version' => 'v3.1']);
$body = [
'Messages' => [
[
'From' => [
'Email' => "info@cpi.lu",
'Name' => "CPI"
],
'To' => [
[
'Email' => 'info@cpi.lu',
]
],
'Bcc' => [
[
'Email' => 'damien@piranha.lu',
],
[
'Email' => 'thomasbregler@protonmail.com',
],
[
'Email' => $userEmail,
],
],
'Subject' => $subject,
'HTMLPart' => $message,
]
]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success();
return $this->redirectToRoute('app_manufacturingERP');
}
/**
* @Route("/sendConsultationBaseOutils", name="sendConsultationBaseOutils")
*/
public function sendConsultationBaseOutils(DocumentsRepository $documentsRepository): Response
{
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$societe = $_POST['societe'];
$email = $_POST['mail'];
if(isset($_POST['flexCheckDefault']))
{
$flexCheckDefault = 'on';
}
else
{
$flexCheckDefault = 'off';
}
$subject = "CPI - Demande de consultation BASE OUTILS COUPANTS / CUTTING TOOLS BASE consultation request : WINTOOL";
$message = $this->renderView(
'emails/consultationBaseOutils.html.twig',
[
'nom' => strtoupper($nom),
'prenom' => strtoupper($prenom),
'societe'=>$societe,
'email'=>$email,
'flexCheckDefault'=>$flexCheckDefault,
]
);
$userEmail = $_POST['mail'];
$mj = new \Mailjet\Client('61722507da55a4f5570d0ad1a5b1435e', '01d31913ab5c0fd4586d08d17d114b8c',true,['version' => 'v3.1']);
$body = [
'Messages' => [
[
'From' => [
'Email' => "info@cpi.lu",
'Name' => "CPI"
],
'To' => [
[
'Email' => 'info@cpi.lu',
]
],
'Bcc' => [
[
'Email' => 'damien@piranha.lu',
],
[
'Email' => 'thomasbregler@protonmail.com',
],
[
'Email' => $userEmail,
],
],
'Subject' => $subject,
'HTMLPart' => $message,
]
]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success();
return $this->redirectToRoute('app_baseOutils');
}
/**
* @Route("/{locale}/cookies", name="cookies")
*/
public function cookies(): Response
{
return $this->render('default/cookie.html.twig', [
]);
}
/**
* @Route("/{locale}/politique-de-confidentialite", name="politique")
*/
public function politique(SectionsRepository $sectionsRepository, PagesRepository $pagesRepository, TemoignagesRepository $temoignagesRepository): Response
{
$page = $pagesRepository->findOneById(15);
$nb = count($page->getSections()) +1;
$sections = $sectionsRepository->findBy(array('Pages'=>15),array('Ordre'=>'asc'));
return $this->render('default/politique.html.twig', [
'sections' => $sections,
'page'=> $page,
'ordreMax' =>$nb,
'ip' => '90.63.222.84',
'temoignages'=>$temoignagesRepository->findAll()
]);
}
public function findSearch($sujet, $type, $lieu, $ref) {
$query = $this->createQueryBuilder('s'); // s représente votre entité de session
if ($sujet) {
$query->andWhere('s.sujetFormation = :sujet')
->setParameter('sujet', $sujet);
}
if ($type) {
$query->andWhere('s.typeFormation = :type')
->setParameter('type', $type);
}
if ($lieu) {
$query->andWhere('s.lieu = :lieu')
->setParameter('lieu', $lieu);
}
if ($ref) {
$query->andWhere('s.ref = :ref')
->setParameter('ref', $ref);
}
// Continuez pour les autres critères de filtrage
return $query->getQuery()->getResult();
}
/**
* @Route("/{locale}/planning-formation", name="app_planningFormation")
*/
public function planningFormation($locale,FormationsRepository $formationsRepository, VersionsFormationsRepository $versionsFormationsRepository, TypesFormationsRepository $typesFormationsRepository,
SujetsFormationsRepository $sujetsFormationsRepository,LogicielsFormationsRepository $logicielsFormationsRepository, SessionsFormationsRepository $sessionsFormationsRepository, Request $request): Response
{
$formations = $formationsRepository->findBy([], ['Date' => 'ASC']);
$sessionsformations = $sessionsFormationsRepository->findBy([], ['Date' => 'ASC']);
$sessionsformationsAll = $sessionsFormationsRepository->findAll();
$formationsSearch = $formationsRepository->findBy([], ['TitreFr' => 'ASC']);
$typeFormation = $typesFormationsRepository->findAll();
$sujetFormation = $sujetsFormationsRepository->findAll();
$date = $sessionsFormationsRepository->findBy([],['Date'=>'asc']);
$tarifs = $sessionsFormationsRepository->findBy([],['Tarifs'=>'asc']);
$langues = $sessionsFormationsRepository->findBy([],['LanguesFr'=>'asc']);
$sessionsCriteria=[];
$sujetFormation = $sujetsFormationsRepository->findAll();
$typeFormation = $typesFormationsRepository->findAll();
if ($request->query->get('sujet')) {
$sessionsCriteria['SujetsFormations'] = $request->query->get('sujet');
}
if ($request->query->get('type')) {
$sessionsCriteria['TypesFormations'] = $request->query->get('type');
}
if ($request->query->get('lieu')) {
$sessionsCriteria['Lieu'] = $request->query->get('lieu');
}
if ($request->query->get('ref')) {
$sessionsCriteria['TitreFr'] = $request->query->get('ref');
}
$sessionsformations = $sessionsFormationsRepository->findByCriteria($sessionsCriteria);
return $this->render('default/planningFormation.html.twig', [
'formations' => $formations,
'sessionsformationsAll' => $sessionsformationsAll,
'sessionsformations' => $sessionsformations,
'formationsSearch'=>$formationsSearch,
'typeFormation'=>$typeFormation,
'sujetFormation'=>$sujetFormation,
'sujets' => $sujetsFormationsRepository->findBy([], ['TitreFr' => 'ASC']),
'date' => $date,
'tarifs' => $tarifs,
'langues' => $langues,
]);
}
/**
* @Route("/genererpdf/{id}", name="genererpdf")
*/
public function genererpdf(FormationsRepository $formationsRepository,CategoriesFormationsRepository $categoriesFormationsRep,$id): Response
{
$categoriesFormations = $categoriesFormationsRep->findAll();
$forma = $formationsRepository->findOneById($id);
$template = $this->renderView('formationPdf.html.twig', [
'formations' => $formationsRepository->findOneById($id),
'categoriesFormations' => $categoriesFormations
]);
$html2pdf = new Html2Pdf();
$html2pdf->setDefaultFont('dejavusans'); // Définit 'dejavusans' comme police par défaut
$html2pdf->writeHTML($template);
$html2pdf->output('formation_cpi_'.$forma->getReference().'.pdf');
}
/**
* @Route("/genererpdfjobs/{id}", name="genererpdfjob")
*/
public function genererpdfjobs(JobsRepository $jobsRepository,$id): Response
{
$template = $this->renderView('jobsPdf.html.twig', [
'jobs' => $jobsRepository->findOneById($id)
]);
$html2pdf = new Html2Pdf();
$html2pdf->writeHTML($template);
$html2pdf->output();
}
/**
* @Route("/resultat-recherche", name="resultatRecherche")
*/
public function resultatRecherche(ContenusRepository $ContenusRepository, FormationsRepository $FormationsRepository, ActualitesRepository $ActualitesRepository, JobsRepository $JobsRepository): Response
{
$keyword = $_POST['search'];
$contenus = $ContenusRepository->findSearch($keyword);
$formations = $FormationsRepository->findSearch($keyword);
$actualites = $ActualitesRepository->findSearch($keyword);
$jobs = $JobsRepository->findSearch($keyword);
return $this->render('default/resultatRecherche.html.twig', [
'contenus'=>$contenus,
'formations'=>$formations,
'actualites'=>$actualites,
'jobs'=>$jobs
]);
}
/**
* @Route("/search", name="search")
*/
public function search(ContenusRepository $ContenusRepository, FormationsRepository $FormationsRepository, ActualitesRepository $ActualitesRepository, JobsRepository $JobsRepository): Response
{
$keyword = 'Manufacturing';
$contenus = $ContenusRepository->findSearch($keyword);
$formations = $FormationsRepository->findSearch($keyword);
$actualites = $ActualitesRepository->findSearch($keyword);
$jobs = $JobsRepository->findSearch($keyword);
dd($formations);
return new response('ok');
}
}
// $formations = $formationsRepository->findBy([], ['TitreFr' => 'ASC']);
// $formationsSearch = $formationsRepository->findBy([], ['TitreFr' => 'ASC']);
// $date = $sessionsFormationsRepository->findBy([],['Date'=>'asc']);
// if(isset($_GET['sujet']))
// {
// $formations = $formationsRepository->findBy(['SujetsFormations'=>$_GET['sujet']]);
// }
// $selectedSujet = $request->query->get('sujet');
// if ($selectedSujet !== null) {
// // Filter the sessions by the selected sujet
// $formations = $formationsRepository->findBy(['SujetsFormations' => $selectedSujet]);
// }
// $reference = $formationsRepository->findBy([],['Reference'=>'asc']);
// $lieu = $sessionsFormationsRepository->findBy([],['Lieu'=>'desc']);
// $type = $sessionsFormationsRepository->findBy([], ['Type' => 'desc']);
// $tarifs = $sessionsFormationsRepository->findBy([], ['Tarifs' => 'desc']);
// return $this->render('default/planningFormation.html.twig', [
// 'formations' => $formations,
// 'date' => $date,
// 'sujets' =>$sujetsFormationsRepository->findBy([], ['TitreFr' => 'ASC']),
// 'reference' => $reference,
// 'lieu'=>$lieu,
// 'tarifs' => $tarifs,
// 'type' => $type,
// 'catLieu'=>$sessionsFormationsRepository->findBy([], ['Lieu' => 'ASC']),
// 'selectedSujet' => $selectedSujet,
// ]);