From 0f1bc0f32f3f148c2b6bb8797755556eb005ba62 Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 7 Feb 2023 09:59:03 +0700 Subject: [PATCH 1/2] update presence boundary --- app/Http/Controllers/PresenceController.php | 27 ++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 3feced9..192abea 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -5,6 +5,7 @@ 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 Carbon\Carbon; @@ -14,6 +15,10 @@ class PresenceController extends Controller { public function add(Request $request) { + + // + // $test = $this->checkLocation($request); + // return response()->json(['status'=>$test,'code'=>200], 200); $this->validate($request, [ 'user_id' => 'required' ]); @@ -58,12 +63,32 @@ class PresenceController extends Controller $result = Presence::create($dataAdd); + $data=array( + 'id' => $result->id, + 'boundary' => true + ); + if($result){ - return response()->json(['status'=>'success', 'id'=>$result->id,'message'=>'clock in successfully!','code'=>200], 200); + 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){ + // cek user tersebut apakah punya assign task yang ada bondary nya + // geom ada di table activity + $geom = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id") + ->join("m_activity as ma", "ma.id", "=", "ahta.activity_id") + ->where("ahta.user_id", $params->user_id) + ->whereDate("ma.start_date", "<=", $params->clock_time) + ->whereDate("ma.end_date", ">=", $params->clock_time) + ->where(DB::raw("ST_Intersects(ST_GeomFromGeoJSON('ma.geom'), ST_GeomFromText('POINT(".$params->clock_out_lng." ".$params->clock_out_lat.")', 4326))")) + ->get(); + // Activity::select('geom')->where(''); + // gejson to geom + // intersect dengan point req + return $geom; + } public function edit($id){ if(!$id || (int) $id < 0 || $id==""){ From 82069a335478c4f6404c70e3943b1e6a9fa94807 Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 7 Feb 2023 10:10:48 +0700 Subject: [PATCH 2/2] add assign_material_id in API reportActivity --- app/Http/Controllers/AssignMaterialController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/AssignMaterialController.php b/app/Http/Controllers/AssignMaterialController.php index 0f857d6..16f848a 100644 --- a/app/Http/Controllers/AssignMaterialController.php +++ b/app/Http/Controllers/AssignMaterialController.php @@ -174,10 +174,10 @@ class AssignMaterialController extends Controller ->where('description', '=', $row->material_name)->first(); return $val_uom ? $val_uom->uom : null; }) - ->addColumn('material_id', function($row){ - $material_id =AssignMaterial::select('assign_material_to_activity.material_id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") + ->addColumn('assign_material_id', function($row){ + $assignMaterial =AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first(); - return $material_id ? $material_id->material_id : null; + return $assignMaterial ? $assignMaterial->id : null; }) ->addColumn('action', function($row){ $dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")