Browse Source

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

Reviewed-on: ordo/adw-backend#194
pull/3/head
ibnu 1 year ago
parent
commit
07ec0a1527
  1. 21
      app/Http/Controllers/PresenceController.php

21
app/Http/Controllers/PresenceController.php

@ -26,11 +26,11 @@ class PresenceController extends Controller
$statusBoundary = true; $statusBoundary = true;
} }
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first(); $statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if ($statusRestriction->status_boundary) { if (!$statusRestriction->status_boundary) {
$statusBoundary = true; $statusBoundary = true;
} }
// not assign // not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => $statusBoundary 'boundary' => $statusBoundary
@ -38,7 +38,7 @@ class PresenceController extends Controller
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 // assign and not in boundary
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => true 'boundary' => true
@ -65,7 +65,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $resultUpdate, "clock_in_out_id" => $resultUpdate,
"user_id" => $request->user_id, "user_id" => $request->user_id,
"activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'] ? $checkLocation[$i]['activity_id'] : 0,
"type" => $request->type, "type" => $request->type,
"created_at" => $date, "created_at" => $date,
"created_by" => $this->currentName "created_by" => $this->currentName
@ -86,7 +86,8 @@ class PresenceController extends Controller
} }
$onlyDate = date_format($date,"Y-m-d"); $onlyDate = date_format($date,"Y-m-d");
$clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; // $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name;
$clock_in_loc = "test";
$dataAdd = array( $dataAdd = array(
'user_id'=> $request->user_id, 'user_id'=> $request->user_id,
@ -139,11 +140,11 @@ class PresenceController extends Controller
$statusBoundary = true; $statusBoundary = true;
} }
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first(); $statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if ($statusRestriction->status_boundary) { if (!$statusRestriction->status_boundary) {
$statusBoundary = true; $statusBoundary = true;
} }
// not assign // not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => $statusBoundary 'boundary' => $statusBoundary
@ -151,7 +152,7 @@ class PresenceController extends Controller
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 // assign and not in boundary
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){ if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => true 'boundary' => true
@ -178,7 +179,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $resultUpdate, "clock_in_out_id" => $resultUpdate,
"user_id" => $request->user_id, "user_id" => $request->user_id,
"activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'] ? $checkLocation[$i]['activity_id'] : 0,
"type" => $request->clock_in_out['type'], "type" => $request->clock_in_out['type'],
"created_at" => $date, "created_at" => $date,
"created_by" => $this->currentName "created_by" => $this->currentName
@ -232,7 +233,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $result->id, "clock_in_out_id" => $result->id,
"user_id" => $request->user_id, "user_id" => $request->user_id,
"activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'] ? $checkLocation[$i]['activity_id'] : 0,
"type" => $request->type, "type" => $request->type,
"created_at" => $date, "created_at" => $date,
"created_by" => $this->currentName "created_by" => $this->currentName

Loading…
Cancel
Save