Merge pull request #13 from jasonMPM/claude/isp-website-docker-EB8pB
Add delete message action to staff portal
This commit is contained in:
@@ -96,6 +96,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['mark_all_read'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Delete a single message
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_message'])) {
|
||||
$db->prepare("DELETE FROM contacts WHERE id = ?")->execute([(int)$_POST['delete_message']]);
|
||||
header('Location: /staff-portal');
|
||||
exit;
|
||||
}
|
||||
|
||||
// ── Fetch messages ────────────────────────────────────────────────────────
|
||||
$messages = $db->query("SELECT * FROM contacts ORDER BY created_at DESC")->fetchAll();
|
||||
$unread_count = (int)$db->query("SELECT COUNT(*) FROM contacts WHERE is_read = 0")->fetchColumn();
|
||||
@@ -140,6 +147,8 @@ function h(string $s): string { return htmlspecialchars($s, ENT_QUOTES); }
|
||||
.btn--primary:hover { background: #1d4ed8; }
|
||||
.btn--ghost { background: transparent; color: #94a3b8; border: 1px solid #1e2d4a; }
|
||||
.btn--ghost:hover { background: #1e2d4a; color: #e2e8f0; }
|
||||
.btn--danger { background: transparent; color: #f87171; border: 1px solid #450a0a; }
|
||||
.btn--danger:hover { background: #450a0a; color: #fca5a5; }
|
||||
.btn--sm { padding: .3rem .65rem; font-size: .78rem; }
|
||||
|
||||
/* ── Container ── */
|
||||
@@ -232,6 +241,10 @@ function h(string $s): string { return htmlspecialchars($s, ENT_QUOTES); }
|
||||
<button class="btn btn--primary btn--sm">Mark as read</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<form method="post" onsubmit="return confirm('Delete message from <?= h(addslashes($m['name'])) ?>? This cannot be undone.')">
|
||||
<input type="hidden" name="delete_message" value="<?= (int)$m['id'] ?>">
|
||||
<button class="btn btn--danger btn--sm">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user