- Add --font-serif/--font-mono/--font-sans tokens to :root and point all ~24 hardcoded font-family declarations at them - Drop an exact-duplicate .footer-brand .knot rule - Merge the shared background/border of .stat-card, .card, .login-card, and .panel into one grouped selector - Combine .btn-outline:hover and .nav-cta:hover into one rule - Move remaining inline style="" attributes in index.php and admin/index.php into named classes/rules (.about-grid h2, footer address/.social-row spacing, .panel-head, .checkbox-label-lg, .field-hint, .form-actions) No visual changes intended — values carried over as-is. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
177 lines
7.5 KiB
PHP
177 lines
7.5 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../inc/auth.php';
|
|
require_once __DIR__ . '/../inc/announcements.php';
|
|
|
|
require_auth();
|
|
$user = get_logged_in_user();
|
|
$pdo = get_db();
|
|
|
|
$successMsg = '';
|
|
$errorMsg = '';
|
|
|
|
// Handle announcement form submission
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'save_announcement') {
|
|
if (!verify_csrf_token($_POST['csrf_token'] ?? '')) {
|
|
$errorMsg = 'Session expired or invalid security token. Please try again.';
|
|
} else {
|
|
$annId = !empty($_POST['announcement_id']) ? (int)$_POST['announcement_id'] : null;
|
|
save_announcement([
|
|
'is_active' => isset($_POST['is_active']) ? 1 : 0,
|
|
'type' => $_POST['type'] ?? 'holiday',
|
|
'headline' => $_POST['headline'] ?? '',
|
|
'message' => $_POST['message'] ?? '',
|
|
'start_date' => $_POST['start_date'] ?? null,
|
|
'end_date' => $_POST['end_date'] ?? null,
|
|
'show_banner' => isset($_POST['show_banner']) ? 1 : 0,
|
|
'show_in_hours' => isset($_POST['show_in_hours']) ? 1 : 0,
|
|
], $annId);
|
|
|
|
$successMsg = 'Announcement updated successfully!';
|
|
}
|
|
}
|
|
|
|
// Fetch current announcement (or default empty template)
|
|
$announcement = get_active_announcement();
|
|
if (!$announcement) {
|
|
$stmt = $pdo->query("SELECT * FROM announcements ORDER BY id DESC LIMIT 1");
|
|
$announcement = $stmt->fetch() ?: [
|
|
'id' => 0,
|
|
'is_active' => 0,
|
|
'type' => 'holiday',
|
|
'headline' => 'Holiday Closure',
|
|
'message' => 'The Old Fitz will be closed for the holiday weekend.',
|
|
'start_date' => '',
|
|
'end_date' => '',
|
|
'show_banner' => 1,
|
|
'show_in_hours' => 1
|
|
];
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Pub Management Dashboard | The Old Fitz</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;1,9..144,400&family=Karla:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="../styles.css">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="admin-nav">
|
|
<div class="container admin-nav-inner">
|
|
<a href="index.php" class="admin-brand">
|
|
<img src="../assets/knot.png" alt="" class="knot">
|
|
<span>The Old Fitz Admin</span>
|
|
</a>
|
|
<div class="admin-user">
|
|
<span>Logged in as <strong><?= htmlspecialchars($user['username']) ?></strong></span>
|
|
<a href="../" target="_blank" rel="noopener">View Public Site ↗</a>
|
|
<a href="logout.php">Sign Out</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="dashboard-layout">
|
|
<div class="container">
|
|
<div class="dash-header">
|
|
<p class="eyebrow">Content & Operations</p>
|
|
<h1>Site Announcements & Alerts</h1>
|
|
</div>
|
|
|
|
<?php if (!empty($successMsg)): ?>
|
|
<div class="alert-success" role="status"><?= htmlspecialchars($successMsg) ?></div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($errorMsg)): ?>
|
|
<div class="alert-error" role="alert"><?= htmlspecialchars($errorMsg) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST" action="index.php">
|
|
<input type="hidden" name="action" value="save_announcement">
|
|
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars(get_csrf_token()) ?>">
|
|
<input type="hidden" name="announcement_id" value="<?= (int)($announcement['id'] ?? 0) ?>">
|
|
|
|
<div class="panel">
|
|
<div class="panel-head">
|
|
<h2>
|
|
<span>📢 Announcement Settings</span>
|
|
</h2>
|
|
<?php if (!empty($announcement['is_active'])): ?>
|
|
<span class="status-badge active">● Live on site</span>
|
|
<?php else: ?>
|
|
<span class="status-badge inactive">○ Inactive / Off</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="form-grid">
|
|
<div class="form-group full-width">
|
|
<label class="checkbox-label checkbox-label-lg">
|
|
<input type="checkbox" name="is_active" value="1" <?= !empty($announcement['is_active']) ? 'checked' : '' ?>>
|
|
<strong>Enable Announcement on Site</strong>
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="headline">Notice Headline</label>
|
|
<input type="text" id="headline" name="headline" class="form-control"
|
|
value="<?= htmlspecialchars($announcement['headline'] ?? '') ?>"
|
|
placeholder="e.g. Labor Day Closure" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="type">Style / Category</label>
|
|
<select id="type" name="type" class="form-control">
|
|
<option value="holiday" <?= ($announcement['type'] ?? '') === 'holiday' ? 'selected' : '' ?>>Holiday / Special Schedule (Warm Brass & Green)</option>
|
|
<option value="special" <?= ($announcement['type'] ?? '') === 'special' ? 'selected' : '' ?>>Event / Live Music Announcement</option>
|
|
<option value="closure" <?= ($announcement['type'] ?? '') === 'closure' ? 'selected' : '' ?>>Urgent Closure / Weather Alert</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group full-width">
|
|
<label for="message">Notice Message</label>
|
|
<textarea id="message" name="message" class="form-control" required
|
|
placeholder="Write details of closure, dates, and when regular hours resume..."><?= htmlspecialchars($announcement['message'] ?? '') ?></textarea>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="start_date">Start Date (Optional Auto-Schedule)</label>
|
|
<input type="date" id="start_date" name="start_date" class="form-control"
|
|
value="<?= htmlspecialchars($announcement['start_date'] ?? '') ?>">
|
|
<span class="muted field-hint">Leave blank to show immediately while enabled.</span>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="end_date">End Date (Optional Expiration)</label>
|
|
<input type="date" id="end_date" name="end_date" class="form-control"
|
|
value="<?= htmlspecialchars($announcement['end_date'] ?? '') ?>">
|
|
<span class="muted field-hint">Auto-hides after 11:59 PM on this date.</span>
|
|
</div>
|
|
|
|
<div class="form-group full-width">
|
|
<label>Display Placements</label>
|
|
<div class="checkbox-group">
|
|
<label class="checkbox-label">
|
|
<input type="checkbox" name="show_banner" value="1" <?= !empty($announcement['show_banner']) ? 'checked' : '' ?>>
|
|
Show as top alert banner across the site
|
|
</label>
|
|
<label class="checkbox-label">
|
|
<input type="checkbox" name="show_in_hours" value="1" <?= !empty($announcement['show_in_hours']) ? 'checked' : '' ?>>
|
|
Highlight inside the "Hours & Visit" card
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-actions">
|
|
<button type="submit" class="btn btn-primary">Save & Update Site</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</main>
|
|
|
|
</body>
|
|
</html>
|