diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php index 3ecb3d9c..4ea828e7 100644 --- a/src/application/controllers/appointments.php +++ b/src/application/controllers/appointments.php @@ -354,7 +354,7 @@ class Appointments extends CI_Controller { $current_hour = $start_hour; $diff = $current_hour->diff($end_hour); - while (($diff->h * 60 + $diff->i) > intval($_POST['service_duration'])) { + while (($diff->h * 60 + $diff->i) >= intval($_POST['service_duration'])) { $available_hours[] = $current_hour->format('H:i'); $current_hour->add(new DateInterval("PT15M")); $diff = $current_hour->diff($end_hour); @@ -382,6 +382,8 @@ class Appointments extends CI_Controller { } } + $available_hours = array_values($available_hours); + sort($available_hours, SORT_STRING ); $available_hours = array_values($available_hours); echo json_encode($available_hours); @@ -537,7 +539,7 @@ class Appointments extends CI_Controller { // We will need to break this period and leave the available part. $period['start'] = $a_end; - } else if ($a_start >= $p_start && $a_end <= $p_start) { + } else if ($a_start >= $p_start && $a_end <= $p_end) { // The appointment is inside the time period, so we will split the period // into two new others. unset($available_periods_with_appointments[$index]);