Correction in the Appointments check datetime availability method

This commit is contained in:
Alex Tselegidis 2020-11-12 14:46:51 +02:00
parent 423edc80c8
commit 0c20363b8b
2 changed files with 6 additions and 14 deletions

View file

@ -578,23 +578,15 @@ class Appointments extends CI_Controller {
$provider = $this->providers_model->get_row($appointment['id_users_provider']);
$available_periods = $this->availability->get_available_periods($date, $provider, $exclude_appointment_id);
$available_hours = $this->availability->get_available_hours($date, $service, $provider, $exclude_appointment_id);
$is_still_available = FALSE;
foreach ($available_periods as $available_period)
$appointment_hour = date('H:i', strtotime($appointment['start_datetime']));
foreach ($available_hours as $available_hour)
{
$appointment_start = new DateTime($appointment['start_datetime']);
$appointment_start = $appointment_start->format('H:i');
$appointment_end = new DateTime($appointment['start_datetime']);
$appointment_end->add(new DateInterval('PT' . $service['duration'] . 'M'));
$appointment_end = $appointment_end->format('H:i');
$available_period_start = date('H:i', strtotime($available_period['start']));
$available_period_end = date('H:i', strtotime($available_period['end']));
if ($available_period_start <= $appointment_start && $available_period_end >= $appointment_end)
if ($appointment_hour === $available_hour)
{
$is_still_available = TRUE;
break;

View file

@ -79,7 +79,7 @@ class Availability {
*
* @throws Exception
*/
public function get_available_periods(
protected function get_available_periods(
$date,
$provider,
$exclude_appointment_id = NULL