@php($title = 'Агентства')
@extends('layouts.admin')
@section('content')
    <div>
        <div class="d-flex mb-3 align-items-center">
            <form class="p-2 border rounded-3 border-1 bg-white" method="GET" action="{{ route('admin.companies') }}">
                <input type="radio" class="btn-check" name="filter" value="all" id="status_all" autocomplete="off"
                    onclick="this.form.submit()" {{ $filter == 'all' || !$filter ? 'checked' : '' }}>
                <label class="btn p-2 fs-5" for="status_all">Все</label>
                @foreach ($statuses as $status)
                    <input type="radio" class="btn-check" name="filter" value="{{ $status->value }}"
                        id="status_{{ $status->value }}" autocomplete="off" onclick="this.form.submit()"
                        {{ $filter == $status->value ? 'checked' : '' }}>
                    <label class="btn p-2 fs-5"
                        for="status_{{ $status->value }}">{{ __('Companies ' . $status->value) }}</label>
                @endforeach
            </form>
            <div class="ms-auto p-2">
                <a class="btn btn-secondary" href="{{ route('admin.companies', ['filter' => 'trashed']) }}">Удаленные</a>
                <!--<button class="btn btn-primary py-2 px-3 fs-5" data-bs-toggle="modal" data-bs-target="#createCityModal">
                                                                                                    <i class="bi bi-plus"></i> Добавить комплекс
                                                                                                </button>-->
            </div>
        </div>
        @if ($companies->count() == 0)
            <div class="text-center py-5">Нет данных для отображения</div>
        @else
            <div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
                <table class="table m-0">
                    <thead>
                        <tr scope="col">
                            <th>Название
                            <th>ИНН
                            <th>Email
                            <th>Статус
                            <th>
                            <th>
                        </tr>
                    </thead>
                    <tbody class=" ">
                        @foreach ($companies as $company)
                            <tr scope="row">
                                <td class="align-middle">
                                    {{ $company->name }}
                                </td>
                                <td class="align-middle">
                                    {{ $company->inn }}
                                </td>
                                <td class="align-middle">
                                    {{ $company->email }}
                                </td>
                                <td class="align-middle">
                                    {{ __('Status ' . $company->status) }}
                                </td>
                                <td class="align-middle">

                                </td>
                                <td class="text-end">
                                    <div class="dropdown" style="">
                                        <button class="btn btn-light" type="button" id="dropdownMenuButton"
                                            data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                            <i class="bi bi-three-dots-vertical"></i>
                                        </button>
                                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                            <a class="dropdown-item"
                                                href="{{ route('admin.companies.edit', ['company' => $company]) }}">Редактировать</a>
                                            @if($company->trashed())
                                                <form method="post"
                                                action="{{ route('admin.companies.restore', ['company' => $company]) }}">
                                                @csrf
                                                <button class="dropdown-item" type="submit">Восстановить</button>
                                                </form>
                                                <form method="post"
                                                    action="{{ route('admin.companies.delete', ['company' => $company]) }}">
                                                    @csrf
                                                    <button class="dropdown-item" type="submit">Удалить полностью</button>
                                                </form>
                                            @else
                                                <form method="post"
                                                    action="{{ route('admin.companies.delete', ['company' => $company]) }}">
                                                    @csrf
                                                    <button class="dropdown-item" type="submit">Удалить</button>
                                                </form>
                                            @endif
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        @endif
    </div>

@endsection
