|
|
@ -277,57 +277,5 @@ class ActivityController extends Controller |
|
|
|
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|