src/Controller/SejourHotel/IndexController.php line 85

Open in your IDE?
  1. <?php
  2. namespace App\Controller\SejourHotel;
  3. use App\Service\Generale;
  4. use App\Service\WSCMS;
  5. use App\Service\WSEspaceAffilie;
  6. use App\Service\WSSejourHotel;
  7. use App\Service\ExceptionService;
  8. use APY\BreadcrumbTrailBundle\BreadcrumbTrail\Trail;
  9. use SebastianBergmann\CodeCoverage\RuntimeException;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. use Symfony\Component\HttpFoundation\JsonResponse;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\HttpFoundation\Session\SessionInterface as Session;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. use Symfony\Component\String\Slugger\SluggerInterface;
  17. /**
  18.  * @Route("/hotel")
  19.  */
  20. class IndexController extends AbstractController
  21. {
  22.     public function __construct(Generale $serviceWSCMS $cmsWSSejourHotel $sejourHotelExceptionService $exceptionService)
  23.     {
  24.         $this->service $service;
  25.         $this->cms $cms;
  26.         $this->sejourHotel $sejourHotel;
  27.         $this->exceptionService $exceptionService;
  28.     }
  29.     /**
  30.      * @Route("/source-typeahead-ville-hotel", name="source_typeahead_ville_hotel")
  31.      * @Route("/search-ville-hotel", name="search_ville_hotel")
  32.      */
  33.     public function sourceTypeaheadVilleHotel(WSSejourHotel $sejourHotelRequest $request): Response
  34.     {
  35.         $listCityHotel $sejourHotel->ListCityHotel([
  36.             'Keywords' => $_GET['Keywords'],
  37.             'maxItem' => $_GET['maxItem'],
  38.             'onlySearchCity' => $_GET['onlySearchCity']
  39.         ]);
  40.         if ($request->get('_route') == 'search_ville_hotel')
  41.             return new JsonResponse($listCityHotel);
  42.         return new JsonResponse($listCityHotel['ListCityHotel']);
  43.     }
  44.     /**
  45.      * @Route("/all-hotel/{ville}/{hotel}",
  46.      *     options={"expose"=true},
  47.      *     name="all_hotel",defaults={"ville":"tous","hotel":"tous"})
  48.      */
  49.     public function getAllHotel($ville$hotelWSCMS $WSCMS): Response
  50.     {
  51.         $hotels $WSCMS->Hotel()['Hotels'];
  52.         $etiquettes $WSCMS->HotelEtiquette()['Etiquettes'];
  53.         $hotels array_map(function ($hotel) use ($etiquettes) {
  54.             $hotel['etiquettes'] = isset($etiquettes['etiquettes'][$hotel['id']]) ? $etiquettes['etiquettes'][$hotel['id']] : [];
  55.             $hotel['etiquettesSaison'] = isset($etiquettes['etiquettesSaison'][$hotel['id']]) ? $etiquettes['etiquettesSaison'][$hotel['id']] : [];
  56.             $hotel['etiquettesEmplacement'] = isset($etiquettes['etiquettesEmplacement'][$hotel['id']]) ? $etiquettes['etiquettesEmplacement'][$hotel['id']] : [];
  57.             return $hotel;
  58.         }, $hotels);
  59.         if ($ville != 'tous')
  60.             $hotels array_filter($hotels, function ($h) use ($ville) {
  61.                 return $h['ville'] == $ville;
  62.             });
  63.         if ($hotel != 'tous')
  64.             $hotels array_filter($hotels, function ($h) use ($hotel) {
  65.                 return ($h['hotel'] == $hotel or in_array($h['id'], explode('-'$hotel)));
  66.             });
  67.         return new JsonResponse(array_values($hotels));
  68.     }
  69.     /**
  70.      * @Route("/ajax-availability",
  71.      *     name="sejour_hotel_ajax_availability")
  72.      */
  73.     public function availabilityHotel(WSSejourHotel $sejourHotel): Response
  74.     {
  75.         $searchParams json_decode(base64_decode($_GET['HotelSearch']), true);
  76.         if (file_exists('../var/site-en-maintenance.php') and ($nbr_iteration = (include '../var/site-en-maintenance.php')['nbrIterationSearchHotel']) > 0)
  77.             return new JsonResponse($sejourHotel->MultipleHotelSearch($searchParams$nbr_iteration));
  78.         return new JsonResponse($sejourHotel->HotelSearch($searchParams));
  79.     }
  80.     /**
  81.      * @Route("/tarifs-hotel-journalier/{hotel}",
  82.      *     options={"expose"=true},
  83.      *     name="tarifs_hotel_journalier")
  84.      */
  85.     public function TarifsHotelJournalier($hotelWSSejourHotel $sejourHotelWSCMS $WSCMS): Response
  86.     {
  87.         $tarif $sejourHotel->TarifsHotelJournalier($hotel);
  88.         if (isset($tarif['HotelSearch'][0]['Price'])) {
  89.             $tarif $tarif['HotelSearch'][0];
  90.             return new JsonResponse([
  91.                 'min_arrangement' => $tarif['min_arrangement'],
  92.                 'etiquettes' => isset($tarif['etiquettes']) ? $tarif['etiquettes'] : [],
  93.                 'etiquettesSaison' => isset($tarif['etiquettesSaison']) ? $tarif['etiquettesSaison'] : []
  94.             ]);
  95.         }
  96.         $etiquettes $WSCMS->HotelEtiquette()['Etiquettes'];
  97.         return new JsonResponse([
  98.             'min_arrangement' => null,
  99.             'etiquettes' => $etiquettes['etiquettes'][$hotel] ?? [],
  100.             'etiquettesSaison' => $etiquettes['etiquettesSaison'][$hotel] ?? []
  101.         ]);
  102.     }
  103.     /**
  104.      * @Route("/calendrier/{hotel}/{fromDate}/{toDate}",
  105.      *     name="calendrier")
  106.      */
  107.     public function calendrier(WSSejourHotel $WSSejourHotel$hotel$fromDate$toDate): Response
  108.     {
  109.         $calendrier $WSSejourHotel->HotelCalendar([
  110.             "Hotel" => intval($hotel),
  111.             "FromDate" => $fromDate,
  112.             "ToDate" => $toDate,
  113.             "Stock" => true,
  114.             "StopSale" => true,
  115.             "MinStay" => true,
  116.             "Retrocession" => true,
  117.         ])['Calendar'];
  118.         return new JsonResponse($calendrier);
  119.     }
  120.     public function tarifDispo(WSSejourHotel $sejourHotelWSEspaceAffilie $affilie$productWSCMS $WSCMSTrail $trailSession $sessionRequest $requestSluggerInterface $slugger): Response
  121.     {
  122.         $Request json_decode(base64_decode($_POST['BookingCreation']), true);
  123.         if (isset($Request['Request']))
  124.             $Request $Request['Request'];
  125.         if ($request->files->get('fichier') != null) {
  126.             $uniqid sha1(uniqid(mt_rand(), TRUE));
  127.             foreach ($request->files->get('fichier') as $i => $file)
  128.                 $_POST['file-passeport'][] = [
  129.                     'nom' => "$i-$uniqid.{$file->guessExtension()}",
  130.                     'ordre' => 0,
  131.                     'base64' => [
  132.                         'contents' => base64_encode(file_get_contents($file->getPathName())),
  133.                         'originalName' => $file->getClientOriginalName(),
  134.                         'size' => $file->getSize(),
  135.                         'mimeType' => $file->getMimeType()
  136.                     ],
  137.                     'nomOrigine' => $file->getClientOriginalName(),
  138.                     'taille' => '',
  139.                     'width' => getimagesize($file)[0],
  140.                     'height' => getimagesize($file)[1]
  141.                 ];
  142.         }
  143.         if (isset($_POST['file-passeport']))
  144.             $Request['HotelBooking']['file-passeport'] = $_POST['file-passeport'];
  145.         /*if (!$Request['HotelBooking']['PreBooking'])
  146.             foreach ($Request['HotelBooking']['Rooms'] as &$room)
  147.                 foreach ($room['Pax'] as &$pax)
  148.                     foreach ($pax as &$p)
  149.                         if ($p['Name'] == '')
  150.                             $p['Name'] = $Request['HotelBooking']['Client']['Name'];*/
  151.         if (isset($_POST['montant-cote-client'])) {
  152.             $montantCoteClient $_POST['montant-cote-client'];
  153.             $devise $session->get('devise');
  154.             $deviseAgence $session->get('devise-agence');
  155.             if ($devise['code'] != $deviseAgence['code'])
  156.                 $montantCoteClient = ($devise['tndToDevise'] ? $montantCoteClient $devise['montant'] : $montantCoteClient $devise['montant']);
  157.             $Request['HotelBooking']['ClientAmount'] = $montantCoteClient;
  158.         }
  159.         if (isset($_POST['solde-points-de-fidelite']))
  160.             $Request['HotelBooking']['PointsDeFidelite'] = $affilie->SoldePointsdeFideliteAgence()["Solde"];
  161.         $BookingCreation $sejourHotel->BookingCreation($Request);
  162.         if (isset($BookingCreation['Erreur'])) {
  163.             $BookingCreation['Error'] = $BookingCreation['Erreur'];
  164.             unset($BookingCreation['Erreur']);
  165.         }
  166.         if ($session->get('devise')['code'] != $session->get('devise-agence')['code'])
  167.             $Request['HotelBooking']['Currency'] = $session->get('devise')['code'];
  168.         if ($WSCMS->ConfigFrontOffice()['ConfigFrontOffice']['HOTEL']['EDIT_PAY_AT_HOTEL'] == 'oui')
  169.             $Request['HotelBooking']['PayAtHotel'] = !isset($BookingCreation['Error']) ? $BookingCreation['BookingCreation']['PayAtHotel'] : 0;
  170.         $trail->add($product == "hotel" 'Liste Hôtels' 'Liste Appartements'$product == "hotel" 'sejour_hotel_availability' 'sejour_appartement_availability'$session->get('last_route_params.sejour_hotel_availability', []));
  171.         if (isset($Request['name_hotel']))
  172.             $trail->add($Request['name_hotel'], $product == "hotel" 'details_hotel' 'details_appartement'$Request['params_route_details_hotel']);
  173.         elseif (!isset($BookingCreation['Error']))
  174.             $trail->add($BookingCreation['BookingCreation']['Hotel']['Name'], 'details_hotel', [
  175.                 'id' => $BookingCreation['BookingCreation']['Hotel']['Id'],
  176.                 'slug' => $slugger->slug($BookingCreation['BookingCreation']['Hotel']['Name'])->lower(),
  177.                 'checkin' => $BookingCreation['BookingCreation']['CheckIn'],
  178.                 'nuitees' => (new \DateTime($BookingCreation['BookingCreation']['CheckIn']))->diff(new \DateTime($BookingCreation['BookingCreation']['CheckOut']))->d,
  179.                 'city' => $BookingCreation['BookingCreation']['Hotel']['City']['Id'],
  180.                 'source' => $BookingCreation['BookingCreation']['Source'],
  181.             ]);
  182.         if ($Request['HotelBooking']['PreBooking'] and isset($BookingCreation['BookingCreation']['Token'])) {
  183.             $Request['HotelBooking']['Token'] = $BookingCreation['BookingCreation']['Token'];
  184.         }
  185.         if (!$Request['HotelBooking']['PreBooking'] and !isset($BookingCreation['Error'])) {
  186.             $paymentOnline $BookingCreation['BookingCreation']['PaymentOnline'];
  187.             $idbook $BookingCreation['BookingCreation']['Id'];
  188.             $route_confir $this->generateUrl($product == "hotel" 'confirmation_sejour' 'confirmation_appartement', ['Paiement' => $paymentOnline 'EnLigne' 'Agence''id' => $idbook,], 0);
  189.             $url_echec $this->generateUrl('echec_sejour', [], 0);
  190.             if (isset($Request['name_hotel'])) {
  191.                 $BookingCreation['params_route_details_hotel'] = $Request['params_route_details_hotel'];
  192.                 $BookingCreation['name_hotel'] = $Request['name_hotel'];
  193.             }
  194.             $session->set('BookingDetails#' $idbook$BookingCreation);
  195.             if ($paymentOnline)
  196.                 return $this->redirect("{$this->service->domaineBack()}/payment-electronique/2/{$idbook}/SHT?url_succes=$route_confir&url_echec=$url_echec&configPayement={$Request['HotelBooking']['ConfigurationPayement']}");
  197.             return $this->redirect($route_confir);
  198.         }
  199.         $BookingCreation['ConfigurationPayement'] = $WSCMS->ConfigurationPayement()['ConfigurationPayement'];
  200.         $BookingCreation['Request'] = $Request;
  201.         $Solde $affilie->SoldePointsdeFideliteAgence()["Solde"];
  202.         $BookingCreation['Solde'] = $Solde;
  203.         $BookingCreation['BookingCreation']['Solde'] = $Solde;
  204.         if ($request->isXmlHttpRequest())
  205.             return new JsonResponse($BookingCreation);
  206.         if (isset($BookingCreation['Error'])) {
  207.             // Créer une exception et l'enregistrer
  208.             $errorException = new \Exception($BookingCreation['Error']);
  209.             $recordedException $this->exceptionService->recordException($errorException);
  210.             
  211.             return $this->render('bundles/TwigBundle/Exception/error.html.twig', [
  212.                 'title' => "Une erreur est survenue lors du traitement de votre demande",
  213.                 'message' => $BookingCreation['Error'],
  214.                 'recordedException' => $recordedException
  215.             ]);
  216.         }
  217.         return $this->render($this->service->checkCustomTemplate('SejourHotel/tarif-dispo.html.twig'), $BookingCreation);
  218.     }
  219.     public function confirmation($idWSSejourHotel $sejourHotelTrail $trail$productSession $sessionSluggerInterface $sluggerRequest $request): Response
  220.     {
  221.         if ($request->get('_route') != "confirmation_sejour_custom")
  222.             try {
  223.                 return $this->redirect($this->generateUrl('confirmation_sejour_custom'array_merge($request->get('_route_params'), $_GET)));
  224.             } catch (\Exception $exception) {
  225.             }
  226.         if ($request->get('_route') != "confirmation_appartement_custom")
  227.             try {
  228.                 return $this->redirect($this->generateUrl('confirmation_appartement_custom'array_merge($request->get('_route_params'), $_GET)));
  229.             } catch (\Exception $exception) {
  230.             }
  231.         if (isset($_GET['id']))
  232.             $id $_GET['id'];
  233.         $BookingDetails $sejourHotel->BookingDetails(["Booking" => $id"dev" => false"DisableClientVerification" => true]);
  234.         $BookingDetails['BookingCreation'] = $BookingDetails['Booking'];
  235.         unset($BookingDetails['Booking']);
  236.         if (isset($BookingDetails['BookingCreation']['DetailsPayement']['Success'])) {
  237.             $this->addFlash('success'$BookingDetails['BookingCreation']['DetailsPayement']['Success']);
  238.             unset($BookingDetails['BookingCreation']['DetailsPayement']['Success']);
  239.         } elseif (isset($BookingDetails['BookingCreation']['DetailsPayement']['Echec']))
  240.             return $this->redirectToRoute('echec_sejour', [
  241.                 'detailsPayement' => base64_encode(json_encode($BookingDetails['BookingCreation']['DetailsPayement']))
  242.             ]);
  243.         $trail->add($product == "hotel" 'sejour_hotel_availability' 'Liste Appartements'$product == "hotel" 'sejour_hotel_availability' 'sejour_appartement_availability'$session->get('last_route_params.sejour_hotel_availability', []));
  244.         $trail->add($BookingDetails['BookingCreation']['Hotel']['Name'], 'details_hotel', [
  245.             'id' => $BookingDetails['BookingCreation']['Hotel']['Id'],
  246.             'slug' => $slugger->slug($BookingDetails['BookingCreation']['Hotel']['Name'])->lower(),
  247.             'checkin' => $BookingDetails['BookingCreation']['CheckIn'],
  248.             'nuitees' => (new \DateTime($BookingDetails['BookingCreation']['CheckIn']))->diff(new \DateTime($BookingDetails['BookingCreation']['CheckOut']))->d,
  249.             'city' => $BookingDetails['BookingCreation']['Hotel']['City']['Id'],
  250.             'source' => $BookingDetails['BookingCreation']['Source'],
  251.         ]);
  252.         return $this->render($this->service->checkCustomTemplate('SejourHotel/confirmation.html.twig'), $BookingDetails);
  253.     }
  254.     public function echec($detailsPayement): Response
  255.     {
  256.         if ($detailsPayement) {
  257.             $detailsPayement json_decode(base64_decode($detailsPayement), true);
  258.             $this->addFlash('danger'$detailsPayement['Echec']);
  259.             unset($detailsPayement['Echec']);
  260.         } else
  261.             $detailsPayement = [];
  262.         return $this->render($this->service->checkCustomTemplate('SejourHotel/echec.html.twig'), [
  263.             'detailsPayement' => $detailsPayement
  264.         ]);
  265.     }
  266.     public function detailsHotel($id$source$city$checkin$productWSSejourHotel $sejourHotelTrail $trailSession $sessionRequest $request): Response
  267.     {
  268.         if (new \DateTime("$checkin 23:59:59") < new \DateTime())
  269.             return $this->redirectToRoute('details_hotel'array_merge($request->get('_route_params'), $request->query->all(), ['checkin' => date('Y-m-d')]));
  270.         $hotels $this->cms->Hotel($product == 'appartement'false)['Hotels'];
  271.         $hotelsBySlug array_column($hotelsnull'hotel');
  272.         $_route_params $request->get('_route_params');
  273.         if ($request->get('_route') != "details_hotel_custom") {
  274.             try {
  275.                 $villesById array_column($this->cms->Ville()['Villes'], null'id');
  276.                 $hotelsById array_column($hotelsnull'id');
  277.                 $nameCity "~";
  278.                 if (isset($villesById[$_route_params['city']]))
  279.                     $nameCity $villesById[$_route_params['city']]['ville'];
  280.                 if (isset($hotelsById[$_route_params['id']]))
  281.                     $nameCity $hotelsById[$_route_params['id']]['ville'];
  282.                 if (isset($hotelsBySlug[$_route_params['slug']]))
  283.                     $nameCity $hotelsBySlug[$_route_params['slug']]['ville'];
  284.                 $customUrl $this->generateUrl('details_hotel_custom'array_merge($_route_params, ['nameCity' => $nameCity]));
  285.                 return $this->redirect($customUrl301);
  286.             } catch (\Exception $exception) {
  287.             }
  288.         }
  289.         if (isset($_GET['id']))
  290.             $id $_GET['id'];
  291.         if ($id == '~') {
  292.             $id $hotelsBySlug[$_route_params['slug']]['id'];
  293.             //$city = $hotelsBySlug[$_route_params['slug']]['ville_id'];
  294.         }
  295.         $trail->add($product == "hotel" 'Liste Hôtels' 'Liste Appartements'$product == "hotel" 'sejour_hotel_availability' 'sejour_appartement_availability'$session->get('last_route_params.sejour_hotel_availability', []));
  296.         $prm = ["Hotel" => $id"Source" => $source == "~" "all" $source];
  297.         if ($source != '~' && $city != '~')
  298.             $prm['XMLCity'] = $city;
  299.         $HotelDetail $sejourHotel->HotelDetail($prm);
  300.         $params['HotelDetail'] = $HotelDetail['HotelDetail'];
  301.         $params['_destination'] = 'h-' $HotelDetail['HotelDetail']['Id'];
  302.         $params['product'] = $product;
  303.         $params['id'] = $id;
  304.         if (isset($_POST['BookingCreation'])) {
  305.             $params['BookingDetails'] = json_decode(base64_decode($_POST['BookingCreation']), true);
  306.             $params['Request'] = $_POST['BookingCreation'];
  307.         }
  308.         return $this->render($this->service->checkCustomTemplate('SejourHotel/details-hotel.html.twig'), $params);
  309.     }
  310.     public function tarfJourFromFormulaireReservation($hotel$productRequest $requestWSSejourHotel $sejourHotel)
  311.     {
  312.         $date $request->get('date');
  313.         $begin = new \DateTime($date);
  314.         date_modify($begin"first day of this month");
  315.         $end = new \DateTime($date);
  316.         date_modify($end"first day of next month");
  317.         $session $this->get('session');
  318.         $params = array(
  319.             'hotel' => $hotel,
  320.             'client' => null,
  321.             'dateDebut' => $begin->format('Y-m-d'),
  322.             'dateFin' => $end->format('Y-m-d'),
  323.             "product" => $product,
  324.             'devise' => $session->get('devise')['montant'],
  325.             "scale" => $session->get('devise')['scale']
  326.         );
  327.         $tarifJourFromformulaire $sejourHotel->CalendrieHotel($params);
  328.         function getChambredouble($array)
  329.         {
  330.             $min null;
  331.             foreach ($array as $k => $a) {
  332.                 if (!is_null($min)) {
  333.                     if ($a['accepte-double'] and $a['minPrix'] < $min['minPrix']) {
  334.                         $min $a;
  335.                     }
  336.                 } else {
  337.                     $min $a['accepte-double'] ? $a null;
  338.                 }
  339.             }
  340.             return $min;
  341.         }
  342.         $result = array();
  343.         foreach ($tarifJourFromformulaire['tarifbydays']['tarifs'] as $tarifbyday) {
  344.             $tarifs = isset($tarifbyday['promo']['minArrangement']) ? $tarifbyday['promo'] : $tarifbyday['standard'];
  345.             if (!is_null($tarifbyday['standard'])) {
  346.                 $stopSales $tarifbyday['stopSales']['standard'];
  347.                 if (isset($tarifbyday['stopSales']['promo']))
  348.                     $stopSales array_merge($stopSales$tarifbyday['stopSales']['promo']);
  349.                 if (!empty($stopSales)) {
  350.                     $arrinstopSales = [];
  351.                     foreach ($stopSales as $stopSale) {
  352.                         if ($stopSale['_end'] == $tarifbyday['dateDebut'])
  353.                             $arrinstopSales array_merge($arrinstopSales$stopSale['arrangements']);
  354.                     }
  355.                     if (count($arrinstopSales) != 0) {
  356.                         foreach ($tarifs['tab'] as $tab) {
  357.                             if (!in_array($tab['id'], $arrinstopSales)) {
  358.                                 $minArr = ['id' => $tab['id'], 'code' => $tab['code']];
  359.                             }
  360.                         }
  361.                     }
  362.                 }
  363.                 $item = [];
  364.                 $id getChambredouble($tarifs['tab_ch']);
  365.                 if (is_null($id))
  366.                     $id current($tarifs['tab_ch'])['idChambre'];
  367.                 $id $id['idChambre'];
  368.                 $tab_ch $tarifs['tab_ch'][$id];
  369.                 $minPrix $tab_ch['minPrix'];
  370.                 $minArr $tab_ch['minArr'];
  371.                 $isRetrocession in_array($tarifbyday['dateDebut'], $tarifJourFromformulaire['tarifbydays']['delayRetrocessionDates']);
  372.                 $item['arran'] = $minArr['id'];
  373.                 $item['codeArr'] = $minArr['code'];
  374.                 $item['jour'] = $tarifbyday['dateDebut'];
  375.                 $item['stopSales'] = $tab_ch['stopSales'];
  376.                 $item['surDemande'] = $tab_ch['surDemande'] or $tab_ch['minStay'] or $tab_ch['allotement'] <= or $isRetrocession;
  377.                 $item['tarifMin'] = number_format($minPrix$session->get('devise')['scale']);
  378.                 $item['isRetrocession'] = $isRetrocession;
  379.                 $item['isStopSales'] = ($minPrix == 0);
  380.                 $result[] = $item;
  381.             }
  382.         }
  383.         return new JsonResponse(array('tarifjour' => $result'stopsales' => []));
  384.     }
  385.     public function searchHotel($ville$hotel$product$hotelMondeRequest $request): Response
  386.     {
  387.         if (!$this->service->hasModule('sejour')) {
  388.             $this->addFlash('danger''Produit sans licence');
  389.             return $this->render('bundles/TwigBundle/Exception/error404.html.twig');
  390.         }
  391.         if (isset($_SERVER['ROUTE_ACCUEIL']) and $_SERVER['ROUTE_ACCUEIL'] == 'details_hotel')
  392.             return $this->redirectToRoute('details_hotel'array_merge(json_decode($_SERVER['PARAMS_ROUTE_ACCUEIL'], true), [
  393.                 'source' => $request->get('source'),
  394.                 'city' => $request->get('ville'),
  395.                 'checkin' => $request->get('checkin'),
  396.                 'nuitees' => $request->get('nuitees'),
  397.                 'rooms' => $request->get('rooms')
  398.             ]));
  399.         if (($destination $request->get('destination''all')) === "all") {
  400.             if (!$hotelMonde)
  401.                 $villes $this->cms->Ville()['Villes'];
  402.             else
  403.                 $villes $this->sejourHotel->ListCityHotel([
  404.                     'Keywords' => $ville,
  405.                     'onlySearchCity' => true
  406.                 ])['ListCityHotel'];
  407.             if ($idVille $request->get('idVille'))
  408.                 $ville array_column($villesnull'id')[$idVille]['ville'];
  409.             $search_recommended explode('###'$this->cms->ConfigFrontOffice()['ConfigFrontOffice']['HOTEL']['SEARCH_RECOMMENDED']);
  410.             $search_recommended = (count($search_recommended) > $search_recommended[1] : $search_recommended[0]);
  411.             if ($ville == "all") {
  412.                 if (($key array_search($search_recommendedarray_column($villes'name'))) !== false)
  413.                     $destination 'v-' $villes[$key]['id'];
  414.             } else {
  415.                 $villes array_filter($villes, function ($item) use ($ville) {
  416.                     return $item['ville'] == $ville;
  417.                 });
  418.                 if (!empty($villes))
  419.                     $destination 'v-' current($villes)['id'];
  420.             }
  421.             if (!isset($destination) and $hotel == 'tous')
  422.                 $hotel $search_recommended;
  423.             if ($hotel != 'tous') {
  424.                 if (!$hotelMonde)
  425.                     $hotels $this->cms->Hotel($product == 'appartement')['Hotels'];
  426.                 else
  427.                     $hotels $this->sejourHotel->ListCityHotel([
  428.                         'Keywords' => $hotel,
  429.                         'onlySearchCity' => false
  430.                     ])['ListCityHotel'];
  431.                 $hotels array_filter($hotels, function ($item) use ($hotel) {
  432.                     return $item['hotel'] == $hotel;
  433.                 });
  434.                 if (!empty($hotels))
  435.                     $destination 'h-' current($hotels)['id'];
  436.                 elseif (($key array_search($search_recommendedarray_column($hotels'name'))) !== false)
  437.                     $destination 'h-' $hotels[$key]['id'];
  438.             }
  439.         }
  440.         return $this->render($this->service->checkCustomTemplate("SejourHotel/availability/availability.html.twig"), [
  441.             '_destination' => $destination !== "all" $destination 'v-',
  442.             'product' => $product,
  443.             'hotelSearchOnlyDetails' => $_SERVER['HOTEL_SEARCH_ONLY_DETAILS']
  444.         ]);
  445.     }
  446. }