src/Controller/Frontend/FrontendController.php line 289

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Frontend;
  3. use App\Entity\Age;
  4. use App\Entity\User;
  5. use App\Entity\Article;
  6. use App\Entity\ArticlePresse;
  7. use App\Entity\Contact;
  8. use App\Entity\ContactRappel;
  9. use App\Entity\Country;
  10. use App\Entity\CroqinfoAbonne;
  11. use App\Entity\DemandeSejourCorse;
  12. use App\Entity\DemandeRappel;
  13. use App\Entity\Departement;
  14. use App\Entity\Newsletter;
  15. use App\Entity\FrontOption;
  16. use App\Entity\Inscription;
  17. use App\Entity\Sejour;
  18. use App\Entity\MediaCategorie;
  19. use App\Entity\Media;
  20. use App\Entity\Saison;
  21. use App\Entity\Theme;
  22. use App\Entity\VilleDesservie;
  23. use App\Form\InscriptionStartType;
  24. use App\Form\ContactRappelType;
  25. use App\Form\CroqinfoAbonnementType;
  26. use App\Form\DemandeSejourCorseType;
  27. use App\Message\SendEmailMessage;
  28. use App\Repository\ArticlePresseRepository;
  29. use App\Repository\SejourRepository;
  30. use App\Repository\FrontOptionRepository;
  31. use App\Utility\UpdateParticipantSession;
  32. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  33. use Symfony\Component\HttpFoundation\Response;
  34. use Symfony\Component\HttpFoundation\Request;
  35. use Symfony\Component\Routing\Annotation\Route;
  36. use Doctrine\ORM\EntityManagerInterface;
  37. use Knp\Component\Pager\PaginatorInterface;
  38. use Presta\SitemapBundle\Controller\SitemapController;
  39. use Presta\SitemapBundle\Event\SitemapPopulateEvent;
  40. use Presta\SitemapBundle\Sitemap\Sitemapindex;
  41. use Symfony\Component\HttpFoundation\JsonResponse;
  42. use Symfony\Component\Messenger\MessageBusInterface;
  43. use Symfony\Contracts\HttpClient\HttpClientInterface;
  44. use Vich\UploaderBundle\Templating\Helper\UploaderHelper;
  45. use Symfony\Component\Serializer\Encoder\JsonEncoder;
  46. use Symfony\Component\Serializer\Normalizer\JsonLdNormalizer;
  47. use App\Entity\SejourSession;
  48. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  49. use Symfony\Contracts\Cache\CacheInterface;
  50. use Symfony\Contracts\Cache\ItemInterface;
  51. use App\Form\ContactPropertyValueType;
  52. use App\Entity\ContactPropertyValue;
  53. use App\Entity\Commande;
  54. use Symfony\Component\Mailer\MailerInterface;
  55. use Symfony\Component\Mime\Email;
  56. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  57. use Symfony\Component\Mime\Address;
  58. use Twig\Environment;
  59. use Twig\Loader\FilesystemLoader;
  60. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  61. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  62. class FrontendController extends AbstractController
  63. {
  64. /**
  65. * @Route("/date", name="frontend_date",options={"sitemap" = false})
  66. */
  67. public function showdate(): Response
  68. {
  69. date_default_timezone_set('Europe/Paris');
  70. $dateTime = new \DateTime('now', new \DateTimeZone('Europe/Paris'));
  71. $date = new \DateTime(); // create a new date object
  72. $dateString = $date->format('Y-m-d H:i:s'); // format the date as a string
  73. return new Response($dateString);
  74. }
  75. /**
  76. * @Route("/", name="frontend_homepage",options={"sitemap" = true})
  77. */
  78. public function index(EntityManagerInterface $em): Response
  79. {
  80. $monOption = $em->getRepository(FrontOption::class)->findOneBy(['name' => 'sejoursAccueil']);
  81. $ids = $monOption !== null ? $monOption->getContent() : [];
  82. $output = [];
  83. foreach ($ids as $id) {
  84. $output[] = $em->getRepository(Sejour::class)->findOneById($id);
  85. }
  86. $header = $em->getRepository(Article::class)->findOneByTitle('Header');
  87. return $this->render('frontend/index.html.twig', [
  88. 'sejours' => $output,
  89. 'footer_seo' => $em->getRepository(Article::class)->findOneBy(['title' => 'footer']),
  90. 'headerMain' => $header
  91. ]);
  92. }
  93. /**
  94. * @Route("/merci", name="merci")
  95. */
  96. public function merci()
  97. {
  98. if ($this->getUser() !== null)
  99. return $this->redirectToRoute('frontend_homepage');
  100. return $this->render('frontend/merci.html.twig');
  101. }
  102. /**
  103. * @Route("/validateProperty", name="validateProperty")
  104. */
  105. public function validateProperty(Request $request, EntityManagerInterface $em)
  106. {
  107. $property = $em->getRepository(ContactPropertyValue::class)->findOneById($request->get('id'));
  108. if($property == null)
  109. return new JsonResponse(['ok']);
  110. $property->setValue($request->get('value'));
  111. if ($property->getProperty()->getValidationClass() == null)
  112. return new JsonResponse(['ok' => '']);
  113. $enfant = $property->getContact();
  114. $this->denyAccessUnlessGranted('view', $enfant);
  115. $form = $this->createForm(ContactPropertyValueType::class, $property);
  116. $form->submit($request->request->all());
  117. //$form->add('Sauver', SubmitType::class, ['attr' => ['class' => 'button bounce item-sejour__button'],'label'=>'Enregistrer et Sauver']);
  118. $form->handleRequest($request);
  119. if (!$form->isValid()) {
  120. $vcString = $property->getProperty()->getValidationClass();
  121. if ($vcString !== null) {
  122. $vc = new $vcString();
  123. if (!$vc->validate($property->getValue()))
  124. return new JsonResponse(['error' => $vc->getErrorMessage()]);
  125. }
  126. }
  127. return new JsonResponse(['ok']);
  128. }
  129. /**
  130. * @Route("/croqinfos.html",name="frontend_croqinfos",options={"sitemap" = true})
  131. */
  132. public function croqinfos(EntityManagerInterface $em, Request $request, MessageBusInterface $bus): Response
  133. {
  134. $abonne = new CroqinfoAbonne();
  135. $form = $this->createForm(CroqinfoAbonnementType::class, $abonne);
  136. $mediaType = $em->getRepository(MediaCategorie::class)->findOneBy(['name' => 'Documentation']);
  137. $medias = $em->getRepository(Media::class)->findBy(
  138. ['mediaCategorie' => $mediaType],
  139. ['position' => 'ASC']
  140. );
  141. $form->handleRequest($request);
  142. if ($form->isSubmitted() and $form->isValid()) {
  143. $em->persist($abonne);
  144. $em->flush();
  145. $bus->dispatch((new SendEmailMessage('inscription_croqinfo', Abonnee::class, $abonne->getId())));
  146. $this->addFlash('success', 'Votre demande d\'abonnement est bien prise en compte');
  147. }
  148. return $this->render('frontend/croqinfos.html.twig', [
  149. 'medias' => $medias,
  150. 'form' => $form->createView()
  151. ]);
  152. }
  153. /**
  154. * @Route("/catalogue-en-ligne.html", name="frontend_catalogue-en-ligne",options={"sitemap" = true})
  155. */
  156. public function catalogueEnLigne(EntityManagerInterface $em): Response
  157. {
  158. $photos = $em->getRepository(Media::class)->findByMediaCategorie('CataloguePhoto');
  159. $pdf = $em->getRepository(Media::class)->findByMediaCategorie('Catalogue');
  160. return $this->render('frontend/catalogue_en_ligne.html.twig', [
  161. 'photos' => $photos,
  162. 'pdf' => $pdf,
  163. ]);
  164. }
  165. /**
  166. * @Route("/contact.html", name="frontend_contact",options={"sitemap" = true})
  167. */
  168. public function contact(EntityManagerInterface $em, Request $request, MessageBusInterface $bus)
  169. {
  170. $demandeContact = new DemandeRappel();
  171. $form = $this->createForm(\App\Form\FormulaireContactType::class, $demandeContact);
  172. $pa = $em->getRepository(Media::class)->findOneByMediaCategorie('plan_acces');
  173. $text = $em->getRepository(Article::class)->findOneBy(['title' => 'Permanences téléphoniques']);
  174. $form->handleRequest($request);
  175. if ($form->isSubmitted() and $form->isValid()) {
  176. $formData = $form->getData();
  177. if (property_exists($formData, 'nom') && is_string($formData->getNom())) {
  178. $formData->setNom(strtoupper($formData->getNom()));
  179. }
  180. if (property_exists($formData, 'nom_enfant') && is_string($formData->getNomEnfant())) {
  181. $formData->setNomEnfant(strtoupper($formData->getNomEnfant()));
  182. }
  183. if (property_exists($formData, 'prenom') && is_string($formData->getPrenom())) {
  184. $formData->setPrenom(ucfirst(strtolower($formData->getPrenom())));
  185. }
  186. if (property_exists($formData, 'prenom_enfant') && is_string($formData->getPrenomEnfant())) {
  187. $formData->setPrenomEnfant(ucfirst(strtolower($formData->getPrenomEnfant())));
  188. }
  189. $em->persist($formData);
  190. $em->flush();
  191. $this->addFlash('success', 'Merci pour votre demande, nous reviendrons vers vous dès que possible.');
  192. $bus->dispatch(new SendEmailMessage('demandeContact', '', $demandeContact->getId(),'0testingall@gmail.com'));
  193. // $bus->dispatch(new SendEmailMessage('demandeContact', '', $demandeContact->getId(),$this->getParameter('email_accueil')));
  194. // $bus->dispatch(new SendEmailMessage('demandeContact', '', $demandeContact->getId(),$this->getParameter('email_info_')));
  195. $bus->dispatch(new SendEmailMessage('accuseReception', '', $demandeContact->getId(), $demandeContact->getEmail()));
  196. }
  197. return $this->render('frontend\contact.html.twig', ['form' => $form->createView(), 'acces' => $pa, 'text' => $text]);
  198. }
  199. /**
  200. * @Route("/contact-rappel", name="frontend_contact_rappel",options={"sitemap" = true})
  201. */
  202. public function contactRappel(Request $request, EntityManagerInterface $em, MessageBusInterface $bus)
  203. {
  204. $contactRappel = new ContactRappel();
  205. $form = $this->createForm(ContactRappelType::class, $contactRappel);
  206. $pa = $em->getRepository(Media::class)->findOneByMediaCategorie('plan_acces');
  207. $text = $em->getRepository(Article::class)->findOneBy(['title' => 'Permanences téléphoniques']);
  208. $form->handleRequest($request);
  209. if ($form->isSubmitted() and $form->isValid()) {
  210. $formData = $form->getData();
  211. if (property_exists($formData, 'name') && is_string($formData->getName())) {
  212. $formData->setName(strtoupper($formData->getName()));
  213. }
  214. if (property_exists($formData, 'nom_enfant') && is_string($formData->getNomEnfant())) {
  215. $formData->setNomEnfant(strtoupper($formData->getNomEnfant()));
  216. }
  217. if (property_exists($formData, 'prenom') && is_string($formData->getPrenom())) {
  218. $formData->setPrenom(ucfirst(strtolower($formData->getPrenom())));
  219. }
  220. if (property_exists($formData, 'prenom_enfant') && is_string($formData->getPrenomEnfant())) {
  221. $formData->setPrenomEnfant(ucfirst(strtolower($formData->getPrenomEnfant())));
  222. }
  223. $em->persist($formData);
  224. $em->flush();
  225. $this->addFlash('success', 'Merci pour votre demande, nous reviendrons vers vous dès que possible.');
  226. $bus->dispatch(new SendEmailMessage('demandeRappel', '', $contactRappel->getId()));
  227. }
  228. return $this->render('frontend/rappel.html.twig', ['form' => $form->createView(), 'pageTitle' => 'C\'est occupé? On vous rappelle']);
  229. }
  230. /**
  231. * @Route("/colonie-vacances-petit-prix.html", name="frontend_colonie-vacances-petit-prix",options={"sitemap" = true})
  232. */
  233. public function ColonieVacancesPetitPrix(EntityManagerInterface $em): Response
  234. {
  235. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Des colonies de vacances à des prix accessibles']);
  236. $liste = $em->getRepository(FrontOption::class)->findOneBy(['name' => 'sejourPrixMini']);
  237. $sejours = $em->getRepository(Sejour::class)->findBy(['id' => $liste->getContent()]);
  238. return $this->render('frontend/actualite/showArticle.html.twig', [
  239. 'article' => $article,
  240. 'sejourTitle' => 'Sélection de séjours Petits budgets',
  241. 'sejours' => $sejours
  242. ]);
  243. }
  244. /**
  245. * @Route("/conditions-de-vente", name="frontend_conditions-de-vente",options={"sitemap" = true})
  246. */
  247. public function ConditionsDeVente(EntityManagerInterface $em): Response
  248. {
  249. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Conditions générales d\'inscription']);
  250. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  251. }
  252. /**
  253. * @Route("/GPRD", name="frontend_gprd",options={"sitemap" = true})
  254. * @Route("/RGPD", name="frontend_gprd",options={"sitemap" = true})
  255. */
  256. public function GPRD(EntityManagerInterface $em): Response
  257. {
  258. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'La protection de vos données personnelles']);
  259. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  260. }
  261. /**
  262. * @Route("/charte-de-qualite.html", name="frontend_charte-de-qualite",options={"sitemap" = true})
  263. */
  264. public function CharteQualite(EntityManagerInterface $em): Response
  265. {
  266. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Notre charte « Qualité »']);
  267. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  268. }
  269. /**
  270. * @Route("/nos-garanties.html", name="frontend_nos-garanties",options={"sitemap" = true})
  271. */
  272. public function NosGaranties(EntityManagerInterface $em): Response
  273. {
  274. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Garanties de nos colonies de vacances']);
  275. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  276. }
  277. /**
  278. * @Route("projet-educatif.html", name="frontend_projet-educatif",options={"sitemap" = true})
  279. */
  280. public function ProjetEducatif(EntityManagerInterface $em): Response
  281. {
  282. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Projet éducatif']);
  283. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  284. }
  285. /**
  286. * @Route("/projet-ecocitoyen", name="frontend_charte-ecologique",options={"sitemap" = true})
  287. */
  288. public function CharteEcologique(EntityManagerInterface $em): Response
  289. {
  290. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Projet éco-citoyen Croq’ Vacances']);
  291. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  292. }
  293. /**
  294. * @Route("/avant-de-partir.html", name="frontend_avant-de-partir",options={"sitemap" = true})
  295. */
  296. public function AvantDePartir(EntityManagerInterface $em): Response
  297. {
  298. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Bon à savoir avant de partir en colonie de vacances !']);
  299. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  300. }
  301. /**
  302. * @Route("/info-vie-du-groupe-colonie-de-vacances.html", name="frontend_vie-du-groupe",options={"sitemap" = true})
  303. */
  304. public function VieDuGroupe(EntityManagerInterface $em): Response
  305. {
  306. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Vie du groupe']);
  307. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  308. }
  309. /**
  310. * @Route("/info-encadrement-colonie-de-vacances.html", name="frontend_encadrement",options={"sitemap" = true})
  311. */
  312. public function Encadrement(EntityManagerInterface $em): Response
  313. {
  314. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'L\'encadrement des colonies de vacances']);
  315. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  316. }
  317. /**
  318. * @Route("/conditions-de-vente-ce.html", name="frontend_conditions_ce",options={"sitemap" = true})
  319. */
  320. public function ConditionsCE(EntityManagerInterface $em): Response
  321. {
  322. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Conditions générales d\'inscription réservées aux CSE, Administrations, Écoles et Œuvres Sociales']);
  323. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  324. }
  325. /**
  326. * @Route("/info-communication-colonie-de-vacances.html", name="frontend_communication",options={"sitemap" = true})
  327. */
  328. public function Communication(EntityManagerInterface $em): Response
  329. {
  330. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Gardez le Contact']);
  331. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  332. }
  333. /**
  334. * @Route("/aide-financiere.html", name="frontend_aide-financiere",options={"sitemap" = true})
  335. */
  336. public function AideFinanciere(EntityManagerInterface $em): Response
  337. {
  338. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Les aides financières pour un séjour à croq’ vacances']);
  339. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  340. }
  341. /**
  342. * @Route("/isLogged", name="frontend_is_logged")
  343. */
  344. public function isLogged(): Response
  345. {
  346. if ($this->getUser() !== null)
  347. return new JsonResponse(true);
  348. return new JsonResponse(false);
  349. }
  350. /**
  351. * @Route("/infos-legales.html", name="frontend_infos-legales",options={"sitemap" = true})
  352. */
  353. public function InfoLegales(EntityManagerInterface $em): Response
  354. {
  355. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Mentions légales']);
  356. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  357. }
  358. /**
  359. * @Route("/conditions-de-vente.html", name="frontend_conditions-vente",options={"sitemap" = true})
  360. */
  361. public function CGU(EntityManagerInterface $em): Response
  362. {
  363. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Conditions générales d\'inscription']);
  364. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  365. }
  366. /**
  367. * @Route("/edito-du-president.html", name="frontend_edito-president",options={"sitemap" = true})
  368. */
  369. public function MotPresident(EntityManagerInterface $em): Response
  370. {
  371. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Le Mot du Président']);
  372. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  373. }
  374. /**
  375. * @Route("/historique-de-l-association.html", name="frontend_historique-association",options={"sitemap" = true})
  376. */
  377. public function Historique(EntityManagerInterface $em): Response
  378. {
  379. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Historique de l\'association']);
  380. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  381. }
  382. /**
  383. * @Route("/info-alimentation-en-colonie-de-vacances.html", name="frontend_info-alimentation-en-colonie-de-vacances",options={"sitemap" = true})
  384. */
  385. public function Alimentation(EntityManagerInterface $em): Response
  386. {
  387. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'L\'alimentation']);
  388. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  389. }
  390. /**
  391. * @Route("/info-organisation-colonie-de-vacances.html", name="frontend_transport",options={"sitemap" = true})
  392. */
  393. public function Transport(EntityManagerInterface $em): Response
  394. {
  395. $article = $em->getRepository(Article::class)->findOneBy(['title' => 'Le transport']);
  396. return $this->render('frontend/actualite/showArticle.html.twig', ['article' => $article]);
  397. }
  398. /**
  399. * @Route("/newsletter.html", name="inscription_newsletter",options={"sitemap" = true})
  400. */
  401. public function inscriptionNewsletter(
  402. Request $request,
  403. EntityManagerInterface $em,
  404. UserPasswordEncoderInterface $passwordEncoder
  405. ) {
  406. if ($request->isMethod('GET')) {
  407. return $this->render('frontend/merciNewsletter.html.twig');
  408. }
  409. $contactInfo = $this->getParameter('mailjet');
  410. $apiKey = $contactInfo['apiKey'];
  411. $secretKey = $contactInfo['secretKey'];
  412. // Compte partagé "assocroqvacances@gmail.com"
  413. // Liste de contacts "Abonnements"
  414. $contacts_id = '1';
  415. $subscriberEmail = $request->get('email');
  416. if ($this->validateEmail($subscriberEmail)) {
  417. $newsletterDone = $em->getRepository(Newsletter::class)->findOneByEmail($subscriberEmail);
  418. if ($newsletterDone !== null)
  419. return $this->render('frontend/merciNewsletter.html.twig');
  420. $newsletter = new Newsletter();
  421. $newsletter->setEmail($subscriberEmail);
  422. $newsletter->setCreationDate(new \DateTime());
  423. $em->persist($newsletter);
  424. $em->flush();
  425. $curl_handle = curl_init();
  426. curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
  427. curl_setopt($curl_handle, CURLOPT_USERPWD, $apiKey . ':' . $secretKey);
  428. curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array(
  429. 'Content-Type: application/json'
  430. ));
  431. // recherche du contact
  432. $url = 'https://api.mailjet.com/v3/REST/contact/' . $subscriberEmail;
  433. curl_setopt($curl_handle, CURLOPT_URL, $url);
  434. curl_setopt($curl_handle, CURLOPT_POST, 0);
  435. $buffer = curl_exec($curl_handle);
  436. $contact = json_decode($buffer);
  437. if (!isset($contact->Data[0]->ID)) {
  438. // création du contact
  439. $url = 'https://api.mailjet.com/v3/REST/contact';
  440. curl_setopt($curl_handle, CURLOPT_URL, $url);
  441. curl_setopt($curl_handle, CURLOPT_POSTFIELDS, json_encode(array(
  442. 'Email' => $subscriberEmail,
  443. )));
  444. curl_setopt($curl_handle, CURLOPT_POST, 1);
  445. $buffer = curl_exec($curl_handle);
  446. $contact = json_decode($buffer);
  447. }
  448. if ($contact !== null) {
  449. // ajout du contact à la liste
  450. $url = 'https://api.mailjet.com/v3/REST/listrecipient';
  451. curl_setopt($curl_handle, CURLOPT_URL, $url);
  452. curl_setopt($curl_handle, CURLOPT_POST, 1);
  453. curl_setopt($curl_handle, CURLOPT_POSTFIELDS, json_encode(array(
  454. 'ContactID' => $contact->Data[0]->ID,
  455. 'ListID' => $contacts_id
  456. )));
  457. $buffer = curl_exec($curl_handle);
  458. $response_code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
  459. curl_close($curl_handle);
  460. $em->flush();
  461. }
  462. }
  463. return $this->render('frontend/merciNewsletter.html.twig');
  464. }
  465. /**
  466. * @Route("sessionphotos", name="sessionPhotoCode-detail")
  467. */
  468. public function sessionPhotoCode(Request $request, EntityManagerInterface $em)
  469. {
  470. if ($request->isMethod('POST')) {
  471. $code = $request->request->get('code');
  472. $sejourSession = $em->getRepository(SejourSession::class)->findOneBy(['codeGen' => $code]);
  473. return $this->render('frontend/sessionphotos.html.twig', ['sejourSession' => $sejourSession]);
  474. }
  475. return $this->render('frontend/sessionphotos.html.twig');
  476. }
  477. /**
  478. * @Route("colonie-de-vacances-{slug}_{id}.html", name="frontend_colonie-detail")
  479. */
  480. public function colonieDetail(Request $request, SejourRepository $sr, $slug, $id, UpdateParticipantSession $ups, UploaderHelper $helper, FrontOptionRepository $frontRepo)
  481. {
  482. $referer = $request->headers->get('referer');
  483. $sejour = $sr->findOneById($id);
  484. if (!$sejour || $sejour->getIsActive() == 0) {
  485. throw $this->createNotFoundException('The product does not exist');
  486. }
  487. foreach ($sejour->getSejourSessions() as $session) {
  488. $ups->updateSingleSejourSession($session);
  489. }
  490. $phrase = $frontRepo->findOneByName('phrase');
  491. $title = $sejour->getTitle() . " " . $sejour->getSaisons()[0]->getTitle() . " " . $sejour->getSaisons()[0]->getAnneeAffichee() . " - Croq' Vacances";
  492. $description = strip_tags(str_replace('</li>', ',', $sejour->getDescription()));
  493. $descriptionArray = explode(",", $description);
  494. $descriptionOutput = "";
  495. foreach ($descriptionArray as $desc) {
  496. if (strlen($descriptionOutput) > 160) continue;
  497. $descriptionOutput .= $desc . " , ";
  498. }
  499. $inscription = new Inscription();
  500. $form = $this->createForm(InscriptionStartType::class, $inscription, ['sejour' => $sejour]);
  501. $media = $sejour->getMedias();
  502. $img_path = "";
  503. try {
  504. $img1 = $media[0];
  505. $img_path = $helper->asset($img1);
  506. } catch (\Throwable $th) {
  507. //throw $th;
  508. }
  509. $jsonLd = [
  510. "@context" => "http://schema.org",
  511. "@type" => "Product",
  512. "brand" => "Croqvacances",
  513. "description" => html_entity_decode(str_replace(array("\r", "\n"), '', $description), ENT_QUOTES | ENT_HTML5, 'UTF-8'),
  514. "name" => $sejour->getTitle(),
  515. "image" => "https://{$_SERVER['HTTP_HOST']}{$img_path}",
  516. "offers" => [
  517. "@type" => "Offer",
  518. "availability" => "http://schema.org/InStock",
  519. "price" => $sejour->getMinPrice(),
  520. "priceCurrency" => "EUR"
  521. ]
  522. ];
  523. $jsonLdScript = sprintf('<script type="application/ld+json">%s</script>', json_encode($jsonLd, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
  524. return $this->render('frontend/sejour.html.twig', [
  525. 'sejour' => $sejour,
  526. 'form' => $form->createView(),
  527. 'referer' => $referer,
  528. 'seo' => ['title' => $title, 'description' => substr($descriptionOutput, 0, -3)],
  529. 'jsonLdScript' => $jsonLdScript,
  530. 'phrase' => $phrase
  531. ]);
  532. }
  533. public function sejoursOrder(EntityManagerInterface $em, CacheInterface $cache)
  534. {
  535. $cache->get('sejours_order_last_execution', function (ItemInterface $item) use ($em) {
  536. $lastExecutionTimestamp = $item->get();
  537. if (!$lastExecutionTimestamp || (time() - $lastExecutionTimestamp) >= 86400) { // 86400 seconds = 1 day
  538. $dql = "SELECT s FROM App\Entity\Sejour s WHERE s.isActive = true ORDER BY s.position ASC";
  539. $query = $em->createQuery($dql);
  540. $sejours = $query->getResult();
  541. $now = new \DateTime(); // Get the current date and time
  542. foreach ($sejours as $sejour) {
  543. $sejour->setBientot(true);
  544. foreach ($sejour->getSejourSessions() as $session) {
  545. if ($session->getDatedebut() >= $now) {
  546. $sejour->setBientot(false);
  547. // $sejour->setPosition(0);
  548. break;
  549. }
  550. }
  551. }
  552. $item->set(time());
  553. $em->flush();
  554. }
  555. });
  556. }
  557. /**
  558. * @Route("/colonie-de-vacances", name="frontend_resa_liste_colonies",options={"sitemap" = true})
  559. * @Route("/liste-des-colonies/", name="frontend_resa_liste_colonies2",options={"sitemap" = false})
  560. */
  561. public function listeDesColonies(EntityManagerInterface $em, PaginatorInterface $paginator, Request $request, CacheInterface $cache): Response
  562. {
  563. $this->sejoursOrder($em, $cache);
  564. $dql = "SELECT s FROM App\Entity\Sejour s WHERE s.isActive = true ORDER BY s.isBientot ASC, s.position ASC";
  565. $query = $em->createQuery($dql);
  566. $pageNumber = $request->query->getInt('page', 1);
  567. $pagination = $paginator->paginate(
  568. $query,
  569. $pageNumber,
  570. 11
  571. );
  572. $theme = $em->getRepository(Theme::class)->findOneByTitle('general');
  573. $annee = $em->getRepository(FrontOption::class)->findOneBy(['name' => 'anneGenerale'])->getContent();
  574. $dql_data = "SELECT count(s) as offerCount , MIN(s.price) as min_price , MAX(s.price) as max_price FROM App\Entity\Sejour s WHERE s.isActive = true ORDER BY s.position ASC";
  575. $query_data = $em->createQuery($dql_data);
  576. $json_data = $query_data->getSingleResult();
  577. $jsonLd = [
  578. "@context" => "http://schema.org",
  579. "@type" => "Product",
  580. "name" => "Colonies de vacances",
  581. "offers" => [
  582. "@type" => "AggregateOffer",
  583. "lowPrice" => $json_data['min_price'],
  584. "highPrice" => $json_data['max_price'],
  585. "offerCount" => $json_data['offerCount'],
  586. "priceCurrency" => "EUR"
  587. ]
  588. ];
  589. $jsonLdScript = sprintf('<script type="application/ld+json">%s</script>', json_encode($jsonLd, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
  590. return $this->render('frontend/resa/index.html.twig', [
  591. 'pagination' => $pagination,
  592. 'title' => 'Liste de nos colonies de vacances ' . $annee,
  593. 'theme' => $theme,
  594. 'noIndex' => $pageNumber > 1,
  595. 'jsonLdScript' => $jsonLdScript
  596. ]);
  597. }
  598. /**
  599. * @Route("colonie-de-vacances/{path}", name="frontend_resa_dynamique_liste_colonies", requirements={"path"=".+"})
  600. */
  601. public function dynamiqueListeColonies($path, PaginatorInterface $paginator, EntityManagerInterface $em, UploaderHelper $helper, Request $request)
  602. {
  603. $keywords = explode("/", $path);
  604. $annee = $em->getRepository(FrontOption::class)->findOneBy(['name' => 'anneGenerale'])->getContent();
  605. $searchKW = [];
  606. $searchKW['saison'] = $em->getRepository(Saison::class)->findOneBy(['title' => $keywords]);
  607. $searchKW['theme'] = $em->getRepository(Theme::class)->findOneBy(['slug' => $keywords, 'isActivite' => false]);
  608. $searchKW['activite'] = $em->getRepository(Theme::class)->findOneBy(['slug' => $keywords, 'isActivite' => true]);
  609. $searchKW['age'] = $em->getRepository(Age::class)->findOneBy(['slug' => $keywords]);
  610. $searchKW['location'] = $em->getRepository(Country::class)->findOneBy(['slug' => $keywords]);
  611. $searchKW['villeDesservie'] = $em->getRepository(VilleDesservie::class)->findOneBy(['slug' => $keywords,'isActive'=>true]);
  612. $query = $em->getRepository(Sejour::class)->colonieSearch($searchKW);
  613. // var_dump($json_data);
  614. // return new Response("");
  615. $pagination = $paginator->paginate(
  616. $query, /* query NOT result */
  617. $request->query->getInt('page', 1), /* page number */
  618. 11, /* limit per page */
  619. );
  620. $noIndex = $request->query->getInt('page') >= 1;
  621. $pageId = $request->query->getInt('page', 1);
  622. if ($searchKW["saison"] !== null)
  623. $annee = $searchKW["saison"]->getAnneeAffichee();
  624. $title = "Colonies de vacances " . implode(', ', $keywords) . " " . $annee;
  625. $hassecond = false;
  626. if (count(array_filter($searchKW)) > 1) {
  627. $theme = $em->getRepository(Theme::class)->findOneByTitle("second niveau");
  628. $hassecond = true;
  629. $title = "Colonies de vacances ";
  630. foreach (array_filter($searchKW) as $key => $entity) {
  631. switch ($key) {
  632. case "age":
  633. $title .= " à partir de " . $entity->getTitle();
  634. break;
  635. case "villeDesservie":
  636. $title .= " au départ de " . $entity->getTitle();
  637. break;
  638. case "saison":
  639. $annee = $entity->getAnneeAffichee();
  640. $title .= " " . $entity->getTitle() . " " . $annee;
  641. break;
  642. default:
  643. $title .= " " . $entity->getTitle();
  644. }
  645. }
  646. $noIndex = true;
  647. } elseif (count(array_filter($searchKW)) == 1) {
  648. $theme = array_values(array_filter($searchKW))[0];
  649. $title = "Colonies de vacances ";
  650. foreach (array_filter($searchKW) as $key => $entity) {
  651. switch ($key) {
  652. case "age":
  653. $title .= " à partir de " . $entity->getTitle();
  654. break;
  655. case "villeDesservie":
  656. $title .= " au départ de " . $entity->getTitle();
  657. break;
  658. case "saison":
  659. $annee = $entity->getAnneeAffichee();
  660. $title .= " " . $entity->getTitle() . " " . $annee;
  661. break;
  662. default:
  663. $title .= " " . $entity->getTitle();
  664. }
  665. }
  666. } else {
  667. $theme = $em->getRepository(Theme::class)->findOneByTitle('general');
  668. }
  669. $maxPrice = 0;
  670. $minPrice = 0;
  671. $img_path = null;
  672. foreach ($pagination as $item) {
  673. // Assuming each item has a 'price' property, adjust the property name accordingly
  674. if ($item->hasFutureSejourSessions() && !$item->isFutureComplete()) {
  675. $price = $item->getMinPrice();
  676. if ($maxPrice === 0 || $price > $maxPrice) {
  677. $maxPrice = $price;
  678. }
  679. if ($minPrice === 0 || $price < $minPrice) {
  680. $minPrice = $price;
  681. }
  682. if ($img_path == null) {
  683. $media = $item->getMedias();
  684. try {
  685. $img1 = $media[0];
  686. $img_path = $helper->asset($img1);
  687. } catch (\Throwable $th) {
  688. //throw $th;
  689. }
  690. }
  691. }
  692. }
  693. $jsonLd = [
  694. "@context" => "http://schema.org",
  695. "@type" => "Product",
  696. "name" => "Colonies de vacances",
  697. "image" => "https://{$_SERVER['HTTP_HOST']}{$img_path}",
  698. "offers" => [
  699. "@type" => "AggregateOffer",
  700. "lowPrice" => $minPrice == 0 ? "Bientot" : $minPrice,
  701. "highPrice" => $maxPrice == 0 ? "Bientot" : $maxPrice,
  702. "offerCount" => count($pagination),
  703. "priceCurrency" => "EUR"
  704. ]
  705. ];
  706. $jsonLdScript = sprintf('<script type="application/ld+json">%s</script>', json_encode($jsonLd, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
  707. return $this->render('frontend/resa/index.html.twig', [
  708. 'pagination' => $pagination,
  709. 'title' => $title,
  710. 'theme' => $theme,
  711. 'noIndex' => $noIndex,
  712. 'searchKW' => $searchKW,
  713. 'hassecond' => $hassecond,
  714. 'jsonLdScript' => $jsonLdScript,
  715. ]);
  716. }
  717. /**
  718. * @Route("/colonie-de-vacances-autour-de-moi", name="frontend_resa_liste_colonies_map",options={"sitemap" = true})
  719. */
  720. public function listeDesColoniesMap(EntityManagerInterface $em, PaginatorInterface $paginator, Request $request, CacheInterface $cache): Response
  721. {
  722. $this->sejoursOrder($em, $cache);
  723. $min = $request->query->get('min');
  724. $max = $request->query->get('max');
  725. if ($min !== null && $max !== null) {
  726. $dql = "SELECT s FROM App\Entity\Sejour s join s.sejourSessions ss WHERE s.isActive = true and ss.prix >= $min and ss.prix <= $max ORDER BY s.isBientot ASC, s.position ASC";
  727. } else {
  728. $dql = "SELECT s FROM App\Entity\Sejour s WHERE s.isActive = true ORDER BY s.isBientot ASC, s.position ASC";
  729. }
  730. $query = $em->createQuery($dql);
  731. $pageNumber = $request->query->getInt('page', 1);
  732. $pagination = $paginator->paginate(
  733. $query, /* query NOT result */
  734. $request->query->getInt('page', 1), /* page number */
  735. 10, /* limit per page */
  736. );
  737. // $sejours = $query->getResult();
  738. $theme = $em->getRepository(Theme::class)->findOneByTitle('general');
  739. $annee = $em->getRepository(FrontOption::class)->findOneBy(['name' => 'anneGenerale'])->getContent();
  740. $dql_data = "SELECT count(s) as offerCount , MIN(s.price) as min_price , MAX(s.price) as max_price FROM App\Entity\Sejour s WHERE s.isActive = true ORDER BY s.position ASC";
  741. $query_data = $em->createQuery($dql_data);
  742. $json_data = $query_data->getSingleResult();
  743. $jsonLd = [
  744. "@context" => "http://schema.org",
  745. "@type" => "Product",
  746. "name" => "Colonies de vacances",
  747. "offers" => [
  748. "@type" => "AggregateOffer",
  749. "lowPrice" => $json_data['min_price'],
  750. "highPrice" => $json_data['max_price'],
  751. "offerCount" => $json_data['offerCount'],
  752. "priceCurrency" => "EUR"
  753. ]
  754. ];
  755. $jsonLdScript = sprintf('<script type="application/ld+json">%s</script>', json_encode($jsonLd, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
  756. return $this->render('frontend/sejour_map.html.twig', [
  757. 'pagination' => $pagination,
  758. // 'sejours' => $sejours,
  759. 'title' => 'Liste de nos colonies de vacances ' . $annee,
  760. 'theme' => $theme,
  761. 'noIndex' => $pageNumber > 1,
  762. "lowPrice" => $json_data['min_price'],
  763. "highPrice" => $json_data['max_price'],
  764. 'jsonLdScript' => $jsonLdScript
  765. ]);
  766. }
  767. /**
  768. * @Route("/colonie-de-vacances-autour-de-moi/{path}", name="frontend_resa_dynamique_liste_colonies_map", requirements={"path"=".+"})
  769. */
  770. public function dynamiqueListeColoniesMap($path, PaginatorInterface $paginator, EntityManagerInterface $em, Request $request)
  771. {
  772. $keywords = explode("/", $path);
  773. $annee = $em->getRepository(FrontOption::class)->findOneBy(['name' => 'anneGenerale'])->getContent();
  774. $searchKW = [];
  775. $searchKW['saison'] = $em->getRepository(Saison::class)->findBy(['title' => $keywords]);
  776. $searchKW['theme'] = $em->getRepository(Theme::class)->findBy(['slug' => $keywords, 'isActivite' => false]);
  777. $searchKW['activite'] = $em->getRepository(Theme::class)->findBy(['slug' => $keywords, 'isActivite' => true]);
  778. $searchKW['age'] = $em->getRepository(Age::class)->findOneBy(['slug' => $keywords]);
  779. $searchKW['location'] = $em->getRepository(Country::class)->findBy(['slug' => $keywords]);
  780. $searchKW['villeDesservie'] = $em->getRepository(VilleDesservie::class)->findBy(['slug' => $keywords]);
  781. $min = $request->query->get('min');
  782. $max = $request->query->get('max');
  783. if ($min == null || $max == null) {
  784. $min = 0;
  785. $max = 9999999999;
  786. }
  787. $query = $em->getRepository(Sejour::class)->colonieWithORSearch($searchKW, $min, $max);
  788. $pagination = $paginator->paginate(
  789. $query,
  790. $request->query->getInt('page', 1),
  791. 10,
  792. );
  793. // $sejours = $query->getResult();
  794. $noIndex = $request->query->getInt('page') >= 1;
  795. $pageId = $request->query->getInt('page', 1);
  796. // if ($searchKW["saison"] !== null)
  797. // $annee = $searchKW["saison"]->getAnneeAffichee();
  798. $title = "Colonies de vacances " . implode(', ', $keywords) . " " . $annee;
  799. $hassecond = false;
  800. if (count(array_filter($searchKW)) > 1) {
  801. $theme = $em->getRepository(Theme::class)->findOneByTitle("second niveau");
  802. $hassecond = true;
  803. $title = "Colonies de vacances ";
  804. // foreach (array_filter($searchKW) as $key => $entity) {
  805. // switch ($key) {
  806. // case "age":
  807. // $title .= " à partir de " . $entity->getTitle();
  808. // break;
  809. // case "villeDesservie":
  810. // $title .= " au départ de " . $entity->getTitle();
  811. // break;
  812. // case "saison":
  813. // $annee = $entity->getAnneeAffichee();
  814. // $title .= " " . $entity->getTitle() . " " . $annee;
  815. // break;
  816. // default:
  817. // $title .= " " . $entity->getTitle();
  818. // }
  819. // }
  820. $noIndex = true;
  821. } elseif (count(array_filter($searchKW)) == 1) {
  822. $theme = array_values(array_filter($searchKW))[0];
  823. $title = "Colonies de vacances ";
  824. // foreach (array_filter($searchKW) as $key => $entity) {
  825. // switch ($key) {
  826. // case "age":
  827. // $title .= " à partir de " . $entity->getTitle();
  828. // break;
  829. // case "villeDesservie":
  830. // $title .= " au départ de " . $entity->getTitle();
  831. // break;
  832. // case "saison":
  833. // $annee = $entity->getAnneeAffichee();
  834. // $title .= " " . $entity->getTitle() . " " . $annee;
  835. // break;
  836. // default:
  837. // $title .= " " . $entity->getTitle();
  838. // }
  839. // }
  840. } else {
  841. $theme = $em->getRepository(Theme::class)->findOneByTitle('general');
  842. }
  843. $maxPrice = 0;
  844. $minPrice = 0;
  845. $img_path = null;
  846. foreach ($pagination as $item) {
  847. // Assuming each item has a 'price' property, adjust the property name accordingly
  848. if ($item->hasFutureSejourSessions() && !$item->isFutureComplete()) {
  849. $price = $item->getMinPrice();
  850. if ($maxPrice === 0 || $price > $maxPrice) {
  851. $maxPrice = $price;
  852. }
  853. if ($minPrice === 0 || $price < $minPrice) {
  854. $minPrice = $price;
  855. }
  856. if ($img_path == null) {
  857. $media = $item->getMedias();
  858. try {
  859. $img1 = $media[0];
  860. $img_path = $helper->asset($img1);
  861. } catch (\Throwable $th) {
  862. //throw $th;
  863. }
  864. }
  865. }
  866. }
  867. // $theme = $em->getRepository(Theme::class)->findOneByTitle('general');
  868. $jsonLd = [
  869. "@context" => "http://schema.org",
  870. "@type" => "Product",
  871. "name" => "Colonies de vacances",
  872. "image" => "https://{$_SERVER['HTTP_HOST']}{$img_path}",
  873. "offers" => [
  874. "@type" => "AggregateOffer",
  875. "lowPrice" => $minPrice == 0 ? "Bientot" : $minPrice,
  876. "highPrice" => $maxPrice == 0 ? "Bientot" : $maxPrice,
  877. "offerCount" => 0,
  878. "priceCurrency" => "EUR"
  879. ]
  880. ];
  881. $jsonLdScript = sprintf('<script type="application/ld+json">%s</script>', json_encode($jsonLd, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
  882. $searchKW['saison'] = !empty($searchKW['saison']) ? $searchKW['saison'][0] : null;
  883. $searchKW['theme'] = !empty($searchKW['theme']) ? $searchKW['theme'][0] : null;
  884. $searchKW['activite'] = !empty($searchKW['activite']) ? $searchKW['activite'][0] : null;
  885. $searchKW['location'] = !empty($searchKW['location']) ? $searchKW['location'][0] : null;
  886. $searchKW['villeDesservie'] = !empty($searchKW['villeDesservie']) ? $searchKW['villeDesservie'][0] : null;
  887. $dql_data = "SELECT count(s) as offerCount , MIN(s.price) as min_price , MAX(s.price) as max_price FROM App\Entity\Sejour s WHERE s.isActive = true ORDER BY s.position ASC";
  888. $query_data = $em->createQuery($dql_data);
  889. $json_data = $query_data->getSingleResult();
  890. return $this->render('frontend/sejour_map.html.twig', [
  891. 'pagination' => $pagination,
  892. 'title' => $title,
  893. 'theme' => $theme,
  894. 'noIndex' => $noIndex,
  895. 'searchKW' => $searchKW,
  896. 'hassecond' => $hassecond,
  897. 'jsonLdScript' => $jsonLdScript,
  898. "lowPrice" => $json_data['min_price'],
  899. "highPrice" => $json_data['max_price'],
  900. ]);
  901. }
  902. /**
  903. * @Route("/sejour-disponible", name="sejour_search_by_date")
  904. */
  905. public function sejourSearchByDate(Request $request, EntityManagerInterface $em, PaginatorInterface $paginator)
  906. {
  907. $dateDebut = $request->query->get('dateDebut');
  908. $dateFin = $request->query->get('dateFin');
  909. $startDate = new \DateTime($dateDebut);
  910. $endDate = new \DateTime($dateFin);
  911. $qb = $em->getRepository(Sejour::class)->createQueryBuilder('s');
  912. $sejours = $qb->select('s')
  913. ->leftJoin('s.sejourSessions', 'ss')
  914. ->where('s.isActive = true')
  915. ->andWhere('ss.dateDebut = :startDate')
  916. ->andWhere('ss.dateFin = :endDate')
  917. ->setParameter('startDate', $startDate)
  918. ->setParameter('endDate', $endDate)
  919. ->getQuery()
  920. ->getResult();
  921. $sejoursAvl = [];
  922. foreach ($sejours as $sejour) {
  923. $sejourSessions = $sejour->getSejourSessions();
  924. foreach ($sejourSessions as $sejourSession) {
  925. if ($sejourSession->getDateDebut() == $startDate && $sejourSession->getDateFin() == $endDate) {
  926. if ($sejourSession->getFreePlacesNumber() > 0) {
  927. $sejoursAvl[] = $sejour;
  928. break;
  929. }
  930. }
  931. }
  932. }
  933. $pagination = $paginator->paginate(
  934. $sejoursAvl, /* result after filtering */
  935. $request->query->getInt('page', 1), /* page number */
  936. 11 /* limit per page */
  937. );
  938. $pageId = $request->query->getInt('page', 1);
  939. $theme = $em->getRepository(Theme::class)->findOneByTitle('general');
  940. return $this->render('frontend/resa/index.html.twig', [
  941. 'pagination' => $pagination,
  942. 'title' => 'Liste de nos colonies de vacances ',
  943. 'theme' => $theme,
  944. 'noIndex' => $pageId > 0
  945. ]);
  946. }
  947. /**
  948. * @Route("FCMICRO",name="frontend_fc_micro")
  949. */
  950. public function fcmicro()
  951. {
  952. $this->getDoctrine()->getManager()->getRepository(FrontOption::class)->findAll();
  953. return new JsonResponse("ce franck, il est quand meme cool");
  954. }
  955. /**
  956. * @Route("goa", name="frontend_goa")
  957. */
  958. public function goa(EntityManagerInterface $em, UploaderHelper $helper)
  959. {
  960. // $mediaType = $em->getRepository(MediaCategorie::class)->findOneBy(['name' => 'Documentation']);
  961. // $media = $em->getRepository(Media::class)->findOneBy(
  962. // [
  963. // 'name' => 'Garantie Option annulation',
  964. // 'mediaCategorie' => $mediaType
  965. // ],
  966. // );
  967. // $path = $helper->asset($media, 'imgFile');
  968. // return $this->redirect($path);
  969. $response = new BinaryFileResponse("files/GOA.2024.pdf");
  970. $response->headers->set('Content-Type', 'application/pdf');
  971. $response->headers->set('Content-Disposition', 'inline; filename="GOA.pdf"');
  972. return $response;
  973. }
  974. /**
  975. * @Route("ajax/enfant/{id}",name="ajax_enfant_id")
  976. */
  977. public function ajaxEnfant(EntityManagerInterface $em, $id)
  978. {
  979. //TODO: voters
  980. $enfant = $em->getRepository(Contact::class)->findOneBy([
  981. 'id' => $id,
  982. 'parent' => $this->getUser()->getContact()
  983. ]);
  984. return new JsonResponse([
  985. 'id' => $id,
  986. 'firstName' => $enfant->getFirstName(),
  987. 'lastName' => $enfant->getLastName(),
  988. 'sexe' => $enfant->getSexe(),
  989. 'birthDate' => $enfant->getBirthdate()->format('Y-m-d'),
  990. ]);
  991. }
  992. /**
  993. * @Route("ficheinscriptionCorse.html",name="frontend_demande_sejour_corse",options={"sitemap" = true})
  994. */
  995. public function demandeSejourCorse(Request $request, EntityManagerInterface $em, MessageBusInterface $bus)
  996. {
  997. $demandeSejourCorse = new DemandeSejourCorse();
  998. $form = $this->createForm(DemandeSejourCorseType::class, $demandeSejourCorse);
  999. $form->handleRequest($request);
  1000. $imageCategorie = $em->getRepository(MediaCategorie::class)->findOneByName('sejourCorse');
  1001. $images = $em->getRepository(Media::class)->findBy(['mediaCategorie' => $imageCategorie]);
  1002. if ($form->isSubmitted() and $form->isValid()) {
  1003. $email = $demandeSejourCorse->getContact()->getEmail();
  1004. $contact = $em->getRepository(Contact::class)->findOneByEmail($email);
  1005. if ($contact !== null) {
  1006. $demandeSejourCorse->setCOntact($contact);
  1007. }
  1008. $em->persist($demandeSejourCorse);
  1009. $em->flush();
  1010. $this->addFlash('success', 'Merci pour votre demande, nous reviendrons vers vous dès que possible.');
  1011. $bus->dispatch(new SendEmailMessage('inscription_corse', '', $demandeSejourCorse->getId(),$this->params->get('email_info')));
  1012. }
  1013. return $this->render('frontend/formCorse.html.twig', [
  1014. 'form' => $form->createView(),
  1015. 'pageTitle' => "Demande de devis Accueil Groupes en Corse",
  1016. 'images' => $images
  1017. ]);
  1018. }
  1019. /**
  1020. * @Route("plan-du-site.html",name="frontend_plan_du_site")
  1021. */
  1022. public function PlanDuSite(HttpClientInterface $client)
  1023. {
  1024. $response = $client->request(
  1025. 'GET',
  1026. 'https://croqvacances.org/sitemap.colonies.xml'
  1027. );
  1028. $xml = simplexml_load_string($response->getContent(), "SimpleXMLElement", LIBXML_NOCDATA);
  1029. $json = json_encode($xml);
  1030. $colonies = json_decode($json, TRUE);
  1031. $response = $client->request(
  1032. 'GET',
  1033. 'https://croqvacances.org/sitemap.default.xml'
  1034. );
  1035. $xml = simplexml_load_string($response->getContent(), "SimpleXMLElement", LIBXML_NOCDATA);
  1036. $json = json_encode($xml);
  1037. $defaults = json_decode($json, TRUE);
  1038. $response = $client->request(
  1039. 'GET',
  1040. 'https://croqvacances.org/sitemap.sejour.xml'
  1041. );
  1042. $xml = simplexml_load_string($response->getContent(), "SimpleXMLElement", LIBXML_NOCDATA);
  1043. $json = json_encode($xml);
  1044. $sejours = json_decode($json, TRUE);
  1045. $response = $client->request(
  1046. 'GET',
  1047. 'https://croqvacances.org/sitemap.article.xml'
  1048. );
  1049. $xml = simplexml_load_string($response->getContent(), "SimpleXMLElement", LIBXML_NOCDATA);
  1050. $json = json_encode($xml);
  1051. $articles = json_decode($json, TRUE);
  1052. return $this->render('frontend/planDuSite.html.twig', ['default' => $defaults, 'sejours' => $sejours, 'articles' => $articles, 'colonies2' => $colonies]);
  1053. }
  1054. /**
  1055. * @Route("vie-associative.html", name="frontend_vie-associative",options={"sitemap" = {"name"="tralala"}})
  1056. */
  1057. public function vieAssoviative(EntityManagerInterface $em)
  1058. {
  1059. $articles = $em->getRepository(Article::class)->findBy([
  1060. 'title' => ['vie_associative_soutenir', 'vie_associative_devenir_benevole', 'vie_associative_temoignage', 'vie_associative_histoire_associative']
  1061. ]);
  1062. return $this->render('frontend/vie-associative.html.twig', ['articles' => $articles]);
  1063. }
  1064. /**
  1065. * @Route("revue-de-presse.html", name="article_de_presse",options={"sitemap" = true})
  1066. */
  1067. public function articleDePresse(ArticlePresseRepository $apr)
  1068. {
  1069. $articles = $apr->findBy(['isActive' => true], ['date' => 'DESC']);
  1070. return $this->render('frontend/article_de_presse.html.twig', ['articles' => $articles]);
  1071. }
  1072. function validateEmail($email)
  1073. {
  1074. return filter_var($email, FILTER_VALIDATE_EMAIL);
  1075. }
  1076. }