From 6ba8f63717f410405a5af5421b4b4372bafdc544 Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 19 Oct 2023 08:03:40 +0700 Subject: [PATCH 1/4] fix endline --- app/Models/HumanResource.php | 76 ++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/app/Models/HumanResource.php b/app/Models/HumanResource.php index 222a835..d3c98d1 100644 --- a/app/Models/HumanResource.php +++ b/app/Models/HumanResource.php @@ -1,38 +1,38 @@ - Date: Thu, 19 Oct 2023 08:05:39 +0700 Subject: [PATCH 2/4] fix endline --- app/Models/CommentActivity.php | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/app/Models/CommentActivity.php b/app/Models/CommentActivity.php index e747af2..0cd259e 100644 --- a/app/Models/CommentActivity.php +++ b/app/Models/CommentActivity.php @@ -1,22 +1,22 @@ - Date: Thu, 19 Oct 2023 08:06:59 +0700 Subject: [PATCH 3/4] fix endline --- app/Models/VersionGantt.php | 154 ++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/app/Models/VersionGantt.php b/app/Models/VersionGantt.php index 4409af8..765ddf1 100644 --- a/app/Models/VersionGantt.php +++ b/app/Models/VersionGantt.php @@ -1,77 +1,77 @@ -updateActDuration(); - }); - } - - public function updateActDuration(){ - $daysOff = explode(',', $this->config_dayoff); - if (in_array('0', $daysOff)) { - $key = array_search('0', $daysOff, false); - $daysOff[$key] = '7'; - } - $activities = Activity::where('version_gantt_id', $this->id)->get(); - foreach ($activities as $value) { - $exist = Link::where('t_activity_id', $value->id)->exists(); - $startDate = new DateTime($value->start_date); - $endDate = new DateTime($value->end_date); - $duration = $endDate->diff($startDate)->days + 1; - if ($exist) { - $duration--; - } - - // Iterate through each day and subtract the days off - for ($i = 0; $i < $duration; $i++) { - $currentDate = clone $startDate; - $currentDate->modify("+$i day"); - - $currentDayOfWeek = $currentDate->format('N'); // Get the day of the week (1 - Monday, 7 - Sunday) - - if (in_array($currentDayOfWeek, $daysOff)) { - $duration--; // Subtract one day from the duration for each day off - } - } - - // Update the activity duration - $value->duration = $duration; - $value->save(); - } - } -} +updateActDuration(); + }); + } + + public function updateActDuration(){ + $daysOff = explode(',', $this->config_dayoff); + if (in_array('0', $daysOff)) { + $key = array_search('0', $daysOff, false); + $daysOff[$key] = '7'; + } + $activities = Activity::where('version_gantt_id', $this->id)->get(); + foreach ($activities as $value) { + $exist = Link::where('t_activity_id', $value->id)->exists(); + $startDate = new DateTime($value->start_date); + $endDate = new DateTime($value->end_date); + $duration = $endDate->diff($startDate)->days + 1; + if ($exist) { + $duration--; + } + + // Iterate through each day and subtract the days off + for ($i = 0; $i < $duration; $i++) { + $currentDate = clone $startDate; + $currentDate->modify("+$i day"); + + $currentDayOfWeek = $currentDate->format('N'); // Get the day of the week (1 - Monday, 7 - Sunday) + + if (in_array($currentDayOfWeek, $daysOff)) { + $duration--; // Subtract one day from the duration for each day off + } + } + + // Update the activity duration + $value->duration = $duration; + $value->save(); + } + } +} From ef500ad9754c954b4dcc270b42ee3e8990a19162 Mon Sep 17 00:00:00 2001 From: wahyu Date: Thu, 19 Oct 2023 10:21:54 +0700 Subject: [PATCH 4/4] custom activity search --- app/Http/Controllers/ActivityController.php | 11 +++++++++++ routes/web.php | 1 + 2 files changed, 12 insertions(+) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index acd94b0..df66558 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -527,6 +527,17 @@ class ActivityController extends Controller return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); } + public function searchAnalysis(Request $request) + { + $dataBuilder = $this->setUpPayload($request->all(), 'm_activity'); + $builder = $dataBuilder['builder']; + $dataGet = $builder->select('selfTable.*','m_version_gantt.name_version', 'm_users.name as user_name') + ->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id') + ->join('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id') + ->join('m_users', 'assign_hr_to_activity.user_id', '=', 'm_users.id') + ->get(); + return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200); + } // before upload file public function importOld(Request $request) { diff --git a/routes/web.php b/routes/web.php index f449cef..73b90db 100644 --- a/routes/web.php +++ b/routes/web.php @@ -206,6 +206,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->get('/sumVolActualM/{id}', 'ActivityController@sumVolumeActualMaterial'); $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); $router->post('/activity/search', 'ActivityController@search'); + $router->post('/activity/search-analysis', 'ActivityController@searchAnalysis'); $router->post('/activity/import', 'ActivityController@import'); $router->post('/activity/import-update', 'ActivityController@importUpdate'); $router->post('/activity/import-old', 'ActivityController@importOld');