diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 43dadf9..158b77e 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -350,20 +350,21 @@ class ProjectController extends Controller } public static function setSyncDate($activity_id, $activity, $report) { - $status = ReportActivityMaterial::select('description')->where('activity_id', $activity_id)->first(); - if (isset($status) && $status != 'done') { + $status = AssignMaterial::select('status_activity')->where('activity_id', $activity_id)->first(); + if (isset($status->status_activity) && $status->status_activity != '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; + $minDate = date_create($material->start_activity); + $maxDate = date_create($material->finish_activity); } $reports = array( 'activity_id' => $activity_id, 'min_date' => $minDate, - 'max_date' => $maxDate + 'max_date' => $maxDate, + 'status' => $status->status_activity ); return $reports; } @@ -397,8 +398,8 @@ class ProjectController extends Controller if ($successor) { $predecessor = Activity::find($successor->s_activity_id); $activity->start_date = $predecessor->end_date; - $reports[$i]['max_date']->modify('1 day'); - } else { + } + if($reports[$i]['status'] != 'done'){ $reports[$i]['max_date']->modify('-1 day'); } $activity->start_date = $reports[$i]['min_date'];