@parent > Disponibilidad @endsection @section('user_contenido') <?php use SRAC\Utilidades; use SRAC\Reserva; $user = Auth::user(); $user_status = $user->getStatus(); if ($user_status == 'suspendido') { $fecha_perdida = DateTime::createFromFormat("Y-m-d H:i:s", Reserva::where('user_id', $user->id)->where('estado', 'perdida')->orderBy('fecha_inicio', 'desc')->get()[0]->fecha_inicio); $fecha_habilitacion = new DateTime(); $fecha_habilitacion->setTimestamp($fecha_perdida->getTimestamp()); $fecha_habilitacion->add(new DateInterval('P' . Utilidades::$dias_castigo . 'D')); } if ($user_status == 'pendiente') { $fecha_pendiente = DateTime::createFromFormat("Y-m-d H:i:s", Reserva::where('user_id', $user->id)->where('estado', 'pendiente')->orderBy('fecha_inicio', 'desc')->get()[0]->fecha_inicio); } $anio = date('Y'); $mes = date('m'); $dia = date('d'); ?> @if($user_status == 'suspendido') @include('info.usuario_suspendido') @elseif($user_status == 'pendiente') @include('info.reservas_pendientes') @endif <table class="table"> <thead> <tr> <th class="text-center">Horario</th> @for($d = 0; $d < Auth::user()->visibleDays(); $d++)
@for($j = 9; $j < 24; $j++) <!-- controla las horas --> <tr> <td class="text-center">{{ $j . ':00'}}</td> @for($i = 0; $i < Auth::user()->visibleDays(); $i++) <td class="text-center"> {!! Form::open(['route' => 'cliente.reservas.store', 'method' => 'POST']) !!} <?php $fecha_inicio = new DateTime(); $fecha_inicio->setDate($anio, $mes, $dia + $i); $fecha_inicio->setTime($j, 0); $fecha_fin = new DateTime(); $fecha_fin->setDate($anio, $mes, $dia + $i); $fecha_fin->setTime($j + 1, 0); $reserva_aux = Reserva::createReserva($fecha_inicio, $fecha_fin, 1, Auth::user()->id); $estado = Reserva::getStatus($reserva_aux); $reservas_aux = Reserva::where('fecha_inicio', $fecha_inicio->format('Y-m-d H:i:s'))->get(); $count = $reservas_aux->count(); $count_max = Reserva::countMax($reserva_aux); ?> <div class="dropdown"> @if($estado == 'disponible') <div class="btn btn-primary dropdown-toggle" data-toggle="dropdown">Disponible @if($count > 0) <span class="badge">{{$count_max}}</span> <span class="caret"/> @endif </div> @else <a class="btn btn-danger dropdown-toggle" data-toggle="dropdown">No Disponible @if($count > 0) <span class="badge">{{$count_max}}</span> <span class="caret"/> @endif
/** * @param : $fecha_inicio, $fecha_fin * @response : Reserva[] * devuelve un array con las reserva pendientes en el intervalo */ public static function getPending($fecha_inicio, $fecha_fin) { $rango = Reserva::where('fecha_inicio', '>=', $fecha_inicio)->where('fecha_fin', '<=', $fecha_fin)->where('estado', '=', 'pendiente')->get(); return $rango > 0; }