public function create($id) { $business = Business::all()->first(); $event = Event::find($id); $presentations = Presentation::where('event_id', $id)->where('cancelled', 0)->where('starts_at', '>', strtotime(Carbon::now()))->get(); foreach ($presentations as $presentation) { if ($presentation->cancelled == 0 || $presentation->cancelled != null) { $presentation->starts_at = date("d-m-Y h:i a", $presentation->starts_at); } } $presentations = $presentations->lists('starts_at', 'id'); $zones = Zone::where('event_id', $id)->lists('name', 'id'); $array = ['event' => $event, 'presentations' => $presentations, 'zones' => $zones, 'business' => $business]; return view('external.booking.create', $array); }
public function eventsForDate(Request $request) { $input = $request->all(); $date_at = strtotime($input['date_at']); $presentations = Presentation::where("cancelled", "0")->whereBetween("starts_at", [$date_at, $date_at + 86400])->get(); $eventsDate = Event::where("cancelled", "0")->where("selling_date", '<=', $date_at)->get(); $eventInformation = []; foreach ($eventsDate as $eventDate) { $presentationsDate = Presentation::where("cancelled", "0")->whereBetween("starts_at", [$date_at, $date_at + 86400])->where("event_id", $eventDate->id)->get(); $presentationInformation = []; if (count($presentationsDate) != 0) { foreach ($presentationsDate as $pre) { array_push($presentationInformation, array($pre->starts_at)); } array_push($eventInformation, array($eventDate->image, $eventDate->id, $eventDate->name, $eventDate->place->name, $eventDate->place->address, $eventDate->category->name, $presentationInformation)); } } $events = Event::where(["publication_date" => $date_at, "cancelled" => "0"])->get(); return view('external.calendar', ["events" => $events, "date_at" => $date_at, "presentations" => $presentations], compact('eventInformation')); }
/** * Show the form for creating a new resource. * * @param int $id * @return \Illuminate\Http\Response */ public function createSalesman($id) { $userId = Auth::user()->id; $moduleUser = ModuleAssigment::where(["salesman_id" => $userId, "status" => 1])->first(); if (!is_object($moduleUser)) { return back()->withErrors(['Usted no tiene modulo asignado, por lo tanto no puede vender']); } else { if (Auth::user()->role_id == config('constants.salesman') && Auth::user()->module && Auth::user()->module->openModule == 0) { return back()->withErrors(['Usted no ha abierto su caja, por lo tanto no puede vender']); } } //Buscar y enviar info de evento con $id $event = Event::find($id); $presentations = Presentation::where('event_id', $id)->where('cancelled', 0)->where('starts_at', '>', strtotime(Carbon::now()))->get(); $slots_array = array(); foreach ($presentations as $pres) { $slots = DB::table('slot_presentation')->where('presentation_id', $pres->id)->where('status', config('constants.seat_available'))->lists('slot_id', 'slot_id'); $slots_array[$pres->id] = $slots; } $presentations = $presentations->lists('starts_at', 'id'); foreach ($presentations as $key => $pres) { $presentations[$key] = date("Y-m-d H:i", $pres); } $presentations = $presentations->toArray(); $zones = Zone::where('event_id', $id)->lists('name', 'id'); $exchangeRate = ExchangeRate::where('status', config('constants.active'))->first(); return view('internal.salesman.buy', compact('event', 'presentations', 'zones', 'slots_array', 'exchangeRate')); }
/** * Display the specified resource. * * @return \Illuminate\Http\Response */ public function showSales() { $events = Event::all(); $tickets = Ticket::all(); $eventInformation = []; foreach ($events as $event) { // pueden ser muchos eventos. Necesito información para llenar la tabla $eventsDate = Presentation::where('event_id', '=', $event->id)->where('cancelled', '=', 0)->get(); foreach ($eventsDate as $eventDate) { $tickets = Ticket::where('presentation_id', '=', $eventDate->id)->get(); $onlineTickets = 0; $presentialTicket = 0; $subTotalOnline = 0; $subTotalPresential = 0; foreach ($tickets as $ticket) { if ($ticket->cancelled != 1) { if (empty($ticket->salesman_id)) { $onlineTickets = $onlineTickets + $ticket->quantity; $subTotalPresential = $subTotalPresential + $ticket->total_price; } else { $presentialTicket = $presentialTicket + $ticket->quantity; $subTotalOnline = $subTotalOnline + $ticket->total_price; } } } array_push($eventInformation, array($event->name, $eventDate->id, date("d/m/Y", $eventDate->starts_at), $onlineTickets, $subTotalPresential, $presentialTicket, $subTotalOnline, $subTotalPresential + $subTotalOnline)); } } // //return $eventInformation; return view('internal.admin.reports.sales', compact('eventInformation')); }