@extends('layouts.appback')

@section('title', 'Elenco Aziende')

@section('content')
    <div class="container-fluid py-2">
        <div class="row">
            <div class="col-12">
                <div class="card my-4">
                    <div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
                        <div
                            class="bg-gradient-dark shadow-dark border-radius-lg pt-4 pb-3 d-flex justify-content-between align-items-center">
                            <h6 class="text-white text-capitalize ps-3 mb-0">Aziende</h6>
                            <a href="{{ route('aziende.create') }}" class="btn btn-primary me-3">Nuova Categoria</a>
                        </div>
                    </div>

                    <div class="card-body px-0 pb-2">
                        <div class="table-responsive p-0">
                            @if ($categorie->isEmpty())
                                <div class="alert alert-info m-3">Non ci sono aziende. Crea la prima!</div>
                            @else
                                <table class="table align-items-center mb-0">
                                    <thead>
                                        <tr>
                                            <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">
                                                #</th>
                                            <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">
                                                Nome</th>
                                            <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">
                                                Azienda</th>
                                            <th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">
                                                Status</th>

                                            <th
                                                class="text-end text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">
                                                Azioni</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach ($aziende as $azienda)
                                            <tr>
                                                <td class="text-sm">{{ $azienda->id }}</td>
                                                <td class="text-sm">{{ $azienda->nome }}</td>
                                                <td class="text-sm">{{ $azienda->azienda }}</td>
                                                <td class="text-sm">{{ $azienda->status }}</td>
                                                <td class="text-end">
                                                    <a href="{{ route('aziende.show', $azienda) }}"
                                                        class="btn btn-sm btn-outline-secondary">Vedi</a>
                                                    <a href="{{ route('aziende.edit', $azienda) }}"
                                                        class="btn btn-sm btn-outline-primary">Modifica</a>
                                                    <form action="{{ route('aziende.destroy', $azienda) }}" method="POST"
                                                        class="d-inline"
                                                        onsubmit="return confirm('Sei sicuro di voler eliminare questa azienda?');">
                                                        @csrf
                                                        @method('DELETE')
                                                        <button type="submit"
                                                            class="btn btn-sm btn-outline-danger">Elimina</button>
                                                    </form>
                                                </td>
                                            </tr>
                                        @endforeach
                                    </tbody>
                                </table>
                            @endif
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
