Browse Source

adding new function for filtering activity

pull/3/head
Wahyu Ramadhan 2 years ago
parent
commit
bbd8d9d763
  1. 32
      app/Http/Controllers/UserToActivityController.php
  2. 1
      routes/web.php

32
app/Http/Controllers/UserToActivityController.php

@ -136,6 +136,38 @@ class UserToActivityController extends Controller
}
}
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');
$data = UserToActivity::select("assign_hr_to_activity.id as id", "u.name as user_name", "mrp.name as role_name")

1
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');

Loading…
Cancel
Save