Browse Source

update logic multi area clockinout

pull/3/head
ibnu 1 year ago
parent
commit
9ec799d787
  1. 12
      app/Http/Controllers/PresenceController.php

12
app/Http/Controllers/PresenceController.php

@ -266,9 +266,9 @@ class PresenceController extends Controller
if($valGeom->type == "FeatureCollection"){ if($valGeom->type == "FeatureCollection"){
$multiArea = $valGeom->features; $multiArea = $valGeom->features;
foreach($multiArea as $area){ 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")); 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; break;
} }
} }
@ -282,7 +282,7 @@ class PresenceController extends Controller
foreach($multiArea as $area){ foreach($multiArea as $area){
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'), $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")); 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; break;
} }
} }
@ -345,9 +345,9 @@ class PresenceController extends Controller
// return count($valGeom->features); // return count($valGeom->features);
$multiArea = $valGeom->features; $multiArea = $valGeom->features;
foreach($multiArea as $area){ 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")); 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; break;
} }
} }
@ -362,7 +362,7 @@ class PresenceController extends Controller
foreach($multiArea as $area){ foreach($multiArea as $area){
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'), $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")); 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; break;
} }
} }

Loading…
Cancel
Save