Browse Source

fix(dashboard) : update shedule health by divison

pull/1/head
farhantock 6 months ago
parent
commit
2ef8ed5edf
  1. 35
      app/Http/Controllers/DashboardBoDController.php

35
app/Http/Controllers/DashboardBoDController.php

@ -288,42 +288,27 @@ class DashboardBoDController extends Controller
} }
foreach ($divisions as $index => $division) { foreach ($divisions as $index => $division) {
$scheduleData = new Collection();
$behindSchedule = $warning = $onSchedule = 0; $behindSchedule = $warning = $onSchedule = 0;
$projects = Project::where('divisi_id', $division->id)->get(); $projects = Project::where('divisi_id', $division->id)->get();
foreach ($projects as $project) { foreach ($projects as $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); if ($project->schedule_health == 'warning') {
$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) {
$warning++; $warning++;
} elseif ($selisihProgress == 0) { } elseif ($project->schedule_health == 'on-schedule') {
$onSchedule++; $onSchedule++;
} else { } elseif ($project->schedule_health == 'behind-schedule') {
$behindSchedule++; $behindSchedule++;
} }
} }
$scheduleData->prepend($behindSchedule, 'behindSchedule'); $division->scheduleData = [
$scheduleData->prepend($warning, 'warning'); 'behindSchedule' => $behindSchedule,
$scheduleData->prepend($onSchedule, 'onSchedule'); 'warning' => $warning,
$divisions[$index]->scheduleData = $scheduleData; 'onSchedule' => $onSchedule,
];
} }
return response()->json([
'data' => [ return response()->json(['data' => $divisions], 200);
$divisions
]
], 200);
} }
public function getTotalProjectPerBudgetHealth($role_name, $company_id, $all_project, $hierarchy) public function getTotalProjectPerBudgetHealth($role_name, $company_id, $all_project, $hierarchy)

Loading…
Cancel
Save