From 3595d587634b927584f45d4b864447bd90195616 Mon Sep 17 00:00:00 2001 From: Niek Rabelink Date: Mon, 14 Sep 2026 11:52:18 +0200 Subject: [PATCH] Dashboard --- includes/header.php | 58 ++++++++++++++++ planner.php | 165 +++++++++++++++++++------------------------- 2 files changed, 129 insertions(+), 94 deletions(-) diff --git a/includes/header.php b/includes/header.php index 598e17b..cb9192f 100644 --- a/includes/header.php +++ b/includes/header.php @@ -252,6 +252,64 @@ require_once __DIR__ . '/env_badge.php';
+ + +
+
+ + +
+ + +
+ + +
+ + +
+ +
diff --git a/planner.php b/planner.php index f2a17d7..c3e2a39 100644 --- a/planner.php +++ b/planner.php @@ -7,13 +7,8 @@ // Controleer of dit een AJAX verzoek is voor een geruisloze datumwisseling $isAjaxRequest = (!empty($_GET['ajax']) && $_GET['ajax'] === '1'); -if ($isAjaxRequest) { - require_once __DIR__ . '/includes/auth.php'; - $currentUser = require_auth(true); -} else { - $pageTitle = 'Fociz'; - require_once __DIR__ . '/includes/header.php'; -} +require_once __DIR__ . '/includes/auth.php'; +$currentUser = require_auth($isAjaxRequest); require_once __DIR__ . '/includes/settings.php'; require_once __DIR__ . '/includes/integrations/microsoft.php'; @@ -70,7 +65,33 @@ $dutchShortMonths = ['', 'jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', $formattedSelectedDate = $dutchFullDays[(int)date('N', $selectedTs)] . ' ' . date('j', $selectedTs) . ' ' . $dutchMonths[(int)date('n', $selectedTs)] . ' ' . date('Y', $selectedTs); $formattedWeekRange = date('j', $mondayTs) . ' ' . $dutchShortMonths[(int)date('n', $mondayTs)] . ' – ' . date('j', $sundayTs) . ' ' . $dutchShortMonths[(int)date('n', $sundayTs)] . ' ' . date('Y', $sundayTs); -// 1. Haal integratiestatussen op +// Haal actieve kalenderblokkades (vakanties / verlof / afwezigheid) op vóór header render +$allCalendarBlocks = []; +$calendarBlocksByDate = []; +try { + $stmtBlocks = $db->prepare(" + SELECT * FROM calendar_blocks + WHERE user_id = ? AND start_date <= ? AND end_date >= ? + ORDER BY start_date ASC + "); + $stmtBlocks->execute([$userId, date('Y-m-d', strtotime('+35 days', $sundayTs)), date('Y-m-d', strtotime('-14 days', $mondayTs))]); + $allCalendarBlocks = $stmtBlocks->fetchAll() ?: []; + foreach ($allCalendarBlocks as $cb) { + $cbStart = strtotime($cb['start_date']); + $cbEnd = strtotime($cb['end_date']); + for ($d = $cbStart; $d <= $cbEnd; $d += 86400) { + $dStr = date('Y-m-d', $d); + $calendarBlocksByDate[$dStr][] = $cb; + } + } +} catch (Throwable $e) { + error_log("Fout bij ophalen calendar_blocks in planner: " . $e->getMessage()); +} + +$selectedDayBlock = $calendarBlocksByDate[$selectedDate][0] ?? null; +$isSelectedDateBlocked = !empty($selectedDayBlock); + +// 1. Haal integratiestatussen op vóór header render $userIntegrations = []; try { $stmtInt = $db->prepare("SELECT * FROM integrations WHERE user_id = ?"); @@ -87,6 +108,11 @@ $isOutlookConnected = !empty($userIntegrations['OUTLOOK']['access_token']) && em $outlookIntegrationSettings = json_decode($userIntegrations['OUTLOOK']['settings'] ?? '{}', true) ?: []; $syncIntervalSeconds = isset($outlookIntegrationSettings['sync_interval_seconds']) ? (int)$outlookIntegrationSettings['sync_interval_seconds'] : 30; +if (!$isAjaxRequest) { + $pageTitle = 'Fociz'; + require_once __DIR__ . '/includes/header.php'; +} + $weekOutlookEvents = []; $isLiveOutlook = false; @@ -247,32 +273,6 @@ foreach ($weekOutlookEvents as $evt) { $outlookEventsByDate[$evtDate][] = $evt; } -// 4b. Haal actieve kalenderblokkades (vakanties / verlof / afwezigheid) op -$allCalendarBlocks = []; -$calendarBlocksByDate = []; -try { - $stmtBlocks = $db->prepare(" - SELECT * FROM calendar_blocks - WHERE user_id = ? AND start_date <= ? AND end_date >= ? - ORDER BY start_date ASC - "); - $stmtBlocks->execute([$userId, date('Y-m-d', strtotime('+35 days', $sundayTs)), date('Y-m-d', strtotime('-14 days', $mondayTs))]); - $allCalendarBlocks = $stmtBlocks->fetchAll() ?: []; - foreach ($allCalendarBlocks as $cb) { - $cbStart = strtotime($cb['start_date']); - $cbEnd = strtotime($cb['end_date']); - for ($d = $cbStart; $d <= $cbEnd; $d += 86400) { - $dStr = date('Y-m-d', $d); - $calendarBlocksByDate[$dStr][] = $cb; - } - } -} catch (Throwable $e) { - error_log("Fout bij ophalen calendar_blocks in planner: " . $e->getMessage()); -} - -$selectedDayBlock = $calendarBlocksByDate[$selectedDate][0] ?? null; -$isSelectedDateBlocked = !empty($selectedDayBlock); - // 7 Dagen van de week samenstellen voor de weekselector $weekDays = []; for ($i = 0; $i < 7; $i++) { @@ -495,67 +495,7 @@ for ($h = $startHour; $h <= $endHour; $h++) { - -
-
-
-
-
- - -
- - VANDAAG - - GEKOZEN DAG - - - - - Werkdag - - - - - Weekend / Vrij - - - - - - - - -
-

- Fociz -

-
- -
- - -
-
-
@@ -1965,6 +1905,10 @@ if ($isAjaxRequest) { 'success' => true, 'selectedDate' => $selectedDate, 'formattedDate' => $formattedSelectedDate, + 'isToday' => (bool)$isTodaySelected, + 'isWorkday' => (bool)$isSelectedDateWorkday, + 'isBlocked' => (bool)$isSelectedDateBlocked, + 'selectedDayBlock'=> $selectedDayBlock ?? null, 'weekStart' => $weekStart, 'weekEnd' => $weekEnd, 'weekNumber' => $weekNumber, @@ -6230,6 +6174,39 @@ async function switchPlannerDate(newDate, event = null, pushState = true) { document.title = data.title; } + // Werk datum & badges in top header bij + const headerDateEl = document.getElementById('headerCurrentDateDisplay'); + if (headerDateEl && data.formattedDate) { + headerDateEl.textContent = data.formattedDate; + } + const headerBadgesEl = document.getElementById('headerDateBadgesContainer'); + if (headerBadgesEl) { + let badgesHtml = ''; + if (data.isToday) { + badgesHtml += `VANDAAG`; + } + if (data.isWorkday) { + badgesHtml += ` + + Werkdag + `; + } else { + badgesHtml += ` + + Weekend / Vrij + `; + } + if (data.isBlocked && data.selectedDayBlock) { + const blockJson = JSON.stringify(data.selectedDayBlock).replace(/"/g, '"'); + const blockTitle = (data.selectedDayBlock.title || '').replace(//g, '>'); + badgesHtml += ` + + ${blockTitle} + `; + } + headerBadgesEl.innerHTML = badgesHtml; + } + // Werk URL bij in adresbalk zonder paginaherlaad if (pushState && window.history && window.history.pushState) { const todayStr = ''; -- 2.52.0