Browse Source

update bugfix presensi

pull/3/head
ibnu 2 years ago
parent
commit
742b23a816
  1. 27
      app/Http/Controllers/PresenceController.php

27
app/Http/Controllers/PresenceController.php

@ -22,24 +22,26 @@ class PresenceController extends Controller
$checkLocation = $this->checkLocation($request);
$statusBoundary = false;
$date = date_create($request->clock_time);
// $ActivityId = null;
if(count($checkLocation) > 0){
$checkLocation[0]['status_assign'] ? $statusBoundary = true
: $statusBoundary = false;
// assign and in boundary
if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){
// $checkLocation[0]['status_assign'] ? $statusBoundary = true
// :
$statusBoundary = true;
}
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){
// not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
$data=array(
'id' => null,
'boundary' => $statusBoundary
);
return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200);
}
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){
// assign and not in boundary
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
$data=array(
'id' => null,
'boundary' => $statusBoundary
'boundary' => true
);
return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200);
}
@ -141,6 +143,7 @@ class PresenceController extends Controller
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary"));
}
foreach ($check as $key) {
// assign and in boundary
if($key->boundary){
$temp[]=array(
"activity_id" => $dataGeom->id,
@ -149,18 +152,22 @@ class PresenceController extends Controller
);
}
}
// assign and not in boundary
if(count($temp) < 1){
$temp[]=array(
"activity_id" => null,
"boundary" => null,
"boundary" => false,
"status_assign" => true
// "geom" => $geom,
// "cek" => $check[0]->boundary
);
}
}
}else{
// not assign
$temp[]=array(
"activity_id" => null,
"boundary" => null,
"boundary" => false,
"status_assign" => false
);
}

Loading…
Cancel
Save