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); $checkLocation = $this->checkLocation($request);
$statusBoundary = false; $statusBoundary = false;
$date = date_create($request->clock_time); $date = date_create($request->clock_time);
// $ActivityId = null; // assign and in boundary
if(count($checkLocation) > 0){ if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){
$checkLocation[0]['status_assign'] ? $statusBoundary = true // $checkLocation[0]['status_assign'] ? $statusBoundary = true
: $statusBoundary = false; // :
$statusBoundary = true;
} }
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ // not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => $statusBoundary 'boundary' => $statusBoundary
); );
return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200); return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200);
} }
// assign and not in boundary
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
$data=array( $data=array(
'id' => null, '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); 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")); $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) { foreach ($check as $key) {
// assign and in boundary
if($key->boundary){ if($key->boundary){
$temp[]=array( $temp[]=array(
"activity_id" => $dataGeom->id, "activity_id" => $dataGeom->id,
@ -149,18 +152,22 @@ class PresenceController extends Controller
); );
} }
} }
// assign and not in boundary
if(count($temp) < 1){ if(count($temp) < 1){
$temp[]=array( $temp[]=array(
"activity_id" => null, "activity_id" => null,
"boundary" => null, "boundary" => false,
"status_assign" => true "status_assign" => true
// "geom" => $geom,
// "cek" => $check[0]->boundary
); );
} }
} }
}else{ }else{
// not assign
$temp[]=array( $temp[]=array(
"activity_id" => null, "activity_id" => null,
"boundary" => null, "boundary" => false,
"status_assign" => false "status_assign" => false
); );
} }

Loading…
Cancel
Save