3 month limit setup

This commit is contained in:
2025-10-04 13:52:17 +02:00
parent 64d5a8fbf3
commit 45c192058a
2 changed files with 24 additions and 0 deletions
+14
View File
@@ -404,6 +404,20 @@ class Pages extends CI_Controller {
return; return;
} }
$today = new DateTime();
$maxDate = (clone $today)->modify('+3 months');
$selectedDate = new DateTime($bookingArray['booking_date']);
if ($selectedDate > $maxDate) {
$this->output
->set_status_header(403)
->set_content_type('application/json')
->set_output(json_encode([
'error' => 'Bookings can only be made up to 3 months in advance.'
]));
return;
}
// 6. Create booking // 6. Create booking
$this->Service_model->createBooking($bookingArray); $this->Service_model->createBooking($bookingArray);
+10
View File
@@ -406,9 +406,19 @@ class Service_model extends CI_Model {
public function getAvailableTimes($worker_id, $selectedDate, $servicelength) { public function getAvailableTimes($worker_id, $selectedDate, $servicelength) {
$this->load->database(); $this->load->database();
if (strtotime($selectedDate) < strtotime(date('Y-m-d'))) { if (strtotime($selectedDate) < strtotime(date('Y-m-d'))) {
return []; return [];
} }
$today = new DateTime();
$maxDate = (clone $today)->modify('+3 months');
$selected = new DateTime($selectedDate);
if ($selected > $maxDate) {
return [];
}
$ts = strtotime($selectedDate); $ts = strtotime($selectedDate);
$debugDate = date('Y-m-d (w)', $ts) . ' - ' . date('l', $ts); $debugDate = date('Y-m-d (w)', $ts) . ' - ' . date('l', $ts);
log_message('error', "📅 DEBUG DATE CHECK for '{$selectedDate}': {$debugDate}"); log_message('error', "📅 DEBUG DATE CHECK for '{$selectedDate}': {$debugDate}");