Browse Source

Merge branch 'master' of https://git.oslog.id/ordo/adw-backend

pull/3/head
farhan048 2 years ago
parent
commit
212adba1a7
  1. 62
      app/Http/Controllers/MapMonitoringController.php
  2. 27
      app/Http/Controllers/PresenceController.php
  3. 7
      app/Http/Controllers/ProjectToChecklistK3Controller.php
  4. 17
      rest-client.http

62
app/Http/Controllers/MapMonitoringController.php

@ -7,8 +7,6 @@ use Illuminate\Http\Request;
use App\Models\Presence; use App\Models\Presence;
use App\Models\Activity; use App\Models\Activity;
use App\Models\MapMonitoring; use App\Models\MapMonitoring;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Http;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -18,17 +16,55 @@ class MapMonitoringController extends Controller
public function search(Request $request) public function search(Request $request)
{ {
// $payload = $request->all(); $dateNow = Carbon::today()->addHour(7)->format('Y-m-d');
// $dataBuilder = $this->setUpPayload($payload, 't_clock_in_out'); // get distinct human assign project
// $builder = $dataBuilder['builder']; $hr_assign_project = DB::table('assign_hr_to_proyek')
// $countBuilder = $dataBuilder['count']; ->select('user_id')
// $dataGet = $builder->get(); ->whereIn('proyek_id', $request->project_id)
// $totalRecord = $countBuilder->count(); ->distinct()
// return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); ->get();
// get position hr in presensi
$monitoringData = MapMonitoring::getUsers($request->all()); $tmp = [];
var_dump($monitoringData); 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() public function list()

27
app/Http/Controllers/PresenceController.php

@ -22,24 +22,26 @@ class PresenceController extends Controller
$checkLocation = $this->checkLocation($request); $checkLocation = $this->checkLocation($request);
$statusBoundary = false; $statusBoundary = false;
$date = date_create($request->clock_time); $date = date_create($request->clock_time);
// $ActivityId = null; // assign and in boundary
if(count($checkLocation) > 0){ if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){
$checkLocation[0]['status_assign'] ? $statusBoundary = true // $checkLocation[0]['status_assign'] ? $statusBoundary = true
: $statusBoundary = false; // :
$statusBoundary = true;
} }
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ // not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => $statusBoundary 'boundary' => $statusBoundary
); );
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
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == null){ if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
$data=array( $data=array(
'id' => null, 'id' => null,
'boundary' => $statusBoundary 'boundary' => true
); );
return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200); return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200);
} }
@ -141,6 +143,7 @@ class PresenceController extends Controller
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary")); $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary"));
} }
foreach ($check as $key) { foreach ($check as $key) {
// assign and in boundary
if($key->boundary){ if($key->boundary){
$temp[]=array( $temp[]=array(
"activity_id" => $dataGeom->id, "activity_id" => $dataGeom->id,
@ -149,18 +152,22 @@ class PresenceController extends Controller
); );
} }
} }
// assign and not in boundary
if(count($temp) < 1){ if(count($temp) < 1){
$temp[]=array( $temp[]=array(
"activity_id" => null, "activity_id" => null,
"boundary" => null, "boundary" => false,
"status_assign" => true "status_assign" => true
// "geom" => $geom,
// "cek" => $check[0]->boundary
); );
} }
} }
}else{ }else{
// not assign
$temp[]=array( $temp[]=array(
"activity_id" => null, "activity_id" => null,
"boundary" => null, "boundary" => false,
"status_assign" => false "status_assign" => false
); );
} }

7
app/Http/Controllers/ProjectToChecklistK3Controller.php

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\ProjectToChecklistK3; use App\Models\ProjectToChecklistK3;
use App\Models\ChecklistK3;
class ProjectToChecklistK3Controller extends Controller class ProjectToChecklistK3Controller extends Controller
{ {
@ -122,6 +123,12 @@ class ProjectToChecklistK3Controller extends Controller
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
$dataGet = $builder->get(); $dataGet = $builder->get();
foreach($dataGet as $key => $value) {
$checklist = ChecklistK3::where('id', $value->checklist_k3_id)->first();
$dataGet[$key]->checklist_k3_name = $checklist->name;
}
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
} }

17
rest-client.http

@ -802,8 +802,8 @@ Authorization: Bearer {{token}}
content-type: application/json content-type: application/json
{ {
"clock_out_lat": -6.16678379060529, "clock_in_lat": -6.16678379060529,
"clock_out_lng": 106.9175039866567, "clock_in_lng": 106.9175039866567,
"clock_time": "2023-02-10T14:48:17+07:00", "clock_time": "2023-02-10T14:48:17+07:00",
"type": "in", "type": "in",
"user_id": 1247 "user_id": 1247
@ -815,8 +815,8 @@ Authorization: Bearer {{token}}
content-type: application/json content-type: application/json
{ {
"clock_out_lat": -1.4264273154149407, "clock_in_lat": -1.4264273154149407,
"clock_out_lng": 113.98530036945851, "clock_in_lng": 113.98530036945851,
"clock_time": "2023-02-13T16:40:17+07:00", "clock_time": "2023-02-13T16:40:17+07:00",
"type": "in", "type": "in",
"user_id": 1 "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 POST {{hostname}}/waypoint/add-bulk
Authorization: Bearer {{token}} Authorization: Bearer {{token}}
content-type: application/json content-type: application/json

Loading…
Cancel
Save