|
|
@ -374,30 +374,29 @@ class ProjectController extends Controller |
|
|
|
if(!$alreadyHasReport) |
|
|
|
if(!$alreadyHasReport) |
|
|
|
continue; |
|
|
|
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') */ |
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
/* ->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) */ |
|
|
|
->min("plan_date"); |
|
|
|
/* ->min("plan_date"); */ |
|
|
|
/* ->min("planned_Start"); */ |
|
|
|
$minDate = Activity::where('version_gantt_id', $keyGantt['last_gantt_id'])->min("planned_start"); |
|
|
|
|
|
|
|
|
|
|
|
$maxDate = DB::table('assign_material_to_activity as ama') |
|
|
|
$begin = new \DateTime($minDate.' Monday'); |
|
|
|
->where("ama.proyek_id", $keyGantt['proyek_id']) |
|
|
|
if(isset($dataPayload['end_date'])){ |
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
|
$maxDate = $dataPayload['end_date']; |
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
$end = new \DateTime($maxDate); |
|
|
|
->max("plan_date"); |
|
|
|
$interval = \DateInterval::createFromDateString('1 day'); |
|
|
|
/* ->whereNull('deleted_at') */ |
|
|
|
} else { |
|
|
|
/* ->get(); */ |
|
|
|
$maxDate = DB::table('assign_material_to_activity as ama') |
|
|
|
/* ->max("plan_date"); */ // plan date overlapped with assign_material_to_activity's, it should be m_activity's |
|
|
|
->where("ama.proyek_id", $keyGantt['proyek_id']) |
|
|
|
/* print_r($maxDate); exit(); */ |
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
|
|
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
$begin = new \DateTime($minDate.' Friday'); |
|
|
|
->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's |
|
|
|
/* print_r($begin); exit(); */ |
|
|
|
$end = new \DateTime($maxDate. ' Friday'); |
|
|
|
$end = new \DateTime($maxDate); |
|
|
|
$interval = new \DateInterval('P7D'); |
|
|
|
$interval = new \DateInterval('P1W'); |
|
|
|
} |
|
|
|
// timezone problems in KIT case also occurs in here |
|
|
|
|
|
|
|
$period = new \DatePeriod($begin, $interval, $end); |
|
|
|
$period = new \DatePeriod($begin, $interval, $end); |
|
|
|
/* $period = new \DatePeriod($begin->modify('-1 days'), $interval, $end); */ |
|
|
|
|
|
|
|
$arr_ActualM = []; |
|
|
|
$arr_ActualM = []; |
|
|
|
$tempDate = []; |
|
|
|
$tempDate = []; |
|
|
|
$tempPercentagePlan = []; |
|
|
|
$tempPercentagePlan = []; |
|
|
@ -409,10 +408,12 @@ class ProjectController extends Controller |
|
|
|
$currentACWP = 0; |
|
|
|
$currentACWP = 0; |
|
|
|
$currentBCWP = 0; |
|
|
|
$currentBCWP = 0; |
|
|
|
|
|
|
|
|
|
|
|
/* foreach($period as $x){ */ |
|
|
|
foreach($period as $x){ |
|
|
|
/* echo $x->format("Y-m-d")."\n"; */ |
|
|
|
echo $x->format("Y-m-d")."\n"; |
|
|
|
/* } exit(); */ |
|
|
|
} exit(); |
|
|
|
foreach ($period as $dt) { |
|
|
|
foreach ($period as $dt) { |
|
|
|
|
|
|
|
$minSevenDays = new \Datetime($dt->format("Y-m-d")); |
|
|
|
|
|
|
|
$minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); |
|
|
|
$dataPlanM = DB::table('assign_material_to_activity as ama') |
|
|
|
$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') |
|
|
|
->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') |
|
|
|
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') |
|
|
@ -420,7 +421,7 @@ class ProjectController extends Controller |
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
/* ->whereDate('ama.plan_date', $dt->format("Y-m-d")) */ |
|
|
|
/* ->whereDate('ama.plan_date', $dt->format("Y-m-d")) */ |
|
|
|
->whereDate('ama.plan_date', '<=',$dt->format("Y-m-d")) |
|
|
|
->whereDate('ama.plan_date', '<=',$dt->format("Y-m-d")) |
|
|
|
->whereDate('ama.plan_date', '>',$dt->modify('-7 day')->format("Y-m-d")) |
|
|
|
->whereDate('ama.plan_date', '>', $minSevenDays) |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
$dataActualM = DB::table('report_activity_material as ram') |
|
|
|
$dataActualM = DB::table('report_activity_material as ram') |
|
|
|
->select('ram.activity_id', 'ram.qty', 'ram.report_date', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress') |
|
|
|
->select('ram.activity_id', 'ram.qty', 'ram.report_date', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress') |
|
|
@ -428,7 +429,7 @@ class ProjectController extends Controller |
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['last_gantt_id']) |
|
|
|
->where('a.proyek_id', '=', $keyGantt['proyek_id']) |
|
|
|
->where('a.proyek_id', '=', $keyGantt['proyek_id']) |
|
|
|
->whereDate('ram.report_date', '<=',$dt->format("Y-m-d")) |
|
|
|
->whereDate('ram.report_date', '<=',$dt->format("Y-m-d")) |
|
|
|
->whereDate('ram.report_date', '>',$dt->modify('-7 day')->format("Y-m-d")) |
|
|
|
->whereDate('ram.report_date', '>',$minSevenDays) |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
$dataTempPlan = []; |
|
|
|
$dataTempPlan = []; |
|
|
|
$x = 0; |
|
|
|
$x = 0; |
|
|
@ -503,14 +504,14 @@ class ProjectController extends Controller |
|
|
|
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2); |
|
|
|
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2); |
|
|
|
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; |
|
|
|
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; |
|
|
|
$tempPercentageReal[] = round($tempTtlPercentActual, 2); |
|
|
|
$tempPercentageReal[] = round($tempTtlPercentActual, 2); |
|
|
|
$tempDate[] = array($dt->format("Y-m-d"), 0, 0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
$tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); |
|
|
|
$tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); |
|
|
|
$tempPercentagePlan[] = round($sumPercentagePlan, 2); |
|
|
|
$tempPercentagePlan[] = round($sumPercentagePlan, 2); |
|
|
|
$tempPercentageReal[] = round($sumPercentageActual, 2); |
|
|
|
$tempPercentageReal[] = round($sumPercentageActual, 2); |
|
|
|
$tempDate[] = array($dt->format("Y-m-d"), 0, 0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$tempDate[] = array($dt->format("Y-m-d")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* print_r($tempDate); exit(); */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
@ -740,5 +741,25 @@ class ProjectController extends Controller |
|
|
|
return response()->json(['status'=>'success','message'=>'Set baseline success!','code'=> 200], 200); |
|
|
|
return response()->json(['status'=>'success','message'=>'Set baseline success!','code'=> 200], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getOverdueActivities(Request $request){ |
|
|
|
|
|
|
|
$payload = $request->all(); |
|
|
|
|
|
|
|
if(empty($payload['id']) || !is_int((int)$payload['id'])) |
|
|
|
|
|
|
|
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = Project::find($payload['id']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!$result) |
|
|
|
|
|
|
|
return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isset($payload['till_date'])) |
|
|
|
|
|
|
|
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$payload['till_date'])->orderBy('end_date', 'asc')->get(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
$overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result->overdueActivities = $overdueActivities; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|