41 lines
909 B
PHP
41 lines
909 B
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 renameArray($data){
|
||
|
computeEndTime($data);
|
||
|
$events = array();
|
||
|
foreach($data as $row){
|
||
|
$events[] = array(
|
||
|
"id" => $row["id"],
|
||
|
"title" => "Cita de " . $row["apellido"],
|
||
|
"start" => $row["fecha"] . " " . $row["hora"],
|
||
|
"end" => $row["fecha"] . " " . $row["end"],
|
||
|
);
|
||
|
}
|
||
|
return $events;
|
||
|
}
|
||
|
|
||
|
function fetchDatabase(){
|
||
|
$pdo = connectDatabase();
|
||
|
$data = listEvents($pdo);
|
||
|
closeDatabase($pdo);
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
|
||
|
$result = fetchDatabase();
|
||
|
$events = renameArray($result);
|
||
|
echo json_encode($events);
|
||
|
|
||
|
?>
|