mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 06:20:21 +00:00
no message
This commit is contained in:
1 parent
a5f6fbd720
commit
c71f0d931d
2 files changed
+16
-8
No files matched your search
@@ -92,4 +92,4 @@ export default {
|
||||
|
||||
.gif-loader
|
||||
height: 30px
|
||||
</style>
|
||||
</style>
|
||||
@@ -433,7 +433,8 @@ class SubTaskController extends Controller
|
||||
*/
|
||||
private function publishDraftWithMultipleEmployees(SubTask $draft, Request $request)
|
||||
{
|
||||
$employees = $draft->draft_data;
|
||||
// Použij employees z requestu ak existujú, inak fallback na draft_data z DB
|
||||
$employees = $request->all()['data']['employees'] ?? $draft->draft_data;
|
||||
|
||||
// Ak je employees pole prázdne, zlyhaj
|
||||
if (empty($employees)) {
|
||||
@@ -453,15 +454,16 @@ class SubTaskController extends Controller
|
||||
// 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;
|
||||
$totalDurationMinutes = 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);
|
||||
$totalDurationMinutes += $end->diffInMinutes($start);
|
||||
}
|
||||
}
|
||||
$employees[$key]['duration'] = $totalDuration;
|
||||
// Konvertuj na hodiny (frontend očakáva hodiny)
|
||||
$employees[$key]['duration'] = $totalDurationMinutes / 60;
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => 'Draft cannot be published. Each employee must have duration or timeblocks.',
|
||||
@@ -477,13 +479,19 @@ class SubTaskController extends Controller
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
// Získame aktuálne hodnoty z requestu (ak existujú), inak fallback na draft
|
||||
$requestData = $request->all()['data'] ?? [];
|
||||
$title = $requestData['title'] ?? $draft->title;
|
||||
$description = $requestData['description'] ?? $draft->description;
|
||||
$deadline = $requestData['deadline'] ?? $draft->deadline;
|
||||
|
||||
// Vytvoríme subtask pre každého zamestnanca
|
||||
foreach ($employees as $employee) {
|
||||
$subtaskData = [
|
||||
'user_id' => $employee['id'],
|
||||
'title' => $draft->title,
|
||||
'description' => $draft->description,
|
||||
'deadline' => $draft->deadline,
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'deadline' => $deadline,
|
||||
'estimated_time' => $employee['duration'],
|
||||
'created_by' => $draft->created_by,
|
||||
'is_draft' => false,
|
||||
|
||||
Reference in new issue
Block a user