diff --git a/src/appointment_feed.php b/src/appointment_feed.php index 7f6511c..649bf25 100644 --- a/src/appointment_feed.php +++ b/src/appointment_feed.php @@ -11,7 +11,7 @@ function computeEndTime(&$data){ } -function renameArray($data){ +function formatArray($data){ computeEndTime($data); $events = array(); foreach($data as $row){ @@ -36,7 +36,7 @@ function fetchDatabase(){ $result = fetchDatabase(); -$events = renameArray($result); +$events = formatArray($result); echo json_encode($events); ?> diff --git a/src/appointment_management.php b/src/appointment_management.php index f087865..33d3aa6 100644 --- a/src/appointment_management.php +++ b/src/appointment_management.php @@ -22,7 +22,7 @@ function listEvents($pdo){ function listHolidays($pdo){ $doctor = fetchDoctor($pdo); $holidays = fetchDoctorHolidays($pdo, $doctor); - return json_encode($holidays); + return $holidays; } diff --git a/src/calendar.js b/src/calendar.js index ab81a9a..57573f2 100644 --- a/src/calendar.js +++ b/src/calendar.js @@ -10,10 +10,12 @@ right: 'month,agendaWeek,agendaDay' }, - events: "appointment_feed.php" + queryString, + eventSources: [ + "appointment_feed.php" + queryString, + "holiday_feed.php" + queryString + ], selectable: true, - selectHelper: true, select: function(start, end) { diff --git a/src/database.php b/src/database.php index f5c17b3..7ce4320 100644 --- a/src/database.php +++ b/src/database.php @@ -395,7 +395,9 @@ function fetchCalendarSettings($pdo, $doctor) function fetchDoctorHolidays($pdo, $doctor) { - $query = "SELECT * FROM festivo WHERE medico IS NULL OR medico=?"; + $query = "SELECT festivo.id, fecha_festivo, tipo_festivo, medico, nombre FROM festivo + INNER JOIN usuario ON festivo.medico = usuario.id; + WHERE medico IS NULL OR medico=?"; $result = $pdo->prepare($query); $result->execute([$doctor]); $data = $result->fetchAll(PDO::FETCH_ASSOC); diff --git a/src/holiday_feed.php b/src/holiday_feed.php new file mode 100644 index 0000000..43cb7bf --- /dev/null +++ b/src/holiday_feed.php @@ -0,0 +1,34 @@ + $row["id"], + "title" => "Festivo", + "start" => $row["fecha_festivo"], + "description" => $row["tipo_festivo"], + "doctor" => $row["nombre"], + "groupId" => "holidays", + "rendering" => "background", + "color" => "#ffa6a3", + ); + } + return $events; +} + +function fetchDatabase(){ + $pdo = connectDatabase(); + $data = listHolidays($pdo); + closeDatabase($pdo); + return $data; +} + + +$result = fetchDatabase(); +$events = formatArray($result); +echo json_encode($events); + +?>