@php use Seka\Portal\Modul\Terminy\Entities\Registracia\StavRegistracie; @endphp
<div class="m-0 p-0">
    <div class="list-group list-group-flush">
        @forelse($registracie as $registracia)
            <div class="list-group-item">
                <div class="media item-align-center">
                    <div class="container">
                        <div class="row justify-content-between align-items-center mb-2">
                            <div class="col">
                                <h3 class="h4 text-truncate">
                                    @if($registracia->pouzivatel)
                                        {{ $registracia->pouzivatel->cele_meno }}
                                    @else
                                        {{ $registracia->cele_meno }}
                                    @endif
                                </h3>
                            </div>
                            <div class="col-auto">
                                @if($registracia->trashed())
                                    <x-badge type="danger"
                                             :text="StavRegistracie::ZRUSENA->label()"
                                    ></x-badge>
                                @endif
                            </div>
                        </div>
                        <div class="row justify-content-between align-items-center">
                            <div class="col">
                                <div class="align-items-center">
                                    <div class="text-small">
                                        <ul class="list-inline text-muted">
                                            <li class="list-item">
                                                <span class="icon-home"></span>
                                                {{ $registracia->pracovisko->nazov }}
                                                [{{ $registracia->pracovisko->kod }}]
                                            </li>
                                            @if($registracia->poznamka)
                                                <li class="list-item">
                                                    <span class="icon-list"></span>
                                                    <small class="text-muted">Poznámka: {{ $registracia->poznamka }}</small>
                                                </li>
                                            @endif
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="col-auto">
                                <div class="dropdown">
                                    <button class="btn btn-sm btn-outline-primary dropdown-toggle dropdown-toggle-no-arrow"
                                            type="button" id="dropdownMenuButton-1"
                                            @if($registracia->trashed()) disabled @endif
                                            data-toggle="dropdown"
                                            aria-haspopup="true"
                                            aria-expanded="false">
                                        <i class="icon-dot-3"></i>
                                    </button>
                                    <div class="dropdown-menu dropdown-menu-sm">
                                        <a class="dropdown-item" href="#"
                                           onclick="event.preventDefault();(confirm('Chystáte sa odstrániť registráciu, prajete si pokračovať?')) ? document.getElementById('delete-registracia-{{ $registracia->hashId() }}-form').submit() : null;">
                                            <i class="fa fa-trash mr-1"></i>
                                            Zrušiť registráciu
                                        </a>

                                        <form id="delete-registracia-{{ $registracia->hashId() }}-form"
                                              action="{{ route('modul.terminy.backend.udalosti.udalost.registracie.delete', [$udalost, $registracia]) }}"
                                              method="POST" style="display: none;">
                                            @csrf
                                            @method('DELETE')
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row justify-content-between align-items-center">
                            @if($registracia->maVytvoreneMoznosti())
                                <div class="col">
                                    <div class="align-items-center">
                                        <div class="text-small">
                                            <span>Možnosti</span>
                                            <span class="text-muted">
                                                @forelse($registracia->moznosti as $zoznamMoznosti)
                                                    <small class="text-muted">
                                                        <small>{{ $zoznamMoznosti->getNazov() }}:</small>
                                                        @forelse($zoznamMoznosti->getMoznosti() as $moznost)
                                                            <small>{{ $moznost->getPopis() }} {{ !$loop->last ? ', ' : '' }}</small>
                                                        @empty
                                                            <small>-</small>
                                                        @endforelse
                                                        {{ !$loop->last ? '; ' : '' }}
                                                    </small>
                                                @empty
                                                    <li class="list-item">-</li>
                                                @endforelse
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            @endif
                            <div class="col-auto">
                                <div class="align-items-center">
                                    <div class="text-small">
                                        <ul class="list-unstyled text-muted">
                                            <li class="list-item">
                                                <span class="icon-user"></span>
                                                Vytvoril: {{ $registracia->vytvoril->cele_meno }}
                                            </li>
                                            <li class="list-item">
                                                <span class="icon-calendar"></span>
                                                Vytvorená: {{ $registracia->created_at->longRelativeDiffForHumans() }}
                                            </li>
                                            <li class="list-item">
                                                <span class="icon-calendar"></span>
                                                Aktualizovaná: {{ $registracia->updated_at->longRelativeDiffForHumans() }}
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        @empty
            <div class="list-group-item bg-light d-flex justify-content-center disabled py-4">
                <span class="text-muted h5">Žiadne registrácie na udalosti sa nenašli...</span>
            </div>
        @endforelse
    </div>
    <div class="card-footer bg-secondary d-flex justify-content-between align-items-center">
        {{ $registracie->onEachSide(5)->links('partials.pagination.pagination-links') }}
        {{ $registracie->links('partials.pagination.pagination-summary') }}
    </div>
</div>
