@extends('layouts.app')
@section('content')
    <div class="panel panel-primary">
        <div class="panel-heading">Správa rezervací ve Vašem ubytování</div>
        <div class="panel-body">
            {{ Form::open(['class' => 'form-horizontal',  'route' => array('chooseRoom',$accommodation->accommodation_id)])}}
            <div class="form-group{{ $errors->has('rooms') ? ' has-error' : '' }}">
                <label class="col-md-4 control-label">Vytvořit rezervaci pokoje</label>
                <div class="col-md-6">
                    {{ Form::select('rooms', $rooms,  null, ['class' => 'form-control' ]) }} @if ($errors->has('persons'))
                        <span class="help-block">
                            <strong>{{ $errors->first('rooms') }}</strong>
                        </span>
                    @endif
                </div>
                {{ Form::submit('Vytvořit rezervaci', array('class'=>'btn btn-primary')) }}
                {{ Form::close() }}
            </div>
        </div>
        <div class="panel-body">
            @include('flash::message')

            <div class="table-responsive">
                <table class="table">
                    <tr>
                        <th>Jméno a příjmení</th>
                        <th>E-mail</th>
                        <th>Telefon</th>
                        <th>Pokoj</th>
                        <th>Od</th>
                        <th>Do</th>
                        <th>Počet osob</th>
                        <th>Potvrzení</th>
                        <th>Upravit</th>
                        <th>Odstranit</th>
                    </tr>
                    @foreach($reservations as $reservation)
                        <tr>
                            <td>{{$reservation->customer_fname}} {{$reservation->customer_lname}}</td>
                            <td>{{$reservation->customer_email}}</td>
                            <td>{{$reservation->customer_phone_number}}</td>
                            <td>{{$reservation->room_name}}</td>
                            <td>{{ date('d. m. Y', strtotime($reservation->date_start))}}</td>
                            <td>{{ date('d. m. Y', strtotime($reservation->date_end))}}</td>
                            <td>{{$reservation->persons}}</td>
                            <td>@if($reservation->confirmation == 'true')
                                    Potvrzeno
                                @else
                                    {{ Form::open(array('method'=>'post', 'route' => array('confirmReservation', $reservation->reservation_id))) }}
                                    {{ Form::hidden('reservation_id', $reservation->reservation_id) }}
                                    {{ Form::submit('Potvrdit', array('class'=>'btn btn-primary')) }}
                                    {{ Form::close() }}
                                @endif
                            </td>
                            <td>
                                <a href="{{ url('edit_reservation/' . $reservation->reservation_id) }}">
                                    <button type="button" class="btn btn-primary">Upravit</button>
                                </a>
                            </td>
                            <td>{{ Form::open(array('method'=>'post', 'route' => array('deleteReservation', $reservation->reservation_id))) }}
                                {{ Form::hidden('reservation_id', $reservation->reservation_id) }}
                                {{ Form::submit('Odstranit', array('class'=>'btn btn-primary')) }}
                                {{ Form::close() }}
                            </td>
                        </tr>
                    @endforeach
                </table>
            </div>
        </div>
    </div>
@endsection
