Browse Source

Merge branch 'staging' of https://git.oslog.id/ordo/adw-backend into dev-ibnu

pull/3/head
ibnu 1 year ago
parent
commit
abac9aa8a3
  1. 25
      app/Http/Controllers/HumanResourceController.php
  2. 9
      app/Http/Controllers/MapMonitoringController.php
  3. 36
      app/Http/Controllers/PresenceController.php

25
app/Http/Controllers/HumanResourceController.php

@ -138,11 +138,26 @@ class HumanResourceController extends Controller
} }
} }
if($search && !empty($search)){ if ($search && !empty($search)) {
$data = UserToProyek::select("m_users.id as id", "m_users.name as name", "assign_hr_to_proyek.project_role as proyek_role")->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id') $data = UserToProyek::select("m_users.id as id", "m_users.name as name", "assign_hr_to_proyek.project_role as proyek_role")
->where("assign_hr_to_proyek.proyek_id", $idProyek)->where("m_users.name", 'like', '%'.$search.'%')->whereNotIn("m_users.id", $forbidden)->get(); ->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id')
}else{ ->where("assign_hr_to_proyek.proyek_id", $idProyek)
$data = UserToProyek::select("m_users.id as id", "m_users.name as name", "assign_hr_to_proyek.project_role as proyek_role")->where("assign_hr_to_proyek.proyek_id", $idProyek)->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id')->whereNotIn("m_users.id", $forbidden)->get(); ->where(function ($query) {
$query->where("assign_hr_to_proyek.is_customer", "!=", true)
->orWhereNull("assign_hr_to_proyek.is_customer");
})
->where("m_users.name", 'like', '%' . $search . '%')
->whereNotIn("m_users.id", $forbidden)->get();
} else {
$data = UserToProyek::select("m_users.id as id", "m_users.name as name", "assign_hr_to_proyek.project_role as proyek_role")
->where("assign_hr_to_proyek.proyek_id", $idProyek)
->where(function ($query) {
$query->where("assign_hr_to_proyek.is_customer", "!=", true)
->orWhereNull("assign_hr_to_proyek.is_customer");
})
->join('m_users', 'm_users.id', '=', 'assign_hr_to_proyek.user_id')
->whereNotIn("m_users.id", $forbidden)
->get();
} }
return response()->json($data); return response()->json($data);

9
app/Http/Controllers/MapMonitoringController.php

@ -38,10 +38,14 @@ class MapMonitoringController extends Controller
'tcio.clock_in_loc', 'tcio.clock_in_loc',
'tcio.clock_out_loc', 'tcio.clock_out_loc',
'tcio.date_presence', 'tcio.date_presence',
'mw.lat',
'mw.lon',
'mw.wptime'
) )
->join('m_users as mu', 'mu.id', '=', 'tcio.user_id') ->join('m_users as mu', 'mu.id', '=', 'tcio.user_id')
->join('m_waypoint as mw', 'mu.id', '=', 'mw.user_id')
->where('mu.id', $key->user_id) ->where('mu.id', $key->user_id)
->orderBy('tcio.id', 'DESC') ->orderBy('mw.wptime', 'DESC')
->first(); ->first();
$project = DB::table('assign_hr_to_proyek as ahtp') $project = DB::table('assign_hr_to_proyek as ahtp')
->select('ahtp.proyek_id as id', 'mp.nama as project_name') ->select('ahtp.proyek_id as id', 'mp.nama as project_name')
@ -53,6 +57,9 @@ class MapMonitoringController extends Controller
$image = DB::table('m_image')->select('image')->where('category', 'presensi')->where('ref_id', $presensi->clock_in_out_id)->first(); $image = DB::table('m_image')->select('image')->where('category', 'presensi')->where('ref_id', $presensi->clock_in_out_id)->first();
$tmp[] = array( $tmp[] = array(
'user_id' => $presensi->user_id, 'user_id' => $presensi->user_id,
'wp_lat' => $presensi->lat,
'wp_lon' => $presensi->lon,
'wp_time' => $presensi->wptime,
'clock_in' => $presensi->clock_in, 'clock_in' => $presensi->clock_in,
'clock_out' => $presensi->clock_out, 'clock_out' => $presensi->clock_out,
'clock_in_lat' => $presensi->clock_in_lat, 'clock_in_lat' => $presensi->clock_in_lat,

36
app/Http/Controllers/PresenceController.php

@ -266,6 +266,20 @@ class PresenceController extends Controller
if($valGeom->type == "FeatureCollection"){ if($valGeom->type == "FeatureCollection"){
$multiArea = $valGeom->features; $multiArea = $valGeom->features;
foreach($multiArea as $area){ foreach($multiArea as $area){
if ($area->geometry->type === "Point") {
$pointCoordinates = $area->geometry->coordinates;
$pointLng = $pointCoordinates[0];
$pointLat = $pointCoordinates[1];
$check = DB::select(DB::raw("SELECT ST_Distance(
ST_GeomFromGeoJSON('" . json_encode($area->geometry) . "'),
ST_GeomFromText('POINT(" . $params->clock_in_out['clock_in_lng'] . " " . $params->clock_in_out['clock_in_lat'] . ")', 4326)
) <= " . $area->properties->radius . " as within_radius"));
if ($check[0]->within_radius) {
break;
}
}
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'), $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary")); ST_GeomFromText('POINT(".$params->clock_in_out['clock_out_lng']." ".$params->clock_in_out['clock_out_lat'].")', 4326)) as boundary"));
if($check[0]->boundary){ if($check[0]->boundary){
@ -280,6 +294,20 @@ class PresenceController extends Controller
if($valGeom->type == "FeatureCollection"){ if($valGeom->type == "FeatureCollection"){
$multiArea = $valGeom->features; $multiArea = $valGeom->features;
foreach($multiArea as $area){ foreach($multiArea as $area){
if ($area->geometry->type === "Point") {
$pointCoordinates = $area->geometry->coordinates;
$pointLng = $pointCoordinates[0];
$pointLat = $pointCoordinates[1];
$check = DB::select(DB::raw("SELECT ST_Distance(
ST_GeomFromGeoJSON('" . json_encode($area->geometry) . "'),
ST_GeomFromText('POINT(" . $params->clock_in_out['clock_in_lng'] . " " . $params->clock_in_out['clock_in_lat'] . ")', 4326)
) <= " . $area->properties->radius . " as within_radius"));
if ($check[0]->within_radius) {
break;
}
}
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'), $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($area->geometry)."'),
ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary")); ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary"));
if($check[0]->boundary){ if($check[0]->boundary){
@ -292,12 +320,18 @@ class PresenceController extends Controller
} }
} }
if(count($check)>0){ if(count($check)>0){
if($check[0]->boundary){ if(isset($check[0]->boundary) && $check[0]->boundary){
$temp[]=array( $temp[]=array(
"activity_id" => $dataGeom->id, "activity_id" => $dataGeom->id,
"boundary" => $check[0]->boundary, "boundary" => $check[0]->boundary,
"status_assign" => true "status_assign" => true
); );
} else if (isset($check[0]->within_radius) && $check[0]->within_radius) {
$temp[]=array(
"activity_id" => $dataGeom->id,
"boundary" => $check[0]->within_radius,
"status_assign" => true
);
} }
} }
} }

Loading…
Cancel
Save