Add pub hours admin panel, rebuild announcements/users lists on CSS Grid
- Add a Hours admin panel (admin/hours.php, admin/hours.js) for editing the weekly open/close schedule and an optional per-day kitchen closing time, with a live preview of how it'll read on the public site - Store hours in a new pub_hours table (inc/db.php), seeded with the site's existing Thu-Sat/9pm-kitchen schedule; inc/hours.php formats and groups it for display (day ranges, kitchen-close note, footer summary) - Wire the public Visit card and both site footers (index.php, menu.php) to read hours from that data instead of hardcoded copy - Rebuild the Announcements and Users admin tables onto the same CSS Grid list pattern already used for the Menu (admin-table-actions -> row-actions), and make the Announcements status toggle an in-place AJAX action like the menu item's (admin/index.js) - Add the Hours tab to admin nav across all four admin pages Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fd928a24cf
commit
eab20899de
14 files changed
+1224
-441
No files matched your search
+38
@@ -77,6 +77,15 @@ function init_db_schema(PDO $pdo): void {
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pub_hours (
|
||||
day_of_week INTEGER PRIMARY KEY,
|
||||
is_open INTEGER NOT NULL DEFAULT 0,
|
||||
open_time TEXT NULL,
|
||||
close_time TEXT NULL,
|
||||
kitchen_close_time TEXT NULL,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
");
|
||||
|
||||
// Seed default admin user if table is empty (username: admin / password: password)
|
||||
@@ -87,4 +96,33 @@ function init_db_schema(PDO $pdo): void {
|
||||
$insert = $pdo->prepare("INSERT INTO users (username, password_hash, role) VALUES (?, ?, 'admin')");
|
||||
$insert->execute(['admin', $defaultPassHash]);
|
||||
}
|
||||
|
||||
// Seed default weekly hours if the table is empty: closed Sun–Wed,
|
||||
// 4–10pm Thu–Sat with the kitchen closing at 9 — matches the hours the
|
||||
// site originally shipped with as hardcoded copy.
|
||||
$stmt = $pdo->query("SELECT COUNT(*) as count FROM pub_hours");
|
||||
$hoursCount = $stmt->fetchColumn();
|
||||
if ($hoursCount == 0) {
|
||||
$insert = $pdo->prepare("
|
||||
INSERT INTO pub_hours (day_of_week, is_open, open_time, close_time, kitchen_close_time)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
");
|
||||
// 0=Sunday ... 6=Saturday
|
||||
$defaults = [
|
||||
0 => null, // Sunday — closed
|
||||
1 => null, // Monday — closed
|
||||
2 => null, // Tuesday — closed
|
||||
3 => null, // Wednesday — closed
|
||||
4 => ['16:00', '22:00', '21:00'], // Thursday
|
||||
5 => ['16:00', '22:00', '21:00'], // Friday
|
||||
6 => ['16:00', '22:00', '21:00'], // Saturday
|
||||
];
|
||||
foreach ($defaults as $day => $times) {
|
||||
if ($times === null) {
|
||||
$insert->execute([$day, 0, null, null, null]);
|
||||
} else {
|
||||
$insert->execute([$day, 1, $times[0], $times[1], $times[2]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user