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

<table border="1" width="100%">
<tr>
<th>Name</th>
<th>Mobile</th>
<th>Date</th>
<th>Time</th>
<th>Status</th>
<th>Action</th>
</tr>

<?php

$q=mysqli_query($conn,"SELECT * FROM appointments WHERE visit_date = CURDATE() ORDER BY id DESC");
while($row=mysqli_fetch_assoc($q)){
echo "<tr>";
echo "<td>{$row['patient_name']}</td>";
echo "<td>{$row['mobile']}</td>";
echo "<td>{$row['visit_date']}</td>";
echo "<td>{$row['visit_time']}</td>";
echo "<td>{$row['status']}</td>";
echo "<td>";

if($row['status']=="Pending"){
    echo "
    <a href='update_appointment.php?id={$row['id']}&action=approve'>Approve</a> |
    <a href='update_appointment.php?id={$row['id']}&action=reject'>Reject</a> |
    <a href='change_time.php?id={$row['id']}'>Change Time</a>
    ";
}
elseif($row['status']=="Approved"){
    echo "Approved | <a href='change_time.php?id={$row['id']}'>Change Time</a>";
}
else{
    echo "<span style='color:red'>Rejected</span>";
}

echo "</td></tr>";
}
?>
</table>

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