|
|
|
@ -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(); |
|
|
|
@ -156,7 +155,7 @@ class ActivityController extends Controller
|
|
|
|
|
|
|
|
|
|
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([ |
|
|
|
@ -408,9 +407,20 @@ class ActivityController extends Controller
|
|
|
|
|
$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; |
|
|
|
|
|
|
|
|
|
$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') |
|
|
|
@ -441,7 +451,6 @@ class ActivityController extends Controller
|
|
|
|
|
$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') |
|
|
|
@ -478,21 +487,10 @@ class ActivityController extends Controller
|
|
|
|
|
$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; |
|
|
|
@ -514,7 +512,11 @@ class ActivityController extends Controller
|
|
|
|
|
$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++; |
|
|
|
|
} |
|
|
|
@ -526,7 +528,6 @@ class ActivityController extends Controller
|
|
|
|
|
'plan'=>$dataTempPlan, |
|
|
|
|
'actual'=>$dataTempReport, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if(isset($dataPayload['period']) && $dataPayload['period'] == 'week'){ |
|
|
|
|
if($dt->format("w")==1){ |
|
|
|
|
if($totalACWP > 0 ){ |
|
|
|
@ -544,7 +545,6 @@ class ActivityController extends Controller
|
|
|
|
|
$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; |
|
|
|
@ -561,11 +561,22 @@ class ActivityController extends Controller
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if(round($totalACWP,0) > $totalRencanaBudget){ |
|
|
|
|
$estimatedCost = round($totalACWP,0)+0; |
|
|
|
|
}else{ |
|
|
|
|
$estimatedCost = ($totalRencanaBudget+0); |
|
|
|
|
} |
|
|
|
|
} 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"; |
|
|
|
@ -593,16 +604,20 @@ class ActivityController extends Controller
|
|
|
|
|
"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"), |
|
|
|
|
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); |
|
|
|
|
$data = array( |
|
|
|
|
"last_gantt_id" => $maxGanttId, |
|
|
|
|
"proyek_id" => $id |
|
|
|
|
); |
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setBaseline($gantt_id) |
|
|
|
|