/** * 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 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'); }
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')); }
/** * 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)); }