From 0a506bdf48c9b6a4774a925a886a39ecad51ac8f Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Wed, 17 May 2023 09:36:03 +0700 Subject: [PATCH] Using current gantt instead of last gantt --- app/Helpers/MasterFunctionsHelper.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index ebd59b3..86197d7 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -54,7 +54,7 @@ class MasterFunctionsHelper { if(!is_int($request)){ $dataPayload = $request->all(); if(isset($dataPayload['gantt_id'])){ - $allGantt = $dataPayload['gantt_id']; + $allGantt[] = $dataPayload['gantt_id']; }else{ $allGantt[] = MasterFunctionsHelper::getLatestGantt($dataPayload['project_id']); } @@ -62,7 +62,15 @@ class MasterFunctionsHelper { $allGantt[] = MasterFunctionsHelper::getLatestGantt($request); } foreach($allGantt as $gantt){ - $gantt = VersionGantt::where('id', $gantt['last_gantt_id'])->first()->toArray(); + if (!isset($gantt['last_gantt_id'])) { + $ganttId = $gantt; + } else { + $ganttId = $gantt['last_gantt_id']; + } + $gantt = VersionGantt::find($ganttId)->toArray(); + // foreach ($gantt as $key => $value) { + // Log::info('gantt '.$value.' index '.$key); + // } if($gantt['calculation_type'] == 'simple') { // to do return MasterFunctionsHelper::calculateProgressBasedOnSimple($gantt);