Browse Source

update logic multi area clockinout

pull/3/head
ibnu 1 year ago
parent
commit
8fee272740
  1. 11
      app/Http/Controllers/PresenceController.php

11
app/Http/Controllers/PresenceController.php

@ -264,12 +264,11 @@ class PresenceController extends Controller
$valGeom = json_decode($dataGeom->geom); $valGeom = json_decode($dataGeom->geom);
if($params->clock_in_out['type']=="out"){ if($params->clock_in_out['type']=="out"){
if($valGeom->type == "FeatureCollection"){ if($valGeom->type == "FeatureCollection"){
// 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($valGeom->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){ if($check[0]->boundary == true){
break; break;
} }
} }
@ -279,12 +278,11 @@ class PresenceController extends Controller
} }
}else{ }else{
if($valGeom->type == "FeatureCollection"){ if($valGeom->type == "FeatureCollection"){
// 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($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){ if($check[0]->boundary == true){
break; break;
} }
} }
@ -338,6 +336,7 @@ class PresenceController extends Controller
->whereDate("ma.end_date", ">=", $params->time) ->whereDate("ma.end_date", ">=", $params->time)
->get(); ->get();
$temp = []; $temp = [];
// return json_encode($geom);
if (count($geom) > 0) { if (count($geom) > 0) {
foreach($geom as $dataGeom){ foreach($geom as $dataGeom){
$valGeom = json_decode($dataGeom->geom); $valGeom = json_decode($dataGeom->geom);
@ -348,7 +347,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($valGeom->geometry)."'), $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")); 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; break;
} }
} }
@ -363,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){ if($check[0]->boundary == true){
break; break;
} }
} }

Loading…
Cancel
Save