diff --git a/api/board.php b/api/board.php index 303e115..0247d2f 100644 --- a/api/board.php +++ b/api/board.php @@ -486,6 +486,101 @@ try { exit; } + // 10. Tijdlijn Datums Snel Bijwerken (Startdatum & Einddatum via Gantt drag) + if ($action === 'update_card_dates') { + $cardId = (int)($input['card_id'] ?? 0); + $startDate = trim($input['start_date'] ?? ''); + $endDate = trim($input['end_date'] ?? $startDate); + + if (!$cardId || !$startDate) { + echo json_encode(['success' => false, 'error' => 'Ongeldige parameters.']); + exit; + } + + $stmtCard = $db->prepare("SELECT * FROM board_cards WHERE id = ?"); + $stmtCard->execute([$cardId]); + $card = $stmtCard->fetch(); + if (!$card) { + echo json_encode(['success' => false, 'error' => 'Taak niet gevonden.']); + exit; + } + + if (!check_board_access($db, (int)$card['board_id'], $userId, $isAdmin)) { + http_response_code(403); + echo json_encode(['success' => false, 'error' => 'Geen toegang tot dit bord.']); + exit; + } + + $stmtSched = $db->prepare(" + INSERT INTO board_card_schedules (card_id, schedule_type, start_date, end_date, start_time, end_time, days_of_week) + VALUES (?, 'DAILY_RANGE', ?, ?, '09:00', '17:00', '1,2,3,4,5') + ON DUPLICATE KEY UPDATE + start_date = VALUES(start_date), + end_date = VALUES(end_date), + schedule_type = 'DAILY_RANGE' + "); + $stmtSched->execute([$cardId, $startDate, $endDate]); + + echo json_encode([ + 'success' => true, + 'card_id' => $cardId, + 'start_date' => $startDate, + 'end_date' => $endDate, + 'message' => 'Tijdlijn bijgewerkt!' + ]); + exit; + } + + // 11. Snelle Inline Taak Aanmaken (⚡ Wat moet er gedaan worden?) + if ($action === 'quick_create_card') { + $boardId = (int)($input['board_id'] ?? 0); + $title = trim($input['title'] ?? ''); + $laneId = (int)($input['lane_id'] ?? 0); + $startDate = !empty($input['start_date']) ? trim($input['start_date']) : null; + $endDate = !empty($input['end_date']) ? trim($input['end_date']) : $startDate; + + if (!$boardId || empty($title)) { + echo json_encode(['success' => false, 'error' => 'Vul een titel in voor de taak.']); + exit; + } + + if (!check_board_access($db, $boardId, $userId, $isAdmin)) { + http_response_code(403); + echo json_encode(['success' => false, 'error' => 'Geen toegang tot dit bord.']); + exit; + } + + // Als geen lane_id is meegegeven, pak de 1e lane van het bord + if ($laneId <= 0) { + $laneId = (int)$db->query("SELECT id FROM board_lanes WHERE board_id = {$boardId} ORDER BY position ASC, id ASC LIMIT 1")->fetchColumn(); + } + + $maxPos = (int)$db->query("SELECT COALESCE(MAX(position), -1) FROM board_cards WHERE lane_id = {$laneId}")->fetchColumn(); + $stmt = $db->prepare(" + INSERT INTO board_cards (board_id, lane_id, title, description, assignee_id, priority, color, position, created_by_id) + VALUES (?, ?, ?, '', NULL, 'P2', 'yellow', ?, ?) + "); + $stmt->execute([$boardId, $laneId, $title, $maxPos + 1, $userId]); + $newCardId = (int)$db->lastInsertId(); + + // Optioneel datums toekennen + if ($startDate) { + $stmtSched = $db->prepare(" + INSERT INTO board_card_schedules (card_id, schedule_type, start_date, end_date, start_time, end_time, days_of_week) + VALUES (?, 'DAILY_RANGE', ?, ?, '09:00', '17:00', '1,2,3,4,5') + "); + $stmtSched->execute([$newCardId, $startDate, $endDate]); + } + + echo json_encode([ + 'success' => true, + 'card_id' => $newCardId, + 'lane_id' => $laneId, + 'message' => 'Taak direct toegevoegd!' + ]); + exit; + } + echo json_encode(['success' => false, 'error' => 'Onbekende actie.']); } catch (Throwable $e) { error_log("Fociz Board API Fout: " . $e->getMessage()); diff --git a/board.php b/board.php index 7d2c47f..c7888a0 100644 --- a/board.php +++ b/board.php @@ -50,6 +50,18 @@ $isAdmin = ($userRole === 'ADMIN'); + +
+ + + Bord + + + + Tijdlijn + +
+
@@ -446,6 +458,10 @@ const LANE_ACCENT_COLORS = { // 1. Initialisatie document.addEventListener('DOMContentLoaded', async () => { + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.get('board_id')) { + currentBoardId = parseInt(urlParams.get('board_id'), 10); + } await loadBoardsList(); }); @@ -494,6 +510,7 @@ function onBoardSelectChange(bId) { // 2. Data van specifiek bord inladen async function loadBoardData(boardId) { currentBoardId = boardId; + document.getElementById('linkToTimeline')?.setAttribute('href', `/timeline.php?board_id=${boardId}`); const container = document.getElementById('boardLanesContainer'); container.innerHTML = `
diff --git a/includes/header.php b/includes/header.php index 64cb522..65889b2 100644 --- a/includes/header.php +++ b/includes/header.php @@ -162,9 +162,9 @@ require_once __DIR__ . '/env_badge.php'; Planning - +
- + + +
+ +
+
+
Tijdlijn
+
Gantt-planning & projectkalender
+
+
+ +
@@ -460,5 +471,5 @@ function focizQuickToggleTheme() { } - +
diff --git a/timeline.php b/timeline.php new file mode 100644 index 0000000..e6945e9 --- /dev/null +++ b/timeline.php @@ -0,0 +1,1079 @@ + + + + +
+ + +
+
+
+ + +
+
+ +
+
+
+ + +
+

+ Gantt-planning, mijlpalen & datumbereiken +

+
+
+ + +
+ + + Bord + + + + Tijdlijn + +
+ + +
+ + +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + + + + + +
+
+
+
+ + +
+
+ +
+ + +
+ + +
+
+ Werk + 0 +
+
Status & Datum
+
+ + +
+
+ + + +
+
+ + +
+ +
+ +
+ + +
+ + +
+ +
+ + +
+ + + + +
+ +
+ +
+ +
+
+ +
+ + + + + + + +