no message

This commit is contained in:
StudioTem committed 2026-01-09 13:44:27 +01:00
1 parent 34b2dc6526
commit b101da8da5
2 files changed
+24 -5

No files matched your search

+1 -1
View File
@@ -1 +1 @@
VUE_APP_WAXIOS_URL=https://taskmanager.internal.studiotem.com/api/ VUE_APP_WAXIOS_URL=http://127.0.0.1:8001/api/
+23 -4
View File
@@ -418,13 +418,32 @@ class SubTaskController extends Controller
], 400); ], 400);
} }
// Validácia - každý zamestnanec musí mať id a duration // Validácia a doplnenie duration z timeblocks
foreach ($employees as $employee) { foreach ($employees as $key => $employee) {
if (!isset($employee['id']) || !isset($employee['duration'])) { if (!isset($employee['id'])) {
return response()->json([ return response()->json([
'message' => 'Draft cannot be published. Each employee must have id and duration.', 'message' => 'Draft cannot be published. Each employee must have id.',
], 400); ], 400);
} }
// Ak duration nie je nastavený, vypočítaj ho z timeblocks
if (!isset($employee['duration']) || $employee['duration'] === null) {
if (isset($employee['timeblocks']) && !empty($employee['timeblocks'])) {
$totalDuration = 0;
foreach ($employee['timeblocks'] as $timeblock) {
if (isset($timeblock['start']) && isset($timeblock['end'])) {
$start = Carbon::parse($timeblock['start']);
$end = Carbon::parse($timeblock['end']);
$totalDuration += $end->diffInMinutes($start);
}
}
$employees[$key]['duration'] = $totalDuration;
} else {
return response()->json([
'message' => 'Draft cannot be published. Each employee must have duration or timeblocks.',
], 400);
}
}
} }
$mastertask = $draft->mastertask; $mastertask = $draft->mastertask;