Postits en editable items.
This commit is contained in:
+7
-6
@@ -695,6 +695,7 @@ try {
|
||||
$duration = max(5, (int)($data['duration_minutes'] ?? 30));
|
||||
$excludeTaskId = (int)($data['task_id'] ?? 0);
|
||||
$startFromNextWorkday = !empty($data['start_from_next_workday']);
|
||||
$targetUserId = !empty($data['target_user_id']) ? (int)$data['target_user_id'] : (int)$user['id'];
|
||||
|
||||
$workdaySettings = get_workday_settings();
|
||||
$workdayStartStr = $workdaySettings['workday_start'] ?? '08:30';
|
||||
@@ -757,7 +758,7 @@ try {
|
||||
$rangeEndObj->modify('+21 days'); // ruim venster incl. weekenden
|
||||
$rangeEndDate = $rangeEndObj->format('Y-m-d');
|
||||
|
||||
// 1. Batch SQL: haal alle bestaande taken van de gebruiker in 1 geoptimaliseerde query op
|
||||
// 1. Batch SQL: haal alle bestaande taken van de doelcollega in 1 geoptimaliseerde query op
|
||||
$tasksByDate = [];
|
||||
$stmtTasks = $db->prepare("
|
||||
SELECT t.id, dp.plan_date, t.time_block_start, t.time_block_end, t.duration_minutes
|
||||
@@ -769,7 +770,7 @@ try {
|
||||
AND t.time_block_start != ''
|
||||
AND t.status != 'CANCELLED'
|
||||
");
|
||||
$stmtTasks->execute([$user['id'], $rangeStartDate, $rangeEndDate]);
|
||||
$stmtTasks->execute([$targetUserId, $rangeStartDate, $rangeEndDate]);
|
||||
while ($t = $stmtTasks->fetch()) {
|
||||
if ($excludeTaskId > 0 && (int)$t['id'] === $excludeTaskId) {
|
||||
continue;
|
||||
@@ -777,11 +778,11 @@ try {
|
||||
$tasksByDate[$t['plan_date']][] = $t;
|
||||
}
|
||||
|
||||
// 2. Batch Microsoft Graph: haal alle Outlook events in 1 API call op voor het gehele venster
|
||||
// 2. Batch Microsoft Graph: haal alle Outlook events in 1 API call op voor het gehele venster van de doelcollega
|
||||
$outlookByDate = [];
|
||||
if (function_exists('microsoft_fetch_events_range')) {
|
||||
try {
|
||||
$allOutlookEvts = microsoft_fetch_events_range($user['id'], $rangeStartDate, $rangeEndDate, false);
|
||||
$allOutlookEvts = microsoft_fetch_events_range($targetUserId, $rangeStartDate, $rangeEndDate, false);
|
||||
foreach ($allOutlookEvts as $oe) {
|
||||
if (!empty($oe['date'])) {
|
||||
$outlookByDate[$oe['date']][] = $oe;
|
||||
@@ -790,11 +791,11 @@ try {
|
||||
} catch (Throwable $e) {}
|
||||
}
|
||||
|
||||
// 3. Batch Calendar Blocks: haal verlof en geblokkeerde vakantiedagen op voor dit venster
|
||||
// 3. Batch Calendar Blocks: haal verlof en geblokkeerde vakantiedagen op voor dit venster van de doelcollega
|
||||
$blockedDates = [];
|
||||
try {
|
||||
$stmtBlk = $db->prepare("SELECT start_date, end_date FROM calendar_blocks WHERE user_id = ? AND start_date <= ? AND end_date >= ?");
|
||||
$stmtBlk->execute([$user['id'], $rangeEndDate, $rangeStartDate]);
|
||||
$stmtBlk->execute([$targetUserId, $rangeEndDate, $rangeStartDate]);
|
||||
while ($b = $stmtBlk->fetch()) {
|
||||
$bStart = strtotime($b['start_date']);
|
||||
$bEnd = strtotime($b['end_date']);
|
||||
|
||||
Reference in New Issue
Block a user