Implement appointment fetch and insertion
This commit is contained in:
40
src/appointment_feed.php
Normal file
40
src/appointment_feed.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user