From c67d62003c2f0b36bbe60c282f31f330ee1d82c1 Mon Sep 17 00:00:00 2001 From: ibnu Date: Wed, 20 Dec 2023 15:21:14 +0700 Subject: [PATCH] update user-to-activity --- .../Controllers/UserToActivityController.php | 22 ++++++++++++++++--- routes/web.php | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/UserToActivityController.php b/app/Http/Controllers/UserToActivityController.php index b387c24..e491e22 100644 --- a/app/Http/Controllers/UserToActivityController.php +++ b/app/Http/Controllers/UserToActivityController.php @@ -158,7 +158,7 @@ class UserToActivityController extends Controller $dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity'); $builder = $dataBuilder['builder']; - $countBuilder = $dataBuilder['count']; + // $countBuilder = $dataBuilder['count']; if (isset($join_column)) { $startDate = $join_column['start_date']; $endDate = $join_column['end_date']; @@ -187,8 +187,24 @@ class UserToActivityController extends Controller } $dataGet = $filteredData; } - $totalRecord = $countBuilder->count(); - return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); + // $totalRecord = $countBuilder->count(); + return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>count($dataGet)], 200); + } + + public function activityUser(Request $request){ + $payload = $request->all(); + $query = DB::table('m_activity as ma') + ->select('ahta.id', 'ma.id as activity_id', 'ma.proyek_id', 'ma.name as join_second_name', 'ma.start_date as join_second_start_date', + 'ma.end_date as join_second_end_date', 'ma.persentase_progress', 'mvg.name_version', 'mp.nama as nama_proyek', 'mp.type_proyek_id') + ->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'ma.id') + ->join('m_version_gantt as mvg', 'mvg.id', '=', 'ma.version_gantt_id') + ->join('m_proyek as mp', 'mp.id', '=', 'ma.proyek_id') + ->where('ahta.user_id', $payload['user_id']) + ->where('ma.start_date', '<=', $payload['start_date']) + ->where('ma.end_date', '>=', $payload['end_date']) + ->get(); + + return response()->json(['status'=>'success','code'=>200,'data'=>$query, 'totalRecord'=>count($request->all())], 200); } public function list() diff --git a/routes/web.php b/routes/web.php index f82f295..9f6c0e4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -198,7 +198,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->post('/user-to-activity/add-multiple', 'UserToActivityController@addMultiple'); $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/search', 'UserToActivityController@activityUser'); $router->post('/user-to-activity/search-analysis', 'UserToActivityController@searchAnalysis'); $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete');