@extends('Layouts.master')

@section('content')
    <style>
        h1,h2,h3,h4,h5{
            text-align:center;
        }
    </style>
    <div class="main-container pb-4" id="tables">
        <div id="topbar" class="row mb-4">
            <div class="col-12 home-container border border-dark">
                <div class="row">
                    <div class="row">
                        <div class="col-6">
                            <p class="headersection text-center">@lang('lastDay')</p>
                            <div class="row">
                                <div class="col-sm-12 col-md-3">
                                    <p class="headertext">
                                        @lang('loaned'):
                                        <br>
                                         {{$lastday_lent}}
                                    </p>
                                </div>
                                <div class="col-sm-12 col-md-3">
                                    <p class="headertext">
                                        @lang('reserved'):
                                        <br>
                                        {{$lastday_reserved}}
                                    </p>
                                </div>
                                <div class="col-sm-12 col-md-3">
                                    <p>
                                        @lang('returned'):
                                        <br>
                                        {{$lastday_returned}}
                                    </p>
                                </div>
                                <div class="col-sm-12 col-md-3">
                                    <p>
                                        @lang('notes'):
                                        <br>
                                        {{$lastday_notes}}
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="col-6 section">
                            <p class="headersection text-center">@lang('storage')</p>
                            <div class="row">
                                <div class="col-sm-12 col-md-3">
                                    <p>
                                        @lang('available'):
                                        <br>
                                        {{$total_total - ($total_lent + $total_reserved)}}
                                    </p>
                                </div>
                                <div class="col-sm-12 col-md-3">
                                    <p>
                                        @lang('loaned'):
                                        <br>
                                        {{$total_lent}}
                                    </p>
                                </div>
                                <div class="col-sm-12 col-md-3">
                                    <p>
                                        @lang('reserved'):
                                        <br>
                                        {{$total_reserved}}
                                    </p>
                                </div>
                                <div class="col-sm-12 col-md-3">
                                    <p>
                                        @lang('total'):
                                        <br>
                                        {{$total_total}}
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="loans" class="row mb-4">
            <h3>
                @lang('loans')
            </h3>
            @if(count($lent) >= 1)
                <table class="table table-striped">
                    <thead>
                    <th class="text-center">@lang('place')</th>
                    <th>@lang('user')</th>
                    <th class="text-center">@lang('amount')</th>
                    </thead>
                    <tbody>
                    @for($i = 1; $i <= count($lent);$i++)
                        <tr>
                            <td class="col text-center">
                                {{$i}}
                            </td>
                            <td class="col">
                                @can('users_view')
                                    <a href="{{route('users.show',['user' => $lent[$i-1]->user->id])}}"  target="_blank" class="btn btn-success">
                                        {{$lent[$i-1]->user->username}}
                                    </a>
                                @else
                                    {{$lent[$i-1]->user->username}}
                                @endcan
                            </td>
                            <td class="col text-center">
                                {{$lent[$i-1]->sum}}
                            </td>
                        </tr>
                    @endfor
                    </tbody>
                </table>
            @else
                <h4>
                    @lang('no_amount')
                </h4>
            @endif

        </div>
        <div id="returns" class="row mb-4">
            <h3>
                @lang('returns')
            </h3>
            @if(count($returned) >= 1)
                <table class="table table-striped">
                    <thead>
                    <th class="text-center">@lang('place')</th>
                    <th>@lang('user')</th>
                    <th class="text-center">@lang('amount')</th>
                    </thead>
                    <tbody>
                    @for($i = 1; $i <= count($returned);$i++)
                        <tr>
                            <td class="col text-center">
                                {{$i}}
                            </td>
                            <td class="col">
                                @can('users_view')
                                    <a href="{{route('users.show',['user' => $returned[$i-1]->user->id])}}"  target="_blank" class="btn btn-success">
                                        {{$returned[$i-1]->user->username}}
                                    </a>
                                @else
                                    {{$returned[$i-1]->user->username}}
                                @endcan
                            </td>
                            <td class="col text-center">
                                {{$returned[$i-1]->sum}}
                            </td>
                        </tr>
                    @endfor
                    </tbody>
                </table>
            @else
                <h4>
                    @lang('no_amount')
                </h4>
            @endif
        </div>
        <div id="notes" class="row mb-4">
            <h3>
                @lang('notes')
            </h3>
            @if(count($notes) >= 1)
                <table class="table table-striped">
                    <thead>
                    <th class="text-center">@lang('place')</th>
                    <th>@lang('user')</th>
                    <th class="text-center">@lang('amount')</th>
                    </thead>
                    <tbody>
                    @for($i = 1; $i <= count($notes);$i++)
                        <tr>
                            <td class="col text-center">
                                {{$i}}
                            </td>
                            <td class="col">
                                @can('users_view')
                                    <a href="{{route('users.show',['user' => $notes[$i-1]->user->id])}}"  target="_blank" class="btn btn-success">
                                        {{$notes[$i-1]->user->username}}
                                    </a>
                                @else
                                    {{$notes[$i-1]->user->username}}
                                @endcan
                            </td>
                            <td class="col text-center align-middle">
                                {{$notes[$i-1]->amount}}
                            </td>
                        </tr>
                    @endfor
                    </tbody>
                </table>
            @else
                <h4>
                    @lang('no_amount')
                </h4>
            @endif
        </div>
        <div id="reservations" class="row mb-4">
            <h3>
                @lang('reservations')
            </h3>
            @if(count($reserved) >= 1)
                <table class="table table-striped">
                    <thead>
                    <th class="text-center">@lang('place')</th>
                    <th>@lang('user')</th>
                    <th class="text-center">@lang('amount')</th>
                    </thead>
                    <tbody>
                    @for($i = 1; $i <= count($reserved);$i++)
                        <tr>
                            <td class="col text-center">
                                {{$i}}
                            </td>
                            <td class="col">
                                @can('users_view')
                                    <a href="{{route('users.show',['user' => $reserved[$i-1]->user->id])}}"  target="_blank" class="btn btn-success">
                                        {{$reserved[$i-1]->user->username}}
                                    </a>
                                @else
                                    {{$reserved[$i-1]->user->username}}
                                @endcan
                            </td>
                            <td class="col text-center">
                                {{$reserved[$i-1]->sum}}
                            </td>
                        </tr>
                    @endfor
                    </tbody>
                </table>
            @else
                <h4>
                    @lang('no_amount')
                </h4>
            @endif

        </div>
        <div id="validations" class="row mb-3">
            <h3>
                @lang('validations')
            </h3>
            @if(count($validated) >= 1)
                <table class="table table-striped">
                    <thead>
                    <th class="text-center">@lang('place')</th>
                    <th>@lang('user')</th>
                    <th class="text-center">@lang('amount')</th>
                    </thead>
                    <tbody>
                    @for($i = 1; $i <= count($validated);$i++)
                        <tr>
                            <td class="col text-center align-middle">
                                {{$i}}
                            </td>
                            <td class="col align-middle">
                                @can('users_view')
                                    <a href="{{route('users.show',['user' => $validated[$i-1]->user->id])}}"  target="_blank" class="btn btn-success">
                                        {{$validated[$i-1]->user->username}}
                                    </a>
                                @else
                                    {{$validated[$i-1]->user->username}}
                                @endcan

                            </td>
                            <td class="col text-center align-middle">
                                {{$validated[$i-1]->amount}}
                            </td>
                        </tr>
                    @endfor
                    </tbody>
                </table>
            @else
                <h4>
                    @lang('no_amount')
                </h4>
            @endif

        </div>
        <div id="setups" class="row mb-3">
            <h3>
                @lang('setups')
            </h3>
            @if(count($setups) >= 1)
                <table class="table table-striped">
                    <thead>
                    <th class="text-center">@lang('place')</th>
                    <th>@lang('user')</th>
                    <th class="text-center">@lang('amount')</th>
                    </thead>
                    <tbody>
                    @for($i = 1; $i <= count($setups);$i++)
                        <tr>
                            <td class="col text-center align-middle">
                                {{$i}}
                            </td>
                            <td class="col align-middle">
                                @can('users_view')
                                    <a href="{{route('users.show',['user' => $setups[$i-1]->user->id])}}"  target="_blank" class="btn btn-success">
                                        {{$setups[$i-1]->user->username}}
                                    </a>
                                @else
                                    {{$setups[$i-1]->user->username}}
                                @endcan

                            </td>
                            <td class="col text-center align-middle">
                                {{$setups[$i-1]->amount}}
                            </td>
                        </tr>
                    @endfor
                    </tbody>
                </table>
            @else
                <h4>
                    @lang('no_amount')
                </h4>
            @endif
        </div>
        <div id="pickups" class="row mb-3">
            <h3>
                @lang('pickups')
            </h3>
            @if(count($pickups) >= 1)
                <table class="table table-striped">
                    <thead>
                    <th class="text-center">@lang('place')</th>
                    <th>@lang('user')</th>
                    <th class="text-center">@lang('amount')</th>
                    </thead>
                    <tbody>
                    @for($i = 1; $i <= count($pickups);$i++)
                        <tr>
                            <td class="col text-center align-middle">
                                {{$i}}
                            </td>
                            <td class="col align-middle">
                                @can('users_view')
                                    <a href="{{route('users.show',['user' => $pickups[$i-1]->user->id])}}"  target="_blank" class="btn btn-success">
                                        {{$pickups[$i-1]->user->username}}
                                    </a>
                                @else
                                    {{$pickups[$i-1]->user->username}}
                                @endcan
                            </td>
                            <td class="col text-center align-middle">
                                {{$setups[$i-1]->amount}}
                            </td>
                        </tr>
                    @endfor
                    </tbody>
                </table>
            @else
                <h4>
                    @lang('no_amount')
                </h4>
            @endif

        </div>
    </div>
@endsection
@section('scripting')
@endsection