public function storeExchangeRate(StoreExchangeRateRequest $request)
 {
     //
     $exchangeRates = ExchangeRate::where('status', 1)->get();
     foreach ($exchangeRates as $exchangeRate) {
         $exchangeRate->status = 0;
         $exchangeRate->finishDate = new Carbon();
         $exchangeRate->save();
     }
     $input = $request->all();
     $module = new ExchangeRate();
     $module->buyingRate = $input['buyingRate'];
     $module->sellingRate = $input['sellingRate'];
     $module->status = 1;
     $module->startDate = new Carbon();
     //$module->endTime      =   new Carbon($input['endTime']);
     //Control de subida de imagen
     $module->save();
     return redirect('admin/config/exchange_rate');
 }
 public function showPayBooking(Request $request)
 {
     $codigo = $request['reserve_code'];
     if ($codigo == '' || $codigo == null) {
         return redirect()->back()->withErrors(['errors' => 'Buscar una reserva y seleccionarla']);
     }
     $tickets = Ticket::where('reserve', $codigo)->get();
     $event = $tickets->first()->event;
     $zone = $tickets->first()->zone;
     $presentation = $tickets->first()->presentation;
     $exchangeRate = ExchangeRate::where('status', config('constants.active'))->first();
     return view('internal.salesman.payBookingShow', array('tickets' => $tickets->first(), 'event' => $event, 'zone' => $zone, 'presentation' => $presentation, 'reserve' => $codigo, 'exchangeRate' => $exchangeRate));
 }
 /**
  * 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'));
 }