Browse Source

Merge pull request 'fix dashboard' (#106) from dev-wahyu into staging

Reviewed-on: ordo/adw-backend#106
pull/3/head
ibnu 1 year ago
parent
commit
512664aa01
  1. 11
      app/Http/Controllers/DashboardBoDController.php

11
app/Http/Controllers/DashboardBoDController.php

@ -10,6 +10,7 @@ use App\Models\User;
use App\Models\UserToVersionGantt;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class DashboardBoDController extends Controller
{
@ -130,17 +131,19 @@ class DashboardBoDController extends Controller
$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];
$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;
try {
if($selisihProgress > 0 && $selisihProgress <= 5)
$return['warning'] += 1;
elseif($selisihProgress > 5 && $selisihProgress <= 100)
$return['behind-schedule'] += 1;
elseif($selisihProgress == 0)
$return['on-schedule'] += 1;
else
$return['behind-schedule'] += 1;
} catch (\Error $e) {
return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200);
}

Loading…
Cancel
Save