3 month limit setup
This commit is contained in:
@@ -403,6 +403,20 @@ class Pages extends CI_Controller {
|
||||
]));
|
||||
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
|
||||
$this->Service_model->createBooking($bookingArray);
|
||||
|
||||
@@ -406,9 +406,19 @@ class Service_model extends CI_Model {
|
||||
|
||||
public function getAvailableTimes($worker_id, $selectedDate, $servicelength) {
|
||||
$this->load->database();
|
||||
|
||||
if (strtotime($selectedDate) < strtotime(date('Y-m-d'))) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$today = new DateTime();
|
||||
$maxDate = (clone $today)->modify('+3 months');
|
||||
$selected = new DateTime($selectedDate);
|
||||
|
||||
if ($selected > $maxDate) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$ts = strtotime($selectedDate);
|
||||
$debugDate = date('Y-m-d (w)', $ts) . ' - ' . date('l', $ts);
|
||||
log_message('error', "📅 DEBUG DATE CHECK for '{$selectedDate}': {$debugDate}");
|
||||
|
||||
Reference in New Issue
Block a user