Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/views/appointments/book.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ class="<?= $require_phone_number === '1' ? 'required' : '' ?> form-control"/>
<script src="<?= asset_url('assets/ext/datejs/date.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/moment/moment.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/moment/moment-timezone-with-data.min.js') ?>"></script>
<script src="<?= asset_url('assets/js/frontend_book_api.js') ?>"></script>
<script src="assets/js/frontend_book_api.js"></script>
<script src="<?= asset_url('assets/js/frontend_book.js') ?>"></script>

<script>
Expand Down
12 changes: 8 additions & 4 deletions assets/js/frontend_book_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ window.FrontendBookApi = window.FrontendBookApi || {};
};

function applyUnavailableDates(unavailableDates, selectedDateString, setDate) {
// Start ZTL Modification
// Start ZTL Modification
// Allows enforcement booking policy no more than 2 weeks in the future
const BOOKINGWINDOW = 14; // How many days in the future is booking open for students?
let bookingWindowTime = new Date.getTime() + (BOOKINGWINDOW * 24 * 60 * 60 * 1000);
let bookingWindowTime = new Date().getTime() + (BOOKINGWINDOW * 24 * 60 * 60 * 1000);
setDate = setDate || false;

processingUnavailabilities = true;
Expand All @@ -289,7 +289,6 @@ window.FrontendBookApi = window.FrontendBookApi || {};
for (var i = 1; i <= numberOfDays; i++) {
var currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i);
if ((unavailableDates.indexOf(currentDate.toString('yyyy-MM-dd')) === -1) && (currentDate.getTime() <= bookingWindowTime)) {
// End ZTL Modification
$('#select-date').datepicker('setDate', currentDate);
FrontendBookApi.getAvailableHours(currentDate.toString('yyyy-MM-dd'));
break;
Expand All @@ -305,9 +304,14 @@ window.FrontendBookApi = window.FrontendBookApi || {};
// Grey out unavailable dates.
$('#select-date .ui-datepicker-calendar td:not(.ui-datepicker-other-month)').each(function (index, td) {
selectedDate.set({day: index + 1});
if (unavailableDates.indexOf(selectedDate.toString('yyyy-MM-dd')) !== -1) {
if ((unavailableDates.indexOf(selectedDate.toString('yyyy-MM-dd')) !== -1) || (selectedDate.getTime() > bookingWindowTime)) {
$(td).addClass('ui-datepicker-unselectable ui-state-disabled');
}
var firstDaySelectedMonth = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), 1);
if(firstDaySelectedMonth.getTime() > bookingWindowTime) {
$('#available-hours').text(EALang.no_available_hours);
}
// End ZTL Modification
});

processingUnavailabilities = false;
Expand Down