|
|
|
@ -348,6 +348,7 @@ class ActivityController extends Controller
|
|
|
|
|
Activity::where('version_gantt_id', $data['ganttId'])->delete(); |
|
|
|
|
|
|
|
|
|
$projectId = VersionGantt::where('id', $data['ganttId'])->first()->proyek_id; |
|
|
|
|
$dayOffs = VersionGantt::find($data['ganttId'])->first()->config_dayoff; |
|
|
|
|
|
|
|
|
|
$activityStack = []; |
|
|
|
|
|
|
|
|
@ -400,7 +401,23 @@ class ActivityController extends Controller
|
|
|
|
|
foreach ($data['activities'] as $i => $activity_row) { |
|
|
|
|
$startDate = \DateTime::createFromFormat('Y-m-d H:i:s.uP', $projectStart->mulai_proyek); |
|
|
|
|
$endDate = clone $startDate; |
|
|
|
|
$endDate->modify('+'.$activity_row['duration'].' days'); |
|
|
|
|
// $endDate->modify('+'.$activity_row['duration'].' days'); |
|
|
|
|
|
|
|
|
|
$daysRemaining = $activity_row['duration']; |
|
|
|
|
|
|
|
|
|
// Loop until the remaining days become zero |
|
|
|
|
while ($daysRemaining > 0) { |
|
|
|
|
$endDate->modify('+1 day'); |
|
|
|
|
|
|
|
|
|
// Check if the current day is a day off (Sunday or Saturday) |
|
|
|
|
$currentDayOfWeek = (int)$endDate->format('w'); |
|
|
|
|
if (strpos($dayOffs, (string)$currentDayOfWeek) !== false) { |
|
|
|
|
continue; // Skip the day off and continue to the next day |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$daysRemaining--; // Decrease the remaining days by one |
|
|
|
|
} |
|
|
|
|
Log::info('create ', [$activity_row['duration'], $startDate, $endDate]); |
|
|
|
|
$endDate->setTime(23, 59, 59); |
|
|
|
|
$input['name'] = $activity_row['name']; |
|
|
|
|
$input['proyek_id'] = $projectId; |
|
|
|
@ -494,6 +511,27 @@ class ActivityController extends Controller
|
|
|
|
|
$predecessorFinishDate = new \DateTime($predecessorActivity->end_date); |
|
|
|
|
$interval = $predecessorFinishDate->diff(new \DateTime($activity->start_date)); |
|
|
|
|
$diff = $interval->days; |
|
|
|
|
unset($activity->level); |
|
|
|
|
$successorStartDate = $predecessorFinishDate; |
|
|
|
|
$successorEndDate = clone $successorStartDate; |
|
|
|
|
$daysRemaining = $activity->duration; |
|
|
|
|
|
|
|
|
|
// Loop until the remaining days become zero |
|
|
|
|
while ($daysRemaining > 1) { |
|
|
|
|
$successorEndDate->modify('+1 day'); |
|
|
|
|
|
|
|
|
|
// Check if the current day is a day off (Sunday or Saturday) |
|
|
|
|
$currentDayOfWeek = (int)$successorEndDate->format('w'); |
|
|
|
|
if (strpos($dayOffs, (string)$currentDayOfWeek) !== false) { |
|
|
|
|
continue; // Skip the day off and continue to the next day |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$daysRemaining--; // Decrease the remaining days by one |
|
|
|
|
} |
|
|
|
|
Log::info('update ', [$activity->id, $activity->duration, $successorStartDate, $successorEndDate]); |
|
|
|
|
$activity->start_date = $successorStartDate; |
|
|
|
|
$activity->end_date = $successorEndDate; |
|
|
|
|
$activity->save(); |
|
|
|
|
|
|
|
|
|
Link::create([ |
|
|
|
|
'created_by' => $this->currentName, |
|
|
|
|