From 2ef8ed5edf255fe01d51e65358f97efdc4ee4f6f Mon Sep 17 00:00:00 2001 From: farhantock Date: Wed, 22 May 2024 20:10:27 +0700 Subject: [PATCH] fix(dashboard) : update shedule health by divison --- .../Controllers/DashboardBoDController.php | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 3303af9..77ad72b 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -288,42 +288,27 @@ class DashboardBoDController extends Controller } foreach ($divisions as $index => $division) { - $scheduleData = new Collection(); $behindSchedule = $warning = $onSchedule = 0; $projects = Project::where('divisi_id', $division->id)->get(); foreach ($projects as $project) { - $project->scurve = MasterFunctionsHelper::getSCurve($project->id); - $selisihProgress = 0; - $planningProgress = 0; - $actualProgress = 0; - - if ($project->scurve && $project->scurve[0]) { - $planningArray = $project->scurve[0]['data']['percentagePlan']; - $actualArray = $project->scurve[0]['data']['percentageReal']; - $planningProgress = !empty($planningArray) ? $planningArray[count($planningArray) - 1] : 0; - $actualProgress = !empty($actualArray) ? $actualArray[count($actualArray) - 1] : 0; - } - $selisihProgress = $planningProgress - $actualProgress; - if ($selisihProgress > 0 && $selisihProgress <= 5) { + if ($project->schedule_health == 'warning') { $warning++; - } elseif ($selisihProgress == 0) { + } elseif ($project->schedule_health == 'on-schedule') { $onSchedule++; - } else { + } elseif ($project->schedule_health == 'behind-schedule') { $behindSchedule++; } } - $scheduleData->prepend($behindSchedule, 'behindSchedule'); - $scheduleData->prepend($warning, 'warning'); - $scheduleData->prepend($onSchedule, 'onSchedule'); - $divisions[$index]->scheduleData = $scheduleData; + $division->scheduleData = [ + 'behindSchedule' => $behindSchedule, + 'warning' => $warning, + 'onSchedule' => $onSchedule, + ]; } - return response()->json([ - 'data' => [ - $divisions - ] - ], 200); + + return response()->json(['data' => $divisions], 200); } public function getTotalProjectPerBudgetHealth($role_name, $company_id, $all_project, $hierarchy)