@extends('layouts.app')
@section('content')
    <div class="panel panel-primary">
        <div class="panel-heading">Správa ubytovacích zařízení</div>
        <div class="panel-body">
            @include('flash::message')
            <div class="table-responsive">
                <table class="table">
                    <tr>
                        <th>Název ubytování</th>
                        <th>Vlastník</th>
                        <th>E-mail</th>
                        <th>Telefon</th>
                        <th>Povolení</th>
                        <th>Odstranit</th>
                    </tr>
                    @foreach($users as $user)
                        <tr>
                            <td><a href="{{ url('detail/' . $user->accommodation_id) }}">
                                    {{$user->accommodation_name}}
                                </a>
                            </td>
                            <td>{{$user->name}} {{$user->lname}}</td>
                            <td>{{$user->email}}</td>
                            <td>{{$user->phone_number}}</td>
                            <td>
                                @if($user->permission == 'false')
                                    {{ Form::open(array('method'=>'post', 'route' => array('permissionOK', $user->accommodation_id))) }}
                                    {{ Form::submit('Povolit', array('class'=>'btn btn-primary')) }}
                                    {{ Form::close() }}
                                @else
                                    {{ Form::open(array('method'=>'post', 'route' => array('permissionKO', $user->accommodation_id))) }}
                                    {{ Form::submit('Zakázat', array('class'=>'btn btn-primary')) }}
                                    {{ Form::close() }}
                                @endif
                            </td>
                            <td>{{ Form::open(array('method'=>'post', 'route' => array('deleteUser', $user->user_id))) }}
                                {{ Form::submit('Odstranit', array('class'=>'btn btn-primary')) }}
                                {{ Form::close() }}
                            </td>
                        </tr>
                    @endforeach
                </table>
            </div>
        </div>
    </div>
@endsection
