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/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 143af38..ebdf8a3 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -304,7 +304,7 @@ class DashboardBoDController extends Controller { $year = $this->interpolateYear($year); - $divisions = Divisi::select('id', 'name') + $divisions = Divisi::select('id', 'name', 'color') ->with('children') ->whereNull('parent') ->get(); 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 @@ -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(); + } + } +} 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');