Browse Source

update conflict

pull/3/head
bnu 2 years ago
parent
commit
35fc1b51f8
  1. 56
      app/Http/Controllers/ActivityController.php

56
app/Http/Controllers/ActivityController.php

@ -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')
@ -422,7 +434,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);
@ -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";
@ -573,7 +600,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,
@ -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)

Loading…
Cancel
Save