Browse Source

update presensi

pull/3/head
ibnu 2 years ago
parent
commit
f4f7e15ea0
  1. 142
      app/Http/Controllers/PresenceController.php

142
app/Http/Controllers/PresenceController.php

@ -44,82 +44,82 @@ class PresenceController extends Controller
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);
} }
// if($request->type=="out"){ if($request->type=="out"){
// $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name;
// $dataUpdate = array( $dataUpdate = array(
// "clock_out"=>$request->clock_time, "clock_out"=>$request->clock_time,
// "clock_out_lat" => $request->clock_out_lat, "clock_out_lat" => $request->clock_out_lat,
// "clock_out_lng" => $request->clock_out_lng, "clock_out_lng" => $request->clock_out_lng,
// "updated_by"=>$this->currentName, "updated_by"=>$this->currentName,
// "clock_out_loc" => $clock_out_loc, "clock_out_loc" => $clock_out_loc,
// "clock_out_boundary" => $statusBoundary "clock_out_boundary" => $statusBoundary
// ); );
// $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id); $resultUpdate = $this->updateFormAdd($dataUpdate, $request->user_id);
// if($resultUpdate && $resultUpdate > 0){ if($resultUpdate && $resultUpdate > 0){
// if($statusBoundary){ if($statusBoundary){
// for ($i=0; $i < count($checkLocation); $i++) { for ($i=0; $i < count($checkLocation); $i++) {
// # code... # code...
// DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
// "clock_in_out_id" => $resultUpdate, "clock_in_out_id" => $resultUpdate,
// "user_id" => $request->user_id, "user_id" => $request->user_id,
// "activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'],
// "type" => $request->type, "type" => $request->type,
// "created_at" => $date, "created_at" => $date,
// "created_by" => $this->currentName "created_by" => $this->currentName
// ]); ]);
// }; };
// }; };
// $data=array( $data=array(
// 'id' => $resultUpdate, 'id' => $resultUpdate,
// 'boundary' => $statusBoundary 'boundary' => $statusBoundary
// ); );
// return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200); return response()->json(['status'=>'success', 'data'=>$data,'message'=>'clock out success!','code'=>200], 200);
// } }
// else{ else{
// return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'clock out failed please try again!','code'=>400], 400);
// } }
// die(); die();
// } }
// $onlyDate = date_format($date,"Y-m-d"); $onlyDate = date_format($date,"Y-m-d");
// $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name; $clock_in_loc = $this->getLoc($request->clock_in_lat, $request->clock_in_lng)->display_name;
// $dataAdd = array( $dataAdd = array(
// 'user_id'=> $request->user_id, 'user_id'=> $request->user_id,
// 'clock_in'=> $request->clock_time, 'clock_in'=> $request->clock_time,
// 'date_presence'=> $onlyDate, 'date_presence'=> $onlyDate,
// 'created_by' => $this->currentName, 'created_by' => $this->currentName,
// 'clock_in_lat' => $request->clock_in_lat, 'clock_in_lat' => $request->clock_in_lat,
// 'clock_in_lng' => $request->clock_in_lng, 'clock_in_lng' => $request->clock_in_lng,
// 'clock_in_loc' => $clock_in_loc, 'clock_in_loc' => $clock_in_loc,
// 'clock_in_boundary' => $statusBoundary 'clock_in_boundary' => $statusBoundary
// ); );
// $result = Presence::create($dataAdd); $result = Presence::create($dataAdd);
// $data=array( $data=array(
// 'id' => $result->id, 'id' => $result->id,
// 'boundary' => $statusBoundary 'boundary' => $statusBoundary
// ); );
// if($result){ if($result){
// if($statusBoundary){ if($statusBoundary){
// for ($i=0; $i < count($checkLocation); $i++) { for ($i=0; $i < count($checkLocation); $i++) {
// # code... # code...
// DB::table('clock_in_out_boundary')->insert([ DB::table('clock_in_out_boundary')->insert([
// "clock_in_out_id" => $result->id, "clock_in_out_id" => $result->id,
// "user_id" => $request->user_id, "user_id" => $request->user_id,
// "activity_id" => $checkLocation[$i]['activity_id'], "activity_id" => $checkLocation[$i]['activity_id'],
// "type" => $request->type, "type" => $request->type,
// "created_at" => $date, "created_at" => $date,
// "created_by" => $this->currentName "created_by" => $this->currentName
// ]); ]);
// }; };
// }; };
// return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200); return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200);
// }else{ }else{
// return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400);
// } }
} }
private function checkLocation($params){ private function checkLocation($params){

Loading…
Cancel
Save