Browse Source

fix s-curve

pull/3/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
b547aa1d3a
  1. 56
      app/Http/Controllers/ActivityController.php

56
app/Http/Controllers/ActivityController.php

@ -389,6 +389,7 @@ class ActivityController extends Controller
public function getCalculateCurvaS(Request $request) // for adw (plan & actual == date)
{
DB::enableQueryLog();
$dataPayload = $request->all();
$allGantt = [];
if(isset($dataPayload['gannt_id'])){
@ -417,7 +418,7 @@ class ActivityController extends Controller
->join('m_activity as b', 'b.id', '=', 'a.activity_id')
->where('b.version_gantt_id', '=', $keyGantt['last_gantt_id'])
->exists();
if(!$alreadyHasReport)
continue;
@ -432,7 +433,7 @@ class ActivityController extends Controller
->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id'])
->max("plan_date");
$begin = new \DateTime($minDate);
$end = new \DateTime($maxDate);
$end2 = new \DateTime($maxDate);
@ -445,10 +446,7 @@ class ActivityController extends Controller
$tempTtlPercentActual=0;
$currentACWP = 0;
$budgetControlACWP = 0;
$currentProgressActivity = 0;
$currentBCWP = 0;
$budgetControlBCWP = 0;
foreach ($period as $dt) {
$dataPlanM = DB::table('assign_material_to_activity as ama')
@ -463,8 +461,11 @@ class ActivityController extends Controller
->join('m_activity as a', 'a.id', '=', 'ram.activity_id')
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id'])
->where('a.proyek_id', '=', $keyGantt['proyek_id'])
->whereDate('ram.report_date', $dt->format("Y-m-d"))
/* ->whereDate('ram.report_date', $dt->format("Y-m-d")) */
->whereDate('ram.report_date', '2021-11-08')
->get();
/* dd($dt->format('Y-m-d')); */
dd($dataActualM);
$dataTempPlan = [];
$x = 0;
$sumPercentagePlan=0;
@ -516,7 +517,7 @@ class ActivityController extends Controller
$totalACWP += $keyActualM->biaya_actual/$keyActualM->duration;
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()]);
}
}
$dataTempReport [$w]['totalacwp'] = $totalACWP;
$w++;
}
@ -529,39 +530,20 @@ class ActivityController extends Controller
'actual'=>$dataTempReport,
);
if(isset($dataPayload['period']) && $dataPayload['period'] == 'week'){
if($dt->format("w")==1){
if($totalACWP > 0 ){
$budgetControlACWP = $currentACWP + $totalACWP;
}
if($totalBCWP > 0 ){
$budgetControlBCWP = $currentBCWP + $totalBCWP;
}
$tempTtlPercentPlan+= $sumPercentagePlan;
$tempTtlPercentActual+= $sumPercentageActual;
$currentACWP += $totalACWP;
$currentBCWP += $totalBCWP;
$tempTtlPercentPlan+= $sumPercentagePlan;
$tempTtlPercentActual+= $sumPercentageActual;
$currentACWP += $totalACWP;
$currentBCWP += $totalBCWP;
$tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2));
$tempDate[] = array($dt->format("Y-m-d"), 0, 0);
}else if($dt->format("Y-m-d") == $end2->format("Y-m-d")) {
$tempTtlPercentPlan+= $sumPercentagePlan;
$tempTtlPercentActual+= $sumPercentageActual;
$currentACWP += $totalACWP;
$currentBCWP += $totalBCWP;
$tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2));
$tempDate[] = array($dt->format("Y-m-d"), 0, 0);
$tempTtlPercentPlan = 0;
$tempTtlPercentActual = 0;
}
$tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2));
$tempDate[] = array($dt->format("Y-m-d"), 0, 0);
}else{
$tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2));
$tempDate[] = array($dt->format("Y-m-d"), 0, 0);
}
}
try {
if(round($totalACWP,0) > $totalRencanaBudget){
$estimatedCost = round($totalACWP,0)+0;
@ -570,13 +552,13 @@ class ActivityController extends Controller
}
} catch (\Exception $e) {
return response()->json([
'message' => $e->getMessage(),
'message' => $e->getMessage(),
"line" => 566,
'gantt' => $keyGantt,
]);
}
//$estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget;
$estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget;
$costDeviation = $totalRencanaBudget - $estimatedCost;
if($costDeviation > 0){
$potential = "SAVING";
@ -598,7 +580,7 @@ class ActivityController extends Controller
"potential" => $potential,
)
);
$dataFinal[] = array(
"proyek_name"=> $dataProject->nama,
"data"=>$dataResponse,

Loading…
Cancel
Save