Browse Source

Merge pull request 'Fix dayoff' (#118) from dev-wahyu into staging

Reviewed-on: ordo/adw-backend#118
pull/3/head
ibnu 1 year ago
parent
commit
ce3686da43
  1. 2
      app/Http/Controllers/ActivityController.php
  2. 15
      app/Http/Controllers/ProjectController.php

2
app/Http/Controllers/ActivityController.php

@ -353,7 +353,7 @@ class ActivityController extends Controller
Activity::where('version_gantt_id', $data['ganttId'])->delete(); Activity::where('version_gantt_id', $data['ganttId'])->delete();
$projectId = VersionGantt::where('id', $data['ganttId'])->first()->proyek_id; $projectId = VersionGantt::where('id', $data['ganttId'])->first()->proyek_id;
$dayOffs = VersionGantt::find($data['ganttId'])->first()->config_dayoff; $dayOffs = VersionGantt::where('id', $data['ganttId'])->first()->config_dayoff;
$activityStack = []; $activityStack = [];

15
app/Http/Controllers/ProjectController.php

@ -350,20 +350,21 @@ class ProjectController extends Controller
} }
public static function setSyncDate($activity_id, $activity, $report) { public static function setSyncDate($activity_id, $activity, $report) {
$status = ReportActivityMaterial::select('description')->where('activity_id', $activity_id)->first(); $status = AssignMaterial::select('status_activity')->where('activity_id', $activity_id)->first();
if (isset($status) && $status != 'done') { if (isset($status->status_activity) && $status->status_activity != 'done') {
$minDate = date_create($report->report_date); $minDate = date_create($report->report_date);
$maxDate = date_create($report->report_date); $maxDate = date_create($report->report_date);
date_add($maxDate, date_interval_create_from_date_string($activity->duration . " days")); date_add($maxDate, date_interval_create_from_date_string($activity->duration . " days"));
} else { } else {
$material = AssignMaterial::where('activity_id', $activity_id)->first(); $material = AssignMaterial::where('activity_id', $activity_id)->first();
$minDate = $material->start_activity; $minDate = date_create($material->start_activity);
$maxDate = $material->finish_activity; $maxDate = date_create($material->finish_activity);
} }
$reports = array( $reports = array(
'activity_id' => $activity_id, 'activity_id' => $activity_id,
'min_date' => $minDate, 'min_date' => $minDate,
'max_date' => $maxDate 'max_date' => $maxDate,
'status' => $status->status_activity
); );
return $reports; return $reports;
} }
@ -397,8 +398,8 @@ class ProjectController extends Controller
if ($successor) { if ($successor) {
$predecessor = Activity::find($successor->s_activity_id); $predecessor = Activity::find($successor->s_activity_id);
$activity->start_date = $predecessor->end_date; $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'); $reports[$i]['max_date']->modify('-1 day');
} }
$activity->start_date = $reports[$i]['min_date']; $activity->start_date = $reports[$i]['min_date'];

Loading…
Cancel
Save