|
|
|
@ -132,8 +132,7 @@ class ActivityController extends Controller
|
|
|
|
|
'created_by'=>$this->currentName, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$resultTypeProject = TemplateGantt::where('proyek_type_id',$project |
|
|
|
|
->type_proyek_id) |
|
|
|
|
$resultTypeProject = TemplateGantt::where('proyek_type_id', $project->type_proyek_id) |
|
|
|
|
->whereNull('parent_id') |
|
|
|
|
->orderByRaw('id ASC') |
|
|
|
|
->get(); |
|
|
|
@ -150,13 +149,13 @@ class ActivityController extends Controller
|
|
|
|
|
'end_date'=>date("Y-m-d H:i:s"), |
|
|
|
|
'created_by'=>$this->currentName |
|
|
|
|
]); |
|
|
|
|
$this->getChildrenTemplate($id, $objRow->id, $project->type_project_id ,$proyek_id, $resultNew->id, $project->mulai_proyek); |
|
|
|
|
$this->getChildrenTemplate($id, $objRow->id, $project->type_project_id, $proyek_id, $resultNew->id, $project->mulai_proyek); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function getChildrenTemplate($id, $parent_id, $type_proyek_id, $proyek_id, $parent_new, $firstDay) |
|
|
|
|
{ |
|
|
|
|
$data = TemplateGantt::where('proyek_type_id', $type_proyek_id)->where('parent_id', $parent_id)->orderByRaw('id ASC')->get(); |
|
|
|
|
$data = TemplateGantt::where('parent_id', $parent_id)->orderByRaw('id ASC')->get(); |
|
|
|
|
foreach($data as $objRow){ |
|
|
|
|
$childActivities = TemplateGantt::where("parent_id", $objRow->id)->count(); |
|
|
|
|
$resultNew = Activity::create([ |
|
|
|
@ -401,208 +400,224 @@ class ActivityController extends Controller
|
|
|
|
|
} |
|
|
|
|
$dataFinal=[]; |
|
|
|
|
foreach ($allGantt as $keyGantt) { |
|
|
|
|
$dataProject = Project::find($keyGantt['proyek_id']); |
|
|
|
|
$dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->first(); |
|
|
|
|
$dataProject = Project::find($keyGantt['proyek_id']); |
|
|
|
|
$dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->first(); |
|
|
|
|
|
|
|
|
|
if($dataHeader){ |
|
|
|
|
$totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); |
|
|
|
|
}else{ |
|
|
|
|
$totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); |
|
|
|
|
if($dataHeader){ |
|
|
|
|
$totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); |
|
|
|
|
}else{ |
|
|
|
|
$totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if(!Activity::where("version_gantt_id", $keyGantt['last_gantt_id'])->first()) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
$minDate = DB::table('assign_material_to_activity as ama') |
|
|
|
|
->where("ama.proyek_id", $keyGantt['proyek_id']) |
|
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
|
->min("plan_date"); |
|
|
|
|
|
|
|
|
|
$maxDate = DB::table('assign_material_to_activity as ama') |
|
|
|
|
->where("ama.proyek_id", $keyGantt['proyek_id']) |
|
|
|
|
->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); |
|
|
|
|
$interval = \DateInterval::createFromDateString('1 day'); |
|
|
|
|
$period = new \DatePeriod($begin, $interval, $end); |
|
|
|
|
$arr_ActualM = []; |
|
|
|
|
$tempDate = []; |
|
|
|
|
$tempPercentage = []; |
|
|
|
|
$tempTtlPercentPlan=0; |
|
|
|
|
$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') |
|
|
|
|
->select('ama.activity_id', 'ama.qty_planning', 'ama.plan_date', 'ama.start_activity', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress') |
|
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
|
|
->where('ama.proyek_id', '=', $keyGantt['proyek_id']) |
|
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
|
->whereDate('ama.plan_date', $dt->format("Y-m-d")) |
|
|
|
|
->get(); |
|
|
|
|
$dataActualM = DB::table('report_activity_material as ram') |
|
|
|
|
->select('ram.activity_id', 'ram.qty', 'ram.report_date', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress') |
|
|
|
|
->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")) |
|
|
|
|
->get(); |
|
|
|
|
$dataTempPlan = []; |
|
|
|
|
$x = 0; |
|
|
|
|
$sumPercentagePlan=0; |
|
|
|
|
$totalACWP = isset($totalACWP) ? $totalACWP : 0; |
|
|
|
|
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0; |
|
|
|
|
|
|
|
|
|
foreach ($dataPlanM as $keyPlanM) { |
|
|
|
|
$sumVolPlan = DB::table('assign_material_to_activity') |
|
|
|
|
->select('activity_id', DB::raw('SUM(qty_planning) as ttl_qty_plan')) |
|
|
|
|
->where('activity_id', '=', $keyPlanM->activity_id) |
|
|
|
|
->groupBy('activity_id') |
|
|
|
|
->first(); |
|
|
|
|
$dataTempPlan [$x]['activity_id'] = $keyPlanM->activity_id; |
|
|
|
|
$dataTempPlan [$x]['qty_plan'] = $keyPlanM->qty_planning; |
|
|
|
|
$dataTempPlan [$x]['plan_date'] = $keyPlanM->plan_date; |
|
|
|
|
$dataTempPlan [$x]['start_activity'] = $keyPlanM->start_activity; |
|
|
|
|
$dataTempPlan [$x]['bobot_planning'] = $keyPlanM->bobot_planning; |
|
|
|
|
$dataTempPlan [$x]['ttl_plan'] = $sumVolPlan->ttl_qty_plan; |
|
|
|
|
$dataTempPlan [$x]['biaya_actual'] = $keyPlanM->biaya_actual; |
|
|
|
|
$dataTempPlan [$x]['duration'] = $keyPlanM->duration; |
|
|
|
|
$dataTempPlan [$x]['persentase_progress'] = $keyPlanM->persentase_progress; |
|
|
|
|
$dataTempPlan [$x]['percentage'] = ($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning; |
|
|
|
|
|
|
|
|
|
$sumPercentagePlan+=($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning; |
|
|
|
|
try { |
|
|
|
|
$totalBCWP += (((($keyPlanM->persentase_progress*$keyPlanM->bobot_planning)/100)/$keyPlanM->duration)* $totalRencanaBudget)/100; |
|
|
|
|
$dataTempPlan [$x]['totalBCWP'] = $totalBCWP; |
|
|
|
|
$x++; |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
return response()->json(['message' => $e->getMessage(), |
|
|
|
|
'data' => $keyPlanM->persentase_progress, |
|
|
|
|
'data2' => $keyPlanM->bobot_planning, |
|
|
|
|
'data3' => $keyPlanM->duration, |
|
|
|
|
'data4' => $totalRencanaBudget, |
|
|
|
|
'data5' => $keyPlanM, |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$w = 0; |
|
|
|
|
$dataTempReport = []; |
|
|
|
|
$sumPercentageActual=0; |
|
|
|
|
foreach ($dataActualM as $keyActualM) { |
|
|
|
|
$sumVolActual = DB::table('assign_material_to_activity') |
|
|
|
|
->select('activity_id', DB::raw('SUM(qty_planning) as ttl_qty_plan')) |
|
|
|
|
->where('activity_id', '=', $keyActualM->activity_id) |
|
|
|
|
->groupBy('activity_id') |
|
|
|
|
->first(); |
|
|
|
|
$dataTempReport [$w]['activity_id'] = $keyActualM->activity_id; |
|
|
|
|
$dataTempReport [$w]['qty'] = $keyActualM->qty; |
|
|
|
|
$dataTempReport [$w]['report_date'] = $keyActualM->report_date; |
|
|
|
|
$dataTempReport [$w]['bobot_planning'] = $keyActualM->bobot_planning; |
|
|
|
|
$dataTempReport [$w]['ttl_plan'] = $sumVolActual->ttl_qty_plan; |
|
|
|
|
$dataTempReport [$w]['biaya_actual'] = $keyActualM->biaya_actual; |
|
|
|
|
$dataTempReport [$w]['duration'] = $keyActualM->duration; |
|
|
|
|
$dataTempReport [$w]['persentase_progress'] = $keyActualM->persentase_progress; |
|
|
|
|
$dataTempReport [$w]['percentage'] = ($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; |
|
|
|
|
$sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; |
|
|
|
|
$totalACWP += $keyActualM->biaya_actual/$keyActualM->duration; |
|
|
|
|
$dataTempReport [$w]['totalacwp'] = $totalACWP; |
|
|
|
|
$w++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$arr_ActualM[] = array( |
|
|
|
|
'date'=>$dt->format("Y-m-d"), |
|
|
|
|
'percentPlan'=>$sumPercentagePlan, |
|
|
|
|
'percentActual'=>$sumPercentageActual, |
|
|
|
|
'plan'=>$dataTempPlan, |
|
|
|
|
'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; |
|
|
|
|
|
|
|
|
|
$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")) { |
|
|
|
|
// error here |
|
|
|
|
$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{ |
|
|
|
|
$tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); |
|
|
|
|
$tempDate[] = array($dt->format("Y-m-d"), 0, 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$alreadyHasReport = DB::table('report_activity_material as a') |
|
|
|
|
->select('a.id') |
|
|
|
|
->join('m_activity as b', 'b.id', '=', 'a.activity_id') |
|
|
|
|
->where('b.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
|
->exists(); |
|
|
|
|
|
|
|
|
|
if(!$alreadyHasReport) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
$minDate = DB::table('assign_material_to_activity as ama') |
|
|
|
|
->where("ama.proyek_id", $keyGantt['proyek_id']) |
|
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
|
->min("plan_date"); |
|
|
|
|
|
|
|
|
|
$maxDate = DB::table('assign_material_to_activity as ama') |
|
|
|
|
->where("ama.proyek_id", $keyGantt['proyek_id']) |
|
|
|
|
->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); |
|
|
|
|
$interval = \DateInterval::createFromDateString('1 day'); |
|
|
|
|
$period = new \DatePeriod($begin, $interval, $end); |
|
|
|
|
$arr_ActualM = []; |
|
|
|
|
$tempDate = []; |
|
|
|
|
$tempPercentage = []; |
|
|
|
|
$tempTtlPercentPlan=0; |
|
|
|
|
$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') |
|
|
|
|
->select('ama.activity_id', 'ama.qty_planning', 'ama.plan_date', 'ama.start_activity', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress') |
|
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
|
|
->where('ama.proyek_id', '=', $keyGantt['proyek_id']) |
|
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
|
->whereDate('ama.plan_date', $dt->format("Y-m-d")) |
|
|
|
|
->get(); |
|
|
|
|
$dataActualM = DB::table('report_activity_material as ram') |
|
|
|
|
->select('ram.activity_id', 'ram.qty', 'ram.report_date', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress') |
|
|
|
|
->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")) |
|
|
|
|
->get(); |
|
|
|
|
$dataTempPlan = []; |
|
|
|
|
$x = 0; |
|
|
|
|
$sumPercentagePlan=0; |
|
|
|
|
$totalACWP = isset($totalACWP) ? $totalACWP : 0; |
|
|
|
|
$totalBCWP = isset($totalBCWP) ? $totalBCWP : 0; |
|
|
|
|
|
|
|
|
|
foreach ($dataPlanM as $keyPlanM) { |
|
|
|
|
$sumVolPlan = DB::table('assign_material_to_activity') |
|
|
|
|
->select('activity_id', DB::raw('SUM(qty_planning) as ttl_qty_plan')) |
|
|
|
|
->where('activity_id', '=', $keyPlanM->activity_id) |
|
|
|
|
->groupBy('activity_id') |
|
|
|
|
->first(); |
|
|
|
|
$dataTempPlan [$x]['activity_id'] = $keyPlanM->activity_id; |
|
|
|
|
$dataTempPlan [$x]['qty_plan'] = $keyPlanM->qty_planning; |
|
|
|
|
$dataTempPlan [$x]['plan_date'] = $keyPlanM->plan_date; |
|
|
|
|
$dataTempPlan [$x]['start_activity'] = $keyPlanM->start_activity; |
|
|
|
|
$dataTempPlan [$x]['bobot_planning'] = $keyPlanM->bobot_planning; |
|
|
|
|
$dataTempPlan [$x]['ttl_plan'] = $sumVolPlan->ttl_qty_plan; |
|
|
|
|
$dataTempPlan [$x]['biaya_actual'] = $keyPlanM->biaya_actual; |
|
|
|
|
$dataTempPlan [$x]['duration'] = $keyPlanM->duration; |
|
|
|
|
$dataTempPlan [$x]['persentase_progress'] = $keyPlanM->persentase_progress; |
|
|
|
|
$dataTempPlan [$x]['percentage'] = ($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning; |
|
|
|
|
$sumPercentagePlan+=($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning; |
|
|
|
|
$totalBCWP += (((($keyPlanM->persentase_progress*$keyPlanM->bobot_planning)/100)/$keyPlanM->duration)* $totalRencanaBudget)/100; |
|
|
|
|
$dataTempPlan [$x]['totalBCWP'] = $totalBCWP; |
|
|
|
|
$x++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$w = 0; |
|
|
|
|
$dataTempReport = []; |
|
|
|
|
$sumPercentageActual=0; |
|
|
|
|
foreach ($dataActualM as $keyActualM) { |
|
|
|
|
$sumVolActual = DB::table('assign_material_to_activity') |
|
|
|
|
->select('activity_id', DB::raw('SUM(qty_planning) as ttl_qty_plan')) |
|
|
|
|
->where('activity_id', '=', $keyActualM->activity_id) |
|
|
|
|
->groupBy('activity_id') |
|
|
|
|
->first(); |
|
|
|
|
$dataTempReport [$w]['activity_id'] = $keyActualM->activity_id; |
|
|
|
|
$dataTempReport [$w]['qty'] = $keyActualM->qty; |
|
|
|
|
$dataTempReport [$w]['report_date'] = $keyActualM->report_date; |
|
|
|
|
$dataTempReport [$w]['bobot_planning'] = $keyActualM->bobot_planning; |
|
|
|
|
$dataTempReport [$w]['ttl_plan'] = $sumVolActual->ttl_qty_plan; |
|
|
|
|
$dataTempReport [$w]['biaya_actual'] = $keyActualM->biaya_actual; |
|
|
|
|
$dataTempReport [$w]['duration'] = $keyActualM->duration; |
|
|
|
|
$dataTempReport [$w]['persentase_progress'] = $keyActualM->persentase_progress; |
|
|
|
|
$dataTempReport [$w]['percentage'] = ($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; |
|
|
|
|
$sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; |
|
|
|
|
try { |
|
|
|
|
$totalACWP += $keyActualM->biaya_actual/$keyActualM->duration; |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
return response()->json(['message' => $e->getMessage()]); |
|
|
|
|
} |
|
|
|
|
$dataTempReport [$w]['totalacwp'] = $totalACWP; |
|
|
|
|
$w++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$arr_ActualM[] = array( |
|
|
|
|
'date'=>$dt->format("Y-m-d"), |
|
|
|
|
'percentPlan'=>$sumPercentagePlan, |
|
|
|
|
'percentActual'=>$sumPercentageActual, |
|
|
|
|
'plan'=>$dataTempPlan, |
|
|
|
|
'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; |
|
|
|
|
|
|
|
|
|
$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{ |
|
|
|
|
$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; |
|
|
|
|
}else{ |
|
|
|
|
$estimatedCost = ($totalRencanaBudget+0); |
|
|
|
|
} |
|
|
|
|
$costDeviation = $totalRencanaBudget - $estimatedCost; |
|
|
|
|
if($costDeviation > 0){ |
|
|
|
|
$potential = "SAVING"; |
|
|
|
|
} else { |
|
|
|
|
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN"; |
|
|
|
|
} |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
return response()->json([ |
|
|
|
|
'message' => $e->getMessage(), |
|
|
|
|
"line" => 566, |
|
|
|
|
'gantt' => $keyGantt, |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
//$estimatedCost = $totalACWP > $totalRencanaBudget ? $totalACWP : $totalRencanaBudget; |
|
|
|
|
|
|
|
|
|
$costDeviation = $totalRencanaBudget - $estimatedCost; |
|
|
|
|
if($costDeviation > 0){ |
|
|
|
|
$potential = "SAVING"; |
|
|
|
|
} else { |
|
|
|
|
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$dataResponse = array( |
|
|
|
|
"date" =>$tempDate, |
|
|
|
|
"percentage" =>$tempPercentage, |
|
|
|
|
"data_details" =>$arr_ActualM, |
|
|
|
|
"budget_control" =>array("current_budget"=> $totalRencanaBudget, |
|
|
|
|
"acwp" => round($totalACWP,0), |
|
|
|
|
"bcwp" => round($totalBCWP,0), |
|
|
|
|
"rem_to_complete" => ($totalRencanaBudget - round($totalACWP,0)), |
|
|
|
|
"add_cost_to_complete" => 0, |
|
|
|
|
"estimated_at_completion" => $estimatedCost, |
|
|
|
|
"cost_deviation" => $costDeviation, |
|
|
|
|
"potential" => $potential, |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$dataFinal[] = array( |
|
|
|
|
"proyek_name"=> $dataProject->nama, |
|
|
|
|
"data"=>$dataResponse, |
|
|
|
|
"allGant"=>$allGantt |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data' => $dataFinal], 200); |
|
|
|
|
$dataResponse = array( |
|
|
|
|
"date" =>$tempDate, |
|
|
|
|
"percentage" =>$tempPercentage, |
|
|
|
|
"data_details" =>$arr_ActualM, |
|
|
|
|
"budget_control" =>array("current_budget"=> $totalRencanaBudget, |
|
|
|
|
"acwp" => round($totalACWP,0), |
|
|
|
|
"bcwp" => round($totalBCWP,0), |
|
|
|
|
"rem_to_complete" => ($totalRencanaBudget - round($totalACWP,0)), |
|
|
|
|
"add_cost_to_complete" => 0, |
|
|
|
|
"estimated_at_completion" => $estimatedCost, |
|
|
|
|
"cost_deviation" => $costDeviation, |
|
|
|
|
"potential" => $potential, |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$dataFinal[] = array( |
|
|
|
|
"proyek_name"=> $dataProject->nama, |
|
|
|
|
"data"=>$dataResponse, |
|
|
|
|
"allGant"=>$allGantt |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data' => $dataFinal], 200); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function getLatestGantt($id){ |
|
|
|
|
return array( |
|
|
|
|
"last_gantt_id" => VersionGantt::where("proyek_id", $id)->max("id"), |
|
|
|
|
"proyek_id" => $id |
|
|
|
|
); |
|
|
|
|
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); |
|
|
|
|
$data = array( |
|
|
|
|
"last_gantt_id" => $maxGanttId, |
|
|
|
|
"proyek_id" => $id |
|
|
|
|
); |
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setBaseline($gantt_id) |
|
|
|
|