{% set nuitees = app.request.get('nuitees',1) %}
{% set checkin = app.request.get('checkin',"now"|date('Y-m-d')) %}
{% set rooms = roomsToArray(app.request.get('rooms','2')) %}
{% if searchPackageVoyages is defined %}
{% set produit = "" %}
{% set resultView = "" %}
{% set onlySearchCity = 0 %}
{% set rooms = roomsToArray(app.request.get('occupations','2')) %}
{% set checkin = app.request.get('debut',"now"|date('Y-m-d')) %}
{% set checkout = app.request.get('fin',"now"|date_modify("+1 day")|date("Y-m-d")) %}
{% set difference = date(checkout).diff(date(checkin)) %}
{% set nuitees = difference.days %}
{% endif %}
{% if configAffichage is not defined %}
{% set configAffichage = getConfigAffichage() %}
{% endif %}
{% if configAffichage.HOTEL["MODELE_SELECT_VILLE_HOTEL#{is_mobile() ? '_MOBILE' : ''}"] == 'jsuites' %}
<script src="{{ asset('assets-commun/js/jsuites.js') }}"></script>
{% elseif configAffichage.HOTEL["MODELE_SELECT_VILLE_HOTEL#{is_mobile() ? '_MOBILE' : ''}"] == 'typeahead' %}
{#{% if is_mobile() %}
<script type="text/javascript" src="{{ asset('assets-commun/js/bootstrap3-typeahead.min.js') }}"></script>
{% else %}#}
<script src="{{ asset('assets-commun/jquery-typeahead-2.11.0/dist/jquery.typeahead.min.js') }}"></script>
{#{% endif %}#}
{% endif %}
{% if app.request.server.get('FORCE_SEARCH_HOTEL_ONLY_BY_CITY') %}
{% set onlySearchCity = 1 %}
{% endif %}
{% if destination is defined %}
{% set villes_hotels = [] %}
{% set selected_destination = destination %}
{% else %}
{% set villes_hotels = getVillesHotels(produit==''?'SHT':produit,onlySearchCity, _destination is defined ? _destination : '', configAffichage.HOTEL["MODELE_SELECT_VILLE_HOTEL#{is_mobile() ? '_MOBILE' : ''}"] , appartement is defined and appartement) %}
{% set selected_destination = villes_hotels.selected_destination %}
{% set villes_hotels = villes_hotels.destinations %}
{% endif %}
<script>
var vjsAdvancedSearch{{ produit }} = new Vue({
el: '#vjs-advanced-search{{ produit!=''?'-'~produit|lower:'' }}',
data: {
module: "hotel",
rooms:{{ rooms|json_encode|raw }},
checkin_fr: '{{ checkin|date('d/m/Y') }}',
checkout_fr: '{{ checkin|date_modify("+" ~ nuitees ~ " day")|date('d/m/Y') }}',
checkin_en: '{{ checkin|date('Y-m-d') }}',
checkout_en: '{{ checkin|date_modify("+" ~ nuitees ~ " day")|date('Y-m-d') }}',
nuitees: {{ nuitees }},
{% if app.request.get('_route') == 'sejour_hotel_availability_landing_page' %}
pays: 'multi',
ville: 'destination',
hotel: '{{ hotel_to_ids(app.request.get('hotel')) }}',
destination: 'v-tous',
lbl_destination: 'multi destination',
{% else %}
pays: '{{ (selected_destination and selected_destination.pays is defined) ? selected_destination.pays : 'all' }}',
ville: '{{ (selected_destination and selected_destination.ville is defined) ? selected_destination.ville : 'all' }}',
hotel: '{{ (selected_destination and selected_destination.hotel is defined) ? selected_destination.hotel : 'tous' }}',
destination: '{{ selected_destination ? selected_destination.type ~ '-' ~ selected_destination.id : 'all' }}',
lbl_destination: '{{ selected_destination ? selected_destination.name : '' }}',
{% endif %}
occupations: '',
recap_occupations: '',
recap_occupationsAppartement: '',
_recap_occupations: '',
},
methods: {
callAvailabilityVoyages() {
var routeAvail = Routing.generate('front_package_liste', {
...{
debut: this.checkin_en,
fin: this.checkout_en,
occupations: this.occupations
}, ...{{ app.request.query.all|json_encode|raw }}
});
window.location = routeAvail;
},
callAvailability() {
this.callAvailabilityVoyages();
},
callAvailability{{ produit }}() {
if ($('#form-search input#search-type').val() == 'voyages' && '{{ produit }}' === '') {
var routeAvail = Routing.generate('front_package_liste', {
...{
debut: this.checkin_en,
fin: this.checkout_en,
occupations: this.occupations
}, ...{{ app.request.query.all|json_encode|raw }}
});
window.location = routeAvail;
} else {
if (($('.typeahead_destination{{ produit }}').val() == '') || this.destination == "all") {
viewAlert('Veuillez choisir une ville ou un hôtel', 'danger')
return
}
{% if product is defined and product=="appartement" %}
{% set route_avail_hotel = app.request.server.get('ROUTE_AVAIL_HOTEL','sejour_appartement_availability') %}
{% else %}
{% set route_avail_hotel = app.request.server.get('ROUTE_AVAIL_HOTEL','sejour_hotel_availability') %}
{% endif %}
{% if route_avail_hotel == 'details_hotel' or route_avail_hotel == 'details_appartement' %}
var routeAvail = Routing.generate('{{ route_avail_hotel }}', {
...{
checkin: this.checkin_en,
nuitees: this.nuitees,
rooms: this.occupations,
city: this.ville,
slug: this.hotel,
id: this.destination.slice(2),
source: "{{ app.request.get('source','all') }}"
}, ...{{ app.request.server.get('PARAMS_ROUTE_AVAIL_HOTEL','{}')|raw }}
})
{% else %}
var routeAvail = Routing.generate('{{ route_avail_hotel }}', {
...{
checkin: this.checkin_en,
nuitees: this.nuitees,
rooms: this.occupations,
pays: this.pays,
ville: this.ville,
hotel: this.hotel,
destination: this.destination,
source: "{{ app.request.get('source','all') }}",
hotelMonde: "{{ enabled_hotel_stay_worldwide == 'true' ? 1 : app.request.get('hotelMonde','0') }}"
}, ...{{ app.request.query.all|json_encode|raw }}
})
{% endif %}
}
$('#mobile-destination').html(`<i class="fa fa-${this.destination.split('-')[0] == 'v' ? 'map-marker-alt' : 'hotel'} fa-1" aria-hidden="true" style=" margin-left: 1px;"></i> ` + this.lbl_destination);
$('#mobile-sejour').html(`Du ${this.checkin_fr.substr(0, 5)} au ${this.checkout_fr.substr(0, 5)} soit ${this.nuitees == 1 ? 'une' : this.nuitees} nuitée${this.nuitees > 1 ? 's' : ''}`);
$('#mobile-occupations').html(this.recap_occupations);
{% if app.request.get('_route') in ['accueil'] %}
window.location = routeAvail
{% else %}
{% if app.request.get('_route') == route_avail_hotel %}
window.history.pushState('data', 'title', routeAvail);
{% endif %}
vjsListHotels.hotels = []
var hotel_loading = this.destination.split('-')[0] == 'v' ? vjsListHotels.paginate_per : 1
vjsListHotels.hotel_loading = hotel_loading
$('#faq').html("")
$('#description-ville').html("")
$('#read-more-desc-ville').hide()
if (typeof vjsSearchNomsHotels !== 'undefined') {
vjsSearchNomsHotels.hotel_loading = hotel_loading
vjsSearchNomsHotels.visible = true
}
if (typeof vjsSortResult !== 'undefined') {
vjsSortResult.hotel_loading = hotel_loading
vjsSortResult.visible = true
}
if (typeof vjsRecapSearch !== 'undefined')
vjsRecapSearch.hotel_loading = hotel_loading
if (typeof vjsRefineResult !== 'undefined') {
vjsRefineResult.hotel_loading = hotel_loading
vjsRefineResult.visible = true
}
if (typeof vjsMinPrice !== 'undefined')
vjsMinPrice.min_arrangement = []
if (typeof vjsMinPrice2 !== 'undefined')
vjsMinPrice2.min_arrangement = []
if (typeof vjsEtiquette !== 'undefined') {
vjsEtiquette.etiquettes = []
vjsEtiquette.etiquettesEmplacement = []
vjsEtiquette.etiquettesSaison = []
}
var ajaxTime = new Date().getTime();
window.checkin = this.checkin_en
window.dispatchEvent(new Event("checkinUpdated")); // Émission de l'événement "checkinUpdated"
window.nuitees = this.nuitees
window.dispatchEvent(new Event("nuiteesUpdated")); // Émission de l'événement "nuiteesUpdated"
window.rooms = this.occupations
window.array_rooms = this.rooms
vjsListHotels.nbr_room = this.rooms.length
vjsListHotels.recap = {
ville: this.ville,
hotel: this.hotel,
checkin: this.checkin_fr,
checkout: this.checkout_fr,
destination: this.lbl_destination,
nuitees: this.nuitees,
nbrRoom: window.nbrRoom,
nbrAdult: window.nbrAdult,
nbrChild: window.nbrChild,
occupations: this.recap_occupations
}
if (typeof vjsRecapResult !== 'undefined')
vjsRecapResult.result = null
if (typeof vjsSortResult !== 'undefined')
vjsSortResult.destination = this.lbl_destination
if (typeof vjsRefineResult !== 'undefined') {
vjsRefineResult.checkin = this.checkin_fr
vjsRefineResult.checkout = this.checkout_fr
vjsRefineResult.destination = this.lbl_destination
vjsRefineResult.occupations = this.recap_occupations
vjsRefineResult.nuitees = this.nuitees
vjsRefineResult.result = null
}
var BookingDetails = {
"CheckIn": this.checkin_en,
"CheckOut": this.checkout_en
}
if (this.destination.split('-')[0] == 'v')
BookingDetails['City'] = this.destination.split('-')[1]
else
BookingDetails['Hotel'] = this.destination.split('-')[1]
{% if app.request.get('_route') == 'sejour_hotel_availability_landing_page' %}
BookingDetails['Hotels'] = "{{ hotel_to_ids(app.request.get('hotel')) }}".split('-')
{% endif %}
{% if app.request.get('source','~') != '~' and app.request.get('city','~') != '~' %}
BookingDetails['XMLCity'] = '{{ app.request.get('city') }}'
{% endif %}
window.dispatchEvent(new Event("callRequestAvailHotel"));
// Store search parameters in cache for later use
window.lastHotelSearchParams = {
SearchDetails: {
BookingDetails: BookingDetails,
Rooms: this.rooms,
GroupingHotel: true,
Product: "{{ app.request.get('product','hotel') }}",
{% if app.request.get('_route') == 'front_evenement_details' %}
Event: true,
{% endif %}
{% if route_avail_hotel == 'sejour_hotel_availability' and hotelSearchOnlyDetails|default('false') == 'true' %}
OnlyHotelDetails: true,
{% endif %}
CombinationRooms: {{ resultView in ['pension-combin-room','combin-room-pension'] ? 'true' : 'false' }},
BoardingByRooms: {{ resultView in ['room-pension','combin-room-pension'] ? 'true' : 'false' }},
Filters: {
Source: "{{ app.request.get('source','all')=='~'?'all':app.request.get('source','all') }}"
}
}
};
axios
.get('{{ path('sejour_hotel_ajax_availability') }}',
{
params: {
HotelSearch: utf8_to_b64(JSON.stringify(window.lastHotelSearchParams))
}
})
.then(response => {
vjsListHotels.hotel_loading = 0
if (typeof vjsSearchNomsHotels !== 'undefined') {
vjsSearchNomsHotels.hotel_loading = 0
vjsSearchNomsHotels.filtre_noms.length = 0
}
if (typeof vjsSortResult !== 'undefined') {
vjsSortResult.hotel_loading = 0
vjsSortResult.trie = '{{ configAffichage.HOTEL.TRI_RESULTAT }}'
}
if (typeof vjsRecapSearch !== 'undefined')
vjsRecapSearch.hotel_loading = 0
if (typeof vjsRefineResult !== 'undefined') {
vjsRefineResult.hotel_loading = 0
vjsRefineResult.filtre_etoiles.length = 0
vjsRefineResult.filtre_arrangements.length = 0
vjsRefineResult.filtre_zones.length = 0
vjsRefineResult.filtre_tags.length = 0
vjsRefineResult.filtre_chambres.length = 0
vjsRefineResult.collect_chambre = 1
}
if (response.data.Erreur !== undefined)
viewAlert(response.data.Erreur, 'danger')
else if (response.data.Error !== undefined) {
viewAlert('Erreur', 'danger')
console.error(response.data.Error)
} else {
this.fetchAllHotelsPaginated(response.data)
var hotels = response.data.HotelSearch
var filtres = response.data.DataFiltre
var duration = response.data.Timing.Duration
if (typeof response.data.AutreInfos !== 'undefined') {
let advancedSearchInstance = this
if (typeof window !== 'undefined' && window['{{ 'vjsAdvancedSearch' ~ produit }}'] !== undefined) {
advancedSearchInstance = window['{{ 'vjsAdvancedSearch' ~ produit }}']
}
const destinationValue = (advancedSearchInstance.destination || '').toString()
const destinationParts = destinationValue.split('-')
const isVilleSelection = destinationValue.startsWith('v-') && destinationParts[1] && destinationParts[1] !== 'tous'
const isDetailsRoute = {{ app.request.get('_route') in ['details_hotel', 'details_hotel_custom', 'details_appartement', 'details_appartement_custom'] ? 'true' : 'false' }}
const descriptionVille = response.data.AutreInfos.Description
const hasDescriptionVille = isVilleSelection && (
(typeof descriptionVille === 'string' && descriptionVille.trim() !== '') ||
(typeof descriptionVille !== 'string' && descriptionVille)
)
if (hasDescriptionVille) {
$('#description-ville').html(descriptionVille)
$('#read-more-desc-ville').show()
} else {
$('#description-ville').html('')
$('#read-more-desc-ville').hide()
}
const hasFAQ = Array.isArray(response.data.AutreInfos.FAQ) && response.data.AutreInfos.FAQ.length > 0
const shouldShowFAQ = hasFAQ && (isVilleSelection || isDetailsRoute)
if (shouldShowFAQ) {
let lignesFAQ = response.data.AutreInfos.FAQ.map((item, i) => `{{ macro('sejour-hotel.availability').ligneFAQ() }}`).join('')
$('#faq').html(`{{ macro('sejour-hotel.availability').templateFAQ() }}`)
} else {
$('#faq').html('')
}
}
vjsListHotels.hotels = hotels;
if (typeof vjsRefineResult !== 'undefined') {
vjsRefineResult.visible = (hotels.length > 0)
if (hotels.length > 0) {
vjsRefineResult.min_prix = parseInt(filtres.minPrix);
vjsRefineResult.max_prix = parseInt(filtres.maxPrix) + 1;
vjsRefineResult.filre_prix = [vjsRefineResult.min_prix, vjsRefineResult.max_prix]
vjsRefineResult.nbr_enfant_gratuit = filtres.enfantGratuit;
vjsRefineResult.nbr_promo = filtres.promo;
vjsRefineResult.nbr_recommander = filtres.recommander;
vjsRefineResult.nbr_rembourssable = filtres.rembourssable;
vjsRefineResult.nbr_disponible = filtres.disponible;
vjsRefineResult.liste_tags = filtres.tags;
vjsRefineResult.liste_etoiles = filtres.etoiles;
vjsRefineResult.liste_arrangements = filtres.arrangements;
vjsRefineResult.liste_zones = filtres.zones;
vjsRefineResult.liste_chambres = Object.entries(filtres.chambres);
{% if app.request.get('export-rooms') %}
var encodedUri = encodeURI("data:text/csv;charset=utf-8," + vjsRefineResult.liste_chambres.map(x => x[0]).toString().replaceAll(',', "\n"));
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "list-rooms.csv");
document.body.appendChild(link);
link.click();
{% endif %}
}
}
if (typeof vjsMinPrice !== 'undefined')
if (hotels.length > 0) {
vjsMinPrice.min_arrangement = hotels[0].min_arrangement
vjsMinPrice.Recap = `${this._recap_occupations} du ${this.checkin_fr} au ${this.checkout_fr}`
} else
vjsMinPrice.min_arrangement = null
if (typeof vjsMinPrice2 !== 'undefined')
if (hotels.length > 0) {
vjsMinPrice2.min_arrangement = hotels[0].min_arrangement
vjsMinPrice2.Recap = `${this._recap_occupations} du ${this.checkin_fr} au ${this.checkout_fr}`
} else
vjsMinPrice2.min_arrangement = null
if (typeof vjsEtiquette !== 'undefined' && hotels.length > 0) {
vjsEtiquette.etiquettes = hotels[0].etiquettes
vjsEtiquette.etiquettesEmplacement = hotels[0].etiquettesEmplacement
vjsEtiquette.etiquettesSaison = hotels[0].etiquettesSaison
}
if (typeof vjsSearchNomsHotels !== 'undefined') {
vjsSearchNomsHotels.liste_noms = Object.values(filtres.noms);
vjsSearchNomsHotels.visible = (hotels.length > 0)
}
if (typeof vjsSortResult !== 'undefined') {
vjsSortResult.recapSearch = {% if app.request.get('product') =="appartement" %} {{ macro('sejour-hotel.availability').recapSearchAppartement() }} {% else %} {{ macro('sejour-hotel.availability').recapSearch() }} {% endif %};
vjsSortResult.visible = (hotels.length > 0)
}
if (typeof vjsRecapSearch !== 'undefined')
vjsRecapSearch.recapSearch = {% if app.request.get('product') =="appartement" %} {{ macro('sejour-hotel.availability').recapSearchAppartement() }} {% else %} {{ macro('sejour-hotel.availability').recapSearch() }} {% endif %};
var totalTime = new Date().getTime() - ajaxTime;
console.log(`first timing ${duration} second timing ${totalTime}`)
window.dispatchEvent(new Event("getResponseAvailHotel")); // Émission de l'événement "getResponseAvailHotel"
{% if configAffichage.HOTEL.DISPLAY_PRICE_HALF_DOUBLE == 'oui' and app.request.get('_route') == route_avail_hotel %}
globalState.minPrix2Loading = true;
axios
.get('{{ path('sejour_hotel_ajax_availability') }}',
{
params: {
HotelSearch: utf8_to_b64(JSON.stringify({
SearchDetails: {
BookingDetails: BookingDetails,
Rooms: [{Adult: 2}],
GroupingHotel: true,
Product: "{{ app.request.get('product','hotel') }}",
CombinationRooms: {{ resultView in ['pension-combin-room','combin-room-pension'] ? 'true' : 'false' }},
BoardingByRooms: {{ resultView in ['room-pension','combin-room-pension'] ? 'true' : 'false' }},
Filters: {
Source: "{{ app.request.get('source','all')=='~'?'all':app.request.get('source','all') }}"
}
}
}))
}
})
.then(response => {
globalState.minPrix2Loading = false;
if (response.data.Error !== undefined) {
viewAlert('{{ "Erreur"|trans }}', 'danger')
console.error(response.data.Error)
} else if (vjsListHotels.hotels !== undefined) {
response.data.HotelSearch.map(h => {
var i = vjsListHotels.hotels.findIndex(htl => h.Hotel.IdLocal !== undefined ? htl.Hotel.IdLocal == h.Hotel.IdLocal : htl.Hotel.Id == h.Hotel.Id)
if (i >= 0) {
this.$set(vjsListHotels.hotels[i], 'min_arrangement2', h.min_arrangement);
}
})
}
}
);
{% endif %}
}
}
);
{% endif %}
},
Recap() {
let nbrR = this.rooms.length,
nbrA = 0,
nbrC = 0;
let rooms = []
this.rooms.map(x => {
nbrA += parseInt(x['Adult']);
nbrC += parseInt(x['children']);
rooms.push(([x['Adult']].concat(x['Child'])).join(','))
});
let text = {{ macro('sejour-hotel.availability').recapOccupation(app.request.get('_route')) }};
let textApprtement = {{ macro('sejour-hotel.availability').recapOccupationAppartement(app.request.get('_route')) }};
let _textAppartement = (nbrA == 1 ? '{{ "un"|trans }}' : nbrA) + ' {{ "adulte"|trans }}' + (nbrA > 1 ? '{{ "s"|trans }}' : '')
let _text = (nbrA == 1 ? '{{ "un"|trans }}' : nbrA) + ' {{ "adulte"|trans }}' + (nbrA > 1 ? '{{ "s"|trans }}' : '')
if (nbrC > 0)
_text += ' et ' + (nbrC == 1 ? '{{ "un"|trans }}' : nbrC) + ' {{ "enfant"|trans }}' + (nbrC > 1 ? '{{ "s"|trans }}' : '')
$('[data-target="#occupations{{ produit }}"]').val(text);
$('[data-target="#occupationsAppartement{{ produit }}"]').val(textApprtement);
$('.rooms-descSHT').html(text);
this.occupations = rooms.join(';')
{% if app.request.get('product') == "appartement" %}
this.recap_occupations = textApprtement
this._recap_occupations = _textAppartement
{% else %}
this.recap_occupations = text
this._recap_occupations = _text
{% endif %}
window.nbrRoom = nbrR
window.nbrAdult = nbrA
window.nbrChild = nbrC
{% if app.request.get('_route') not in ['front_evenement_details'] %}
if (typeof $('#occupations{{ produit }}').modal === "function")
$('#occupations{{ produit }}').modal('hide')
{% endif %}
},
editChildren(index) {
let old_child = this.rooms[index]['Child'].length;
let new_child = this.rooms[index]['children'];
if (old_child > new_child)
this.rooms[index]['Child'].length = new_child;
else
do
this.rooms[index]['Child'].push({{ configAffichage.HOTEL.MIN_AGE_ENFANT }})
while (this.rooms[index]['Child'].length < new_child);
},
removeRoom(index) {
this.rooms.splice(index, 1);
},
addRoom() {
this.rooms.push({
Adult: 2,
children: 0,
Child: []
})
},
fetchAllHotelsPaginated(response) {
vjsListHotels.totalHotels = response.CountResults;
vjsListHotels.loadedHotels = response.HotelSearch.length;
vjsListHotels.progressHotels = Math.round((vjsListHotels.loadedHotels / vjsListHotels.totalHotels) * 100);
let offset = vjsListHotels.loadedHotels;
let limit = vjsListHotels.loadedHotels;
function fetchNextBatch() {
if (vjsListHotels.loadedHotels >= vjsListHotels.totalHotels) return;
axios.get("{{ path('sejour_hotel_ajax_availability') }}", {
params: {
HotelSearch: utf8_to_b64(JSON.stringify({
offset: offset,
limit: limit,
search_id: response.SearchId
}))
}
}).then(function (res) {
if (res.data && res.data.HotelSearch) {
// Ajouter les nouveaux hôtels à la liste
vjsListHotels.hotels = vjsListHotels.hotels.concat(res.data.HotelSearch);
vjsListHotels.loadedHotels += res.data.HotelSearch.length;
offset += res.data.HotelSearch.length;
vjsListHotels.progressHotels = Math.round((vjsListHotels.loadedHotels / vjsListHotels.totalHotels) * 100);
// Appel récursif si pas fini
if (vjsListHotels.loadedHotels < vjsListHotels.totalHotels) {
fetchNextBatch();
}
}
});
}
// Démarrer la récupération si besoin
if (vjsListHotels.loadedHotels < vjsListHotels.totalHotels) {
fetchNextBatch();
}
},
},
mounted() {
window.checkin_en = this.checkin_en
window.checkout_en = this.checkout_en
$('.typeahead_destination{{ produit }}').val(this.lbl_destination)
$('.typeahead.destination{{ produit }}').val(this.lbl_destination)
$('#nuitees{{ produit }}').val(this.nuitees)
this.Recap()
if (typeof $(this.$refs.select).selectpicker === "function") {
$(this.$refs.select).selectpicker('refresh')
$('.btn-group.bootstrap-select button').attr('title', '')
}
},
updated() {
if (typeof $(this.$refs.select).selectpicker === "function") {
$(this.$refs.select).selectpicker('refresh')
$('.btn-group.bootstrap-select button').attr('title', '')
}
},
destroyed() {
if (typeof $(this.$refs.select).selectpicker === "function")
$(this.$refs.select).off().selectpicker('destroy')
}
})
var date = new Date();
var currentMonth = date.getMonth();
var currentDate = date.getDate();
var currentYear = date.getFullYear();
$('input[name="daterange{{ produit }}"]').daterangepicker({
opens: 'left',
startDate: vjsAdvancedSearch{{ produit }}.checkin_fr,
endDate: vjsAdvancedSearch{{ produit }}.checkout_fr,
locale: {
format: "DD/MM/YYYY",
cancelLabel: '{{ "Effacer"|trans }}',
applyLabel: '{{ "Valider"|trans }}',
"firstDay": 1,
},
minDate: new Date(currentYear, currentMonth, currentDate),
beforeShowDay: function (d) {
var dmy = (d.getMonth() + 1);
if (d.getMonth() < 9)
dmy = "0" + dmy;
if ($.inArray(dmy, availableDates) != -1) {
return [true, "", "Available"];
} else {
return [false, "", "unAvailable"];
}
}
},
function (start, end, label) {
vjsAdvancedSearch{{ produit }}.checkin_en = start.format('YYYY-MM-DD')
vjsAdvancedSearch{{ produit }}.checkout_en = end.format('YYYY-MM-DD')
window.checkin_en = start.format('YYYY-MM-DD')
window.checkout_en = end.format('YYYY-MM-DD')
vjsAdvancedSearch{{ produit }}.checkin_fr = start.format('DD/MM/YYYY')
vjsAdvancedSearch{{ produit }}.checkout_fr = end.format('DD/MM/YYYY')
let nuitees = (new Date(window.checkout_en) - new Date(window.checkin_en)) / 86400000;
vjsAdvancedSearch{{ produit }}.nuitees = nuitees
$('#nuitees{{ produit }}').val(nuitees)
});
$('#nuitees{{ produit }}').change(function () {
vjsAdvancedSearch{{ produit }}.nuitees = parseInt($(this).val())
let checkin = new Date(vjsAdvancedSearch{{ produit }}.checkin_en)
let checkout = checkin.addDays(parseInt($(this).val()))
$('input[name="daterange{{ produit }}"]').data('daterangepicker').setEndDate(checkout)
vjsAdvancedSearch{{ produit }}.checkout_en = checkout.toISOString().slice(0, 10)
window.checkout_en = checkout.toISOString().slice(0, 10)
vjsAdvancedSearch{{ produit }}.checkout_fr = checkout.toISOString().slice(0, 10).split('-').reverse().join('/')
})
{% if configAffichage.HOTEL["MODELE_SELECT_VILLE_HOTEL#{is_mobile() ? '_MOBILE' : ''}"] == 'jsuites' %}
var jSuites = jSuites.dropdown(document.getElementById('dropdown{{ produit }}'), {
data:{{ villes_hotels|json_encode|raw }},
/* width: '280px',*/
placeholder: 'Ville ou Hôtel',
autocomplete: true,
onopen: function () {
$('div.jdropdown-content').animate({
scrollTop: 0
}, 100);
},
onchange: function (el, val) {
if (val.currentIndex === undefined)
return
var item = val.items[val.currentIndex].data
vjsAdvancedSearch{{ produit }}.pays = item.pays
vjsAdvancedSearch{{ produit }}.ville = item.ville
vjsAdvancedSearch{{ produit }}.hotel = (item.hotel === undefined ? 'tous' : item.hotel)
vjsAdvancedSearch{{ produit }}.destination = item.value
vjsAdvancedSearch{{ produit }}.lbl_destination = item.text
}
});
{% if selected_destination %}
jSuites.setValue('{{ selected_destination.type }}-{{ selected_destination.id }}')
{% endif %}
{% elseif configAffichage.HOTEL["MODELE_SELECT_VILLE_HOTEL#{is_mobile() ? '_MOBILE' : ''}"] == 'typeahead' %}
{% if is_mobile() %}
var $input = $("input.typeahead.destination{{ produit }}");
window.query_cache = {};
$input.typeahead({
maxItem: 30,
accent: true,
{% if produit == 'SHE' or enabled_hotel_stay_worldwide == 'true' %}
source: function (query, process) {
if (query_cache[query]) { // if in cache use cached value, if don't wanto use cache remove this if statement
process(query_cache[query]);
return;
}
if (typeof searching != "undefined") {
clearTimeout(searching);
process([]);
}
searching = setTimeout(function () {
$.ajax({
url: "{{ path('source_typeahead_ville_hotel') }}",
data: {Keywords: query, onlySearchCity: {{ onlySearchCity ? 1 : 0 }} },
dataType: "json",
beforeSend: function () {
$input.parent().removeClass('input-marker').addClass('input-spinner');
},
success: function (data) {
query_cache[query] = data; // save result to cache, remove next line if you don't want to use cache
process(data);
},
complete: function () {
$input.parent().addClass('input-marker').removeClass('input-spinner');
}
});
}, 300); // 300 ms only search if stop typing for 300ms aka fast typers
},
highlight: true,
minLength: 1,
hint: true,
{% else %}
source: {{ villes_hotels|json_encode|raw }},
{% endif %}
autoSelect: true,
displayText: function (item) {
return item.name
},
//highlighter: Object,
afterSelect: function (item) {
$input.val(item.name).change();
vjsAdvancedSearch{{ produit }}.pays = item.pays
vjsAdvancedSearch{{ produit }}.ville = item.ville
vjsAdvancedSearch{{ produit }}.hotel = (item.hotel === undefined ? 'tous' : item.hotel)
vjsAdvancedSearch{{ produit }}.destination = `${item.type}-${item.id}`
vjsAdvancedSearch{{ produit }}.lbl_destination = item.name
}
});
{% endif %}
window.query_cache = {};
//http://www.runningcoder.org/jquerytypeahead/demo
$.typeahead({
input: '.typeahead_destination{{ produit }}',
minLength: 1,
maxItem: 30,
hint: true,
accent: true,
dynamic: true,
loadingAnimation: false,
cancelButton: false,
delay: 500,
// backdrop: {"background-color": "#fff"},
template: function (query, item) {
var fa = (item.type == 'v' ? 'map-marker-alt' : 'hotel')
return `
<div class="suggestion-content">
<span class="icon-hotel"><i class="fa fa-${fa}"></i></span>
<div class="hotel-info">
<strong>${item.name}</strong> <span>${item.destination}</span>
</div>
</div> `;
},
emptyTemplate: "<span color='red'>Aucun résultat pour la chaîne saisie <b>'{{ '{{query}}' }}'</b></span>",
source: {
ville: {
display: "name",
{% if produit == 'SHE' or enabled_hotel_stay_worldwide == 'true' %}
ajax: function (query) {
// if (query_cache[query]) // if in cache use cached value, if don't wanto use cache remove this if statement
// return query_cache[query];
return {
type: "GET",
url: "{{ path('source_typeahead_ville_hotel') }}",
path: "data",
data: {
Keywords: "{{ '{{query}}' }}",
maxItem: 30,
onlySearchCity: 1
},
callback: {
done: function (data) {
data.data = data
// query_cache[query] = data; // save result to cache, remove next line if you don't want to use cache
return data;
}
}
}
}
{% else %}
data:{{ villes_hotels|json_encode|raw }}
{% endif %}
}
},
callback: {
onClickAfter: function (node, a, item, event) {
jQuery(node).val(item.name);
vjsAdvancedSearch{{ produit }}.pays = item.pays
vjsAdvancedSearch{{ produit }}.ville = item.ville
vjsAdvancedSearch{{ produit }}.hotel = (item.hotel === undefined ? 'tous' : item.hotel)
vjsAdvancedSearch{{ produit }}.destination = `${item.type}-${item.id}`
vjsAdvancedSearch{{ produit }}.lbl_destination = item.name
},
onSendRequest: function (node, query) {
jQuery(node).parent().removeClass('input-marker').addClass('input-spinner');
},
onReceiveRequest: function (node, query) {
jQuery(node).parent().addClass('input-marker').removeClass('input-spinner');
}
},
debug: true
});
{% endif %}
$(window).scroll(function () {
if ($(window).scrollTop() >= 300) {
$('#navbar').addClass('stikynavbar');
} else {
$('#navbar').removeClass('stikynavbar');
}
});
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('.advance-search-header').addClass('sticky-advanced-search')
} else {
$('.advance-search-header').removeClass('sticky-advanced-search')
}
});
</script>