@extends('layouts.app')
@section('content')
    <div class="panel panel-primary">
        <div class="panel-heading">Vyhledejte si ubytování</div>
        <div class="panel-body">
            @include('flash::message')
            {{ Form::open(['route' => 'getResults', 'class' => 'form-horizontal']) }}
            <div class="form-group{{ $errors->has('date_start') ? ' has-error' : '' }}">
                <label class="col-md-4 control-label">Datum od</label>

                <div class="col-md-6">
                    {{ Form::date('date_start', $date_start,  ['class' => 'form-control']) }} @if ($errors->has('date_start'))
                        <span class="help-block">
                            <strong>{{ $errors->first('date_start') }}</strong>
                        </span>
                    @endif 
                </div>
				<label class="control-label">(RRRR-MM-DD)</label>
            </div>

            <div class="form-group{{ $errors->has('date_end') ? ' has-error' : '' }}">
                <label class="col-md-4 control-label">Datum do</label>

                <div class="col-md-6">
                    {{ Form::date('date_end', $date_end,  ['class' => 'form-control']) }} @if ($errors->has('date_end'))
                        <span class="help-block">
                            <strong>{{ $errors->first('date_end') }}</strong>
                        </span>
                    @endif
                </div>
				<label class="control-label">(RRRR-MM-DD)</label>
            </div>

            <div class="form-group">
                <div class="col-md-6 col-md-offset-4">
                    {{ Form::submit('Vyhledat', array('class'=>'btn btn-primary')) }}
                </div>
            </div>
            {{ Form::close() }}
        </div>
    </div>

    <div class="panel panel-primary">
        <div class="panel-heading">Nabízené pokoje</div>
        <div class="panel-body">
            @foreach($rooms as $room)
                <div class="row">
                    <div class="panel panel-primary">
                        <div class="panel-heading">
                            {{$room->accommodation_name}} > {{$room->room_name}}
                            <a href="{{ url('create_reservation/' . $room->room_id) }}" class="float_right">
                                <div class="btn right_btn">Vytvořit rezervaci</div>
                            </a>
                        </div>
                        <div class="panel-body">
                            <div class="float_left col-md-7">
                                <table class="table">
                                    <tr>
                                        <th class="col-md-5"> Počet lůžek:</th>
                                        <td class="col-md-1">{{$room->beds}}</td>
                                    </tr>
                                    <tr>
                                        <th class="col-md-5">Cena za noc a lůžko:</th>
                                        <td class="col-md-1">{{$room->price}}
                                        </td>
                                    </tr>
                                    <tr>
                                        <th class="col-md-5">Počet volných lůžek v daném termínu a ubytování:</th>
                                        <td class="col-md-1">{{$room->free}}
                                        </td>
                                    </tr>
                                    <tr>
                                        <th class="col-md-5">Počet volných pokojů v daném termínu a ubytování </th>
                                        <td class="col-md-1">{{$room->free_rooms}}
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div class="float_right col-md-5">
                                @if($room->image != null)
                                    <img alt="playground" class="float_right image_width"  src="data:image/jpeg;base64,{{base64_encode($room->image)}}">
                                @else
                                    <img alt="playground" class="float_right col-md-8" src="{{ asset('images/img_placeholder.png') }}">
                                @endif
                            </div>

                        </div>
                    </div>
                </div>

            @endforeach
        </div>
    </div>
@endsection
