src/Controller/Generale/IndexController.php line 45

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Generale;
  3. use App\Service\Generale;
  4. use App\Service\SessionManager;
  5. use App\Service\WSAerien;
  6. use App\Service\WSAuth;
  7. use App\Service\WSCMS;
  8. use App\Service\WSEspaceAffilie;
  9. use App\Service\WSLocationVoiture;
  10. use App\Service\WSSejourHotel;
  11. use App\Service\WSVoyagesOrganise;
  12. use App\Twig\Extension\GeneraleExtension;
  13. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  14. use Symfony\Component\Form\Extension\Core\Type\DateType;
  15. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  16. use Symfony\Component\HttpFoundation\JsonResponse;
  17. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  18. use Symfony\Component\Validator\Constraints\Positive;
  19. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  20. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  21. use Symfony\Component\Form\Extension\Core\Type\TextType;
  22. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  23. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  24. use Symfony\Component\Form\Extension\Core\Type\TimeType;
  25. use Symfony\Component\HttpFoundation\Request;
  26. use Symfony\Component\HttpFoundation\Response;
  27. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  28. use Symfony\Component\Routing\Annotation\Route;
  29. use Knp\Snappy\Pdf;
  30. class IndexController extends AbstractController
  31. {
  32.     public function __construct(Generale $service)
  33.     {
  34.         $this->service = $service;
  35.     }
  36.     /**
  37.      * @Route("/", name="accueil")
  38.      */
  39.     public function accueil(WSCMS $WSCMS, WSSejourHotel $hotel, WSEspaceAffilie $affilie, Request $request, WSLocationVoiture $WSLocationVoiture, WSAerien $WSAerien): Response
  40.     {
  41.         /*
  42.          * $frontBlocs = $hotel->FrontBlocs(['devise' => $this->get('session')->get('devise'), 'version' => 'blocs', 'fields' => 'lite']);
  43.          * $hotelPromoParMois = $hotel->HotelPromoParMois(['devise' => $this->get('session')->get('devise'), 'fields' => 'lite']);
  44.          * $hotelPromoParMois['villesgroupes'] $hotelPromoParMois['maxhotelPromoPour']
  45.          */
  46.         if (isset($_SERVER['ROUTE_ACCUEIL']))
  47.             return $this->redirectToRoute($_SERVER['ROUTE_ACCUEIL'], isset($_SERVER['PARAMS_ROUTE_ACCUEIL']) ? json_decode($_SERVER['PARAMS_ROUTE_ACCUEIL'], true) : []);
  48.         if (isset($_SERVER['DOMAINE_AMADEUS'])) {
  49.             $classes['Resultat'] = [
  50.                 [
  51.                     'id' => 'Y',
  52.                     'typeClasse' => 'Economy'
  53.                 ],
  54.                 [
  55.                     'id' => 'W',
  56.                     'typeClasse' => 'Premium Economy'
  57.                 ],
  58.                 [
  59.                     'id' => 'C',
  60.                     'typeClasse' => 'Business'
  61.                 ],
  62.                 [
  63.                     'id' => 'F',
  64.                     'typeClasse' => 'First'
  65.                 ]
  66.             ];
  67.             $show = false;
  68.         }
  69.         else {
  70.             $classes = $WSAerien->Classe();
  71.             $show = true;
  72.         }
  73.         $classe = $request->get('classe');
  74.         if ($request->isMethod('POST')) {
  75.             $file = $request->files->get('image');
  76.             $path = sha1(uniqid(mt_rand(), TRUE)) . '.' . $file->guessExtension();
  77.             $a = $affilie->ProfileAgence()['ProfileAgence'];
  78.             $uploadRootDir = $a['uploadRootDir'];
  79.             $amicale = [
  80.                 'amicale' => [
  81.                     'libelle' => '',
  82.                     'tel' => '',
  83.                     'fax' => '',
  84.                     'email' => '',
  85.                     'matriculeFiscale' => '',
  86.                     'registreCommercie' => '',
  87.                     'adresse' => '',
  88.                     'path' => $path
  89.                 ]
  90.             ];
  91.             $a = $affilie->ProfileAgence($amicale);
  92.             if (!isset($a['Error']))
  93.                 $file->move($uploadRootDir, $path);
  94.         }
  95.         /*dd($this->service);*/
  96.         return $this->render($this->service->checkCustomTemplate('accueil.html.twig'), [
  97.             'elements' => $WSCMS->Element()['Elements'],
  98.             'sliders' => $WSCMS->Slider()['Sliders'],
  99.             'hotels' => $hotel->PackTopVente()['PackTopVente'],
  100.             'hotelsRecommandes' => $hotel->PackBonPlan()['PackBonPlan'],
  101.             'lieux' => $WSLocationVoiture->LieuxPriseEnCharge(),
  102.             'lieuArrivee' => $request->get('lieu_arrivee'),
  103.             'lieuDepart' => $request->get('lieu_depart'),
  104.             'dateDebutFin' => $request->get('date_debut_fin'),
  105.             'dateDebut' => null,
  106.             'dateFin' => null,
  107.             'classes' => $classes,
  108.             'classe' => $classe,
  109.             'blocBootstrap' => $WSCMS->BlocBootstrap()['BlocsBootstrap'],
  110.             'show' => $show // pour vol (si true donc vol avec xml sinon avec domaine amadeus)
  111.         ]);
  112.     }
  113.     /**
  114.      * @Route("/feature-flags", name="feature_flags")
  115.      */
  116.     public function featureFlags(SessionManager $sessionManager): Response
  117.     {
  118.         $flags = $sessionManager->getAllFeatureFlags();
  119.         return $this->render('feature_flags.html.twig', [
  120.             'flags' => $flags,
  121.         ]);
  122.     }
  123.     /**
  124.      * @Route("/feature-flags/toggle/{key}", name="feature_flag_toggle")
  125.      */
  126.     public function toggleFeatureFlags(string $key, SessionManager $sessionManager, Request $request): Response
  127.     {
  128.         $newValue = $sessionManager->toggleFeatureFlag($key);
  129.         if ($request->isXmlHttpRequest())
  130.             return new JsonResponse([
  131.                 'success' => true,
  132.                 'newStatus' => $newValue,
  133.             ]);
  134.         return $this->redirect($request->headers->get('referer', $this->generateUrl('feature_flags')));
  135.     }
  136.     /**
  137.      * @Route("/wishlist/toggle/{hotelId}", name="wishlist_toggle", methods={"POST"})
  138.      */
  139.     public function toggleWishlist(int $hotelId, SessionInterface $session)
  140.     {
  141.         try {
  142.             // Récupérer la liste de souhaits depuis la session
  143.             $wishlist = $session->get('wishlist', []);
  144.             // Vérifier si l'hôtel est déjà dans la liste de souhaits
  145.             if (in_array($hotelId, $wishlist)) {
  146.                 // Retirer l'hôtel de la liste de souhaits
  147.                 $wishlist = array_filter($wishlist, function ($id) use ($hotelId) {
  148.                     return $id !== $hotelId;
  149.                 });
  150.                 $isInWishlist = false;
  151.             } else {
  152.                 // Ajouter l'hôtel à la liste de souhaits
  153.                 $wishlist[] = $hotelId;
  154.                 $isInWishlist = true;
  155.             }
  156.             // Mettre à jour la liste de souhaits dans la session
  157.             $session->set('wishlist', array_values($wishlist));
  158.             // Retourner une réponse JSON
  159.             return new JsonResponse([
  160.                 'success' => true,
  161.                 'isInWishlist' => $isInWishlist,
  162.             ]);
  163.         } catch (\Exception $e) {
  164.             // En cas d'erreur, retourner un message d'erreur
  165.             return new JsonResponse([
  166.                 'success' => false,
  167.                 'message' => 'Une erreur est survenue : ' . $e->getMessage(),
  168.             ], 500);
  169.         }
  170.     }
  171.     /**
  172.      * @Route("/wishlist/view", name="wishlist_view")
  173.      */
  174.     public function viewWishlist(SessionInterface $session)
  175.     {
  176.         // Récupérer la liste de souhaits depuis la session
  177.         $wishlist = $session->get('wishlist', []);
  178.         return $this->redirectToRoute('sejour_hotel_availability_landing_page', ['hotel' => implode('-', empty($wishlist) ? [0] : $wishlist)]);
  179.     }
  180.     /**
  181.      * @Route("/switch-connexion/{id}", name="switch_connexion")
  182.      */
  183.     public function switchConnexion($id, WSAuth $auth, WSEspaceAffilie $affilie)
  184.     {
  185.         if (!$this->get('session')->get('ADMINISTRATOR_AGENCY') and !isset($_SESSION['ROLE_SUPPER_ADMIN'])) {
  186.             $this->addFlash('danger', 'accès refusé');
  187.             return $this->render('bundles/TwigBundle/Exception/error404.html.twig');
  188.         }
  189.         $infosUser = $auth->infosUserAffilier(['amicale' => $id]);
  190.         if (isset($infosUser['Error']))
  191.             $this->addFlash('danger', $infosUser['Error']);
  192.         else {
  193.             $this->get('session')->set('client', $infosUser['client']);
  194.             $this->get('session')->set('solde', $affilie->Solde());
  195.         }
  196.         return $this->redirect($_SERVER['HTTP_REFERER']);
  197.     }
  198.     /**
  199.      * @Route("/verif-couponreduction/{produit}/{code}/{achat}/{vente}/{checkin}/{nuitees}/{hotel}",
  200.      *     options={"expose"=true},
  201.      *     defaults={"produit":"SHT", "hotel":null},
  202.      *     name="verif_couponreduction")
  203.      */
  204.     public function verifCouponReduction($produit, $code, $achat, $vente, $checkin, $nuitees, $hotel, WSCMS $WSCMS): Response
  205.     {
  206.         return new JsonResponse($WSCMS->CouponReduction(['hotel' => $hotel, 'code' => $code, 'achat' => $achat, 'vente' => $vente, 'checkin' => $checkin, 'nuitees' => $nuitees, 'produit' => $produit]));
  207.     }
  208.     /**
  209.      * @Route("/referencement-by-route",
  210.      *     name="referencement_by_route")
  211.      */
  212.     public function referencementByRoute(Request $request, GeneraleExtension $ext): JsonResponse
  213.     {
  214.         $route = $request->query->get('route');
  215.         $path = $request->query->get('path');
  216.         $balise = $request->query->get('balise');
  217.         $html = $ext->referencementByRoute($route, $path, $balise);
  218.         return $this->json(['html' => $html]);
  219.     }
  220.     /**
  221.      * @Route("/recu-paiement",
  222.      *     options={"expose"=true},
  223.      *     name="recu_paiement")
  224.      */
  225.     public function recuPaiement(Request $request, WSCMS $WSCMS): Response
  226.     {
  227.         $params = json_decode(base64_decode($_GET['params']), true);
  228.         $client = $params['Client'];
  229.         $reference = $params['Numéro de commande'];
  230.         $date = $params['Date et l’heure de la transaction'];
  231.         $montant = $params['Montant de paiement'];
  232.         unset($params['Client'], $params['Date et l’heure de la transaction'], $params['Montant de paiement'], $params['Numéro de commande']);
  233.         if ($request->get('email')) {
  234.             $pdf = self::genererPDFRecuPaiement(['params' => $_GET['params']]);
  235.             $res = $WSCMS->SendMailLibre([
  236.                 'mailToClient' => true,
  237.                 'email' => $request->get('email'),
  238.                 'subject' => "Reçu de paiement",
  239.                 'attach_base64' => [
  240.                     'data' => base64_encode(file_get_contents($pdf)),
  241.                     'filename' => 'reçu-paiement.pdf',
  242.                     'contentType' => mime_content_type($pdf)
  243.                 ],
  244.                 'body' => $this->renderView($this->service->checkCustomTemplate('recu-paiement.html.twig'), [
  245.                     'client' => $client,
  246.                     'date' => $date,
  247.                     'reference' => $reference,
  248.                     'montant' => $montant,
  249.                     'params' => $params,
  250.                 ])
  251.             ]);
  252.             unlink($pdf);
  253.             if (isset($res['SendMail']['Error']))
  254.                 return new Response(0);
  255.             return new Response($res['SendMail']);
  256.         }
  257.         return $this->render($this->service->checkCustomTemplate('recu-paiement.html.twig'), [
  258.             'client' => $client,
  259.             'date' => $date,
  260.             'reference' => $reference,
  261.             'montant' => $montant,
  262.             'params' => $params,
  263.         ]);
  264.     }
  265.     /**
  266.      * @Route("/pdf-recu-paiement",
  267.      *     options={"expose"=true},
  268.      *     name="pdf_recu_paiement")
  269.      */
  270.     public function pdfRecuPaiement(): Response
  271.     {
  272.         $pdf = self::genererPDFRecuPaiement($_GET);
  273.         header('Content-Description: File Transfer');
  274.         header('Content-Disposition: attachment; filename=reçu-paiement.pdf');
  275.         header("Content-Type: application/pdf");
  276.         readfile($pdf);
  277.         unlink($pdf);
  278.         return new Response(" ");
  279.     }
  280.     /**
  281.      * @param $data
  282.      * @return string
  283.      *
  284.      * 1️⃣ Supprime la version actuelle (si elle existe)
  285.      *  sudo yum remove -y wkhtmltopdf
  286.      *
  287.      * 2️⃣ Installe les polices nécessaires
  288.      * sudo yum install -y xorg-x11-fonts-75dpi xorg-x11-fonts-Type1
  289.      * sudo apt install xfonts-100dpi xfonts-75dpi
  290.      *
  291.      * 3️⃣ Télécharge la version “patched” (statique) de wkhtmltopdf
  292.      * wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos7.x86_64.rpm --> yum
  293.      * wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb  --> apt
  294.      *
  295.      * 4️⃣ Installe ce paquet
  296.      * sudo yum localinstall -y wkhtmltox-0.12.6-1.centos7.x86_64.rpm
  297.      * sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb
  298.      *
  299.      * 5️⃣ Vérifie que l’installation est correcte
  300.      * wkhtmltopdf --version  => wkhtmltopdf 0.12.6 (with patched qt)
  301.      */
  302.     function genererPDFRecuPaiement($data)
  303.     {
  304.         /*
  305.          * sudo apt update
  306.          * sudo apt install wkhtmltopdf -y  or yum install wkhtmltopdf
  307.          * sudo cp /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
  308.          *
  309.          * ou bien
  310.          *
  311.          * yum install wget -y
  312.          * wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos8.x86_64.rpm
  313.          * yum localinstall wkhtmltox-0.12.6-1.centos8.x86_64.rpm -y
  314.          * wkhtmltopdf --version
  315.          *
  316.          * exec("wkhtmltopdf '$url' $file 2>&1"); //2>&1 pour comprendre l'erreur exacte.
  317.          */
  318.         /*
  319.          * $snappy = new Pdf('/usr/local/bin/wkhtmltopdf');
  320.          *
  321.          * header('Content-Type: application/pdf');
  322.          * header('Content-Disposition: attachment; filename="file.pdf"');
  323.          * echo $snappy->getOutput('https://www.google.fr/');
  324.          */
  325.         $snappy = new Pdf('/usr/local/bin/wkhtmltopdf');
  326.         #$snappy = new Pdf($this->getParameter('kernel.project_dir') . '/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64');
  327.         $ref = uniqid();
  328.         $file = "uploads/recu-paiement-$ref.pdf";
  329.         $snappy->generate($this->generateUrl('recu_paiement', $data, 0), $file);
  330.         return $file;
  331.     }
  332.     /**
  333.      * @Route("/header", name="header")
  334.      */
  335.     public function header()
  336.     {
  337.         return $this->render($this->service->checkCustomTemplate('header.html.twig'));
  338.     }
  339.     /**
  340.      * @Route("/footer", name="footer")
  341.      */
  342.     public function footer()
  343.     {
  344.         return $this->render($this->service->checkCustomTemplate('footer.html.twig'));
  345.     }
  346.     /**
  347.      * @Route("/blogs/{categorie}/{motcle}",  name="blogs", defaults={"categorie"="all","motcle"="all"})
  348.      */
  349.     public function listblogs($categorie, $motcle, WSCMS $WSCMS): Response
  350.     {
  351.         $articles = $WSCMS->Article();
  352.         $categories = $articles['Categories'];
  353.         $motcles = $articles['MotCles'];
  354.         $articles = $articles['Articles'];
  355.         if ($categorie != 'all')
  356.             $articles = array_filter($articles, function ($item) use ($categorie) {
  357.                 return in_array($categorie, array_column($item['categories'], 'id'));
  358.             });
  359.         if ($motcle != 'all')
  360.             $articles = array_filter($articles, function ($item) use ($motcle) {
  361.                 return in_array($motcle, array_column($item['motcles'], 'id'));
  362.             });
  363.         return $this->render($this->service->checkCustomTemplate('blogs/liste-blogs.html.twig'), [
  364.             'articles' => $articles,
  365.             'categories' => $categories,
  366.             'motcles' => $motcles,
  367.         ]);
  368.     }
  369.     /**
  370.      * @Route("/details-blog/{id}/{slug}",  name="details_blog")
  371.      */
  372.     public function detailsblog($id, $slug, WSCMS $WSCMS): Response
  373.     {
  374.         return $this->render($this->service->checkCustomTemplate('blogs/detail-blogs.html.twig'), [
  375.             'article' => $WSCMS->Article()['Articles'][$id],
  376.             'articles' => $WSCMS->Article()['Articles']
  377.         ]);
  378.     }
  379.     /**
  380.      * @Route ("/article/{slug}", name="details-article")
  381.      */
  382.     public function article($slug, WSCMS $WSCMS): Response
  383.     {
  384.         $articles = $WSCMS->ArticlesElement()['ArticlesElement'];
  385.         $element = array();
  386.         $element['desktop'] = array();
  387.         $element['mobile'] = array();
  388.         foreach ($articles['desktop'] as $item) {
  389.             foreach ($item['elements'] as $_element) {
  390.                 if ($_element['slug'] == $slug) {
  391.                     $element['desktop'] = $_element;
  392.                     break(1);
  393.                 }
  394.             }
  395.         }
  396.         foreach ($articles['mobile'] as $item) {
  397.             foreach ($item['elements'] as $_element) {
  398.                 if ($_element['slug'] == $slug) {
  399.                     $element['mobile'] = $_element;
  400.                     break(1);
  401.                 }
  402.             }
  403.         }
  404.         return $this->render($this->service->checkCustomTemplate('articles/article.html.twig'), [
  405.             'articleDesktop' => $element['desktop'],
  406.             'articleMobile' => $element['mobile']
  407.         ]);
  408.     }
  409.     /**
  410.      * @Route ("/contact", name="contact")
  411.      */
  412.     public function contact(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  413.     {
  414.         $infoAgence = $generaleExtension->getAgence()['information'];
  415.         $form = $this->createFormBuilder(null, ['csrf_protection' => true])
  416.             ->add('email', EmailType::class, array('required' => TRUE))
  417.             ->add('nom', TextType::class, array('required' => TRUE))
  418.             ->add('website', TextType::class, array('required' => false))
  419.             ->add('checkRobot', TextType::class, array('required' => false))
  420.             ->add('gsm', TextType::class, array('required' => false))
  421.             ->add('objet', ChoiceType::class, ['choices' => ['Demande information' => 'information', 'Reclamation' => 'reclamation',],])
  422.             ->add('piecejoint', TextareaType::class, array('required' => false))
  423.             ->add('message', TextareaType::class, array('required' => TRUE))
  424.             ->getForm();
  425.         $form->handleRequest($request);
  426.         if ($form->isSubmitted()) {
  427.             if ($form->isValid()) {
  428.                 try {
  429.                     $data = $form->getData();
  430.                     // dd($data,$_POST);
  431.                     if (!empty($data['website']))
  432.                         return new Response("no web site");
  433.                     $body = $this->renderView($this->service->checkCustomTemplate('contact_mail_body.html.twig'), array(
  434.                         'nom' => $data['nom'],
  435.                         'gsm' => $data['gsm'],
  436.                         'message' => $data['message'],
  437.                         'objet' => $data['objet'],
  438.                         'email' => $data['email'],
  439.                     ));
  440.                     $params = array(
  441.                         'checkRobot' => $data['checkRobot'],
  442.                         'email' => $data['email'],
  443. //                        'subject' => $data['message'],
  444.                         'subject' => $data['objet'],
  445.                         'attach_base64' => json_decode($data['piecejoint'], true),
  446.                         'body' => $body,
  447.                         'post' => $_POST,
  448.                         'page_contact' => true
  449.                     );
  450.                     $result = $WSCMS->SendMailLibre($params);
  451.                     if ($result['SendMail'] == 1) {
  452.                         $msg = "<span style='color:green;font-size: 14px;'>Votre message a été Envoyé avec succès !</span>";
  453.                         $this->addFlash('success', 'Félicitation votre message a été envoyé avec succès! ');
  454.                         return $this->redirectToRoute('contact_ok');
  455.                     } else
  456.                         $msg = '<span style="color:red;font-size: 14px;">Echèc d\'envoi</span>';
  457.                 } catch (\Exception $e) {
  458.                     $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  459.                 }
  460.             } else
  461.                 $msg = '<span style="color:red;font-size: 14px;">' . (string)$form->getErrors(true, false) . '</span>';
  462.             return new Response($msg);
  463.         }
  464.         $configAffichage = array();
  465.         if (!is_null($WSCMS->ConfigFrontOffice()))
  466.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  467.         return $this->render($this->service->checkCustomTemplate('contact.html.twig'), array(
  468.             'infoAgence' => $infoAgence,
  469.             'form' => $form->createView(),
  470.             'contactPerso' => $WSCMS->ContactPerso(),
  471.             'configAffichage' => $configAffichage,
  472.         ));
  473.     }
  474.     /**
  475.      * @Route ("/envoi=Ok", name="contact_ok")
  476.      */
  477.     public function contact_ok()
  478.     {
  479.         return $this->render($this->service->checkCustomTemplate('contact_ok.html.twig'));
  480.     }
  481.     /**
  482.      * @Route ("/sendPayment", name="sendPayment")
  483.      */
  484.     public function sendPayments(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  485.     {
  486.         $infoAgence = $generaleExtension->getAgence()['information'];
  487.         $tabDevise = [];
  488.         foreach ($generaleExtension->getDevise() as $dev) {
  489.             $tabDevise = array_merge($tabDevise, [$dev["code"] => $dev["libelle"]]);
  490.         }
  491.         $form = $this->createFormBuilder(null, ['csrf_protection' => true])
  492.             ->add('montant', TextType::class, array('required' => TRUE))
  493.             ->add('devise', ChoiceType::class, ['choices' => $tabDevise])
  494.             ->add('paiement', ChoiceType::class, ['choices' => [
  495.                 'Séjour Hotel en Tunisie' => 'Séjour Hotel en Tunisie',
  496.                 'Voyages Organisés' => 'Voyages Organisés',
  497.                 'Programmes & activités' => 'Programmes & activités',
  498.                 'Billetterie' => 'Billetterie',
  499.                 'Maritime' => 'Maritime',
  500.                 'Transfert' => 'Transfert',
  501.                 'ResaBooking' => 'ResaBooking',
  502.                 'Réservation Divers' => 'Réservation Divers',
  503.                 'Mice' => 'Mice',
  504.                 'Séjour Hotel à  l \'Etranger' => 'Séjour Hotel à  l \'Etranger',
  505.                 'Bien-être' => 'Bien-être',
  506.                 'Location de voiture' => 'Location de voiture',],])
  507.             ->add('mode', ChoiceType::class, ['choices' => ['Virement bancaire' => 'Virement bancaire', 'Versement bancaire' => 'Versement bancaire',],])
  508.             ->add('note', TextareaType::class, array('required' => true))
  509.             ->add('piecejoint', TextareaType::class, array('required' => false))
  510.             ->add('checkRobot', TextType::class, array('required' => false))
  511.             ->add('code_formulaire', HiddenType::class, array('required' => false, 'data' => 'Formulaire_Payment',))
  512.             ->getForm();
  513.         $form->handleRequest($request);
  514.         if ($form->isSubmitted()) {
  515.             if ($form->isValid()) {
  516.                 /* dd($_POST);*/
  517.                 try {
  518.                     $data = $form->getData();
  519.                     $body = $this->renderView($this->service->checkCustomTemplate('sendPayment_mail_body.html.twig'), array(
  520.                         'montant' => $data['montant'],
  521.                         'devise' => $data['devise'],
  522.                         'paiement' => $data['paiement'],
  523.                         'mode' => $data['mode'],
  524.                         'note' => $data['note'],
  525.                     ));
  526.                     $params = array(
  527.                         'checkRobot' => $data['checkRobot'],
  528.                         'subject' => $data['note'],
  529.                         'post' => $_POST,
  530.                         'code_formulaire' => $data['code_formulaire'],
  531.                         'attach_base64' => json_decode($data['piecejoint'], true),
  532.                         'body' => $body
  533.                     );
  534.                     $result = $WSCMS->SendMailLibre($params);
  535.                     /* dd($data,$params,$result);*/
  536.                     if ($result['SendMail'] == 1)
  537.                         $msg = "<span style='color:green;font-size: 14px;'>Votre message a été Envoyé avec succès !</span>";
  538.                     else
  539.                         $msg = '<span style="color:red;font-size: 14px;">Echèc d\'envoi</span>';
  540.                 } catch (\Exception $e) {
  541.                     $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  542.                 }
  543.             } else
  544.                 $msg = '<span style="color:red;font-size: 14px;">' . (string)$form->getErrors(true, false) . '</span>';
  545.             return new Response($msg);
  546.         }
  547.         $configAffichage = array();
  548.         if (!is_null($WSCMS->ConfigFrontOffice()))
  549.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  550.         return $this->render($this->service->checkCustomTemplate('sendPayment.html.twig'), array(
  551.             'infoAgence' => $infoAgence,
  552.             'form' => $form->createView(),
  553.             'configAffichage' => $configAffichage,
  554.         ));
  555.     }
  556.     /**
  557.      * @Route("/landing-page/{slug}",  name="landing_page")
  558.      * @Route("/hotels/landing-page/{slug}",  name="landing_page_hotels")
  559.      * @Route("/avail-hotels/landing-page/{slug}",  name="landing_page_avail_hotels")
  560.      */
  561.     public function landingPage($slug, WSSejourHotel $hotel, Request $request): Response
  562.     {
  563.         $banner = "{$this->service->domaineBack()}/file_manager/source/landing.webp";
  564.         if (in_array($request->get('_route'), ['landing_page_hotels', 'landing_page_avail_hotels'])) {
  565.             $frontBlocs = $hotel->FrontBlocs(['devise' => $this->get('session')->get('devise'), 'version' => 'blocs', 'fields' => 'lite']);
  566.             $frontBloc = array_column($frontBlocs, null, 'slug')[$slug];
  567.             $flashPromo = ['libelle' => $frontBloc['titre']];
  568.             $details = array_map(function ($hotel) {
  569.                 if (!isset($hotel['prices']['minPrixPromo']))
  570.                     if (isset($hotel['prices']['minPrix']))
  571.                         $hotel['prices']['minPrixPromo'] = $hotel['prices']['minPrix'];
  572.                     elseif (isset($hotel['prices']['prix-demi-double']))
  573.                         $hotel['prices']['minPrixPromo'] = [
  574.                             'prix' => $hotel['prices']['prix-demi-double'],
  575.                             'libelle' => null,
  576.                             'code' => null
  577.                         ];
  578.                     else
  579.                         $hotel['prices']['minPrixPromo'] = [
  580.                             'prix' => null,
  581.                             'libelle' => null,
  582.                             'code' => null
  583.                         ];
  584.                 return [
  585.                     'libelle' => $hotel['details']['libelle'],
  586.                     'sulg' => $hotel['details']['slug'],
  587.                     'photo' => $hotel['photo'],
  588.                     'prix' => $hotel['prices']['minPrixPromo']['prix'],
  589.                     'lbl_arrangement' => $hotel['prices']['minPrixPromo']['libelle'],
  590.                     'code_arrangement' => $hotel['prices']['minPrixPromo']['code'],
  591.                     'idhotel' => $hotel['details']['id'],
  592.                     'image' => $hotel['photo'],
  593.                     'etiquettes' => $hotel['prices']['etiquettes'],
  594.                     //'etiquetteHotel' => array_values(array_column(array_merge($hotel['prices']['etiquettes'],$hotel['prices']['etiquettesSaison'],$hotel['prices']['etiquettesEmplacement']),null,'libelle')),
  595.                     'star' => $hotel['details']['categorie']['nombre_etoiles'],
  596.                     'ville' => $hotel['details']['ville']['libelle'],
  597.                     'nuitees' => $hotel['prices']['nuitees'],
  598.                     'checkin' => $hotel['prices']['dateDebut']
  599.                 ];
  600.             },
  601.                 $frontBloc['hotels']);
  602.         } elseif (strpos($slug, '-pack-bon-plan') !== false) {
  603.             $packBonPlan = array_column($hotel->PackBonPlan()['PackBonPlan'], null, 'categorieId')[explode('-', $slug)[0]];
  604.             $flashPromo = ['libelle' => $packBonPlan['categorie']];
  605.             $hotels = $packBonPlan['element'];
  606.             if ($packBonPlan['bannier'])
  607.                 $banner = $packBonPlan['bannier'];
  608.             $details = array_map(function ($hotel) {
  609.                 return [
  610.                     'libelle' => $hotel['hotel']['libelle'],
  611.                     'sulg' => $hotel['hotel']['slug'],
  612.                     'photo' => $hotel['hotel']['photo'],
  613.                     'prix' => $hotel['prix'],
  614.                     'lbl_arrangement' => $hotel['libelle_arrg'],
  615.                     'code_arrangement' => $hotel['code_arrg'],
  616.                     'idhotel' => $hotel['hotel']['id'],
  617.                     'image' => $hotel['image'],
  618.                     'etiquetteHotel' => $hotel['etiquetteHotel'],
  619.                     'star' => $hotel['hotel']['categorie']['nombre_etoiles'],
  620.                     'ville' => $hotel['hotel']['ville']['libelle'],
  621.                     'nuitees' => $hotel['nuitees'],
  622.                     'checkin' => date('Y-m-d')
  623.                     /*'source' => $hotel['hotel']['source'],*/
  624.                 ];
  625.             },
  626.                 $hotels);
  627.         } else {
  628.             $flashPromo = $hotel->FlashPromo()['FlashPromo'][$slug];
  629.             $banner = $flashPromo['bannier'];
  630.             $details = array_map(function ($hotel) {
  631.                 $checkin = date('Y-m-d');
  632.                 if ($hotel['firstCheckIn'] and new \DateTime($hotel['firstCheckIn']) >= new \DateTime())
  633.                     $checkin = $hotel['firstCheckIn'];
  634.                 return [
  635.                     'libelle' => $hotel['libelle'],
  636.                     'sulg' => $hotel['slug'],
  637.                     'photo' => $hotel['image'],
  638.                     'prix' => $hotel['prix'],
  639.                     'lbl_arrangement' => $hotel['libelleArrg'],
  640.                     'code_arrangement' => $hotel['codeArrg'],
  641.                     'idhotel' => $hotel['idHotel'],
  642.                     'image' => $hotel['image'],
  643.                     'etiquetteHotel' => $hotel['etiquetteHotel'],
  644.                     'star' => $hotel['star'],
  645.                     'ville' => $hotel['ville'],
  646.                     'checkin' => $checkin,
  647.                     'nuitees' => 1
  648.                 ];
  649.             },
  650.                 $flashPromo['hotels']);
  651.         }
  652.         if (in_array($request->get('_route'), ['landing_page_hotels', 'landing_page_avail_hotels'])) {
  653.             //$hotels = array_column($details, 'idhotel');
  654.             return $this->redirectToRoute('sejour_hotel_availability_landing_page', [
  655.                 'checkin' => empty($details) ? "now" : $details[0]['checkin'],
  656.                 'nuitees' => empty($details) ? 1 : $details[0]['nuitees'],
  657.                 'hotel' => $slug//implode('-', empty($hotels) ? [0] : $hotels)
  658.             ]);
  659.         }
  660.         return $this->render($this->service->checkCustomTemplate('SejourHotel/landing-page.html.twig'),
  661.             [
  662.                 'details' => $details,
  663.                 'banner' => $banner,
  664.                 'info' => $flashPromo
  665.             ]);
  666.     }
  667.     /**
  668.      * @Route("/landing-page-package/{slug}",  name="landing_page_package")
  669.      */
  670.     public function landingPagePackage($slug, WSVoyagesOrganise $voyage): Response
  671.     {
  672.         $banner = "{$this->service->domaineBack()}/file_manager/source/landing.webp";
  673.         $flashPromo = $voyage->FlashPromoPackage()['FlashPromo'][$slug];
  674.         $banner = $flashPromo['bannier'];
  675.         $details = $packages = array_map(function ($package) {
  676.             return [
  677.                 'libelle' => $package['libelle'],
  678.                 'sulg' => $package['slug'],
  679.                 'photo' => $package['image'],
  680.                 'prix' => $package['prix'],
  681.                 'idvoyage' => $package['idVoyage'],
  682.                 'image' => $package['image'],
  683.                 'type' => $package['type'],
  684.             ];
  685.         },
  686.             $flashPromo['packages']);
  687.         return $this->render($this->service->checkCustomTemplate('VoyagesOrganise/landing-page.html.twig'),
  688.             [
  689.                 'details' => $details,
  690.                 'banner' => $banner,
  691.                 'info' => $flashPromo
  692.             ]);
  693.     }
  694.     /**
  695.      * showVoyage
  696.      * showCircuits
  697.      * showTopHotelTunisie (topventes)
  698.      * showHotelsRecommandes (bonplan)
  699.      * showPackPromo (promo)
  700.      * showOmra
  701.      * showHTML
  702.      * showHTML2
  703.      * showHTML3
  704.      */
  705.     public function showvoyage(WSCMS $WSCMS): Response
  706.     {
  707.         $groupeCategories = $WSCMS->Element()['Elements'];
  708.         $elements = array();
  709.         foreach ($groupeCategories as $groupeCategory) {
  710.             if ($groupeCategory['groupeCategorie'] == 'voyage')
  711.                 foreach ($groupeCategory['categories'] as $category) {
  712.                     $elements['titreBloc'] = $groupeCategory['titre'];
  713.                     $elements['description'] = $groupeCategory['description'];
  714.                     $elements['image1'] = $groupeCategory['image1'];
  715.                     $elements['lienDetails'] = $category['lienDetails'];
  716.                     if ($category['code'] == 'voyage') {
  717.                         $elements['elements'] = $category['elements'];
  718.                     }
  719.                 }
  720.         }
  721.         return $this->render($this->service->checkCustomTemplate('showVoyage.html.twig'), ['groupe' => $elements]);
  722.     }
  723.     public function showcircuits(WSCMS $WSCMS): Response
  724.     {
  725.         $groupeCategories = $WSCMS->Element()['Elements'];
  726.         $elements = array();
  727.         foreach ($groupeCategories as $groupeCategory) {
  728.             if ($groupeCategory['groupeCategorie'] == 'circuits')
  729.                 foreach ($groupeCategory['categories'] as $category) {
  730.                     $elements['titreBloc'] = $groupeCategory['titre'];
  731.                     $elements['description'] = $groupeCategory['description'];
  732.                     $elements['image1'] = $groupeCategory['image1'];
  733.                     $elements['lienDetails'] = $category['lienDetails'];
  734.                     if ($category['code'] == 'circuits') {
  735.                         $elements['elements'] = $category['elements'];
  736.                     }
  737.                 }
  738.         }
  739.         return $this->render($this->service->checkCustomTemplate('showCircuits.html.twig'), ['groupe' => $elements]);
  740.     }
  741.     public function showTopHotelTunisie(WSCMS $WSCMS, WSSejourHotel $hotel): Response
  742.     {
  743.         $groupeCategories = $WSCMS->Element()['Elements'];
  744.         $elements = array();
  745.         foreach ($groupeCategories as $groupeCategory) {
  746.             if ($groupeCategory['groupeCategorie'] == 'TopHotelTunisie') {
  747.                 foreach ($groupeCategory['categories'] as $category) {
  748.                     $elements['titreBloc'] = $groupeCategory['titre'];
  749.                     $elements['description'] = $groupeCategory['description'];
  750.                     $elements['lienDetails'] = $category['lienDetails'];
  751.                     $elements['image1'] = $groupeCategory['image1'];
  752.                 }
  753.             }
  754.         }
  755.         return $this->render($this->service->checkCustomTemplate('show-hotels-tunisie.html.twig'), ['groupe' => $elements, 'hotels' => $hotel->PackTopVente()['PackTopVente']]);
  756.     }
  757.     public function showPackPromo(WSCMS $WSCMS, WSSejourHotel $hotel): Response
  758.     {
  759.         $groupeCategories = $WSCMS->Element()['Elements'];
  760.         $elements = array();
  761.         foreach ($groupeCategories as $groupeCategory) {
  762.             if ($groupeCategory['groupeCategorie'] == 'PackPromo') {
  763.                 foreach ($groupeCategory['categories'] as $category) {
  764.                     $elements['titreBloc'] = $groupeCategory['titre'];
  765.                     $elements['description'] = $groupeCategory['description'];
  766.                     $elements['image1'] = $groupeCategory['image1'];
  767.                     $elements['lienDetails'] = $category['lienDetails'];
  768.                 }
  769.             }
  770.         }
  771.         return $this->render($this->service->checkCustomTemplate('show-hotels-promo.html.twig'), ['groupe' => $elements, 'hotels' => $hotel->PackPromo()['PackPromo']]);
  772.     }
  773.     /**/
  774.     public function showTarifsChambre(?int $id_hotel, WSCMS $WSCMS, WSSejourHotel $hotel): Response
  775.     {
  776.         $groupeCategories = $WSCMS->Element()['Elements'];
  777.         $elements = array();
  778.         foreach ($groupeCategories as $groupeCategory) {
  779.             if ($groupeCategory['groupeCategorie'] == 'TarifsChambre') {
  780.                 foreach ($groupeCategory['categories'] as $category) {
  781.                     $elements['titreBloc'] = $groupeCategory['titre'];
  782.                     $elements['description'] = $groupeCategory['description'];
  783.                     $elements['image1'] = $groupeCategory['image1'];
  784.                 }
  785.             }
  786.         }
  787.         return $this->render($this->service->checkCustomTemplate('show-tarifschambre.html.twig'), ['groupe' => $elements, 'hotels' => $hotel->TarifsChambre(['Hotel' => $id_hotel])['TarifsChambre']]);
  788.     }
  789.     /**/
  790.     public function showhotelsRecommandes(WSCMS $WSCMS, WSSejourHotel $hotel): Response
  791.     {
  792.         $groupeCategories = $WSCMS->Element()['Elements'];
  793.         $elements = array();
  794.         foreach ($groupeCategories as $groupeCategory) {
  795.             if ($groupeCategory['groupeCategorie'] == 'hotelsRecommandes') {
  796.                 foreach ($groupeCategory['categories'] as $category) {
  797.                     $elements['titreBloc'] = $groupeCategory['titre'];
  798.                     $elements['description'] = $groupeCategory['description'];
  799.                     $elements['lienDetails'] = $category['lienDetails'];
  800.                 }
  801.             }
  802.         }
  803.         return $this->render($this->service->checkCustomTemplate('show-hotels-recommande.html.twig'), ['groupe' => $elements, 'hotels' => $hotel->PackBonPlan()['PackBonPlan']]);
  804.     }
  805.     public function showFlashPromo(WSCMS $WSCMS, WSSejourHotel $hotel): Response
  806.     {
  807.         $groupeCategories = $WSCMS->Element()['Elements'];
  808.         $elements = array();
  809.         foreach ($groupeCategories as $groupeCategory) {
  810.             if ($groupeCategory['groupeCategorie'] == 'FlashPromo') {
  811.                 foreach ($groupeCategory['categories'] as $category) {
  812.                     $elements['titreBloc'] = $groupeCategory['titre'];
  813.                     $elements['description'] = $groupeCategory['description'];
  814.                     $elements['image1'] = $groupeCategory['image1'];
  815.                     $elements['lienDetails'] = $category['lienDetails'];
  816.                 }
  817.             }
  818.         }
  819.         return $this->render($this->service->checkCustomTemplate('show-flash-promo.html.twig'), ['groupe' => $elements, 'hotels' => $hotel->FlashPromo()['FlashPromo']]);
  820.     }
  821.     public function showOmra(WSCMS $WSCMS): Response
  822.     {
  823.         $groupeCategories = $WSCMS->Element()['Elements'];
  824.         $elements = array();
  825.         foreach ($groupeCategories as $groupeCategory) {
  826.             if ($groupeCategory['groupeCategorie'] == 'Omra')
  827.                 foreach ($groupeCategory['categories'] as $category) {
  828.                     $elements['titreBloc'] = $groupeCategory['titre'];
  829.                     $elements['description'] = $groupeCategory['description'];
  830.                     $elements['image1'] = $groupeCategory['image1'];
  831.                     $elements['lienDetails'] = $category['lienDetails'];
  832.                     if ($category['code'] == 'Omra') {
  833.                         $elements['elements'] = $category['elements'];
  834.                     }
  835.                 }
  836.         }
  837.         return $this->render($this->service->checkCustomTemplate('showOmra.html.twig'), ['groupe' => $elements]);
  838.     }
  839.     public function showHTML(WSCMS $WSCMS): Response
  840.     {
  841.         $groupeCategories = $WSCMS->Element()['Elements'];
  842.         $motGroupe = "HTML";
  843.         $groupeCategories = current(array_filter($groupeCategories, function ($item) use ($motGroupe) {
  844.             return in_array($motGroupe, $item);
  845.         }));
  846.         $blocHtml = $WSCMS->BlocHtml()['BlocsHtml']['BlocHtml1'];
  847.         return $this->render($this->service->checkCustomTemplate('showBlocHTML.html.twig'), ['blocsHtml' => $blocHtml]);
  848.     }
  849.     public function showHTML2(WSCMS $WSCMS): Response
  850.     {
  851.         $groupeCategories = $WSCMS->Element()['Elements'];
  852.         $motGroupe = "HTML2";
  853.         $groupeCategories = current(array_filter($groupeCategories, function ($item) use ($motGroupe) {
  854.             return in_array($motGroupe, $item);
  855.         }));
  856.         $blocHtml = $WSCMS->BlocHtml()['BlocsHtml']['BlocHtml2'];
  857.         return $this->render($this->service->checkCustomTemplate('showBlocHTML2.html.twig'), ['blocsHtml' => $blocHtml]);
  858.     }
  859.     public function showHTML3(WSCMS $WSCMS): Response
  860.     {
  861.         $groupeCategories = $WSCMS->Element()['Elements'];
  862.         $motGroupe = "HTML3";
  863.         $groupeCategories = current(array_filter($groupeCategories, function ($item) use ($motGroupe) {
  864.             return in_array($motGroupe, $item);
  865.         }));
  866.         $blocHtml = $WSCMS->BlocHtml()['BlocsHtml']['BlocHtml3'];
  867.         return $this->render($this->service->checkCustomTemplate('showBlocHTML3.html.twig'), ['blocsHtml' => $blocHtml]);
  868.     }
  869.     /**
  870.      * @Route ("/contact_us", name="contact_us")
  871.      */
  872.     public function contactNos(WSCMS $WSCMS): Response
  873.     {
  874.         return $this->render($this->service->checkCustomTemplate('Contactez-nous.html.twig'));
  875.     }
  876.     /**
  877.      * @Route ("/condition-vente/{produit}",name="condition_vente")
  878.      */
  879.     public function conditionVente($produit, WSCMS $WSCMS): Response
  880.     {
  881.         return new Response($WSCMS->ConditionVente()['ConditionVente'][$produit]["texte"]);
  882.     }
  883.     /**
  884.      * @Route("/voyage-carte", name="voyage-carte")
  885.      */
  886.     public function voyagecarte(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  887.     {
  888.         $compagnies = $WSCMS->Company()['Company'];
  889.         $compagnies_choices = array_column($compagnies, 'id', 'libelle');
  890.         $form = $this->createFormBuilder()
  891.             ->add('email', EmailType::class, array(
  892.                 'required' => false,
  893.                 'attr' => [
  894.                     'placeholder' => 'Entrer votre email'
  895.                 ]
  896.             ))
  897.             ->add('civility', ChoiceType::class, [
  898.                 'choices' => [
  899.                     'Mr' => 'mr',
  900.                     'Mme' => 'mme',
  901.                 ],
  902.                 'expanded' => true,
  903.                 'multiple' => false,
  904.             ])
  905.             ->add('travelType', ChoiceType::class, [
  906.                 'choices' => [
  907.                     'Voyage organisé' => 'voyage-organise',
  908.                     'Voyage Combiné' => 'combine',
  909.                 ],
  910.                 'expanded' => true,
  911.                 'multiple' => false,
  912.                 'data' => 'voyage-organise',
  913.             ])
  914.             ->add('firstDestination', TextType::class, [
  915.                 'required' => true,
  916.                 'attr' => [
  917.                     'placeholder' => 'Ville/Pays pour Destination 1',
  918.                     'class' => 'destination-input'
  919.                 ]
  920.             ])
  921.             ->add('secondDestination', TextType::class, [
  922.                 'required' => false,
  923.                 'attr' => [
  924.                     'placeholder' => 'Ville/Pays pour Destination 2',
  925.                     'class' => 'destination-input'
  926.                 ]
  927.             ])
  928.             ->add('singleHotel', TextType::class, [
  929.                 'required' => true,
  930.                 'attr' => [
  931.                     'placeholder' => 'Ville',
  932.                     'class' => 'w-100',
  933.                     'name' => 'hotelCity',
  934.                     'id' => 'singleHotel'
  935.                 ]
  936.             ])
  937.             ->add('combinedHotels', TextType::class, [
  938.                 'required' => FALSE,
  939.                 'attr' => [
  940.                     'placeholder' => 'Ville',
  941.                     'class' => 'w-100',
  942.                     'name' => 'hotelCity2',
  943.                     'id' => 'combinedHotels'
  944.                 ]
  945.             ])
  946.             ->add('situation', ChoiceType::class, [
  947.                 'choices' => [
  948.                     'Single' => 'Single',
  949.                     'Couple' => 'Couple',
  950.                     'Société' => 'Société',
  951.                     'Voyage de Noces' => 'Voyage-de-Noces',
  952.                     'Famille' => 'Famille',
  953.                     'Personnes Âgées ' => 'Personnes-Âgées ',
  954.                     'groupe amis' => 'groupe-amis',
  955.                 ],
  956.                 'placeholder' => "choisissez",
  957.             ])
  958.             ->add('nbrEtoiles', ChoiceType::class, [
  959.                 'label' => "Catégorie d'Hôtel",
  960.                 'choices' => [
  961.                     '2' => 2,
  962.                     '3' => 3,
  963.                     '4' => 4,
  964.                     '5' => 5,
  965.                 ],
  966.                 'expanded' => true,
  967.                 'multiple' => false,
  968.                 'required' => true,
  969.                 'attr' => [
  970.                     'id' => 'hotelCategoryGroup',
  971.                 ],
  972.             ])
  973.             ->add('hotelSuggestions', ChoiceType::class, [
  974.                 'label' => "Suggestions d'Hôtels (max 3)",
  975.                 'choices' => [
  976.                     'Économique' => 'economique',
  977.                     'Confort' => 'confort',
  978.                 ],
  979.                 'expanded' => true,
  980.                 'multiple' => false,
  981.                 'placeholder' => false,
  982.                 'required' => false,
  983.                 'attr' => [],
  984.             ])
  985.             ->add('pension', ChoiceType::class, [
  986.                 'choices' => [
  987.                     'Petit déjeuner' => 'Petit-déjeuner',
  988.                     'Demi pension' => 'Demi-pension',
  989.                     'Pension complète' => 'Pension-complète',
  990.                     'All inclusive' => 'All inclusive',
  991.                 ],
  992.                 'placeholder' => "choisissez",
  993.             ])
  994.             ->add('transport', ChoiceType::class, [
  995.                 'choices' => [
  996.                     'Vol' => 'vol',
  997.                     'Bus' => 'bus',
  998.                     'Train' => 'train',
  999.                     'Bateau' => 'bateau',
  1000.                 ],
  1001.                 'placeholder' => 'Choisissez...',
  1002.                 'attr' => [
  1003.                     'name' => 'transport',
  1004.                     'id' => 'transportSelect',
  1005.                     'required' => false,
  1006.                 ],
  1007.             ])
  1008.             ->add('flightType', ChoiceType::class, [
  1009.                 'choices' => [
  1010.                     'Indirect' => 'indirect',
  1011.                 ],
  1012.                 'placeholder' => 'Direct',
  1013.                 'attr' => [
  1014.                     'id' => 'flightTypeSelect',
  1015.                     'name' => 'flightType'
  1016.                 ],
  1017.                 'required' => false,
  1018.             ])
  1019.             ->add('airline', ChoiceType::class, [
  1020.                 'choices' => $compagnies_choices,
  1021.                 'placeholder' => 'Choisissez...',
  1022.                 'attr' => [
  1023.                     'id' => 'airlineSelect',
  1024.                     'name' => 'airline',
  1025.                     'class' => 'selectpicker',
  1026.                     'data-live-search' => 'true'
  1027.                 ],
  1028.                 'required' => false,
  1029.             ])
  1030.             ->add('transfert', CheckboxType::class, [
  1031.                 'attr' => [
  1032.                     'id' => 'transfertCheckbox',
  1033.                 ],
  1034.                 'required' => false,
  1035.             ])
  1036.             ->add('nbrPersonne', IntegerType::class, array(
  1037.                 'required' => false,
  1038.                 'attr' => [
  1039.                     'placeholder' => 'Nombre de personne ',
  1040.                     'min' => 1,
  1041.                     'max' => 100,
  1042.                 ]
  1043.             ))
  1044.             ->add('adulte', IntegerType::class, array(
  1045.                 'required' => false,
  1046.                 'attr' => [
  1047.                     'placeholder' => 'Adultes  ',
  1048.                     'min' => 0,
  1049.                     'max' => 100,
  1050.                 ]
  1051.             ))
  1052.             ->add('nbrEnfant', IntegerType::class, array(
  1053.                 'required' => false,
  1054.                 'attr' => [
  1055.                     'placeholder' => 'Nombre de enfant ',
  1056.                     'min' => 0,
  1057.                     'max' => 100,
  1058.                     'id' => 'childrenInput',
  1059.                 ]
  1060.             ))
  1061.             ->add('agesEnfants', HiddenType::class, [
  1062.                 'mapped' => true,
  1063.                 'required' => false,
  1064.                 'attr' => [
  1065.                     'id' => 'childrenAgesHidden',
  1066.                 ],
  1067.             ])
  1068.             ->add('nbrBebe', IntegerType::class, array(
  1069.                 'required' => false,
  1070.                 'attr' => [
  1071.                     'placeholder' => 'Nombre de Bébé ',
  1072.                     'min' => 0,
  1073.                     'max' => 100,
  1074.                 ]
  1075.             ))
  1076.             ->add('nom', TextType::class, array(
  1077.                 'required' => TRUE,
  1078.                 'attr' => [
  1079.                     'placeholder' => 'nom '
  1080.                 ]
  1081.             ))
  1082.             ->add('prenom', TextType::class, array(
  1083.                 'required' => TRUE,
  1084.                 'attr' => [
  1085.                     'placeholder' => ' prénom'
  1086.                 ]
  1087.             ))
  1088. //        ->add('avatar', FileType::class, array(
  1089. //            'required' => TRUE,
  1090. //            ))
  1091.             ->add('start', DateType::class, array(
  1092.                 'required' => TRUE,
  1093.                 'format' => 'yyyy-MM-dd',
  1094.                 'widget' => 'single_text',
  1095.                 'attr' => [
  1096.                     'min' => (new \DateTime())->format('Y-m-d'),
  1097.                 ]
  1098.             ))
  1099.             ->add('retourDate', DateType::class, array(
  1100.                 'required' => TRUE,
  1101.                 'format' => 'yyyy-MM-dd',
  1102.                 'widget' => 'single_text',
  1103.                 'attr' => [
  1104.                     'min' => (new \DateTime())->format('Y-m-d'),
  1105.                 ]
  1106.             ))
  1107.             ->add('startDest1', DateType::class, array(
  1108.                 'required' => false,
  1109.                 'format' => 'yyyy-MM-dd',
  1110.                 'widget' => 'single_text',
  1111.                 'attr' => [
  1112.                     'min' => (new \DateTime())->format('Y-m-d'),
  1113.                 ]
  1114.             ))
  1115.             ->add('retourDest1', DateType::class, array(
  1116.                 'required' => false,
  1117.                 'format' => 'yyyy-MM-dd',
  1118.                 'widget' => 'single_text',
  1119.                 'attr' => [
  1120.                     'min' => (new \DateTime())->format('Y-m-d'),
  1121.                 ]
  1122.             ))
  1123.             ->add('startDest2', DateType::class, array(
  1124.                 'required' => false,
  1125.                 'format' => 'yyyy-MM-dd',
  1126.                 'widget' => 'single_text',
  1127.                 'attr' => [
  1128.                     'min' => (new \DateTime())->format('Y-m-d'),
  1129.                 ]
  1130.             ))
  1131.             ->add('retourDest2', DateType::class, array(
  1132.                 'required' => false,
  1133.                 'format' => 'yyyy-MM-dd',
  1134.                 'widget' => 'single_text',
  1135.                 'attr' => [
  1136.                     'min' => (new \DateTime())->format('Y-m-d'),
  1137.                 ]
  1138.             ))
  1139.             ->add('adresse', TextType::class, array(
  1140.                 'required' => TRUE,
  1141.                 'attr' => [
  1142.                     'placeholder' => 'Entrer votre adresse'
  1143.                 ]
  1144.             ))
  1145.             ->add('destination', TextType::class, array(
  1146.                 'required' => TRUE,
  1147.                 'attr' => [
  1148.                     'placeholder' => 'Entrer votre Destination'
  1149.                 ]
  1150.             ))
  1151.             ->add('tel', TextType::class, array(
  1152.                 'required' => false,
  1153.                 'attr' => [
  1154.                     'placeholder' => 'Entrer votre Téléphone'
  1155.                 ]
  1156.             ))
  1157.             ->add('subject', TextareaType::class, array(
  1158.                 'required' => false,
  1159.                 'attr' => [
  1160.                     'placeholder' => 'Commentaire'
  1161.                 ]
  1162.             ))
  1163.             ->add('code_formulaire', HiddenType::class, array('required' => false, 'data' => 'demande_voyage_carte',));
  1164.         $form = $form->getForm();
  1165.         $form->handleRequest($request);
  1166.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  1167.             try {
  1168.                 /*  parse_str($request->request->get('form'), $form);*/
  1169.                 /*  dd($form);*/
  1170.                 $data = $form->getData();
  1171.                 /* dd($data);*/
  1172.                 $body = $this->renderView('FrontCommun/formulaire_mail_body.html.twig', array(
  1173.                     'nom' => $data['nom'],
  1174.                     'start' => $data['start'],
  1175.                     'email' => $data['email'],
  1176.                     'adresse' => $data['adresse'] ?? '',
  1177.                     'destination' => $data['destination'] ?? '',
  1178.                     'tel' => $data['tel'],
  1179.                     'subject' => $data['subject'],
  1180.                 ));
  1181.                 $params = array(
  1182.                     'mailToClient' => true,
  1183.                     'email' => $data['email'],
  1184.                     'subject' => $data['subject'],
  1185.                     'body' => $body,
  1186.                     'post' => $_POST,
  1187.                     'code_formulaire' => $data['code_formulaire']
  1188.                 );
  1189.                 $result = $WSCMS->SendMailLibre($params);
  1190.             } catch (\Exception $e) {
  1191.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  1192.                 return new Response($msg);
  1193.             }
  1194.             if ($result != 0) {
  1195.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  1196.             } else {
  1197.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  1198.             }
  1199.             return new Response($msg);
  1200.         }
  1201.         $configAffichage = array();
  1202.         if (!is_null($WSCMS->ConfigFrontOffice()))
  1203.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  1204.         return $this->render($this->service->checkCustomTemplate('demande_voyage_carte.html.twig'), array(
  1205.             'form' => $form->createView(),
  1206.             'configAffichage' => $configAffichage,
  1207.         ));
  1208.     }
  1209.     /**
  1210.      * @Route("/inscriptioncomite", name="inscription-comite")
  1211.      */
  1212.     public function inscriptioncomite(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  1213.     {
  1214.         $form = $this->createFormBuilder()
  1215.             ->add('email', EmailType::class, array(
  1216.                 'required' => TRUE,
  1217.                 'attr' => [
  1218.                     'placeholder' => 'Entrer votre email'
  1219.                 ]
  1220.             ))
  1221.             ->add('nom_agence', TextType::class, array(
  1222.                 'required' => TRUE,
  1223.                 'attr' => [
  1224.                     'placeholder' => 'Nom du comité ou de l’Amicale'
  1225.                 ]
  1226.             ))
  1227.             ->add('nom', TextType::class, array(
  1228.                 'required' => TRUE,
  1229.                 'attr' => [
  1230.                     'placeholder' => 'Nom du Contact'
  1231.                 ]
  1232.             ))
  1233.             ->add('num_adh', IntegerType::class, array(
  1234.                 'required' => TRUE,
  1235.                 'attr' => [
  1236.                     'placeholder' => 'Nombre d’adhérent'
  1237.                 ]
  1238.             ))
  1239.             ->add('civ', ChoiceType::class, [
  1240.                     'choices' => [
  1241.                         "Mr" => "Mr",
  1242.                         "Mme" => "Mme",
  1243.                         "Mlle" => "Mlle",
  1244.                     ]
  1245.                 ]
  1246.             )
  1247. //        ->add('avatar', FileType::class, array(
  1248. //            'required' => TRUE,
  1249. //            ))
  1250.             ->add('adresse', TextType::class, array(
  1251.                 'required' => TRUE,
  1252.                 'attr' => [
  1253.                     'placeholder' => 'Entrer votre adresse'
  1254.                 ]
  1255.             ))
  1256.             ->add('tel', IntegerType::class, array(
  1257.                 'required' => TRUE,
  1258.                 'attr' => [
  1259.                     'placeholder' => 'Entrer votre Téléphone'
  1260.                 ]
  1261.             ))
  1262.             ->add('subject', HiddenType::class, [
  1263.                 'data' => 'demande-inscription',
  1264.             ]);
  1265.         $form = $form->getForm();
  1266.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  1267.             try {
  1268.                 parse_str($request->request->get('form'), $form);
  1269.                 $data = $form['form'];
  1270.                 /* dd($data);*/
  1271.                 $body = $this->renderView('FrontCommun/formulaire_mail_body.html.twig', array(
  1272.                     'nom_agence' => $data['nom_agence'],
  1273.                     'nom' => $data['nom'],
  1274.                     'num_adh' => $data['num_adh'],
  1275.                     'civ' => $data['civ'],
  1276.                     'email' => $data['email'],
  1277.                     'adresse' => $data['adresse'],
  1278.                     'tel' => $data['tel'],
  1279.                     'subject' => $data['subject'],
  1280.                 ));
  1281.                 $params = array(
  1282.                     'email' => $data['email'],
  1283.                     'subject' => $data['subject'],
  1284.                     'body' => $body,
  1285.                 );
  1286.                 $result = $WSCMS->SendMailLibre($params);
  1287.                 $params['mailToClient'] = true;
  1288.                 $result = $WSCMS->SendMailLibre($params);
  1289.             } catch (\Exception $e) {
  1290.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  1291.                 return new Response($msg);
  1292.             }
  1293.             if ($result != 0) {
  1294.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  1295.             } else {
  1296.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  1297.             }
  1298.             return new Response($msg);
  1299.         }
  1300.         $configAffichage = array();
  1301.         if (!is_null($WSCMS->ConfigFrontOffice()))
  1302.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  1303.         return $this->render($this->service->checkCustomTemplate('demande_commite.html.twig'), array(
  1304.             'form' => $form->createView(),
  1305.             'configAffichage' => $configAffichage,
  1306.         ));
  1307.     }
  1308.     /**
  1309.      * @Route("/demande_voyage_groupe", name="demande_voyage_groupe")
  1310.      */
  1311.     public function voyage_groupe(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  1312.     {
  1313.         $form = $this->createFormBuilder()
  1314.             ->add('email', EmailType::class, array(
  1315.                 'required' => TRUE,
  1316.                 'attr' => [
  1317.                     'placeholder' => 'Entrer votre email'
  1318.                 ]
  1319.             ))
  1320.             ->add('Type_groupe', ChoiceType::class, array(
  1321.                 'required' => TRUE,
  1322.                 'choices' => [
  1323.                     "Groupe d'amis" => "Groupe d'amis",
  1324.                     "Association" => "Association",
  1325.                     "entreprise" => "entreprise",
  1326.                 ]
  1327.             ))
  1328.             /* ->add('destination', ChoiceType::class, array(
  1329.                  'required' => TRUE,
  1330.                  'destination' => [
  1331.                      "Ain Draham" => "Ain Draham",
  1332.                      "Bizerte" => "Bizerte",
  1333.                      "Djerba" => "Djerba",
  1334.                      "Douz" => "Douz",
  1335.                      "El Jem" => "El Jem",
  1336.                      "Gafsa" => "Gafsa",
  1337.                      "Gammarth" => "Gammarth",
  1338.                      "Hammamet" => "Hammamet",
  1339.                      "Kairouan" => "Kairouan",
  1340.                      "Mahdia" => "Mahdia",
  1341.                      "Monastir" => "Monastir",
  1342.                      "Nabeul" => "Nabeul",
  1343.                      "Sbeitla" => "Sbeitla",
  1344.                      "Sfax" => "Sfax",
  1345.                      "Sousse" => "Sousse",
  1346.                      "Tabarka" => "Tabarka",
  1347.                      "Tozeur" => "Tozeur",
  1348.                      "Tunis" => "Tunis",
  1349.                      "Zarzis" => "Zarzis",
  1350.                  ]
  1351.              ))*/
  1352.             ->add('nom_hotel', TextType::class, array(
  1353.                 'required' => TRUE,
  1354.                 'attr' => [
  1355.                     'placeholder' => 'Nom de Hôtel ou catégorie'
  1356.                 ]
  1357.             ))
  1358.             ->add('start', DateType::class, array(
  1359.                 'required' => TRUE,
  1360.                 'format' => 'yyyy-MM-dd',
  1361.                 'widget' => 'single_text',
  1362.             ))
  1363.             ->add('civ', ChoiceType::class, [
  1364.                     'choices' => [
  1365.                         "Mr" => "Mr",
  1366.                         "Mme" => "Mme",
  1367.                         "Mlle" => "Mlle",
  1368.                     ]
  1369.                 ]
  1370.             )
  1371.             ->add('num_participants', IntegerType::class, array(
  1372.                 'mapped' => false,
  1373.                 'required' => false,
  1374.                 'constraints' => [new Positive()],
  1375.                 'attr' => [
  1376.                     'min' => 20
  1377.                 ]
  1378.             ))
  1379.             ->add('num_nuite', IntegerType::class, array(
  1380.                 'mapped' => false,
  1381.                 'required' => false,
  1382.                 'constraints' => [new Positive()],
  1383.                 'attr' => [
  1384.                     'min' => 1
  1385.                 ]
  1386.             ))
  1387.             ->add('num_budget', IntegerType::class, array(
  1388.                 'mapped' => false,
  1389.                 'required' => false,
  1390.                 'constraints' => [new Positive()],
  1391.                 'attr' => [
  1392.                     'placeholder' => 'Budget/personne'
  1393.                 ]
  1394.             ))
  1395.             ->add('formule', ChoiceType::class, [
  1396.                     'choices' => [
  1397.                         "Logement Petit Déjeuner" => "Logement Petit Déjeuner",
  1398.                         "Demi Pension" => "Demi Pension",
  1399.                         "Pension Complète" => "Pension Complète",
  1400.                         "Tous compris" => "Tous compris",
  1401.                     ]
  1402.                 ]
  1403.             )
  1404.             ->add('demandespec', TextareaType::class, array(
  1405.                 'required' => TRUE,
  1406.                 'attr' => [
  1407.                     'placeholder' => 'Demande spécifique'
  1408.                 ]
  1409.             ))
  1410. //        ->add('avatar', FileType::class, array(
  1411. //            'required' => TRUE,
  1412. //            ))
  1413.             ->add('nom', TextType::class, array(
  1414.                 'required' => TRUE,
  1415.                 'attr' => [
  1416.                     'placeholder' => 'Nom & prénom'
  1417.                 ]
  1418.             ))
  1419.             ->add('adresse', TextType::class, array(
  1420.                 'required' => TRUE,
  1421.                 'attr' => [
  1422.                     'placeholder' => 'Entrer votre adresse'
  1423.                 ]
  1424.             ))
  1425.             ->add('tel', IntegerType::class, array(
  1426.                 'required' => TRUE,
  1427.                 'attr' => [
  1428.                     'placeholder' => 'Entrer votre Téléphone'
  1429.                 ]
  1430.             ))
  1431.             ->add('subject', HiddenType::class, [
  1432.                 'data' => 'demande-groupe-voyage',
  1433.             ]);
  1434.         $form = $form->getForm();
  1435.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  1436.             try {
  1437.                 parse_str($request->request->get('form'), $form);
  1438.                 $data = $form['form'];
  1439.                 /* dd($data);*/
  1440.                 $body = $this->renderView('FrontCommun/formulaire_mail_body.html.twig', array(
  1441.                     'Type_groupe' => $data['Type_groupe'],
  1442.                     'num_participants' => $data['num_participants'],
  1443.                     'email' => $data['email'],
  1444.                     'civ' => $data['civ'],
  1445.                     'nom_hotel' => $data['nom_hotel'],
  1446.                     'nom' => $data['nom'],
  1447.                     'num_nuite' => $data['num_nuite'],
  1448.                     'tel' => $data['tel'],
  1449.                     'start' => $data['start'],
  1450.                     'formule' => $data['formule'],
  1451.                     'num_budget' => $data['num_budget'],
  1452.                     'adresse' => $data['adresse'],
  1453.                     'subject' => $data['subject'],
  1454.                     'demandespec' => $data['demandespec'],
  1455.                 ));
  1456.                 $params = array(
  1457.                     'email' => $data['email'],
  1458.                     'subject' => $data['subject'],
  1459.                     'body' => $body,
  1460.                 );
  1461.                 $result = $WSCMS->SendMailLibre($params);
  1462.                 $params['mailToClient'] = true;
  1463.                 $result = $WSCMS->SendMailLibre($params);
  1464.             } catch (\Exception $e) {
  1465.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  1466.                 return new Response($msg);
  1467.             }
  1468.             if ($result != 0) {
  1469.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  1470.             } else {
  1471.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  1472.             }
  1473.             return new Response($msg);
  1474.         }
  1475.         $configAffichage = array();
  1476.         if (!is_null($WSCMS->ConfigFrontOffice()))
  1477.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  1478.         return $this->render($this->service->checkCustomTemplate('formulaire_voyage_groupe.html.twig'), array(
  1479.             'form' => $form->createView(),
  1480.             'configAffichage' => $configAffichage,
  1481.         ));
  1482.     }
  1483.     /**
  1484.      * @Route("/omra", name="omra")
  1485.      */
  1486.     public function omra(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  1487.     {
  1488.         $form = $this->createFormBuilder()
  1489.             ->add('email', EmailType::class, array(
  1490.                 'required' => TRUE,
  1491.                 'attr' => [
  1492.                     'placeholder' => 'Entrer votre email'
  1493.                 ]
  1494.             ))
  1495.             ->add('nom', TextType::class, array(
  1496.                 'required' => TRUE,
  1497.                 'attr' => [
  1498.                     'placeholder' => 'nom & prénom'
  1499.                 ]
  1500.             ))
  1501. //        ->add('avatar', FileType::class, array(
  1502. //            'required' => TRUE,
  1503. //            ))
  1504.             ->add('start', DateType::class, array(
  1505.                 'required' => TRUE,
  1506.                 'format' => 'yyyy-MM-dd',
  1507.                 'widget' => 'single_text',
  1508.             ))
  1509.             ->add('adresse', TextType::class, array(
  1510.                 'required' => TRUE,
  1511.                 'attr' => [
  1512.                     'placeholder' => 'Entrer votre adresse'
  1513.                 ]
  1514.             ))
  1515.             ->add('tel', TextType::class, array(
  1516.                 'required' => TRUE,
  1517.                 'attr' => [
  1518.                     'placeholder' => 'Entrer votre Téléphone'
  1519.                 ]
  1520.             ))
  1521.             ->add('subject', TextareaType::class, array(
  1522.                 'required' => TRUE,
  1523.                 'attr' => [
  1524.                     'placeholder' => 'Commentaire'
  1525.                 ]
  1526.             ));
  1527.         $form = $form->getForm();
  1528.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  1529.             try {
  1530.                 parse_str($request->request->get('form'), $form);
  1531.                 $data = $form['form'];
  1532.                 /* dd($data);*/
  1533.                 $body = $this->renderView('FrontCommun/formulaire_mail_body.html.twig', array(
  1534.                     'nom' => $data['nom'],
  1535.                     'start' => $data['start'],
  1536.                     /*                    'avatar' => $data['avatar'],*/
  1537.                     'email' => $data['email'],
  1538.                     'adresse' => $data['adresse'],
  1539.                     'tel' => $data['tel'],
  1540.                     'subject' => $data['subject'],
  1541.                 ));
  1542.                 $params = array(
  1543.                     'email' => $data['email'],
  1544.                     'subject' => $data['subject'],
  1545.                     'body' => $body,
  1546.                 );
  1547.                 $result = $WSCMS->SendMailLibre($params);
  1548.                 $params['mailToClient'] = true;
  1549.                 $result = $WSCMS->SendMailLibre($params);
  1550.             } catch (\Exception $e) {
  1551.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  1552.                 return new Response($msg);
  1553.             }
  1554.             if ($result != 0) {
  1555.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  1556.             } else {
  1557.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  1558.             }
  1559.             return new Response($msg);
  1560.         }
  1561.         $configAffichage = array();
  1562.         if (!is_null($WSCMS->ConfigFrontOffice()))
  1563.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  1564.         return $this->render($this->service->checkCustomTemplate('demande_omra.html.twig'), array(
  1565.             'form' => $form->createView(),
  1566.             'configAffichage' => $configAffichage,
  1567.         ));
  1568.     }
  1569.     /**
  1570.      * @Route("/omra-carte-formulaire", name="omra_carte_formulaire")
  1571.      *
  1572.      */
  1573.     public function formOmraCarteFormulaire(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  1574.     {
  1575.         $infoAgence = $generaleExtension->getAgence()['information'];
  1576.         $form = $this->createFormBuilder(null, ['csrf_protection' => true])
  1577.             ->add('civility', ChoiceType::class, [
  1578.                 'choices' => [
  1579.                     'Mr' => 'mr',
  1580.                     'Mme' => 'mme',
  1581.                 ],
  1582.                 'placeholder' => "choisissez",
  1583.             ])
  1584.             ->add('nom', TextType::class, array(
  1585.                 'required' => TRUE,
  1586.                 'attr' => [
  1587.                     'placeholder' => 'nom '
  1588.                 ]
  1589.             ))
  1590.             ->add('prenom', TextType::class, array(
  1591.                 'required' => TRUE,
  1592.                 'attr' => [
  1593.                     'placeholder' => ' prénom'
  1594.                 ]
  1595.             ))
  1596.             ->add('situation', ChoiceType::class, [
  1597.                 'choices' => [
  1598.                     'Single' => 'Single',
  1599.                     'Couple' => 'Couple',
  1600.                     'Société' => 'Société',
  1601.                     'Famille' => 'Famille',
  1602.                     'Amicale ' => 'amicale',
  1603.                 ],
  1604.                 'placeholder' => "choisissez",
  1605.             ])
  1606.             ->add('adulte', IntegerType::class, array(
  1607.                 'required' => false,
  1608.                 'attr' => [
  1609.                     'placeholder' => 'Adultes  ',
  1610.                     'min' => 0,
  1611.                     'max' => 100,
  1612.                 ]
  1613.             ))
  1614.             ->add('nbrEnfant', IntegerType::class, array(
  1615.                 'required' => false,
  1616.                 'attr' => [
  1617.                     'placeholder' => 'Nombre de enfant ',
  1618.                     'min' => 0,
  1619.                     'max' => 100,
  1620.                     'id' => 'nb_enfants',
  1621.                 ]
  1622.             ))
  1623.             ->add('nbrBebe', IntegerType::class, array(
  1624.                 'required' => false,
  1625.                 'attr' => [
  1626.                     'placeholder' => 'Nombre de Bébé ',
  1627.                     'min' => 0,
  1628.                     'max' => 100,
  1629.                 ]
  1630.             ))
  1631.             ->add('tel', TextType::class, array(
  1632.                 'required' => TRUE,
  1633.                 'attr' => [
  1634.                     'placeholder' => 'Entrer votre Téléphone'
  1635.                 ]
  1636.             ))
  1637.             ->add('email', EmailType::class, array(
  1638.                 'required' => TRUE,
  1639.                 'attr' => [
  1640.                     'placeholder' => 'Entrer votre email'
  1641.                 ]
  1642.             ))
  1643.             ->add('ville_depart', TextType::class, array(
  1644.                 'required' => TRUE,
  1645.                 'attr' => [
  1646.                     'placeholder' => 'ville départ'
  1647.                 ]
  1648.             ))
  1649.             ->add('destAller', ChoiceType::class, [
  1650.                 'choices' => [
  1651.                     'Jeddah' => 'Jeddah',
  1652.                     'Medina' => 'Medina',
  1653.                 ],
  1654.                 'placeholder' => "choisissez",
  1655.             ])
  1656.             ->add('destRetour', ChoiceType::class, [
  1657.                 'choices' => [
  1658.                     'Jeddah' => 'Jeddah',
  1659.                     'Medina' => 'Medina',
  1660.                 ],
  1661.                 'placeholder' => "choisissez",
  1662.             ])
  1663.             ->add('villeRetour', TextType::class, array(
  1664.                 'required' => TRUE,
  1665.                 'attr' => [
  1666.                     'placeholder' => 'ville départ'
  1667.                 ]
  1668.             ))
  1669.             ->add('dateDepart', DateType::class, array(
  1670.                 'required' => TRUE,
  1671.                 'format' => 'yyyy-MM-dd',
  1672.                 'widget' => 'single_text',
  1673.                 'attr' => [
  1674.                     'min' => (new \DateTime())->format('Y-m-d'),
  1675.                 ]
  1676.             ))
  1677.             ->add('dateRetour', DateType::class, array(
  1678.                 'required' => TRUE,
  1679.                 'format' => 'yyyy-MM-dd',
  1680.                 'widget' => 'single_text',
  1681.                 'attr' => [
  1682.                     'min' => (new \DateTime())->format('Y-m-d'),
  1683.                 ]
  1684.             ))
  1685.             ->add('flightType', ChoiceType::class, [
  1686.                 'choices' => [
  1687.                     'Direct' => 'Direct',
  1688.                     'Indirect' => 'indirect',
  1689.                 ],
  1690.                 'attr' => [
  1691.                     'id' => 'type_vol',
  1692.                 ],
  1693.                 'placeholder' => 'Sélectionnez',
  1694.                 'required' => true,
  1695.             ])
  1696.             ->add('compagnieAerien', TextType::class, array(
  1697.                 'required' => false,
  1698.                 'attr' => [
  1699.                     'placeholder' => 'Turkish Airlines'
  1700.                 ]
  1701.             ))
  1702.             ->add('escale', TextType::class, array(
  1703.                 'required' => false,
  1704.                 'attr' => [
  1705.                     'placeholder' => 'Ex: istanbul'
  1706.                 ]
  1707.             ))
  1708.             ->add('transfert', ChoiceType::class, [
  1709.                 'choices' => [
  1710.                     'Oui' => 'Oui',
  1711.                     'Non' => 'non',
  1712.                 ],
  1713.                 'expanded' => true,
  1714.                 'multiple' => false,
  1715.             ])
  1716.             ->add('moyen_transport', ChoiceType::class, [
  1717.                 'required' => false,
  1718.                 'choices' => [
  1719.                     'Bus' => 'bus',
  1720.                     'GMC' => 'GMC',
  1721.                     'train' => 'train',
  1722.                 ],
  1723.                 'placeholder' => 'Choisissez...',
  1724.                 'attr' => [
  1725.                     'id' => 'moyenTransport',
  1726.                 ],
  1727.             ])
  1728.             ->add('destinationTrain', ChoiceType::class, [
  1729.                 'required' => false,
  1730.                 'choices' => [
  1731.                     'Gare de Medina' => 'Gare-de-Medina',
  1732.                     'Gare de Jeddah' => 'Gare-de-Jeddah',
  1733.                     'Gare de Mekka' => 'Gare-de-Mekka',
  1734.                 ],
  1735.                 'placeholder' => 'Choisissez...',
  1736.                 'attr' => [
  1737.                     'id' => 'train_destination',
  1738.                 ],
  1739.             ])
  1740.             ->add('Itineraire', TextType::class, array(
  1741.                 'required' => false,
  1742.                 'attr' => [
  1743.                     'placeholder' => 'Ex: Jeddah à Medina',
  1744.                     'id' => 'train_itineraire',
  1745.                 ]
  1746.             ))
  1747.             ->add('hotelMakkah', TextType::class, array(
  1748.                 'required' => false,
  1749.                 'attr' => [
  1750.                     'placeholder' => 'Nom de l\'hôtel suggéré',
  1751.                     'id' => 'hotel_mekka',
  1752.                 ]
  1753.             ))
  1754.             ->add('hotelMedina', TextType::class, array(
  1755.                 'required' => false,
  1756.                 'attr' => [
  1757.                     'placeholder' => 'Nom de l\'hôtel suggéré',
  1758.                     'id' => 'hotel_medina',
  1759.                 ]
  1760.             ))
  1761.             ->add('pension', ChoiceType::class, [
  1762.                 'required' => true,
  1763.                 'choices' => [
  1764.                     'Petit déjeuner' => 'Petit-déjeuner',
  1765.                     'Demi pension' => 'Demi-pension',
  1766.                     'Pension complète' => 'Pension-complète',
  1767.                 ],
  1768.                 'placeholder' => "Sélectionnez",
  1769.             ])
  1770.             ->add('categorieHotel', ChoiceType::class, [
  1771.                 'required' => true,
  1772.                 'choices' => [
  1773.                     '2 Étoiles ' => '2-etoiles',
  1774.                     '3 Étoiles' => '3-etoiles',
  1775.                     '4 Étoiles' => '4-etoiles',
  1776.                     '5 Étoiles' => '5-etoiles',
  1777.                 ],
  1778.                 'placeholder' => "Sélectionnez",
  1779.             ])
  1780.             ->add('typeChambre', ChoiceType::class, [
  1781.                 'required' => false,
  1782.                 'choices' => [
  1783.                     'Single ' => 'Single',
  1784.                     'Double' => 'Double',
  1785.                     'Triple' => 'Triple',
  1786.                     'Quadruple' => 'Quadruple',
  1787.                     'Plus (5+)' => 'Plus',
  1788.                 ],
  1789.                 'placeholder' => "Type de Chambre",
  1790.             ])
  1791.             ->add('nbrPersonne', IntegerType::class, array(
  1792.                 'required' => false,
  1793.                 'attr' => [
  1794.                     'placeholder' => 'Nombre de personnes ',
  1795.                     'min' => 1,
  1796.                     'max' => 100,
  1797.                 ]
  1798.             ))
  1799.             ->add('nbJourMekkah', IntegerType::class, array(
  1800.                 'required' => false,
  1801.                 'attr' => [
  1802.                     'min' => 1,
  1803.                     'max' => 100,
  1804.                 ]
  1805.             ))
  1806.             ->add('nbJourMedina', IntegerType::class, array(
  1807.                 'required' => false,
  1808.                 'attr' => [
  1809.                     'min' => 1,
  1810.                     'max' => 100,
  1811.                 ]
  1812.             ))
  1813.             ->add('subject', TextareaType::class, array(
  1814.                 'required' => false,
  1815.                 'attr' => [
  1816.                     'placeholder' => 'Décrivez vos préférences...'
  1817.                 ]
  1818.             ))
  1819.             ->add('code_formulaire', HiddenType::class,
  1820.                 array(
  1821.                     'required' => false,
  1822.                     'data' => 'omra-formulaire' ,
  1823.                 ));
  1824.         $form = $form->getForm();
  1825.         $form->handleRequest($request);
  1826.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  1827.             try {
  1828.                 $data = $form->getData();
  1829.                 $body = $this->renderView('FrontCommun/formulaire_mail_body.html.twig', array(
  1830.                     'nom' => $data['nom'],
  1831.                     'ville_depart' => $data['ville_depart'] ,
  1832.                     'email' => $data['email'] ?? '',
  1833.                     'adulte' => $data['adulte'],
  1834.                     'nbrEnfant' => $data['nbrEnfant'],
  1835.                     'nbrBebe' => $data['nbrBebe'],
  1836.                     'civility' => $data['civility'],
  1837.                     'tel' => $data['tel'],
  1838.                     'nbJourMekkah' => $data['nbJourMekkah'],
  1839.                     'nbJourMedina' => $data['nbJourMedina'],
  1840.                     'subject' => $data['subject'],
  1841.                 ));
  1842.                 $params = array(
  1843.                     'subject' => $data['subject'],
  1844.                     'email' => $data['email'],
  1845.                     'post' => $_POST,
  1846.                     'code_formulaire' => $data['code_formulaire'],
  1847.                     'body' => $body
  1848.                 );
  1849. //               dd( $params);
  1850. //                $result = $WSCMS->SendMailLibre($params);
  1851.                 $params['mailToClient'] = true;
  1852.                 $result = $WSCMS->SendMailLibre($params);
  1853.             } catch (\Exception $e) {
  1854.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  1855.                 return new Response($msg);
  1856.             }
  1857.             if ($result != 0) {
  1858.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  1859.             } else {
  1860.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  1861.             }
  1862.             return new Response($msg);
  1863.         }
  1864.         $configAffichage = array();
  1865.         if (!is_null($WSCMS->ConfigFrontOffice()))
  1866.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  1867.         return $this->render($this->service->checkCustomTemplate('omra_carte_formulaire.html.twig'), array(
  1868.             'infoAgence' => $infoAgence,
  1869.             'form' => $form->createView(),
  1870.             'configAffichage' => $configAffichage,
  1871.         ));
  1872.     }
  1873.     /**
  1874.      * @Route("/omra-carte", name="omra_carte_form")
  1875.      *
  1876.      */
  1877.     public function formOmraCarte(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  1878.     {
  1879.         $infoAgence = $generaleExtension->getAgence()['information'];
  1880.         $form = $this->createFormBuilder(null, ['csrf_protection' => true])
  1881.             ->add('nombre_adultes', IntegerType::class, array(
  1882.                 'required' => TRUE,
  1883.                 'attr' => [
  1884.                     'placeholder' => 'Nombre adulte' ,
  1885.                     'min' => 1,
  1886.                     'max' => 20,
  1887.                 ]
  1888.             ))
  1889.             ->add('nombre_enfant', IntegerType::class, array(
  1890.                 'required' => TRUE,
  1891.                 'attr' => [
  1892.                     'placeholder' => 'Nombre d enfant' ,
  1893.                     'min' => 0,
  1894.                     'max' => 5,
  1895.                 ]
  1896.             ))
  1897.             ->add('nombre_bebe', IntegerType::class, array(
  1898.                 'required' => TRUE,
  1899.                 'attr' => [
  1900.                     'placeholder' => 'Nombre bébés' ,
  1901.                     'min' => 0,
  1902.                     'max' => 5,
  1903.                 ]
  1904.             ))
  1905.             ->add('civilite', ChoiceType::class, [
  1906.                 'choices' => [
  1907.                     'Mr' => 'Mr',
  1908.                     'Mme' => 'Mme',
  1909.                     'Mlle' => 'Mlle',
  1910.                 ]
  1911.             ])
  1912.             ->add('nom', TextType::class, array(
  1913.                 'required' => TRUE,
  1914.                 'attr' => [
  1915.                     'placeholder' => 'nom & prénom'
  1916.                 ]
  1917.             ))
  1918.             ->add('tel', TextType::class, array(
  1919.                 'required' => TRUE,
  1920.                 'attr' => [
  1921.                     'placeholder' => 'Entrer votre Téléphone' ,
  1922.                     'type'        => 'tel',
  1923.                     'inputmode'   => 'tel',
  1924.                     'pattern'     => '[0-9+\s\-\(\)]*',
  1925.                     'title'       => 'Veuillez saisir uniquement des chiffres',
  1926.                     'maxlength'   => 20,
  1927.                 ]
  1928.             ))
  1929.             ->add('email', EmailType::class, array(
  1930.                 'required' => TRUE,
  1931.                 'attr' => [
  1932.                     'placeholder' => 'Entrer votre email'
  1933.                 ]
  1934.             ))
  1935.             ->add('ville_depart', TextType::class, array(
  1936.                 'required' => TRUE,
  1937.                 'attr' => [
  1938.                     'placeholder' => 'ville départ' ,
  1939.                 ]
  1940.             ))
  1941.             ->add('date_depart', DateType::class, array(
  1942.                 'required' => TRUE,
  1943.                 'format' => 'yyyy-MM-dd',
  1944.                 'widget' => 'single_text',
  1945.                 'attr' => [
  1946.                     'min' => (new \DateTime('today'))->format('Y-m-d'),
  1947.                 ]
  1948.             ))
  1949.             ->add('chambre_type', ChoiceType::class, [
  1950.                 'choices' => [
  1951.                     'Single' => 'Single',
  1952.                     'Double' => 'Double',
  1953.                     'Triple' => 'Triple',
  1954.                     'Quadruple' => 'Quadruple',
  1955.                     'Junior suite' => 'Junior suite',
  1956.                     'Deluxe suite' => 'Deluxe suite',
  1957.                     'Royal suite' => 'Royal suite'
  1958.                 ]
  1959.             ])
  1960.             ->add('visa_type', ChoiceType::class, [
  1961.                 'choices' => [
  1962.                     'Touristique' => 'Touristique',
  1963.                     'Hajj' => 'Hajj',
  1964.                     'Schengen' => 'Triple',
  1965.                     'Quadruple' => 'Schengen',
  1966.                     'Omra' => 'Omra',
  1967.                     'Américain (USA)' => 'Américain (USA)'
  1968.                 ]
  1969.             ])
  1970.             ->add('list_hotel_makka', ChoiceType::class, [
  1971.                 'choices' => [
  1972.                     'Swissotel Al Maqam Makkah' => 'Swissotel Al Maqam Makkah',
  1973.                     'Swissotel Makkah' => 'Swissotel Makkah',
  1974.                     'Al Shohada Hotel' => 'Al Shohada Hotel',
  1975.                     'Jabal Omar Hyatt Regency Makkah' => 'Jabal Omar Hyatt Regency Makkah',
  1976.                     'Fairmont Makkah Clock Royal Tower' => 'Fairmont Makkah Clock Royal Tower',
  1977.                     'Raffles Makkah Palace' => 'Raffles Makkah Palace',
  1978.                     'Anjum Hotel Makkah' => 'Anjum Hotel Makkah',
  1979.                     'Pullman Zamzam Makkah' => 'Pullman Zamzam Makkah',
  1980.                     'Hilton Makkah' => 'Hilton Makkah',
  1981.                     'Shaza Makkah' => 'Shaza Makkah',
  1982.                     'Sheraton Makkah ' => 'Sheraton Makkah ',
  1983.                 ]
  1984.             ])
  1985.             ->add('list_hotel_medine', ChoiceType::class, [
  1986.                 'choices' => [
  1987.                     'Swissotel Madinah Hilton' => 'Swissotel Madinah Hilton',
  1988.                     ' Intercontinental Madinah-Dar Al Iman' => ' Intercontinental Madinah-Dar Al Iman',
  1989.                     'Hôtel pullman Zamzam Madinah' => 'Hôtel pullman Zamzam Madinah',
  1990.                     'Sofitel Shahd Al Madinah' => 'Sofitel Shahd Al Madinah',
  1991.                     'Intercontinental Dar Al Hijra' => 'Intercontinental Dar Al Hijra',
  1992.                     'Intercontinental Madinah-Dar Al Iman' => 'Intercontinental Madinah-Dar Al Iman',
  1993.                     'Dar Al Taqwa Hotel Madinah' => 'Dar Al Taqwa Hotel Madinah',
  1994.                     'Pullman Zamzam Makkah' => 'Pullman Zamzam Makkah',
  1995.                     'The Oberoi, Madina' => 'The Oberoi, Madina'
  1996.                 ]
  1997.             ])
  1998.             ->add('type_transfert', ChoiceType::class, [
  1999.                 'choices' => [
  2000.                     'TGV' => 'TGV',
  2001.                     'VOITURE' => 'VOITURE'
  2002.                 ]
  2003.             ])
  2004.             ->add('nbr_jour_makka', TextType::class, array(
  2005.                 'required' => TRUE,
  2006.                 'attr' => [
  2007.                     'placeholder' => 'Nombre de jour makka'
  2008.                 ]
  2009.             ))
  2010.             ->add('nbr_jour_medina', TextType::class, array(
  2011.                 'required' => TRUE,
  2012.                 'attr' => [
  2013.                     'placeholder' => 'Nombre de jour medine'
  2014.                 ]
  2015.             ))
  2016.             ->add('subject', TextareaType::class, array(
  2017.                 'required' => TRUE,
  2018.                 'attr' => [
  2019.                     'placeholder' => 'Commentaire'
  2020.                 ]
  2021.             ))
  2022.             ->add('code_formulaire', HiddenType::class,
  2023.                 array(
  2024.                     'required' => false,
  2025.                     'data' => 'Formulaire_Omra_carte',
  2026.                 ));
  2027.         $form = $form->getForm();
  2028.         $form->handleRequest($request);
  2029.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  2030.             try {
  2031.                 $data = $form->getData();
  2032.                 $body = $this->renderView($this->service->checkCustomTemplate('formulaire_mail_omra_carte.html.twig'), array(
  2033.                     'nom' => $data['nom'],
  2034.                     'ville_depart' => $data['ville_depart'] ?? '',
  2035.                     'email' => $data['email'],
  2036.                     'nombre_adultes' => $data['nombre_adultes'],
  2037.                     'nombre_enfant' => $data['nombre_enfant'],
  2038.                     'nombre_bebe' => $data['nombre_bebe'],
  2039.                     'civilite' => $data['civilite'],
  2040.                     'tel' => $data['tel'],
  2041.                     'chambre_type' => $data['chambre_type'],
  2042.                     'visa_type' => $data['visa_type'],
  2043.                     'list_hotel_makka' => $data['list_hotel_makka'],
  2044.                     'list_hotel_medine' => $data['list_hotel_medine'],
  2045.                     'type_transfert' => $data['type_transfert'],
  2046.                     'nbr_jour_makka' => $data['nbr_jour_makka'],
  2047.                     'nbr_jour_medina' => $data['nbr_jour_medina'],
  2048.                     'subject' => $data['subject'],
  2049.                 ));
  2050.                 $params = array(
  2051.                     'subject' => $data['subject'],
  2052.                     'email' => $data['email'],
  2053.                     'post' => $_POST,
  2054.                     'code_formulaire' => $data['code_formulaire'],
  2055.                     'body' => $body
  2056.                 );
  2057. //               dd( $params);
  2058. //                $result = $WSCMS->SendMailLibre($params);
  2059.                 $params['mailToClient'] = true;
  2060.                 $result = $WSCMS->SendMailLibre($params);
  2061.             } catch (\Exception $e) {
  2062.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  2063.                 return new Response($msg);
  2064.             }
  2065.             if ($result != 0) {
  2066.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  2067.             } else {
  2068.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  2069.             }
  2070.             return new Response($msg);
  2071.         }
  2072.         $configAffichage = array();
  2073.         if (!is_null($WSCMS->ConfigFrontOffice()))
  2074.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  2075.         return $this->render($this->service->checkCustomTemplate('formulaire_omra_carte.html.twig'), array(
  2076.             'infoAgence' => $infoAgence,
  2077.             'form' => $form->createView(),
  2078.             'configAffichage' => $configAffichage,
  2079.         ));
  2080.     }
  2081.     /**
  2082.      * @Route("/vol", name="vol")
  2083.      */
  2084.     public function vol(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  2085.     {
  2086.         if (isset($_SERVER['FLIGHTS_WORLDSOFT_SUB_DOMAINE'])) {
  2087.             if (!isset($_COOKIE['WSSESSIONID'])) {
  2088.                 $client = $this->get('session')->get('client');
  2089.                 if (isset($client['amicale']['id']) and $client['amicale']['modules']['vol']) {
  2090.                     $professionalId = $_SERVER['FLIGHTS_WORLDSOFT_PROFESSIONAL_ID'];
  2091.                     $partnerId = $this->get('session')->get('client')['amicale']['id'];
  2092.                     $apiKey = $_SERVER['FLIGHTS_WORLDSOFT_API_KEY'];
  2093.                     $ch = curl_init();
  2094.                     curl_setopt($ch, CURLOPT_URL, "{$_SERVER['FLIGHTS_WORLDSOFT_SUB_DOMAINE']}/rest/b2b/CreateSession?professionalId=$professionalId&partnerId=$partnerId&apiKey=$apiKey");
  2095.                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  2096.                     $output = curl_exec($ch);
  2097.                     $info = curl_getinfo($ch);
  2098.                     $curl_error = curl_error($ch);
  2099.                     curl_close($ch);
  2100.                     $res = json_decode($output, true);
  2101.                     if ($res['success'])
  2102.                         setcookie("WSSESSIONID", $res['sessionId'], 0, "/", ".{$_SERVER['HTTP_HOST']}", false, true);
  2103.                     else
  2104.                         setcookie("WSSESSIONID", $res['error'], 0, "/", ".{$_SERVER['HTTP_HOST']}", false, true);
  2105.                 }
  2106.             }
  2107.             return $this->redirect($_SERVER['FLIGHTS_WORLDSOFT_SUB_DOMAINE']);
  2108.         }
  2109.         $form = $this->createFormBuilder()
  2110.             ->add('email', EmailType::class, array(
  2111.                 'required' => TRUE,
  2112.                 'attr' => [
  2113.                     'placeholder' => 'Entrer votre email'
  2114.                 ]
  2115.             ))
  2116.             ->add('nom', TextType::class, array(
  2117.                 'required' => TRUE,
  2118.                 'attr' => [
  2119.                     'placeholder' => 'nom & prénom'
  2120.                 ]
  2121.             ))->add('depart', TextType::class, array(
  2122.                 'required' => TRUE,
  2123.                 'attr' => [
  2124.                     'placeholder' => 'ville départ'
  2125.                 ]
  2126.             ))
  2127.             ->add('datedepart', DateType::class, array(
  2128.                 'required' => TRUE,
  2129.                 'format' => 'yyyy-MM-dd',
  2130.                 'widget' => 'single_text',
  2131.             ))->add('datearrive', DateType::class, array(
  2132.                 'required' => TRUE,
  2133.                 'format' => 'yyyy-MM-dd',
  2134.                 'widget' => 'single_text',
  2135.             ))
  2136.             ->add('arrive', TextType::class, array(
  2137.                 'required' => TRUE,
  2138.                 'attr' => [
  2139.                     'placeholder' => 'ville arrivée'
  2140.                 ]
  2141.             ))
  2142.             ->add('tel', TextType::class, array(
  2143.                 'required' => TRUE,
  2144.                 'attr' => [
  2145.                     'placeholder' => 'Entrer votre Téléphone'
  2146.                 ]
  2147.             ))
  2148.             ->add('company', TextType::class, array(
  2149.                 'required' => TRUE,
  2150.                 'attr' => [
  2151.                     'placeholder' => 'Compagnie souhaitée'
  2152.                 ]
  2153.             ))
  2154.             ->add('passager', TextType::class, array(
  2155.                 'required' => TRUE,
  2156.                 'attr' => [
  2157.                     'placeholder' => 'Nom passager'
  2158.                 ]
  2159.             ))
  2160.             ->add('age', TextType::class, array(
  2161.                 'required' => TRUE,
  2162.                 'attr' => [
  2163.                     'placeholder' => 'Age passager'
  2164.                 ]
  2165.             ))
  2166.             ->add('classe', ChoiceType::class, [
  2167.                 'choices' => [
  2168.                     'Economy' => 'Economy',
  2169.                     'First' => 'First',
  2170.                     'Business' => 'Business',
  2171.                 ]
  2172.             ])
  2173.             ->add('vol', ChoiceType::class, [
  2174.                 'choices' => [
  2175.                     'Aller-Retour' => 'Aller-Retour',
  2176.                     'Aller-Simple' => 'Aller-Simple',
  2177.                     'Multi-Segments' => 'Multi-Segments',
  2178.                 ],
  2179.             ])
  2180.             ->add('subject', TextareaType::class, array(
  2181.                 'required' => TRUE,
  2182.                 'attr' => [
  2183.                     'placeholder' => 'Commentaire'
  2184.                 ]
  2185.             ))
  2186.             ->getForm();
  2187.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  2188.             try {
  2189.                 parse_str($request->request->get('form'), $form);
  2190.                 $data = $form['form'];
  2191.                 $body = $this->renderView('FrontCommun/formulaire_mail_vol.html.twig', array(
  2192.                     'nom' => $data['nom'],
  2193.                     'depart' => $data['depart'],
  2194.                     'email' => $data['email'],
  2195.                     'datedepart' => $data['datedepart'],
  2196.                     'datearrive' => $data['datearrive'],
  2197.                     'tel' => $data['tel'],
  2198.                     'classe' => $data['classe'],
  2199.                     'vol' => $data['vol'],
  2200.                     'company' => $data['company'],
  2201.                     'arrive' => $data['arrive'],
  2202.                     'ages' => $data['age'],
  2203.                     'passagers' => $data['passager'],
  2204.                     'subject' => $data['subject'],
  2205.                 ));
  2206.                 $params = array(
  2207.                     'email' => $data['email'],
  2208.                     'subject' => $data['subject'],
  2209.                     'body' => $body,
  2210.                 );
  2211.                 $result = $WSCMS->SendMailLibre($params);
  2212.                 $params['mailToClient'] = true;
  2213.                 $result = $WSCMS->SendMailLibre($params);
  2214.             } catch (\Exception $e) {
  2215.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  2216.                 return new Response($msg);
  2217.             }
  2218.             if ($result != 0) {
  2219.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  2220.             } else {
  2221.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  2222.             }
  2223.             return new Response($msg);
  2224.         }
  2225.         $configAffichage = array();
  2226.         if (!is_null($WSCMS->ConfigFrontOffice()))
  2227.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  2228.         return $this->render($this->service->checkCustomTemplate('demande_billetterie.html.twig'), array(
  2229.             'form' => $form->createView(),
  2230.             'configAffichage' => $configAffichage,
  2231.         ));
  2232.     }
  2233.     /**
  2234.      * @Route("/maritime", name="maritime")
  2235.      */
  2236.     public function maritime(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  2237.     {
  2238.         $form = $this->createFormBuilder()
  2239.             ->add('nomPrenom', TextType::class, array(
  2240.                 'required' => TRUE,
  2241.                 'attr' => [
  2242.                     'placeholder' => 'Nom & Prénom'
  2243.                 ]
  2244.             ))
  2245.             ->add('gsm', TextType::class, array(
  2246.                 'required' => TRUE,
  2247.                 'attr' => [
  2248.                     'placeholder' => 'GSM'
  2249.                 ]
  2250.             ))
  2251.             ->add('email', EmailType::class, array(
  2252.                 'required' => TRUE,
  2253.                 'attr' => [
  2254.                     'placeholder' => 'Email'
  2255.                 ]
  2256.             ))
  2257.             ->add('cin', TextType::class, array(
  2258.                 'required' => TRUE,
  2259.                 'attr' => [
  2260.                     'placeholder' => 'CIN'
  2261.                 ]
  2262.             ))
  2263.             ->add('typeVoyage', ChoiceType::class, [
  2264.                     'choices' => [
  2265.                         1 => "Aller-Retour",
  2266.                         2 => "Aller-Simple",
  2267.                         3 => "Retour-Differt",
  2268.                     ]
  2269.                 ]
  2270.             )
  2271.             ->add('typeReservation', ChoiceType::class, [
  2272.                     'required' => true,
  2273.                     'choices' => [
  2274.                         1 => 'Emission',
  2275.                         //2 => 'Annulation',
  2276.                         3 => 'Remboursement',
  2277.                         4 => 'Modification',
  2278.                     ]
  2279.                 ]
  2280.             )
  2281.             ->add('cabine', ChoiceType::class, [
  2282.                     'choices' => [
  2283.                         1 => "Fauteuil",
  2284.                         2 => "Cabine-Exterieur",
  2285.                         3 => "Cabine-Interieur",
  2286.                         4 => "Couchette Int",
  2287.                         5 => "Cab. Single Int",
  2288.                         6 => "Cab. Double Int",
  2289.                         7 => "Cab. Triple Int",
  2290.                         8 => "Cab. Quad Int",
  2291.                         9 => "Couchette Ext",
  2292.                         10 => "Cab. Single EXT",
  2293.                         11 => "Cab. Double Ext",
  2294.                         12 => "Cab. Triple Ext",
  2295.                         13 => "Cab. Quad Ext",
  2296.                         14 => "Cab Accès animaux int/ Ext",
  2297.                         15 => "Suite single",
  2298.                         16 => "Suite matrimoniale",
  2299.                         17 => "Suite familiale",
  2300.                         18 => "Suite présidentielle"
  2301.                     ]
  2302.                 ]
  2303.             )
  2304.             ->add('passagers', ChoiceType::class, [
  2305.                     'choices' => [
  2306.                         1 => "Résident",
  2307.                         2 => "Non-Résident",
  2308.                         3 => "Diplomat",
  2309.                         4 => "Etudiant",
  2310.                     ]
  2311.                 ]
  2312.             )
  2313.             ->add('lieuDepart', TextType::class, array(
  2314.                 'required' => TRUE,
  2315.                 'attr' => [
  2316.                     'placeholder' => 'Lieu départ'
  2317.                 ]
  2318.             ))
  2319.             ->add('lieuArrivee', TextType::class, array(
  2320.                 'required' => TRUE,
  2321.                 'attr' => [
  2322.                     'placeholder' => 'Lieu arrivée'
  2323.                 ]
  2324.             ))
  2325.             ->add('dateDepart', DateType::class, array(
  2326.                 'widget' => 'single_text',
  2327.                 'format' => 'yyyy-MM-dd',
  2328.             ))
  2329.             ->add('commentaire', TextareaType::class, array('required' => false));
  2330.         $form = $form->getForm();
  2331.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  2332.             try {
  2333.                 parse_str($request->request->get('form'), $form);
  2334.                 $data = $form['form'];
  2335.                 /* dd($data);*/
  2336.                 $body = $this->renderView('FrontCommun/formulaire_mail_body.html.twig', array(
  2337.                     'nom' => $data['nomPrenom'],
  2338.                     'depart' => $data['lieuDepart'],
  2339.                     'arrivee' => $data['lieuArrivee'],
  2340.                     'email' => $data['email'],
  2341.                     'datedepart' => $data['dateDepart'],
  2342.                     'tel' => $data['gsm'],
  2343.                     'passagers' => $data['passagers'],
  2344.                     'cabine' => $data['cabine'],
  2345.                     'typeVoyage' => $data['typeVoyage'],
  2346.                     'cin' => $data['cin'],
  2347.                     'typeReservation' => $data['typeReservation'],
  2348.                     'subject' => $data['commentaire'],
  2349.                 ));
  2350.                 $params = array(
  2351.                     'email' => $data['email'],
  2352.                     'subject' => $data['commentaire'],
  2353.                     'body' => $body,
  2354.                 );
  2355.                 $result = $WSCMS->SendMailLibre($params);
  2356.                 $params['mailToClient'] = true;
  2357.                 $result = $WSCMS->SendMailLibre($params);
  2358.             } catch (\Exception $e) {
  2359.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  2360.                 return new Response($msg);
  2361.             }
  2362.             if ($result != 0) {
  2363.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  2364.             } else {
  2365.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  2366.             }
  2367.             return new Response($msg);
  2368.         }
  2369.         $configAffichage = array();
  2370.         if (!is_null($WSCMS->ConfigFrontOffice()))
  2371.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  2372.         return $this->render($this->service->checkCustomTemplate('demande_maritime.html.twig'), array(
  2373.             'form' => $form->createView(),
  2374.             'configAffichage' => $configAffichage,
  2375.         ));
  2376.     }
  2377.     /**
  2378.      * @Route("/location-bus", name="location_bus")
  2379.      */
  2380.     public function locationBus(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  2381.     {
  2382.         $infoAgence = $generaleExtension->getAgence()['information'];
  2383.         $form = $this->createFormBuilder(null, ['csrf_protection' => true])
  2384.             ->add('titre', ChoiceType::class, [
  2385.                     'choices' => [
  2386.                         "Mr" => "Mr",
  2387.                         "Mme" => "Mme",
  2388.                         "Mlle" => "Mlle",
  2389.                     ]
  2390.                 ]
  2391.             )
  2392.             ->add('nomPrenom', TextType::class, array(
  2393.                 'required' => TRUE,
  2394.                 'attr' => [
  2395.                     'placeholder' => 'Nom & Prénom'
  2396.                 ]
  2397.             ))
  2398.             ->add('typeTransfert', ChoiceType::class, [
  2399.                 'choices' => [
  2400.                     "Transfert simple" => "transfert-simple",
  2401.                     "Transfert aller-retour" => "transfert_aller_retour",
  2402.                     "Mise à disposition à la journée" => "Mise-à-disposition-à-la-journée",
  2403.                     "Mise à disposition pour plusieurs jours" => "Mise-à-isposition-pour-plusieurs-jours",
  2404.                 ],
  2405.                 'expanded' => true,
  2406.                 'multiple' => false,
  2407.                 'label' => false,
  2408.                 'data' => 'transfert-simple',
  2409.             ])
  2410.             ->add('age', TextType::class, array(
  2411.                 'required' => false,
  2412.                 'attr' => [
  2413.                     'placeholder' => 'Age'
  2414.                 ]
  2415.             ))
  2416.             ->add('tel', TextType::class, array(
  2417.                 'required' => false,
  2418.                 'attr' => [
  2419.                     'placeholder' => 'téléphone'
  2420.                 ]
  2421.             ))
  2422.             ->add('email', EmailType::class, array(
  2423.                 'required' => TRUE,
  2424.                 'attr' => [
  2425.                     'placeholder' => 'Email'
  2426.                 ]
  2427.             ))
  2428.             ->add('adresse', TextType::class, array(
  2429.                 'required' => false,
  2430.                 'attr' => [
  2431.                     'placeholder' => 'adresse'
  2432.                 ]
  2433.             ))
  2434.             ->add('ville', TextType::class, array(
  2435.                 'required' => false,
  2436.                 'attr' => [
  2437.                     'placeholder' => 'ville'
  2438.                 ]
  2439.             ))
  2440.             ->add('codePostal', TextType::class, array(
  2441.                 'required' => false,
  2442.                 'attr' => [
  2443.                     'placeholder' => 'Code Postal'
  2444.                 ]
  2445.             ))
  2446.             ->add('typeBus', ChoiceType::class, [
  2447.                 'choices' => [
  2448.                     "Grand bus" => "Grand bus",
  2449.                     "Mini bus" => "Mini bus",
  2450.                 ]
  2451.             ])
  2452.             ->add('destination', TextType::class, array(
  2453.                 'required' => TRUE,
  2454.                 'attr' => [
  2455.                     'placeholder' => 'Destination'
  2456.                 ]
  2457.             ))
  2458.             ->add('nbrPersonne', IntegerType::class, array(
  2459.                 'required' => false,
  2460.                 'attr' => [
  2461.                     'placeholder' => 'Nombre de personnes ',
  2462.                     'min' => 1,
  2463.                     'max' => 100,
  2464.                 ]
  2465.             ))
  2466.             ->add('depart', ChoiceType::class, array(
  2467.                 'required' => TRUE,
  2468.                 'choices' => [
  2469.                     "Aeroport djerba" => "Aéroport djerba",
  2470.                     "Aeroport enfidha" => "Aéroport enfidha",
  2471.                     "Aeroport monastir" => "Aéroport monastir",
  2472.                     "Aeroport tunis carthage" => "Aéroport tunis carthage",
  2473.                     "Djerba" => "Djerba",
  2474.                     "Hammamet" => "Hammamet",
  2475.                     "Nabeul" => "Nabeul",
  2476.                     "Sousse" => "Sousse",
  2477.                     "Tozeur" => "Tozeur",
  2478.                     "Tunis" => "Tunis",
  2479.                 ]
  2480.             ))
  2481.             ->add('retour', ChoiceType::class, array(
  2482.                 'required' => TRUE,
  2483.                 'choices' => [
  2484.                     "Aeroport djerba" => "Aéroport djerba",
  2485.                     "Aeroport enfidha" => "Aéroport enfidha",
  2486.                     "Aeroport monastir" => "Aéroport monastir",
  2487.                     "Aeroport tunis carthage" => "Aéroport tunis carthage",
  2488.                     "Djerba" => "Djerba",
  2489.                     "Hammamet" => "Hammamet",
  2490.                     "Nabeul" => "Nabeul",
  2491.                     "Sousse" => "Sousse",
  2492.                     "Tozeur" => "Tozeur",
  2493.                     "Tunis" => "Tunis",
  2494.                 ]
  2495.             ))
  2496.             ->add('dateDepart', DateType::class, array(
  2497.                 'widget' => 'single_text',
  2498.                 'format' => 'yyyy-MM-dd',
  2499.                 'required' => TRUE,
  2500.             ))
  2501.             ->add('dateRetour', DateType::class, array(
  2502.                 'widget' => 'single_text',
  2503.                 'format' => 'yyyy-MM-dd',
  2504.                 'required' => TRUE,
  2505.             ))
  2506.             ->add('heureDepart', TimeType::class, array(
  2507.                 'input' => 'datetime',
  2508.                 'widget' => 'choice',
  2509.                 'required' => TRUE,
  2510.             ))
  2511.             ->add('heureRetour', TimeType::class, array(
  2512.                 'input' => 'datetime',
  2513.                 'widget' => 'choice',
  2514.                 'required' => TRUE,
  2515.             ))
  2516.             ->add('commentaire', TextareaType::class,
  2517.                 array(
  2518.                     'required' => true
  2519.                 ))
  2520.             ->add('code_formulaire', HiddenType::class,
  2521.                 array(
  2522.                     'required' => false,
  2523.                     'data' => 'Demande_Location_Bus',
  2524.                 ));
  2525.         $form = $form->getForm();
  2526.         $form->handleRequest($request);
  2527.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  2528.             try {
  2529. //                parse_str($request->request->get('form'), $form);
  2530.                 $data = $form->getData();
  2531.                 $body = $this->renderView($this->service->checkCustomTemplate('formulaire_mail_location_bus.html.twig'), array(
  2532.                     'nomPrenom' => $data['nomPrenom'],
  2533.                     'titre' => $data['titre'],
  2534.                     'age' => $data['age'],
  2535.                     'adresse' => $data['adresse'],
  2536.                     'ville' => $data['ville'],
  2537.                     'codePostal' => $data['codePostal'],
  2538.                     'tel' => $data['tel'],
  2539.                     'email' => $data['email'],
  2540.                     'typeBus' => $_POST['form']['typeBus'],
  2541.                     'destination' => $data['destination'],
  2542.                     'nbrPersonne' => $data['nbrPersonne'],
  2543.                     'depart' => $data['depart'],
  2544.                     'retour' => $data['retour'],
  2545.                     'dateDepart' => !is_null($data['dateDepart']) ? $data['dateDepart']->format('d-m-Y') : '',
  2546.                     'dateRetour' => !is_null($data['dateRetour']) ? $data['dateRetour']->format('d-m-Y') : '',
  2547.                     'heureDepart' => !is_null($data['heureDepart']) ? $data['heureDepart']->format('H:i') : '',
  2548.                     'heureRetour' => !is_null($data['heureRetour']) ? $data['heureRetour']->format('H:i') : '',
  2549.                     'subject' => $data['commentaire'],
  2550.                     'typeTransfert' => $data['typeTransfert'],
  2551.                 ));
  2552.                 $_POST['form']['heureDepart'] = "{$_POST['form']['heureDepart']['hour']}:{$_POST['form']['heureDepart']['minute']}";
  2553.                 $params = array(
  2554.                     'email' => $data['email'],
  2555.                     'subject' => $data['commentaire'],
  2556.                     'post' => $_POST,
  2557.                     'code_formulaire' => $data['code_formulaire'],
  2558.                     'body' => $body,
  2559.                 );
  2560. //                dd( $_POST);
  2561. //                $result = $WSCMS->SendMailLibre($params);
  2562.                 $params['mailToClient'] = true;
  2563.                 $result = $WSCMS->SendMailLibre($params);
  2564.             } catch (\Exception $e) {
  2565.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  2566.                 return new Response($msg);
  2567.             }
  2568.             if ($result != 0) {
  2569.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  2570.             } else {
  2571.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  2572.             }
  2573.             return new Response($msg);
  2574.         }
  2575.         $configAffichage = array();
  2576.         if (!is_null($WSCMS->ConfigFrontOffice()))
  2577.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  2578.         return $this->render($this->service->checkCustomTemplate('demande_location_bus.html.twig'), array(
  2579.             'infoAgence' => $infoAgence,
  2580.             'form' => $form->createView(),
  2581.             'configAffichage' => $configAffichage,
  2582.         ));
  2583.     }
  2584.     /**
  2585.      * @Route("/location-voiture", name="location_voiture")
  2586.      */
  2587.     public function locationVoiture(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  2588.     {
  2589.         $form = $this->createFormBuilder()
  2590.             ->add('titre', ChoiceType::class, [
  2591.                     'choices' => [
  2592.                         "Mr" => "Mr",
  2593.                         "Mme" => "Mme",
  2594.                         "Mlle" => "Mlle",
  2595.                     ]
  2596.                 ]
  2597.             )
  2598.             ->add('nomPrenom', TextType::class, array(
  2599.                 'required' => TRUE,
  2600.                 'attr' => [
  2601.                     'placeholder' => 'Nom & Prénom'
  2602.                 ]
  2603.             ))
  2604.             ->add('age', TextType::class, array(
  2605.                 'required' => false,
  2606.                 'attr' => [
  2607.                     'placeholder' => 'Age'
  2608.                 ]
  2609.             ))
  2610.             ->add('tel', TextType::class, array(
  2611.                 'required' => false,
  2612.                 'attr' => [
  2613.                     'placeholder' => 'téléphone'
  2614.                 ]
  2615.             ))
  2616.             ->add('email', EmailType::class, array(
  2617.                 'required' => TRUE,
  2618.                 'attr' => [
  2619.                     'placeholder' => 'Email'
  2620.                 ]
  2621.             ))
  2622.             ->add('adresse', TextType::class, array(
  2623.                 'required' => false,
  2624.                 'attr' => [
  2625.                     'placeholder' => 'adresse'
  2626.                 ]
  2627.             ))
  2628.             ->add('ville', TextType::class, array(
  2629.                 'required' => false,
  2630.                 'attr' => [
  2631.                     'placeholder' => 'ville'
  2632.                 ]
  2633.             ))
  2634.             ->add('codePostal', TextType::class, array(
  2635.                 'required' => false,
  2636.                 'attr' => [
  2637.                     'placeholder' => 'Code Postal'
  2638.                 ]
  2639.             ))
  2640.             ->add('typeVoiture', ChoiceType::class, [
  2641.                     'choices' => [
  2642.                         "Jamp" => "Jamp",
  2643.                         "4 * 4" => "4 * 4",
  2644.                     ]
  2645.                 ]
  2646.             )
  2647.             ->add('destination', TextType::class, array(
  2648.                 'required' => TRUE,
  2649.                 'attr' => [
  2650.                     'placeholder' => 'Destination'
  2651.                 ]
  2652.             ))
  2653.             ->add('nbrPersonne', TextType::class, array(
  2654.                 'required' => false,
  2655.                 'attr' => [
  2656.                     'placeholder' => 'Nombre de personnes'
  2657.                 ]
  2658.             ))
  2659.             ->add('depart', ChoiceType::class, array(
  2660.                 'required' => TRUE,
  2661.                 'choices' => [
  2662.                     "Aeroport djerba" => "Aéroport djerba",
  2663.                     "Aeroport enfidha" => "Aéroport enfidha",
  2664.                     "Aeroport monastir" => "Aéroport monastir",
  2665.                     "Aeroport tunis carthage" => "Aéroport tunis carthage",
  2666.                     "Djerba" => "Djerba",
  2667.                     "Hammmamet" => "Hammmamet",
  2668.                     "Nabeul" => "Nabeul",
  2669.                     "Sousse" => "Sousse",
  2670.                     "Tozeur" => "Tozeur",
  2671.                     "Tunis" => "Tunis",
  2672.                 ]
  2673.             ))
  2674.             ->add('retour', ChoiceType::class, array(
  2675.                 'required' => TRUE,
  2676.                 'choices' => [
  2677.                     "Aeroport djerba" => "Aéroport djerba",
  2678.                     "Aeroport enfidha" => "Aéroport enfidha",
  2679.                     "Aeroport monastir" => "Aéroport monastir",
  2680.                     "Aeroport tunis carthage" => "Aéroport tunis carthage",
  2681.                     "Djerba" => "Djerba",
  2682.                     "Hammmamet" => "Hammmamet",
  2683.                     "Nabeul" => "Nabeul",
  2684.                     "Sousse" => "Sousse",
  2685.                     "Tozeur" => "Tozeur",
  2686.                     "Tunis" => "Tunis",
  2687.                 ]
  2688.             ))
  2689.             ->add('dateDepart', DateType::class, array(
  2690.                 'widget' => 'single_text',
  2691.                 'format' => 'yyyy-MM-dd',
  2692.                 'required' => TRUE,
  2693.             ))
  2694.             ->add('dateRetour', DateType::class, array(
  2695.                 'widget' => 'single_text',
  2696.                 'format' => 'yyyy-MM-dd',
  2697.                 'required' => TRUE,
  2698.             ))
  2699.             ->add('heureDepart', TimeType::class, array(
  2700.                 'input' => 'datetime',
  2701.                 'widget' => 'choice',
  2702.                 'required' => TRUE,
  2703.             ))
  2704.             ->add('heureRetour', TimeType::class, array(
  2705.                 'input' => 'datetime',
  2706.                 'widget' => 'choice',
  2707.                 'required' => TRUE,
  2708.             ))
  2709.             ->add('commentaire', TextareaType::class, array('required' => true));
  2710.         $form = $form->getForm();
  2711.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  2712.             try {
  2713.                 parse_str($request->request->get('form'), $form);
  2714.                 $data = $form['form'];
  2715.                 /* dd($data);*/
  2716.                 $body = $this->renderView('FrontCommun/formulaire_mail_body.html.twig', array(
  2717.                     'nom' => $data['nomPrenom'],
  2718.                     'titre' => $data['titre'],
  2719.                     'age' => $data['age'],
  2720.                     'adresse' => $data['adresse'],
  2721.                     'ville' => $data['ville'],
  2722.                     'codePostal' => $data['codePostal'],
  2723.                     'tel' => $data['tel'],
  2724.                     'email' => $data['email'],
  2725.                     'typeVoiture' => $data['typeVoiture'],
  2726.                     'destination' => $data['destination'],
  2727.                     'nbrPersonne' => $data['nbrPersonne'],
  2728.                     'depart' => $data['depart'],
  2729.                     'retour' => $data['retour'],
  2730.                     'datedepart' => $data['dateDepart'],
  2731.                     'dateRetour' => $data['dateRetour'],
  2732.                     'heureDepart' => $data['heureDepart'],
  2733.                     'heureRetour' => $data['heureRetour'],
  2734.                     'subject' => $data['commentaire'],
  2735.                 ));
  2736.                 $params = array(
  2737.                     'email' => $data['email'],
  2738.                     'subject' => $data['commentaire'],
  2739.                     'body' => $body,
  2740.                 );
  2741.                 $result = $WSCMS->SendMailLibre($params);
  2742.                 $params['mailToClient'] = true;
  2743.                 $result = $WSCMS->SendMailLibre($params);
  2744.             } catch (\Exception $e) {
  2745.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  2746.                 return new Response($msg);
  2747.             }
  2748.             if ($result != 0) {
  2749.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  2750.             } else {
  2751.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  2752.             }
  2753.             return new Response($msg);
  2754.         }
  2755.         $configAffichage = array();
  2756.         if (!is_null($WSCMS->ConfigFrontOffice()))
  2757.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  2758.         return $this->render($this->service->checkCustomTemplate('demande_location_voiture.html.twig'), array(
  2759.             'form' => $form->createView(),
  2760.             'configAffichage' => $configAffichage,
  2761.         ));
  2762.     }
  2763.     /**
  2764.      * @Route("/newsletter", name="newsletter")
  2765.      */
  2766.     public function newsletter(WSCMS $WSCMS): Response
  2767.     {
  2768.         $WSCMS->NewsLetter(['email' => $_POST['email']]);
  2769.         return new Response(1);
  2770.     }
  2771.     /**
  2772.      * @Route ("/gallery", name="gallery")
  2773.      */
  2774.     public function gallery(WSCMS $WSCMS): Response
  2775.     {
  2776.         $gallery = $WSCMS->Gallery()['Gallery'];
  2777.         return $this->render($this->service->checkCustomTemplate('gallery.html.twig'), [
  2778.             'gallery' => $gallery
  2779.         ]);
  2780.     }
  2781.     /**
  2782.      * @Route("/admin", name="admin")
  2783.      */
  2784.     public function admin()
  2785.     {
  2786.         return $this->redirect("{$_SERVER[$this->get('session')->get('DOMAINE_BACK', "DOMAINE_BACK")]}/admin");
  2787.     }
  2788.     /**
  2789.      * @Route("/script", name="script")
  2790.      */
  2791.     public function script()
  2792.     {
  2793.         return $this->redirectToRoute("app_script", $_GET);
  2794.     }
  2795.     /**
  2796.      * @Route("/reset-cache-webservices/{name}", defaults={"name"="all"})
  2797.      */
  2798.     public function resetCacheWebServices($name): Response
  2799.     {
  2800.         return $this->redirectToRoute('reset_cache_webservices', ['name' => $name]);
  2801.     }
  2802.     /**
  2803.      * @Route ("/agences-liste/{id}", name="agences_liste", defaults={"id"=null})
  2804.      */
  2805.     public function agencesListe()
  2806.     {
  2807.         return $this->render($this->service->checkCustomTemplate('agence/agences-liste.html.twig'));
  2808.     }
  2809.     /**
  2810.      * @Route ("/home_aerien", name="home_aerien")
  2811.      */
  2812.     public function home_aerien(WSCMS $WSCMS, Request $request, WSAerien $WSAerien): Response
  2813.     {
  2814.         $classes = $WSAerien->Classe();
  2815.         $classe = $request->get('classe');
  2816.         $aeroports = $WSAerien->Aeroports()['Resultat'];
  2817.         return $this->render($this->service->checkCustomTemplate('Aerien/home_aerien.html.twig'), [
  2818.             'lieuDepart' => $request->get('lieu_depart'),
  2819.             'dateDebutFin' => $request->get('date_debut_fin'),
  2820.             'dateDebut' => null,
  2821.             'dateFin' => null,
  2822.             'classes' => $classes,
  2823.             'classe' => $classe,
  2824.             'aeroports' => $aeroports,
  2825.             'show' => true
  2826.         ]);
  2827.     }
  2828.     /**
  2829.      * @Route("/type-transfert", name="form_type_transfert")
  2830.      */
  2831.     public function formTypeTransfert(Request $request, GeneraleExtension $generaleExtension, WSCMS $WSCMS): Response
  2832.     {
  2833.         $infoAgence = $generaleExtension->getAgence()['information'];
  2834.         $form = $this->createFormBuilder(null, ['csrf_protection' => true])
  2835.             ->add('NomPrenom', TextType::class, array(
  2836.                 'required' => TRUE,
  2837.                 'attr' => [
  2838.                     'placeholder' => 'Nom & Prénom'
  2839.                 ]
  2840.             ))
  2841.             ->add('NumTel', TextType::class, [
  2842.                 'required' => false,
  2843.                 'attr' => [
  2844.                     'placeholder' => 'Numéro de téléphone',
  2845.                     'type'        => 'tel',
  2846.                     'inputmode'   => 'tel',
  2847.                     'pattern'     => '[0-9+\s\-\(\)]*',
  2848.                     'title'       => 'Veuillez saisir uniquement des chiffres',
  2849.                     'maxlength'   => 20,
  2850.                 ],
  2851.             ])
  2852.             ->add('email', EmailType::class, array(
  2853.                 'required' => TRUE,
  2854.                 'attr' => [
  2855.                     'placeholder' => 'Entrer votre email'
  2856.                 ]
  2857.             ))
  2858.             ->add('adresse', TextType::class, array(
  2859.                 'required' => false,
  2860.                 'attr' => [
  2861.                     'placeholder' => 'Adresse'
  2862.                 ]
  2863.             ))
  2864.             ->add('TypeVehicule', ChoiceType::class, [
  2865.                 'choices' => [
  2866.                     "Economie" => "Economie",
  2867.                     "Confort" => "Confort",
  2868.                     "Suv" => "Suv",
  2869.                     "Van" => "Van",
  2870.                     "Mini-Bus" => "Mini-Bus",
  2871.                 ]
  2872.             ])
  2873.             ->add('NbrPassagers', IntegerType::class, array(
  2874.                 'required' => false,
  2875.                 'attr' => [
  2876.                     'placeholder' => 'Nombre de passagers'
  2877.                 ]
  2878.             ))
  2879.             ->add('LieuDepart', TextType::class, array(
  2880.                 'required' => TRUE,
  2881.                 'attr' => [
  2882.                     'placeholder' => 'Lieu de départ'
  2883.                 ]
  2884. //                'choices' => [
  2885. //                    "Djerba" => "Djerba",
  2886. //                    "Hammamet" => "Hammamet",
  2887. //                    "Nabeul" => "Nabeul",
  2888. //                    "Sousse" => "Sousse",
  2889. //                    "Tozeur" => "Tozeur",
  2890. //                    "Tunis" => "Tunis",
  2891. //
  2892. //                ]
  2893.             ))
  2894.             ->add('DateDepart', DateType::class, array(
  2895.                 'widget' => 'single_text',
  2896.                 'format' => 'yyyy-MM-dd',
  2897.                 'required' => TRUE,
  2898.                 'attr'     => array(
  2899.                     'min' => (new \DateTime('today'))->format('Y-m-d'),   // ← bloque tout avant aujourd'hui dans le calendrier
  2900.                 ),
  2901.             ))
  2902.             ->add('HeureDepart', TimeType::class, array(
  2903.                 'input' => 'datetime',
  2904.                 'widget' => 'choice',
  2905.                 'required' => TRUE,
  2906.             ))
  2907.             ->add('LieuArrive', TextType::class, array(
  2908.                 'required' => TRUE,
  2909.                 'attr' => [
  2910.                     'placeholder' => "Lieu d’arrivée"
  2911.                 ]
  2912. //                'choices' => [
  2913. //                    "Djerba" => "Djerba",
  2914. //                    "Hammamet" => "Hammamet",
  2915. //                    "Nabeul" => "Nabeul",
  2916. //                    "Sousse" => "Sousse",
  2917. //                    "Tozeur" => "Tozeur",
  2918. //                    "Tunis" => "Tunis",
  2919. //
  2920. //                ]
  2921.             ))
  2922. //            ->add('DateArrive', DateType::class, array(
  2923. //                'widget' => 'single_text',
  2924. //                'format' => 'yyyy-MM-dd',
  2925. //                'required' => TRUE,
  2926. //            ))
  2927. //            ->add('HeureArrive', TimeType::class, array(
  2928. //                'input' => 'datetime',
  2929. //                'widget' => 'choice',
  2930. //                'required' => TRUE,
  2931. //            ))
  2932.             ->add('LieuDepartRetour', TextType::class, array(
  2933.                 'required' => TRUE,
  2934.                 'attr' => [
  2935.                     'placeholder' => "Lieu de départ retour"
  2936.                 ]
  2937. //                'choices' => [
  2938. //                    "Djerba" => "Djerba",
  2939. //                    "Hammamet" => "Hammamet",
  2940. //                    "Nabeul" => "Nabeul",
  2941. //                    "Sousse" => "Sousse",
  2942. //                    "Tozeur" => "Tozeur",
  2943. //                    "Tunis" => "Tunis",
  2944. //
  2945. //                ]
  2946.             ))
  2947.             ->add('DateDepartRetour', DateType::class, array(
  2948.                 'widget' => 'single_text',
  2949.                 'format' => 'yyyy-MM-dd',
  2950.                 'required' => TRUE,
  2951.                 'attr'     => array(
  2952.                     'min' => (new \DateTime('today'))->format('Y-m-d'),   // ← bloque tout avant aujourd'hui dans le calendrier
  2953.                 ),
  2954.             ))
  2955.             ->add('HeureDepartRetour', TimeType::class, array(
  2956.                 'input' => 'datetime',
  2957.                 'widget' => 'choice',
  2958.                 'required' => TRUE,
  2959.             ))
  2960.             ->add('LieuArriveRetour', TextType::class, array(
  2961.                 'required' => TRUE,
  2962.                 'attr' => [
  2963.                     'placeholder' => "Lieu d'arrivée retour"
  2964.                 ]
  2965.             ))
  2966. //            ->add('DateArriveRetour', DateType::class, array(
  2967. //                'widget' => 'single_text',
  2968. //                'format' => 'yyyy-MM-dd',
  2969. //                'required' => TRUE,
  2970. //            ))
  2971. //            ->add('HeureArriveRetour', TimeType::class, array(
  2972. //                'input' => 'datetime',
  2973. //                'widget' => 'choice',
  2974. //                'required' => TRUE,
  2975. //            ))
  2976.             ->add('commentaire', TextareaType::class, array(
  2977.                 'required' => false
  2978.             ))
  2979.             ->add('code_formulaire', HiddenType::class,
  2980.                 array(
  2981.                     'required' => false,
  2982.                     'data' => 'Formulaire_Type_Transfert',
  2983.                 ));
  2984.         $form = $form->getForm();
  2985.         $form->handleRequest($request);
  2986.         if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
  2987.             try {
  2988.                 $data = $form->getData();
  2989.                 $body = $this->renderView($this->service->checkCustomTemplate('formulaire_mail_type_transfert.html.twig'), array(
  2990.                     'NomPrenom' => $data['NomPrenom'],
  2991.                     'adresse' => $data['adresse'],
  2992.                     'NumTel' => $data['NumTel'],
  2993.                     'email' => $data['email'],
  2994.                     'TypeVehicule' => $data['TypeVehicule'],
  2995.                     'NbrPassagers' => $data['NbrPassagers'],
  2996.                     'LieuDepart' => $data['LieuDepart'],
  2997.                     'DateDepart' => $data['DateDepart']->format('d-m-Y'),
  2998.                     'HeureDepart' => $data['HeureDepart']->format('H:i'),
  2999.                     'LieuArrive' => $data['LieuArrive'],
  3000. //                    'DateArrive' => $data['DateArrive']->format('d-m-Y'),
  3001. //                    'HeureArrive' => $data['HeureArrive']->format('H:i'),
  3002.                     'LieuDepartRetour' => $data['LieuDepartRetour'],
  3003.                     'DateDepartRetour' => $data['DateDepartRetour'] ? $data['DateDepartRetour']->format('d-m-Y') : null,
  3004.                     'HeureDepartRetour' => $data['HeureDepartRetour']->format('H:i'),
  3005.                     'LieuArriveRetour' => $data['LieuArriveRetour'],
  3006. //                    'DateArriveRetour' => $data['DateArriveRetour'] ? $data['DateArriveRetour']->format('d-m-Y') : null,
  3007. //                    'HeureArriveRetour' => $data['HeureArriveRetour']->format('H:i'),
  3008.                     'subject' => $data['commentaire'],
  3009.                 ));
  3010.                 $params = array(
  3011.                     'email' => $data['email'],
  3012.                     'subject' => $data['commentaire'],
  3013.                     'post' => $_POST,
  3014.                     'code_formulaire' => $data['code_formulaire'],
  3015.                     'body' => $body,
  3016.                 );
  3017.                 $params['mailToClient'] = true;
  3018.                 $result = $WSCMS->SendMailLibre($params);
  3019.             } catch (\Exception $e) {
  3020.                 $msg = '<span style="color:red">' . $e->getMessage() . '</span>';
  3021.                 return new Response($msg);
  3022.             }
  3023.             if ($result != 0) {
  3024.                 $msg = "<span style='color:green'>Votre message a été Envoyé avec succès !</span>";
  3025.             } else {
  3026.                 $msg = '<span style="color:red">Echèc d\'envoi</span>';
  3027.             }
  3028.             return new Response($msg);
  3029.         }
  3030.         $configAffichage = array();
  3031.         if (!is_null($WSCMS->ConfigFrontOffice()))
  3032.             $configAffichage = $WSCMS->ConfigFrontOffice()['ConfigFrontOffice'];
  3033.         return $this->render($this->service->checkCustomTemplate('form_type_transfert.html.twig'), array(
  3034.             'infoAgence' => $infoAgence,
  3035.             'form' => $form->createView(),
  3036.             'configAffichage' => $configAffichage,
  3037.         ));
  3038.     }
  3039.     /**
  3040.      * @Route("/Avis/page/{idavis}/{idreservation}/{idhotel}", name="front_avis_page")
  3041.      */
  3042.     public function front_avis_page($idavis, $idhotel, $idreservation, WSSejourHotel $sejourHotel)
  3043.     {
  3044.         $getpageavis = $sejourHotel->getAvisPageTemp(array('reservation' => $idreservation));
  3045.         $parameters = array();
  3046.         $details = array();
  3047.         if ($getpageavis['ok']) {
  3048.             $parameters = $getpageavis['parameters'];
  3049.             $details = $getpageavis['details'];
  3050.         }
  3051.         $ok = $getpageavis['ok'];
  3052.         $message = $getpageavis['message'];
  3053.         return $this->render($this->service->checkCustomTemplate('SejourHotel/avis.html.twig'), ['ok' => $ok, 'message' => $message, 'idavis' => $idavis, 'idHotel' => $idhotel, 'idReservation' => $idreservation, 'parameters' => $parameters, 'details' => $details]);
  3054.     }
  3055.     /**
  3056.      * @Route("/AvisPost/{idavis}/{idreservation}/{idhotel}", name="front_avis_post")
  3057.      */
  3058.     public function front_avis_post($idavis, $idhotel, $idreservation, WSSejourHotel $sejourHotel, Request $request)
  3059.     {
  3060.         $data = $_POST;
  3061.         $data['id'] = $idhotel;
  3062.         $data['idavis'] = $idavis;
  3063.         $data['idreservation'] = $idreservation;
  3064.         $data['recommended'] = $data['recommended'] == 'true' ? true : false;
  3065.         $submit = $sejourHotel->postAvisPageTemp($data);
  3066.         return $this->render($this->service->checkCustomTemplate('SejourHotel/avisresult.html.twig'), ['ok' => $submit['ok'], 'message' => $submit['message']]);
  3067.     }
  3068. }