From 18780a09c31e5210cba80e647e0da678757c5b8e Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Tue, 27 Jun 2023 08:41:55 +0700 Subject: [PATCH] Fix project by schedule health --- app/Http/Controllers/DashboardBoDController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 273d568..8e851cb 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -127,13 +127,19 @@ class DashboardBoDController extends Controller $projects = Project::where('mulai_proyek', 'like', $year)->get(); foreach($projects as $project) { - $project->scurve = MasterFunctionsHelper::getSCurve($project->id); + $project->scurve = MasterFunctionsHelper::getSCurve($project->id); + $selisihProgress = 0; + if($project->scurve && $project->scurve[0]){ + $planningProgress = $project->scurve[0]['data']['percentagePlan'][count($project->scurve[0]['data']['percentagePlan'])-1]; + $actualProgress = $project->scurve[0]['data']['percentageReal'][count($project->scurve[0]['data']['percentageReal'])-1]; + } + $selisihProgress = $planningProgress - $actualProgress; try { - if(@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5) + if($selisihProgress > 0 && $selisihProgress <= 5) $return['warning'] += 1; - elseif(@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100) + elseif($selisihProgress > 5 && $selisihProgress <= 100) $return['behind-schedule'] += 1; - elseif(@$project->scurve['difference'] == 0) + elseif($selisihProgress == 0) $return['on-schedule'] += 1; } catch (\Error $e) { return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200);