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
+13 -9
View File
@@ -121,14 +121,14 @@ try {
// 6. E-mail direct inplannen in Fociz dagplanning
if ($action === 'plan_email') {
$input = json_decode(file_get_contents('php://input'), true) ?: $_POST;
$messageId = trim($input['message_id'] ?? '');
$subject = trim($input['subject'] ?? 'E-mail actiepunt');
$planDate = trim($input['plan_date'] ?? date('Y-m-d'));
$messageId = trim($input['message_id'] ?? $input['mail_id'] ?? '');
$subject = trim($input['title'] ?? $input['subject'] ?? 'E-mail actiepunt');
$planDate = trim($input['plan_date'] ?? $input['date'] ?? date('Y-m-d'));
$timeBlockStart = !empty($input['time_block_start']) ? trim($input['time_block_start']) : null;
$durationMinutes = (int)($input['duration_minutes'] ?? 30);
$priority = in_array($input['priority'] ?? '', ['P1', 'P2', 'P3']) ? $input['priority'] : 'P2';
$webLink = trim($input['web_link'] ?? 'https://outlook.office.com/mail/');
$sender = trim($input['sender'] ?? '');
$sender = trim($input['sender'] ?? $input['sender_name'] ?? '');
if (empty($subject)) {
echo json_encode(['success' => false, 'error' => 'Onderwerp is verplicht.']);
@@ -137,8 +137,8 @@ try {
if ($durationMinutes <= 0) $durationMinutes = 30;
$timeBlockEnd = null;
if (!empty($timeBlockStart)) {
$timeBlockEnd = !empty($input['time_block_end']) ? trim($input['time_block_end']) : null;
if (!empty($timeBlockStart) && empty($timeBlockEnd)) {
try {
$dtEnd = new DateTime("{$planDate} {$timeBlockStart}:00", new DateTimeZone('Europe/Amsterdam'));
$dtEnd->modify("+{$durationMinutes} minutes");
@@ -155,9 +155,13 @@ try {
$stmtPlan->execute([$userId, $planDate]);
$planId = (int)$db->lastInsertId();
$taskTitle = "✉️ " . $subject;
if (!empty($sender)) {
$taskTitle .= " (van " . $sender . ")";
// Als er een custom titel is ingevoerd, gebruik die direct, anders maak een nette titel
$taskTitle = $subject;
if (isset($input['subject']) && !isset($input['title'])) {
$taskTitle = "✉️ " . $subject;
if (!empty($sender) && strpos($taskTitle, $sender) === false) {
$taskTitle .= " (van " . $sender . ")";
}
}
$stmtTask = $db->prepare("