From 4ca0f1105e78075d1e23a9494b186b332b5fea01 Mon Sep 17 00:00:00 2001 From: ibnu Date: Sun, 12 Feb 2023 15:16:59 +0700 Subject: [PATCH 01/11] update sample presence --- rest-client.http | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/rest-client.http b/rest-client.http index a7a710b..e7b5a5a 100644 --- a/rest-client.http +++ b/rest-client.http @@ -796,22 +796,31 @@ GET {{hostname}}/presence/clockinout/262 Authorization: Bearer {{token}} content-type: application/json -####### -"clock_out_lat": -1.4264273154149407, - "clock_out_lng": 113.98530036945851, ###### POST {{hostname}}/presence/add Authorization: Bearer {{token}} content-type: application/json { - "clock_out_lat": -6.2622811, - "clock_out_lng": 106.7881746, + "clock_in_lat": -6.2622811, + "clock_in_lng": 106.7881746, "clock_time": "2023-02-06T16:40:17+07:00", - "type": "out", + "type": "in", "user_id": 1 } +###### +POST {{hostname}}/presence/add +Authorization: Bearer {{token}} +content-type: application/json + +{ + "clock_out_lat": -1.4264273154149407, + "clock_out_lng": 113.98530036945851, + "clock_time": "2023-02-06T16:40:17+07:00", + "type": "in", + "user_id": 1 +} ###### # POST {{hostname}}/ From b630b9706368ab70eb92b12464a6b0d9b7a37467 Mon Sep 17 00:00:00 2001 From: farhan048 Date: Mon, 13 Feb 2023 10:09:48 +0700 Subject: [PATCH 02/11] Project Expenditure order by DESC, Search Divisi --- app/Http/Controllers/DashboardBoDController.php | 1 + app/Http/Controllers/DivisiController.php | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 94931b6..c6309e5 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -304,6 +304,7 @@ class DashboardBoDController extends Controller $year = $this->interpolateYear($year); $projects = Project::where('mulai_proyek', 'like', $year) /* ->orWhere('akhir_proyek', 'like', $year) */ + ->orderBy('id', 'desc') ->get(); foreach($projects as $project){ $lastGantt = MasterFunctionsHelper::getLatestGantt($project->id); diff --git a/app/Http/Controllers/DivisiController.php b/app/Http/Controllers/DivisiController.php index aad3c90..1991c24 100644 --- a/app/Http/Controllers/DivisiController.php +++ b/app/Http/Controllers/DivisiController.php @@ -72,8 +72,13 @@ class DivisiController extends Controller public function search() { - return $this->list(); - // cant use builder for this case + $payload = $request->all(); + $dataBuilder = $this->setUpPayload($payload, 'm_divisi'); + $builder = $dataBuilder['builder']; + $countBuilder = $dataBuilder['count']; + $dataGet = $builder->get(); + $totalRecord = $countBuilder->count(); + return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); } public function list() From fb674e529e753fdacda70272ba1c58d19363d229 Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 14 Feb 2023 01:42:45 +0700 Subject: [PATCH 03/11] update presensi add policy boundary --- app/Http/Controllers/PresenceController.php | 196 +++++++++++--------- rest-client.http | 8 +- 2 files changed, 113 insertions(+), 91 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 5dafe10..a472138 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -5,9 +5,9 @@ namespace App\Http\Controllers; use Log; use Illuminate\Http\Request; use App\Models\Presence; -use App\Models\Activity; -use GuzzleHttp\Client; -use Illuminate\Support\Facades\Http; +// use App\Models\Activity; +// use GuzzleHttp\Client; +// use Illuminate\Support\Facades\Http; use Carbon\Carbon; use Illuminate\Support\Facades\DB; @@ -24,86 +24,102 @@ class PresenceController extends Controller $date = date_create($request->clock_time); // $ActivityId = null; if(count($checkLocation) > 0){ - $statusBoundary = true; + $checkLocation[0]['status_assign'] ? $statusBoundary = true + : $statusBoundary = false; } - if($request->type=="out"){ - - $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; - $dataUpdate = array( - "clock_out"=>$request->clock_time, - "clock_out_lat" => $request->clock_out_lat, - "clock_out_lng" => $request->clock_out_lng, - "updated_by"=>$this->currentName, - "clock_out_loc" => $clock_out_loc, - "clock_out_boundary" => $statusBoundary + if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ + $data=array( + 'id' => null, + 'boundary' => $statusBoundary ); - - $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); - if($resultUpdate && $resultUpdate > 0){ - if($statusBoundary){ - for ($i=0; $i < count($checkLocation); $i++) { - # code... - DB::table('clock_in_out_boundary')->insert([ - "clock_in_out_id" => $resultUpdate, - "user_id" => $request->user_id, - "activity_id" => $checkLocation[$i]['activity_id'], - "type" => $request->type, - "created_at" => $date, - "created_by" => $this->currentName - ]); - }; - }; - $data=array( - 'id' => $resultUpdate, - 'boundary' => $statusBoundary - ); - - return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); - } - else{ - return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); - } - die(); + return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200); } - $onlyDate = date_format($date,"Y-m-d"); - $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; - - $dataAdd = array( - 'user_id'=> $request->user_id, - 'clock_in'=> $request->clock_time, - 'date_presence'=> $onlyDate, - 'created_by' => $this->currentName, - 'clock_in_lat' => $request->clock_in_lat, - 'clock_in_lng' => $request->clock_in_lng, - 'clock_in_loc' => $clock_in_loc, - 'clock_in_boundary' => $statusBoundary - ); - - $result = Presence::create($dataAdd); - $data=array( - 'id' => $result->id, - 'boundary' => $statusBoundary - ); - if($result){ - if($statusBoundary){ - for ($i=0; $i < count($checkLocation); $i++) { - # code... - DB::table('clock_in_out_boundary')->insert([ - "clock_in_out_id" => $result->id, - "user_id" => $request->user_id, - "activity_id" => $checkLocation[$i]['activity_id'], - "type" => $request->type, - "created_at" => $date, - "created_by" => $this->currentName - ]); - }; - }; - return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); - }else{ - return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); + if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ + $data=array( + 'id' => null, + 'boundary' => $statusBoundary + ); + return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200); } + + // if($request->type=="out"){ + // $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; + // $dataUpdate = array( + // "clock_out"=>$request->clock_time, + // "clock_out_lat" => $request->clock_out_lat, + // "clock_out_lng" => $request->clock_out_lng, + // "updated_by"=>$this->currentName, + // "clock_out_loc" => $clock_out_loc, + // "clock_out_boundary" => $statusBoundary + // ); + + // $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); + // if($resultUpdate && $resultUpdate > 0){ + // if($statusBoundary){ + // for ($i=0; $i < count($checkLocation); $i++) { + // # code... + // DB::table('clock_in_out_boundary')->insert([ + // "clock_in_out_id" => $resultUpdate, + // "user_id" => $request->user_id, + // "activity_id" => $checkLocation[$i]['activity_id'], + // "type" => $request->type, + // "created_at" => $date, + // "created_by" => $this->currentName + // ]); + // }; + // }; + // $data=array( + // 'id' => $resultUpdate, + // 'boundary' => $statusBoundary + // ); + + // return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); + // } + // else{ + // return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); + // } + // die(); + // } + + // $onlyDate = date_format($date,"Y-m-d"); + // $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; + + // $dataAdd = array( + // 'user_id'=> $request->user_id, + // 'clock_in'=> $request->clock_time, + // 'date_presence'=> $onlyDate, + // 'created_by' => $this->currentName, + // 'clock_in_lat' => $request->clock_in_lat, + // 'clock_in_lng' => $request->clock_in_lng, + // 'clock_in_loc' => $clock_in_loc, + // 'clock_in_boundary' => $statusBoundary + // ); + + // $result = Presence::create($dataAdd); + // $data=array( + // 'id' => $result->id, + // 'boundary' => $statusBoundary + // ); + // if($result){ + // if($statusBoundary){ + // for ($i=0; $i < count($checkLocation); $i++) { + // # code... + // DB::table('clock_in_out_boundary')->insert([ + // "clock_in_out_id" => $result->id, + // "user_id" => $request->user_id, + // "activity_id" => $checkLocation[$i]['activity_id'], + // "type" => $request->type, + // "created_at" => $date, + // "created_by" => $this->currentName + // ]); + // }; + // }; + // return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); + // }else{ + // return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); + // } } private function checkLocation($params){ @@ -128,11 +144,25 @@ class PresenceController extends Controller if($key->boundary){ $temp[]=array( "activity_id" => $dataGeom->id, - "boundary" => $key->boundary + "boundary" => $key->boundary, + "status_assign" => true ); - } + } + } + if(count($temp) < 1){ + $temp[]=array( + "activity_id" => null, + "boundary" => null, + "status_assign" => true + ); } } + }else{ + $temp[]=array( + "activity_id" => null, + "boundary" => null, + "status_assign" => false + ); } return $temp; } @@ -152,14 +182,10 @@ class PresenceController extends Controller } } - - public function clockinout($id) { $dateTimeNow = Carbon::now()->addHour(7); $dataPresence = Presence::where('user_id', $id)->orderBy('id', 'DESC')->first(); - - if($dataPresence){ $dateNow = date("Y-m-d"); @@ -199,10 +225,8 @@ class PresenceController extends Controller private function updateFormAdd($data, $id){ $date = date_create($data['clock_out']); - $onlyDate = date_format($date,"Y-m-d"); - $dataPresence = Presence::where('user_id',$id) ->where("clock_in", "<=", $data["clock_out"]) ->orderByDesc("id") @@ -237,7 +261,6 @@ class PresenceController extends Controller die(); } - if($result){ return response()->json(['status'=>'success','message'=>'data presence successfully updated!','code'=>200], 200); }else{ @@ -256,7 +279,6 @@ class PresenceController extends Controller die(); } - if($delete){ return response()->json(['status'=>'success','message'=>'data presence successfully deleted!','code'=>200], 200); }else{ diff --git a/rest-client.http b/rest-client.http index 416c9b0..120334f 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,12 +1,12 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA3NFwvYWR3LWJhY2tlbmRcL2FwaVwvbG9naW4iLCJpYXQiOjE2NzYxODQ5ODgsImV4cCI6MTY3Njc4OTc4OCwibmJmIjoxNjc2MTg0OTg4LCJqdGkiOiJSMkk1R3FLdXM3bWhMUWwzIiwic3ViIjoxMjQ3LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.GlxG-DaiY1Slc0dR8sRK6CvU-F7MTjT47989MImubJ0 +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NjI5MTQwNiwiZXhwIjoxNjc2ODk2MjA2LCJuYmYiOjE2NzYyOTE0MDYsImp0aSI6IkNNRVNGMEcwVzVNQlRLenoiLCJzdWIiOjEyNDcsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.ZV2ncAf6H61vnK7fmg-bMfeqBTcxm0aFE5zs_4tor8g # @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api # @hostname = https://api-iu.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api -# @hostname = http://localhost:8444/api +@hostname = http://localhost:8444/api # @hostname = http://103.73.125.81:8444/api -@hostname = http://localhost:8074/adw-backend/api +# @hostname = http://localhost:8444/adw-ba/api ###### login POST {{hostname}}/login @@ -817,7 +817,7 @@ content-type: application/json { "clock_out_lat": -1.4264273154149407, "clock_out_lng": 113.98530036945851, - "clock_time": "2023-02-06T16:40:17+07:00", + "clock_time": "2023-02-13T16:40:17+07:00", "type": "in", "user_id": 1 } From f4f7e15ea05d6888f65f22a1212b69b9d4985b9c Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 14 Feb 2023 02:46:01 +0700 Subject: [PATCH 04/11] update presensi --- app/Http/Controllers/PresenceController.php | 142 ++++++++++---------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index a472138..0e844d0 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -44,82 +44,82 @@ class PresenceController extends Controller return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200); } - // if($request->type=="out"){ - // $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; - // $dataUpdate = array( - // "clock_out"=>$request->clock_time, - // "clock_out_lat" => $request->clock_out_lat, - // "clock_out_lng" => $request->clock_out_lng, - // "updated_by"=>$this->currentName, - // "clock_out_loc" => $clock_out_loc, - // "clock_out_boundary" => $statusBoundary - // ); + if($request->type=="out"){ + $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; + $dataUpdate = array( + "clock_out"=>$request->clock_time, + "clock_out_lat" => $request->clock_out_lat, + "clock_out_lng" => $request->clock_out_lng, + "updated_by"=>$this->currentName, + "clock_out_loc" => $clock_out_loc, + "clock_out_boundary" => $statusBoundary + ); - // $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); - // if($resultUpdate && $resultUpdate > 0){ - // if($statusBoundary){ - // for ($i=0; $i < count($checkLocation); $i++) { - // # code... - // DB::table('clock_in_out_boundary')->insert([ - // "clock_in_out_id" => $resultUpdate, - // "user_id" => $request->user_id, - // "activity_id" => $checkLocation[$i]['activity_id'], - // "type" => $request->type, - // "created_at" => $date, - // "created_by" => $this->currentName - // ]); - // }; - // }; - // $data=array( - // 'id' => $resultUpdate, - // 'boundary' => $statusBoundary - // ); + $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); + if($resultUpdate && $resultUpdate > 0){ + if($statusBoundary){ + for ($i=0; $i < count($checkLocation); $i++) { + # code... + DB::table('clock_in_out_boundary')->insert([ + "clock_in_out_id" => $resultUpdate, + "user_id" => $request->user_id, + "activity_id" => $checkLocation[$i]['activity_id'], + "type" => $request->type, + "created_at" => $date, + "created_by" => $this->currentName + ]); + }; + }; + $data=array( + 'id' => $resultUpdate, + 'boundary' => $statusBoundary + ); - // return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); - // } - // else{ - // return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); - // } - // die(); - // } + return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); + } + else{ + return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); + } + die(); + } - // $onlyDate = date_format($date,"Y-m-d"); - // $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; + $onlyDate = date_format($date,"Y-m-d"); + $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; - // $dataAdd = array( - // 'user_id'=> $request->user_id, - // 'clock_in'=> $request->clock_time, - // 'date_presence'=> $onlyDate, - // 'created_by' => $this->currentName, - // 'clock_in_lat' => $request->clock_in_lat, - // 'clock_in_lng' => $request->clock_in_lng, - // 'clock_in_loc' => $clock_in_loc, - // 'clock_in_boundary' => $statusBoundary - // ); + $dataAdd = array( + 'user_id'=> $request->user_id, + 'clock_in'=> $request->clock_time, + 'date_presence'=> $onlyDate, + 'created_by' => $this->currentName, + 'clock_in_lat' => $request->clock_in_lat, + 'clock_in_lng' => $request->clock_in_lng, + 'clock_in_loc' => $clock_in_loc, + 'clock_in_boundary' => $statusBoundary + ); - // $result = Presence::create($dataAdd); - // $data=array( - // 'id' => $result->id, - // 'boundary' => $statusBoundary - // ); - // if($result){ - // if($statusBoundary){ - // for ($i=0; $i < count($checkLocation); $i++) { - // # code... - // DB::table('clock_in_out_boundary')->insert([ - // "clock_in_out_id" => $result->id, - // "user_id" => $request->user_id, - // "activity_id" => $checkLocation[$i]['activity_id'], - // "type" => $request->type, - // "created_at" => $date, - // "created_by" => $this->currentName - // ]); - // }; - // }; - // return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); - // }else{ - // return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); - // } + $result = Presence::create($dataAdd); + $data=array( + 'id' => $result->id, + 'boundary' => $statusBoundary + ); + if($result){ + if($statusBoundary){ + for ($i=0; $i < count($checkLocation); $i++) { + # code... + DB::table('clock_in_out_boundary')->insert([ + "clock_in_out_id" => $result->id, + "user_id" => $request->user_id, + "activity_id" => $checkLocation[$i]['activity_id'], + "type" => $request->type, + "created_at" => $date, + "created_by" => $this->currentName + ]); + }; + }; + return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); + } } private function checkLocation($params){ From 47b4f779bfe555573fbfec14308755d5e3787b91 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Tue, 14 Feb 2023 13:29:19 +0700 Subject: [PATCH 05/11] Project to k3 checklist adding name --- app/Http/Controllers/ProjectToChecklistK3Controller.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Controllers/ProjectToChecklistK3Controller.php b/app/Http/Controllers/ProjectToChecklistK3Controller.php index 99413ba..3fb5a8e 100644 --- a/app/Http/Controllers/ProjectToChecklistK3Controller.php +++ b/app/Http/Controllers/ProjectToChecklistK3Controller.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\ProjectToChecklistK3; +use App\Models\ChecklistK3; class ProjectToChecklistK3Controller extends Controller { @@ -122,6 +123,12 @@ class ProjectToChecklistK3Controller extends Controller $builder = $dataBuilder['builder']; $countBuilder = $dataBuilder['count']; $dataGet = $builder->get(); + + foreach($dataGet as $key => $value) { + $checklist = ChecklistK3::where('id', $value->checklist_k3_id)->first(); + $dataGet[$key]->checklist_k3_name = $checklist->name; + } + $totalRecord = $countBuilder->count(); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); } From 43e96917ffb9baadf41809abe6d69cdee69d8f1f Mon Sep 17 00:00:00 2001 From: farhan048 Date: Tue, 14 Feb 2023 17:53:50 +0700 Subject: [PATCH 06/11] search divisi update --- app/Http/Controllers/DivisiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/DivisiController.php b/app/Http/Controllers/DivisiController.php index 1991c24..6fe8287 100644 --- a/app/Http/Controllers/DivisiController.php +++ b/app/Http/Controllers/DivisiController.php @@ -70,7 +70,7 @@ class DivisiController extends Controller return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=> 200], 200); } - public function search() + public function search(Request $request) { $payload = $request->all(); $dataBuilder = $this->setUpPayload($payload, 'm_divisi'); From 7a07f7bd12585ced6f1d03066fc8f5a657a54120 Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 16 Feb 2023 00:48:50 +0700 Subject: [PATCH 07/11] update api maps monitoring --- .../Controllers/MapMonitoringController.php | 64 +++++++++++++++---- rest-client.http | 17 +++-- 2 files changed, 63 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/MapMonitoringController.php b/app/Http/Controllers/MapMonitoringController.php index 3614c2f..26b36cb 100644 --- a/app/Http/Controllers/MapMonitoringController.php +++ b/app/Http/Controllers/MapMonitoringController.php @@ -7,8 +7,6 @@ use Illuminate\Http\Request; use App\Models\Presence; use App\Models\Activity; use App\Models\MapMonitoring; -use GuzzleHttp\Client; -use Illuminate\Support\Facades\Http; use Carbon\Carbon; use Illuminate\Support\Facades\DB; @@ -17,18 +15,56 @@ class MapMonitoringController extends Controller // default map monitoring shows today's presence lat lon in the map public function search(Request $request) - { - // $payload = $request->all(); - // $dataBuilder = $this->setUpPayload($payload, 't_clock_in_out'); - // $builder = $dataBuilder['builder']; - // $countBuilder = $dataBuilder['count']; - // $dataGet = $builder->get(); - // $totalRecord = $countBuilder->count(); - // return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); - - $monitoringData = MapMonitoring::getUsers($request->all()); - var_dump($monitoringData); - + { + $dateNow = Carbon::today()->addHour(7)->format('Y-m-d'); + // get distinct human assign project + $hr_assign_project = DB::table('assign_hr_to_proyek') + ->select('user_id') + ->whereIn('proyek_id', $request->project_id) + ->distinct() + ->get(); + // get position hr in presensi + $tmp = []; + foreach($hr_assign_project as $key){ + $presensi = DB::table('t_clock_in_out as tcio') + ->select('tcio.id as clock_in_out_id','mu.id as user_id', 'mu.name as fullname', 'tcio.clock_in', 'tcio.clock_out', 'tcio.clock_in_lat', 'tcio.clock_in_lng', + 'tcio.clock_out_lat', 'tcio.clock_out_lng', 'tcio.clock_in_loc', 'tcio.clock_out_loc', 'tcio.clock_in_boundary', + 'tcio.clock_out_boundary', 'mu.username', 'tcio.date_presence', 'tcio.created_at') + ->join('m_users as mu', 'mu.id', '=', 'tcio.user_id') + ->where('mu.id', $key->user_id) + ->orderBy('tcio.id', 'DESC') + ->first(); + $project = DB::table('assign_hr_to_proyek as ahtp') + ->select('ahtp.proyek_id as id', 'mp.nama as project_name') + ->join('m_proyek as mp', 'mp.id', '=', 'ahtp.proyek_id') + ->whereIn('ahtp.proyek_id', $request->project_id) + ->where('ahtp.user_id', $key->user_id) + ->get(); + if($presensi && isset($presensi->user_id)){ + $image = DB::table('m_image')->select('image')->where('category', 'presensi')->where('ref_id', $presensi->clock_in_out_id)->first(); + $tmp[] = array( + 'user_id' => $presensi->user_id, + 'clock_in' => $presensi->clock_in, + 'clock_out' => $presensi->clock_out, + 'date_presence' => $presensi->date_presence, + 'clock_in_lat' => $presensi->clock_in_lat, + 'clock_in_lng' => $presensi->clock_in_lng, + 'clock_out_lat' => $presensi->clock_out_lat, + 'clock_out_lng' => $presensi->clock_out_lng, + 'clock_in_loc' => $presensi->clock_in_loc, + 'clock_out_loc' => $presensi->clock_out_loc, + 'clock_in_boundary' => $presensi->clock_in_boundary, + 'clock_out_boundary' => $presensi->clock_out_boundary, + 'username' => $presensi->username, + 'name' => $presensi->fullname, + 'image_selfie' => isset($image->image) ? $image->image : '-', + 'created_at' => $presensi->created_at, + 'presence_status' => $presensi->date_presence == $dateNow ? true : false,//true, //status date_presence, + 'projects' => $project + ); + } + } + return response()->json(['status'=>'success','code'=>200, 'data' => $tmp, 'totalRecord'=>count($tmp)], 200); } public function list() diff --git a/rest-client.http b/rest-client.http index 120334f..6cdd4ad 100644 --- a/rest-client.http +++ b/rest-client.http @@ -802,8 +802,8 @@ Authorization: Bearer {{token}} content-type: application/json { - "clock_out_lat": -6.16678379060529, - "clock_out_lng": 106.9175039866567, + "clock_in_lat": -6.16678379060529, + "clock_in_lng": 106.9175039866567, "clock_time": "2023-02-10T14:48:17+07:00", "type": "in", "user_id": 1247 @@ -815,8 +815,8 @@ Authorization: Bearer {{token}} content-type: application/json { - "clock_out_lat": -1.4264273154149407, - "clock_out_lng": 113.98530036945851, + "clock_in_lat": -1.4264273154149407, + "clock_in_lng": 113.98530036945851, "clock_time": "2023-02-13T16:40:17+07:00", "type": "in", "user_id": 1 @@ -864,7 +864,16 @@ content-type: application/json } ###### +POST {{hostname}}/map-monitoring/search +Authorization: Bearer {{token}} +content-type: application/json +{ + "project_id" : [1, 2, 3] + +} + +###### POST {{hostname}}/waypoint/add-bulk Authorization: Bearer {{token}} content-type: application/json From 742b23a8168940f499a2149d06258550e1224357 Mon Sep 17 00:00:00 2001 From: ibnu Date: Thu, 16 Feb 2023 09:49:30 +0700 Subject: [PATCH 08/11] update bugfix presensi --- app/Http/Controllers/PresenceController.php | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 0e844d0..3a6e7f5 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -22,24 +22,26 @@ class PresenceController extends Controller $checkLocation = $this->checkLocation($request); $statusBoundary = false; $date = date_create($request->clock_time); - // $ActivityId = null; - if(count($checkLocation) > 0){ - $checkLocation[0]['status_assign'] ? $statusBoundary = true - : $statusBoundary = false; + // assign and in boundary + if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){ + // $checkLocation[0]['status_assign'] ? $statusBoundary = true + // : + $statusBoundary = true; } - if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ + // not assign + if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ $data=array( 'id' => null, 'boundary' => $statusBoundary ); return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200); } - - if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ + // assign and not in boundary + if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ $data=array( 'id' => null, - 'boundary' => $statusBoundary + 'boundary' => true ); return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200); } @@ -141,6 +143,7 @@ class PresenceController extends Controller $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary")); } foreach ($check as $key) { + // assign and in boundary if($key->boundary){ $temp[]=array( "activity_id" => $dataGeom->id, @@ -149,18 +152,22 @@ class PresenceController extends Controller ); } } + // assign and not in boundary if(count($temp) < 1){ $temp[]=array( "activity_id" => null, - "boundary" => null, + "boundary" => false, "status_assign" => true + // "geom" => $geom, + // "cek" => $check[0]->boundary ); } } }else{ + // not assign $temp[]=array( "activity_id" => null, - "boundary" => null, + "boundary" => false, "status_assign" => false ); } From 7101008905c0341c44fa433f788f6e93c10cb883 Mon Sep 17 00:00:00 2001 From: farhan048 Date: Thu, 16 Feb 2023 15:26:36 +0700 Subject: [PATCH 09/11] Add boundary status --- app/Models/HumanResource.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Models/HumanResource.php b/app/Models/HumanResource.php index 4647aa2..222a835 100644 --- a/app/Models/HumanResource.php +++ b/app/Models/HumanResource.php @@ -32,6 +32,7 @@ class HumanResource extends Model 'created_by', 'updated_at', 'updated_by', - 'divisi_id' + 'divisi_id', + 'status_boundary' ]; } From 790ad536f89aff48a8490189fe066e9ba63029af Mon Sep 17 00:00:00 2001 From: farhan048 Date: Thu, 16 Feb 2023 16:07:41 +0700 Subject: [PATCH 10/11] Update Model HR --- app/Models/HumanResource.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Models/HumanResource.php b/app/Models/HumanResource.php index 222a835..4745a1d 100644 --- a/app/Models/HumanResource.php +++ b/app/Models/HumanResource.php @@ -34,5 +34,6 @@ class HumanResource extends Model 'updated_by', 'divisi_id', 'status_boundary' + ]; } From 9503d9e6c6c146a54eff450ddf364d48acfc184b Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 20 Feb 2023 12:41:20 +0700 Subject: [PATCH 11/11] Handling if cost planning < 0 --- app/Models/Activity.php | 7 +++++++ app/Models/UserToActivity.php | 3 +++ 2 files changed, 10 insertions(+) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 9be182c..7ee841a 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -127,6 +127,13 @@ class Activity extends Model if($parent = Activity::find($this->parent_id)){ $parentActWeight = $parent->bobot_planning; + if ($parentActWeight == 0) { + $parent->update([ + "persentase_progress" => 0 + ]); + return; + } + $totalChildProportionalProgress = 0; $childs = Activity::where("parent_id", $parent->id)->get(); foreach($childs as $child){ diff --git a/app/Models/UserToActivity.php b/app/Models/UserToActivity.php index 3dac828..a33667c 100644 --- a/app/Models/UserToActivity.php +++ b/app/Models/UserToActivity.php @@ -50,6 +50,9 @@ class UserToActivity extends Model } $activity->rencana_biaya -= $salary; + if ($activity->rencana_biaya < 0) { + $activity->rencana_biaya = 0; + } $activity->save(); });