|
|
@ -157,6 +157,7 @@ class ActivityController extends Controller |
|
|
|
private function getChildrenTemplate($id, $parent_id, $type_proyek_id, $proyek_id, $parent_new, $firstDay) |
|
|
|
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('proyek_type_id', $type_proyek_id)->where('parent_id', $parent_id)->orderByRaw('id ASC')->get(); |
|
|
|
|
|
|
|
dd($data); |
|
|
|
foreach($data as $objRow){ |
|
|
|
foreach($data as $objRow){ |
|
|
|
$childActivities = TemplateGantt::where("parent_id", $objRow->id)->count(); |
|
|
|
$childActivities = TemplateGantt::where("parent_id", $objRow->id)->count(); |
|
|
|
$resultNew = Activity::create([ |
|
|
|
$resultNew = Activity::create([ |
|
|
@ -408,9 +409,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"); |
|
|
|
$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{ |
|
|
|
}else{ |
|
|
|
$totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); |
|
|
|
$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') |
|
|
|
$minDate = DB::table('assign_material_to_activity as ama') |
|
|
|
->where("ama.proyek_id", $keyGantt['proyek_id']) |
|
|
|
->where("ama.proyek_id", $keyGantt['proyek_id']) |
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
@ -502,7 +514,11 @@ class ActivityController extends Controller |
|
|
|
$dataTempReport [$w]['persentase_progress'] = $keyActualM->persentase_progress; |
|
|
|
$dataTempReport [$w]['persentase_progress'] = $keyActualM->persentase_progress; |
|
|
|
$dataTempReport [$w]['percentage'] = ($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; |
|
|
|
$dataTempReport [$w]['percentage'] = ($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; |
|
|
|
$sumPercentageActual+=($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; |
|
|
|
try { |
|
|
|
|
|
|
|
$totalACWP += $keyActualM->biaya_actual/$keyActualM->duration; |
|
|
|
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
|
|
|
return response()->json(['message' => $e->getMessage()]); |
|
|
|
|
|
|
|
} |
|
|
|
$dataTempReport [$w]['totalacwp'] = $totalACWP; |
|
|
|
$dataTempReport [$w]['totalacwp'] = $totalACWP; |
|
|
|
$w++; |
|
|
|
$w++; |
|
|
|
} |
|
|
|
} |
|
|
@ -547,11 +563,22 @@ class ActivityController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(round($totalACWP,0) > $totalRencanaBudget){ |
|
|
|
|
|
|
|
$estimatedCost = round($totalACWP,0)+0; |
|
|
|
try { |
|
|
|
}else{ |
|
|
|
if(round($totalACWP,0) > $totalRencanaBudget){ |
|
|
|
$estimatedCost = ($totalRencanaBudget+0); |
|
|
|
$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; |
|
|
|
$costDeviation = $totalRencanaBudget - $estimatedCost; |
|
|
|
if($costDeviation > 0){ |
|
|
|
if($costDeviation > 0){ |
|
|
|
$potential = "SAVING"; |
|
|
|
$potential = "SAVING"; |
|
|
@ -581,15 +608,18 @@ class ActivityController extends Controller |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data' => $dataFinal], 200); |
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data' => $dataFinal], 200); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function getLatestGantt($id){ |
|
|
|
private function getLatestGantt($id){ |
|
|
|
return array( |
|
|
|
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); |
|
|
|
"last_gantt_id" => VersionGantt::where("proyek_id", $id)->latest(), |
|
|
|
$data = array( |
|
|
|
"proyek_id" => $id |
|
|
|
"last_gantt_id" => $maxGanttId, |
|
|
|
); |
|
|
|
"proyek_id" => $id |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setBaseline($gantt_id) |
|
|
|
public function setBaseline($gantt_id) |
|
|
|