Add appointment calendar queries

This commit is contained in:
coolneng 2020-06-25 17:59:56 +02:00
parent 095f22f60f
commit 270e4ec03d
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
2 changed files with 38 additions and 2 deletions

View File

@ -19,8 +19,14 @@
<?php <?php
include 'database.php'; include 'database.php';
#$pdo = connectDatabase(); $pdo = connectDatabase();
#$data = fetchCalendarEvents($pdo); $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);
?> ?>
<div class="response"></div> <div class="response"></div>
<div id="calendar"></div> <div id="calendar"></div>

View File

@ -308,3 +308,33 @@ function configureCalendar($pdo, $data)
} }
return "Calendario configurado con éxito"; return "Calendario configurado con éxito";
} }
function fetchCalendarEvents($pdo)
{
$query = "SELECT * from cita";
$result = $pdo->prepare($query);
$result->execute();
$data = $result->fetchAll();
return $data;
}
function fetchCalendarSettings($pdo, $doctor)
{
$query = "SELECT * from calendario WHERE medico=?";
$result = $pdo->prepare($query);
$result->execute([$doctor]);
$data = $result->fetch();
return $data;
}
function fetchDoctorHolidays($pdo, $doctor)
{
$query = "SELECT * FROM festivo WHERE medico IS NULL OR medico=?";
$result = $pdo->prepare($query);
$result->execute($doctor);
$data = $result->fetchAll();
return $data;
}