From 8fee272740a6dd9dfa4831b1ea84e7f48f333ca5 Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 15 Aug 2023 14:58:55 +0700 Subject: [PATCH 1/2] update logic multi area clockinout --- app/Http/Controllers/PresenceController.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 00980cc..7490ab8 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -263,13 +263,12 @@ class PresenceController extends Controller foreach($geom as $dataGeom){ $valGeom = json_decode($dataGeom->geom); if($params->clock_in_out['type']=="out"){ - if($valGeom->type == "FeatureCollection"){ - // return count($valGeom->features); + if($valGeom->type == "FeatureCollection"){ $multiArea = $valGeom->features; foreach($multiArea as $area){ $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary")); - if($check[0]->boundary){ + if($check[0]->boundary == true){ break; } } @@ -278,13 +277,12 @@ class PresenceController extends Controller ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary")); } }else{ - if($valGeom->type == "FeatureCollection"){ - // return count($valGeom->features); + if($valGeom->type == "FeatureCollection"){ $multiArea = $valGeom->features; foreach($multiArea as $area){ $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary")); - if($check[0]->boundary){ + if($check[0]->boundary == true){ break; } } @@ -338,6 +336,7 @@ class PresenceController extends Controller ->whereDate("ma.end_date", ">=", $params->time) ->get(); $temp = []; + // return json_encode($geom); if (count($geom) > 0) { foreach($geom as $dataGeom){ $valGeom = json_decode($dataGeom->geom); @@ -348,7 +347,7 @@ class PresenceController extends Controller foreach($multiArea as $area){ $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary")); - if($check[0]->boundary){ + if($check[0]->boundary == true){ break; } } @@ -363,7 +362,7 @@ class PresenceController extends Controller foreach($multiArea as $area){ $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary")); - if($check[0]->boundary){ + if($check[0]->boundary == true){ break; } } From 9ec799d787d5db77e55c210cc4da12693e723413 Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 15 Aug 2023 15:04:36 +0700 Subject: [PATCH 2/2] update logic multi area clockinout --- app/Http/Controllers/PresenceController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 7490ab8..722607c 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -266,9 +266,9 @@ class PresenceController extends Controller if($valGeom->type == "FeatureCollection"){ $multiArea = $valGeom->features; foreach($multiArea as $area){ - $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), + $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary")); - if($check[0]->boundary == true){ + if($check[0]->boundary){ break; } } @@ -282,7 +282,7 @@ class PresenceController extends Controller foreach($multiArea as $area){ $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary")); - if($check[0]->boundary == true){ + if($check[0]->boundary){ break; } } @@ -345,9 +345,9 @@ class PresenceController extends Controller // return count($valGeom->features); $multiArea = $valGeom->features; foreach($multiArea as $area){ - $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), + $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary")); - if($check[0]->boundary == true){ + if($check[0]->boundary){ break; } } @@ -362,7 +362,7 @@ class PresenceController extends Controller foreach($multiArea as $area){ $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary")); - if($check[0]->boundary == true){ + if($check[0]->boundary){ break; } }