public function __construct() { $this->middleware('auth'); // Checking event_id key exist in session. if (Session::has('event_id')) { $eventId = Session::get('event_id'); $systemtrackId = Session::get('systemtrack_id'); $systemtrack = Systemtrack::find($systemtrackId); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); Session::forget('event_id'); } }
public function showboothAjax() { //log out from last booth if (Session::has('booth_id')) { $boothId = Session::get('booth_id'); $systemtrackId = Session::get('systemtrack_booth_id'); $systemtrack = Systemtrack::find($systemtrackId); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); Session::forget('booth_id'); // Session::forget('systemtrack_id'); } $boothId = Request::get('boothId'); $booth = Booth::find($boothId); $systemtrack = new Systemtrack(); $systemtrack->user_id = Auth::User()->id; $systemtrack->spot_id = $booth->spot_id; $systemtrack->do = Auth::User()->name . ' ' . 'visit' . ' ' . $booth->name . ' Booth ' . 'at' . ' ' . date("Y-m-d H:i:s"); $systemtrack->comein_at = date("Y-m-d H:i:s"); $systemtrack->type = 'booth'; $systemtrack->type_id = $boothId; $systemtrack->save(); Session::put('booth_id', $boothId); Session::put('systemtrack_booth_id', $systemtrack->id); // echo json_encode($booth); //echo "yarab far7a"; $result = $booth; $result2 = $booth->exhibitor->name; echo json_encode(array("value" => $result, "value2" => $result2)); }
/** * function run by server every certain time for logout */ public function outFromSystem() { $now = new DateTime(date("Y-m-d H:i:s")); $userid = Tracklogin::select('userid')->first(); $userId = $userid->userid; $sessiontime = Tracklogin::select('sessiontime')->get()->first(); $date2 = $sessiontime->sessiontime; $date3 = new DateTime($date2); $diff1 = $date3->diff($now); $test = $diff1->s; if ($diff1->s > 2) { //Checking event_id key exist in session. $maxID = DB::table('systemtracks')->max('id'); $eventid = Systemtrack::where('id', $maxID)->pluck('eventid'); $leave_at = Systemtrack::where('id', $maxID)->pluck('leave_at'); if ($eventid != 0 && $leave_at == NULL) { $systemeventid = Systemtrack::where('id', $maxID)->pluck('systemeventid'); $systemtrack = Systemtrack::find($systemeventid); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); } //Checking booth_id key exist in session. $maxID = DB::table('systemtracks')->max('id'); $boothid = Systemtrack::where('id', $maxID)->pluck('boothid'); $leave_at = Systemtrack::where('id', $maxID)->pluck('leave_at'); if ($boothid != 0 && $leave_at == Null) { $systemboothid = Systemtrack::where('id', $maxID)->pluck('systemboothid'); $systemtrack = Systemtrack::find($systemboothid); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); } $maxLogin = DB::table('tracklogins')->where('user_id', $userId)->max('login_at'); DB::table('tracklogins')->where('user_id', $userId)->where('login_at', $maxLogin)->update(['logout_at' => $now]); //Auth::logout(); } }
public function outFromSystem() { //ignore_user_abort(true); // $date1 = new DateTime(Session::get('sessionstart')); // $date2 = new DateTime(date("Y-m-d H:i:s")); // $date3 = new DateTime(Session::get('timer')); // $diff1 = $date2->diff($date1); //login // $diff2 = $date2->diff($date3); //refresh // // echo $diff->format('%h hours %i mintues %s secounds'); // // echo $diff->i; // //if($diff1->i > 1 ){ // ob_flush(); // if (connection_aborted()) { // // Checking event_id key exist in session. // if (Session::has('event_id')) { // $eventId=Session::get('event_id'); // $systemtrackId=Session::get('systemtrack_event_id'); // $systemtrack = Systemtrack::find($systemtrackId); // $systemtrack->leave_at=date("Y-m-d H:i:s"); // $systemtrack->save(); // Session::forget('event_id'); // // Session::forget('systemtrack_id'); // } // if (Session::has('booth_id')) { // $boothId=Session::get('booth_id'); // $systemtrackId=Session::get('systemtrack_booth_id'); // $systemtrack = Systemtrack::find($systemtrackId); // $systemtrack->leave_at=date("Y-m-d H:i:s"); // $systemtrack->save(); // Session::forget('booth_id'); // // Session::forget('systemtrack_id'); // } // $userId=Auth::user()->id; // $now = new DateTime(); // $maxLogin=DB::table('tracklogins') // ->where('user_id', $userId) // ->max('login_at'); // DB::table('tracklogins') // ->where('user_id', $userId) // ->where('login_at', $maxLogin) // ->update(['logout_at' => $now]); // Auth::logout(); // } ignore_user_abort(true); // inactive $date1 = new DateTime(Session::get('sessiontimer')); $date2 = new DateTime(date("Y-m-d H:i:s")); $diff1 = $date2->diff($date1); //refresh if ($diff1->i > 10) { // Checking event_id key exist in session. if (Session::has('event_id')) { $eventId = Session::get('event_id'); $systemtrackId = Session::get('systemtrack_event_id'); $systemtrack = Systemtrack::find($systemtrackId); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); Session::forget('event_id'); // Session::forget('systemtrack_id'); } if (Session::has('booth_id')) { $boothId = Session::get('booth_id'); $systemtrackId = Session::get('systemtrack_booth_id'); $systemtrack = Systemtrack::find($systemtrackId); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); Session::forget('booth_id'); // Session::forget('systemtrack_id'); } $userId = Auth::user()->id; $now = new DateTime(); $maxLogin = DB::table('tracklogins')->where('user_id', $userId)->max('login_at'); DB::table('tracklogins')->where('user_id', $userId)->where('login_at', $maxLogin)->update(['logout_at' => $now]); Auth::logout(); } else { for ($i = 0; $i < 5; $i++) { flush(); ob_flush(); echo connection_status(); if (connection_aborted()) { // Checking event_id key exist in session. if (Session::has('event_id')) { $eventId = Session::get('event_id'); $systemtrackId = Session::get('systemtrack_event_id'); $systemtrack = Systemtrack::find($systemtrackId); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); Session::forget('event_id'); // Session::forget('systemtrack_id'); } if (Session::has('booth_id')) { $boothId = Session::get('booth_id'); $systemtrackId = Session::get('systemtrack_booth_id'); $systemtrack = Systemtrack::find($systemtrackId); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); Session::forget('booth_id'); // Session::forget('systemtrack_id'); } $userId = Auth::user()->id; $now = new DateTime(); $maxLogin = DB::table('tracklogins')->where('user_id', $userId)->max('login_at'); DB::table('tracklogins')->where('user_id', $userId)->where('login_at', $maxLogin)->update(['logout_at' => $now]); Auth::logout(); //exit; } sleep(1); } } }
public function ajaxSearchForBoothTrack() { //if(Request::ajax){ $boothId = Request::get('optValue'); //echo $boothId; $booth = Booth::find($boothId); //} // $exhibitionevents=ExhibitionEvent::all(); // $users=User::all(); // $booths=Booth::all(); $systemtracks = Systemtrack::where('type', 'booth')->get(); //$systemtracks=Systemtrack::where('type','booth')->get(); $systemtrack_users = DB::table('systemtracks')->where('systemtracks.type', 'booth')->join('users', 'users.id', '=', 'systemtracks.user_id')->get(); // echo json_encode(array("value" => $booth, "value2" => $systemtracks)); return view('AdminCP.reports.systemtracks.ajaxbooth', compact('booth', 'systemtracks', 'systemtrack_users')); }
public function eventsreport() { $exhibitionevents = ExhibitionEvent::all(); $booths = array(); $i = 0; foreach ($exhibitionevents as $exhibitionevent) { $booths[$i] = Booth::where('exhibition_event_id', $exhibitionevent->id)->count(); $data = $exhibitionevent->name; // $allvisitors[$i]=Systemtrack::where('do','LIKE', "%$data%")->count(); $allvisitors[$i] = Systemtrack::where('type', 'exhibitionevent')->where('type_id', $exhibitionevent->id)->count(); $uniquevisit[$i] = Systemtrack::where('type', 'exhibitionevent')->where('type_id', $exhibitionevent->id)->distinct('user_id')->count('user_id'); $i++; } //var_dump($uniquevisit); exit(); return view('AdminCP.reports.exhibitionevents.eventreport', compact('exhibitionevents', 'booths', 'allvisitors', 'uniquevisit')); }
/** * function ajax for showing booths * @param integer $user_id * @return Response */ public function showboothAjax() { //log out from last booth if (Session::has('booth_id')) { $boothId = Session::get('booth_id'); $systemtrackId = Session::get('systemtrack_booth_id'); $systemtrack = Systemtrack::find($systemtrackId); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); Session::forget('booth_id'); // Session::forget('systemtrack_id'); } //check on event_id is exsist //log out from last booth if (Session::has('systemtrack_event_id')) { $systemtrack_event_id_value = Session::get('systemtrack_event_id'); $systemtrack_event = Systemtrack::find($systemtrack_event_id_value); if ($systemtrack_event->leave_at == null) { DB::table('systemtracks')->where('id', $systemtrack_event_id_value)->update(['leave_at' => date("Y-m-d H:i:s")]); //$systemtrack_booth->leave_at=date("Y-m-d H:i:s"); } } $boothId = Request::get('boothId'); $booth = Booth::find($boothId); $systemtrack = new Systemtrack(); $systemtrack->user_id = Auth::User()->id; $systemtrack->spot_id = $booth->spot_id; $systemtrack->do = Auth::User()->name . ' ' . 'visit' . ' ' . $booth->name . ' Booth ' . 'at' . ' ' . date("Y-m-d H:i:s"); $systemtrack->comein_at = date("Y-m-d H:i:s"); $systemtrack->type = 'booth'; $systemtrack->type_id = $boothId; $systemtrack->save(); Session::put('booth_id', $boothId); Session::put('systemtrack_booth_id', $systemtrack->id); DB::table('systemtracks')->where('id', $systemtrack->id)->update(['boothid' => $id, 'systemboothid' => $systemtrack->id]); // echo json_encode($booth); //echo "yarab far7a"; $result = $booth; $result2 = $booth->exhibitor->name; echo json_encode(array("value" => $result, "value2" => $result2)); }
/** * Log the user out of the application. * * @return \Illuminate\Http\Response */ public function getLogout() { // Checking event_id key exist in session. if (Session::has('event_id')) { $eventId = Session::get('event_id'); $systemtrackId = Session::get('systemtrack_event_id'); $systemtrack = Systemtrack::find($systemtrackId); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); Session::forget('event_id'); // Session::forget('systemtrack_id'); } if (Session::has('booth_id')) { $boothId = Session::get('booth_id'); $systemtrackId = Session::get('systemtrack_booth_id'); $systemtrack = Systemtrack::find($systemtrackId); $systemtrack->leave_at = date("Y-m-d H:i:s"); $systemtrack->save(); Session::forget('booth_id'); // Session::forget('systemtrack_id'); } $userId = Auth::user()->id; $now = new DateTime(); // Tracklogin::where('user_id', $userId) // ->max('login_at') // ->update(['logout_at' => $now]); $maxLogin = DB::table('tracklogins')->where('user_id', $userId)->max('login_at'); DB::table('tracklogins')->where('user_id', $userId)->where('login_at', $maxLogin)->update(['logout_at' => $now]); $this->auth->logout(); return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/'); }
/** * function to show event in certain page * * @param int $id * @return Response */ public function showEventPage($id) { //check on event_id is exsist if (Session::has('systemtrack_event_id')) { $systemtrack_event_id_value = Session::get('systemtrack_event_id'); $systemtrack_event = Systemtrack::find($systemtrack_event_id_value); if ($systemtrack_event->leave_at == null) { DB::table('systemtracks')->where('id', $systemtrack_event_id_value)->update(['leave_at' => date("Y-m-d H:i:s")]); //$systemtrack_booth->leave_at=date("Y-m-d H:i:s"); } } //check on booth_id is exsist if (Session::has('systemtrack_booth_id')) { $systemtrackid = Systemtrack::all()->last()->pluck('id'); $systemtrack_booth_id_value = Session::get('systemtrack_booth_id'); $systemtrack_booth = Systemtrack::find($systemtrack_booth_id_value); if ($systemtrack_booth->leave_at == null) { DB::table('systemtracks')->where('id', $systemtrack_booth_id_value)->update(['leave_at' => date("Y-m-d H:i:s")]); //$systemtrack_booth->leave_at=date("Y-m-d H:i:s"); } } $exhibitionevent = ExhibitionEvent::find($id); $booths = Booth::where('exhibition_event_id', $id)->get(); $systemtrack = new Systemtrack(); $systemtrack->user_id = Auth::User()->id; // $systemtrack->spot_id=$booth->spot_id; $systemtrack->do = Auth::User()->name . ' ' . 'visit' . ' ' . $exhibitionevent->name . ' Event ' . 'at' . ' ' . date("Y-m-d H:i:s"); $systemtrack->comein_at = date("Y-m-d H:i:s"); $systemtrack->type = 'exhibitionevent'; $systemtrack->type_id = $id; $systemtrack->save(); //save exhibition event id in session Session::put('event_id', $id); Session::put('systemtrack_event_id', $systemtrack->id); DB::table('systemtracks')->where('id', $systemtrack->id)->update(['eventid' => $id, 'systemeventid' => $systemtrack->id]); return view('exhibitionevents.eventpage', compact('exhibitionevent', 'booths')); }
public function booth() { if (!$this->adminAuth()) { return view('errors.404'); } $exhibitionevents = ExhibitionEvent::all(); $users = User::all(); $booths = Booth::all(); $systemtracks = Systemtrack::where('type', 'booth')->get(); $systemtrack_users = DB::table('systemtracks')->where('systemtracks.type', 'booth')->join('users', 'users.id', '=', 'systemtracks.user_id')->get(); return view('AdminCP.reports.systemtracks.booth', compact('booths', 'systemtracks', 'users', 'exhibitionevents', 'systemtrack_users')); }