Browse Source

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

Reviewed-on: ordo/adw-backend#185
pull/3/head
ibnu 1 year ago
parent
commit
995042102b
  1. 23
      app/Http/Controllers/HumanResourceController.php
  2. 7
      app/Http/Controllers/PresenceController.php

23
app/Http/Controllers/HumanResourceController.php

@ -10,7 +10,8 @@ use Illuminate\Support\Facades\Artisan;
class HumanResourceController extends Controller
{
public function add(Request $request){
public function add(Request $request)
{
$this->validate($request, [
'role_id' => 'required',
'name' => 'required',
@ -33,7 +34,8 @@ class HumanResourceController extends Controller
}
}
public function edit($id){
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
@ -48,7 +50,8 @@ class HumanResourceController extends Controller
}
}
public function update(Request $request, $id){
public function update(Request $request, $id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -112,7 +115,7 @@ class HumanResourceController extends Controller
public function list()
{
$data = HumanResource::select('id', 'name')->get();
$data = HumanResource::select('id', 'name', 'role_id')->get();
$countData = $data->count();
if ($data) {
@ -122,7 +125,8 @@ class HumanResourceController extends Controller
}
}
public function select(Request $request){
public function select(Request $request)
{
$search = $request->query('search');
@ -177,17 +181,16 @@ class HumanResourceController extends Controller
$data['old_password'] = md5($request->old_password);
if ($data['old_password'] !== $result->password) {
return response()->json(['status' => 'failed', 'message' => "old password seems doesn't match in records. please try again.", 'code' => 400], 400);
}
elseif($data['old_password'] === $result->password) {
} elseif ($data['old_password'] === $result->password) {
return response()->json(['status' => 'success', 'message' => "old password match", 'data' => $result, 'code' => 200], 200);
}
}
else {
} else {
return response()->json(['status' => 'failed', 'message' => 'old_password is required!', 'code' => 400], 400);
}
}
public function sync(){
public function sync()
{
Artisan::call('sync:integration-human-resources');
}
}

7
app/Http/Controllers/PresenceController.php

@ -258,6 +258,7 @@ class PresenceController extends Controller
// cek user tersebut apakah punya assign task yang ada bondary nya
// 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")
->join("m_activity as ma", "ma.id", "=", "ahta.activity_id")
->where("ahta.user_id", $params->user_id)
@ -326,14 +327,14 @@ class PresenceController extends Controller
ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary"));
}
}
if(count($check)>0){
if(isset($check[0]->boundary) && $check[0]->boundary){
if(!$user->status_boundary || count($check)>0){
if(!$user->status_boundary || (isset($check[0]->boundary) && $check[0]->boundary)){
$temp[]=array(
"activity_id" => $dataGeom->id,
"boundary" => $check[0]->boundary,
"status_assign" => true
);
} else if (isset($check[0]->within_radius) && $check[0]->within_radius) {
} else if (!$user->status_boundary || (isset($check[0]->within_radius) && $check[0]->within_radius)) {
$temp[]=array(
"activity_id" => $dataGeom->id,
"boundary" => $check[0]->within_radius,

Loading…
Cancel
Save