@ -25,11 +25,26 @@ class MapMonitoringController extends Controller
->get();
->get();
// get position hr in presensi
// get position hr in presensi
$tmp = [];
$tmp = [];
foreach($hr_assign_project as $key){
foreach ($hr_assign_project as $key) {
$presensi = DB::table('t_clock_in_out as tcio')
$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',
->select(
'tcio.clock_out_lat', 'tcio.clock_out_lng', 'tcio.clock_in_loc', 'tcio.clock_out_loc', 'tcio.clock_in_boundary',
'tcio.id as clock_in_out_id',
'tcio.clock_out_boundary', 'mu.username', 'tcio.date_presence', 'tcio.created_at')
'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')
->join('m_users as mu', 'mu.id', '=', 'tcio.user_id')
->where('mu.id', $key->user_id)
->where('mu.id', $key->user_id)
->orderBy('tcio.id', 'DESC')
->orderBy('tcio.id', 'DESC')
@ -40,7 +55,7 @@ class MapMonitoringController extends Controller
->whereIn('ahtp.proyek_id', $request->project_id)
->whereIn('ahtp.proyek_id', $request->project_id)
->where('ahtp.user_id', $key->user_id)
->where('ahtp.user_id', $key->user_id)
->get();
->get();
if($presensi & & isset($presensi->user_id)){
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();
$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,
@ -59,12 +74,12 @@ class MapMonitoringController extends Controller
'name' => $presensi->fullname,
'name' => $presensi->fullname,
'image_selfie' => isset($image->image) ? $image->image : '-',
'image_selfie' => isset($image->image) ? $image->image : '-',
'created_at' => $presensi->created_at,
'created_at' => $presensi->created_at,
'presence_status' => $presensi->date_presence == $dateNow ? true : false,//true, //status date_presence,
'presence_status' => $presensi->date_presence == $dateNow ? true : false, //true, //status date_presence,
'projects' => $project
'projects' => $project
);
);
}
}
}
}
return response()->json(['status'=>'success','code'=>200, 'data' => $tmp, 'totalRecord'=>count($tmp)], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $tmp, 'totalRecord' => count($tmp)], 200);
}
}
public function list()
public function list()
@ -72,10 +87,10 @@ class MapMonitoringController extends Controller
$data = Presence::all();
$data = Presence::all();
$countData = $data->count();
$countData = $data->count();
if($data){
if ($data) {
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
}else{
} else {
return response()->json(['status'=>'failed','message'=>'failed get list presence, please try again later!','code'=>400], 400);
return response()->json(['status' => 'failed', 'message' => 'failed get list presence, please try again later!', 'code' => 400], 400);
}
}
}
}