Browse Source

fix: SCurve progress bar

pull/11/head
wahyun 4 months ago
parent
commit
84c731370f
  1. 17
      app/Http/Controllers/ProjectController.php

17
app/Http/Controllers/ProjectController.php

@ -415,7 +415,22 @@ class ProjectController extends Controller
public function calculateSCurve(Request $request) public function calculateSCurve(Request $request)
{ {
$sCurve = Project::select('scurve')->where('id', $request->project_id)->first(); $sCurve = Project::select('scurve')->where('id', $request->project_id)->first();
return response()->json(['status' => 'success', 'code' => 200, 'data' => json_decode($sCurve->scurve)], 200); $dcdScurve = json_decode($sCurve['scurve'],true);
$dataScurve = $dcdScurve[0]['data'];
$today = date('Y-m-d');
$progressPlanBar = 0;
foreach($dataScurve['date'] as $index => $dateArray) {
if (isset($dateArray[0])) {
$date = $dateArray[0];
if($date <= $today) {
if (isset($dataScurve['percentagePlan'][$index])) {
$progressPlanBar = round($dataScurve['percentagePlan'][$index], 2);
}
}
}
}
$dcdScurve[0]['data']['progressPlanToDay'] = round($progressPlanBar,2);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dcdScurve], 200);
} }
public function sCurveCommand(Request $request) public function sCurveCommand(Request $request)

Loading…
Cancel
Save