Aanpassingen planner en ai

This commit is contained in:
2026-09-12 13:24:00 +02:00
parent bc33c0bd1a
commit 8714038db2
5 changed files with 1173 additions and 142 deletions
+47 -4
View File
@@ -271,20 +271,22 @@ try {
}
}
$description = isset($data['description']) ? trim((string)$data['description']) : ($existingTask['description'] ?? null);
if ($newPlanId) {
$stmtUpdate = $db->prepare("
UPDATE tasks
SET title = ?, priority = ?, time_block_start = ?, time_block_end = ?, duration_minutes = ?, daily_plan_id = ?
SET title = ?, description = ?, priority = ?, time_block_start = ?, time_block_end = ?, duration_minutes = ?, daily_plan_id = ?
WHERE id = ? AND user_id = ?
");
$stmtUpdate->execute([$title, $priority, $timeBlockStart, $timeBlockEnd, $durationMinutes, $newPlanId, $taskId, $user['id']]);
$stmtUpdate->execute([$title, $description, $priority, $timeBlockStart, $timeBlockEnd, $durationMinutes, $newPlanId, $taskId, $user['id']]);
} else {
$stmtUpdate = $db->prepare("
UPDATE tasks
SET title = ?, priority = ?, time_block_start = ?, time_block_end = ?, duration_minutes = ?
SET title = ?, description = ?, priority = ?, time_block_start = ?, time_block_end = ?, duration_minutes = ?
WHERE id = ? AND user_id = ?
");
$stmtUpdate->execute([$title, $priority, $timeBlockStart, $timeBlockEnd, $durationMinutes, $taskId, $user['id']]);
$stmtUpdate->execute([$title, $description, $priority, $timeBlockStart, $timeBlockEnd, $durationMinutes, $taskId, $user['id']]);
}
echo json_encode([
@@ -645,6 +647,47 @@ try {
exit;
}
// 10b. Volledige taakdetails ophalen inclusief subtaken en dagplan informatie
if ($action === 'get_task_details') {
$taskId = (int)($_GET['task_id'] ?? ($_POST['task_id'] ?? 0));
if (!$taskId) {
echo json_encode(['error' => 'Taak-ID ontbreekt']);
exit;
}
$stmt = $db->prepare("
SELECT t.*, dp.plan_date, dp.focus_goal
FROM tasks t
LEFT JOIN daily_plans dp ON t.daily_plan_id = dp.id
WHERE t.id = ? AND t.user_id = ?
");
$stmt->execute([$taskId, $user['id']]);
$task = $stmt->fetch();
if (!$task) {
echo json_encode(['error' => 'Taak niet gevonden']);
exit;
}
// Subtaken ophalen
$stmtSub = $db->prepare("
SELECT id, task_id, title, is_completed, position, created_at
FROM task_subtasks
WHERE task_id = ? AND user_id = ?
ORDER BY position ASC, created_at ASC
");
$stmtSub->execute([$taskId, $user['id']]);
$subtasks = $stmtSub->fetchAll();
echo json_encode([
'success' => true,
'task' => $task,
'subtasks' => $subtasks,
]);
exit;
}
// 11. Zoek eerstvolgende vrije open blok binnen werktijden (Release v2.1)
if ($action === 'find_next_free_slot') {
$rawInput = json_decode(file_get_contents('php://input'), true);