mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +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
|
.gif-loader
|
||||||
height: 30px
|
height: 30px
|
||||||
</style>
|
</style>
|
||||||
@@ -433,7 +433,8 @@ class SubTaskController extends Controller
|
|||||||
*/
|
*/
|
||||||
private function publishDraftWithMultipleEmployees(SubTask $draft, Request $request)
|
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
|
// Ak je employees pole prázdne, zlyhaj
|
||||||
if (empty($employees)) {
|
if (empty($employees)) {
|
||||||
@@ -453,15 +454,16 @@ class SubTaskController extends Controller
|
|||||||
// Ak duration nie je nastavený, vypočítaj ho z timeblocks
|
// Ak duration nie je nastavený, vypočítaj ho z timeblocks
|
||||||
if (! isset($employee['duration']) || $employee['duration'] === null) {
|
if (! isset($employee['duration']) || $employee['duration'] === null) {
|
||||||
if (isset($employee['timeblocks']) && ! empty($employee['timeblocks'])) {
|
if (isset($employee['timeblocks']) && ! empty($employee['timeblocks'])) {
|
||||||
$totalDuration = 0;
|
$totalDurationMinutes = 0;
|
||||||
foreach ($employee['timeblocks'] as $timeblock) {
|
foreach ($employee['timeblocks'] as $timeblock) {
|
||||||
if (isset($timeblock['start']) && isset($timeblock['end'])) {
|
if (isset($timeblock['start']) && isset($timeblock['end'])) {
|
||||||
$start = Carbon::parse($timeblock['start']);
|
$start = Carbon::parse($timeblock['start']);
|
||||||
$end = Carbon::parse($timeblock['end']);
|
$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 {
|
} else {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'message' => 'Draft cannot be published. Each employee must have duration or timeblocks.',
|
'message' => 'Draft cannot be published. Each employee must have duration or timeblocks.',
|
||||||
@@ -477,13 +479,19 @@ class SubTaskController extends Controller
|
|||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
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
|
// Vytvoríme subtask pre každého zamestnanca
|
||||||
foreach ($employees as $employee) {
|
foreach ($employees as $employee) {
|
||||||
$subtaskData = [
|
$subtaskData = [
|
||||||
'user_id' => $employee['id'],
|
'user_id' => $employee['id'],
|
||||||
'title' => $draft->title,
|
'title' => $title,
|
||||||
'description' => $draft->description,
|
'description' => $description,
|
||||||
'deadline' => $draft->deadline,
|
'deadline' => $deadline,
|
||||||
'estimated_time' => $employee['duration'],
|
'estimated_time' => $employee['duration'],
|
||||||
'created_by' => $draft->created_by,
|
'created_by' => $draft->created_by,
|
||||||
'is_draft' => false,
|
'is_draft' => false,
|
||||||
|
|||||||
Reference in new issue
Block a user