Allow admins to select a doctor's appointments
This commit is contained in:
parent
270e4ec03d
commit
f591cb5f2f
|
@ -20,14 +20,31 @@
|
|||
include 'database.php';
|
||||
|
||||
$pdo = connectDatabase();
|
||||
$events = fetchCalendarEvents($pdo);
|
||||
if($_SESSION["user_type"] == 2){
|
||||
?>
|
||||
<?php if($_SESSION["user_type"] == 2): ?>
|
||||
$user = finduser($pdo, $_SESSION["user"]);
|
||||
}
|
||||
$events = fetchCalendarEvents($pdo, $user[0][4]);
|
||||
$holidays = fetchDoctorHolidays($pdo, $user[0][4]);
|
||||
$calendar_settings = fetchCalendarSettings($pdo, $user[0][4]);
|
||||
closeDatabase($pdo);
|
||||
<?php else: ?>
|
||||
<form name="select_doctor" method="get">
|
||||
<?php $doctors = listDoctors($pdo); ?>
|
||||
<div class="input-group">
|
||||
<select id="medico" name="medico">
|
||||
<option>Seleccione un médico</option>
|
||||
<?php foreach ($doctors as $row) : ?>
|
||||
<option value="<?php echo $row[0]; ?>"><?php echo $row[1]; ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
<button class="create_btn" type="submit" name="select">Seleccionar</button>
|
||||
</div>
|
||||
<?php
|
||||
$events = fetchCalendarEvents($pdo, $_GET["medico"]);
|
||||
$holidays = fetchDoctorHolidays($pdo, $_GET["medico"]);
|
||||
$calendar_settings = fetchCalendarSettings($pdo, $_GET["medico"]);
|
||||
?>
|
||||
<?php endif; ?>
|
||||
<?php closeDatabase($pdo); ?>
|
||||
<div class="response"></div>
|
||||
<div id="calendar"></div>
|
||||
</body>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue