parent
14bbd793bf
commit
af296cf147
1 changed files with 13 additions and 12 deletions
|
@ -402,20 +402,21 @@ class Appointments extends CI_Controller {
|
||||||
// If the selected date is today, remove past hours. It is important include the timeout before
|
// 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
|
// 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.
|
// 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'))
|
$selected_date = $this->input->post('selected_date');
|
||||||
{
|
|
||||||
$book_advance_timeout = $this->settings_model->get_setting('book_advance_timeout');
|
$book_advance_timeout = $this->settings_model->get_setting('book_advance_timeout');
|
||||||
|
|
||||||
|
$threshold = new DateTime('+' . $book_advance_timeout . ' minutes');
|
||||||
|
|
||||||
foreach ($available_hours as $index => $value)
|
foreach ($available_hours as $index => $value)
|
||||||
{
|
{
|
||||||
$available_hour = strtotime($value);
|
$available_hour = new DateTime($selected_date . ' ' . $value);
|
||||||
$current_hour = strtotime('+' . $book_advance_timeout . ' minutes', strtotime('now'));
|
|
||||||
if ($available_hour <= $current_hour)
|
if ($available_hour->getTimestamp() <= $threshold->getTimestamp())
|
||||||
{
|
{
|
||||||
unset($available_hours[$index]);
|
unset($available_hours[$index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$available_hours = array_values($available_hours);
|
$available_hours = array_values($available_hours);
|
||||||
sort($available_hours, SORT_STRING);
|
sort($available_hours, SORT_STRING);
|
||||||
|
|
Loading…
Reference in a new issue