Corrected but with mutiple months navigation in booking wizard.

This commit is contained in:
alextselegidis 2016-10-10 16:45:19 +02:00
parent 1164dcd588
commit ea55bc54f5

View file

@ -24,6 +24,7 @@ window.FrontendBookApi = window.FrontendBookApi || {};
var unavailableDatesBackup; var unavailableDatesBackup;
var selectedDateStringBackup; var selectedDateStringBackup;
var processingUnavailabilities = false;
/** /**
* Get Available Hours * Get Available Hours
@ -200,6 +201,10 @@ window.FrontendBookApi = window.FrontendBookApi || {};
* @param {String} selectedDateString Y-m-d value of the selected date. * @param {String} selectedDateString Y-m-d value of the selected date.
*/ */
exports.getUnavailableDates = function(providerId, serviceId, selectedDateString) { exports.getUnavailableDates = function(providerId, serviceId, selectedDateString) {
if (processingUnavailabilities) {
return;
}
var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_unavailable_dates'; var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_unavailable_dates';
var data = { var data = {
provider_id: providerId, provider_id: providerId,
@ -229,6 +234,8 @@ window.FrontendBookApi = window.FrontendBookApi || {};
function _applyUnavailableDates(unavailableDates, selectedDateString, setDate) { function _applyUnavailableDates(unavailableDates, selectedDateString, setDate) {
setDate = setDate || false; setDate = setDate || false;
processingUnavailabilities = true;
// Select first enabled date. // Select first enabled date.
var selectedDate = Date.parse(selectedDateString); var selectedDate = Date.parse(selectedDateString);
var numberOfDays = new Date(selectedDate.getFullYear(), selectedDate.getMonth() + 1, 0).getDate(); var numberOfDays = new Date(selectedDate.getFullYear(), selectedDate.getMonth() + 1, 0).getDate();
@ -236,7 +243,7 @@ window.FrontendBookApi = window.FrontendBookApi || {};
if (setDate) { if (setDate) {
for (var i=1; i<=numberOfDays; i++) { for (var i=1; i<=numberOfDays; i++) {
var currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i); var currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i);
if ($.inArray(currentDate.toString('yyyy-MM-dd'), unavailableDates) === -1) { if (unavailableDates.indexOf(currentDate.toString('yyyy-MM-dd')) === -1) {
$('#select-date').datepicker('setDate', currentDate); $('#select-date').datepicker('setDate', currentDate);
FrontendBookApi.getAvailableHours(currentDate.toString('yyyy-MM-dd')); FrontendBookApi.getAvailableHours(currentDate.toString('yyyy-MM-dd'));
break; break;
@ -256,6 +263,8 @@ window.FrontendBookApi = window.FrontendBookApi || {};
$(td).addClass('ui-datepicker-unselectable ui-state-disabled'); $(td).addClass('ui-datepicker-unselectable ui-state-disabled');
} }
}); });
processingUnavailabilities = false;
} }
})(window.FrontendBookApi); })(window.FrontendBookApi);