Browse Source

Merge pull request 'staging' (#109) from staging into master

Reviewed-on: ordo/adw-backend#109
pull/3/head
ibnu 1 year ago
parent
commit
6cbec3e111
  1. 26
      app/Http/Controllers/PresenceController.php

26
app/Http/Controllers/PresenceController.php

@ -263,20 +263,22 @@ class PresenceController extends Controller
foreach($geom as $dataGeom){ foreach($geom as $dataGeom){
$valGeom = json_decode($dataGeom->geom); $valGeom = json_decode($dataGeom->geom);
if($params->clock_in_out['type']=="out"){ if($params->clock_in_out['type']=="out"){
$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")); $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"));
}else{ }else{
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary")); $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary"));
} }
foreach ($check as $key) { if(count($check)>0){
// assign and in boundary if($check[0]->boundary){
if($key->boundary){ $temp[]=array(
$temp[]=array( "activity_id" => $dataGeom->id,
"activity_id" => $dataGeom->id, "boundary" => $check[0]->boundary,
"boundary" => $key->boundary, "status_assign" => true
"status_assign" => true );
); }
}
} }
}
// assign and not in boundary // assign and not in boundary
if(count($temp) < 1){ if(count($temp) < 1){
$temp[]=array( $temp[]=array(
@ -288,7 +290,7 @@ class PresenceController extends Controller
); );
} }
} }
}else{ else{
// not assign // not assign
$temp[]=array( $temp[]=array(
"activity_id" => null, "activity_id" => null,

Loading…
Cancel
Save