Browse Source

fix s-curve

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

Loading…
Cancel
Save