From 6ef3ca0da9f97b15e6bb3c0891c7bdeaa4644e8f Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 27 Feb 2023 15:05:23 +0700 Subject: [PATCH 1/2] Adding functions for project dashboard --- app/Http/Controllers/ProjectController.php | 16 +++++++++++++++- routes/web.php | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index d0934e5..6a14f1a 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -215,6 +215,20 @@ class ProjectController extends Controller return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); } + public function getManpower($proyek_id){ + $manPower = UserToProyek::where('proyek_id', $proyek_id)->get(); + $manCount = $manPower->count(); + return response()->json(['data'=>$manPower, 'totalRecord'=>$manCount]); + } + + public function getAssignedHR($gantt_id){ + $results = UserToActivity::select('assign_hr_to_activity.proyek_id', 'assign_hr_to_activity.user_id', 'm_activity.id', 'm_activity.name', 'm_activity.start_date', 'm_activity.end_date') + ->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id') + ->where('assign_hr_to_activity.version_gantt_id', $gantt_id) + ->get(); + return response()->json(['data'=>$results]); + } + public function list() { $data = Project::orderBy('id', 'desc')->get(); @@ -389,7 +403,7 @@ class ProjectController extends Controller if(!$result) return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404); - + //TODO possible overdue bug if(isset($payload['till_date'])) $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$payload['till_date'])->orderBy('end_date', 'asc')->get(); else diff --git a/routes/web.php b/routes/web.php index 57e03bc..9021ba1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -62,6 +62,8 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->get('/project/list', 'ProjectController@list'); $router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline'); $router->get('/project/synchronize-report/{gantt_id}', 'ProjectController@synchronizeReport'); + $router->get('/project/manpower/{proyek_id}', 'ProjectController@getManpower'); + $router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR'); $router->post('/project/get-s-curve', 'ProjectController@getSCurve'); $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); From bbd8d9d7631c602908c8e5485f6e1a6bcec007ce Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 2 Mar 2023 10:17:41 +0700 Subject: [PATCH 2/2] adding new function for filtering activity --- .../Controllers/UserToActivityController.php | 34 ++++++++++++++++++- routes/web.php | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/UserToActivityController.php b/app/Http/Controllers/UserToActivityController.php index 2b9b403..8cf9ad6 100644 --- a/app/Http/Controllers/UserToActivityController.php +++ b/app/Http/Controllers/UserToActivityController.php @@ -134,7 +134,39 @@ class UserToActivityController extends Controller }else{ return response()->json(['status'=>'failed','message'=>'failed get list user to activity gantt, please try again later!','code'=>400], 400); } - } + } + + public function listFiltered(Request $request) + { + $startDate = $request->start_date; + $endDate = $request->end_date; + $userId = $request->user_id; + $proyekId = $request->proyek_id; + + if (isset($proyekId)) { + $data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date') + ->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id') + ->where('m_activity.start_date', '=', $startDate) + ->where('m_activity.end_date', '=', $endDate) + ->where('assign_hr_to_activity.user_id', '=', $userId) + ->where('assign_hr_to_activity.proyek_id', '=', $proyekId) + ->get(); + }else { + $data = UserToActivity::select('assign_hr_to_activity.id', 'assign_hr_to_activity.activity_id', 'm_activity.name', 'm_activity.kode_sortname', 'm_activity.start_date', 'm_activity.end_date') + ->join('m_activity', 'assign_hr_to_activity.activity_id', '=', 'm_activity.id') + ->where('m_activity.start_date', '=', $startDate) + ->where('m_activity.end_date', '=', $endDate) + ->where('assign_hr_to_activity.user_id', '=', $userId) + ->get(); + } + $countData = $data->count(); + + if($data){ + return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'failed get list user to activity gantt, please try again later!','code'=>400], 400); + } + } public function datatables(Request $request){ $id_activity = $request->query('idact'); diff --git a/routes/web.php b/routes/web.php index 9021ba1..4a66429 100644 --- a/routes/web.php +++ b/routes/web.php @@ -192,6 +192,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); $router->post('/user-to-activity/search', 'UserToActivityController@search'); + $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete'); $router->get('/user-to-activity/list', 'UserToActivityController@list'); $router->get('/user-to-activity/datatables', 'UserToActivityController@datatables');