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++) {
-
-
-
-
-
-
-
- = htmlspecialchars($formattedSelectedDate) ?>
-
-
-
-
-
GEKOZEN DAG
-
-
-
-
- Werkdag
-
-
-
-
-
-
-
-
-
- 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 += ``;
+ }
+ if (data.isWorkday) {
+ badgesHtml += `
+
+ Werkdag
+ `;
+ } else {
+ badgesHtml += ``;
+ }
+ if (data.isBlocked && data.selectedDayBlock) {
+ const blockJson = JSON.stringify(data.selectedDayBlock).replace(/"/g, '"');
+ const blockTitle = (data.selectedDayBlock.title || '').replace(//g, '>');
+ badgesHtml += ``;
+ }
+ headerBadgesEl.innerHTML = badgesHtml;
+ }
+
// Werk URL bij in adresbalk zonder paginaherlaad
if (pushState && window.history && window.history.pushState) {
const todayStr = '= $today ?>';