Apply the future booking limit to the booking page

This commit is contained in:
Alex Tselegidis 2023-02-13 09:36:08 +01:00
parent 7f534e51c7
commit c8bfb623e2
2 changed files with 6 additions and 2 deletions

View file

@ -133,6 +133,7 @@ class Booking extends EA_Controller {
$display_login_button = setting('display_login_button'); $display_login_button = setting('display_login_button');
$display_delete_personal_information = setting('display_delete_personal_information'); $display_delete_personal_information = setting('display_delete_personal_information');
$book_advance_timeout = setting('book_advance_timeout'); $book_advance_timeout = setting('book_advance_timeout');
$future_booking_limit = setting('future_booking_limit');
$theme = request('theme', setting('theme', 'default')); $theme = request('theme', setting('theme', 'default'));
if (empty($theme) || ! file_exists(__DIR__ . '/../../assets/css/themes/' . $theme . '.min.css')) if (empty($theme) || ! file_exists(__DIR__ . '/../../assets/css/themes/' . $theme . '.min.css'))
@ -225,6 +226,7 @@ class Booking extends EA_Controller {
'first_weekday' => $first_weekday, 'first_weekday' => $first_weekday,
'display_cookie_notice' => $display_cookie_notice, 'display_cookie_notice' => $display_cookie_notice,
'display_any_provider' => setting('display_any_provider'), 'display_any_provider' => setting('display_any_provider'),
'future_booking_limit' => setting('future_booking_limit'),
'appointment_data' => $appointment, 'appointment_data' => $appointment,
'provider_data' => $provider, 'provider_data' => $provider,
'customer_data' => $customer, 'customer_data' => $customer,

View file

@ -82,12 +82,14 @@ App.Pages.Booking = (function () {
App.Utils.UI.initializeDatepicker($selectDate, { App.Utils.UI.initializeDatepicker($selectDate, {
inline: true, inline: true,
minDate: new Date(),
maxDate: moment().add(vars('future_booking_limit'), 'days').toDate(),
onChange: (selectedDates) => { onChange: (selectedDates) => {
App.Http.Booking.getAvailableHours(moment(selectedDates[0]).format('YYYY-MM-DD')); App.Http.Booking.getAvailableHours(moment(selectedDates[0]).format('YYYY-MM-DD'));
updateConfirmFrame(); updateConfirmFrame();
}, },
onMonthChange: () => { onMonthChange: (selectedDates, dateStr, instance) => {
setTimeout(() => { setTimeout(() => {
const displayedMonthMoment = moment(instance.currentYearElement.value + '-' + (Number(instance.monthsDropdownContainer.value) + 1) + '-01'); const displayedMonthMoment = moment(instance.currentYearElement.value + '-' + (Number(instance.monthsDropdownContainer.value) + 1) + '-01');
@ -99,7 +101,7 @@ App.Pages.Booking = (function () {
}, 500); }, 500);
}, },
onYearChange: () => { onYearChange: (selectedDates, dateStr, instance) => {
setTimeout(() => { setTimeout(() => {
const displayedMonthMoment = moment(instance.currentYearElement.value + '-' + (Number(instance.monthsDropdownContainer.value) + 1) + '-01'); const displayedMonthMoment = moment(instance.currentYearElement.value + '-' + (Number(instance.monthsDropdownContainer.value) + 1) + '-01');