From 6cc0a077bce3519bbcbf5bdbd77165ac2b63907a Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 18 Oct 2022 01:21:23 +0700 Subject: [PATCH] endpoint peta persebaran laporan --- app/Http/Controllers/ProjectController.php | 20 ++++++++++++++++++++ routes/web.php | 1 + 2 files changed, 21 insertions(+) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index e9b1125..36cca6b 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -809,5 +809,25 @@ class ProjectController extends Controller return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); } + public function getReportDistribution(Request $request){ + $payload = $request->all(); + + if(empty($payload['project_id']) || !is_int((int)$payload['project_id'])) + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + + $reports = DB::table('assign_material_to_activity as ama') + ->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'rm.description as material_name', 'rm.uom as material_unit', + 'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date') + ->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id') + ->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id') + ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') + ->join('m_users as u', 'u.id', '=', 'ram.user_id') + ->where('ama.proyek_id', '=', $payload['project_id']) + ->whereNotNull('ram.lat') + ->whereBetween('ram.report_date', [$payload['start_date'], $payload['end_date']]) + ->get(); + + return response()->json(['status'=>'success', 'code'=> 200, 'data'=> $reports], 200); + } } diff --git a/routes/web.php b/routes/web.php index ef0bf50..2c869be 100644 --- a/routes/web.php +++ b/routes/web.php @@ -65,6 +65,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout $router->post('/project/get-s-curve', 'ProjectController@getSCurve'); $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); $router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration'); + $router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution'); /* $router->get('/project/get-progress/{id}/{date?}', 'ProjectController@getProgress'); */ /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */