<?php

error_reporting(E_ALL);
ini_set('display_errors',1);
session_start();
if(!isset($_SESSION['admin'])){
    header("Location:index.php");
    exit();
}

include "config.php";
include "header.php";
?>
<head>
    <link rel="stylesheet" href="assets/style.css">
    
</head>
<h3>Clinic Dashboard</h3>

<div class="row">

<div class="col-md-4">
<div class="card p-3 shadow">
<h5>Add Patient</h5>
<a href="add_patient.php" class="btn btn-primary">Open</a>
</div>
</div>

<div class="col-md-4">
<div class="card p-3 shadow">
<h5>View Patients</h5>
<a href="patients.php" class="btn btn-primary">Open</a>
</div>
</div>

<div class="col-md-4">
<div class="card p-3 shadow">
<h5>Approve Appointment</h5>
<a href="appointments.php" class="btn btn-primary">Open</a>
</div>
</div>


<h4>Today's OPD Queue</h4>

<table border="1">
<tr>
<th>Token</th>
<th>Patient</th>
</tr>

<?php
$today=date("Y-m-d");
$q=mysqli_query($conn,"
SELECT opd_tokens.token_no,patients.name
FROM opd_tokens
JOIN patients ON opd_tokens.patient_id=patients.id
WHERE  visit_date='$today'
ORDER BY token_no ASC");

while($row=mysqli_fetch_assoc($q)){
echo "<tr>
<td>{$row['token_no']}</td>
<td>{$row['name']}</td>
</tr>";
}
?>
</table>

</div>


<?php include "footer.php"; ?>
