44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
include 'appointment_management.php';
|
|
|
|
function computeEndTime(&$data){
|
|
foreach($data as &$row){
|
|
$time = new DateTime($row["hora"]);
|
|
$time->modify("+{$row["duracion"]} minutes");
|
|
$time_string = $time->format('H:i:s');
|
|
$row += ["end" => $time_string];
|
|
}
|
|
}
|
|
|
|
|
|
function formatArray($data){
|
|
computeEndTime($data);
|
|
$events = array();
|
|
foreach($data as $row){
|
|
$events[] = array(
|
|
"id" => $row["id"],
|
|
"title" => $row["apellido"] . ", " . $row["nombre"],
|
|
"start" => $row["fecha"] . " " . $row["hora"],
|
|
"description" => $row["observaciones"],
|
|
"patient" => $row["documento_identificativo"],
|
|
"end" => $row["fecha"] . " " . $row["end"],
|
|
"overlap" => false,
|
|
);
|
|
}
|
|
return $events;
|
|
}
|
|
|
|
function fetchDatabase(){
|
|
$pdo = connectDatabase();
|
|
$data = listEvents($pdo);
|
|
closeDatabase($pdo);
|
|
return $data;
|
|
}
|
|
|
|
|
|
$result = fetchDatabase();
|
|
$events = formatArray($result);
|
|
echo json_encode($events);
|
|
|
|
?>
|