<?php
namespace App\Controller;
use App\Api\Helper\SeoHelper;
use App\Api\Helper\ThemeHelper;
use App\Api\Helper\ContactHelper;
use App\Helper\NavigationHelper;
use App\Api\Helper\DemandHelper;
use App\Api\Helper\VoyageHelper;
use App\Api\Helper\ContentHelper;
use App\Api\Helper\PaysHelper;
use App\Api\Helper\TemoignageHelper;
use App\Api\ApiClient;
use App\Api\DolApiClient;
use App\Api\Helper\VoyageTypeHelper;
use App\Form\TourFormType;
use App\Form\CustomTourFormType;
use App\Form\InfoTourType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
class TourController extends AbstractController {
private $voyageHelper;
private $contentHelper;
private $demandHelper;
public function __construct(VoyageHelper $voyageHelper,
ContentHelper $contentHelper,
DemandHelper $demandHelper)
{
$this->voyageHelper = $voyageHelper;
$this->contentHelper = $contentHelper;
$this->demandHelper = $demandHelper;
}
/**
* @Route("tourcat/voyages-sur-mesure", name="tour_planner")
*/
public function planner(Request $request,
ApiClient $apiClient,
DolApiClient $dolApiClient,
\Swift_Mailer $mailer,
TranslatorInterface $translator,
contactHelper $contactHelper) {
$debug = $this->getParameter('kernel.debug');
$locale = $request->getLocale();
$seo['meta_title'] = 'Voyage sur mesure';
$form = $this->createForm(TourFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$contact = [];
$contact["name"] = $data['name'];
$contact["address"] = $data['address'];
$contact["zip"] = $data['zip'];
$contact["town"] = $data['city'];
$contact["pays"] = $data['country'];
$contact["phone"] = $data['phone'];
$contact["email"] = $data['email'];
$contact["client"] = 2;
$contact["code_client"] = -1;
$contact["array_options"] = ["source" => 1];
try {
$contactExists = $contactHelper->getByEmail($contact["email"]);
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
if (is_null($contactExists)) {
try {
$response = $contactHelper->create($contact);
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
$customerId = $response;
} else {
try {
$response = $contactHelper->update($contactExists['rowid'], $contact);
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
$customerId = $response['id'];
}
$demand = [];
$demand["customer"] = $customerId;
$demand['destination'] = $request->request->get('destination', null);
$demand['destination2'] = $request->request->get('destination2', null);
$demand["date"] = $data['date'];
$demand["duration"] = $data['duration'];
$demand["budget"] = $data['budget'];
$demand["type"] = $data['type'];
$demand["language"] = $data['language'];
$demand["wishes"] = $data['wishes'];
$demand["group"] = $data['group'];
$demand["persons"] = $data['budget'];
$demand["adults"] = $data['adults'];
$demand["children"] = $data['children'];
$demand["divers"] = $data['divers'];
$demand["no_divers"] = $data['no_divers'];
$demand["message"] = $data['message'];
try {
$demandHelper = $this->demandHelper;
$demandResponse = $demandHelper->create($demand);
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
$message = (new \Swift_Message($translator->trans('Nous vous remercions pour votre demande')))
->setFrom('voyage@odasie.fr')
->setTo($data['email'])
->setBody(
$this->renderView(
'emails/registration.html.twig', [
'name' => $data['name'],
'subject' => 'Voyage sur mesure',
'message' => $data['message'],
]
), 'text/html'
)
;
$mailer->send($message);
//dd('test');
$this->addFlash(
'success', $translator->trans('Votre demande a bien été transmise')
);
return $this->redirectToRoute('tour_planner');
}
return $this->render('tour/planner.html.twig', [
'seo' => $seo,
'form' => $form->createView()
]);
}
public function showByType($slug, Request $request, ApiClient $apiClient,
TranslatorInterface $translator,
VoyageTypeHelper $voyageTypeHelper,
NavigationHelper $navigationHelper,
SeoHelper $seoHelper,
TemoignageHelper $temoignageHelper,
ThemeHelper $themeHelper,
PaysHelper $paysHelper)
{
$page = $request->query->get('page', 1);
$locale = $request->getLocale();
$debug = $this->getParameter('kernel.debug');
//$entity = 'content';
$entity = 'thematic';
/*
Récuperation du slug FR pour nourrir SeoHelper
Le slug sert aussi d'url aux différentes pages de catégories de tour
ainsi, le slug est traduit en anglais.
il faut retrouver le slug d'origine (en FR) et nourrir
$seoHelper avec celui-ci.
*/
$voyageTypes = $voyageTypeHelper->getAllTranslated($locale);
foreach($voyageTypes as $voyageType){
if($slug == $voyageType['slug']){
$slug = $voyageType['original_slug'];
}
}
/* Fin récuperation du slug FR pour nourrir SeoHelper */
try {
$seo = $seoHelper->getSeoBySlug($entity, $slug,$request->getLocale());
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
$theme = $themeHelper->getOneBySlug($slug);
/* Pays */
//$paysHelper = $this->container->get('app.api.helper.paysHelper');
$countries = $paysHelper->getAllTranslated($locale);
//formulaire
$duration_range = $request->get("duration_range") ?? null;
$arrival = $request->get("arrival") ?? null;
$category = $request->get("category") ?? null;
$arrTemoignages = [];
$arrTemoignages = $temoignageHelper->getByTourType($slug);
try {
$navigation = $navigationHelper->getNavigation();
}
catch(\Exception $e) {
}
/**
* sélection et formatage des tour_types
* pour affichage dans twig
*/
$typeLibelle = '';
foreach($navigation['themes']['children'] as $tourTypeKey => $tourType) {
$slugBis = str_replace('-', '_', $slug);
if(str_contains($slugBis, $tourTypeKey)) {
$typeLibelle = str_replace('Voyage ', '', $tourType['label']);
if($typeLibelle === 'entre amis') {
$typeLibelle = 'entre potes';
}
}
if($slug === 'solitaire') {
$typeLibelle = 'en solo';
}
}
return $this->render('tour/index_by_category.html.twig', [
'seo' => $seo,
'slug' => $slug,
//'content' => $content,
'page' => $page,
'countries' => $countries,
'temoignages' => $arrTemoignages,
//Champs du formulaire
'duration_range' => $duration_range,
'arrival' => $arrival,
'category' => $category,
'navigation' => $navigation,
'typeLibelle' => $typeLibelle
]);
}
/**
* @Route("tourcat/{slug}", name="tour_index_by_theme")
*/
public function indexByTheme($slug,
Request $request,
ApiClient $apiClient,
TranslatorInterface $translator,
SeoHelper $seoHelper) {
$page = $request->query->get('page', 1);
$debug = $this->getParameter('kernel.debug');
$entity = 'thematic';
try {
$seo = $seoHelper->getSeoBySlug($entity, $slug);
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
return $this->render('tour/index_by_category.html.twig', [
'seo' => $seo,
'slug' => $slug,
'page' => $page
]);
}
/**
*
* @Route({
* "fr": "/{_locale}/voyages",
* "en": "/{_locale}/trips"
* }, name="tour_index")
*
*/
public function index(Request $request, ApiClient $apiClient,
TranslatorInterface $translator,
PaysHelper $paysHelper) {
$page = $request->query->get('page', 1);
$debug = $this->getParameter('kernel.debug');
$locale = $request->getLocale();
$params['pays'] = $request->query->get('country', "");
if($params['pays'] == ""){
$params['pays'] = $request->query->get('pays', "");
}
$params['arrivee'] = $request->query->get('arrival', "");
$params['duree'] = $request->query->get('duration_range', "");
$params['categorie'] = $request->query->get('category', "");
if ($params['pays'] != "") {
return $this->redirect('/'.$locale.'/' . $params['pays'] . "?arrival=" . $params['arrivee'] . "&duration_range=" . $params['duree'] . "&duree=" . $params['duree'] . "&categorie=" . $params['categorie']);
}
if ($params['pays'] == "") {
return $this->redirect('/'.$locale.'/' . $params['categorie'] . "?arrival=" . $params['arrivee'] . "&duration_range=" . $params['duree'] . "&duree=" . $params['duree']);
}
if ($params['arrivee'] ) {
$request->getSession()->set('date', $params['arrivee']);
}
try {
//$paysHelper = $this->container->get('app.api.helper.paysHelper');
$pays = $paysHelper->getOneBySlug($params['pays']);
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
return $this->render('tour/index.html.twig', [
// 'seo' => $seo,
'page' => $page,
'pays' => $pays,
'params' => $params,
]);
}
/**
* @Route("/{_locale}/promotions", name="tour_promos")
*/
public function promos(Request $request,
ApiClient $apiClient,
TranslatorInterface $translator,
SeoHelper $seoHelper) {
$debug = $this->getParameter('kernel.debug');
$locale = $request->getLocale();
$entity = 'content';
try {
$seo = $seoHelper->getSeoBySlug($entity, "promotions",$request->getLocale());
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
try {
$voyageHelper = $this->voyageHelper;
$voyages = $voyageHelper->getAll(null, null, null, null, null, 'promotion');
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
$contentHelper = $this->contentHelper;
$content = $contentHelper->getOneBySlug("promotions");
return $this->render('tour/promotions.html.twig', [
'seo' => $seo,
'content' => $content,
'voyages' => $voyages
]);
}
/*
public function show($pays, $slug, Request $request,ApiClient $apiClient, TranslatorInterface $translator) {
$debug = $this->getParameter('kernel.debug');
$entity = 'tour';
$locale = $request->getLocale();
$basePath = $this->getParameter('api.base_uri').'/uploads/';
try {
$seoHelper = new SeoHelper($apiClient);
$seo = $seoHelper->getSeoBySlug($entity, $slug);
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
$voyageHelper = new VoyageHelper($apiClient,$locale);
$voyages = $voyageHelper->getAll();
$contentHelper = new ContentHelper($apiClient, $locale);
//$voyages = $contentHelper->getTraductionCustomTour($voyages,$locale);
//Si la langue n'est pas FR, le slug est très probablement une version traduite
//il faut retrouver sa version originale.
$realSlug = $slug;
$trip = $voyageHelper->getOneBySlug($realSlug);
//Traductions du customtour
if($locale != "fr"){
$traductionContent = $contentHelper->getTraductionCustomTour([$trip['tour']],$locale);
$trip['tour'] = $traductionContent[0] ?? $trip['tour'];
//traduction des commodités
foreach($trip['commodities'] as &$commodite){
$tradCommodity = $contentHelper->getTraductionContenu($commodite['commodity_id'],"ext_commodite",$locale);
$commodite['commodity_libelle'] = $tradCommodity['libelle'];
}
//traduction des jours
foreach($trip['days'] as &$day){
$trad = $contentHelper->getTraductionContenu($day['day_id'],"ext_customtour_day",$locale);
$day['day_description'] = $trad['description'];
//traduction des supports
foreach($day['supports'] as &$support){
$trad = $contentHelper->getTraductionContenu($support['id'],"ext_customtour_day_support",$locale);
$support['libelle'] = $trad['libelle'];
}
}
}
if(!$trip){
$this->addFlash(
'danger', $translator->trans('ce voyage n\'existe pas')
);
return $this->redirectToRoute('tour_index');
}
//on organise les hotels et croisieres par destination car en twig c'est chiant
$arrHotels = array();
$arrayHEtC = array_merge($trip['hotels'],$trip['cruises']);
foreach($arrayHEtC as $keyH => $hotelOuCroisiere){
if(!array_key_exists($hotelOuCroisiere['destination_libelle'], $arrHotels)){
$arrHotels[$hotelOuCroisiere['destination_libelle']] = array();
}
array_push($arrHotels[$hotelOuCroisiere['destination_libelle']],$hotelOuCroisiere);
}
// Recherche de voyages sur la même destination
$voyagesDestination = [];
$voyagesAutresDestinations = [];
$voyageHelper = $this->voyageHelper;
$voyagesDestination = $voyageHelper->getAll($trip['tour']['pays_slug'], null, 1, null, null, null, 'ct.ordre', 'ASC', 12, null);
if (empty($voyagesDestination)) {
$voyagesAutresDestinations = $voyageHelper->getAll(null, null, 1, null, null, null, 'ct.ordre', 'ASC', 12, null);
}
//dd($arrHotels);
return $this->render('tour/show2.html.twig', [
'seo' => $seo,
'trip' => $trip,
'slug' => $realSlug,
'locale' => $locale,
'basePath' => $basePath,
'arrHotels' => $arrHotels,
'voyagesDestination' => $voyagesDestination,
'voyagesAutresDestinations' => $voyagesAutresDestinations
]);
}
*/
// /**
// * @Route("voyage/{slug}/devis", name="tour_quotation")
// */
// public function quotation($slug, Request $request, ApiClient $apiClient, DolApiClient $dolApiClient, \Swift_Mailer $mailer, TranslatorInterface $translator) {
// $debug = $this->getParameter('kernel.debug');
// $locale = $request->getLocale();
// $entity = 'tour';
//
// try {
// $seoHelper = new SeoHelper($apiClient);
// $seo = $seoHelper->getSeoBySlug($entity, $slug);
// } catch (ClientException $e) {
// if ($debug) {
// $viewPath = "api/error/notfound.html.twig";
// return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
// }
// }
//
// $form = $this->createForm(CustomTourFormType::class);
// $form->handleRequest($request);
//
// if ($form->isSubmitted() && $form->isValid()) {
//
// $data = $form->getData();
//
// $contact = [];
// $contact["name"] = $data['lastname'] . ' ' . $data['firstname'];
// $contact["address"] = $data['address'];
// $contact["zip"] = $data['zip'];
// $contact["town"] = $data['city'];
// $contact["pays"] = $data['country'];
// $contact["phone"] = $data['phone'];
// $contact["email"] = $data['email'];
// $contact["client"] = 2;
// $contact["code_client"] = -1;
// $contact["array_options"] = ["source" => 1];
//
// try {
// $contactHelper = new contactHelper($apiClient, $locale);
// $contactExists = $contactHelper->getByEmail($contact["email"]);
// } catch (ClientException $e) {
// if ($debug) {
// $viewPath = "api/error/notfound.html.twig";
// return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
// }
// }
//
// $contactHelper = new contactHelper($dolApiClient, $locale);
//
// if (is_null($contactExists)) {
//
// try {
// $response = $contactHelper->create($contact);
// } catch (ClientException $e) {
// if ($debug) {
// $viewPath = "api/error/notfound.html.twig";
// return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
// }
// }
//
// $customerId = $response;
// } else {
//
// try {
// $response = $contactHelper->update($contactExists['rowid'], $contact);
// } catch (ClientException $e) {
// if ($debug) {
// $viewPath = "api/error/notfound.html.twig";
// return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
// }
// }
//
// $customerId = $response['id'];
// }
//
// $demand = [];
// $demand["customer"] = $customerId;
// $demand['tour'] = $slug;
// $demand["message"] = $data['message'];
// $demand["availabilities"] = $data['availability'];
//
// try {
// $demandHelper = new DemandHelper($apiClient, $locale);
// $demandResponse = $demandHelper->create($demand);
// } catch (ClientException $e) {
// if ($debug) {
// $viewPath = "api/error/notfound.html.twig";
// return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
// }
// }
//
// $message = (new \Swift_Message($translator->trans('Nous vous remercions pour votre demande')))
// ->setFrom('voyage@odasie.fr')
// ->setTo($data['email'])
// ->setBody(
// $this->renderView(
// 'emails/registration.html.twig', [
// 'name' => $contact['name'],
// 'subject' => 'Votre demande de devis',
// 'message' => $demand["message"],
// ]
// ), 'text/html'
// )
// ;
//
// $mailer->send($message);
//
// $this->addFlash(
// 'success', $translator->trans('Votre demande a bien été transmise')
// );
//
// return $this->redirectToRoute('tour_show', ['slug' => $slug,]);
// }
//
// return $this->render('tour/quotation.html.twig', [
// 'seo' => $seo,
// 'slug' => $slug,
// 'form' => $form->createView()
// ]);
// }
/**
* @Route({
* "fr": "{_locale}/votre-voyage/{key}",
* "en": "{_locale}/your-trip/{key}"
* }, name="tour_custom_itinary")
*/
public function customItinary($key, Request $request, ApiClient $apiClient, TranslatorInterface $translator) {
$debug = $this->getParameter('kernel.debug');
$locale = $request->getLocale();
$basePath = $this->getParameter('api.base_uri').'/uploads/';
if (!$key) {
throw new BadRequestHttpException($translator->trans("La clé doit être indiquée"));
}
try {
$voyageHelper = $this->voyageHelper;
$voyage = $voyageHelper->getOneByKey($key);
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
if (empty($voyage)) {
return $this->redirectToRoute('tour_index');
}
//on organise les hotels et croisieres par destination car en twig c'est chiant
$arrHotels = array();
$arrayHEtC = array_merge($voyage['hotels'],$voyage['cruises']);
foreach($arrayHEtC as $keyH => $hotelOuCroisiere){
if(!array_key_exists($hotelOuCroisiere['destination_libelle'], $arrHotels)){
$arrHotels[$hotelOuCroisiere['destination_libelle']] = array();
}
array_push($arrHotels[$hotelOuCroisiere['destination_libelle']],$hotelOuCroisiere);
}
$params = [];
$params['arrivee'] = $request->query->get('arrival', "");
$params['duree'] = $request->query->get('duration_range', "");
$params['categorie'] = $request->query->get('category', "");
$params['defaultTour'] = "custom";
$sum = 0;
$totalBarre = 0;
if (isset($voyage['tour']['voyage_price_per_person_to_apply']) &&
json_decode($voyage['tour']['voyage_price_per_person_to_apply'], true) == true) {
foreach (json_decode($voyage['tour']['voyage_price_per_person_to_apply'], true) as $pricePerPerson) {
$sum += $pricePerPerson;
}
// caclul du prix total barré à aficher
$applyDiscountPrice = json_decode($voyage['tour']['voyage_apply_discount_price_per_person'], true);
$initialPricePerPerson = json_decode($voyage['tour']['voyage_initial_price_per_person'], true);
foreach ($applyDiscountPrice as $keyDiscount => $pax) {
if($pax === true) {
$price = round($initialPricePerPerson[$keyDiscount]['totalPrice']);
$totalBarre += $price;
} else {
/* $price = $voyage['tour']['voyage_prix_personne']; */
foreach ($voyage['voyageurs'] as $keyVoyageur => $voyageur) {
if($voyageur['rowid'] == $keyDiscount) {
$price = $voyageur['contact_price'];
}
}
$totalBarre += $price;
}
}
/* dd($voyage, json_decode($voyage['tour']['voyage_price_per_person_to_apply']), $initialPricePerPerson); */
} else {
if(isset($voyage['tour']['voyage_initial_price_per_person'])){
foreach (json_decode($voyage['tour']['voyage_initial_price_per_person'], true) as $pricePerPerson) {
$sum += $pricePerPerson['totalPrice'];
}
}
}
/* dd($totalBarre); */
return $this->render('tour/show2.html.twig', [
'params' => $params,
'trip' => $voyage,
'titleTagName' => 'h1',
'key' => $key,
'locale' => $locale,
'basePath' => $basePath,
'arrHotels' => $arrHotels,
'initialPricePerPerson' => json_decode($voyage['tour']['voyage_initial_price_per_person'], true),
'pricePerPersonToApply' => json_decode($voyage['tour']['voyage_price_per_person_to_apply'], true),
'applyDiscountPricePerPerson' => json_decode($voyage['tour']['voyage_apply_discount_price_per_person'], true),
'totalPrice' => $sum,
'totalBarre' => $totalBarre
]);
}
/**
* @Route({
* "fr": "{_locale}/votre-voyage/{key}/contacts",
* "en": "{_locale}/your-trip/{key}/contacts"
* }, name="tour_custom_itinary_contact")
*/
public function customItinaryContacts($key, Request $request, ApiClient $apiClient, TranslatorInterface $translator) {
$debug = $this->getParameter('kernel.debug');
$locale = $request->getLocale();
if (!$key) {
throw new BadRequestHttpException($translator->trans("La clé doit être indiquée"));
}
//on recupère les voyageurs
try {
$voyageHelper = $this->voyageHelper;
$voyageurs = $voyageHelper->getVoyageurs($key);
$clientId = $voyageurs['contacts'][0]['client_id'];
//sanétization : si un champs à la string "null" en valeur, on le passe à null (vrai valeur vide)
/*
foreach($voyageurs['contacts'] as &$v){
foreach($v as $key => $field){
if(is_string($field)){
if($field === "null"){
$v[$key] = null;
}
}
}
}
*/
// //recup de la session, si pas encore loggé redirect vers login
// $session = $request->getSession();
// $userId = $session->get('userId');
// //on teste si user est bien le contact
// if ($userId != $clientId) {
// $userId = $session->set('userId', '-1');
// $this->addFlash(
// 'warning', $translator->trans('Merci de vous connecter avec le bon utilisateur')
// );
// return $this->redirectToRoute('login', array('key' => $key));
// }
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
if (empty($voyageurs) && $debug) {
return $this->redirectToRoute('tour_index');
}
//TODO get info du form
$form = $this->createForm(InfoTourType::class, array('key' => $key));
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
//on envoi a l'api
try {
$voyageHelper = $this->voyageHelper;
$retour = $voyageHelper->setVoyageurs($key, $form->getData());
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
if ($retour) {
//redirect sur la page du voyage
// $this->addFlash(
// 'success', $translator->trans('Votre demande a bien été transmise')
// );
return $this->redirectToRoute('tour_custom_itinary_valide', array('key' => $key));
}
}
//tableau des pays pour faciliter la gestion des selecteurs de pays
$pays = array(
0 => array('value' => 'BE', 'label' => 'Belgique'),
1 => array('value' => 'CA', 'label' => 'Canada'),
2 => array('value' => 'FR', 'label' => 'France'),
3 => array('value' => 'LU', 'label' => 'Luxembourg'),
4 => array('value' => 'CH', 'label' => 'Suisse'),
5 => array(),
6 => array('value' => 'AF', 'label' => 'Afghanistan'),
7 => array('value' => 'ZA', 'label' => 'Afrique du Sud'),
8 => array('value' => 'AL', 'label' => 'Albanie'),
9 => array('value' => 'DZ', 'label' => 'Algérie'),
10 => array('value' => 'DE', 'label' => 'Allemagne'),
11 => array('value' => 'AD', 'label' => 'Andorre'),
12 => array('value' => 'AO', 'label' => 'Angola'),
13 => array('value' => 'AI', 'label' => 'Anguilla'),
14 => array('value' => 'AQ', 'label' => 'Antarctique'),
15 => array('value' => 'AG', 'label' => 'Antigua-et-Barbuda'),
16 => array('value' => 'SA', 'label' => 'Arabie saoudite'),
17 => array('value' => 'AR', 'label' => 'Argentine'),
18 => array('value' => 'AM', 'label' => 'Arménie'),
19 => array('value' => 'AW', 'label' => 'Aruba'),
20 => array('value' => 'AU', 'label' => 'Australie'),
21 => array('value' => 'AT', 'label' => 'Autriche'),
22 => array('value' => 'AZ', 'label' => 'Azerbaïdjan'),
23 => array('value' => 'BS', 'label' => 'Bahamas'),
24 => array('value' => 'BH', 'label' => 'Bahreïn'),
25 => array('value' => 'BD', 'label' => 'Bangladesh'),
26 => array('value' => 'BB', 'label' => 'Barbade'),
27 => array('value' => 'BZ', 'label' => 'Belize'),
28 => array('value' => 'BM', 'label' => 'Bermudes'),
29 => array('value' => 'BT', 'label' => 'Bhoutan'),
30 => array('value' => 'BY', 'label' => 'Biélorussie'),
31 => array('value' => 'BO', 'label' => 'Bolivie'),
32 => array('value' => 'BA', 'label' => 'Bosnie-Herzégovine'),
33 => array('value' => 'BW', 'label' => 'Botswana'),
34 => array('value' => 'BN', 'label' => 'Brunei'),
35 => array('value' => 'BR', 'label' => 'Brésil'),
36 => array('value' => 'BG', 'label' => 'Bulgarie'),
37 => array('value' => 'BF', 'label' => 'Burkina Faso'),
38 => array('value' => 'BI', 'label' => 'Burundi'),
39 => array('value' => 'BJ', 'label' => 'Bénin'),
40 => array('value' => 'KH', 'label' => 'Cambodge'),
41 => array('value' => 'CM', 'label' => 'Cameroun'),
42 => array('value' => 'CV', 'label' => 'Cap Vert'),
43 => array('value' => 'CL', 'label' => 'Chili'),
44 => array('value' => 'CN', 'label' => 'Chine'),
45 => array('value' => 'CY', 'label' => 'Chypre'),
46 => array('value' => 'CO', 'label' => 'Colombie'),
47 => array('value' => 'KM', 'label' => 'Comores'),
48 => array('value' => 'KP', 'label' => 'Corée du Nord'),
49 => array('value' => 'KR', 'label' => 'Corée du Sud'),
50 => array('value' => 'CR', 'label' => 'Costa Rica'),
51 => array('value' => 'HR', 'label' => 'Croatie'),
52 => array('value' => 'CU', 'label' => 'Cuba'),
53 => array('value' => 'CI', 'label' => 'Côte d\'Ivoire'),
54 => array('value' => 'DK', 'label' => 'Danemark'),
55 => array('value' => 'DJ', 'label' => 'Djibouti'),
56 => array('value' => 'DM', 'label' => 'Dominique'),
57 => array('value' => 'SV', 'label' => 'El Salvador'),
58 => array('value' => 'ES', 'label' => 'Espagne'),
59 => array('value' => 'EE', 'label' => 'Estonie'),
60 => array('value' => 'FM', 'label' => 'Etats fédérés de Micronésie'),
61 => array('value' => 'US', 'label' => 'Etats-Unis d\'Amérique'),
62 => array('value' => 'FJ', 'label' => 'Fidji'),
63 => array('value' => 'FI', 'label' => 'Finlande'),
64 => array('value' => 'GA', 'label' => 'Gabon'),
65 => array('value' => 'GM', 'label' => 'Gambie'),
66 => array('value' => 'GH', 'label' => 'Ghana'),
67 => array('value' => 'GI', 'label' => 'Gibraltar'),
68 => array('value' => 'GD', 'label' => 'Grenade'),
69 => array('value' => 'GR', 'label' => 'Grèce'),
70 => array('value' => 'GU', 'label' => 'Guam'),
71 => array('value' => 'GT', 'label' => 'Guatemala'),
72 => array('value' => 'GN', 'label' => 'Guinée'),
73 => array('value' => 'GQ', 'label' => 'Guinée équatoriale'),
74 => array('value' => 'GW', 'label' => 'Guinée-Bissau'),
75 => array('value' => 'GE', 'label' => 'Géorgie'),
76 => array('value' => 'HT', 'label' => 'Haïti'),
77 => array('value' => 'HN', 'label' => 'Honduras'),
78 => array('value' => 'HK', 'label' => 'Hong-Kong'),
79 => array('value' => 'HU', 'label' => 'Hongrie'),
80 => array('value' => 'IN', 'label' => 'Inde'),
81 => array('value' => 'ID', 'label' => 'Indonésie'),
82 => array('value' => 'IR', 'label' => 'Iran'),
83 => array('value' => 'IQ', 'label' => 'Iraq'),
84 => array('value' => 'IE', 'label' => 'Irlande'),
85 => array('value' => 'IS', 'label' => 'Islande'),
86 => array('value' => 'IL', 'label' => 'Israël'),
87 => array('value' => 'IT', 'label' => 'Italie'),
88 => array('value' => 'JM', 'label' => 'Jamaïque'),
89 => array('value' => 'JP', 'label' => 'Japon'),
90 => array('value' => 'JO', 'label' => 'Jordanie'),
91 => array('value' => 'KZ', 'label' => 'Kazakhstan'),
92 => array('value' => 'KE', 'label' => 'Kenya'),
93 => array('value' => 'KG', 'label' => 'Kirghizstan'),
94 => array('value' => 'KI', 'label' => 'Kiribati'),
95 => array('value' => 'KW', 'label' => 'Koweït'),
96 => array('value' => 'LA', 'label' => 'Laos'),
97 => array('value' => 'LS', 'label' => 'Lesotho'),
98 => array('value' => 'LV', 'label' => 'Lettonie'),
99 => array('value' => 'LB', 'label' => 'Liban'),
100 => array('value' => 'LY', 'label' => 'Libye'),
101 => array('value' => 'LR', 'label' => 'Libéria'),
102 => array('value' => 'LI', 'label' => 'Liechtenstein'),
103 => array('value' => 'LT', 'label' => 'Lituanie'),
104 => array('value' => 'MO', 'label' => 'Macao'),
105 => array('value' => 'MK', 'label' => 'Macédoine'),
106 => array('value' => 'MG', 'label' => 'Madagascar'),
107 => array('value' => 'MY', 'label' => 'Malaisie'),
108 => array('value' => 'MW', 'label' => 'Malawi'),
109 => array('value' => 'MV', 'label' => 'Maldives'),
110 => array('value' => 'ML', 'label' => 'Mali'),
111 => array('value' => 'MT', 'label' => 'Malte'),
112 => array('value' => 'MA', 'label' => 'Maroc'),
113 => array('value' => 'MQ', 'label' => 'Martinique'),
114 => array('value' => 'MR', 'label' => 'Mauritanie'),
115 => array('value' => 'YT', 'label' => 'Mayotte'),
116 => array('value' => 'MX', 'label' => 'Mexique'),
117 => array('value' => 'MD', 'label' => 'Moldavie'),
118 => array('value' => 'MC', 'label' => 'Monaco'),
119 => array('value' => 'MN', 'label' => 'Mongolie'),
120 => array('value' => 'MS', 'label' => 'Montserrat'),
121 => array('value' => 'ME', 'label' => 'Monténégro'),
122 => array('value' => 'MZ', 'label' => 'Mozambique'),
123 => array('value' => 'MM', 'label' => 'Myanmar'),
124 => array('value' => 'NA', 'label' => 'Namibie'),
125 => array('value' => 'NR', 'label' => 'Nauru'),
126 => array('value' => 'NI', 'label' => 'Nicaragua'),
127 => array('value' => 'NE', 'label' => 'Niger'),
128 => array('value' => 'NG', 'label' => 'Nigeria'),
129 => array('value' => 'NU', 'label' => 'Nioué'),
130 => array('value' => 'NO', 'label' => 'Norvège'),
131 => array('value' => 'NZ', 'label' => 'Nouvelle-Zélande'),
132 => array('value' => 'NP', 'label' => 'Népal'),
133 => array('value' => 'OM', 'label' => 'Oman'),
134 => array('value' => 'UG', 'label' => 'Ouganda'),
135 => array('value' => 'UZ', 'label' => 'Ouzbékistan'),
136 => array('value' => 'PK', 'label' => 'Pakistan'),
137 => array('value' => 'PW', 'label' => 'Palau'),
138 => array('value' => 'PS', 'label' => 'Palestine'),
139 => array('value' => 'PA', 'label' => 'Panama'),
140 => array('value' => 'PG', 'label' => 'Papouasie-Nouvelle-Guinée'),
141 => array('value' => 'PY', 'label' => 'Paraguay'),
142 => array('value' => 'NL', 'label' => 'Pays-Bas'),
143 => array('value' => 'PH', 'label' => 'Philippines'),
144 => array('value' => 'PL', 'label' => 'Pologne'),
145 => array('value' => 'PR', 'label' => 'Porto Rico'),
146 => array('value' => 'PT', 'label' => 'Portugal'),
147 => array('value' => 'PE', 'label' => 'Pérou'),
148 => array('value' => 'QA', 'label' => 'Qatar'),
149 => array('value' => 'RO', 'label' => 'Roumanie'),
150 => array('value' => 'UK', 'label' => 'Royaume-Uni'),
151 => array('value' => 'RU', 'label' => 'Russie'),
152 => array('value' => 'RW', 'label' => 'Rwanda'),
153 => array('value' => 'CF', 'label' => 'République Centrafricaine'),
154 => array('value' => 'DO', 'label' => 'République Dominicaine'),
155 => array('value' => 'CG', 'label' => 'République du Congo'),
156 => array('value' => 'GY', 'label' => 'République du Guyana'),
157 => array('value' => 'CD', 'label' => 'République démocratique du Congo'),
158 => array('value' => 'CZ', 'label' => 'République tchèque'),
159 => array('value' => 'RE', 'label' => 'Réunion'),
160 => array('value' => 'SM', 'label' => 'Saint-Marin'),
161 => array('value' => 'WS', 'label' => 'Samoa'),
162 => array('value' => 'ST', 'label' => 'Sao Tomé-et-Principe'),
163 => array('value' => 'RS', 'label' => 'Serbie'),
164 => array('value' => 'SC', 'label' => 'Seychelles'),
165 => array('value' => 'SL', 'label' => 'Sierra Leone'),
166 => array('value' => 'SG', 'label' => 'Singapour'),
167 => array('value' => 'SK', 'label' => 'Slovaquie'),
168 => array('value' => 'SI', 'label' => 'Slovénie'),
169 => array('value' => 'SO', 'label' => 'Somalie'),
170 => array('value' => 'SD', 'label' => 'Soudan'),
171 => array('value' => 'LK', 'label' => 'Sri Lanka'),
172 => array('value' => 'SR', 'label' => 'Suriname'),
173 => array('value' => 'SE', 'label' => 'Suède'),
174 => array('value' => 'SZ', 'label' => 'Swaziland'),
175 => array('value' => 'SY', 'label' => 'Syrie'),
176 => array('value' => 'SN', 'label' => 'Sénégal'),
177 => array('value' => 'TJ', 'label' => 'Tadjikistan'),
178 => array('value' => 'TZ', 'label' => 'Tanzanie'),
179 => array('value' => 'TW', 'label' => 'Taïwan'),
180 => array('value' => 'TD', 'label' => 'Tchad'),
181 => array('value' => 'TH', 'label' => 'Thaïlande'),
182 => array('value' => 'TL', 'label' => 'Timor oriental'),
183 => array('value' => 'TG', 'label' => 'Togo'),
184 => array('value' => 'TO', 'label' => 'Tonga'),
185 => array('value' => 'TT', 'label' => 'Trinité-et-Tobago'),
186 => array('value' => 'TN', 'label' => 'Tunisie'),
187 => array('value' => 'TM', 'label' => 'Turkménistan'),
188 => array('value' => 'TR', 'label' => 'Turquie'),
189 => array('value' => 'TV', 'label' => 'Tuvalu'),
190 => array('value' => 'UA', 'label' => 'Ukraine'),
191 => array('value' => 'UY', 'label' => 'Uruguay'),
192 => array('value' => 'VU', 'label' => 'Vanuatu'),
193 => array('value' => 'VA', 'label' => 'Vatican'),
194 => array('value' => 'VE', 'label' => 'Venezuela'),
195 => array('value' => 'VN', 'label' => 'Vietnam'),
196 => array('value' => 'YE', 'label' => 'Yémen'),
197 => array('value' => 'ZM', 'label' => 'Zambie'),
198 => array('value' => 'ZW', 'label' => 'Zimbabwe'),
199 => array('value' => 'EG', 'label' => 'Égypte'),
200 => array('value' => 'AE', 'label' => 'Émirats arabes unis'),
201 => array('value' => 'EC', 'label' => 'Équateur'),
202 => array('value' => 'ER', 'label' => 'Érythrée'),
203 => array('value' => 'ET', 'label' => 'Éthiopie'),
204 => array('value' => 'BV', 'label' => 'Île Bouvet'),
205 => array('value' => 'MU', 'label' => 'Île Maurice'),
206 => array('value' => 'AX', 'label' => 'Îles Åland'),
);
//dd($voyageurs);
return $this->render('tour/form_contact.html.twig', [
'voyageurs' => $voyageurs,
'pays' => $pays,
'titleTagName' => 'h1',
'form' => $form->createView(),
'upload_dir' => $this->getParameter('upload_dir'),
'locale' => $locale
]);
}
/**
* @Route({
* "fr": "{_locale}/votre-voyage/{key}/valide",
* "en": "{_locale}/your-trip/{key}/valide"
* }, name="tour_custom_itinary_valide")
*/
public function customItinaryValide($key, Request $request, ApiClient $apiClient, TranslatorInterface $translator) {
$locale = $request->getLocale();
$voyageHelper = $this->voyageHelper;
$voyageur = $voyageHelper->getVoyageurs($key);
$prenom = '';
if(!is_null($voyageur)){
if(array_key_exists("contacts", $voyageur)){
$prenom = $voyageur["contacts"][0]["firstname"];
}
}
return $this->render('tour/valide.html.twig', [
'prenom' => $prenom,
'titleTagName' => 'h1',
'locale' => $locale
]);
}
/**
* @Route("/{_locale}/{pays}/{slug}", name="show_tour")
*/
public function showTour($pays, $slug, Request $request,
ApiClient $apiClient,
TranslatorInterface $translator,
VoyageHelper $voyageHelper,
SeoHelper $seoHelper) {
$debug = $this->getParameter('kernel.debug');
$entity = 'tour';
$locale = $request->getLocale();
$basePath = $this->getParameter('api.base_uri').'/uploads/';
//$voyageHelper = new VoyageHelper($apiClient,$locale);
//$voyages = $voyageHelper->getAll();
$contentHelper = $this->contentHelper;
$locale = $request->getLocale();
if(!in_array($locale,['fr','en'])){
$request->getSession()->set('_locale', "fr");
$locale = $request->getSession()->get('_locale', "fr");
}
//$voyages = $contentHelper->getTraductionCustomTour($voyages,$locale);
//Si la langue n'est pas FR, le slug est très probablement une version traduite
//il faut retrouver sa version originale.
if($locale != "fr"){
$realSlug = $contentHelper->getVoyageByTranslatedSlug($slug,$locale);
//Verifier si le $pays est correct
if(!in_array($pays,
["thailand","indonesia", "cambodia","sri-lanka", "philippines","vietnam","laos", "birmanie-myanmar"])){
return $this->redirectToRoute("homepage", ["_locale"=> $locale], 301);
}
if(!is_null($realSlug)){
$slug = $realSlug;
}
}else{
//Si on est en FR et que le pays n'est pas bon, on redirige à l'accueil.
if(!in_array($pays,
["thailande","indonesie", "cambodge","sri-lanka", "philippines","vietnam","laos" ,"birmanie-myanmar"])){
return $this->redirectToRoute("homepage", ["_locale"=>$locale], 301);
}
}
try {
$seo = $seoHelper->getSeoBySlug($entity, $slug, $request->getLocale());
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
$trip = $voyageHelper->getOneBySlug($slug);
//Traductions du customtour
if($locale != "fr" && $trip && $slug == $realSlug){
$traductionContent = $contentHelper->getTraductionCustomTour([$trip['tour']],$locale);
$trip['tour'] = $traductionContent[0] ?? $trip['tour'];
//traduction des commodités
foreach($trip['commodities'] as &$commodite){
$tradCommodity = $contentHelper->getTraductionContenu($commodite['commodity_id'],"ext_commodite",$locale);
if(!empty($tradCommodity)){
$commodite['commodity_libelle'] = $tradCommodity['libelle'];
}else{
$commodite['commodity_libelle'] = $commodite['libelle'] ?? "";
}
}
//traduction des jours
foreach($trip['days'] as &$day){
$trad = $contentHelper->getTraductionContenu($day['day_id'],"ext_customtour_day",$locale);
if(!empty($trad)){
$day['day_libelle'] = $trad['libelle'] ?? $day['day_libelle'];
$day['day_description'] = $trad['description'];
}else{
$day['day_libelle'] = $day['day_libelle'];
$day['day_description'] = $day['description'];
}
//traduction des elements de l'hotel et sous-jacent
if (isset($day) && !empty($day['hotels'])) {
foreach ($day['hotels'] as &$hotel) {
//Hotel
//dd($hotel);
$tradHotel = $contentHelper->getTraductionContenu($hotel['service_id'], "ext_service", $locale);
if (!is_null($tradHotel) && !empty($tradHotel)) {
//hotel_description
$hotel['hotel_description'] = (isset($tradHotel['description'])) ? $tradHotel['description'] : $hotel['hotel_description'];
}
//commodities
//Si l'hotel possède un champs "rooms" qui n'est pas vide
if (isset($hotel['rooms']) && !empty($hotel['rooms'])) {
foreach ($hotel['rooms'] as &$room) {
//dump($room);
$tradRoom = $contentHelper->getTraductionContenu($room['room_id'], "ext_hotel_chambre", $locale);
if (!is_null($tradRoom) && !empty($tradRoom)) {
//description
$room['description'] = (isset($tradRoom['description'])) ? $tradRoom['description'] : $room['description'];
}
//Commodités de la room
if (isset($room['commodities']) && !empty($room['commodities'])) {
foreach ($room['commodities'] as &$commodity) {
$tradCom = $contentHelper->getTraductionContenu($commodity['commodity_id'], "ext_commodite", $locale);
if (!is_null($tradCom) && !empty($tradCom)) {
//description
$commodity['commodity_libelle'] = (isset($tradCom['libelle'])) ? $tradCom['libelle'] : $commodity['commodity_libelle'];
}
}
}
}
}
}
}
//traduction des supports
foreach($day['supports'] as &$support){
$trad = $contentHelper->getTraductionContenu($support['id'],"ext_customtour_day_support",$locale);
if(!empty($trad)){
$support['libelle'] = $trad['libelle'];
}
}
}
//dd($trip['days']);
}
if(!$trip){
$this->addFlash(
'danger', $translator->trans('ce voyage n\'existe pas')
);
return $this->redirectToRoute('tour_index', [], 301);
}
foreach($trip['hotels'] as &$hotel){
//$hotel = $contentHelper->getTraductionContenu($support['id'],"ext_customtour_day_support",$locale);
}
foreach($trip['cruises'] as &$cruise){
//$cruise = $contentHelper->getTraductionContenu($support['id'],"ext_customtour_day_support",$locale);
}
//on organise les hotels et croisieres par destination car en twig c'est chiant
$arrHotels = array();
$arrayHEtC = array_merge($trip['hotels'],$trip['cruises']);
//dd($arrayHEtC);
foreach($arrayHEtC as $keyH => $hotelOuCroisiere){
if(!array_key_exists($hotelOuCroisiere['destination_libelle'], $arrHotels)){
$arrHotels[$hotelOuCroisiere['destination_libelle']] = array();
}
array_push($arrHotels[$hotelOuCroisiere['destination_libelle']],$hotelOuCroisiere);
}
// Recherche de voyages sur la même destination
$voyagesDestination = [];
$voyagesAutresDestinations = [];
$voyageHelper = $this->voyageHelper;
$voyagesDestination = $voyageHelper->getAll($trip['tour']['pays_slug'], null, 1, null, null, null, 'ct.ordre', 'ASC', 12, null);
if (empty($voyagesDestination)) {
$voyagesAutresDestinations = $voyageHelper->getAll(null, null, 1, null, null, null, 'ct.ordre', 'ASC', 12, null);
}
//Voyages 'coup de coeur'
$pays = $request->query->get('pays');
$theme = $request->query->get('theme');
$favoris = $request->query->get('favoris');
$dateDebut = $request->query->get('dateDebut');
$duree = $request->query->get('duree');
$tag = $request->query->get('tag');
$page = $request->query->get('page', 1);
$perPage = $request->query->get('perPage', 6);
$sort = $request->query->get('sort', 'ct.ordre');
$direction = $request->query->get('direction', 'ASC');
$limit = $request->query->get('limit', 6);
$offset = $request->query->get('offset');
try {
$voyageHelper = $this->voyageHelper;
$voyages = $voyageHelper->getAll($pays, $theme, $favoris, $dateDebut, $duree, $tag, $sort, $direction, $limit, $offset);
} catch (ClientException $e) {
if ($debug) {
$viewPath = "api/error/notfound.html.twig";
return $this->render($viewPath, array("message" => sprintf("Erreur API : %s", $this->getParameter('api.base_uri') . $e->getRequest()->getRequestTarget())));
}
}
$params = [];
$params['arrivee'] = $request->query->get('arrival', "");
$params['duree'] = $request->query->get('duration_range', "");
$params['categorie'] = $request->query->get('category', "");
$params['defaultTour'] = "default";
$bestSellerTableau = $voyageHelper->getBestseller("", 8);
$tabBestSeller = [];
$index = 0;
if(!empty($bestSellerTableau)){
foreach($bestSellerTableau as $best){
if($index < 4){
if($index < 2){
$tabBestSeller['partiGauche']['carre'][] = $best;
}
if($index == 2){
$tabBestSeller['partiGauche']['hauteur'] = $best;
}
if($index == 3){
$tabBestSeller['partiGauche']['largeur'] = $best;
}
} else {
if($index == 4){
$tabBestSeller['partiDroite']['largeur'] = $best;
}
if($index > 4 && $index < 7){
$tabBestSeller['partiDroite']['carre'][] = $best;
}
if($index == 7){
$tabBestSeller['partiDroite']['hauteur'] = $best;
}
}
$index++;
}
}
/**
* si plus d'une image, supprimer les images qui ne sont pas dans le répertoire customtour (car identiques)
*/
if(count($trip['pictures']) > 1) {
$offset = 0;
foreach($trip['pictures'] as $pictureKey => $picture) {
if($picture['document_entite'] === false) {
array_splice($trip['pictures'], $offset, 1);
}
$offset++;
}
}
return $this->render('tour/show2.html.twig', [
'seo' => $seo,
'trip' => $trip,
'slug' => $slug,
'locale' => $locale,
'basePath' => $basePath,
'arrHotels' => $arrHotels,
'voyagesDestination' => $voyagesDestination,
'voyages' => $voyages,
'voyagesAutresDestinations' => $voyagesAutresDestinations,
'params' => $params,
'tabBestSeller' => $tabBestSeller
]);
}
}