diff --git a/src/appointment.php b/src/appointment.php index 349ff1f..94124fa 100644 --- a/src/appointment.php +++ b/src/appointment.php @@ -23,6 +23,7 @@ $pdo = connectDatabase(); $patients = listPatients($pdo); $calendar_settings = fetchCalendarSettings($pdo, $doctor); + $time_ranges = computeTimeRanges($pdo); ?>
@@ -42,7 +43,12 @@
- +
@@ -53,12 +59,12 @@
- +
diff --git a/src/appointment_feed.php b/src/appointment_feed.php index 649bf25..e8aceb5 100644 --- a/src/appointment_feed.php +++ b/src/appointment_feed.php @@ -22,6 +22,7 @@ function formatArray($data){ "description" => $row["observaciones"], "patient" => $row["documento_identificativo"], "end" => $row["fecha"] . " " . $row["end"], + "overlap" => false, ); } return $events; diff --git a/src/appointment_management.php b/src/appointment_management.php index aa94551..d2656d1 100644 --- a/src/appointment_management.php +++ b/src/appointment_management.php @@ -60,6 +60,48 @@ function appointmentDeletion(){ } +function getFloorCeiling($pdo){ + $data = listCalendarSettings($pdo); + if($data["horario"] == "completo"){ + $start = $data["hora_inicio_mañana"]; + $end = $data["hora_fin_tarde"]; + } else if($data["horario"] == "mañana"){ + $start = $data["hora_inicio_mañana"]; + $end = $data["hora_fin_mañana"]; + } else { + $start = $data["hora_inicio_tarde"]; + $end = $data["hora_fin_tarde"]; + } + $range[] = array( + "start" => $start, + "end" => $end, + ); + return $range[0]; +} + + +function getTimeDiff(){ + $current = time(); + $addTime = strtotime("+30 mins", $current); + $diff = $addTime - $current; + return $diff; +} + + +function computeTimeRanges($pdo){ + $range = getFloorCeiling($pdo); + $diff = getTimeDiff(); + $start = strtotime($range["start"]); + $end = strtotime($range["end"]); + $time_range = array(); + while($start < $end){ + $time_range[] = date('G:i:s', $start); + $start += $diff; + } + return $time_range; +} + + if(isset($_POST["create"])){ appointmentCreation(); } diff --git a/src/calendar_management.php b/src/calendar_management.php index d109281..baef20f 100644 --- a/src/calendar_management.php +++ b/src/calendar_management.php @@ -30,15 +30,37 @@ function holidayDeletion() } -function calendarConfig() -{ - $data = $_POST; +function setWorkingHours(&$data){ + if(isset($data["hora_inicio_mañana"], $data["hora_fin_mañana"], $data["hora_inicio_tarde"], $data["hora_fin_tarde"])){ + $data["horario"] = "completo"; + } else if (isset($data["hora_inicio_mañana"], $data["hora_fin_mañana"])){ + $data["horario"] = "mañana"; + } else if (isset($data["hora_inicio_tarde"], $data["hora_fin_tarde"])){ + $data["horario"] = "tarde"; + } +} + + +function setUncheckedBoxes(&$data){ if (!isset($data["sabado_habil"])){ $data["sabado_habil"] = 0; } if (!isset($data["domingo_habil"])){ $data["domingo_habil"] = 0; } +} + + +function sanitizeInputs(&$data){ + setWorkingHours($data); + setUncheckedBoxes($data); +} + + +function calendarConfig() +{ + $data = $_POST; + sanitizeInputs($data); $pdo = connectDatabase(); configureCalendar($pdo, $data); closeDatabase($pdo); diff --git a/src/calendar_setup_form.php b/src/calendar_setup_form.php index 2d05172..8d64893 100644 --- a/src/calendar_setup_form.php +++ b/src/calendar_setup_form.php @@ -50,14 +50,6 @@ -
- - -