@extends('Layouts.master')

@section('content')
    <div class="main-container pb-4">
        <div class="head-section mb-2">
            @include('Partials.Pages.Search.search_bar')
        </div>
        @include('Partials.Pages.reservation_selector')
        <table class="table table-striped">
            <thead>
            <th>@lang('user')</th>
            <th>@lang('room')</th>
            <th>@lang('items')</th>
            <th>@lang('date_start')</th>
            <th>@lang('date_end')</th>
            <th>@lang('action')</th>
            </thead>
            <tbody>
            @foreach($data as $reservation)
                <tr>
                    <td class="col-2 align-middle">
                        <a href="{{route('users.show',['user' => $reservation->user_id])}}" target="_blank"
                           class="btn btn-success">
                            {{$reservation->user->username}}
                        </a>
                    </td>
                    <td class="col-2 align-middle">
                        <a href="{{route('rooms.show',['room' => $reservation->room_id])}}" target="_blank"
                           class="btn btn-success">
                            {{$reservation->room->building->name}}.{{$reservation->room->name}}
                        </a>
                    </td>
                    <td class="col-2 align-middle">
                        @include('Partials.Pages.reservation_items')
                    </td>

                    <td class="col align-middle">
                        {{date('d.m.Y',strtotime($reservation->date_start))}}
                    </td>
                    <td class="col align-middle">
                        @if(!empty($reservation->date_end))
                            {{date('d.m.Y',strtotime($reservation->date_end))}}
                        @else
                            @lang('permanent')
                        @endif
                    </td>
                    <td>
                        @can('reservations_pickup')
                            @include('Partials.Pages.reservation_pickup')
                        @endcan
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
        @include('Partials.Pages.display')
    </div>
@endsection

@section('scripting')
@endsection