dashboard - first draft of complete redesign
This commit is contained in:
@@ -9,7 +9,9 @@ if (!in_array($generalPermission, [1, '1', true, 't', 'true'], true)) {
|
||||
exit();
|
||||
}
|
||||
|
||||
contentpanel_cleanup_expired_news();
|
||||
$today = date('Y-m-d');
|
||||
contentpanel_cleanup_expired_news();
|
||||
contentpanel_cleanup_expired_announcements($pdo, $today);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = trim((string) ($_POST['action'] ?? ''));
|
||||
@@ -52,8 +54,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$flash = $_SESSION['contentpanel_flash'] ?? null;
|
||||
unset($_SESSION['contentpanel_flash']);
|
||||
|
||||
$today = date('Y-m-d');
|
||||
$services = contentpanel_fetch_services($pdo, $today);
|
||||
$services = contentpanel_fetch_services($pdo, $today);
|
||||
$announcements = contentpanel_fetch_announcements($pdo, $today);
|
||||
$newsItems = contentpanel_list_news();
|
||||
$pdo = null;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
function contentpanel_cleanup_expired_announcements(PDO $pdo, string $today): void
|
||||
{
|
||||
// Das Enddatum ist einschließlich gültig; ohne Enddatum zählt das Startdatum.
|
||||
// Datensätze ohne beide Datumswerte werden nicht als abgelaufen gelöscht.
|
||||
$statement = $pdo->prepare(
|
||||
'DELETE FROM ansagen WHERE COALESCE(ansage_datum_bis, ansage_datum_von) < ?'
|
||||
);
|
||||
$statement->execute([$today]);
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
require_once __DIR__ . '/news.php';
|
||||
require_once __DIR__ . '/news_queue.php';
|
||||
require_once __DIR__ . '/announcements.php';
|
||||
|
||||
function contentpanel_html($value): string
|
||||
{
|
||||
@@ -294,6 +295,6 @@ function contentpanel_fetch_announcements(PDO $pdo, string $today): array
|
||||
return contentpanel_query($pdo,
|
||||
'SELECT id, ansage_titel AS title, ansage_untertitel AS subtitle, ansage_datum_von AS date,
|
||||
ansage_datum_bis AS end_date, ansage_uhrzeit AS time, ansage_ort AS location
|
||||
FROM ansagen WHERE ansage_datum_von >= ? OR ansage_datum_bis >= ? ORDER BY ansage_datum_von',
|
||||
[$today, $today])->fetchAll(PDO::FETCH_ASSOC);
|
||||
FROM ansagen WHERE COALESCE(ansage_datum_bis, ansage_datum_von) >= ? ORDER BY ansage_datum_von',
|
||||
[$today])->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user