forked from mirrors/easyappointments
Rename unavailability dates to unavailable dates
This commit is contained in:
parent
15cf1cf2bf
commit
906c91331f
3 changed files with 32 additions and 32 deletions
|
@ -619,15 +619,15 @@ class Booking extends EA_Controller {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get Unavailability Dates
|
||||
* Get Unavailable Dates
|
||||
*
|
||||
* Get an array with the available dates of a specific provider, service and month of the year. Provide the
|
||||
* "provider_id", "service_id" and "selected_date" as GET parameters to the request. The "selected_date" parameter
|
||||
* must have the Y-m-d format.
|
||||
* must have the "Y-m-d" format.
|
||||
*
|
||||
* Outputs a JSON string with the unavailability dates. that are unavailability.
|
||||
*/
|
||||
public function get_unavailability_dates()
|
||||
public function get_unavailable_dates()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -638,7 +638,7 @@ class Booking extends EA_Controller {
|
|||
$selected_date_string = request('selected_date');
|
||||
$selected_date = new DateTime($selected_date_string);
|
||||
$number_of_days_in_month = (int)$selected_date->format('t');
|
||||
$unavailability_dates = [];
|
||||
$unavailable_dates = [];
|
||||
|
||||
$provider_ids = $provider_id === ANY_PROVIDER
|
||||
? $this->search_providers_by_service($service_id)
|
||||
|
@ -656,7 +656,7 @@ class Booking extends EA_Controller {
|
|||
if ($current_date < new DateTime(date('Y-m-d 00:00:00')))
|
||||
{
|
||||
// Past dates become immediately unavailability.
|
||||
$unavailability_dates[] = $current_date->format('Y-m-d');
|
||||
$unavailable_dates[] = $current_date->format('Y-m-d');
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -681,11 +681,11 @@ class Booking extends EA_Controller {
|
|||
// No availability amongst all the provider.
|
||||
if (empty($available_hours))
|
||||
{
|
||||
$unavailability_dates[] = $current_date->format('Y-m-d');
|
||||
$unavailable_dates[] = $current_date->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
json_response($unavailability_dates);
|
||||
json_response($unavailable_dates);
|
||||
}
|
||||
catch (Throwable $e)
|
||||
{
|
||||
|
|
|
@ -22,9 +22,9 @@ App.Http.Booking = (function () {
|
|||
const $availableHours = $('#available-hours');
|
||||
const $captchaHint = $('#captcha-hint');
|
||||
const $captchaTitle = $('.captcha-title');
|
||||
let unavailabilityDatesBackup;
|
||||
let unavailableDatesBackup;
|
||||
let selectedDateStringBackup;
|
||||
let processingUnavailabilities = false;
|
||||
let processingUnavailableDates = false;
|
||||
|
||||
/**
|
||||
* Get Available Hours
|
||||
|
@ -219,9 +219,9 @@ App.Http.Booking = (function () {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the unavailability dates of a provider.
|
||||
* Get the unavailable dates of a provider.
|
||||
*
|
||||
* This method will fetch the unavailability dates of the selected provider and service and then it will
|
||||
* This method will fetch the unavailable dates of the selected provider and service and then it will
|
||||
* select the first available date (if any). It uses the "FrontendBookApi.getAvailableHours" method to
|
||||
* fetch the appointment* hours of the selected date.
|
||||
*
|
||||
|
@ -229,8 +229,8 @@ App.Http.Booking = (function () {
|
|||
* @param {Number} serviceId The selected service ID.
|
||||
* @param {String} selectedDateString Y-m-d value of the selected date.
|
||||
*/
|
||||
function getUnavailabilityDates(providerId, serviceId, selectedDateString) {
|
||||
if (processingUnavailabilities) {
|
||||
function getUnavailableDates(providerId, serviceId, selectedDateString) {
|
||||
if (processingUnavailableDates) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ App.Http.Booking = (function () {
|
|||
|
||||
const appointmentId = App.Pages.Booking.manageMode ? vars('appointment_data').id : null;
|
||||
|
||||
const url = App.Utils.Url.siteUrl('booking/get_unavailability_dates');
|
||||
const url = App.Utils.Url.siteUrl('booking/get_unavailable_dates');
|
||||
|
||||
const data = {
|
||||
provider_id: providerId,
|
||||
|
@ -257,20 +257,20 @@ App.Http.Booking = (function () {
|
|||
data: data,
|
||||
dataType: 'json'
|
||||
}).done((response) => {
|
||||
unavailabilityDatesBackup = response;
|
||||
unavailableDatesBackup = response;
|
||||
selectedDateStringBackup = selectedDateString;
|
||||
applyUnavailabilityDates(response, selectedDateString, true);
|
||||
applyUnavailableDates(response, selectedDateString, true);
|
||||
});
|
||||
}
|
||||
|
||||
function applyPreviousUnavailabilityDates() {
|
||||
applyUnavailabilityDates(unavailabilityDatesBackup, selectedDateStringBackup);
|
||||
function applyPreviousUnavailableDates() {
|
||||
applyUnavailableDates(unavailableDatesBackup, selectedDateStringBackup);
|
||||
}
|
||||
|
||||
function applyUnavailabilityDates(unavailabilityDates, selectedDateString, setDate) {
|
||||
function applyUnavailableDates(unavailableDates, selectedDateString, setDate) {
|
||||
setDate = setDate || false;
|
||||
|
||||
processingUnavailabilities = true;
|
||||
processingUnavailableDates = true;
|
||||
|
||||
// Select first enabled date.
|
||||
const selectedDateMoment = moment(selectedDateString);
|
||||
|
@ -280,7 +280,7 @@ App.Http.Booking = (function () {
|
|||
if (setDate && !vars('manage_mode')) {
|
||||
for (let i = 1; i <= numberOfDays; i++) {
|
||||
const currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i);
|
||||
if (unavailabilityDates.indexOf(moment(currentDate).format('YYYY-MM-DD')) === -1) {
|
||||
if (unavailableDates.indexOf(moment(currentDate).format('YYYY-MM-DD')) === -1) {
|
||||
$('#select-date').datepicker('setDate', currentDate);
|
||||
getAvailableHours(moment(currentDate).format('YYYY-MM-DD'));
|
||||
break;
|
||||
|
@ -288,20 +288,20 @@ App.Http.Booking = (function () {
|
|||
}
|
||||
}
|
||||
|
||||
// If all the days are unavailability then hide the appointments hours.
|
||||
if (unavailabilityDates.length === numberOfDays) {
|
||||
// If all the days are unavailable then hide the appointments hours.
|
||||
if (unavailableDates.length === numberOfDays) {
|
||||
$availableHours.text(lang('no_available_hours'));
|
||||
}
|
||||
|
||||
// Grey out unavailability dates.
|
||||
// Grey out unavailable dates.
|
||||
$('#select-date .ui-datepicker-calendar td:not(.ui-datepicker-other-month)').each((index, td) => {
|
||||
selectedDateMoment.set({date: index + 1});
|
||||
if (unavailabilityDates.indexOf(selectedDateMoment.format('YYYY-MM-DD')) !== -1) {
|
||||
if (unavailableDates.indexOf(selectedDateMoment.format('YYYY-MM-DD')) !== -1) {
|
||||
$(td).addClass('ui-datepicker-unselectable ui-state-disabled');
|
||||
}
|
||||
});
|
||||
|
||||
processingUnavailabilities = false;
|
||||
processingUnavailableDates = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -325,8 +325,8 @@ App.Http.Booking = (function () {
|
|||
return {
|
||||
registerAppointment,
|
||||
getAvailableHours,
|
||||
getUnavailabilityDates,
|
||||
applyPreviousUnavailabilityDates,
|
||||
getUnavailableDates,
|
||||
applyPreviousUnavailableDates,
|
||||
deletePersonalInformation
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -142,7 +142,7 @@ App.Pages.Booking = (function () {
|
|||
onChangeMonthYear: (year, month) => {
|
||||
const currentDate = new Date(year, month - 1, 1);
|
||||
|
||||
App.Http.Booking.getUnavailabilityDates(
|
||||
App.Http.Booking.getUnavailableDates(
|
||||
$selectProvider.val(),
|
||||
$selectService.val(),
|
||||
moment(currentDate).format('YYYY-MM-DD')
|
||||
|
@ -269,7 +269,7 @@ App.Pages.Booking = (function () {
|
|||
$selectProvider.on('change', (event) => {
|
||||
const $target = $(event.target);
|
||||
|
||||
App.Http.Booking.getUnavailabilityDates(
|
||||
App.Http.Booking.getUnavailableDates(
|
||||
$target.val(),
|
||||
$selectService.val(),
|
||||
moment($selectDate.datepicker('getDate')).format('YYYY-MM-DD')
|
||||
|
@ -305,7 +305,7 @@ App.Pages.Booking = (function () {
|
|||
$selectProvider.prepend(new Option(lang('any_provider'), 'any-provider', true, true));
|
||||
}
|
||||
|
||||
App.Http.Booking.getUnavailabilityDates(
|
||||
App.Http.Booking.getUnavailableDates(
|
||||
$selectProvider.val(),
|
||||
$target.val(),
|
||||
moment($selectDate.datepicker('getDate')).format('YYYY-MM-DD')
|
||||
|
@ -513,7 +513,7 @@ App.Pages.Booking = (function () {
|
|||
|
||||
$selectDate.on('mousedown', '.ui-datepicker-calendar td', () => {
|
||||
setTimeout(() => {
|
||||
App.Http.Booking.applyPreviousUnavailabilityDates();
|
||||
App.Http.Booking.applyPreviousUnavailableDates();
|
||||
}, 300);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue