<?php include '../db.php'; ?>

<h2>Notification Logs</h2>

<table border="1" cellpadding="5">
<tr>
    <th>Client</th><th>Type</th><th>Subject</th><th>Message</th><th>Status</th><th>Sent At</th>
</tr>

<?php
$stmt = $conn->query("
    SELECT nl.*, c.name AS client_name 
    FROM notification_logs nl 
    LEFT JOIN clients c ON nl.client_id = c.id
    ORDER BY sent_at DESC
");

foreach ($stmt->fetchAll() as $log) {
    echo "<tr>
        <td>{$log['client_name']}</td>
        <td>{$log['type']}</td>
        <td>{$log['subject']}</td>
        <td>{$log['message']}</td>
        <td>{$log['status']}</td>
        <td>{$log['sent_at']}</td>
    </tr>";
}
?>
</table>
