Book advance timeout must span in multiple days (#365, #428).

This commit is contained in:
Alex Tselegidis 2020-03-09 21:15:03 +01:00
parent 14bbd793bf
commit af296cf147

View file

@ -402,18 +402,19 @@ class Appointments extends CI_Controller {
// If the selected date is today, remove past hours. It is important include the timeout before
// booking that is set in the back-office the system. Normally we might want the customer to book
// an appointment that is at least half or one hour from now. The setting is stored in minutes.
if (date('Y-m-d', strtotime($this->input->post('selected_date'))) === date('Y-m-d'))
{
$book_advance_timeout = $this->settings_model->get_setting('book_advance_timeout');
$selected_date = $this->input->post('selected_date');
foreach ($available_hours as $index => $value)
$book_advance_timeout = $this->settings_model->get_setting('book_advance_timeout');
$threshold = new DateTime('+' . $book_advance_timeout . ' minutes');
foreach ($available_hours as $index => $value)
{
$available_hour = new DateTime($selected_date . ' ' . $value);
if ($available_hour->getTimestamp() <= $threshold->getTimestamp())
{
$available_hour = strtotime($value);
$current_hour = strtotime('+' . $book_advance_timeout . ' minutes', strtotime('now'));
if ($available_hour <= $current_hour)
{
unset($available_hours[$index]);
}
unset($available_hours[$index]);
}
}