@ -26,11 +26,11 @@ class PresenceController extends Controller
$statusBoundary = true;
}
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if ($statusRestriction->status_boundary) {
if (! $statusRestriction->status_boundary) {
$statusBoundary = true;
}
// not assign
if(!$checkLocation[0]['status_assign'] & & $checkLocation[0]['boundary'] == false){
if(!$checkLocation[0]['status_assign'] & & $checkLocation[0]['boundary'] == false & & $statusBoundary == false ){
$data=array(
'id' => null,
'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);
}
// 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(
'id' => null,
'boundary' => true
@ -65,7 +65,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $resultUpdate,
"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,
"created_at" => $date,
"created_by" => $this->currentName
@ -86,7 +86,8 @@ class PresenceController extends Controller
}
$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(
'user_id'=> $request->user_id,
@ -139,11 +140,11 @@ class PresenceController extends Controller
$statusBoundary = true;
}
$statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first();
if ($statusRestriction->status_boundary) {
if (! $statusRestriction->status_boundary) {
$statusBoundary = true;
}
// not assign
if(!$checkLocation[0]['status_assign'] & & $checkLocation[0]['boundary'] == false){
if(!$checkLocation[0]['status_assign'] & & $checkLocation[0]['boundary'] == false & & $statusBoundary == false ){
$data=array(
'id' => null,
'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);
}
// 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(
'id' => null,
'boundary' => true
@ -178,7 +179,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $resultUpdate,
"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'],
"created_at" => $date,
"created_by" => $this->currentName
@ -232,7 +233,7 @@ class PresenceController extends Controller
DB::table('clock_in_out_boundary')->insert([
"clock_in_out_id" => $result->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,
"created_at" => $date,
"created_by" => $this->currentName
@ -259,13 +260,17 @@ class PresenceController extends Controller
// geom ada di table activity
// $clock_time =
$user = HumanResource::find($params->user_id);
$geom = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id")
$geomQuery = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id")
->join("m_activity as ma", "ma.id", "=", "ahta.activity_id")
->where("ahta.user_id", $params->user_id)
->whereNotNull("ma.geom")
->whereDate("ma.start_date", "< =", $params->time)
->whereDate("ma.end_date", ">=", $params->time)
->get();
->whereDate("ma.end_date", ">=", $params->time);
if (isset($params->report_k3['proyek_id'])) {
$geom = $geomQuery->where("ma.proyek_id", $params->report_k3['proyek_id'])->get();
} else {
$geom = $geomQuery->get();
}
$temp = [];
if (count($geom) > 0) {
foreach($geom as $dataGeom){
@ -341,6 +346,13 @@ class PresenceController extends Controller
"status_assign" => true
);
}
} else {
// bypass work area restriction
$temp[]=array(
"activity_id" => null,
"boundary" => true,
"status_assign" => true
);
}
}
// assign and not in boundary
@ -355,6 +367,14 @@ class PresenceController extends Controller
}
}
else{
if ($user->status_boundary) {
// bypass work area restriction
$temp[]=array(
"activity_id" => null,
"boundary" => true,
"status_assign" => true
);
} else {
// not assign
$temp[]=array(
"activity_id" => null,
@ -362,6 +382,7 @@ class PresenceController extends Controller
"status_assign" => false
);
}
}
return $temp;
}