From f591cb5f2f54f54484783fee673c3ec3e8ea3a34 Mon Sep 17 00:00:00 2001 From: coolneng Date: Thu, 25 Jun 2020 20:01:41 +0200 Subject: [PATCH] Allow admins to select a doctor's appointments --- src/appointment.php | 31 ++++++++++++++++++++++++------- src/database.php | 8 ++++---- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/appointment.php b/src/appointment.php index e1324de..7347858 100644 --- a/src/appointment.php +++ b/src/appointment.php @@ -20,14 +20,31 @@ include 'database.php'; $pdo = connectDatabase(); - $events = fetchCalendarEvents($pdo); - if($_SESSION["user_type"] == 2){ - $user = finduser($pdo, $_SESSION["user"]); - } - $holidays = fetchDoctorHolidays($pdo, $user[0][4]); - $calendar_settings = fetchCalendarSettings($pdo, $user[0][4]); - closeDatabase($pdo); ?> + + $user = finduser($pdo, $_SESSION["user"]); + $events = fetchCalendarEvents($pdo, $user[0][4]); + $holidays = fetchDoctorHolidays($pdo, $user[0][4]); + $calendar_settings = fetchCalendarSettings($pdo, $user[0][4]); + +
+ +
+ + +
+ + +
diff --git a/src/database.php b/src/database.php index 95e9b7a..277913c 100644 --- a/src/database.php +++ b/src/database.php @@ -310,11 +310,11 @@ function configureCalendar($pdo, $data) } -function fetchCalendarEvents($pdo) +function fetchCalendarEvents($pdo, $doctor) { - $query = "SELECT * from cita"; + $query = "SELECT * from cita WHERE medico=?"; $result = $pdo->prepare($query); - $result->execute(); + $result->execute([$doctor]); $data = $result->fetchAll(); return $data; } @@ -334,7 +334,7 @@ function fetchDoctorHolidays($pdo, $doctor) { $query = "SELECT * FROM festivo WHERE medico IS NULL OR medico=?"; $result = $pdo->prepare($query); - $result->execute($doctor); + $result->execute([$doctor]); $data = $result->fetchAll(); return $data; }