Browse Source

update api maps monitoring

pull/3/head
ibnu 2 years ago
parent
commit
7a07f7bd12
  1. 64
      app/Http/Controllers/MapMonitoringController.php
  2. 17
      rest-client.http

64
app/Http/Controllers/MapMonitoringController.php

@ -7,8 +7,6 @@ use Illuminate\Http\Request;
use App\Models\Presence;
use App\Models\Activity;
use App\Models\MapMonitoring;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Http;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
@ -17,18 +15,56 @@ class MapMonitoringController extends Controller
// default map monitoring shows today's presence lat lon in the map
public function search(Request $request)
{
// $payload = $request->all();
// $dataBuilder = $this->setUpPayload($payload, 't_clock_in_out');
// $builder = $dataBuilder['builder'];
// $countBuilder = $dataBuilder['count'];
// $dataGet = $builder->get();
// $totalRecord = $countBuilder->count();
// return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
$monitoringData = MapMonitoring::getUsers($request->all());
var_dump($monitoringData);
{
$dateNow = Carbon::today()->addHour(7)->format('Y-m-d');
// get distinct human assign project
$hr_assign_project = DB::table('assign_hr_to_proyek')
->select('user_id')
->whereIn('proyek_id', $request->project_id)
->distinct()
->get();
// get position hr in presensi
$tmp = [];
foreach($hr_assign_project as $key){
$presensi = DB::table('t_clock_in_out as tcio')
->select('tcio.id as clock_in_out_id','mu.id as user_id', 'mu.name as fullname', 'tcio.clock_in', 'tcio.clock_out', 'tcio.clock_in_lat', 'tcio.clock_in_lng',
'tcio.clock_out_lat', 'tcio.clock_out_lng', 'tcio.clock_in_loc', 'tcio.clock_out_loc', 'tcio.clock_in_boundary',
'tcio.clock_out_boundary', 'mu.username', 'tcio.date_presence', 'tcio.created_at')
->join('m_users as mu', 'mu.id', '=', 'tcio.user_id')
->where('mu.id', $key->user_id)
->orderBy('tcio.id', 'DESC')
->first();
$project = DB::table('assign_hr_to_proyek as ahtp')
->select('ahtp.proyek_id as id', 'mp.nama as project_name')
->join('m_proyek as mp', 'mp.id', '=', 'ahtp.proyek_id')
->whereIn('ahtp.proyek_id', $request->project_id)
->where('ahtp.user_id', $key->user_id)
->get();
if($presensi && isset($presensi->user_id)){
$image = DB::table('m_image')->select('image')->where('category', 'presensi')->where('ref_id', $presensi->clock_in_out_id)->first();
$tmp[] = array(
'user_id' => $presensi->user_id,
'clock_in' => $presensi->clock_in,
'clock_out' => $presensi->clock_out,
'date_presence' => $presensi->date_presence,
'clock_in_lat' => $presensi->clock_in_lat,
'clock_in_lng' => $presensi->clock_in_lng,
'clock_out_lat' => $presensi->clock_out_lat,
'clock_out_lng' => $presensi->clock_out_lng,
'clock_in_loc' => $presensi->clock_in_loc,
'clock_out_loc' => $presensi->clock_out_loc,
'clock_in_boundary' => $presensi->clock_in_boundary,
'clock_out_boundary' => $presensi->clock_out_boundary,
'username' => $presensi->username,
'name' => $presensi->fullname,
'image_selfie' => isset($image->image) ? $image->image : '-',
'created_at' => $presensi->created_at,
'presence_status' => $presensi->date_presence == $dateNow ? true : false,//true, //status date_presence,
'projects' => $project
);
}
}
return response()->json(['status'=>'success','code'=>200, 'data' => $tmp, 'totalRecord'=>count($tmp)], 200);
}
public function list()

17
rest-client.http

@ -802,8 +802,8 @@ Authorization: Bearer {{token}}
content-type: application/json
{
"clock_out_lat": -6.16678379060529,
"clock_out_lng": 106.9175039866567,
"clock_in_lat": -6.16678379060529,
"clock_in_lng": 106.9175039866567,
"clock_time": "2023-02-10T14:48:17+07:00",
"type": "in",
"user_id": 1247
@ -815,8 +815,8 @@ Authorization: Bearer {{token}}
content-type: application/json
{
"clock_out_lat": -1.4264273154149407,
"clock_out_lng": 113.98530036945851,
"clock_in_lat": -1.4264273154149407,
"clock_in_lng": 113.98530036945851,
"clock_time": "2023-02-13T16:40:17+07:00",
"type": "in",
"user_id": 1
@ -864,7 +864,16 @@ content-type: application/json
}
######
POST {{hostname}}/map-monitoring/search
Authorization: Bearer {{token}}
content-type: application/json
{
"project_id" : [1, 2, 3]
}
######
POST {{hostname}}/waypoint/add-bulk
Authorization: Bearer {{token}}
content-type: application/json

Loading…
Cancel
Save