Refactor planner.php to remove commented-out code and clean up integration logic

This commit is contained in:
2026-09-09 16:22:46 +02:00
parent 890cbe7446
commit 8f191f5123
-145
View File
@@ -42,53 +42,7 @@ $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); $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); $formattedWeekRange = date('j', $mondayTs) . ' ' . $dutchShortMonths[(int)date('n', $mondayTs)] . ' – ' . date('j', $sundayTs) . ' ' . $dutchShortMonths[(int)date('n', $sundayTs)] . ' ' . date('Y', $sundayTs);
<<<<<<< HEAD
// 1. Haal integratiestatussen op // 1. Haal integratiestatussen op
=======
// 1. Haal dagplanning op of maak aan voor $selectedDate
$stmtPlan = $db->prepare("SELECT * FROM daily_plans WHERE user_id = ? AND plan_date = ?");
$stmtPlan->execute([$userId, $selectedDate]);
$dailyPlan = $stmtPlan->fetch();
if (!$dailyPlan) {
$defaultGoal = ($selectedDate === $today) ? 'Mijn belangrijkste doel van vandaag behalen' : 'Focusdoel voor deze dag bepalen';
$stmtCreatePlan = $db->prepare("
INSERT INTO daily_plans (user_id, plan_date, focus_goal)
VALUES (?, ?, ?)
");
$stmtCreatePlan->execute([$userId, $selectedDate, $defaultGoal]);
$planId = (int)$db->lastInsertId();
$dailyPlan = ['id' => $planId, 'plan_date' => $selectedDate, 'focus_goal' => $defaultGoal, 'notes' => ''];
}
// 2. Haal taken op voor de geselecteerde dag
$stmtTasks = $db->prepare("
SELECT * FROM tasks
WHERE user_id = ? AND (daily_plan_id = ? " . ($selectedDate === $today ? "OR daily_plan_id IS NULL" : "") . ")
ORDER BY is_completed ASC, priority ASC, time_block_start ASC, created_at DESC
");
$stmtTasks->execute([$userId, $dailyPlan['id']]);
$tasks = $stmtTasks->fetchAll();
// 3. Haal weekstatistieken voor taken op (aantal per dag)
$stmtWeekTasks = $db->prepare("
SELECT dp.plan_date, COUNT(t.id) as total_tasks, SUM(CASE WHEN t.is_completed = 1 THEN 1 ELSE 0 END) as completed_tasks
FROM daily_plans dp
LEFT JOIN tasks t ON t.daily_plan_id = dp.id AND t.user_id = ?
WHERE dp.user_id = ? AND dp.plan_date BETWEEN ? AND ?
GROUP BY dp.plan_date
");
$stmtWeekTasks->execute([$userId, $userId, $weekStart, $weekEnd]);
$weekTaskStats = [];
foreach ($stmtWeekTasks->fetchAll() as $row) {
$weekTaskStats[$row['plan_date']] = [
'total' => (int)$row['total_tasks'],
'completed' => (int)$row['completed_tasks'],
];
}
// 4. Haal integratiestatussen op
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
$stmtInt = $db->prepare("SELECT * FROM integrations WHERE user_id = ?"); $stmtInt = $db->prepare("SELECT * FROM integrations WHERE user_id = ?");
$stmtInt->execute([$userId]); $stmtInt->execute([$userId]);
$userIntegrations = []; $userIntegrations = [];
@@ -97,12 +51,9 @@ foreach ($stmtInt->fetchAll() as $row) {
} }
$isOutlookConnected = !empty($userIntegrations['OUTLOOK']['access_token']) && empty($userIntegrations['OUTLOOK']['is_demo_mode']); $isOutlookConnected = !empty($userIntegrations['OUTLOOK']['access_token']) && empty($userIntegrations['OUTLOOK']['is_demo_mode']);
<<<<<<< HEAD
$outlookIntegrationSettings = json_decode($userIntegrations['OUTLOOK']['settings'] ?? '{}', true) ?: []; $outlookIntegrationSettings = json_decode($userIntegrations['OUTLOOK']['settings'] ?? '{}', true) ?: [];
$syncIntervalSeconds = isset($outlookIntegrationSettings['sync_interval_seconds']) ? (int)$outlookIntegrationSettings['sync_interval_seconds'] : 30; $syncIntervalSeconds = isset($outlookIntegrationSettings['sync_interval_seconds']) ? (int)$outlookIntegrationSettings['sync_interval_seconds'] : 30;
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
$weekOutlookEvents = []; $weekOutlookEvents = [];
$isLiveOutlook = false; $isLiveOutlook = false;
@@ -110,12 +61,9 @@ if ($isOutlookConnected) {
// Haal afspraken op voor het volledige datumbereik van de week // Haal afspraken op voor het volledige datumbereik van de week
$weekOutlookEvents = microsoft_fetch_events_range($userId, $weekStart, $weekEnd); $weekOutlookEvents = microsoft_fetch_events_range($userId, $weekStart, $weekEnd);
$isLiveOutlook = true; $isLiveOutlook = true;
<<<<<<< HEAD
// Synchroniseer / reconcilieer Fociz taken direct met actuele Outlook data // Synchroniseer / reconcilieer Fociz taken direct met actuele Outlook data
microsoft_reconcile_tasks_with_outlook($userId, $weekStart, $weekEnd, $weekOutlookEvents); microsoft_reconcile_tasks_with_outlook($userId, $weekStart, $weekEnd, $weekOutlookEvents);
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
} else { } else {
// Demo data indien Microsoft Outlook nog niet gekoppeld is // Demo data indien Microsoft Outlook nog niet gekoppeld is
$weekOutlookEvents = [ $weekOutlookEvents = [
@@ -152,7 +100,6 @@ if ($isOutlookConnected) {
]; ];
} }
<<<<<<< HEAD
// 2. Haal dagplanning op of maak aan voor $selectedDate // 2. Haal dagplanning op of maak aan voor $selectedDate
$stmtPlan = $db->prepare("SELECT * FROM daily_plans WHERE user_id = ? AND plan_date = ?"); $stmtPlan = $db->prepare("SELECT * FROM daily_plans WHERE user_id = ? AND plan_date = ?");
$stmtPlan->execute([$userId, $selectedDate]); $stmtPlan->execute([$userId, $selectedDate]);
@@ -195,8 +142,6 @@ foreach ($stmtWeekTasks->fetchAll() as $row) {
]; ];
} }
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
// Groepeer Outlook afspraken per datum // Groepeer Outlook afspraken per datum
$outlookEventsByDate = []; $outlookEventsByDate = [];
foreach ($weekOutlookEvents as $evt) { foreach ($weekOutlookEvents as $evt) {
@@ -249,7 +194,6 @@ foreach ($dayOutlookEvents as $evt) {
$displayedOutlookEvents[] = $evt; $displayedOutlookEvents[] = $evt;
} }
<<<<<<< HEAD
// Bereken initiële status-hash voor achtergrondsynchronisatie // Bereken initiële status-hash voor achtergrondsynchronisatie
$dayEventsForHash = []; $dayEventsForHash = [];
foreach ($displayedOutlookEvents as $e) { foreach ($displayedOutlookEvents as $e) {
@@ -274,8 +218,6 @@ $initialSyncHash = md5(json_encode([
'tasks' => $tasksForHash 'tasks' => $tasksForHash
])); ]));
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
// 6. Tijdlijn uren & Werkdag Standaarden (Release v1.4) // 6. Tijdlijn uren & Werkdag Standaarden (Release v1.4)
$workdayStartStr = $workdaySettings['workday_start'] ?? '08:30'; $workdayStartStr = $workdaySettings['workday_start'] ?? '08:30';
$workdayEndStr = $workdaySettings['workday_end'] ?? '17:30'; $workdayEndStr = $workdaySettings['workday_end'] ?? '17:30';
@@ -338,20 +280,12 @@ for ($h = $startHour; $h <= $endHour; $h++) {
<!-- Integratie Status Badges --> <!-- Integratie Status Badges -->
<div class="flex flex-wrap items-center gap-2"> <div class="flex flex-wrap items-center gap-2">
<?php if ($isOutlookConnected): ?> <?php if ($isOutlookConnected): ?>
<<<<<<< HEAD
<div id="outlookSyncBadge" class="flex items-center space-x-2 px-3 py-1.5 rounded-xl bg-sky-50 dark:bg-sky-500/10 border border-sky-200/80 dark:border-sky-500/20 text-sky-800 dark:text-sky-300 text-xs font-medium shadow-2xs transition"> <div id="outlookSyncBadge" class="flex items-center space-x-2 px-3 py-1.5 rounded-xl bg-sky-50 dark:bg-sky-500/10 border border-sky-200/80 dark:border-sky-500/20 text-sky-800 dark:text-sky-300 text-xs font-medium shadow-2xs transition">
<span id="outlookSyncDot" class="w-2 h-2 rounded-full bg-sky-500"></span> <span id="outlookSyncDot" class="w-2 h-2 rounded-full bg-sky-500"></span>
<span id="outlookSyncStatusText">Outlook 365 Live</span> <span id="outlookSyncStatusText">Outlook 365 Live</span>
<span id="outlookLastSyncText" class="text-[10px] text-sky-600/70 dark:text-sky-400/60 font-mono hidden sm:inline">(synced <span id="syncTimeDisplay"><?= date('H:i') ?></span>)</span> <span id="outlookLastSyncText" class="text-[10px] text-sky-600/70 dark:text-sky-400/60 font-mono hidden sm:inline">(synced <span id="syncTimeDisplay"><?= date('H:i') ?></span>)</span>
<button id="manualSyncBtn" onclick="triggerManualSync()" title="Nu handmatig synchroniseren met Outlook" class="p-0.5 hover:bg-sky-100 dark:hover:bg-sky-500/20 text-sky-600 hover:text-sky-900 dark:text-sky-400 dark:hover:text-white rounded transition cursor-pointer"> <button id="manualSyncBtn" onclick="triggerManualSync()" title="Nu handmatig synchroniseren met Outlook" class="p-0.5 hover:bg-sky-100 dark:hover:bg-sky-500/20 text-sky-600 hover:text-sky-900 dark:text-sky-400 dark:hover:text-white rounded transition cursor-pointer">
<i id="manualSyncIcon" data-lucide="refresh-cw" class="w-3 h-3"></i> <i id="manualSyncIcon" data-lucide="refresh-cw" class="w-3 h-3"></i>
=======
<div class="flex items-center space-x-2 px-3 py-1.5 rounded-xl bg-sky-50 dark:bg-sky-500/10 border border-sky-200/80 dark:border-sky-500/20 text-sky-800 dark:text-sky-300 text-xs font-medium shadow-2xs">
<span class="w-2 h-2 rounded-full bg-sky-500 animate-pulse"></span>
<span>Outlook 365 Live</span>
<button onclick="location.reload()" title="Agenda Verversen" class="p-0.5 text-sky-600 hover:text-sky-900 dark:text-sky-400 dark:hover:text-white rounded transition">
<i data-lucide="refresh-cw" class="w-3 h-3"></i>
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
</button> </button>
</div> </div>
<?php else: ?> <?php else: ?>
@@ -571,24 +505,16 @@ for ($h = $startHour; $h <= $endHour; $h++) {
<label class="block text-[11px] font-medium text-slate-600 dark:text-slate-400 mb-1">Taaktitel</label> <label class="block text-[11px] font-medium text-slate-600 dark:text-slate-400 mb-1">Taaktitel</label>
<input type="text" id="newTaskTitle" placeholder="Wat moet er vandaag gedaan worden?" class="w-full bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl px-3 py-2 text-slate-900 dark:text-white text-xs placeholder-slate-400 dark:placeholder-slate-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"> <input type="text" id="newTaskTitle" placeholder="Wat moet er vandaag gedaan worden?" class="w-full bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl px-3 py-2 text-slate-900 dark:text-white text-xs placeholder-slate-400 dark:placeholder-slate-500 focus:outline-none focus:ring-1 focus:ring-indigo-500">
</div> </div>
<<<<<<< HEAD
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3"> <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3">
<div> <div>
<label class="block text-[11px] font-semibold text-slate-700 dark:text-slate-300 mb-1">Prioriteit</label> <label class="block text-[11px] font-semibold text-slate-700 dark:text-slate-300 mb-1">Prioriteit</label>
<select id="newTaskPriority" class="w-full bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl px-2.5 py-1.5 text-slate-900 dark:text-white text-xs focus:outline-none focus:ring-1 focus:ring-indigo-500"> <select id="newTaskPriority" class="w-full bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl px-2.5 py-1.5 text-slate-900 dark:text-white text-xs focus:outline-none focus:ring-1 focus:ring-indigo-500">
=======
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<div>
<label class="block text-[11px] font-medium text-slate-600 dark:text-slate-400 mb-1">Prioriteit</label>
<select id="newTaskPriority" class="w-full bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl px-2.5 py-1.5 text-slate-900 dark:text-white text-xs focus:outline-none">
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
<option value="P1">P1 - Brandend / Focus</option> <option value="P1">P1 - Brandend / Focus</option>
<option value="P2" selected>P2 - Belangrijk (Standaard)</option> <option value="P2" selected>P2 - Belangrijk (Standaard)</option>
<option value="P3">P3 - Regulier / Lage druk</option> <option value="P3">P3 - Regulier / Lage druk</option>
</select> </select>
</div> </div>
<div> <div>
<<<<<<< HEAD
<label class="block text-[11px] font-semibold text-slate-700 dark:text-slate-300 mb-1">Starttijd</label> <label class="block text-[11px] font-semibold text-slate-700 dark:text-slate-300 mb-1">Starttijd</label>
<div class="relative"> <div class="relative">
<input type="text" id="newTaskTime" placeholder="Bijv. 09:30" class="w-full bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl pl-2.5 pr-7 py-1.5 text-slate-900 dark:text-white text-xs font-mono focus:outline-none focus:ring-1 focus:ring-indigo-500" oninput="onNewTaskTimeOrDurationChange('start')"> <input type="text" id="newTaskTime" placeholder="Bijv. 09:30" class="w-full bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl pl-2.5 pr-7 py-1.5 text-slate-900 dark:text-white text-xs font-mono focus:outline-none focus:ring-1 focus:ring-indigo-500" oninput="onNewTaskTimeOrDurationChange('start')">
@@ -629,22 +555,6 @@ for ($h = $startHour; $h <= $endHour; $h++) {
</select> </select>
<input type="number" id="newTaskCustomDuration" min="1" max="720" placeholder="Min" class="hidden w-20 bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl px-2 py-1.5 text-slate-900 dark:text-white text-xs font-mono focus:outline-none focus:ring-1 focus:ring-indigo-500" oninput="onNewTaskTimeOrDurationChange('custom_duration')"> <input type="number" id="newTaskCustomDuration" min="1" max="720" placeholder="Min" class="hidden w-20 bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl px-2 py-1.5 text-slate-900 dark:text-white text-xs font-mono focus:outline-none focus:ring-1 focus:ring-indigo-500" oninput="onNewTaskTimeOrDurationChange('custom_duration')">
</div> </div>
=======
<label class="block text-[11px] font-medium text-slate-600 dark:text-slate-400 mb-1">Tijdblok (Starttijd)</label>
<input type="text" id="newTaskTime" placeholder="Bijv. 09:30" class="w-full bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl px-2.5 py-1.5 text-slate-900 dark:text-white text-xs font-mono focus:outline-none">
</div>
<div>
<label class="block text-[11px] font-medium text-slate-600 dark:text-slate-400 mb-1">Tijdsduur</label>
<select id="newTaskDuration" class="w-full bg-white dark:bg-slate-900 border border-slate-300 dark:border-slate-800 rounded-xl px-2.5 py-1.5 text-slate-900 dark:text-white text-xs focus:outline-none">
<?php
$defDuration = (int)($workdaySettings['default_task_duration'] ?? 30);
$durations = [15 => '15 minuten', 30 => '30 minuten', 45 => '45 minuten', 60 => '60 minuten (1 uur)', 90 => '90 minuten (1,5 uur)', 120 => '120 minuten (2 uur)'];
foreach ($durations as $mins => $label):
?>
<option value="<?= $mins ?>" <?= $defDuration === $mins ? 'selected' : '' ?>><?= $label ?></option>
<?php endforeach; ?>
</select>
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
</div> </div>
</div> </div>
@@ -703,11 +613,7 @@ for ($h = $startHour; $h <= $endHour; $h++) {
<?php if (!empty($task['time_block_start'])): ?> <?php if (!empty($task['time_block_start'])): ?>
<span class="text-[10px] text-slate-500 dark:text-slate-400 font-mono flex items-center space-x-1"> <span class="text-[10px] text-slate-500 dark:text-slate-400 font-mono flex items-center space-x-1">
<i data-lucide="clock" class="w-2.5 h-2.5"></i> <i data-lucide="clock" class="w-2.5 h-2.5"></i>
<<<<<<< HEAD
<span><?= htmlspecialchars($task['time_block_start']) ?><?= !empty($task['time_block_end']) ? ' - ' . htmlspecialchars($task['time_block_end']) : '' ?><?= !empty($task['duration_minutes']) ? ' (' . (int)$task['duration_minutes'] . 'm)' : '' ?></span> <span><?= htmlspecialchars($task['time_block_start']) ?><?= !empty($task['time_block_end']) ? ' - ' . htmlspecialchars($task['time_block_end']) : '' ?><?= !empty($task['duration_minutes']) ? ' (' . (int)$task['duration_minutes'] . 'm)' : '' ?></span>
=======
<span><?= htmlspecialchars($task['time_block_start']) ?><?= !empty($task['time_block_end']) ? ' - ' . htmlspecialchars($task['time_block_end']) : '' ?></span>
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
</span> </span>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($task['external_url'])): ?> <?php if (!empty($task['external_url'])): ?>
@@ -733,16 +639,11 @@ for ($h = $startHour; $h <= $endHour; $h++) {
<?php endif; ?> <?php endif; ?>
<?php if (!$task['is_completed']): ?> <?php if (!$task['is_completed']): ?>
<<<<<<< HEAD
<button onclick="selectFocusTask('<?= htmlspecialchars(addslashes($task['title'])) ?>')" title="Koppel aan Focus Timer" class="p-1.5 rounded-lg text-slate-400 hover:text-amber-500 hover:bg-amber-500/10 transition cursor-pointer"> <button onclick="selectFocusTask('<?= htmlspecialchars(addslashes($task['title'])) ?>')" title="Koppel aan Focus Timer" class="p-1.5 rounded-lg text-slate-400 hover:text-amber-500 hover:bg-amber-500/10 transition cursor-pointer">
=======
<button onclick="selectFocusTask('<?= htmlspecialchars(addslashes($task['title'])) ?>')" title="Koppel aan Focus Timer" class="p-1.5 rounded-lg text-slate-400 hover:text-amber-500 hover:bg-amber-500/10 transition">
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
<i data-lucide="flame" class="w-3.5 h-3.5"></i> <i data-lucide="flame" class="w-3.5 h-3.5"></i>
</button> </button>
<?php endif; ?> <?php endif; ?>
<<<<<<< HEAD
<button onclick="openEditTaskModal(<?= htmlspecialchars(json_encode([ <button onclick="openEditTaskModal(<?= htmlspecialchars(json_encode([
'id' => (int)$task['id'], 'id' => (int)$task['id'],
'title' => $task['title'], 'title' => $task['title'],
@@ -757,9 +658,6 @@ for ($h = $startHour; $h <= $endHour; $h++) {
</button> </button>
<button onclick="deleteTask(<?= $task['id'] ?>)" title="Verwijderen" class="p-1.5 rounded-lg text-slate-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-500/10 opacity-0 group-hover:opacity-100 transition cursor-pointer"> <button onclick="deleteTask(<?= $task['id'] ?>)" title="Verwijderen" class="p-1.5 rounded-lg text-slate-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-500/10 opacity-0 group-hover:opacity-100 transition cursor-pointer">
=======
<button onclick="deleteTask(<?= $task['id'] ?>)" title="Verwijderen" class="p-1.5 rounded-lg text-slate-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-500/10 opacity-0 group-hover:opacity-100 transition">
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
<i data-lucide="trash-2" class="w-3.5 h-3.5"></i> <i data-lucide="trash-2" class="w-3.5 h-3.5"></i>
</button> </button>
</div> </div>
@@ -975,7 +873,6 @@ for ($h = $startHour; $h <= $endHour; $h++) {
</div> </div>
</div> </div>
<<<<<<< HEAD
<!-- Modal: Taak & Tijdblok Bewerken (Vrij invullen van tijden & duur) --> <!-- Modal: Taak & Tijdblok Bewerken (Vrij invullen van tijden & duur) -->
<div id="editTaskModal" class="fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-xs hidden items-center justify-center p-4"> <div id="editTaskModal" class="fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-xs hidden items-center justify-center p-4">
<div class="bg-white dark:bg-[#111622] border border-slate-200/90 dark:border-slate-800 rounded-2xl p-6 w-full max-w-lg shadow-2xl space-y-4"> <div class="bg-white dark:bg-[#111622] border border-slate-200/90 dark:border-slate-800 rounded-2xl p-6 w-full max-w-lg shadow-2xl space-y-4">
@@ -1070,8 +967,6 @@ for ($h = $startHour; $h <= $endHour; $h++) {
</div> </div>
</div> </div>
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
<script> <script>
// --- Focus Timer Logica (Release v1.4) --- // --- Focus Timer Logica (Release v1.4) ---
const pomodoroFocusTime = <?= (int)$workdaySettings['pomodoro_focus'] ?>; const pomodoroFocusTime = <?= (int)$workdaySettings['pomodoro_focus'] ?>;
@@ -1113,10 +1008,7 @@ function toggleTimer() {
clearInterval(timerInterval); clearInterval(timerInterval);
isRunning = false; isRunning = false;
document.getElementById('timerToggleText').innerText = 'Hervatten'; document.getElementById('timerToggleText').innerText = 'Hervatten';
<<<<<<< HEAD
saveTimerStateBeforeReload(); saveTimerStateBeforeReload();
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
} else { } else {
isRunning = true; isRunning = true;
document.getElementById('timerToggleText').innerText = 'Pauzeren'; document.getElementById('timerToggleText').innerText = 'Pauzeren';
@@ -1127,10 +1019,7 @@ function toggleTimer() {
} else { } else {
clearInterval(timerInterval); clearInterval(timerInterval);
isRunning = false; isRunning = false;
<<<<<<< HEAD
sessionStorage.removeItem('fociz_timer_state'); sessionStorage.removeItem('fociz_timer_state');
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
document.getElementById('timerToggleText').innerText = 'Start Focus'; document.getElementById('timerToggleText').innerText = 'Start Focus';
alert('Focus sessie voltooid! Neem even een korte pauze.'); alert('Focus sessie voltooid! Neem even een korte pauze.');
} }
@@ -1142,15 +1031,11 @@ function resetTimer() {
clearInterval(timerInterval); clearInterval(timerInterval);
isRunning = false; isRunning = false;
timerSeconds = totalDuration; timerSeconds = totalDuration;
<<<<<<< HEAD
sessionStorage.removeItem('fociz_timer_state'); sessionStorage.removeItem('fociz_timer_state');
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
document.getElementById('timerToggleText').innerText = 'Start Focus'; document.getElementById('timerToggleText').innerText = 'Start Focus';
updateTimerDisplay(); updateTimerDisplay();
} }
<<<<<<< HEAD
function saveTimerStateBeforeReload() { function saveTimerStateBeforeReload() {
try { try {
if (isRunning || timerSeconds < totalDuration) { if (isRunning || timerSeconds < totalDuration) {
@@ -1199,8 +1084,6 @@ window.addEventListener('beforeunload', () => {
saveTimerStateBeforeReload(); saveTimerStateBeforeReload();
}); });
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
function selectFocusTask(title) { function selectFocusTask(title) {
document.getElementById('activeTaskDisplay').innerText = title; document.getElementById('activeTaskDisplay').innerText = title;
} }
@@ -1231,7 +1114,6 @@ async function saveGoal() {
} }
} }
<<<<<<< HEAD
// --- Tijdblok Hulpfuncties & Vrije Duur Berekening --- // --- Tijdblok Hulpfuncties & Vrije Duur Berekening ---
function parseTimeToMinutes(str) { function parseTimeToMinutes(str) {
if (!str || typeof str !== 'string') return null; if (!str || typeof str !== 'string') return null;
@@ -1365,8 +1247,6 @@ function setSelectedNewTaskDuration(mins) {
if (durationDisplay) durationDisplay.innerText = `${mins}m`; if (durationDisplay) durationDisplay.innerText = `${mins}m`;
} }
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
function toggleAddTaskForm() { function toggleAddTaskForm() {
const form = document.getElementById('addTaskForm'); const form = document.getElementById('addTaskForm');
form.classList.toggle('hidden'); form.classList.toggle('hidden');
@@ -1376,7 +1256,6 @@ function toggleAddTaskForm() {
} }
function quickSchedule(hour) { function quickSchedule(hour) {
<<<<<<< HEAD
const form = document.getElementById('addTaskForm'); const form = document.getElementById('addTaskForm');
if (form && form.classList.contains('hidden')) { if (form && form.classList.contains('hidden')) {
form.classList.remove('hidden'); form.classList.remove('hidden');
@@ -1389,20 +1268,12 @@ function quickSchedule(hour) {
const outlookCheckbox = document.getElementById('newTaskSyncOutlook'); const outlookCheckbox = document.getElementById('newTaskSyncOutlook');
if (outlookCheckbox) outlookCheckbox.checked = true; if (outlookCheckbox) outlookCheckbox.checked = true;
document.getElementById('newTaskTitle')?.focus(); document.getElementById('newTaskTitle')?.focus();
=======
toggleAddTaskForm();
const timeInput = document.getElementById('newTaskTime');
if (timeInput) timeInput.value = hour;
const outlookCheckbox = document.getElementById('newTaskSyncOutlook');
if (outlookCheckbox) outlookCheckbox.checked = true;
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
} }
async function submitNewTask() { async function submitNewTask() {
const title = document.getElementById('newTaskTitle').value.trim(); const title = document.getElementById('newTaskTitle').value.trim();
const priority = document.getElementById('newTaskPriority').value; const priority = document.getElementById('newTaskPriority').value;
const time = document.getElementById('newTaskTime').value.trim(); const time = document.getElementById('newTaskTime').value.trim();
<<<<<<< HEAD
const endTime = document.getElementById('newTaskEndTime') ? document.getElementById('newTaskEndTime').value.trim() : ''; const endTime = document.getElementById('newTaskEndTime') ? document.getElementById('newTaskEndTime').value.trim() : '';
const duration = getSelectedNewTaskDurationMinutes(); const duration = getSelectedNewTaskDurationMinutes();
const syncOutlook = document.getElementById('newTaskSyncOutlook') ? document.getElementById('newTaskSyncOutlook').checked : false; const syncOutlook = document.getElementById('newTaskSyncOutlook') ? document.getElementById('newTaskSyncOutlook').checked : false;
@@ -1411,12 +1282,6 @@ async function submitNewTask() {
alert('Vul een taaktitel in.'); alert('Vul een taaktitel in.');
return; return;
} }
=======
const duration = document.getElementById('newTaskDuration') ? parseInt(document.getElementById('newTaskDuration').value) : 30;
const syncOutlook = document.getElementById('newTaskSyncOutlook') ? document.getElementById('newTaskSyncOutlook').checked : false;
if (!title) return;
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
try { try {
const res = await fetch('/api/planner.php?action=add_task', { const res = await fetch('/api/planner.php?action=add_task', {
@@ -1425,12 +1290,8 @@ async function submitNewTask() {
body: JSON.stringify({ body: JSON.stringify({
title, title,
priority, priority,
<<<<<<< HEAD
time_block_start: time, time_block_start: time,
time_block_end: endTime, time_block_end: endTime,
=======
time_block_start: time,
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
duration_minutes: duration, duration_minutes: duration,
sync_to_outlook: syncOutlook, sync_to_outlook: syncOutlook,
date: activePlannerDate date: activePlannerDate
@@ -1450,7 +1311,6 @@ async function submitNewTask() {
} }
} }
<<<<<<< HEAD
// --- Taak & Tijdblok Bewerken Modal Logica --- // --- Taak & Tijdblok Bewerken Modal Logica ---
function openEditTaskModal(task) { function openEditTaskModal(task) {
if (!task) return; if (!task) return;
@@ -1639,8 +1499,6 @@ async function submitEditTask() {
} }
} }
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
async function syncTaskToOutlook(taskId, btn) { async function syncTaskToOutlook(taskId, btn) {
if (!btn) return; if (!btn) return;
const originalHtml = btn.innerHTML; const originalHtml = btn.innerHTML;
@@ -1766,7 +1624,6 @@ async function aiSmartSchedule(btn) {
} }
} }
} }
<<<<<<< HEAD
// --- Outlook 365 Auto-Sync & Achtergrond Controle --- // --- Outlook 365 Auto-Sync & Achtergrond Controle ---
const isOutlookConnected = <?= $isOutlookConnected ? 'true' : 'false' ?>; const isOutlookConnected = <?= $isOutlookConnected ? 'true' : 'false' ?>;
let currentSyncHash = '<?= $initialSyncHash ?? '' ?>'; let currentSyncHash = '<?= $initialSyncHash ?? '' ?>';
@@ -1855,8 +1712,6 @@ document.addEventListener('DOMContentLoaded', () => {
}); });
} }
}); });
=======
>>>>>>> dd738e670b78819c11e329da93db1b472808f195
</script> </script>
<?php require_once __DIR__ . '/includes/footer.php'; ?> <?php require_once __DIR__ . '/includes/footer.php'; ?>