|
|
|
@ -336,18 +336,20 @@ class ProjectController extends Controller
|
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function getCalculateCurvaS(Request $request) // for adw (plan & actual == date) |
|
|
|
|
public function getSCurve(Request $request) |
|
|
|
|
{ |
|
|
|
|
DB::enableQueryLog(); |
|
|
|
|
$dataPayload = $request->all(); |
|
|
|
|
/* print_r($dataPayload); exit(); */ |
|
|
|
|
|
|
|
|
|
$allGantt = []; |
|
|
|
|
if(isset($dataPayload['gannt_id'])){ |
|
|
|
|
$allGantt = $dataPayload['gannt_id']; |
|
|
|
|
|
|
|
|
|
if(isset($dataPayload['gantt_id'])){ |
|
|
|
|
$allGantt = $dataPayload['gantt_id']; |
|
|
|
|
}else{ |
|
|
|
|
foreach ($dataPayload['project_id'] as $val) { |
|
|
|
|
$allGantt[] = $this->getLatestGantt($val); |
|
|
|
|
} |
|
|
|
|
$allGantt[] = $this->getLatestGantt($dataPayload['project_id']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$dataFinal=[]; |
|
|
|
|
foreach ($allGantt as $keyGantt) { |
|
|
|
|
$dataProject = Project::find($keyGantt['proyek_id']); |
|
|
|
@ -376,21 +378,29 @@ class ProjectController extends Controller
|
|
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
|
->min("plan_date"); |
|
|
|
|
/* ->min("planned_Start"); */ |
|
|
|
|
|
|
|
|
|
$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->modify('-1 days'), $interval, $end); |
|
|
|
|
->max("planned_end"); |
|
|
|
|
/* ->whereNull('deleted_at') */ |
|
|
|
|
/* ->get(); */ |
|
|
|
|
/* ->max("plan_date"); */ // plan date overlapped with assign_material_to_activity's, it should be m_activity's |
|
|
|
|
/* print_r($maxDate); exit(); */ |
|
|
|
|
|
|
|
|
|
$begin = new \DateTime($minDate.' Monday'); |
|
|
|
|
$end = new \DateTime($maxDate. ' Friday'); |
|
|
|
|
$interval = new \DateInterval('P7D'); |
|
|
|
|
// timezone problems in KIT case also occurs in here |
|
|
|
|
$period = new \DatePeriod($begin, $interval, $end); |
|
|
|
|
/* $period = new \DatePeriod($begin->modify('-1 days'), $interval, $end); */ |
|
|
|
|
$arr_ActualM = []; |
|
|
|
|
$tempDate = []; |
|
|
|
|
$tempPercentage = []; |
|
|
|
|
$tempPercentagePlan = []; |
|
|
|
|
$tempPercentagePlanWhr = []; |
|
|
|
|
$tempPercentageReal = []; |
|
|
|
|
$tempTtlPercentPlan=0; |
|
|
|
|
$tempTtlPercentActual=0; |
|
|
|
|
|
|
|
|
@ -482,9 +492,14 @@ class ProjectController extends Controller
|
|
|
|
|
$currentBCWP += $totalBCWP; |
|
|
|
|
|
|
|
|
|
$tempPercentage[] = array(round($tempTtlPercentPlan,2), round($tempTtlPercentActual,2)); |
|
|
|
|
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2); |
|
|
|
|
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; |
|
|
|
|
$tempPercentageReal[] = round($tempTtlPercentActual, 2); |
|
|
|
|
$tempDate[] = array($dt->format("Y-m-d"), 0, 0); |
|
|
|
|
}else{ |
|
|
|
|
$tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); |
|
|
|
|
$tempPercentagePlan[] = round($sumPercentagePlan, 2); |
|
|
|
|
$tempPercentageReal[] = round($sumPercentageActual, 2); |
|
|
|
|
$tempDate[] = array($dt->format("Y-m-d"), 0, 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -515,6 +530,8 @@ class ProjectController extends Controller
|
|
|
|
|
$dataResponse = array( |
|
|
|
|
"date" =>$tempDate, |
|
|
|
|
"percentage" =>$tempPercentage, |
|
|
|
|
"percentagePlan" => $tempPercentagePlan, |
|
|
|
|
"percentageReal" => $tempPercentageReal, |
|
|
|
|
"data_details" =>$arr_ActualM, |
|
|
|
|
"budget_control" =>array("current_budget"=> $totalRencanaBudget, |
|
|
|
|
"acwp" => round($totalACWP,0), |
|
|
|
@ -644,5 +661,74 @@ class ProjectController extends Controller
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function detail($id){ |
|
|
|
|
if(empty($id) || !is_int((int)$id)) |
|
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
|
|
|
|
|
|
$result = Project::find($id); |
|
|
|
|
|
|
|
|
|
if(!$result) |
|
|
|
|
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); |
|
|
|
|
|
|
|
|
|
$gantt = $this->getLatestGantt($id); |
|
|
|
|
$result->projectManager = User::where('id', $result->pm_id)->value('name'); |
|
|
|
|
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $gantt['last_gantt_id'])->first(); |
|
|
|
|
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function synchronizeReport($gantt_id) |
|
|
|
|
{ |
|
|
|
|
$activities = Activity::where("version_gantt_id", $gantt_id)->get(); |
|
|
|
|
$reports = []; |
|
|
|
|
|
|
|
|
|
foreach($activities as $activity) { |
|
|
|
|
$activity_id = $activity->id; |
|
|
|
|
$countReports = ReportActivity::where('activity_id', $activity_id)->count(); |
|
|
|
|
if ($countReports === 1) { |
|
|
|
|
$dataReports = ReportActivity::where('activity_id', $activity_id)->orderBy('report_date')->get(); |
|
|
|
|
foreach($dataReports as $dr) { |
|
|
|
|
$reports[] = array( |
|
|
|
|
'activity_id'=>$activity_id, |
|
|
|
|
'min_date'=>$dr->report_date, |
|
|
|
|
'max_date'=>date_modify(date_create($dr->report_date), "1 days") |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if ($countReports > 1) { |
|
|
|
|
$firstReport = ReportActivity::where('activity_id', $activity_id)->orderBy('report_date')->first(); |
|
|
|
|
$lastReport = ReportActivity::where('activity_id', $activity_id)->orderByDesc('report_date')->first(); |
|
|
|
|
$reports[] = array( |
|
|
|
|
'activity_id'=>$activity_id, |
|
|
|
|
'min_date'=>$firstReport->report_date, |
|
|
|
|
'max_date'=>date_modify(date_create($lastReport->report_date), "1 days") |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for ($i=0; $i < count($reports); $i++) { |
|
|
|
|
$activity = Activity::find($reports[$i]['activity_id']); |
|
|
|
|
$activity->start_date = $reports[$i]['min_date']; |
|
|
|
|
$activity->end_date = $reports[$i]['max_date']; |
|
|
|
|
$activity->save(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setBaseline($gantt_id) |
|
|
|
|
{ |
|
|
|
|
$activities = Activity::where("version_gantt_id", $gantt_id)->get(); |
|
|
|
|
|
|
|
|
|
foreach ($activities as $activity) { |
|
|
|
|
$activity->update([ |
|
|
|
|
"planned_start"=>$activity->start_date, |
|
|
|
|
"planned_end"=>$activity->end_date, |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','message'=>'Set baseline success!','code'=> 200], 200); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|