From 88fbfa395606ffdbfa8b4e74a2fc7fc0b8508dc7 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Sun, 16 Oct 2022 23:23:12 +0700 Subject: [PATCH] move synchro & baseline codes --- app/Http/Controllers/ActivityController.php | 52 --------------------- 1 file changed, 52 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index c74f841..3fdd675 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -277,57 +277,5 @@ class ActivityController extends Controller return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 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); - } - - 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); - } }