140 lines
No EOL
4.7 KiB
JavaScript
140 lines
No EOL
4.7 KiB
JavaScript
$(document).ready(function() {
|
|
|
|
var frm$ = $('.st-booking-form');
|
|
var summary$ = $('.st-booking-summary');
|
|
|
|
var toDateDay$ = $('#fewo_booking_request_toDate_day');
|
|
var toDateMonth$ = $('#fewo_booking_request_toDate_month');
|
|
var toDateYear$ = $('#fewo_booking_request_toDate_year');
|
|
|
|
function loadCalculationFewo(){
|
|
var tmp = location.href.split('?');
|
|
var tmp2 = tmp[0].split('/');
|
|
tmp2.pop();
|
|
var url = tmp2.join('/') + '/berechne-gesamtpreis';
|
|
if (tmp[1])
|
|
{
|
|
url += '?'+ tmp[1];
|
|
}
|
|
$.ajax({
|
|
url: url,
|
|
type: 'post',
|
|
data: frm$.serialize()
|
|
|
|
}).then(function(r) {
|
|
summary$.html(r);
|
|
|
|
}, function() {
|
|
summary$.html('Aufgrund eines Fehlers konnte kein Angebot ermittelt werden.');
|
|
});
|
|
}
|
|
frm$.find('input, select').change(function() {
|
|
loadCalculationFewo();
|
|
});
|
|
|
|
// var currentDate = moment().format("DD.MM.YYYY");
|
|
|
|
var startDate = $('#fewo_booking_request_fromDate').val();
|
|
var endDate = $('#fewo_booking_request_toDate').val();
|
|
var maxDate = $('#hidden_toDate').val();
|
|
var reservationDays = JSON.parse($('#hidden_reservationDays').val());
|
|
var customDays = JSON.parse($('#hidden_customDays').val());
|
|
|
|
var checkDates = function (date) {
|
|
var formatted = date.format('DD.MM.YYYY');
|
|
if(reservationDays.indexOf(formatted) > -1){
|
|
return true;
|
|
}
|
|
if(customDays[formatted] !== undefined && customDays[formatted].indexOf('bookable') == -1 && customDays[formatted].indexOf('bookable-end') == -1){
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
var checkCustom = function (date) {
|
|
if (date !== false) {
|
|
var formatted = date.format('DD.MM.YYYY');
|
|
if(customDays[formatted] !== undefined){
|
|
return customDays[formatted];
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
$('#fewo_booking_request_datepicker').daterangepicker({
|
|
isInvalidDate: checkDates,
|
|
isCustomDate: checkCustom,
|
|
"minDate": moment(),
|
|
"maxDate": maxDate,
|
|
"timePickerSeconds": true,
|
|
"locale": {
|
|
"format": "DD.MM.YYYY",
|
|
"separator": " - ",
|
|
"applyLabel": "OK",
|
|
"cancelLabel": "X",
|
|
"fromLabel": "Von",
|
|
"toLabel": "Bis",
|
|
"customRangeLabel": "Custom",
|
|
"weekLabel": "W",
|
|
"daysOfWeek": [
|
|
"So",
|
|
"Mo",
|
|
"Di",
|
|
"Mi",
|
|
"Do",
|
|
"Fr",
|
|
"Sa"
|
|
],
|
|
"monthNames": [
|
|
"Januar",
|
|
"Februar",
|
|
"März",
|
|
"April",
|
|
"Mai",
|
|
"Juni",
|
|
"Juli",
|
|
"August",
|
|
"September",
|
|
"Oktober",
|
|
"November",
|
|
"Dezember"
|
|
],
|
|
"firstDay": 1
|
|
},
|
|
autoApply: true,
|
|
autoUpdateInput: true,
|
|
singleDatePicker: false,
|
|
alwaysShowCalendars: true,
|
|
"startDate": startDate,
|
|
"endDate": endDate,
|
|
allowInput: true,
|
|
}, function(start, end, label) {
|
|
|
|
// console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')');
|
|
// Lets update the fields manually this event fires on selection of range
|
|
var selectedStartDate = start.format('DD.MM.YYYY'); // selected start
|
|
var selectedEndDate = end.format('DD.MM.YYYY'); // selected end
|
|
|
|
var $checkinInput = $('#fewo_booking_request_fromDate');
|
|
var $checkoutInput = $('#fewo_booking_request_toDate');
|
|
|
|
// Updating Fields with selected dates
|
|
$checkinInput.val(selectedStartDate);
|
|
$checkoutInput.val(selectedEndDate);
|
|
|
|
/*
|
|
// Setting the Selection of dates on calender on CHECKOUT FIELD (To get this it must be binded by Ids not Calss)
|
|
var checkOutPicker = $checkoutInput.data('daterangepicker');
|
|
checkOutPicker.setStartDate(selectedStartDate);
|
|
checkOutPicker.setEndDate(selectedEndDate);
|
|
|
|
// Setting the Selection of dates on calender on CHECKIN FIELD (To get this it must be binded by Ids not Calss)
|
|
var checkInPicker = $checkinInput.data('daterangepicker');
|
|
checkInPicker.setStartDate(selectedStartDate);
|
|
checkInPicker.setEndDate(selectedEndDate);
|
|
*/
|
|
loadCalculationFewo();
|
|
|
|
});
|
|
|
|
}); |