<?php
session_start();
if (!isset($_SESSION['admin_id'])) { header("Location: login.php"); exit(); }
include '../include/config.php';

$notifications = $conn->query("SELECT * FROM patient_notifications ORDER BY created_at DESC LIMIT 100");
?>
<!DOCTYPE html>
<html>
<head><title>Manage Notifications</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"></head>
<body><div class="container mt-4"><h2>Patient Notifications</h2><table class="table table-bordered"><thead><tr><th>Patient ID</th><th>Title</th><th>Message</th><th>Type</th><th>Read</th><th>Date</th></tr></thead><tbody>
<?php while($n = $notifications->fetch_assoc()): ?>
<tr><td><?= $n['patient_id'] ?></td><td><?= htmlspecialchars($n['title']) ?></td><td><?= htmlspecialchars($n['message']) ?></td><td><?= $n['type'] ?></td><td><?= $n['is_read']?'Yes':'No' ?></td><td><?= $n['created_at'] ?></td></tr>
<?php endwhile; ?>
</tbody></table><a href="dashboard.php" class="btn btn-secondary">Back</a></div></body>
</html>