/** * Update the booth totals. * * @param Request $request * @param Booth $booth * @return Response */ public function updateBooths(Request $request) { foreach ($request->input('totals') as $id => $total) { $booth = Booth::find($id); $this->authorize('updateBooth', $booth); $booth->total = $total; $booth->save(); } return redirect('/booths'); }
public static function getBooths($day, $early = false, $weekend = false) { if ($early) { $type = [1]; } else { $type = [0]; } if ($weekend) { $type = [0, 1]; } return Booth::join('days', 'days.id', '=', 'day_id')->join('time_slots', 'time_slots.id', '=', 'time_slot_id')->where('user_id', 0)->where('day_id', $day)->whereIn('time_slots.type', $type)->orderBy('day_id', 'asc')->get(); }
public function postAutoAssign(Request $request) { // Weekend booths only = 1 // if this is a weekend booth, can assign to everyone // if this is a weekday booth, can only assign to troops with 0 $isWeekend = Day::find($request->date)->weekend; $brownies = User::getTroops('Brownie', $isWeekend)->toArray(); $juniors = User::getTroops('Junior', $isWeekend)->toArray(); $cadettes = User::getTroops('Cadette', $isWeekend)->toArray(); $seniors = User::getTroops('Senior', $isWeekend)->toArray(); $ambassadors = User::getTroops('Ambassador', $isWeekend)->toArray(); $all = array_merge($brownies, $juniors, $cadettes, $seniors, $ambassadors); $nonCsa = array_merge($brownies, $juniors); $csa = array_merge($cadettes, $seniors, $ambassadors); if ($isWeekend) { $booths = Booth::getBooths($request->date, '', $isWeekend); if ($booths->count()) { shuffle($all); foreach ($booths as $key => $booth) { $booth = Booth::find($booth['id']); $id = array_rand($all); $troop = $all[$id]; $booth->user_id = $troop['id']; $booth->save(); } } } else { $earlyBooths = Booth::getBooths($request->date, true, $isWeekend); $lateBooths = Booth::getBooths($request->date, false, $isWeekend); if ($earlyBooths->count()) { shuffle($nonCsa); foreach ($earlyBooths as $key => $booth) { $booth = Booth::find($booth['id']); $id = array_rand($nonCsa); $troop = $nonCsa[$id]; $booth->user_id = $troop['id']; $booth->save(); } } if ($lateBooths->count()) { shuffle($csa); foreach ($lateBooths as $key => $booth) { $booth = Booth::find($booth['id']); $id = array_rand($csa); $troop = $csa[$id]; $booth->user_id = $troop['id']; $booth->save(); } } } return redirect('/admin/booths'); }
/** * Show the application dashboard to the user. * * @return Response */ public function index(Route $route) { $upcomingexhibitionevents = ExhibitionEvent::where('start_time', '>', date("Y-m-d H:i:s"))->take(4)->get(); $currentlyexhibitionevents = ExhibitionEvent::where('start_time', '<', date("Y-m-d H:i:s"))->where('end_time', '>', date("Y-m-d H:i:s"))->take(4)->get(); $tracklogins = Tracklogin::where('user_id', '=', Auth::User()->id)->orderBy('created_at', 'desc')->take(2)->get(); $systemtracks = Systemtrack::where('user_id', '=', Auth::User()->id)->orderBy('created_at', 'desc')->take(5)->get(); if (Auth::User()->type == 'company') { $user = User::find(Auth::User()->id); $company = Company::where('user_id', $user->id)->get(); $company = $company[0]; $companyId = $company->id; $exhibitors = Exhibitor::where('company_id', $companyId)->get(); //$booths=array(); $events = array(); $i = 0; foreach ($exhibitors as $exhibitor) { $booths = Booth::where('exhibitor_id', $exhibitor->id)->get(); foreach ($booths as $booth) { $events[$i] = $booth->exhibition_event_id; $i++; } } $events = array_unique($events); //var_dump($events); exit(); $i = 0; $exhibitionevents = array(); foreach ($events as $event) { $exhibitionevents[$i] = ExhibitionEvent::find($event); $i++; } // var_dump($exhibitionevents[0]); exit(); $upcomingcompanyevents = array(); $currentlycompanyevents = array(); $finishedcompanyevents = array(); $i = 0; foreach ($exhibitionevents as $exhibitionevent) { if ($exhibitionevent->start_time > date("Y-m-d H:i:s")) { $upcomingcompanyevents[$i] = $exhibitionevent; $i++; } elseif ($exhibitionevent->start_time < date("Y-m-d H:i:s") && $exhibitionevent->end_time > date("Y-m-d H:i:s")) { $currentlycompanyevents[$i] = $exhibitionevent; $i++; } else { $finishedcompanyevents[$i] = $exhibitionevent; $i++; } } } return view('home', compact('upcomingexhibitionevents', 'currentlyexhibitionevents', 'tracklogins', 'systemtracks', 'upcomingcompanyevents', 'currentlycompanyevents', 'finishedcompanyevents')); }
/** * Take the booth. * * @param Request $request * @param Booth $booth * @return Response */ public function takeBooth(Request $request, Booth $booth) { $booth->user_id = $request->user()->id; $booth->save(); return redirect('/booths'); }
/** * list booth of certain company in certain events * @param integer $id * @return Response */ public function listboothsofcompanyinthisevent($id) { if (!$this->companyAuth($id)) { return view('errors.404'); } $user = User::find($id); $company = Company::where('user_id', $user->id)->get(); $company = $company[0]; $companyId = $company->id; $exhibitors = Exhibitor::where('company_id', $companyId)->get(); $booths = array(); $i = 0; foreach ($exhibitors as $exhibitor) { $booths = Booth::where('exhibitor_id', $exhibitor->id)->get(); $booths[$i] = $booths[0]; $i++; } // var_dump($booths); exit(); return view('booths.index', compact('booths')); }
/** * Get all of the unassigned early booths. * * @param User $user * @return Collection */ public function earlyBooths($day) { return Booth::join('days', 'days.id', '=', 'day_id')->where('user_id', 0)->where('day_id', $day)->orderBy('day_id', 'asc')->get(); }
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)); }
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)); }
/** * 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')); }