Browse Source

Merge pull request 'Dev-Farhan' (#232) from Dev-Farhan into general

Reviewed-on: ordo/adw-backend#232
pull/3/head
farhantock 11 months ago
parent
commit
890fe7b6be
  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();
foreach ($projects as $project) {
foreach ($projects as $index => $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$selisihProgress = 0;
if ($project->scurve && $project->scurve[0]) {
@ -144,12 +144,18 @@ class DashboardBoDController extends Controller
}
$selisihProgress = $planningProgress - $actualProgress;
try {
if ($selisihProgress > 0 && $selisihProgress <= 5)
if ($selisihProgress > 0 && $selisihProgress <= 5){
$return['warning'] += 1;
elseif ($selisihProgress == 0)
$projects[$index]->status = 'warning';
}
elseif ($selisihProgress == 0){
$return['on-schedule'] += 1;
else
$projects[$index]->status = 'on-schedule';
}
else {
$return['behind-schedule'] += 1;
$projects[$index]->status = 'behind-schedule';
}
} catch (\Error $e) {
return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200);
}
@ -163,7 +169,7 @@ class DashboardBoDController extends Controller
$year = $this->interpolateYear($year);
$divisions = Divisi::whereNull('parent')->get();
foreach ($divisions as $division) {
foreach ($divisions as $index => $division) {
$scheduleData = new Collection();
$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();
foreach ($projects as $project) {
$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++;
elseif (@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100)
$behindSchedule++;
elseif (@$project->scurve['difference'] == 0)
}
elseif ($selisihProgress == 0){
$onSchedule++;
}
else {
$behindSchedule++;
}
}
$scheduleData->prepend($behindSchedule, 'behindSchedule');
$scheduleData->prepend($warning, 'warning');
$scheduleData->prepend($onSchedule, 'onSchedule');
$division->scheduleData = $scheduleData;
$divisions[$index]->scheduleData = $scheduleData;
}
return response()->json([
'data' => [

Loading…
Cancel
Save