|
|
@ -349,6 +349,25 @@ class ProjectController extends Controller |
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); |
|
|
|
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function setSyncDate($activity_id, $activity, $report) { |
|
|
|
|
|
|
|
$status = ReportActivityMaterial::select('description')->where('activity_id', $activity_id)->first(); |
|
|
|
|
|
|
|
if (isset($status) && $status != 'done') { |
|
|
|
|
|
|
|
$minDate = date_create($report->report_date); |
|
|
|
|
|
|
|
$maxDate = date_create($report->report_date); |
|
|
|
|
|
|
|
date_add($maxDate, date_interval_create_from_date_string($activity->duration . " days")); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$material = AssignMaterial::where('activity_id', $activity_id)->first(); |
|
|
|
|
|
|
|
$minDate = $material->start_activity; |
|
|
|
|
|
|
|
$maxDate = $material->finish_activity; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$reports = array( |
|
|
|
|
|
|
|
'activity_id' => $activity_id, |
|
|
|
|
|
|
|
'min_date' => $minDate, |
|
|
|
|
|
|
|
'max_date' => $maxDate |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
return $reports; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function synchronizeReport($gantt_id) |
|
|
|
public function synchronizeReport($gantt_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$activities = Activity::where("version_gantt_id", $gantt_id)->get(); |
|
|
|
$activities = Activity::where("version_gantt_id", $gantt_id)->get(); |
|
|
@ -360,21 +379,12 @@ class ProjectController extends Controller |
|
|
|
if ($countReports === 1) { |
|
|
|
if ($countReports === 1) { |
|
|
|
$dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); |
|
|
|
$dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); |
|
|
|
foreach($dataReports as $dr) { |
|
|
|
foreach($dataReports as $dr) { |
|
|
|
$reports[] = array( |
|
|
|
$reports[] = ProjectController::setSyncDate($activity_id, $activity, $dr); |
|
|
|
'activity_id'=>$activity_id, |
|
|
|
|
|
|
|
'min_date'=>$dr->report_date, |
|
|
|
|
|
|
|
'max_date'=>date_modify(date_create($dr->report_date), "1 days") |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ($countReports > 1) { |
|
|
|
if ($countReports > 1) { |
|
|
|
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); |
|
|
|
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); |
|
|
|
$lastReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderByDesc('report_date')->first(); |
|
|
|
$reports[] = ProjectController::setSyncDate($activity_id, $activity, $firstReport); |
|
|
|
$reports[] = array( |
|
|
|
|
|
|
|
'activity_id'=>$activity_id, |
|
|
|
|
|
|
|
'min_date'=>$firstReport->report_date, |
|
|
|
|
|
|
|
'max_date'=>date_modify(date_create($lastReport->report_date), "1 days") |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
$activity->reports = $reports; |
|
|
|
$activity->reports = $reports; |
|
|
|
} |
|
|
|
} |
|
|
@ -383,8 +393,16 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
for ($i=0; $i < count($reports); $i++) { |
|
|
|
for ($i=0; $i < count($reports); $i++) { |
|
|
|
$activity = Activity::find($reports[$i]['activity_id']); |
|
|
|
$activity = Activity::find($reports[$i]['activity_id']); |
|
|
|
|
|
|
|
$successor = Link::where('t_activity_id', $activity->id)->first(); |
|
|
|
|
|
|
|
if ($successor) { |
|
|
|
|
|
|
|
$predecessor = Activity::find($successor->s_activity_id); |
|
|
|
|
|
|
|
$activity->start_date = $predecessor->end_date; |
|
|
|
|
|
|
|
$reports[$i]['max_date']->modify('1 day'); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$reports[$i]['max_date']->modify('-1 day'); |
|
|
|
|
|
|
|
} |
|
|
|
$activity->start_date = $reports[$i]['min_date']; |
|
|
|
$activity->start_date = $reports[$i]['min_date']; |
|
|
|
$activity->end_date = $reports[$i]['max_date']; |
|
|
|
$activity->end_date = $reports[$i]['max_date']->setTime(23,59,59); |
|
|
|
$activity->save(); |
|
|
|
$activity->save(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|