Browse Source

fix dashboard bod

pull/3/head
wahyu 1 year ago
parent
commit
a19d0ea5cd
  1. 37
      app/Http/Controllers/DashboardBoDController.php

37
app/Http/Controllers/DashboardBoDController.php

@ -133,7 +133,7 @@ class DashboardBoDController extends Controller
]; ];
$projects = Project::where('mulai_proyek', 'like', $year)->get(); $projects = Project::where('mulai_proyek', 'like', $year)->get();
foreach ($projects as $project) { foreach ($projects as $index => $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); $project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$selisihProgress = 0; $selisihProgress = 0;
if ($project->scurve && $project->scurve[0]) { if ($project->scurve && $project->scurve[0]) {
@ -144,12 +144,18 @@ class DashboardBoDController extends Controller
} }
$selisihProgress = $planningProgress - $actualProgress; $selisihProgress = $planningProgress - $actualProgress;
try { try {
if ($selisihProgress > 0 && $selisihProgress <= 5) if ($selisihProgress > 0 && $selisihProgress <= 5){
$return['warning'] += 1; $return['warning'] += 1;
elseif ($selisihProgress == 0) $projects[$index]->status = 'warning';
}
elseif ($selisihProgress == 0){
$return['on-schedule'] += 1; $return['on-schedule'] += 1;
else $projects[$index]->status = 'on-schedule';
}
else {
$return['behind-schedule'] += 1; $return['behind-schedule'] += 1;
$projects[$index]->status = 'behind-schedule';
}
} catch (\Error $e) { } catch (\Error $e) {
return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200); return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200);
} }
@ -163,7 +169,7 @@ class DashboardBoDController extends Controller
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::whereNull('parent')->get(); $divisions = Divisi::whereNull('parent')->get();
foreach ($divisions as $division) { foreach ($divisions as $index => $division) {
$scheduleData = new Collection(); $scheduleData = new Collection();
$behindSchedule = $warning = $onSchedule = 0; $behindSchedule = $warning = $onSchedule = 0;
@ -171,18 +177,29 @@ class DashboardBoDController extends Controller
$projects = Project::where('mulai_proyek', 'like', $year)->where('divisi_id', $division->id)->get(); $projects = Project::where('mulai_proyek', 'like', $year)->where('divisi_id', $division->id)->get();
foreach ($projects as $project) { foreach ($projects as $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); $project->scurve = MasterFunctionsHelper::getSCurve($project->id);
if (@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5) $selisihProgress = 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 (@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100) }
$behindSchedule++; elseif ($selisihProgress == 0){
elseif (@$project->scurve['difference'] == 0)
$onSchedule++; $onSchedule++;
}
else {
$behindSchedule++;
}
} }
$scheduleData->prepend($behindSchedule, 'behindSchedule'); $scheduleData->prepend($behindSchedule, 'behindSchedule');
$scheduleData->prepend($warning, 'warning'); $scheduleData->prepend($warning, 'warning');
$scheduleData->prepend($onSchedule, 'onSchedule'); $scheduleData->prepend($onSchedule, 'onSchedule');
$division->scheduleData = $scheduleData; $divisions[$index]->scheduleData = $scheduleData;
} }
return response()->json([ return response()->json([
'data' => [ 'data' => [

Loading…
Cancel
Save