Browse Source

bug fix

modified:   app/Http/Controllers/ActivityController.php
	modified:   app/Http/Controllers/ProjectPhaseController.php
pull/3/head
Yusuf 2 years ago
parent
commit
c7a00e2401
  1. 57
      app/Http/Controllers/ActivityController.php
  2. 89
      app/Http/Controllers/ProjectPhaseController.php

57
app/Http/Controllers/ActivityController.php

@ -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)

89
app/Http/Controllers/ProjectPhaseController.php

@ -1,4 +1,3 @@
<<<<<<< HEAD
<?php
namespace App\Http\Controllers;
@ -83,91 +82,3 @@ class ProjectPhaseController extends Controller
}
}
=======
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectPhase;
class ProjectPhaseController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
if(!ProjectPhase::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$result = ProjectPhase::find($id))
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$data = ProjectPhase::find($id))
return response()->json(['status'=>'failed','message'=>'data role not found!','code'=>400], 400);
if(!$data->update($request->all()))
return response()->json(['status'=>'failed','message'=>'data project type failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'data project type successfully updated!','code'=>200], 200);
}
public function delete($id)
{
if(!$data = ProjectPhase::find($id))
return response()->json(['status'=>'failed','message'=>'data project type not found!','code'=>400], 400);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'data project type failed deleted!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'data project type successfully deleted!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
dd($payload);
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_phase');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list()
{
$data = ProjectPhase::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list project type, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}
>>>>>>> 3ef5875 (Dashboard PMO & Project Phase)

Loading…
Cancel
Save