<div class="card">
    <div class="card-header">

        <div class="card-tools">
            <div class="input-group input-group-sm" style="width: 300px;">
                <input type="text" name="search" wire:model="search" class="form-control float-right"
                    placeholder="Cerca">

                <div class="input-group-append">
                    <button type="submit" class="btn btn-default">
                        <i class="fas fa-search"></i>
                    </button>
                </div>
            </div>
        </div>
    </div>
    <div class="card-body table-responsive p-0">
        <table class="table table-hover text-nowrap">
            <thead>
                <tr>
                    <th>Protocollo</th>
                    <th>Anno</th>
                    <th>Data</th>
                    <th>Indirizzo</th>
                    <th>Validato</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($records as $record)
                    @php
                        $ord = '';
                        switch ($record->protocollo_ord) {
                            case 2:
                                $ord = '/Bis';
                                break;
                            case 3:
                                $destUso = '/Ter';
                                break;
                            case 4:
                                $destUso = '/Quater';
                                break;
                            case 5:
                                $destUso = '/Quinquies';
                                break;
                            case 6:
                                $destUso = '/Sexies';
                                break;
                            case 7:
                                $destUso = '/Septies';
                                break;
                            case 8:
                                $destUso = '/Octies';
                                break;
                            case 9:
                                $destUso = '/Novies';
                                break;
                            case 10:
                                $destUso = '/Decies';
                                break;
                            default:
                                break;
                        }
                    @endphp
                    <tr style=" {{ $record->validated == 1 ? 'background-color: #ECF3F5;' : '' }}">
                        <td style="vertical-align: middle">{{ str_pad($record->protocollo_num, 3, '0', STR_PAD_LEFT) }}{{ $ord }}</td>
                        <td style="vertical-align: middle">{{ $record->protocollo_anno }}</td>
                        <td style="vertical-align: middle">{{ $record->verificatosi_in_data != '0000-00-00' ? date('d/m/Y', strtotime($record->verificatosi_in_data)) : '' }}
                        </td>
                        <td style="vertical-align: middle">{{ $record->indirizzo ? $record->indirizzo->TOPONIMO . ' ' . $record->indirizzo->DESCRIZIONE : '' }}
                        </td>
                        <td style="vertical-align:middle">{{ $record->validated == 1 ? 'VALIDATO' : '' }}</td>
                        <td><button wire:click="edit({{ $record->id }})" type="button"
                            class="btn {{ $record->validated == 1 ? 'btn-danger' : 'btn-primary' }} btn-block">
                            {{ $record->validated == 1 ? 'Visualizza' : 'Modifica' }}
                        </button></td>
                        <td><button onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()"
                                wire:click="delete({{ $record->id }})" type="button"
                                class="btn btn-success btn-block">Elimina</button></td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    </div>
    <div class="card-footer clearfix">
        <ul class="pagination pagination-sm m-0 float-right">
            {{ $records->links() }}
        </ul>
    </div>
</div>
