<?php
session_start();
if (!isset($_SESSION['doctor_id'])) {
    header("Location: login.php");
    exit();
}
include '../include/config.php';
$patients = $conn->query("SELECT * FROM patients ORDER BY created_at DESC");
?>
<!DOCTYPE html>
<html><head><title>All Patients</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"></head>
<body><nav class="navbar navbar-dark bg-dark"><div class="container"><span class="navbar-brand">All Patients</span><a href="dashboard.php" class="btn btn-light btn-sm">Back</a></div></nav>
<div class="container mt-4"><div class="card"><div class="card-header bg-success text-white">Patient Directory</div><div class="card-body"><div class="table-responsive"><table class="table"><thead><tr><th>ID</th><th>Name</th><th>Email</th><th>Phone</th><th>Action</th></tr></thead><tbody>
<?php while($p=$patients->fetch_assoc()): ?>
<tr><td><?= $p['patient_id'] ?></td><td><?= $p['first_name'].' '.$p['last_name'] ?></td><td><?= $p['email'] ?></td><td><?= $p['phone'] ?></td><td><a href="view_patient_record.php?id=<?= $p['patient_id'] ?>" class="btn btn-sm btn-primary">View Record</a></td></tr>
<?php endwhile; ?>
</tbody></table></div></div></div></div></body>
</html>