@extends('layouts.default')

@section('content')
    @parent

    <section class="bg-white space-sm pb-4">
        <div class="container">
            <div class="row justify-content-between align-items-center">
                <div class="col-auto">
                    <h1 class="h2">Účet používateľa</h1>
                    <span>Akcie vykonané používateľom</span>
                </div>
                <div class="col-auto">
                    <span class="badge badge-light">{{ $akcie->total() }} vykonaných akcii</span>
                </div>
            </div>
        </div>
    </section>

    <section class="flush-with-above space-0">
        <div class="bg-white">
            <div class="container">
                <div class="row">
                    <div class="col">
                        <ul class="nav nav-tabs" id="myTab" role="tablist">
                            <li class="nav-item">
                                <a class="nav-link" href="{{ route('portal.sprava.pouzivatelia.edit', $pouzivatel) }}" role="tab">Hlavné</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link active" role="tab">Akcie</a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section class="flush-with-above height-80 d-block">
        <div class="tab-content">
            <div class="tab-pane active" role="tabpanel">
                <div class="container">
                    <div class="card card-sm shadow">
                        <div class="card-header bg-secondary d-flex justify-content-between align-items-center">
                            <div>
                                <span class="text-muted text-small">Počet položiek {{ ($akcie->currentPage() * $akcie->perPage()) - $akcie->perPage() + 1 }} - @if($akcie->total() > ($akcie->currentPage() * $akcie->perPage())) {{ $akcie->currentPage() * $akcie->perPage() }} @else {{ $akcie->total() }} @endif z {{ $akcie->total() }}</span>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="row">
                                <div class="col">
                                    <div class="table-responsive">
                                        <table class="table table-borderless table-hover align-items-center">
                                            <thead>
                                            <tr>
                                                <th scope="col">Akcia</th>
                                                <th scope="col">Značka</th>
                                                <th scope="col">Časová značka vykonania</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            @forelse($akcie as $akcia)
                                                <tr class="bg-white">
                                                    <th scope="row">
                                                        {{ $akcia->description }}
                                                    </th>
                                                    <td class="text-left">
                                                    <span class="badge badge-info text-uppercase">
                                                        {{ $akcia->log_name }}
                                                    </span>
                                                    </td>
                                                    <td class="text-left">
                                                        {{ $akcia->created_at->format('d.m.Y H:i:s') }}
                                                    </td>
                                                </tr>
                                            @empty
                                                <tr>
                                                    <td colspan="3">
                                                        <span class="text-muted text-center h5">Zatiaľ neexistujú žiadne akcie používateľa...</span>
                                                    </td>
                                                </tr>
                                            @endforelse
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        @if(!$akcie->isEmpty() && $akcie->hasPages())
                            <div class="row">
                                <div class="col-12 d-flex justify-content-center">
                                    {{ $akcie->onEachSide(25)->links() }}
                                </div>
                            </div>
                        @endif
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
@endsection