Browse Source

Merge branch 'master' of https://git.oslog.id/ordo/adw-backend

pull/3/head
ibnu 2 years ago
parent
commit
4b2666e020
  1. 16
      app/Http/Controllers/ProjectController.php
  2. 34
      app/Http/Controllers/UserToActivityController.php
  3. 3
      routes/web.php

16
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

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

3
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');
@ -190,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