<div class="m-3">

    <div class="row mb-3">
        <div class="col-6">
            <h2>{{ $title }}</h2>
        </div>
        <div class="col-md-6 text-right">
            @if (!$add && !$update)
                <button wire:click="openModal()" type="button" class="btn btn-block btn-success float-right"
                    style="max-width:150px">
                    Aggiungi
                </button>
            @endif
        </div>
    </div>

    @if($showModal)
        <div class="modal fade show d-block" tabindex="-1" role="dialog" wire:keydown.escape="closeModal">
            <div class="modal-dialog modal-xl modal-dialog-scrollable" role="document">
                <div class="modal-content">
                    <div class="modal-header bg-light sticky-top">
                        <h5 class="modal-title">
                            <i class="fas fa-file-alt mr-2"></i>Nuovo Verbale
                        </h5>
                        <button type="button" class="close" wire:click="closeModal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <form wire:submit.prevent="add">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <div class="form-group">
                                            <label>Località</label>
                                            <select class="form-control select2 localita_uno" wire:model="localita_uno"
                                                style="width:100%">
                                                <option value="{{ $localita_uno }}">
                                                    {{ $this->getLocalita($localita_uno) }}
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label>Indirizzo</label>
                                        <select class="form-control select2 localita_due" wire:model="localita_due"
                                            style="width:100%">
                                            <option value="{{ $localita_due }}">
                                                {{ $this->getStradario($localita_due) }}
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Verificatosi in data</label>
                                        <input class="form-control" type="date" wire:model="verificatosi_in_data">
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="form-group">
                                        <label>Seleziona ora</label>
                                        <select class="form-control" wire:model="verificatosi_in_data_ora">
                                            <option value="">-- Seleziona ora --
                                            </option>
                                            @for ($hour = 0; $hour <= 23; $hour++)
                                                <option value="{{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}">
                                                    {{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}
                                                </option>
                                            @endfor
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="form-group">
                                        <label>Seleziona minuti</label>
                                        <select class="form-control" wire:model="verificatosi_in_data_minuti">
                                            <option value="">-- Seleziona minuti --
                                            </option>
                                            @for ($minute = 0; $minute <= 59; $minute++)
                                                <option value="{{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}">
                                                    {{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}
                                                </option>
                                            @endfor
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-6 col-md-6">
                                    <div class="form-group">
                                        <label>Data segnalazione</label>
                                        <input class="form-control" type="date" wire:model="segnalazione_data">
                                    </div>
                                </div>
                                <div class="col-sm-3 col-md-3">
                                    <div class="form-group">
                                        <label>Seleziona ora</label>
                                        <select class="form-control" wire:model="segnalazione_ora">
                                            <option value="">-- Seleziona ora --</option>
                                            @for ($hour = 0; $hour <= 23; $hour++)
                                                <option value="{{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}">
                                                    {{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}
                                            @endfor
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-3 col-md-3">
                                    <div class="form-group">
                                        <label>Seleziona minuti</label>
                                        <select class="form-control" wire:model="segnalazione_minuti">
                                            <option value="">-- Seleziona minuti --</option>
                                            @for ($minute = 0; $minute <= 59; $minute++)
                                                <option value="{{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}">
                                                    {{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}
                                            @endfor
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-3">
                                    <div class="form-group">
                                        <label>Ora intervento</label>
                                        <select class="form-control" wire:model="sinistro_ora">
                                            <option value="">-- Seleziona ora --</option>
                                            @for ($hour = 0; $hour <= 23; $hour++)
                                                <option value="{{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}">
                                                    {{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}
                                            @endfor
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <div class="form-group">
                                        <label>Minuti intervento</label>
                                        <select class="form-control" wire:model="sinistro_minuti">
                                            <option value="">-- Seleziona minuti --</option>
                                            @for ($minute = 0; $minute <= 59; $minute++)
                                                <option value="{{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}">
                                                    {{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}
                                            @endfor
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Tipo di rilievo</label>
                                        <select class="form-control" wire:model="rilievi_id" style="width:100%">
                                            <option value="">
                                                @foreach ($rilievi as $r)
                                                    <option value="{{ $r->id }}">{{ $r->name }}
                                                @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Localizzazione dell'incidente</label>
                                        <select class="form-control" wire:model="localizzazione_incidente"
                                            style="width:100%">
                                            <option value="">
                                            <option value="1">NELL'ABITATO
                                            <option value="2">FUORI DELL'ABITATO
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Nomenclatura strada</label>
                                        <select class="form-control" wire:model="nomenclatura_strada" style="width:100%">
                                            <option value="">
                                                @foreach ($nomenclature as $t)
                                                    <option value="{{ $t->id }}">{{ $t->name }}
                                                @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Condizioni atmosferiche</label>
                                        <select class="form-control" wire:model="condizioni_atmosferiche"
                                            style="width:100%">
                                            <option value="">
                                                @foreach ($condizioni_atmosferiche_array as $t)
                                                    <option value="{{ $t->id }}">{{ $t->name }}
                                                @endforeach
                                        </select>
                                    </div>
                                </div>

                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Visibilità</label>
                                        <select class="form-control" wire:model="visibilita"
                                            style="width:100%">
                                            <option value="">
                                            <option value="1">BUONA
                                            <option value="2">LIMITATA
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Pavimentazione strada</label>
                                        <select class="form-control" wire:model="pavimentazione"
                                            style="width:100%">
                                            <option value="">
                                                @foreach ($pavimentazioni as $t)
                                                    <option value="{{ $t->id }}">{{ $t->name }}
                                                @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Fondo stradale</label>
                                        <select class="form-control" wire:model="fondo_stradale"
                                            style="width:100%">
                                            <option value="">
                                                @foreach ($fondi_stradali as $t)
                                                    <option value="{{ $t->id }}">{{ $t->name }}
                                                @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Particolarità strada</label>
                                        <select class="form-control"
                                            wire:model="particolarita_strada" style="width:100%">
                                            <option value="">
                                                @foreach ($particolarita_strade as $t)
                                                    <option value="{{ $t->id }}">{{ $t->name }}
                                                @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Condizione strada</label>
                                        <select class="form-control" wire:model="condizione_strada"
                                            style="width:100%">
                                            <option value="">
                                                @foreach ($condizioni_strada as $t)
                                                    <option value="{{ $t->id }}">{{ $t->name }}
                                                @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" wire:click="closeModal">Chiudi</button>
                                <button type="submit" class="btn btn-primary">Crea</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    @endif

@if (session()->has('success'))
    <div class="alert alert-success" role="alert">
        {{ session()->get('success') }}
    </div>
@endif
@if (session()->has('error'))
    <div class="alert alert-danger" role="alert">
        {{ session()->get('error') }}
    </div>
@endif

@if (count($errors) > 0)
    <div class="alert alert-danger">
        @foreach ($errors->all() as $e)
            {{ $e }}<br>
        @endforeach
    </div>
@endif

@if (!$add && !$update)

    <div>

        <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 style="width:150px">&nbsp;</th>
                            <th style="width:150px">&nbsp;</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>
                                            <td>{{ $record->protocollo_num }}{{ $ord }}</td>
                                            <td>{{ $record->protocollo_anno }}</td>
                                            <td>{{ $record->verificatosi_in_data != '0000-00-00' ? date('d/m/Y', strtotime($record->verificatosi_in_data)) : '' }}
                                            </td>
                                            <td>{{ $record->indirizzo ? $record->indirizzo->TOPONIMO . ' ' . $record->indirizzo->DESCRIZIONE : '' }}
                                            </td>
                                            <td><button wire:click="edit({{ $record->id }})" type="button"
                                                    class="btn btn-primary btn-block">Modifica</button></td>
                                            <td><button onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()"
                                                    wire:click="delete({{ $record->id }})" type="button"
                                                    class="btn btn-danger 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>
    </div>
@else
    <div class="card card-primary">

        <form>

            <div class="card-header">

                <h3 class="card-title"><b>Inserimento/Modifica</b></h3>
                <div class="card-tools">
                    <div class="row">
                        <div class="col">
                            <button type="submit" class="btn btn-primary"
                                wire:click.prevent="update(true)">Valida&nbsp;verbale</button>
                        </div>
                        <div class="col" style="margin-right: 15px">
                            <a href="{{ route('print.pdf', ['id' => $this->dataId]) }}" target="_blank"
                                class="btn btn-block btn-success float-right">STAMPA</a>
                        </div>
                    </div>
                </div>
            </div>

            <div class="card-body">
                <div class="col-12 col-sm-12">
                    <div class="card card-primary card-outline card-tabs">
                        <div class="card-header p-0 border-bottom-0">
                            <ul class="nav nav-tabs" id="custom-tabs-three-tab" role="tablist">
                                <li class="nav-item" wire:ignore>
                                    <a class="nav-link active" id="tab1-tab" data-toggle="pill" href="#tab1" role="tab"
                                        aria-controls="tab1" aria-selected="true">Protocollo</a>
                                </li>
                                <li class="nav-item" wire:ignore>
                                    <a class="nav-link" id="tab2-tab" data-toggle="pill" href="#tab2" role="tab"
                                        aria-controls="tab2" aria-selected="false">Parti e Accertatori</a>
                                </li>
                                <li class="nav-item" wire:ignore>
                                    <a class="nav-link" id="tab3-tab" data-toggle="pill" href="#tab3" role="tab"
                                        aria-controls="tab3" aria-selected="false">Segnalazione</a>
                                </li>
                                <li class="nav-item" wire:ignore>
                                    <a class="nav-link" id="tab4-tab" data-toggle="pill" href="#tab4" role="tab"
                                        aria-controls="tab4" aria-selected="false">Campo del
                                        sinistro</a>
                                </li>
                                <li class="nav-item" wire:ignore>
                                    <a class="nav-link" id="tab5-tab" data-toggle="pill" href="#tab5" role="tab"
                                        aria-controls="tab5" aria-selected="false">Segnaletica</a>
                                </li>
                                <li class="nav-item" wire:ignore>
                                    <a class="nav-link" id="tab6-tab" data-toggle="pill" href="#tab6" role="tab"
                                        aria-controls="tab6" aria-selected="false">Testi
                                        oculari</a>
                                </li>
                                <li class="nav-item" wire:ignore>
                                    <a class="nav-link" id="tab7-tab" data-toggle="pill" href="#tab7" role="tab"
                                        aria-controls="tab7" aria-selected="false">Allegati</a>
                                </li>
                            </ul>
                        </div>
                        <div class="card-body">
                            <div class="tab-content" id="custom-tabs-three-tabContent">
                                <div class="tab-pane fade show active" id="tab1" role="tabpanel" aria-labelledby="tab1-tab"
                                    wire:ignore.self>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Generale</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <div class="custom-control custom-switch custom-switch-md">
                                                                    <input type="checkbox" class="custom-control-input"
                                                                        id="necessita_nulla_osta"
                                                                        wire:model="necessita_nulla_osta">
                                                                    <label class="custom-control-label"
                                                                        for="necessita_nulla_osta">Necessità nulla
                                                                        osta</label>
                                                                </div>

                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Data nulla osta</label>

                                                                <input class="form-control" type="date"
                                                                    wire:model="data_nulla_osta">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>Numero protocollo</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="protocollo_num">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>Anno protocollo</label>
                                                                <select class="form-control" wire:model="protocollo_anno">
                                                                    @for ($year = date('Y'); $year > 1970; $year--)
                                                                        <option value="{{ $year }}">
                                                                            {{ $year }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>Numerazione secondaria</label>
                                                                <select class="form-control" style="width:100%"
                                                                    wire:model="protocollo_ord">
                                                                    <option value=""></option>
                                                                    <option value="1">---</option>
                                                                    <option value="2">Bis</option>
                                                                    <option value="3">Ter</option>
                                                                    <option value="4">Quater</option>
                                                                    <option value="5">Quinquies</option>
                                                                    <option value="6">Sexies</option>
                                                                    <option value="7">Septies</option>
                                                                    <option value="8">Octies</option>
                                                                    <option value="9">Novies</option>
                                                                    <option value="10">Decies</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Verificatosi in data</label>
                                                                <input class="form-control" type="date"
                                                                    wire:model="verificatosi_in_data">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="form-group">
                                                                <label>Seleziona ora</label>
                                                                <select class="form-control"
                                                                    wire:model="verificatosi_in_data_ora">
                                                                    <option value="">-- Seleziona ora --
                                                                    </option>
                                                                    @for ($hour = 0; $hour <= 23; $hour++)
                                                                        <option
                                                                            value="{{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}
                                                                        </option>
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="form-group">
                                                                <label>Seleziona minuti</label>
                                                                <select class="form-control"
                                                                    wire:model="verificatosi_in_data_minuti">
                                                                    <option value="">-- Seleziona minuti --
                                                                    </option>
                                                                    @for ($minute = 0; $minute <= 59; $minute++)
                                                                        <option
                                                                            value="{{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}
                                                                        </option>
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <div class="custom-control custom-switch custom-switch-md">
                                                                    <input type="checkbox" class="custom-control-input"
                                                                        id="utg" wire:model="utg">
                                                                    <label class="custom-control-label"
                                                                        for="utg">UTG</label>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    @if ($utg)
                                                        <div class="row">
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>UTG data</label>
                                                                    <input class="form-control" type="date"
                                                                        wire:model="utg_data">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>UTG protocollo</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="utg_protocollo">
                                                                </div>
                                                            </div>
                                                        </div>
                                                    @endif
                                                    <div class="row">
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <div class="custom-control custom-switch custom-switch-md">
                                                                    <input type="checkbox" class="custom-control-input"
                                                                        id="ag" wire:model="ag">
                                                                    <label class="custom-control-label" for="ag">AG</label>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    @if ($ag)
                                                        <div class="row">
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>AG data</label>
                                                                    <input class="form-control" type="date"
                                                                        wire:model="ag_data">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>AG protocollo</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="ag_protocollo">
                                                                </div>
                                                            </div>
                                                        </div>
                                                    @endif
                                                    <div class="row">
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <div class="custom-control custom-switch custom-switch-md">
                                                                    <input type="checkbox" class="custom-control-input"
                                                                        id="incidente_con_danni_a_cose"
                                                                        wire:model="incidente_con_danni_a_cose">
                                                                    <label class="custom-control-label"
                                                                        for="incidente_con_danni_a_cose">Danni a
                                                                        cose</label>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <div class="custom-control custom-switch custom-switch-md">
                                                                    <input type="checkbox" class="custom-control-input"
                                                                        id="incidente_con_feriti"
                                                                        wire:model="incidente_con_feriti">
                                                                    <label class="custom-control-label"
                                                                        for="incidente_con_feriti">Feriti</label>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    @if ($incidente_con_feriti)
                                                        <div class="row">
                                                            <div class="col-sm-4">
                                                                <div class="form-group">
                                                                    <div class="custom-control custom-switch custom-switch-md">
                                                                        <input type="checkbox" class="custom-control-input"
                                                                            id="incidente_con_feriti_lesioni_lievi"
                                                                            wire:model="incidente_con_feriti_lesioni_lievi">
                                                                        <label class="custom-control-label"
                                                                            for="incidente_con_feriti_lesioni_lievi">Lesioni
                                                                            lievi</label>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-4">
                                                                <div class="form-group">
                                                                    <div class="custom-control custom-switch custom-switch-md">
                                                                        <input type="checkbox" class="custom-control-input"
                                                                            id="incidente_con_feriti_lesioni_gravi"
                                                                            wire:model="incidente_con_feriti_lesioni_gravi">
                                                                        <label class="custom-control-label"
                                                                            for="incidente_con_feriti_lesioni_gravi">Lesioni
                                                                            gravi</label>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    @endif
                                                    <div class="row">
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <div class="custom-control custom-switch custom-switch-md">
                                                                    <input type="checkbox" class="custom-control-input"
                                                                        id="incidente_mortale"
                                                                        wire:model="incidente_mortale">
                                                                    <label class="custom-control-label"
                                                                        for="incidente_mortale">Mortale</label>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Rapporto tecnico descrittivo incidente
                                                        stradale</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>Località</label>
                                                                <select class="form-control select2 localita_uno"
                                                                    wire:model="localita_uno" style="width:100%">
                                                                    <option value="{{ $localita_uno }}">
                                                                        {{ $this->getLocalita($localita_uno) }}
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>Indirizzo</label>
                                                                <select class="form-control select2 localita_due"
                                                                    wire:model="localita_due" style="width:100%">
                                                                    <option value="{{ $localita_due }}">
                                                                        {{ $this->getStradario($localita_due) }}
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>Intersezione con</label>
                                                                <select class="form-control select2 intersezione_con"
                                                                    wire:model="intersezione_con" style="width:100%">
                                                                    <option value="{{ $intersezione_con }}">
                                                                        {{ $this->getStradario($intersezione_con) }}
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>In prossimità del civico</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="prossimita_civico">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>In prossimità del palo della luce</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="prossimita_palo_luce">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>In prossimità del km</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="prossimita_chilometro">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-12">
                                                            <div class="form-group">
                                                                <label>Note aggiuntive</label>
                                                                <textarea class="form-control" rows="10"
                                                                    wire:model="note_aggiuntive"></textarea>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col  col-md-12">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Note</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <table class="table table-hover text-nowrap">
                                                            <thead>
                                                                <tr>
                                                                    <th>Data</th>
                                                                    <th>Creata da</th>
                                                                    <th>Nota</th>
                                                                    <th style="width:150px">&nbsp;</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                @foreach ($notes as $note)
                                                                    <tr>
                                                                        <td>{{ date('d/m/Y H:i', strtotime($note->created)) }}
                                                                        </td>
                                                                        <td></td>
                                                                        <td>{{ $note->text }}</td>
                                                                        <td><button
                                                                                onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()"
                                                                                wire:click.prevent="removeNote({{ $note->id }})"
                                                                                type="button"
                                                                                class="btn btn-danger btn-block"><i
                                                                                    class="fa fa-trash"></i>&nbsp;Elimina</button>
                                                                        </td>
                                                                    </tr>
                                                                @endforeach
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                    <div class="row">
                                                        <textarea class="form-control" rows="5"
                                                            wire:model="noteText"></textarea>
                                                        @if (!$this->validated)
                                                            <button type="button" class="btn btn-primary mt-2"
                                                                wire:click.prevent="addNote()">Aggiungi</button>
                                                        @endif
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Gestione richieste</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <table class="table table-hover text-nowrap">
                                                            <thead>
                                                                <tr>
                                                                    <th>Richiedente</th>
                                                                    <th>Data richiesta</th>
                                                                    <th>Data consegna</th>
                                                                    <th>Nota</th>
                                                                    <th style="width:100px">&nbsp;</th>
                                                                    <th style="width:100px">&nbsp;</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                @foreach ($richieste as $richiesta)
                                                                    <tr>
                                                                        <td>{{ $this->getAnagrafica($richiesta->anagrafica_id) }}
                                                                        </td>
                                                                        <td>{{ $richiesta->data_richiesta ? date('d/m/Y', strtotime($richiesta->data_richiesta)) : '' }}
                                                                        </td>
                                                                        <td>{{ $richiesta->consegna_richiesta ? date('d/m/Y', strtotime($richiesta->consegna_richiesta)) : '' }}
                                                                        </td>
                                                                        <td style="white-space: normal;max-width: 150px;">
                                                                            {{ $richiesta->description }}
                                                                        </td>
                                                                        <td><button
                                                                                wire:click="editRichiesta({{ $richiesta->id }})"
                                                                                type="button" class="btn btn-primary btn-block"
                                                                                style="background-color: orange;border-color: orange;"><i
                                                                                    class="fa fa-edit"></i></i></button>
                                                                        </td>
                                                                        <td><button
                                                                                onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()"
                                                                                wire:click.prevent="removeRichiesta({{ $richiesta->id }})"
                                                                                type="button"
                                                                                class="btn btn-danger btn-block"><i
                                                                                    class="fa fa-trash"></i>&nbsp;</button>
                                                                        </td>
                                                                    </tr>
                                                                @endforeach
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>Richiedente</label>
                                                                <select
                                                                    class="form-control richiestaAnagrafica @error('richiestaAnagrafica') is-invalid @enderror"
                                                                    style="width:100%">
                                                                    <option value="{{ $richiestaAnagrafica }}">
                                                                        {{ $this->getAnagrafica($richiestaAnagrafica) }}
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>Data richiesta</label>
                                                                <input
                                                                    class="form-control @error('richiestaData') is-invalid @enderror"
                                                                    type="date" wire:model="richiestaData">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-4">
                                                            <div class="form-group">
                                                                <label>Data consegna</label>
                                                                <input
                                                                    class="form-control @error('richiestaConsegna') is-invalid @enderror"
                                                                    type="date" wire:model="richiestaConsegna">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <textarea class="form-control" rows="5"
                                                            wire:model="richiestaText"></textarea>
                                                        @if (!$this->validated)
                                                            <button type="button" class="btn btn-primary mt-2"
                                                                wire:click.prevent="saveRichiesta()">Aggiungi</button>
                                                        @endif
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                                <div class="tab-pane fade" id="tab2" role="tabpanel" aria-labelledby="tab2-tab"
                                    wire:ignore.self>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Parti coinvolte</h3>
                                                </div>
                                                <div class="card-body">
                                                    @foreach ($parti_coinvolte as $idx => $p)
                                                        <div class="row">
                                                            <div class="col-sm-12">
                                                                <div class="form-group">
                                                                    <label>Conducente o pedone</label><br>
                                                                    <input type="radio" value="2" {{ $p->conducente_o_pedone == 2 ? 'checked' : '' }} name="type{{ $idx }}"
                                                                        wire:click="updateConducentePedoneParteCoinvolta(2, {{ $p->progressive }})">Conducente
                                                                    <input type="radio" value="1" {{ $p->conducente_o_pedone == 1 ? 'checked' : '' }} name="type{{ $idx }}"
                                                                        wire:click="updateConducentePedoneParteCoinvolta(1, {{ $p->progressive }})">Pedone
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Anagrafica parte coinvolta </label>
                                                                    <div class="row">
                                                                        <div class="col-sm-6">
                                                                            <select class="form-control anagraficaClass"
                                                                                data-progressive="{{ $p->progressive }}"
                                                                                style="width:100%">
                                                                                <option value="{{ $p->anagrafica }}">
                                                                                    {{ $this->getAnagrafica($p->anagrafica) }}
                                                                            </select>
                                                                        </div>
                                                                        <div class="col-sm-5">
                                                                            @if ($p->anagrafica > 0)
                                                                                <a class="btn btn-primary editAnagrafica"
                                                                                    wire:click.prevent="editAnagraficaParte({{ $p->progressive }})"
                                                                                    data-toggle="modal"
                                                                                    data-target="#anagraficaParte"
                                                                                    style="background-color: orange;border-color: orange;"><i
                                                                                        class="fa fa-edit"></i></i></a>
                                                                                @if ($p->conducente_o_pedone == 1)
                                                                                    <a class="btn btn-primary editPedone"
                                                                                        wire:click.prevent="editPedoneData({{ $p->progressive }})"
                                                                                        data-toggle="modal"
                                                                                        data-target="#pedoneModal"><i
                                                                                            class="fa-solid fa-info"></i></a>
                                                                                @endif
                                                                                <a onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()"
                                                                                    wire:click.prevent="removeAnagraficaParteCoinvolta({{ $p->progressive }})"
                                                                                    class="btn btn-danger"><i
                                                                                        class="fa fa-trash"></i>&nbsp;</a>
                                                                            @else
                                                                                <a class="btn btn-primary"
                                                                                    wire:click.prevent="addAnagrafica({{ $p->progressive }})"
                                                                                    data-toggle="modal"
                                                                                    data-target="#anagraficaParte">+&nbsp;</a>
                                                                            @endif
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    @if ($p->conducente_o_pedone == 2)
                                                                        <label>Veicolo parte coinvolta
                                                                            {{ App\Helpers\PoliziaUtils::numberToLetter($p->progressive) }}</label>
                                                                        <div class="row">
                                                                            <div class="col-sm-6">
                                                                                <select class="form-control veicoliClass"
                                                                                    data-progressive="{{ $p->progressive }}"
                                                                                    style="width:100%">
                                                                                    <option value="{{ $p->veicolo }}">
                                                                                        {{ $this->getVeicolo($p->veicolo) }}
                                                                                </select>
                                                                            </div>
                                                                            <div class="col-sm-5">
                                                                                @if ($p->veicolo > 0)
                                                                                    <a class="btn btn-primary editVeicolo"
                                                                                        wire:click.prevent="editVeicolo({{ $p->veicolo }})"
                                                                                        data-toggle="modal" data-target="#veicoloParte"
                                                                                        style="background-color: orange;border-color: orange;"><i
                                                                                            class="fa fa-edit"></i></i></a>
                                                                                    <a class="btn btn-primary editVeicoloData"
                                                                                        wire:click.prevent="editVeicoloData({{ $p->progressive }})"
                                                                                        data-toggle="modal"
                                                                                        data-target="#veicoloDataParte"><i
                                                                                            class="fa-solid fa-info"></i></a>
                                                                                    <a onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()"
                                                                                        wire:click.prevent="removeVeicoloParteCoinvolta({{ $p->progressive }})"
                                                                                        type="button" class="btn btn-danger "><i
                                                                                            class="fa fa-trash"></i>&nbsp;</a>
                                                                                @else
                                                                                    <a class="btn btn-primary"
                                                                                        wire:click.prevent="addVeicolo({{ $p->progressive }})"
                                                                                        data-toggle="modal"
                                                                                        data-target="#veicoloParte">+&nbsp;</a>
                                                                                @endif
                                                                            </div>
                                                                        </div>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                            <div class="row">
                                                                <div class="col-sm-6 pl-3">
                                                                    <button class="btn btn-danger"
                                                                        wire:click.prevent="removeParteCoinvolta({{ $p->progressive }})">Elimina</button>
                                                                </div>
                                                            </div>


                                                        </div>

                                                        <div class="row">
                                                            <div class="col-sm-12">
                                                                <hr size="1">
                                                            </div>
                                                        </div>
                                                    @endforeach

                                                    <button class="btn btn-success"
                                                        wire:click.prevent="addParteCoinvolta()">Aggiungi</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Accertatori</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-sm-6 col-md-6">
                                                            <label>Accertatore</label>
                                                            <div class="row">
                                                                <div class="col-sm-10">
                                                                    <select class="form-control accertatore_1"
                                                                        style="width:100%" wire:model="accertatore_1"
                                                                        style="width:100%">
                                                                        <option value="{{ $accertatore_1 }}">
                                                                            {{ $this->getAccertatore($accertatore_1) }}
                                                                        </option>
                                                                    </select>
                                                                </div>
                                                                <div class="col-sm-2">
                                                                    @if ($accertatore_1 > 0)
                                                                        <a class="btn btn-primary editAccertatore"
                                                                            wire:click.prevent="editAccertatore({{ $accertatore_1 }})"
                                                                            data-toggle="modal" data-target="#accertatoriModal"
                                                                            style="background-color: orange;border-color: orange;"><i
                                                                                class="fa fa-edit"></i></i></a>
                                                                    @else
                                                                        <a class="btn btn-primary"
                                                                            wire:click.prevent="addAccertatore(1)"
                                                                            data-toggle="modal"
                                                                            data-target="#accertatoriModal">+&nbsp;</a>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6  col-md-6">
                                                            <div class="form-group">
                                                                <label>Grado accertatore</label>
                                                                <select class="form-control"
                                                                    wire:model="grado_accertatore_1" style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($grado_accertatore as $g)
                                                                            <option value="{{ $g->id }}" {{ $g->id == $accertatore_1 ? 'selected' : '' }}>
                                                                                {{ $g->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6 col-md-6">
                                                            <label>Accertatore</label>
                                                            <div class="row">
                                                                <div class="col-sm-10">
                                                                    <select class="form-control accertatore_2"
                                                                        style="width:100%" wire:model="accertatore_2">
                                                                        <option value="{{ $accertatore_2 }}">
                                                                            {{ $this->getAccertatore($accertatore_2) }}
                                                                        </option>
                                                                    </select>
                                                                </div>
                                                                <div class="col-sm-2">
                                                                    @if ($accertatore_2 > 0)
                                                                        <a class="btn btn-primary editAccertatore"
                                                                            wire:click.prevent="editAccertatore({{ $accertatore_2 }})"
                                                                            data-toggle="modal" data-target="#accertatoriModal"
                                                                            style="background-color: orange;border-color: orange;"
                                                                            style="background-color: orange;border-color: orange;"><i
                                                                                class="fa fa-edit"></i></a>
                                                                    @else
                                                                        <a class="btn btn-primary"
                                                                            wire:click.prevent="addAccertatore(2)"
                                                                            data-toggle="modal"
                                                                            data-target="#accertatoriModal">+&nbsp;</a>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6 col-md-6">
                                                            <label>Grado accertatore</label>
                                                            <select class="form-control" wire:model="grado_accertatore_2"
                                                                style="width:100%">
                                                                <option value="">
                                                                    @foreach ($grado_accertatore as $g)
                                                                        <option value="{{ $g->id }}" {{ $g->id == $accertatore_2 ? 'selected' : '' }}>{{ $g->name }}
                                                                    @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6 col-md-6">
                                                            <label>Accertatore</label>
                                                            <div class="row">
                                                                <div class="col-sm-10">
                                                                    <select class="form-control accertatore_3"
                                                                        style="width:100%" wire:model="accertatore_3">
                                                                        <option value="{{ $accertatore_3 }}">
                                                                            {{ $this->getAccertatore($accertatore_3) }}
                                                                        </option>
                                                                    </select>
                                                                </div>
                                                                <div class="col-sm-2">
                                                                    @if ($accertatore_3 > 0)
                                                                        <a class="btn btn-primary editAccertatore"
                                                                            wire:click.prevent="editAccertatore({{ $accertatore_3 }})"
                                                                            data-toggle="modal" data-target="#accertatoriModal"
                                                                            style="background-color: orange;border-color: orange;"><i
                                                                                class="fa fa-edit"></i></i></a>
                                                                    @else
                                                                        <a class="btn btn-primary"
                                                                            wire:click.prevent="addAccertatore(3)"
                                                                            data-toggle="modal"
                                                                            data-target="#accertatoriModal">+&nbsp;</a>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6 col-md-6">
                                                            <label>Grado accertatore</label>
                                                            <select class="form-control" wire:model="grado_accertatore_3"
                                                                style="width:100%">
                                                                <option value="">
                                                                    @foreach ($grado_accertatore as $g)
                                                                        <option value="{{ $g->id }}" {{ $g->id == $accertatore_3 ? 'selected' : '' }}>{{ $g->name }}
                                                                    @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6 col-md-6">
                                                            <label>Accertatore</label>
                                                            <div class="row">
                                                                <div class="col-sm-10">
                                                                    <select class="form-control accertatore_4"
                                                                        style="width:100%" wire:model="accertatore_4">
                                                                        <option value="{{ $accertatore_4 }}">
                                                                            {{ $this->getAccertatore($accertatore_4) }}
                                                                        </option>
                                                                    </select>
                                                                </div>
                                                                <div class="col-sm-2">
                                                                    @if ($accertatore_4 > 0)
                                                                        <a class="btn btn-primary editAccertatore"
                                                                            wire:click.prevent="editAccertatore({{ $accertatore_4 }})"
                                                                            data-toggle="modal" data-target="#accertatoriModal"
                                                                            style="background-color: orange;border-color: orange;"><i
                                                                                class="fa fa-edit"></i></i></a>
                                                                    @else
                                                                        <a class="btn btn-primary"
                                                                            wire:click.prevent="addAccertatore(3)"
                                                                            data-toggle="modal"
                                                                            data-target="#accertatoriModal">+&nbsp;</a>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6 col-md-6">
                                                            <label>Grado accertatore</label>
                                                            <select class="form-control" wire:model="grado_accertatore_4"
                                                                style="width:100%">
                                                                <option value="">
                                                                    @foreach ($grado_accertatore as $g)
                                                                        <option value="{{ $g->id }}" {{ $g->id == $accertatore_4 ? 'selected' : '' }}>{{ $g->name }}
                                                                    @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6 col-md-6">
                                                            <label>Accertatore</label>
                                                            <div class="row">
                                                                <div class="col-sm-10">
                                                                    <select class="form-control accertatore_5"
                                                                        style="width:100%" wire:model="accertatore_5">
                                                                        <option value="{{ $accertatore_5 }}">
                                                                            {{ $this->getAccertatore($accertatore_5) }}
                                                                        </option>
                                                                    </select>
                                                                </div>
                                                                <div class="col-sm-2">
                                                                    @if ($accertatore_5 > 0)
                                                                        <a class="btn btn-primary editAccertatore"
                                                                            wire:click.prevent="editAccertatore({{ $accertatore_5 }})"
                                                                            data-toggle="modal" data-target="#accertatoriModal"
                                                                            style="background-color: orange;border-color: orange;"><i
                                                                                class="fa fa-edit"></i></i></a>
                                                                    @else
                                                                        <a class="btn btn-primary"
                                                                            wire:click.prevent="addAccertatore(3)"
                                                                            data-toggle="modal"
                                                                            data-target="#accertatoriModal">+&nbsp;</a>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6 col-md-6">
                                                            <label>Grado accertatore</label>
                                                            <select class="form-control" wire:model="grado_accertatore_5"
                                                                style="width:100%">
                                                                <option value="">
                                                                    @foreach ($grado_accertatore as $g)
                                                                        <option value="{{ $g->id }}" {{ $g->id == $accertatore_5 ? 'selected' : '' }}>{{ $g->name }}
                                                                    @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Rilievi</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="col-sm-12">
                                                        <div class="form-group">
                                                            <label>Tipo di rilievo</label>
                                                            <select class="form-control" wire:model="rilievi_id"
                                                                style="width:100%">
                                                                <option value="">
                                                                    @foreach ($rilievi as $r)
                                                                        <option value="{{ $r->id }}">{{ $r->name }}
                                                                    @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12">
                                                        <div class="form-group">
                                                            <label>Tipo di urto</label>
                                                            <select class="form-control select2 tipo_urto"
                                                                multiple="multiple" wire:model="tipo_urto"
                                                                style="width: 100%;">
                                                                <option value="">
                                                                    @foreach ($tipi_urto as $t)
                                                                        <option value="{{ $t->id }}">{{ $t->name }}
                                                                    @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="tab3" role="tabpanel" aria-labelledby="tab3-tab"
                                    wire:ignore.self>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Segnalazione</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-sm-6 col-md-12">
                                                            <div class="form-group">
                                                                <label>Data segnalazione</label>
                                                                <input class="form-control" type="date"
                                                                    wire:model="segnalazione_data">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6 col-md-6">
                                                            <div class="form-group">
                                                                <label>Seleziona ora</label>
                                                                <select class="form-control" wire:model="segnalazione_ora">
                                                                    <option value="">-- Seleziona ora --</option>
                                                                    @for ($hour = 0; $hour <= 23; $hour++)
                                                                        <option
                                                                            value="{{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6 col-md-6">
                                                            <div class="form-group">
                                                                <label>Seleziona minuti</label>
                                                                <select class="form-control"
                                                                    wire:model="segnalazione_minuti">
                                                                    <option value="">-- Seleziona minuti --</option>
                                                                    @for ($minute = 0; $minute <= 59; $minute++)
                                                                        <option
                                                                            value="{{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="col-sm-12">
                                                            <div class="form-group">
                                                                <label>Tipo di segnalazione</label>
                                                                <select class="form-control tipo_segnalazione"
                                                                    multiple="multiple" wire:model="tipo_segnalazione"
                                                                    style="width: 100%;">
                                                                    <option value="">
                                                                        @foreach ($tipi_segnalazioni as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-12">
                                                            <div class="form-group">
                                                                <label>Altro tipo di segnalazione</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="segnalazione_altro">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-12">
                                                            <div class="form-group">
                                                                <label>Segnalazione Pervenuta Da</label>
                                                                <select class="form-control segnalazione_pervenuta_da"
                                                                    multiple="multiple"
                                                                    wire:model="segnalazione_pervenuta_da"
                                                                    style="width: 100%;">
                                                                    <option value="">
                                                                        @foreach ($pervenute_da as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Ausilio altri enti</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-sm-12">
                                                            <div class="form-group">
                                                                <label>Ausilio altri enti</label>
                                                                <select class="form-control select2 ausilio_altri_enti"
                                                                    multiple="multiple" wire:model="ausilio_altri_enti"
                                                                    style="width: 100%;">
                                                                    <option value="">
                                                                        @foreach ($altri_enti as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-12">
                                                            <div class="form-group">
                                                                <label>Motivo ausilio</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="ausilio_altri_enti_motivo">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Ora di intervento</label>
                                                                <select class="form-control"
                                                                    wire:model="ausilio_altri_enti_ora_intervento">
                                                                    @for ($hour = 0; $hour <= 23; $hour++)
                                                                        <option
                                                                            value="{{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Minuti</label>
                                                                <select class="form-control"
                                                                    wire:model="ausilio_altri_enti_minuti_intervento">
                                                                    @for ($minute = 0; $minute <= 59; $minute++)
                                                                        <option
                                                                            value="{{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Ripristino post incidente</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-sm-12">
                                                            <div class="form-group">
                                                                <label>Ditta intervenuta</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="ditta_intervenuta">
                                                            </div>
                                                        </div>

                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Ora di chiamata</label>
                                                                <select class="form-control"
                                                                    wire:model="ripristino_ora_chiamata">
                                                                    @for ($hour = 0; $hour <= 23; $hour++)
                                                                        <option
                                                                            value="{{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Minuti</label>
                                                                <select class="form-control"
                                                                    wire:model="ripristino_minuti_chiamata">
                                                                    @for ($minute = 0; $minute <= 59; $minute++)
                                                                        <option
                                                                            value="{{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Ora di arrivo</label>
                                                                <select class="form-control"
                                                                    wire:model="ripristino_ora_arrivo">
                                                                    @for ($hour = 0; $hour <= 23; $hour++)
                                                                        <option
                                                                            value="{{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Minuti di arrivo</label>
                                                                <select class="form-control"
                                                                    wire:model="ripristino_minuti_arrivo">
                                                                    @for ($minute = 0; $minute <= 59; $minute++)
                                                                        <option
                                                                            value="{{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="col-sm-12">
                                                            <div class="form-group">
                                                                <label>Materiale recuperato</label>
                                                                <select class="form-control materiale_recuperato"
                                                                    multiple="multiple" wire:model="materiale_recuperato"
                                                                    style="width: 100%;">
                                                                    <option value="">
                                                                        @foreach ($materiali as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-12">
                                                            <div class="form-group">
                                                                <label>Descrizione danni</label>
                                                                <textarea class="form-control" rows="5"
                                                                    wire:model="danni_cose_diverse_da_veicoli"></textarea>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="tab4" role="tabpanel" aria-labelledby="tab4-tab"
                                    wire:ignore.self>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Campo del sinistro</h3>
                                                </div>
                                                <div class="card-body">

                                                    <div class="row">
                                                        <div class="col-sm-3">
                                                            <div class="form-group">
                                                                <label>Ora intervento</label>
                                                                <select class="form-control" wire:model="sinistro_ora">
                                                                    <option value="">-- Seleziona ora --</option>
                                                                    @for ($hour = 0; $hour <= 23; $hour++)
                                                                        <option
                                                                            value="{{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($hour, 2, '0', STR_PAD_LEFT) }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="form-group">
                                                                <label>Minuti intervento</label>
                                                                <select class="form-control" wire:model="sinistro_minuti">
                                                                    <option value="">-- Seleziona minuti --</option>
                                                                    @for ($minute = 0; $minute <= 59; $minute++)
                                                                        <option
                                                                            value="{{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}">
                                                                            {{ str_pad($minute, 2, '0', STR_PAD_LEFT) }}
                                                                    @endfor
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Localizzazione dell'incidente</label>
                                                                <select class="form-control"
                                                                    wire:model="localizzazione_incidente"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                    <option value="1">NELL'ABITATO
                                                                    <option value="2">FUORI DELL'ABITATO
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Altro</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="localizzazione_incidente_altro">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Nomenclatura strada</label>
                                                                <select class="form-control"
                                                                    wire:model="nomenclatura_strada" style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($nomenclature as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="form-group">
                                                                <label>Num</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="nomenclatura_strada_numero">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <div class="form-group">
                                                                <label>Altro</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="nomenclatura_strada_altro">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Condizioni atmosferiche</label>
                                                                <select class="form-control"
                                                                    wire:model="condizioni_atmosferiche" style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($condizioni_atmosferiche_array as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Altro</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="condizioni_atmosferiche_altro">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Pavimentazione strada</label>
                                                                <select class="form-control" wire:model="pavimentazione"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($pavimentazioni as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Altro</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="pavimentazione_altro">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Condizione strada</label>
                                                                <select class="form-control" wire:model="condizione_strada"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($condizioni_strada as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Altro</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="condizione_strada_altro">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Fondo stradale</label>
                                                                <select class="form-control" wire:model="fondo_stradale"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($fondi_stradali as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Inserire specifica</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="fondo_stradale_specifica">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Condizioni luce</label>
                                                                <select class="form-control condizioni_luce"
                                                                    multiple="multiple" wire:model="condizioni_luce"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($condizioni_luce_array as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>

                                                    </div>

                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Visibilità</label>
                                                                <select class="form-control" wire:model="visibilita"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                    <option value="1">BUONA
                                                                    <option value="2">LIMITATA
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Inserire specifica</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="visibilita_specifica">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Particolarità strada</label>
                                                                <select class="form-control"
                                                                    wire:model="particolarita_strada" style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($particolarita_strade as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Inserire specifica</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="particolarita_strada_specifica">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Traffico</label>
                                                                <select class="form-control" wire:model="traffico"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                    <option value="2">Scarso
                                                                    <option value="1">Normale
                                                                    <option value="3">Intenso
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Tipo di strada</label>
                                                                <select class="form-control tipo_strada" multiple="multiple"
                                                                    wire:model="tipo_strada" style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($tipi_strade as $t)
                                                                            <option value="{{ $t->id }}">{{ $t->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Altro</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="tipo_strada_altro">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="tab5" role="tabpanel" aria-labelledby="tab5-tab"
                                    wire:ignore.self>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Segnaletica</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Stato segnaletica</label>
                                                                <select class="form-control" wire:model="segnaletica"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($segnaletiche as $s)
                                                                            <option value="{{ $s['id'] }}">{{ $s['name'] }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-6">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Segnaletica verticale</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Via di riferimento</label>
                                                                <select class="form-control segnaletica_verticale_1_via"
                                                                    wire:model="segnaletica_verticale_1_via"
                                                                    style="width:100%">
                                                                    <option value="{{ $segnaletica_verticale_1_via }}">
                                                                        {{ $this->getStradario($segnaletica_verticale_1_via) }}
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Direzione</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="segnaletica_verticale_1_direzione">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Dettaglio segnaletica verticale</label>
                                                                <select class="form-control segnaletica_verticale_1"
                                                                    multiple="multiple" wire:model="segnaletica_verticale_1"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($segnaletica_verticale as $s)
                                                                            <option value="{{ $s->id }}">{{ $s->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Limite di velocità</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="segnaletica_verticale_1_limite_velocita">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-12">
                                                            <div class="form-group">
                                                                <label>Altro</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="segnaletica_verticale_1_altro">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-12">
                                                            <hr size="1">
                                                        </div>
                                                    </div>

                                                    @if ($div_segnaletica_verticale_2)
                                                        <div class="row" id="div_segnaletica_verticale_2">
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Via di riferimento</label>
                                                                    <select
                                                                        class="form-control select2 segnaletica_verticale_2_via"
                                                                        wire:model="segnaletica_verticale_2_via"
                                                                        style="width:100%">
                                                                        <option value="{{ $segnaletica_verticale_2_via }}">
                                                                            {{ $this->getStradario($segnaletica_verticale_2_via) }}

                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Direzione</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_verticale_2_direzione">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Dettaglio segnaletica verticale</label>
                                                                    <select class="form-control segnaletica_verticale_2"
                                                                        multiple="multiple" wire:model="segnaletica_verticale_2"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($segnaletica_verticale as $s)
                                                                                <option value="{{ $s->id }}">{{ $s->name }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Limite di velocità</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_verticale_2_limite_velocita">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-12">
                                                                <div class="form-group">
                                                                    <label>Altro</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_verticale_2_altro">
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-12">
                                                                <hr size="1">
                                                            </div>
                                                        </div>
                                                    @endif

                                                    @if ($div_segnaletica_verticale_3)
                                                        <div class="row" id="div_segnaletica_verticale_3">
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Via di riferimento</label>
                                                                    <select class="form-control segnaletica_verticale_3_via"
                                                                        wire:model="segnaletica_verticale_3_via"
                                                                        style="width:100%">
                                                                        <option value="{{ $segnaletica_verticale_3_via }}">
                                                                            {{ $this->getStradario($segnaletica_verticale_3_via) }}

                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Direzione</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_verticale_3_direzione">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Dettaglio segnaletica verticale</label>
                                                                    <select class="form-control segnaletica_verticale_3"
                                                                        multiple="multiple" wire:model="segnaletica_verticale_3"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($segnaletica_verticale as $s)
                                                                                <option value="{{ $s->id }}">{{ $s->name }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Limite di velocità</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_verticale_3_limite_velocita">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-12">
                                                                <div class="form-group">
                                                                    <label>Altro</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_verticale_3_altro">
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-12">
                                                                <hr size="1">
                                                            </div>
                                                        </div>
                                                    @endif
                                                    @if ($div_segnaletica_verticale_4)
                                                        <div class="row" id="div_segnaletica_verticale_4">
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Via di riferimento</label>
                                                                    <select
                                                                        class="form-control select2 segnaletica_verticale_4_via"
                                                                        wire:model="segnaletica_verticale_4_via"
                                                                        style="width:100%">
                                                                        <option value="{{ $segnaletica_verticale_4_via }}">
                                                                            {{ $this->getStradario($segnaletica_verticale_4_via) }}

                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Direzione</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_verticale_4_direzione">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Dettaglio segnaletica verticale</label>
                                                                    <select class="form-control segnaletica_verticale_4"
                                                                        multiple="multiple" wire:model="segnaletica_verticale_4"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($segnaletica_verticale as $s)
                                                                                <option value="{{ $s->id }}">{{ $s->name }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Limite di velocità</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_verticale_4_limite_velocita">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-12">
                                                                <div class="form-group">
                                                                    <label>Altro</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_verticale_4_altro">
                                                                </div>
                                                            </div>
                                                        </div>
                                                    @endif

                                                    @if (!$div_segnaletica_verticale_4)
                                                        <a class="btn btn-success " id="btAddSegnaleticaVerticale"
                                                            wire:click="showSegnaleticaVerticale()">Aggiungi</a>
                                                    @endif
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Segnaletica orizzontale</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Via di riferimento</label>
                                                                <select
                                                                    class="form-control select2 segnaletica_orizzontale_1_via"
                                                                    wire:model="segnaletica_orizzontale_1_via"
                                                                    style="width:100%">
                                                                    <option value="{{ $segnaletica_orizzontale_1_via }}">
                                                                        {{ $this->getStradario($segnaletica_orizzontale_1_via) }}

                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Direzione</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="segnaletica_orizzontale_1_direzione">
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Dettaglio segnaletica orizzontale</label>
                                                                <select class="form-control segnaletica_orizzontale_1"
                                                                    multiple="multiple"
                                                                    wire:model="segnaletica_orizzontale_1"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($segnaletica_orizzontale as $s)
                                                                            <option value="{{ $s->id }}">{{ $s->name }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Linea di margine</label>
                                                                <select class="form-control"
                                                                    wire:model="segnaletica_orizzontale_1_linea_margine"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($linee as $s)
                                                                            <option value="{{ $s['id'] }}">{{ $s['name'] }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        @if ($segnaletica_orizzontale_1_linea_margine == 3)
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Inserire specifica</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_orizzontale_1_linea_margine_specifica">
                                                                </div>
                                                            </div>
                                                        @endif
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Linea di mezzeria</label>
                                                                <select class="form-control"
                                                                    wire:model="segnaletica_orizzontale_1_linea_mezzeria"
                                                                    style="width:100%">
                                                                    <option value="">
                                                                        @foreach ($linee as $s)
                                                                            <option value="{{ $s['id'] }}">{{ $s['name'] }}
                                                                        @endforeach
                                                                </select>
                                                            </div>
                                                        </div>
                                                        @if ($segnaletica_orizzontale_1_linea_mezzeria == 3)
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Inserire specifica</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_orizzontale_1_linea_mezzeria_specifica">
                                                                </div>
                                                            </div>
                                                        @endif
                                                        <div class="col-sm-6">
                                                            <div class="form-group">
                                                                <label>Altro</label>
                                                                <input class="form-control" type="text"
                                                                    wire:model="segnaletica_orizzontale_1_altro">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-sm-12">
                                                            <hr size="1">
                                                        </div>
                                                    </div>

                                                    @if ($div_segnaletica_orizzontale_2)
                                                        <div class="row" id="div_segnaletica_orizzontale_2">
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Via di riferimento</label>
                                                                    <select
                                                                        class="form-control select2 segnaletica_orizzontale_2_via"
                                                                        wire:model="segnaletica_orizzontale_2_via"
                                                                        style="width:100%">
                                                                        <option value="{{ $segnaletica_orizzontale_2_via }}">
                                                                            {{ $this->getStradario($segnaletica_orizzontale_2_via) }}

                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Direzione</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_orizzontale_2_direzione">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Dettaglio segnaletica orizzontale</label>
                                                                    <select class="form-control segnaletica_orizzontale_2"
                                                                        multiple="multiple"
                                                                        wire:model="segnaletica_orizzontale_2"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($segnaletica_orizzontale as $s)
                                                                                <option value="{{ $s->id }}">{{ $s->name }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Linea di margine</label>
                                                                    <select class="form-control"
                                                                        wire:model="segnaletica_orizzontale_2_linea_margine"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($linee as $s)
                                                                                <option value="{{ $s['id'] }}">{{ $s['name'] }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            @if ($segnaletica_orizzontale_2_linea_margine == 3)
                                                                <div class="col-sm-6">
                                                                    <div class="form-group">
                                                                        <label>Inserire specifica</label>
                                                                        <input class="form-control" type="text"
                                                                            wire:model="segnaletica_orizzontale_2_linea_margine_specifica">
                                                                    </div>
                                                                </div>
                                                            @endif
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Linea di mezzeria</label>
                                                                    <select class="form-control"
                                                                        wire:model="segnaletica_orizzontale_2_linea_mezzeria"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($linee as $s)
                                                                                <option value="{{ $s['id'] }}">{{ $s['name'] }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            @if ($segnaletica_orizzontale_2_linea_mezzeria == 3)
                                                                <div class="col-sm-6">
                                                                    <div class="form-group">
                                                                        <label>Inserire specifica</label>
                                                                        <input class="form-control" type="text"
                                                                            wire:model="segnaletica_orizzontale_2_linea_mezzeria_specifica">
                                                                    </div>
                                                                </div>
                                                            @endif
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Altro</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_orizzontale_2_altro">
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-12">
                                                                <hr size="1">
                                                            </div>
                                                        </div>
                                                    @endif

                                                    @if ($div_segnaletica_orizzontale_3)
                                                        <div class="row" id="div_segnaletica_orizzontale_3">
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Via di riferimento</label>
                                                                    <select
                                                                        class="form-control select2 segnaletica_orizzontale_3_via"
                                                                        wire:model="segnaletica_orizzontale_3_via"
                                                                        style="width:100%">
                                                                        <option value="{{ $segnaletica_orizzontale_3_via }}">
                                                                            {{ $this->getStradario($segnaletica_orizzontale_3_via) }}

                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Direzione</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_orizzontale_3_direzione">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Dettaglio segnaletica orizzontale</label>
                                                                    <select class="form-control segnaletica_orizzontale_3"
                                                                        multiple="multiple"
                                                                        wire:model="segnaletica_orizzontale_3"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($segnaletica_orizzontale as $s)
                                                                                <option value="{{ $s->id }}">{{ $s->name }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Linea di margine</label>
                                                                    <select class="form-control"
                                                                        wire:model="segnaletica_orizzontale_3_linea_margine"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($linee as $s)
                                                                                <option value="{{ $s['id'] }}">{{ $s['name'] }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            @if ($segnaletica_orizzontale_3_linea_margine == 3)
                                                                <div class="col-sm-6">
                                                                    <div class="form-group">
                                                                        <label>Inserire specifica</label>
                                                                        <input class="form-control" type="text"
                                                                            wire:model="segnaletica_orizzontale_3_linea_margine_specifica">
                                                                    </div>
                                                                </div>
                                                            @endif
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Linea di mezzeria</label>
                                                                    <select class="form-control"
                                                                        wire:model="segnaletica_orizzontale_3_linea_mezzeria"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($linee as $s)
                                                                                <option value="{{ $s['id'] }}">{{ $s['name'] }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            @if ($segnaletica_orizzontale_3_linea_mezzeria == 3)
                                                                <div class="col-sm-6">
                                                                    <div class="form-group">
                                                                        <label>Inserire specifica</label>
                                                                        <input class="form-control" type="text"
                                                                            wire:model="segnaletica_orizzontale_3_linea_mezzeria_specifica">
                                                                    </div>
                                                                </div>
                                                            @endif
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Altro</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_orizzontale_3_altro">
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-sm-12">
                                                                <hr size="1">
                                                            </div>
                                                        </div>
                                                    @endif

                                                    @if ($div_segnaletica_orizzontale_4)
                                                        <div class="row" id="div_segnaletica_orizzontale_4">
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Via di riferimento</label>
                                                                    <select
                                                                        class="form-control select2 segnaletica_orizzontale_4_via"
                                                                        wire:model="segnaletica_orizzontale_4_via"
                                                                        style="width:100%">
                                                                        <option value="{{ $segnaletica_orizzontale_4_via }}">
                                                                            {{ $this->getStradario($segnaletica_orizzontale_4_via) }}

                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Direzione</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_orizzontale_4_direzione">
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Dettaglio segnaletica orizzontale</label>
                                                                    <select class="form-control segnaletica_orizzontale_4"
                                                                        multiple="multiple"
                                                                        wire:model="segnaletica_orizzontale_4"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($segnaletica_orizzontale as $s)
                                                                                <option value="{{ $s->id }}">{{ $s->name }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Linea di margine</label>
                                                                    <select class="form-control"
                                                                        wire:model="segnaletica_orizzontale_4_linea_margine"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($linee as $s)
                                                                                <option value="{{ $s['id'] }}">{{ $s['name'] }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            @if ($segnaletica_orizzontale_4_linea_margine == 3)
                                                                <div class="col-sm-6">
                                                                    <div class="form-group">
                                                                        <label>Inserire specifica</label>
                                                                        <input class="form-control" type="text"
                                                                            wire:model="segnaletica_orizzontale_4_linea_margine_specifica">
                                                                    </div>
                                                                </div>
                                                            @endif
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Linea di mezzeria</label>
                                                                    <select class="form-control"
                                                                        wire:model="segnaletica_orizzontale_4_linea_mezzeria"
                                                                        style="width:100%">
                                                                        <option value="">
                                                                            @foreach ($linee as $s)
                                                                                <option value="{{ $s['id'] }}">{{ $s['name'] }}
                                                                            @endforeach
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            @if ($segnaletica_orizzontale_4_linea_mezzeria == 3)
                                                                <div class="col-sm-6">
                                                                    <div class="form-group">
                                                                        <label>Inserire specifica</label>
                                                                        <input class="form-control" type="text"
                                                                            wire:model="segnaletica_orizzontale_4_linea_mezzeria_specifica">
                                                                    </div>
                                                                </div>
                                                            @endif
                                                            <div class="col-sm-6">
                                                                <div class="form-group">
                                                                    <label>Altro</label>
                                                                    <input class="form-control" type="text"
                                                                        wire:model="segnaletica_orizzontale_4_altro">
                                                                </div>
                                                            </div>
                                                        </div>
                                                    @endif

                                                    @if (!$div_segnaletica_orizzontale_4)
                                                        <a class="btn btn-success " id="btAddSegnaleticaOrizzontale"
                                                            wire:click="showSegnaleticaOrizzontale()">Aggiungi</a>
                                                    @endif

                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="tab6" role="tabpanel" aria-labelledby="tab6-tab"
                                    wire:ignore.self>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Teste oculare</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-md-6">
                                                            <label for="data_testi_oculari_0" class="form-label">Teste
                                                                oculare</label>
                                                            <div class="row">
                                                                <div class="col-sm-10">
                                                                    <select class="form-control data_testi_oculari_0"
                                                                        style="width:100%">
                                                                        <option value="{{ $data_testi_oculari_0 }}">
                                                                            {{ $this->getAnagrafica($data_testi_oculari_0) }}
                                                                        </option>
                                                                    </select>
                                                                </div>
                                                                <div class="col-sm-2">
                                                                    @if ($data_testi_oculari_0 > 0)
                                                                        <a class="btn btn-primary editAnagrafica"
                                                                            wire:click.prevent="editAnagrafica({{ $data_testi_oculari_0 }})"
                                                                            data-toggle="modal" data-target="#anagraficaParte"
                                                                            style="background-color: orange;border-color: orange;"><i
                                                                                class="fa fa-edit"></i></i></a>
                                                                    @else
                                                                        <a class="btn btn-primary"
                                                                            wire:click.prevent="addTesteOculare(1)"
                                                                            data-toggle="modal"
                                                                            data-target="#anagraficaParte">+&nbsp;</a>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-6">
                                                            <label for="data_testi_oculari_0" class="form-label">Stato
                                                                teste</label>
                                                            <select class="form-control" style="width:100%"
                                                                wire:model="data_testi_oculari_stato_0">
                                                                <option value=""></option>
                                                                <option value="1">Teste presente al momento del rilievo
                                                                </option>
                                                                <option value="2">Teste non presente al momento del
                                                                    rilievo</option>
                                                                <option value="3">Teste che dichiara sul luogo
                                                                    dell'incidente</option>
                                                                <option value="4">Teste che dichiara al Pronto Soccorso
                                                                </option>
                                                                <option value="5">Teste che dichiara in un proseguo di
                                                                    tempo</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Teste oculare</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-md-6">
                                                            <label for="data_testi_oculari_1" class="form-label">Teste
                                                                oculare</label>
                                                            <div class="row">
                                                                <div class="col-sm-10">
                                                                    <select class="form-control data_testi_oculari_1"
                                                                        style="width:100%">
                                                                        <option value="{{ $data_testi_oculari_1 }}">
                                                                            {{ $this->getAnagrafica($data_testi_oculari_1) }}
                                                                        </option>
                                                                    </select>
                                                                </div>
                                                                <div class="col-sm-2">
                                                                    @if ($data_testi_oculari_1 > 0)
                                                                        <a class="btn btn-primary editAnagrafica"
                                                                            wire:click.prevent="editAnagrafica({{ $data_testi_oculari_1 }})"
                                                                            data-toggle="modal" data-target="#anagraficaParte"
                                                                            style="background-color: orange;border-color: orange;"><i
                                                                                class="fa fa-edit"></i></i></a>
                                                                    @else
                                                                        <a class="btn btn-primary"
                                                                            wire:click.prevent="addTesteOculare(2)"
                                                                            data-toggle="modal"
                                                                            data-target="#anagraficaParte">+&nbsp;</a>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-6">
                                                            <label for="data_testi_oculari_1" class="form-label">Stato
                                                                teste</label>
                                                            <select class="form-control" style="width:100%"
                                                                wire:model="data_testi_oculari_stato_1">
                                                                <option value=""></option>
                                                                <option value="1">Teste presente al momento del rilievo
                                                                </option>
                                                                <option value="2">Teste non presente al momento del
                                                                    rilievo</option>
                                                                <option value="3">Teste che dichiara sul luogo
                                                                    dell'incidente</option>
                                                                <option value="4">Teste che dichiara al Pronto Soccorso
                                                                </option>
                                                                <option value="5">Teste che dichiara in un proseguo di
                                                                    tempo</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Teste oculare</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-md-6">
                                                            <label for="data_testi_oculari_2" class="form-label">Teste
                                                                oculare</label>
                                                            <div class="row">
                                                                <div class="col-sm-10">
                                                                    <select class="form-control data_testi_oculari_2"
                                                                        style="width:100%">
                                                                        <option value="{{ $data_testi_oculari_2 }}">
                                                                            {{ $this->getAnagrafica($data_testi_oculari_2) }}
                                                                        </option>
                                                                    </select>
                                                                </div>
                                                                <div class="col-sm-2">
                                                                    @if ($data_testi_oculari_2 > 0)
                                                                        <a class="btn btn-primary editAnagrafica"
                                                                            wire:click.prevent="editAnagrafica({{ $data_testi_oculari_2 }})"
                                                                            data-toggle="modal" data-target="#anagraficaParte"
                                                                            style="background-color: orange;border-color: orange;"><i
                                                                                class="fa fa-edit"></i></i></a>
                                                                    @else
                                                                        <a class="btn btn-primary"
                                                                            wire:click.prevent="addTesteOculare(3)"
                                                                            data-toggle="modal"
                                                                            data-target="#anagraficaParte">+&nbsp;</a>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-6">
                                                            <label for="data_testi_oculari_2" class="form-label">Stato
                                                                teste</label>
                                                            <select class="form-control" style="width:100%"
                                                                wire:model="data_testi_oculari_stato_2">
                                                                <option value=""></option>
                                                                <option value="1">Teste presente al momento del rilievo
                                                                </option>
                                                                <option value="2">Teste non presente al momento del
                                                                    rilievo</option>
                                                                <option value="3">Teste che dichiara sul luogo
                                                                    dell'incidente</option>
                                                                <option value="4">Teste che dichiara al Pronto Soccorso
                                                                </option>
                                                                <option value="5">Teste che dichiara in un proseguo di
                                                                    tempo</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Teste oculare</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <div class="col-md-6">
                                                            <label for="data_testi_oculari_3" class="form-label">Teste
                                                                oculare</label>
                                                            <div class="row">
                                                                <div class="col-sm-10">
                                                                    <select class="form-control data_testi_oculari_3"
                                                                        style="width:100%">
                                                                        <option value="{{ $data_testi_oculari_3 }}">
                                                                            {{ $this->getAnagrafica($data_testi_oculari_3) }}
                                                                        </option>
                                                                    </select>
                                                                </div>
                                                                <div class="col-sm-2">
                                                                    @if ($data_testi_oculari_3 > 0)
                                                                        <a class="btn btn-primary editAnagrafica"
                                                                            wire:click.prevent="editAnagrafica({{ $data_testi_oculari_3 }})"
                                                                            data-toggle="modal" data-target="#anagraficaParte"
                                                                            style="background-color: orange;border-color: orange;"><i
                                                                                class="fa fa-edit"></i></i></a>
                                                                    @else
                                                                        <a class="btn btn-primary"
                                                                            wire:click.prevent="addTesteOculare(4)"
                                                                            data-toggle="modal"
                                                                            data-target="#anagraficaParte">+&nbsp;</a>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-6">
                                                            <label for="data_testi_oculari_3" class="form-label">Stato
                                                                teste</label>
                                                            <select class="form-control" style="width:100%"
                                                                wire:model="data_testi_oculari_stato_3">
                                                                <option value=""></option>
                                                                <option value="1">Teste presente al momento del rilievo
                                                                </option>
                                                                <option value="2">Teste non presente al momento del
                                                                    rilievo</option>
                                                                <option value="3">Teste che dichiara sul luogo
                                                                    dell'incidente</option>
                                                                <option value="4">Teste che dichiara al Pronto Soccorso
                                                                </option>
                                                                <option value="5">Teste che dichiara in un proseguo di
                                                                    tempo</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="tab7" role="tabpanel" aria-labelledby="tab7-tab"
                                    wire:ignore.self>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Immagini</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <table class="table table-hover text-nowrap">
                                                            <thead>
                                                                <tr>
                                                                    <th>Nome</th>
                                                                    <th>Tipologia</th>
                                                                    <th>Visibile in stampa</th>
                                                                    <th style="width:100px">&nbsp;</th>
                                                                    <th style="width:100px">&nbsp;</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                @foreach ($allegatiImmagini as $allegato)
                                                                    <tr>
                                                                        <td>{{ $allegato->name }}</td>
                                                                        <td>{{ $this->getAllegatoType($allegato->gallery_type) }}
                                                                        </td>
                                                                        <td>{{ $allegato->is_visible ? 'SI' : 'NO' }}</td>
                                                                        <td><a wire:click.prevent="editAllegato({{ $allegato->id }})"
                                                                                data-toggle="modal" data-target="#allegatiModal"
                                                                                class="btn btn-primary btn-block"
                                                                                style="background-color: orange;border-color: orange;"><i
                                                                                    class="fa fa-edit"></i></i></a></td>
                                                                        <td><button
                                                                                onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()"
                                                                                wire:click.prevent="removeAllegato({{ $allegato->id }})"
                                                                                type="button"
                                                                                class="btn btn-danger btn-block"><i
                                                                                    class="fa fa-trash"></i>&nbsp;</button>
                                                                        </td>
                                                                    </tr>
                                                                    @if ($allegato->files != '')
                                                                        <tr>
                                                                            <td colspan="5" style="border-top:0px solid;">
                                                                                @foreach (explode('|', $allegato->files) as $a)
                                                                                    <a href="{{ url('/storage/' . $a) }}"
                                                                                        target="_blank">{{ $a }}</a>&nbsp;&nbsp;&nbsp;
                                                                                @endforeach
                                                                            </td>
                                                                        </tr>
                                                                    @endif
                                                                @endforeach
                                                            </tbody>
                                                        </table>
                                                        <a class="btn btn-success " wire:click.prevent="addAllegato(0)"
                                                            data-toggle="modal" data-target="#allegatiModal">Aggiungi</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col">
                                            <div class="card card-primary">
                                                <div class="card-header">
                                                    <h3 class="card-title">Documenti</h3>
                                                </div>
                                                <div class="card-body">
                                                    <div class="row">
                                                        <table class="table table-hover text-nowrap">
                                                            <thead>
                                                                <tr>
                                                                    <th>Nome</th>
                                                                    <th>Tipologia</th>
                                                                    <th>Visibile in stampa</th>
                                                                    <th style="width:100px">&nbsp;</th>
                                                                    <th style="width:100px">&nbsp;</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                @foreach ($allegatiDocumenti as $allegato)
                                                                    <tr>
                                                                        <td>{{ $allegato->name }}</td>
                                                                        <td>{{ $this->getAllegatoType($allegato->gallery_type) }}
                                                                        </td>
                                                                        <td>{{ $allegato->is_visible ? 'SI' : 'NO' }}</td>
                                                                        <td><a wire:click.prevent="editAllegato({{ $allegato->id }})"
                                                                                data-toggle="modal" data-target="#allegatiModal"
                                                                                class="btn btn-primary btn-block"
                                                                                style="background-color: orange;border-color: orange;"><i
                                                                                    class="fa fa-edit"></i></i></a></td>
                                                                        <td><button
                                                                                onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()"
                                                                                wire:click.prevent="removeAllegato({{ $allegato->id }})"
                                                                                type="button"
                                                                                class="btn btn-danger btn-block"><i
                                                                                    class="fa fa-trash"></i>&nbsp;</button>
                                                                        </td>
                                                                    </tr>
                                                                    @if ($allegato->files != '')
                                                                        <tr>
                                                                            <td colspan="5" style="border-top:0px solid;">
                                                                                @foreach (explode('|', $allegato->files) as $a)
                                                                                    <a href="{{ url('/storage/' . $a) }}"
                                                                                        target="_blank">{{ $a }}</a>&nbsp;&nbsp;&nbsp;
                                                                                @endforeach
                                                                            </td>
                                                                        </tr>
                                                                    @endif
                                                                @endforeach
                                                            </tbody>
                                                        </table>
                                                        <a class="btn btn-success " wire:click.prevent="addAllegato(1)"
                                                            data-toggle="modal" data-target="#allegatiModal">Aggiungi</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="card-footer">
                @if ($add)
                    <button type="submit" class="btn btn-success" wire:click.prevent="store()">Salva</button>
                @endif
                @if ($update)
                    @if (!$this->validated)
                        <button type="submit" class="btn btn-success" wire:click.prevent="update(false)">Salva</button>
                    @else
                        Verbale validato
                    @endif
                @endif
                <button type="submit" class="btn btn-default" wire:click.prevent="cancel()">Indietro</button>
            </div>
        </form>
    </div>


    <div wire:ignore class="modal fade " id="anagraficaParte" tabindex="-1" aria-labelledby="anagraficaParteLabel"
        aria-hidden="true" data-keyboard="false" style="z-index: 9999">
        <div class="modal-dialog modal-xl">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="anagraficaParteLabel">Inserimento/modifica anagrafica</h5>
                </div>
                <div class="modal-body">
                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="anag_type" class="form-label">Tipologia</label>
                        </div>
                        <div class="col-md-8">
                            <input type="radio" value="0" {{ $anag_type == 0 ? 'checked' : '' }}
                                name="anag_type">&nbsp;Persona fisica&nbsp;&nbsp;&nbsp;
                            <input type="radio" value="1" {{ $anag_type == 1 ? 'checked' : '' }}
                                name="anag_type">&nbsp;Persona giuridica
                        </div>
                    </div>
                    <div id="boxPersonaFisica">
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_firstname" class="form-label">Nome</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control @error('anag_firstname') is-invalid @enderror" type="text"
                                    id="anag_firstname" wire:model="anag_firstname">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_lastname" class="form-label">Cognome</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control @error('anag_lastname') is-invalid @enderror" type="text"
                                    id="anag_lastname" wire:model="anag_lastname">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_gender" class="form-label">Sesso</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="anag_gender">
                                    <option value="">
                                    <option value="M">Uomo
                                    <option value="F">Donna
                                </select>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_birth_date" class="form-label">Data di nascita</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="date" id="anag_birth_date" wire:model="anag_birth_date">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_nazionalita" class="form-label">Nazionalità</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="anag_nazionalita">
                                    <option value="">
                                    <option value="0">Italiana
                                    <option value="1">Straniera
                                </select>
                            </div>
                        </div>
                        <div class="row mt-3" id="foreignBirthCountry" style="display: none;">
                            <div class="col-md-4">
                                <label for="anag_foreign_birth_country" class="form-label">Paese straniero di
                                    nascita</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="anag_foreign_birth_country">
                                    <option value="">Seleziona paese</option>
                                    @foreach (\App\Models\LocationCountry::all() as $country)
                                        <option value="{{ $country->id }}">{{ $country->name }}</option>
                                    @endforeach

                                </select>
                            </div>
                        </div>

                        <div class="row mt-3" id="foreignBirthCity" style="display: none;">
                            <div class="col-md-4">
                                <label for="anag_foreign_birth_city" class="form-label">Città straniera di
                                    nascita</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="text" id="anag_foreign_birth_city"
                                    wire:model="anag_foreign_birth_city">
                            </div>
                        </div>

                        <div class="row mt-3" id="foreignResidenceCountry" style="display: none;">
                            <div class="col-md-4">
                                <label for="anag_foreign_residence_country" class="form-label">Paese straniero di
                                    residenza</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="anag_foreign_residence_country">
                                    <option value="">Seleziona paese</option>
                                    @foreach (\App\Models\LocationCountry::all() as $country)
                                        <option value="{{ $country->id }}">{{ $country->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>

                        <div class="row mt-3" id="foreignResidenceCity" style="display: none;">
                            <div class="col-md-4">
                                <label for="anag_foreign_residence_city" class="form-label">Città straniera di
                                    residenza</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="text" id="anag_foreign_residence_city"
                                    wire:model="anag_foreign_residence_city">
                            </div>
                        </div>
                        <div class="row mt-3" id="pippo">
                            <div class="col-md-4">
                                <label for="anag_birth_town_id" class="form-label">Comune di nascita</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control anag_birth_town_id" wire:model="anag_birth_town_id"
                                    style="width:100%">
                                    <option value="{{ $anag_birth_town_id }}">
                                        {{ $this->getLocalita($anag_birth_town_id) }}
                                </select>

                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_residenza_town_id" class="form-label">Comune di residenza</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control select2 anag_residenza_town_id"
                                    wire:model="anag_residenza_town_id" style="width:100%">
                                    <option value="">

                                </select>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_residenza_address" class="form-label">Indirizzo di residenza</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="text" id="anag_residenza_address"
                                    wire:model="anag_residenza_address">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_residenza_cap" class="form-label">CAP</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="text" id="anag_residenza_cap"
                                    wire:model="anag_residenza_cap">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_mobile" class="form-label">Telefono</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="text" id="anag_mobile" wire:model="anag_mobile">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_sedicente" class="form-label">Sedicente</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="anag_sedicente">
                                    <option value="">
                                    <option value="1">SI
                                    <option value="0">NO
                                </select>
                            </div>
                        </div>

                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_documento_tipo" class="form-label">Tipo di documento</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="anag_documento_tipo">
                                    <option value=""></option>
                                    <option value="1">Carta d'Identità</option>
                                    <option value="2">Patente</option>
                                    <option value="3">Passaporto</option>
                                    <option value="4">Altro</option>
                                </select>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_documento_patente_cat" class="form-label">Categoria patente</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="anag_documento_patente_cat">
                                    <option value=""></option>
                                    <option value="AM">AM</option>
                                    <option value="A1">A1</option>
                                    <option value="A1B">A1B</option>
                                    <option value="A2">A2</option>
                                    <option value="A">A</option>
                                    <option value="AB">AB</option>
                                    <option value="B1">B1</option>
                                    <option value="B">B</option>
                                    <option value="BE">BE</option>
                                    <option value="C1">C1</option>
                                    <option value="C1E">C1E</option>
                                    <option value="C">C</option>
                                    <option value="CE">CE</option>
                                    <option value="D1">D1</option>
                                    <option value="D1E">D1E</option>
                                    <option value="DE">DE</option>
                                    <option value="E">E</option>
                                </select>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_documento_tipo_altro" class="form-label">Altro documento</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="text" id="anag_documento_tipo_altro"
                                    wire:model="anag_documento_tipo_altro">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_documento_numero" class="form-label">Numero documento</label>
                            </div>
                            <div class="col-md-6">
                                <input class="form-control" type="text" id="anag_documento_numero"
                                    wire:model="anag_documento_numero">
                            </div>
                            <div class="col-md-2">
                                <button wire:click="getByPatente()" type="button"
                                    class="btn btn-block btn-success float-right btPatente" style="max-width:150px">Dati
                                    MCTC</button>
                                <span class="btPatenteText" style="display:none">Caricamento...</span>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_documento_rilasciato_da" class="form-label">Rilasciato da</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="anag_documento_rilasciato_da">
                                    <option value=""></option>
                                    <option value="1">Comune</option>
                                    <option value="2">Motorizzazione</option>
                                    <option value="4">MCTC</option>
                                    <option value="5">MIT</option>
                                    <option value="6">UCO</option>
                                    <option value="7">Prefettura</option>
                                </select>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_documento_rilasciato_da_altro" class="form-label">Rilasciato da
                                    altro</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="text" id="anag_documento_rilasciato_da_altro"
                                    wire:model="anag_documento_rilasciato_da_altro">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_documento_rilasciato_da_di_foreign_localita" class="form-label">Comune
                                    di</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control  anag_documento_rilasciato_da_di_foreign_localita"
                                    wire:model="anag_documento_rilasciato_da_di_foreign_localita" style="width:100%">
                                    <option value="">
                                </select>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_foreign_country" class="form-label">Nazionalità</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="anag_foreign_country">
                                    <option value="">
                                    <option value="0">Italiana
                                    <option value="1">Altro paese
                                </select>
                            </div>
                        </div>

                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_documento_rilasciato_il" class="form-label">Rilasciato il</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="date" id="anag_documento_rilasciato_il"
                                    wire:model="anag_documento_rilasciato_il">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_documento_scadenza_il" class="form-label">Data scadenza</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="date" id="anag_documento_scadenza_il"
                                    wire:model="anag_documento_scadenza_il">
                            </div>
                        </div>
                    </div>
                    <div id="boxPersonaGiuridica">
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_rag_soc" class="form-label">Ragione sociale</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control @error('anag_rag_soc') is-invalid @enderror" type="text"
                                    id="anag_rag_soc" wire:model="anag_rag_soc">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_vat" class="form-label">Partita IVA</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control @error('anag_vat') is-invalid @enderror" type="text"
                                    id="anag_vat" wire:model="anag_vat">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="nazionalita" class="form-label">Paese Sede Legale</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="nazionalita">
                                    <option value="">
                                    <option value="0">Italia
                                    <option value="1">Estero
                                </select>
                            </div>
                        </div>

                        <div class="row mt-3" id="foreignPGResidenceCountry" style="display: none;">
                            <div class="col-md-4">
                                <label for="anag_foreign_residence_country" class="form-label">Paese straniero sede
                                    legale</label>
                            </div>
                            <div class="col-md-8">
                                <select class="form-control" style="width:100%" wire:model="anag_foreign_residence_country">
                                    <option value="">Seleziona paese</option>
                                    @foreach (\App\Models\LocationCountry::all() as $country)
                                        <option value="{{ $country->id }}">{{ $country->name }}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>

                        <div class="row mt-3" id="foreignPGResidenceCity" style="display: none;">
                            <div class="col-md-4">
                                <label for="anag_foreign_residence_city" class="form-label">Città straniera sede
                                    legale</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="text" id="anag_foreign_residence_city"
                                    wire:model="anag_foreign_residence_city">
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_sede_legale_address" class="form-label">Indirizzo sede legale</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="text" id="anag_sede_legale_address"
                                    wire:model="anag_sede_legale_address">
                            </div>
                        </div>
                        <div id="italianAddressFields">
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="anag_sede_legale_town_id" class="form-label">Comune sede legale</label>
                                </div>
                                <div class="col-md-8">
                                    <select class="form-control select2 anag_sede_legale_town_id"
                                        wire:model="anag_sede_legale_town_id" style="width:100%">
                                        <option value="">
                                    </select>
                                </div>
                            </div>
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="anag_sede_legale_cap" class="form-label">CAP sede legale</label>
                                </div>
                                <div class="col-md-8">
                                    <input class="form-control" type="text" id="anag_sede_legale_cap"
                                        wire:model="anag_sede_legale_cap">
                                </div>
                            </div>
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="anag_sede_legale_prov_id" class="form-label">Provincia sede
                                        legale</label>
                                </div>
                                <div class="col-md-8">
                                    <select class="form-control select2 anag_sede_legale_prov_id"
                                        wire:model="anag_sede_legale_prov_id" style="width:100%">
                                        @foreach ($provinces as $p)
                                            <option value="{{ $p->id }}">{{ $p->title }}
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="row mt-3">
                            <div class="col-md-4">
                                <label for="anag_phone" class="form-label">Telefono</label>
                            </div>
                            <div class="col-md-8">
                                <input class="form-control" type="text" id="anag_phone" wire:model="anag_phone">
                            </div>
                        </div>

                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
                    @if (!$this->validated)
                        <button type="button" class="btn btn-primary" wire:click.prevent="anagraficaSave()">Salva</button>
                    @endif
                </div>
            </div>
        </div>
    </div>

    <div wire:ignore class="modal fade" id="veicoloParte" tabindex="-1" aria-labelledby="veicoloParteLabel"
        aria-hidden="true" data-keyboard="false">
        <div class="modal-dialog modal-xl">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="veicoloParteLabel">Inserimento/modifica veicolo</h5>

                </div>
                <div class="modal-body">

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_tipo_id" class="form-label">Tipo di veicolo</label>
                        </div>
                        <div class="col-md-8">
                            <select class="form-control " wire:model="vei_tipo_id" style="width:100%">
                                <option value="">
                                    @foreach ($tipi_veicolo as $t)
                                        <option value="{{ $t->id }}">{{ $t->name }}
                                    @endforeach
                            </select>
                            @error('vei_tipo_id')
                                <span class="text-danger">{{ $message }}</span>
                            @enderror

                        </div>
                    </div>
                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_marca_id" class="form-label">Marca</label>
                        </div>
                        <div class="col-md-8">
                            <select class="form-control" wire:model="vei_marca_id" style="width:100%">
                                <option value="">
                                    @foreach ($marche as $t)
                                        <option value="{{ $t->id }}">{{ $t->name }}
                                    @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_modello_id" class="form-label">Modello</label>
                        </div>
                        <div class="col-md-8">
                            <select class="form-control" wire:model="vei_modello_id" style="width:100%">
                                <option value="">
                                    @foreach ($modelli as $t)
                                        <option value="{{ $t->id }}">{{ $t->name }}
                                    @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_colore" class="form-label">Colore</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control" type="text" id="vei_colore" placeholder="Colore"
                                wire:model="vei_colore">
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_targa" class="form-label">Targa</label>
                        </div>
                        <div class="col-md-6">
                            <input class="form-control" type="text" id="vei_targa" placeholder="Targa"
                                wire:model="vei_targa">
                        </div>
                        <div class="col-md-2">
                            <button wire:click="getByTarga()" type="button"
                                class="btn btn-block btn-success float-right btTarga" style="max-width:150px">Dati
                                MCTC</button>
                            <span class="btTargaText" style="display:none">Caricamento...</span>
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_carta_circolazione" class="form-label">Carta di circolazione</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control" type="text" id="vei_carta_circolazione"
                                placeholder="Carta di circolazione" wire:model="vei_carta_circolazione">
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_carta_circolazione_rilasciata_da" class="form-label">Rilasciata da</label>
                        </div>
                        <div class="col-md-8">
                            <select class="form-control" style="width:100%"
                                wire:model="vei_carta_circolazione_rilasciata_da">
                                <option value=""></option>
                                <option value="1">Comune</option>
                                <option value="2">Motorizzazione</option>
                                <option value="3">Altro</option>
                            </select>
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_foreign_country" class="form-label">Paese di rilascio</label>
                        </div>
                        <div class="col-md-8">
                            <select class="form-control" style="width:100%" wire:model="vei_foreign_country">
                                <option value="">
                                <option value="0">Italia
                                <option value="1">Altro paese
                            </select>
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_carta_circolazione_rilasciata_da_di" class="form-label">Località di
                                rilascio</label>
                        </div>
                        <div class="col-md-8">
                            <select class="form-control select2 vei_carta_circolazione_rilasciata_da_di"
                                wire:model="vei_carta_circolazione_rilasciata_da_di" style="width:100%">
                                <option value="">

                            </select>
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_carta_circolazione_rilasciata_il" class="form-label">Data di
                                rilascio</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control" type="date" id="vei_carta_circolazione_rilasciata_il"
                                placeholder="Data di rilascio" wire:model="vei_carta_circolazione_rilasciata_il">
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_data_ultima_revisione" class="form-label">Data ultima revisione</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control" type="date" id="vei_data_ultima_revisione"
                                placeholder="Data ultima revisione" wire:model="vei_data_ultima_revisione">
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_cilindrata" class="form-label">Cilindrata</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control" type="text" id="vei_cilindrata" placeholder="Cilindrata"
                                wire:model="vei_cilindrata">
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_peso_complessivo" class="form-label">Peso</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control" type="text" id="vei_peso_complessivo" placeholder="Peso"
                                wire:model="vei_peso_complessivo">
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="vei_destinazione_uso" class="form-label">Destinazione d'uso</label>
                        </div>
                        <div class="col-md-8">
                            <select class="form-control" style="width:100%" wire:model="vei_destinazione_uso">
                                <option value=""></option>
                                <option value="1">Privato</option>
                                <option value="8">Pubblico</option>
                                <option value="2">Locazione senza conducente</option>
                                <option value="3">Taxi</option>
                                <option value="4">Servizo pubblico di linea</option>
                                <option value="9">Soccorso o Polizia</option>
                                <option value="5">Trasporto merci</option>
                                <option value="6">Contro proprio</option>
                                <option value="7">Conto terzi</option>
                            </select>
                        </div>
                    </div>

                </div>



                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
                    @if (!$this->validated)
                        <button type="button" class="btn btn-primary" wire:click.prevent="veicoloSave()">Salva</button>
                    @endif
                </div>
            </div>
        </div>
    </div>

    <div wire:ignore class="modal fade" id="veicoloDataParte" tabindex="-1" aria-labelledby="veicoloDataParteLabel"
        aria-hidden="true" data-backdrop="static" data-keyboard="false" style="overflow-y:auto;">
        <div class="modal-dialog modal-xl modal-fullscreen-xl">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="veicoloDataParteLabel">Inserimento/modifica dati veicolo
                        {{ $currentProgressive }}
                    </h5>

                </div>
                <div class="modal-body">

                    <div class="card  collapsed-card">
                        <div class="card-header">
                            <h3 class="card-title">Veicolo</h3>
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse"><i
                                        class="fas fa-minus"></i></button>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <div class="column">
                                        <label for="data_chilometri_percorsi" class="form-label">KM percorsi</label>
                                        <input class="form-control" type="text" id="data_chilometri_percorsi" placeholder=""
                                            wire:model="data_chilometri_percorsi">
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_stato_veicolo" class="form-label">Stato veicolo</label>
                                        <select class="form-control" style="width:100%" wire:model="data_stato_veicolo">
                                            <option value=""></option>
                                            <option value="1">In marcia</option>
                                            <option value="2">In sosta</option>
                                            <option value="3">Non presente</option>
                                        </select>
                                    </div>
                                    <div class="column">
                                        <label for="data_polizze" class="form-label">Polizza auto</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_polizze" style="width:100%">
                                                    @if ($data_polizze)
                                                        <option value="{{ $data_polizze }}">
                                                            {{ $this->getPolizza($data_polizze) }}
                                                        </option>
                                                    @endif
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                <a class="btn btn-primary data_polizze_add"
                                                    wire:click.prevent="addPolizza()" data-toggle="modal"
                                                    data-target="#polizzaParte">
                                                    +&nbsp;
                                                </a>
                                                <a class="btn btn-danger data_polizze_remove"
                                                    wire:click.prevent="removePolizza()">
                                                    <i class="fa fa-trash"></i>&nbsp;
                                                </a>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="modal fade" id="polizzaParte" data-backdrop="static" data-keyboard="false"
                                        tabindex="-1" role="dialog" aria-labelledby="polizzaParteLabel" aria-hidden="true">
                                        <div class="modal-dialog modal-lg" role="document">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <h5 class="modal-title" id="polizzaParteLabel">Gestione Polizza</h5>
                                                    <button type="button" class="close" data-dismiss="modal"
                                                        aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">
                                                    <form wire:submit.prevent="savePolizza">
                                                        <div class="row mb-3">
                                                            <div class="col-md-12">
                                                                <label>Contraente *</label>
                                                                <div class="row">
                                                                    <div class="col-sm-9">
                                                                        <select class="form-control anagrafica_id"
                                                                            wire:model="anagrafica_id" required>
                                                                            @if ($anagrafica_id)
                                                                                <option value="{{ $anagrafica_id }}">
                                                                                    {{ $this->getAnagrafica($anagrafica_id) }}
                                                                                </option>
                                                                            @endif
                                                                        </select>
                                                                        @error('anagrafica_id')
                                                                            <span class="text-danger">{{ $message }}</span>
                                                                        @enderror
                                                                    </div>
                                                                    <div class="col-sm-3">
                                                                        @if ($anagrafica_id)
                                                                            <a class="btn btn-primary editAnagrafica"
                                                                                wire:click.prevent="editAnagraficaPolizza()"
                                                                                data-target="#anagraficaParte"
                                                                                style="background-color: orange;border-color: orange;">
                                                                                <i class="fa fa-edit"></i>
                                                                            </a>
                                                                            <a class="btn btn-danger"
                                                                                wire:click.prevent="removeAnagraficaPolizza()">
                                                                                <i class="fa fa-trash"></i>&nbsp;
                                                                            </a>
                                                                        @else
                                                                            <a class="btn btn-primary"
                                                                                wire:click.prevent="addAnagraficaPolizza()"
                                                                                data-target="#anagraficaParte">+&nbsp;
                                                                            </a>
                                                                        @endif
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-6">
                                                                <div class="form-group">
                                                                    <label>Compagnia *</label>
                                                                    <select class="form-control compagnia_id"
                                                                        wire:model="compagnia_id" required>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-6">
                                                                <div class="form-group">
                                                                    <label>Agenzia</label>
                                                                    <select class="form-control agenzia"
                                                                        wire:model="agenzia">
                                                                    </select>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-12">
                                                                <div class="form-group">
                                                                    <label>Numero Polizza *</label>
                                                                    <input type="text" class="form-control polizza_num"
                                                                        wire:model.debounce.500ms="polizza_num" required>

                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="row">
                                                            <div class="col-md-6">
                                                                <div class="form-group">
                                                                    <label>Valida dal *</label>
                                                                    <div class="input-group">
                                                                        <input type="date" class="form-control valida_dal"
                                                                            wire:model="valida_dal" required>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-6">
                                                                <div class="form-group">
                                                                    <label>Valida al *</label>
                                                                    <div class="input-group">
                                                                        <input type="date" class="form-control valida_al"
                                                                            wire:model="valida_al" required>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>


                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-secondary"
                                                                wire:click="cleanPolizzaData"
                                                                onclick="$('#polizzaParte').modal('hide')">Chiudi</button>
                                                            <button type="submit" class="btn btn-primary">Salva</button>
                                                        </div>
                                                    </form>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="column">
                                        <label for="data_proprietari" class="form-label">Proprietario</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_proprietari" style="width:100%">
                                                    <option value="{{ $data_proprietari }}">
                                                        {{ $this->getAnagrafica($data_proprietari) }}
                                                    </option>
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                <a class="btn btn-primary editAnagrafica data_proprietari_edit"
                                                    wire:click.prevent="editProprietario()" data-toggle="modal"
                                                    data-target="#anagraficaParte"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a>
                                                <a class="btn btn-danger data_proprietari_remove"
                                                    wire:click.prevent="removeProprietario()"><i
                                                        class="fa fa-trash"></i>&nbsp;</a>
                                                <a class="btn btn-primary data_proprietari_add"
                                                    wire:click.prevent="addProprietario()" data-toggle="modal"
                                                    data-target="#anagraficaParte">+&nbsp;</a>
                                            </div>
                                        </div>

                                    </div>

                                    <div class="column">
                                        <label for="data_coproprietari" class="form-label">Coproprietario</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_coproprietari" style="width:100%">
                                                    <option value="{{ $data_coproprietari }}">
                                                        {{ $this->getAnagrafica($data_coproprietari) }}
                                                    </option>
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                <a class="btn btn-primary editAnagrafica data_coproprietari_edit"
                                                    wire:click.prevent="editCoproprietario()" data-toggle="modal"
                                                    data-target="#anagraficaParte"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a>
                                                <a class="btn btn-danger data_coproprietari_remove"
                                                    wire:click.prevent="removeCoproprietario()"><i
                                                        class="fa fa-trash"></i>&nbsp;</a>
                                                <a class="btn btn-primary data_coproprietari_add"
                                                    wire:click.prevent="addCoproprietario()" data-toggle="modal"
                                                    data-target="#anagraficaParte">+&nbsp;</a>
                                            </div>
                                        </div>

                                    </div>

                                    @if (false)
                                        <div class="column mt-3">
                                            <div class="form-group">
                                                <div class="custom-control custom-switch custom-switch-md">
                                                    <input type="checkbox" class="custom-control-input"
                                                        id="data_conducente_uguale_proprietario"
                                                        wire:model="data_conducente_uguale_proprietario">
                                                    <label class="custom-control-label"
                                                        for="data_conducente_uguale_proprietario">Proprietario è anche
                                                        conducente</label>
                                                </div>
                                            </div>

                                        </div>

                                        <div class="column mt-3">
                                            <label for="data_conducenti" class="form-label">Conducente</label>
                                            <div class="row">
                                                <div class="col-sm-6">
                                                    <select class="form-control data_conducenti" style="width:100%">
                                                        <option value="{{ $data_conducenti }}">
                                                            {{ $this->getAnagrafica($data_conducenti) }}
                                                        </option>
                                                    </select>
                                                </div>
                                                <div class="col-sm-4">
                                                    <a class="btn btn-primary editAnagrafica data_conducenti_edit"
                                                        wire:click.prevent="editConducente()" data-toggle="modal"
                                                        data-target="#anagraficaParte"
                                                        style="background-color: orange;border-color: orange;"><i
                                                            class="fa fa-edit"></i></i></a>
                                                    <a class="btn btn-danger data_conducenti_remove"
                                                        wire:click.prevent="removeConducente()"><i
                                                            class="fa fa-trash"></i>&nbsp;</a>
                                                    <a class="btn btn-primary data_conducenti_add"
                                                        wire:click.prevent="addConducente()" data-toggle="modal"
                                                        data-target="#anagraficaParte">+&nbsp;</a>

                                                </div>
                                            </div>
                                        </div>
                                    @endif

                                    <div class="column mt-3">
                                        <label for="data_infortunato" class="form-label">Conducente
                                            infortunato</label>
                                        <select class="form-control" style="width:100%" wire:model="data_infortunato"
                                            id="data_infortunato">
                                            <option value=""></option>
                                            <option value="1">Ferito</option>
                                            <option value="2">Deceduto entro 24 ore</option>
                                            <option value="3">Deceduto entro 30 giorni</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3" id="data_infortunato_select">
                                        <label for="data_infortunato_ospedale" class="form-label">Ospedale
                                            medicazione/ricovero</label>
                                        <input class="form-control" type="text" id="data_infortunato_ospedale"
                                            placeholder="" wire:model="data_infortunato_ospedale">
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_patente_al_seguito" class="form-label">Patente al
                                            seguito</label>
                                        <select class="form-control" style="width:100%"
                                            wire:model="data_patente_al_seguito">
                                            <option value=""></option>
                                            <option value="1">Si</option>
                                            <option value="2">No</option>
                                            <option value="3">Non prevista</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_generalizzato" class="form-label">Generalizzato</label>
                                        <select class="form-control" style="width:100%" wire:model="data_generalizzato"
                                            id="data_generalizzato">
                                            <option value=""></option>
                                            <option value="1">Sul luogo</option>
                                            <option value="2">In ospedale</option>
                                            <option value="3">Altrove</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3" id="data_generalizzato_select">
                                        <label for="data_generalizzato_altrove" class="form-label">Altrove</label>
                                        <input class="form-control" type="text" id="data_generalizzato_altrove"
                                            placeholder="" wire:model="data_generalizzato_altrove">
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="column">
                                        <label for="data_passeggero_0" class="form-label">Selezionare passeggero
                                            (sedile
                                            anteriore)</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_passeggero_0" style="width:100%">
                                                    <option value="{{ $data_passeggero_0 }}">
                                                        {{ $this->getAnagrafica($data_passeggero_0) }}
                                                    </option>
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                <a class="btn btn-primary editAnagrafica data_passeggero_0_edit"
                                                    wire:click.prevent="editPasseggero(1)" data-toggle="modal"
                                                    data-target="#anagraficaParte"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a>
                                                <a class="btn btn-danger data_passeggero_0_remove"
                                                    wire:click.prevent="removePasseggero(1)"><i
                                                        class="fa fa-trash"></i>&nbsp;</a>
                                                <a class="btn btn-primary data_passeggero_0_add"
                                                    wire:click.prevent="addPasseggero(1)" data-toggle="modal"
                                                    data-target="#anagraficaParte">+&nbsp;</a>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_infortunato_0" class="form-label">Infortunato</label>
                                        <select class="form-control" wire:model="data_infortunato_0"
                                            id="data_infortunato_0">
                                            <option value=""></option>
                                            <option value="1">Ferito</option>
                                            <option value="2">Deceduto entro 24 ore</option>
                                            <option value="3">Deceduto entro 30 giorni</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3" id="data_infortunato_0_select">
                                        <label for="data_infortunato_ospedale_0" class="form-label">Ospedale
                                            medicazione/ricovero</label>
                                        <input class="form-control" type="text" id="data_infortunato_ospedale_0"
                                            placeholder="" wire:model="data_infortunato_ospedale_0">
                                    </div>
                                    <div class="column mt-3">
                                        <hr size="1">
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_passeggero_1" class="form-label">Selezionare passeggero
                                            (posteriore destra)</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_passeggero_1" style="width:100%">
                                                    <option value="{{ $data_passeggero_1 }}">
                                                        {{ $this->getAnagrafica($data_passeggero_1) }}
                                                    </option>
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                <a class="btn btn-primary editAnagrafica data_passeggero_1_edit"
                                                    wire:click.prevent="editPasseggero(2)" data-toggle="modal"
                                                    data-target="#anagraficaParte"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a>
                                                <a class="btn btn-danger data_passeggero_1_remove"
                                                    wire:click.prevent="removePasseggero(2)"><i
                                                        class="fa fa-trash"></i>&nbsp;</a>
                                                <a class="btn btn-primary data_passeggero_1_add"
                                                    wire:click.prevent="addPasseggero(2)" data-toggle="modal"
                                                    data-target="#anagraficaParte">+&nbsp;</a>

                                            </div>
                                        </div>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_infortunato_1" class="form-label">Infortunato</label>
                                        <select class="form-control" wire:model="data_infortunato_1"
                                            id="data_infortunato_1">
                                            <option value=""></option>
                                            <option value="1">Ferito</option>
                                            <option value="2">Deceduto entro 24 ore</option>
                                            <option value="3">Deceduto entro 30 giorni</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3" id="data_infortunato_1_select">
                                        <label for="data_infortunato_ospedale_1" class="form-label">Ospedale
                                            medicazione/ricovero</label>
                                        <input class="form-control" type="text" id="data_infortunato_ospedale_1"
                                            placeholder="" wire:model="data_infortunato_ospedale_1">
                                    </div>
                                    <div class="column mt-3">
                                        <hr size="1">
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_passeggero_2" class="form-label">Selezionare passeggero
                                            (posteriore centrale)</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_passeggero_2" style="width:100%">
                                                    <option value="{{ $data_passeggero_2 }}">
                                                        {{ $this->getAnagrafica($data_passeggero_2) }}
                                                    </option>
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                <a class="btn btn-primary editAnagrafica data_passeggero_2_edit"
                                                    wire:click.prevent="editPasseggero(3)" data-toggle="modal"
                                                    data-target="#anagraficaParte"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a>
                                                <a class="btn btn-danger data_passeggero_2_remove"
                                                    wire:click.prevent="removePasseggero(3)"><i
                                                        class="fa fa-trash"></i>&nbsp;</a>
                                                <a class="btn btn-primary data_passeggero_2_add"
                                                    wire:click.prevent="addPasseggero(3)" data-toggle="modal"
                                                    data-target="#anagraficaParte">+&nbsp;</a>

                                            </div>
                                        </div>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_infortunato_2" class="form-label">Infortunato</label>
                                        <select class="form-control" wire:model="data_infortunato_2"
                                            id="data_infortunato_2">
                                            <option value=""></option>
                                            <option value="1">Ferito</option>
                                            <option value="2">Deceduto entro 24 ore</option>
                                            <option value="3">Deceduto entro 30 giorni</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3" id="data_infortunato_2_select">
                                        <label for="data_infortunato_ospedale_2" class="form-label">Ospedale
                                            medicazione/ricovero</label>
                                        <input class="form-control" type="text" id="data_infortunato_ospedale_2"
                                            placeholder="" wire:model="data_infortunato_ospedale_2">
                                    </div>
                                    <div class="column mt-3">
                                        <hr size="1">
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_passeggero_3" class="form-label">Selezionare passeggero
                                            (posteriore sinistro)</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_passeggero_3" style="width:100%">
                                                    <option value="{{ $data_passeggero_3 }}">
                                                        {{ $this->getAnagrafica($data_passeggero_3) }}
                                                    </option>
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                <a class="btn btn-primary editAnagrafica data_passeggero_3_edit"
                                                    wire:click.prevent="editPasseggero(4)" data-toggle="modal"
                                                    data-target="#anagraficaParte"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a>
                                                <a class="btn btn-danger data_passeggero_3_remove"
                                                    wire:click.prevent="removePasseggero(4)"><i
                                                        class="fa fa-trash"></i>&nbsp;</a>
                                                <a class="btn btn-primary data_passeggero_3_add"
                                                    wire:click.prevent="addPasseggero(4)" data-toggle="modal"
                                                    data-target="#anagraficaParte">+&nbsp;</a>

                                            </div>
                                        </div>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_infortunato_3" class="form-label">Infortunato</label>
                                        <select class="form-control" wire:model="data_infortunato_3"
                                            id="data_infortunato_3">
                                            <option value=""></option>
                                            <option value="1">Ferito</option>
                                            <option value="2">Deceduto entro 24 ore</option>
                                            <option value="3">Deceduto entro 30 giorni</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3" id="data_infortunato_3_select">
                                        <label for="data_infortunato_ospedale_3" class="form-label">Ospedale
                                            medicazione/ricovero</label>
                                        <input class="form-control" type="text" id="data_infortunato_ospedale_3"
                                            placeholder="" wire:model="data_infortunato_ospedale_3">
                                    </div>
                                    <div class="column mt-3">
                                        <hr size="1">
                                    </div>
                                </div>

                            </div>

                            <div class="row mt-3">
                                <div class="divider"></div>
                            </div>
                            <div class="row mt-3">
                                {{-- <div class="col-md-4">
                                    <div class="column">
                                        <label for="data_infortunato_extra_0" class="form-label">Selezionare
                                            infortunato</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_infortunato_extra_0" style="width:100%">
                                                    <option value="{{ $data_infortunato_extra_0 }}">
                                                        {{ $this->getAnagrafica($data_infortunato_extra_0) }}
                                                    </option>
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                @if ($data_infortunato_extra_0 > 0)
                                                <a class="btn btn-primary editAnagrafica"
                                                    wire:click.prevent="editAnagrafica({{ $data_infortunato_extra_0 }})"
                                                    data-toggle="modal" data-target="#anagraficaParte"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a>
                                                @else
                                                <a class="btn btn-primary" wire:click.prevent="addInfortunato(1)"
                                                    data-toggle="modal" data-target="#anagraficaParte">+&nbsp;</a>
                                                @endif
                                            </div>
                                        </div>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_infortunato_extra_1" class="form-label">Selezionare
                                            infortunato</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_infortunato_extra_1" style="width:100%">
                                                    <option value="{{ $data_infortunato_extra_1 }}">
                                                        {{ $this->getAnagrafica($data_infortunato_extra_1) }}
                                                    </option>
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                @if ($data_infortunato_extra_1 > 0)
                                                <a class="btn btn-primary editAnagrafica"
                                                    wire:click.prevent="editAnagrafica({{ $data_infortunato_extra_1 }})"
                                                    data-toggle="modal" data-target="#anagraficaParte"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a>
                                                @else
                                                <a class="btn btn-primary" wire:click.prevent="addInfortunato(2)"
                                                    data-toggle="modal" data-target="#anagraficaParte">+&nbsp;</a>
                                                @endif
                                            </div>
                                        </div>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_infortunato_extra_2" class="form-label">Selezionare
                                            infortunato</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_infortunato_extra_2" style="width:100%">
                                                    <option value="{{ $data_infortunato_extra_2 }}">
                                                        {{ $this->getAnagrafica($data_infortunato_extra_2) }}
                                                    </option>
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                @if ($data_infortunato_extra_2 > 0)
                                                <a class="btn btn-primary editAnagrafica"
                                                    wire:click.prevent="editAnagrafica({{ $data_infortunato_extra_2 }})"
                                                    data-toggle="modal" data-target="#anagraficaParte"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a>
                                                @else
                                                <a class="btn btn-primary" wire:click.prevent="addInfortunato(3)"
                                                    data-toggle="modal" data-target="#anagraficaParte">+&nbsp;</a>
                                                @endif
                                            </div>
                                        </div>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_infortunato_extra_3" class="form-label">Selezionare
                                            infortunato</label>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <select class="form-control data_infortunato_extra_3" style="width:100%">
                                                    <option value="{{ $data_infortunato_extra_3 }}">
                                                        {{ $this->getAnagrafica($data_infortunato_extra_3) }}
                                                    </option>
                                                </select>
                                            </div>
                                            <div class="col-sm-4">
                                                @if ($data_infortunato_extra_3 > 0)
                                                <a class="btn btn-primary editAnagrafica"
                                                    wire:click.prevent="editAnagrafica({{ $data_infortunato_extra_3 }})"
                                                    data-toggle="modal" data-target="#anagraficaParte"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a>
                                                @else
                                                <a class="btn btn-primary" wire:click.prevent="addInfortunato(4)"
                                                    data-toggle="modal" data-target="#anagraficaParte">+&nbsp;</a>
                                                @endif
                                            </div>
                                        </div>
                                    </div>
                                </div> --}}
                                <div class="col-md-4">
                                    <div class="column">
                                        <label for="data_posizione_statica_finale" class="form-label">Posizione
                                            statica
                                            finale</label>
                                        <select class="form-control" style="width:100%"
                                            wire:model="data_posizione_statica_finale">
                                            <option value=""></option>
                                            <option value="1">Come da documentazione fotografica</option>
                                            <option value="2">Come rilievo planimetrico</option>
                                            <option value="3">Coma da schizzo a vista non in scala</option>
                                            <option value="4">Già rimosso</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_danni_visibili_riportati" class="form-label">Danni visibili
                                            riportati</label>
                                        <textarea rows="5" class="form-control" id="data_danni_visibili_riportati"
                                            placeholder="" wire:model="data_danni_visibili_riportati"></textarea>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_danni_visibili_pre_esistenti" class="form-label">Danni
                                            visibili
                                            preesistenti</label>
                                        <textarea rows="5" class="form-control" id="data_danni_visibili_pre_esistenti"
                                            placeholder="" wire:model="data_danni_visibili_pre_esistenti"></textarea>
                                    </div>

                                </div>
                                <div class="col-md-4">
                                    <div class="column">

                                        <label for="data_destinazione_veicolo" class="form-label">Destinazione
                                            veicolo</label>
                                        <select class="form-control" style="width:100%"
                                            wire:model="data_destinazione_veicolo" id="data_destinazione_veicolo">
                                            <option value=""></option>
                                            <option value="1">Rimosso ai sensi dell'articolo 2028</option>
                                            <option value="2">Sequestro art. 354 Codice Procedura Penale</option>
                                            <option value="3">Sequestro art. 321 Codice Procedura Penale</option>
                                            <option value="4">Sequestro</option>
                                            <option value="5">Sequestro amministrativo</option>
                                            <option value="6">Fermo amministrativo</option>
                                            <option value="7">Ritirato dal conducente</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3" id="data_destinazione_veicolo_select_0">
                                        <label for="data_destinazione_veicolo_affidato_a" class="form-label">Affidato
                                            a</label>
                                        <input class="form-control" type="text" id="data_destinazione_veicolo_affidato_a"
                                            placeholder="" wire:model="data_destinazione_veicolo_affidato_a">
                                    </div>
                                    <div class="column mt-3" id="data_destinazione_veicolo_select_1">
                                        <label for="data_destinazione_veicolo_sequestro_num_art" class="form-label">Ai
                                            sensi dell'art.</label>
                                        <input class="form-control" type="text"
                                            id="data_destinazione_veicolo_sequestro_num_art" placeholder=""
                                            wire:model="data_destinazione_veicolo_sequestro_num_art">
                                    </div>
                                    <div class="column mt-3" id="data_destinazione_veicolo_select_2">
                                        <label for="data_destinazione_veicolo_amministrativo_num" class="form-label">Numero
                                            fermo o sequestro amministrativo</label>
                                        <input class="form-control" type="text"
                                            id="data_destinazione_veicolo_amministrativo_num" placeholder=""
                                            wire:model="data_destinazione_veicolo_amministrativo_num">
                                    </div>
                                    <div class="column mt-3" id="data_destinazione_veicolo_select_3">
                                        <label for="data_destinazione_veicolo_amministrativo_num_art_violato"
                                            class="form-label">Art. violato</label>
                                        <input class="form-control" type="text"
                                            id="data_destinazione_veicolo_amministrativo_num_art_violato" placeholder=""
                                            wire:model="data_destinazione_veicolo_amministrativo_num_art_violato">
                                    </div>
                                    <div class="column" id="data_destinazione_veicolo_select_4">
                                        <label for="data_destinazione_veicolo_amministrativo_cds"
                                            class="form-label">Cds</label>
                                        <input class="form-control" type="text"
                                            id="data_destinazione_veicolo_amministrativo_cds" placeholder=""
                                            wire:model="data_destinazione_veicolo_amministrativo_cds">
                                    </div>
                                </div>
                            </div>

                            <div class="row mt-3">
                                <div class="col-md-12">
                                    <div id="fields-container" class="row">
                                        <div class="field-group col-md-3">
                                            <div class="column">
                                                <label for="data_tipo_danno" class="form-label">Tipologia
                                                    danno</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_tipo_danno">
                                                    <option value=""></option>
                                                    @foreach ($tipi_danno as $t)
                                                        <option value="{{ $t->id }}">{{ $t->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_entita_danno" class="form-label">Entità del
                                                    danno</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_entita_danno">
                                                    <option value=""></option>
                                                    @foreach ($entita_danni as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_effetto_danno" class="form-label">Effetto del
                                                    danno</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_effetto_danno">
                                                    <option value=""></option>
                                                    @foreach ($effetto_danni as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_parte_macchina" class="form-label">Zona
                                                    veicolo</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_parte_macchina">
                                                    <option value=""></option>
                                                    @foreach ($parti_macchina as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>

                                        <div class="field-group col-md-3" id="damage-column-2" style="display: none;">
                                            <div class="column">
                                                <label for="data_tipo_danno_2" class="form-label">Tipologia danno
                                                    2</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_tipo_danno_2">
                                                    <option value=""></option>
                                                    @foreach ($tipi_danno as $t)
                                                        <option value="{{ $t->id }}">{{ $t->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_entita_danno_2" class="form-label">Entità del danno
                                                    2</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_entita_danno_2">
                                                    <option value=""></option>
                                                    @foreach ($entita_danni as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_effetto_danno_2" class="form-label">Effetto del
                                                    danno 2</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_effetto_danno_2">
                                                    <option value=""></option>
                                                    @foreach ($effetto_danni as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_parte_macchina_2" class="form-label">Zona veicolo
                                                    2</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_parte_macchina_2">
                                                    <option value=""></option>
                                                    @foreach ($parti_macchina as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>

                                        <div class="field-group col-md-3" id="damage-column-3" style="display: none;">
                                            <div class="column">
                                                <label for="data_tipo_danno_3" class="form-label">Tipologia danno
                                                    3</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_tipo_danno_3">
                                                    <option value=""></option>
                                                    @foreach ($tipi_danno as $t)
                                                        <option value="{{ $t->id }}">{{ $t->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_entita_danno_3" class="form-label">Entità del danno
                                                    3</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_entita_danno_3">
                                                    <option value=""></option>
                                                    @foreach ($entita_danni as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_effetto_danno_3" class="form-label">Effetto del
                                                    danno 3</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_effetto_danno_3">
                                                    <option value=""></option>
                                                    @foreach ($effetto_danni as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_parte_macchina_3" class="form-label">Zona veicolo
                                                    3</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_parte_macchina_3">
                                                    <option value=""></option>
                                                    @foreach ($parti_macchina as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>

                                        <div class="field-group col-md-3" id="damage-column-4" style="display: none;">
                                            <div class="column">
                                                <label for="data_tipo_danno_4" class="form-label">Tipologia danno
                                                    4</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_tipo_danno_4">
                                                    <option value=""></option>
                                                    @foreach ($tipi_danno as $t)
                                                        <option value="{{ $t->id }}">{{ $t->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_entita_danno_4" class="form-label">Entità del danno
                                                    4</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_entita_danno_4">
                                                    <option value=""></option>
                                                    @foreach ($entita_danni as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_effetto_danno_4" class="form-label">Effetto del
                                                    danno 4</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_effetto_danno_4">
                                                    <option value=""></option>
                                                    @foreach ($effetto_danni as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="column">
                                                <label for="data_parte_macchina_4" class="form-label">Zona veicolo
                                                    4</label>
                                                <select class="form-control" style="width:100%"
                                                    wire:model="data_parte_macchina_4">
                                                    <option value=""></option>
                                                    @foreach ($parti_macchina as $e)
                                                        <option value="{{ $e->id }}">{{ $e->name }}
                                                        </option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row mt-2">
                                        <div class="col-12">
                                            <button type="button" class="btn btn-primary" id="add-damage-btn"
                                                onclick="showNextDamageColumn()">
                                                Aggiungi Danni
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>



                            <div class="column mt-3">
                                <label for="data_circostanze_presunte_incidente" class="form-label">Circostanze
                                    presunte
                                    incidente</label>
                                <textarea rows="5" class="form-control" id="data_circostanze_presunte_incidente"
                                    placeholder="" wire:model="data_circostanze_presunte_incidente"></textarea>
                            </div>
                        </div>
                    </div>

                    @if (false)
                        <div class="card collapsed-card">
                            <div class="card-header">
                                <h3 class="card-title">Documenti di guida conducente</h3>
                                <div class="card-tools">
                                    <button type="button" class="btn btn-tool" data-card-widget="collapse"><i
                                            class="fas fa-minus"></i></button>
                                </div>
                            </div>
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="column">
                                            <label for="data_conducente_patente_numero" class="form-label">Patente
                                                num</label>
                                            <input class="form-control" type="text" id="data_conducente_patente_numero"
                                                placeholder="" wire:model="data_conducente_patente_numero">
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_patente_categoria" class="form-label">Patente
                                                cat</label>
                                            <select class="form-control" style="width:100%"
                                                wire:model="data_conducente_patente_categoria">
                                                <option value=""></option>
                                                <option value="AM">AM</option>
                                                <option value="A1">A1</option>
                                                <option value="A1B">A1B</option>
                                                <option value="A2">A2</option>
                                                <option value="A">A</option>
                                                <option value="AB">AB</option>
                                                <option value="B1">B1</option>
                                                <option value="B">B</option>
                                                <option value="BE">BE</option>
                                                <option value="C1">C1</option>
                                                <option value="C1E">C1E</option>
                                                <option value="C">C</option>
                                                <option value="CE">CE</option>
                                                <option value="D1">D1</option>
                                                <option value="D1E">D1E</option>
                                                <option value="DE">DE</option>
                                                <option value="E">E</option>
                                            </select>
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_patente_rilasciata_da" class="form-label">Rilasciato
                                                da</label>
                                            <select class="form-control" style="width:100%"
                                                wire:model="data_conducente_patente_rilasciata_da">
                                                <option value=""></option>
                                                <option value="1">Comune</option>
                                                <option value="2">Motorizzazione</option>
                                                <option value="4">MCTC</option>
                                                <option value="5">MIT</option>
                                                <option value="6">UCO</option>
                                                <option value="7">Prefettura</option>
                                            </select>
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_patente_rilasciata_il" class="form-label">Rilasciato
                                                il</label>
                                            <input class="form-control" type="date" id="data_conducente_patente_rilasciata_il"
                                                placeholder="" wire:model="data_conducente_patente_rilasciata_il">
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_patente_scadenza" class="form-label">Data
                                                scadenza</label>
                                            <input class="form-control" type="date" id="data_conducente_patente_scadenza"
                                                placeholder="Data scadenza" wire:model="data_conducente_patente_scadenza">
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="column">
                                            <label for="data_conducente_patente_prescrizioni"
                                                class="form-label">Prescrizioni</label>
                                            <select class="form-control" style="width:100%"
                                                wire:model="data_conducente_patente_prescrizioni">
                                                <option value=""></option>
                                                <option value="1">OBBLIGO LENTI</option>
                                                <option value="2">OBBLIGO APPARECCHIO ACUSTICO</option>
                                                <option value="3">LIMITAZIONI ART 117</option>
                                            </select>
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_patente_limitazioni_art_117_1"
                                                class="form-label">Limitazioni</label>
                                            <input class="form-control" type="text"
                                                id="data_conducente_patente_limitazioni_art_117_1" placeholder=""
                                                wire:model="data_conducente_patente_limitazioni_art_117_1">
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_patente_limitazioni_art_117_2" class="form-label">Altre
                                                limitazioni</label>
                                            <input class="form-control" type="text"
                                                id="data_conducente_patente_limitazioni_art_117_2" placeholder=""
                                                wire:model="data_conducente_patente_limitazioni_art_117_2">
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_patente_abilitazione"
                                                class="form-label">Abilitazione</label>
                                            <select class="form-control" style="width:100%"
                                                wire:model="data_conducente_patente_abilitazione">
                                                <option value=""></option>
                                                <option value="1">ABILITAZIONE CQC</option>
                                                <option value="2">ABILITAZIONE CAP</option>
                                                <option value="3">ABILITAZIONE CFC</option>
                                            </select>
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_patente_abilitazione_numero" class="form-label">Numero
                                                abilitazione</label>
                                            <input class="form-control" type="text"
                                                id="data_conducente_patente_abilitazione_numero" placeholder=""
                                                wire:model="data_conducente_patente_abilitazione_numero">
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="column">
                                            <label for="data_conducente_patente_abilitazione_rilasciata_da"
                                                class="form-label">Abilitazione rilasciata da</label>
                                            <select class="form-control" style="width:100%"
                                                wire:model="data_conducente_patente_abilitazione_rilasciata_da">
                                                <option value=""></option>
                                                <option value="1">Comune</option>
                                                <option value="2">Motorizzazione</option>
                                            </select>
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_patente_abilitazione_rilasciata_il"
                                                class="form-label">Abilitazione rilasciata il</label>
                                            <input class="form-control" type="date"
                                                id="data_conducente_patente_abilitazione_rilasciata_il" placeholder=""
                                                wire:model="data_conducente_patente_abilitazione_rilasciata_il">
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_documento" class="form-label">Documento</label>
                                            <select class="form-control" style="width:100%"
                                                wire:model="data_conducente_documento">
                                                <option value=""></option>
                                                <option value="1">Carte identità</option>
                                                <option value="2">Patente</option>
                                                <option value="3">Passaporto</option>
                                            </select>
                                        </div>
                                        <div class="column mt-3">
                                            <label for="data_conducente_documento_numero" class="form-label">Numero
                                                documento</label>
                                            <input class="form-control" type="text" id="data_conducente_documento_numero"
                                                placeholder="" wire:model="data_conducente_documento_numero">
                                        </div>
                                        <div class="column mt-3">
                                            <div class="form-group">
                                                <div class="custom-control custom-switch custom-switch-md">
                                                    <input type="checkbox" class="custom-control-input"
                                                        id="data_conducente_sedicente" wire:model="data_conducente_sedicente">
                                                    <label class="custom-control-label"
                                                        for="data_conducente_sedicente">Sedicente</label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    @endif

                    <div class="card collapsed-card">
                        <div class="card-header">
                            <h3 class="card-title">Osservazioni sul veicolo</h3>
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse"><i
                                        class="fas fa-minus"></i></button>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <div class="column">
                                        <label for="data_stato_pneumatici" class="form-label">Stato
                                            pneumatici</label>
                                        <select class="form-control" style="width:100%" wire:model="data_stato_pneumatici">
                                            <option value=""></option>
                                            <option value="1">Regolamentare</option>
                                            <option value="2">Buono</option>
                                            <option value="3">Sufficiente</option>
                                            <option value="4">Insufficiente</option>
                                            <option value="5">Non rilevato</option>
                                            </ul>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_dispositivi_ottici" class="form-label">Dispositivi
                                            ottici</label>
                                        <select class="form-control" style="width:100%"
                                            wire:model="data_dispositivi_ottici">
                                            <option value=""></option>
                                            <option value="1">Funzionante</option>
                                            <option value="2">Non funzionante</option>
                                            <option value="3">Non rilevato</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_abs" class="form-label">ABS</label>
                                        <select class="form-control" style="width:100%" wire:model="data_abs">
                                            <option value=""></option>
                                            <option value="1">Presente</option>
                                            <option value="2">Non presente</option>
                                            <option value="3">Non rilevato</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_cristallo" class="form-label">Cristallo</label>
                                        <select class="form-control" style="width:100%" wire:model="data_cristallo">
                                            <option value=""></option>
                                            <option value="1">Incrinato all'interno</option>
                                            <option value="2">Incrinato all'esterno</option>
                                            <option value="3">Altra posizione</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_specchio_retrovisore" class="form-label">Specchio
                                            retrovisore</label>
                                        <select class="form-control" style="width:100%"
                                            wire:model="data_specchio_retrovisore">
                                            <option value=""></option>
                                            <option value="1">Presente</option>
                                            <option value="2">Non presente</option>
                                            <option value="3">Non rilevato</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_attivazione_airbag" class="form-label">Attivazione
                                            airbag</label>
                                        <select class="form-control" style="width:100%"
                                            wire:model="data_attivazione_airbag">
                                            <option value=""></option>
                                            <option value="1">SI</option>
                                            <option value="2">NO</option>
                                            <option value="3">Non rilevato</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="column">
                                        <label for="data_marca_pneumatici" class="form-label">Marca
                                            pneumatici</label>
                                        <input class="form-control" type="text" id="data_marca_pneumatici" placeholder=""
                                            wire:model="data_marca_pneumatici">
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_tergicristalli" class="form-label">Tergicristalli</label>
                                        <select class="form-control" style="width:100%" wire:model="data_tergicristalli">
                                            <option value=""></option>
                                            <option value="1">Funzionante</option>
                                            <option value="2">Non funzionante</option>
                                            <option value="3">Non rilevato</option>
                                            <option value="4">Non previsto</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_gps" class="form-label">GPS</label>
                                        <select class="form-control" style="width:100%" wire:model="data_gps">
                                            <option value=""></option>
                                            <option value="1">Presente</option>
                                            <option value="2">Non presente</option>
                                            <option value="3">Non rilevato</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_specchio_lat_dx" class="form-label">Specchio laterale
                                            dx</label>
                                        <select class="form-control" style="width:100%" wire:model="data_specchio_lat_dx">
                                            <option value=""></option>
                                            <option value="1">Presente</option>
                                            <option value="2">Non presente</option>
                                            <option value="3">Non rilevato</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="column">
                                        <label for="data_misura_pneumatici" class="form-label">Misura
                                            pneumatici</label>
                                        <input class="form-control" type="text" id="data_misura_pneumatici" placeholder=""
                                            wire:model="data_misura_pneumatici">
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_segnale_pericolo" class="form-label">Segnale di
                                            pericolo</label>
                                        <select class="form-control" style="width:100%" wire:model="data_segnale_pericolo">
                                            <option value=""></option>
                                            <option value="1">Presente</option>
                                            <option value="2">Non presente</option>
                                            <option value="3">Non rilevato</option>
                                            <option value="4">Non previsto</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_marcia_inserita" class="form-label">Marcia inserita</label>
                                        <select class="form-control" style="width:100%" wire:model="data_marcia_inserita">
                                            <option value=""></option>
                                            <option value="0">Folle</option>
                                            <option value="1">Prima</option>
                                            <option value="2">Seconda</option>
                                            <option value="3">Terza</option>
                                            <option value="4">Quarta</option>
                                            <option value="5">Quinta</option>
                                            <option value="6">Sesta</option>
                                            <option value="7">Retromarcia</option>
                                            <option value="9">Cambio automatico</option>
                                            <option value="8">Non rilevata</option>
                                        </select>
                                    </div>
                                    <div class="column mt-3">
                                        <label for="data_specchio_lat_sx" class="form-label">Specchio laterale
                                            sx</label>
                                        <select class="form-control" style="width:100%" wire:model="data_specchio_lat_sx">
                                            <option value=""></option>
                                            <option value="1">Presente</option>
                                            <option value="2">Non presente</option>
                                            <option value="3">Non rilevato</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="card collapsed-card">
                        <div class="card-header">
                            <h3 class="card-title">Accertamenti conducente</h3>
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse"><i
                                        class="fas fa-minus"></i></button>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="data_cinture_conducente" class="form-label">Uso cinture di
                                        sicurezza</label>
                                    <select class="form-control" style="width:100%" wire:model="data_cinture_conducente">
                                        <option value="0"></option>
                                        <option value="1">SI</option>
                                        <option value="2">NO</option>
                                        <option value="3">Non rilevato</option>
                                    </select>
                                </div>
                            </div>
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="data_casco_conducente" class="form-label">Uso del casco</label>
                                    <select class="form-control" style="width:100%" wire:model="data_casco_conducente"
                                        id="data_casco_conducente">
                                        <option value="0"></option>
                                        <option value="1">SI</option>
                                        <option value="2">NO</option>
                                        <option value="3">Non rilevato</option>
                                    </select>
                                </div>
                                <div class="col-md-4" id="data_casco_conducente_select">
                                    <label for="data_casco_omologazione_conducente" class="form-label">Omologazione
                                        casco</label>
                                    <input class="form-control" type="text" id="data_casco_omologazione_conducente"
                                        placeholder="" wire:model="data_casco_omologazione_conducente">
                                </div>
                            </div>
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="data_alcool_test" class="form-label">Alcool test</label>
                                    <select class="form-control" style="width:100%" wire:model="data_alcool_test"
                                        id="data_alcool_test">
                                        <option value="0"></option>
                                        <option value="1">SI</option>
                                        <option value="2">NO</option>
                                    </select>
                                </div>
                                <div class="col-md-4" id="data_alcool_test_select">
                                    <label for="data_alcool_test_esito" class="form-label">Esito alcool test</label>
                                    <select class="form-control" style="width:100%" wire:model="data_alcool_test_esito">
                                        <option value="0"></option>
                                        <option value="1">Esito negativo</option>
                                        <option value="2">Esito positivo</option>
                                    </select>
                                </div>
                            </div>
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="data_drug_test" class="form-label">Drug test</label>
                                    <select class="form-control" style="width:100%" wire:model="data_drug_test"
                                        id="data_drug_test">
                                        <option value="0"></option>
                                        <option value="1">SI</option>
                                        <option value="2">NO</option>
                                    </select>
                                </div>
                                <div class="col-md-4" id="data_drug_test_select">
                                    <label for="data_drug_test_esito" class="form-label">Esito drug test</label>
                                    <select class="form-control" style="width:100%" wire:model="data_drug_test_esito">
                                        <option value="0"></option>
                                        <option value="1">Esito negativo</option>
                                        <option value="2">Esito positivo</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="card collapsed-card">
                        <div class="card-header">
                            <h3 class="card-title">Accertamenti passeggeri</h3>
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse"><i
                                        class="fas fa-minus"></i></button>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="row mt-3">
                                <div class="col-md-3" id="data_passeggero_0_cinture">
                                    <label for="data_cinture_passeggeri_0" class="form-label">Uso cinture di
                                        sicurezza
                                        (anteriore)</label>
                                    <select class="form-control" style="width:100%" wire:model="data_cinture_passeggeri_0">
                                        <option value="0"></option>
                                        <option value="1">SI</option>
                                        <option value="2">NO</option>
                                        <option value="3">Non rilevato</option>
                                    </select>
                                </div>
                                <div class="col-md-3" id="data_passeggero_1_cinture">
                                    <label for="data_cinture_passeggeri_1" class="form-label">Uso cinture di
                                        sicurezza
                                        (posteriore destra)</label>
                                    <select class="form-control" style="width:100%" wire:model="data_cinture_passeggeri_1">
                                        <option value="0"></option>
                                        <option value="1">SI</option>
                                        <option value="2">NO</option>
                                        <option value="3">Non rilevato</option>
                                    </select>
                                </div>
                                <div class="col-md-3" id="data_passeggero_2_cinture">
                                    <label for="data_cinture_passeggeri_2" class="form-label">Uso cinture di
                                        sicurezza
                                        (posteriore centrale)</label>
                                    <select class="form-control" style="width:100%" wire:model="data_cinture_passeggeri_2">
                                        <option value="0"></option>
                                        <option value="1">SI</option>
                                        <option value="2">NO</option>
                                        <option value="3">Non rilevato</option>
                                    </select>
                                </div>
                                <div class="col-md-3" id="data_passeggero_3_cinture">
                                    <label for="data_cinture_passeggeri_3" class="form-label">Uso cinture di
                                        sicurezza
                                        (posteriore sinistra)</label>
                                    <select class="form-control" style="width:100%" wire:model="data_cinture_passeggeri_3">
                                        <option value="0"></option>
                                        <option value="1">SI</option>
                                        <option value="2">NO</option>
                                        <option value="3">Non rilevato</option>
                                    </select>
                                </div>
                            </div>
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="data_casco_passeggero" class="form-label">Uso del casco</label>
                                    <select class="form-control" style="width:100%" wire:model="data_casco_passeggero"
                                        id="data_casco_passeggero">
                                        <option value="0"></option>
                                        <option value="1">SI</option>
                                        <option value="2">NO</option>
                                        <option value="3">Non rilevato</option>
                                    </select>
                                </div>
                                <div class="col-md-4" id="data_casco_passeggero_select">
                                    <label for="data_casco_omologazione_passeggero" class="form-label">Omologazione
                                        casco</label>
                                    <input class="form-control" type="text" id="data_casco_omologazione_passeggero"
                                        placeholder="" wire:model="data_casco_omologazione_passeggero">
                                </div>
                            </div>
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="data_sistema_ritenuta_minori" class="form-label">Sistema ritenuta
                                        minori</label>
                                    <select class="form-control" style="width:100%"
                                        wire:model="data_sistema_ritenuta_minori">
                                        <option value="0"></option>
                                        <option value="1">SI</option>
                                        <option value="2">NO</option>
                                        <option value="3">Non rilevato</option>
                                    </select>
                                </div>
                                <div class="col-md-4">
                                    <label for="data_sistema_ritenuta_minori_omologazione" class="form-label">Omologazione
                                        sistema ritenuta minori</label>
                                    <input class="form-control" type="text" id="data_sistema_ritenuta_minori_omologazione"
                                        placeholder="" wire:model="data_sistema_ritenuta_minori_omologazione">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="card collapsed-card">
                        <div class="card-header">
                            <h3 class="card-title">Provvedimenti adottati</h3>
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse"><i
                                        class="fas fa-minus"></i></button>
                            </div>
                        </div>
                        <div class="card-body">


                            @for ($count = 1; $count <= 3; $count++)
                                <div class="row mt-3">
                                    <div class="col-md-4">
                                        <label for="verbale_violazione_numero_{{ $count }}" class="form-label">Verbale di
                                            violazione Num.</label>
                                        <textarea class="form-control" type="text" id="verbale_violazione_numero_{{ $count }}"
                                            rows="5" wire:model="data_verbale_violazione_numero_{{ $count }}"></textarea>
                                    </div>
                                    <div class="col-md-4">
                                        <label for="articolo_violato_{{ $count }}" class="form-label">Art.
                                            violato</label>
                                        <input class="form-control" type="text" id="articolo_violato_{{ $count }}"
                                            placeholder="" wire:model="data_articolo_violato_{{ $count }}">
                                    </div>
                                    <div class="col-md-4">
                                        <label for="cds_{{ $count }}" class="form-label">C.D.S.</label>
                                        <input class="form-control" type="text" id="cds_{{ $count }}" placeholder=""
                                            wire:model="data_cds_{{ $count }}">
                                    </div>
                                </div>
                                <div class="row mt-3">
                                    <div class="col-md-4">
                                        <hr size="1">
                                    </div>
                                </div>
                            @endfor

                        </div>
                    </div>

                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal"
                        wire:click="closeAndResetModal()">Annulla</button>
                    @if (!$this->validated)
                        <button type="button" class="btn btn-primary"
                            wire:click.prevent="anagraficaDataParteComuneSave()">Salva</button>
                    @endif
                </div>
            </div>
        </div>
    </div>

    <div wire:ignore class="modal fade" id="pedoneModal" tabindex="-1" aria-labelledby="pedoneModalLabel" aria-hidden="true"
        data-keyboard="false">
        <div class="modal-dialog modal-xl modal-fullscreen-xl">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="pedoneModalLabel">Inserimento/modifica dati pedone</h5>

                </div>
                <div class="modal-body">

                    <div class="card  collapsed-card">
                        <div class="card-header">
                            <h3 class="card-title">Pedone</h3>
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse"><i
                                        class="fas fa-minus"></i></button>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <div class="column">
                                        <label for="data_chilometri_percorsi" class="form-label">Pedone</label>
                                        <br><b><span class="pedone"></span></b>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <label for="infortunato" class="form-label">Pedone infortunato</label>
                                    <select class="form-control" style="width:100%" wire:model="infortunato"
                                        id="infortunato">
                                        <option value=""></option>
                                        <option value="0" class="success">Incolume</option>
                                        <option value="1" class="success">Ferito</option>
                                        <option value="2" class="success">Deceduto entro 24 ore</option>
                                        <option value="3" class="success">Deceduto entro 30 gg.</option>
                                    </select>
                                </div>

                                <div class="col-md-4" id="infortunato_select">
                                    <label for="infortunato_ospedale" class="form-label">Ospedale</label>
                                    <input class="form-control" type="text" id="infortunato_ospedale" placeholder=""
                                        wire:model="infortunato_ospedale">
                                </div>
                                <div class="col-md-4">
                                    <label for="generalizzato" class="form-label">Generalizzato</label>
                                    <select class="form-control" style="width:100%" wire:model="generalizzato"
                                        id="generalizzato">
                                        <option value=""></option>
                                        <option value="1" class="success">Sul luogo</option>
                                        <option value="2" class="success">In ospedale</option>
                                        <option value="3" class="success">Altrove</option>
                                    </select>
                                </div>
                                <div class="col-md-4" id="generalizzato_select">
                                    <label for="generalizzato_altrove" class="form-label">Altrove</label>
                                    <input class="form-control" type="text" id="generalizzato_altrove" placeholder=""
                                        wire:model="generalizzato_altrove">
                                </div>
                            </div>

                        </div>
                    </div>

                    <div class="card collapsed-card">
                        <div class="card-header">
                            <h3 class="card-title">Posizione del pedone</h3>
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse"><i
                                        class="fas fa-minus"></i></button>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="pedone_posizione" class="form-label">Posizione del pedone</label>
                                    <select class="form-control" style="width:100%" wire:model="pedone_posizione">
                                        <option value=""></option>
                                        <option value="1" class="success">Presente e in posizione</option>
                                        <option value="2" class="success">Già soccorso e trasportato presso
                                            ospedale</option>
                                        </ul>
                                    </select>
                                </div>
                                <div class="col-md-4">
                                    <label for="pedone_referto" class="form-label">Referto (Cod. TRIAGE)</label>
                                    <textarea class="form-control" type="text" id="pedone_referto" rows="5"
                                        wire:model="pedone_referto"></textarea>
                                </div>
                                <div class="col-md-4">
                                    <label for="pedone_prognosi" class="form-label">Prognosi</label>
                                    <input class="form-control" type="text" id="pedone_prognosi" placeholder=""
                                        wire:model="pedone_prognosi">
                                </div>
                            </div>


                        </div>

                        <div class="card-body">
                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <div class="custom-control custom-switch custom-switch-md">
                                        <input type="checkbox" class="custom-control-input" id="pedone_pioggia"
                                            wire:model="pedone_pioggia">
                                        <label class="custom-control-label" for="pedone_pioggia">Caso di
                                            pioggia</label>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <label for="pedone_ombrello" class="form-label">Ombrello</label>
                                    <select class="form-control" style="width:100%" wire:model="pedone_ombrello">
                                        <option value=""></option>
                                        <option value="1">Si</option>
                                        <option value="2">No</option>
                                    </select>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="custom-control custom-switch custom-switch-md">
                                        <input type="checkbox" class="custom-control-input" id="pedone_notte"
                                            wire:model="pedone_notte">
                                        <label class="custom-control-label" for="pedone_notte">Caso di notte</label>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <label for="pedone_abiti_scuri" class="form-label">Abiti scuri</label>
                                    <select class="form-control" style="width:100%" wire:model="pedone_abiti_scuri">
                                        <option value=""></option>
                                        <option value="1">Si</option>
                                        <option value="2">No</option>
                                    </select>
                                </div>
                            </div>

                        </div>
                    </div>

                    <div class="card collapsed-card">
                        <div class="card-header">
                            <h3 class="card-title">Provvedimenti adottati</h3>
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse"><i
                                        class="fas fa-minus"></i></button>
                            </div>
                        </div>
                        <div class="card-body">

                            <div class="row mt-3">
                                <div class="col-md-4">
                                    <label for="verbale_violazione_numero" class="form-label">Verbale di violazione
                                        Num.</label>
                                    <textarea class="form-control" type="text" id="verbale_violazione_numero" rows="5"
                                        wire:model="verbale_violazione_numero"></textarea>
                                </div>
                                <div class="col-md-4">
                                    <label for="articolo_violato" class="form-label">Art. violato</label>
                                    <input class="form-control" type="text" id="articolo_violato" placeholder=""
                                        wire:model="articolo_violato">
                                </div>
                                <div class="col-md-4">
                                    <label for="cds" class="form-label">C.D.S.</label>
                                    <input class="form-control" type="text" id="cds" placeholder="" wire:model="cds">
                                </div>
                            </div>


                        </div>
                    </div>

                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
                    @if (!$this->validated)
                        <button type="button" class="btn btn-primary" wire:click.prevent="pedoneSave()">Salva</button>
                    @endif
                </div>
            </div>
        </div>
    </div>

    <div wire:ignore class="modal fade " id="allegatiModal" tabindex="-1" aria-labelledby="allegatiModalLabel"
        aria-hidden="true" data-keyboard="false">
        <div class="modal-dialog modal-xl">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="allegatiModalLabel">Inserimento/modifica allegati</h5>
                </div>
                <div class="modal-body">
                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="allegatoName" class="form-label">Nome</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control" type="text" id="allegatoName" placeholder="Nome"
                                wire:model="allegatoName">
                        </div>
                    </div>
                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="allegatoGallery" class="form-label">Tipologia</label>
                        </div>
                        <div class="col-md-8">
                            <select class="form-control" style="width:100%" wire:model="allegatoGallery">
                                <option value="">
                                    @foreach ($allegatiType as $t)
                                        <option value="{{ $t->id }}">{{ $t->name }}
                                    @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="" class="form-label">Files</label>
                        </div>
                        <div class="col-md-8">
                            <input type="file" wire:model="allegati" multiple>
                            <div id="attachments">
                                @foreach ($allegatiFiles as $a)
                                    {{ $a }}<br>
                                @endforeach
                            </div>
                        </div>
                    </div>

                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="" class="form-label">Visibile in stampa</label>
                        </div>
                        <div class="col-md-8">
                            <div class="custom-control custom-switch custom-switch-md">
                                <input type="checkbox" class="custom-control-input" id="allegatoVisible"
                                    wire:model="allegatoVisible">
                                <label class="custom-control-label" for="allegatoVisible">&nbsp;</label>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
                    @if (!$this->validated)
                        <button type="button" class="btn btn-primary" wire:click.prevent="saveAllegato()">Salva</button>
                    @endif
                </div>
            </div>

        </div>
    </div>

    <div wire:ignore class="modal fade " id="accertatoriModal" tabindex="-1" aria-labelledby="accertatoriModalLabel"
        aria-hidden="true" data-keyboard="false" style="z-index: 9999">
        <div class="modal-dialog modal-xl">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="accertatoriModalLabel">Inserimento/modifica accertatore</h5>
                </div>
                <div class="modal-body">
                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="accertatore_nome" class="form-label">Nome</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control @error('accertatore_nome') is-invalid @enderror" type="text"
                                id="accertatore_nome" wire:model="accertatore_nome">
                        </div>
                    </div>
                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="accertatore_cognome" class="form-label">Cognome</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control @error('accertatore_cognome') is-invalid @enderror" type="text"
                                id="accertatore_cognome" wire:model="accertatore_cognome">
                        </div>
                    </div>
                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="accertatore_username" class="form-label">Username</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control @error('accertatore_username') is-invalid @enderror" type="text"
                                id="accertatore_username" wire:model="accertatore_username">
                        </div>
                    </div>
                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="accertatore_email" class="form-label">Email</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control @error('accertatore_email') is-invalid @enderror" type="text"
                                id="accertatore_email" wire:model="accertatore_email">
                        </div>
                    </div>
                    <div class="row mt-3">
                        <div class="col-md-4">
                            <label for="accertatore_password" class="form-label">Password</label>
                        </div>
                        <div class="col-md-8">
                            <input class="form-control @error('accertatore_password') is-invalid @enderror" type="text"
                                id="accertatore_password" wire:model="accertatore_password">
                        </div>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
                    @if (!$this->validated)
                        <button type="button" class="btn btn-primary" wire:click.prevent="accertatoreSave()">Salva</button>
                    @endif
                </div>
            </div>
        </div>
    </div>

@endif

</div>



@push('css')
    <link rel="stylesheet" href="/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
    <link rel="stylesheet" href="/plugins/select2/css/select2.min.css">
    <link rel="stylesheet" href="/dist/css/app.css">

    <style>
        .modal-fullscreen-xl {
            max-width: 100% !important;
        }

        div.modal-body>div.card>.card-header {
            background-color: gray !important;
            color: white !important;
        }

        .select2 {
            width: 100% !important;
            border-radius: .25rem !important;
        }

        .select2-selection:before,
        .select2-selection--multiple:before {
            content: "";
            position: absolute;
            right: 7px;
            top: 42%;
            border-top: 5px solid #888;
            border-left: 4px solid transparent;
            border-right: 4px solid transparent;
        }

        .select2-search,
        .select2-selection,
        .select2-search input,
        .select2-results {
            background: #fff !important;
            color: #000000 !important;
        }

        .select2-selection__rendered,
        .select2-selection__choice {
            color: black !important;
        }

        select,
        select option,
        .select2 {
            background: #fff !important;
            color: #000000 !important;
        }

        .card-primary:not(.card-outline)>.card-header {
            background-color: #023047 !important;
            color: #fff !important;
        }

        .card-primary.card-outline {
            border-top: none !important;
        }

        .select2-container--bootstrap4 .select2-selection {}

        .select2-selection__arrow {
            display: none !important;
        }

        .select2-selection:before,
        .select2-selection--multiple:before {
            content: "";
            color: black;
            position: absolute;
            right: 7px;
            top: 42%;
            border-top: 5px solid black;
            border-left: 4px solid transparent;
            border-right: 4px solid transparent;
        }

        .custom-switch.custom-switch-sm .custom-control-label {
            padding-left: 1rem;
            padding-bottom: 1rem;
        }

        .custom-switch.custom-switch-sm .custom-control-label::before {
            height: 1rem;
            width: calc(1rem + 0.75rem);
            border-radius: 2rem;
        }

        .custom-switch.custom-switch-sm .custom-control-label::after {
            width: calc(1rem - 4px);
            height: calc(1rem - 4px);
            border-radius: calc(1rem - (1rem / 2));
        }

        .custom-switch.custom-switch-sm .custom-control-input:checked~.custom-control-label::after {
            transform: translateX(calc(1rem - 0.25rem));
        }

        /* for md */

        .custom-switch.custom-switch-md .custom-control-label {
            padding-left: 2rem;
            padding-bottom: 1.5rem;
        }

        .custom-switch.custom-switch-md .custom-control-label::before {
            height: 1.5rem;
            width: calc(2rem + 0.75rem);
            border-radius: 3rem;
        }

        .custom-switch.custom-switch-md .custom-control-label::after {
            width: calc(1.5rem - 4px);
            height: calc(1.5rem - 4px);
            border-radius: calc(2rem - (1.5rem / 2));
        }

        .custom-switch.custom-switch-md .custom-control-input:checked~.custom-control-label::after {
            transform: translateX(calc(1.5rem - 0.25rem));
        }

        /* for lg */

        .custom-switch.custom-switch-lg .custom-control-label {
            padding-left: 3rem;
            padding-bottom: 2rem;
        }

        .custom-switch.custom-switch-lg .custom-control-label::before {
            height: 2rem;
            width: calc(3rem + 0.75rem);
            border-radius: 4rem;
        }

        .custom-switch.custom-switch-lg .custom-control-label::after {
            width: calc(2rem - 4px);
            height: calc(2rem - 4px);
            border-radius: calc(3rem - (2rem / 2));
        }

        .custom-switch.custom-switch-lg .custom-control-input:checked~.custom-control-label::after {
            transform: translateX(calc(2rem - 0.25rem));
        }

        /* for xl */

        .custom-switch.custom-switch-xl .custom-control-label {
            padding-left: 4rem;
            padding-bottom: 2.5rem;
        }

        .custom-switch.custom-switch-xl .custom-control-label::before {
            height: 2.5rem;
            width: calc(4rem + 0.75rem);
            border-radius: 5rem;
        }

        .custom-switch.custom-switch-xl .custom-control-label::after {
            width: calc(2.5rem - 4px);
            height: calc(2.5rem - 4px);
            border-radius: calc(4rem - (2.5rem / 2));
        }

        .custom-switch.custom-switch-xl .custom-control-input:checked~.custom-control-label::after {
            transform: translateX(calc(2.5rem - 0.25rem));
        }

        .custom-control-input:checked~.custom-control-label::before {
            color: #fff;
            border-color: #023047 !important;
            background-color: #023047 !important;
            box-shadow: none;
        }
    </style>
@endpush

@push('scripts')
    <script src="/plugins/select2/js/select2.min.js"></script>
    <script src="/plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
@endpush

@push('scripts')
    <script>
        var maxDamageColumns = 4;
        var displayedDamageColumns = 1;

        function hasColumnValues(columnNumber) {
            const selectors = [
                `data_tipo_danno_${columnNumber}`,
                `data_entita_danno_${columnNumber}`,
                `data_effetto_danno_${columnNumber}`,
                `data_parte_macchina_${columnNumber}`
            ];

            return selectors.some(selector => {
                const element = document.querySelector(`[wire\\:model="${selector}"]`);
                return element && element.value;
            });
        }

        function showNextDamageColumn() {
            if (displayedDamageColumns < maxDamageColumns) {
                displayedDamageColumns++;
                var nextColumn = document.getElementById('damage-column-' + displayedDamageColumns);
                if (nextColumn) {
                    nextColumn.style.display = 'block';
                }
                if (displayedDamageColumns >= maxDamageColumns) {
                    document.getElementById('add-damage-btn').style.display = 'none';
                }
                window.Livewire.rescan();
            }
        }

        // Function to initialize column visibility based on data
        function initializeDamageColumns() {
            // Start from column 2 since column 1 is always visible
            for (let i = 2; i <= maxDamageColumns; i++) {
                if (hasColumnValues(i)) {
                    var column = document.getElementById('damage-column-' + i);
                    if (column) {
                        column.style.display = 'block';
                        displayedDamageColumns = i;
                    }
                }
            }

            if (displayedDamageColumns >= maxDamageColumns) {
                document.getElementById('add-damage-btn').style.display = 'none';
            }
        }

        document.addEventListener('DOMContentLoaded', initializeDamageColumns);

        document.addEventListener('livewire:load', function () {
            Livewire.hook('message.processed', () => {
                initializeDamageColumns();
            });
        });

        Livewire.on('load-check', () => {

            $("input[data-bootstrap-switch]").each(function () {
                $(this).bootstrapSwitch({
                    onSwitchChange: function (e, state) {
                        @this.set($(this).prop('id'), state);
                    }
                });
            });

        });

        Livewire.on('load-select', () => {
            const stradario = [
                "localita_due", "intersezione_con", "segnaletica_verticale_1_via",
                "segnaletica_verticale_2_via", "segnaletica_orizzontale_1_via",
                "segnaletica_orizzontale_2_via", "segnaletica_verticale_3_via",
                "segnaletica_verticale_4_via", "segnaletica_orizzontale_3_via",
                "segnaletica_orizzontale_4_via", "vei_carta_circolazione_rilasciata_da_di"
            ];

            stradario.forEach(stradarioSelect);

            function stradarioSelect(value) {
                const ajaxUrl = (value === "vei_carta_circolazione_rilasciata_da_di") ?
                    '/localita' :
                    '/stradario_api';

                $('.' + value).select2({
                    theme: 'bootstrap4',
                    ajax: {
                        url: ajaxUrl,
                        dataType: 'json'
                    }
                });

                $('.' + value).on('change', function (e) {
                    var data = $('.' + value).select2("val");
                    @this.set(value, data);
                });
            }

            $('.anagraficaClass').select2({
                theme: 'bootstrap4',
                ajax: {
                    url: '/anagrafica',
                    dataType: 'json'
                }
            });

            $('.anagraficaClass').on('change', function (e) {
                var data = $(e.currentTarget).val();
                var progressive = $(e.currentTarget).data("progressive");
                @this.updateAnagraficaParteCoinvolta(data, progressive);
            });

            const anagrafiche = ["richiestaAnagrafica", "data_testi_oculari_0", "data_testi_oculari_1",
                "data_testi_oculari_2", "data_testi_oculari_3"
            ];
            anagrafiche.forEach(anagraficheSelect);

            function anagraficheSelect(value) {
                $('.' + value).select2({
                    theme: 'bootstrap4',
                    ajax: {
                        url: '/anagrafica',
                        dataType: 'json'
                    }
                });

                $('.' + value).on('change', function (e) {
                    var data = $('.' + value).select2("val");
                    @this.set(value, data);
                });

            }

            const accertatori = ["accertatore_1", "accertatore_2", "accertatore_3", "accertatore_4",
                "accertatore_5"
            ];
            accertatori.forEach(accertatoreSelect);

            function accertatoreSelect(value) {
                $('.' + value).select2({
                    theme: 'bootstrap4',
                    ajax: {
                        url: '/accertatori',
                        dataType: 'json'
                    }
                });
                $('.' + value).on('change', function (e) {
                    var data = $('.' + value).select2("val");
                    @this.set(value, data);
                });
            }

            $('.veicoliClass').select2({
                theme: 'bootstrap4',
                ajax: {
                    url: '/veicoli',
                    dataType: 'json'
                }
            });

            $('.veicoliClass').on('change', function (e) {
                var data = $(e.currentTarget).val();
                var progressive = $(e.currentTarget).data("progressive");
                @this.updateVeicoloParteCoinvolta(data, progressive);
            });

            $('.localita_uno').select2({
                theme: 'bootstrap4',
                ajax: {
                    url: '/localita',
                    dataType: 'json'
                }
            });
            $('.localita_uno').on('change', function (e) {
                var data = $('.localita_uno').select2("val");
                @this.set('localita_uno', data);
            });

            const multiple = ["tipo_urto", "tipo_segnalazione", "segnalazione_pervenuta_da", "materiale_recuperato",
                "ausilio_altri_enti", "condizioni_luce", "tipo_strada", "segnaletica_verticale_1",
                "segnaletica_verticale_2", "segnaletica_verticale_3", "segnaletica_verticale_4",
                "segnaletica_orizzontale_1", "segnaletica_orizzontale_2", "segnaletica_orizzontale_3",
                "segnaletica_orizzontale_4"
            ];
            multiple.forEach(multipleSelect);

            function multipleSelect(value) {
                $('.' + value).select2({
                    theme: 'bootstrap4'
                });
                $('.' + value).on('change', function (e) {
                    var data = $('.' + value).select2("val");
                    @this.set(value, data);
                });
            }
        });
        Livewire.on('load-anagrafica-modal', () => {
            const modalsAnag = [
                "anag_birth_town_id",
                "anag_residenza_town_id",
                "anag_documento_rilasciato_da_di_foreign_localita",
                "anag_sede_legale_town_id",
                "anag_foreign_birth_country",
                "anag_foreign_residence_country",
                "anag_pg_foreign_residence_country"
            ];

            const countryFields = [
                "anag_foreign_birth_country",
                "anag_foreign_residence_country"
            ];

            function modalsAnagSelect(value) {
                $('.' + value).select2({
                    dropdownParent: $("#anagraficaParte .modal-content"),
                    theme: 'bootstrap4',
                    ajax: {
                        url: '/localita',
                        dataType: 'json'
                    },
                    width: '100%'
                }).on('change', function (e) {
                    var data = $('.' + value).select2("val");
                    @this.set(value, data);
                });

                const currentValue = $('.' + value).val();
                const currentText = $('.' + value).find('option:selected').text();
                if (currentValue) {
                    let option = new Option(currentText, currentValue, true, true);
                    $('.' + value).append(option).trigger('change');
                }
            }

            function initializeCountrySelects(value) {
                $('.' + value).select2({
                    dropdownParent: $("#anagraficaParte .modal-content"),
                    theme: 'bootstrap4',
                    ajax: {
                        url: '/countries',
                        dataType: 'json'
                    },
                    width: '100%'
                }).on('change', function (e) {
                    var data = $('.' + value).select2("val");
                    @this.set(value, data);
                });

                const currentValue = $('.' + value).val();
                const currentText = $('.' + value).find('option:selected').text();
                if (currentValue) {
                    let option = new Option(currentText, currentValue, true, true);
                    $('.' + value).append(option).trigger('change');
                }
            }

            function initializeModalState() {
                const currentType = $('input[name="anag_type"]:checked').val();
                if (currentType == 0 || !currentType) {
                    $("#boxPersonaFisica").show();
                    $("#boxPersonaGiuridica").hide();

                    const isStraniera = $('select[wire\\:model="anag_nazionalita"]').val() === "1";
                    $("#foreignBirthCountry")[isStraniera ? 'show' : 'hide']();
                    $("#foreignBirthCity")[isStraniera ? 'show' : 'hide']();
                    $("#foreignResidenceCountry")[isStraniera ? 'show' : 'hide']();
                    $("#foreignResidenceCity")[isStraniera ? 'show' : 'hide']();
                    if (isStraniera) {
                        $("#pippo").hide();
                        $(".anag_residenza_town_id").closest('.row').hide();
                    }
                } else {
                    $("#boxPersonaFisica").hide();
                    $("#boxPersonaGiuridica").show();

                    const isPGStraniera = $('select[wire\\:model="nazionalita"]').val() === "1";
                    $("#foreignPGResidenceCountry")[isPGStraniera ? 'show' : 'hide']();
                    $("#foreignPGResidenceCity")[isPGStraniera ? 'show' : 'hide']();

                    if (isPGStraniera) {
                        $(".anag_sede_legale_town_id").closest('.row').hide();
                        $(".anag_sede_legale_cap").closest('.row').hide();
                        $(".anag_sede_legale_prov_id").closest('.row').hide();
                    } else {
                        $(".anag_sede_legale_town_id").closest('.row').show();
                        $(".anag_sede_legale_cap").closest('.row').show();
                        $(".anag_sede_legale_prov_id").closest('.row').show();
                    }
                }

                setTimeout(() => {
                    modalsAnag.forEach(modalsAnagSelect);
                }, 100);

                setTimeout(() => {
                    countryFields.forEach(initializeCountrySelects);
                }, 100);
            }

            $('select[wire\\:model="anag_nazionalita"]').change(function () {
                const isStraniera = $(this).val() === "1";
                $("#foreignBirthCountry")[isStraniera ? 'show' : 'hide']();
                $("#foreignBirthCity")[isStraniera ? 'show' : 'hide']();
                $("#foreignResidenceCountry")[isStraniera ? 'show' : 'hide']();
                $("#foreignResidenceCity")[isStraniera ? 'show' : 'hide']();

                if (isStraniera) {
                    $("#pippo").hide();
                    $(".anag_residenza_town_id").closest('.row').hide();
                    $(".anag_documento_rilasciato_da_di_foreign_localita").closest('.row').hide();
                } else {
                    $("#pippo").show();
                    $(".anag_residenza_town_id").closest('.row').show();
                    @this.set('anag_foreign_birth_country', '');
                    @this.set('anag_foreign_birth_city', '');
                    @this.set('anag_foreign_residence_country', '');
                    @this.set('anag_foreign_residence_city', '');
                }
            });

            initializeModalState();

            $('input[name="anag_type"]').change(function () {
                var x = $('input[name="anag_type"]:checked').val();
                if (x == 0) {
                    $("#boxPersonaFisica").show();
                    $("#boxPersonaGiuridica").hide();
                    @this.changeAnagType(0);
                } else {
                    $("#boxPersonaFisica").hide();
                    $("#boxPersonaGiuridica").show();
                    setTimeout(() => {
                        modalsAnag.forEach(modalsAnagSelect);
                    }, 100);
                    @this.changeAnagType(1);
                }
            });

            Livewire.on('change-visualization', (type) => {
                $('input:radio[name="anag_type"]').filter('[value="' + type + '"]').prop('checked', true);
                if (type == 0) {
                    $("#boxPersonaFisica").show();
                    $("#boxPersonaGiuridica").hide();
                } else {
                    $("#boxPersonaFisica").hide();
                    $("#boxPersonaGiuridica").show();
                    setTimeout(() => {
                        modalsAnag.forEach(modalsAnagSelect);
                    }, 100);
                }
            });

            $('select[wire\\:model="nazionalita"]').change(function () {
                const isPGStraniera = $(this).val() === "1";
                $("#foreignPGResidenceCountry")[isPGStraniera ? 'show' : 'hide']();
                $("#foreignPGResidenceCity")[isPGStraniera ? 'show' : 'hide']();

                if (isPGStraniera) {
                    $(".anag_sede_legale_town_id").closest('.row').hide();
                    $(".anag_sede_legale_cap").closest('.row').hide();
                    $(".anag_sede_legale_prov_id").closest('.row').hide();
                } else {
                    $(".anag_sede_legale_town_id").closest('.row').show();
                    $(".anag_sede_legale_cap").closest('.row').show();
                    $(".anag_sede_legale_prov_id").closest('.row').show();
                    @this.set('anag_foreign_residence_country', '');
                    @this.set('anag_foreign_residence_city', '');
                }
            });

            $('#anagraficaParte').on('show.bs.modal', function () {
                initializeModalState();
            });

            $('#anagraficaParte').on('hidden.bs.modal', function () {
                modalsAnag.forEach(value => {
                    if ($('.' + value).data('select2')) {
                        $('.' + value).select2('destroy');
                    }
                });
            });
        });

        Livewire.on('load-select-modal', () => {
            // Destroy existing Select2 instances
            $('#veicoloDataParte .select2').each(function () {
                if ($(this).data('select2')) {
                    $(this).select2('destroy');
                }
            });

            const modals = [
                "data_proprietari",
                "data_coproprietari",
                "data_conducenti",
                "data_passeggero_0",
                "data_passeggero_1",
                "data_passeggero_2",
                "data_passeggero_3",
                "data_infortunato_extra_0",
                "data_infortunato_extra_1",
                "data_infortunato_extra_2",
                "data_infortunato_extra_3"
            ];

            function modalsSelect(value) {
                $('.' + value).select2({
                    dropdownParent: $("#veicoloDataParte"),
                    theme: 'bootstrap4',
                    ajax: {
                        url: '/anagrafica',
                        dataType: 'json'
                    },
                    width: '100%'
                });

                if (["data_proprietari", "data_coproprietari", "data_conducenti", "data_passeggero_0",
                    "data_passeggero_1", "data_passeggero_2", "data_passeggero_3"
                ].includes(value)) {

                    $('#' + value + "_cinture").hide();
                    $('.' + value + "_edit").hide();
                    $('.' + value + "_remove").hide();
                    $('.' + value + "_add").hide();

                    const currentVal = $('.' + value).val();
                    if (currentVal > 0) {
                        $('.' + value + "_edit").show();
                        $('.' + value + "_remove").show();
                        $('.' + value + "_add").hide();
                        $('#' + value + "_cinture").show();
                    } else {
                        $('.' + value + "_add").show();
                    }
                }

                $('.' + value).on('change', function (e) {
                    const data = $(this).val();
                    @this.set(value, data);

                    if (["data_proprietari", "data_coproprietari", "data_conducenti", "data_passeggero_0",
                        "data_passeggero_1", "data_passeggero_2", "data_passeggero_3"
                    ].includes(value)) {

                        $('#' + value + "_cinture").hide();
                        $('.' + value + "_edit").hide();
                        $('.' + value + "_remove").hide();
                        $('.' + value + "_add").hide();

                        if (data > 0) {
                            $('.' + value + "_edit").show();
                            $('.' + value + "_remove").show();
                            $('.' + value + "_add").hide();
                            $('#' + value + "_cinture").show();
                        } else {
                            $('.' + value + "_add").show();
                        }
                    }
                });

                const currentValue = $('.' + value).val();
                const currentText = $('.' + value).find('option:selected').text();
                if (currentValue) {
                    const option = new Option(currentText, currentValue, true, true);
                    $('.' + value).append(option).trigger('change');
                }
            }

            modals.forEach(modalsSelect);

            $('#veicoloDataParte').on('hidden.bs.modal', function () {
                modals.forEach(value => {
                    if ($('.' + value).data('select2')) {
                        $('.' + value).select2('destroy');
                    }
                });
            });

            $(document).ready(function () {
                $('.data_polizze').select2({
                    dropdownParent: $("#veicoloDataParte"),
                    theme: 'bootstrap4',
                    ajax: {
                        url: '/polizze',
                        dataType: 'json'
                    }
                });
            });

            $('.data_polizze').on('change', function (e) {
                var data = $(this).val();
                @this.set('data_polizze', data);
            });

            const selectInf = ["data_infortunato", "data_infortunato_0", "data_infortunato_1", "data_infortunato_2",
                "data_infortunato_3", "data_alcool_test", "data_drug_test"
            ];
            selectInf.forEach(selectInfSelect);

            function selectInfSelect(value) {
                var x = $("#" + value).val();
                if (x == "1")
                    $("#" + value + "_select").show();
                else
                    $("#" + value + "_select").hide();
                $("#" + value).change(function () {
                    var val = this.value;
                    if (val == "1")
                        $("#" + value + "_select").show();
                    else
                        $("#" + value + "_select").hide();
                });
            }

            const selectGen = ["data_generalizzato", "generalizzato"];
            selectGen.forEach(selectGenSelect);

            function selectGenSelect(value) {
                var x = $("#" + value).val();
                if (x == "3")
                    $("#" + value + "_select").show();
                else
                    $("#" + value + "_select").hide();
                $("#" + value).change(function () {
                    var val = this.value;
                    if (val == "3")
                        $("#" + value + "_select").show();
                    else
                        $("#" + value + "_select").hide();
                });
            }

            var x = $("#data_casco_conducente").val();
            if (x == "1")
                $("#data_casco_conducente_select").show();
            else
                $("#data_casco_conducente_select").hide();
            $("#data_casco_conducente").change(function () {
                var val = this.value;
                if (val == "1")
                    $("#data_casco_conducente_select").show();
                else
                    $("#data_casco_conducente_select").hide();
            });

            var x = $("#data_casco_passeggero").val();
            if (x == "1")
                $("#data_casco_passeggero_select").show();
            else
                $("#data_casco_passeggero_select").hide();
            $("#data_casco_passeggero").change(function () {
                var val = this.value;
                if (val == "1")
                    $("#data_casco_passeggero_select").show();
                else
                    $("#data_casco_passeggero_select").hide();
            });

            var x = $("#data_destinazione_veicolo").val();
            $("#data_destinazione_veicolo_select_0").hide();
            $("#data_destinazione_veicolo_select_1").hide();
            $("#data_destinazione_veicolo_select_2").hide();
            $("#data_destinazione_veicolo_select_3").hide();
            $("#data_destinazione_veicolo_select_4").hide();
            if (x == "1") {
                $("#data_destinazione_veicolo_select_0").show();
            }
            if (x == "4") {
                $("#data_destinazione_veicolo_select_1").show();
            }
            if (x == "5" || x == "6") {
                $("#data_destinazione_veicolo_select_2").show();
                $("#data_destinazione_veicolo_select_3").show();
                $("#data_destinazione_veicolo_select_4").show();
            }

            $("#data_destinazione_veicolo").change(function () {
                var val = this.value;
                $("#data_destinazione_veicolo_select_0").hide();
                $("#data_destinazione_veicolo_select_1").hide();
                $("#data_destinazione_veicolo_select_2").hide();
                $("#data_destinazione_veicolo_select_3").hide();
                $("#data_destinazione_veicolo_select_4").hide();
                if (val == "1") {
                    $("#data_destinazione_veicolo_select_0").show();
                }
                if (val == "4") {
                    $("#data_destinazione_veicolo_select_1").show();
                }
                if (val == "5" || val == "6") {
                    $("#data_destinazione_veicolo_select_2").show();
                    $("#data_destinazione_veicolo_select_3").show();
                    $("#data_destinazione_veicolo_select_4").show();
                }
            });
        });
        Livewire.on('load-select-pedone', () => {

            var x = $("#generalizzato").val();
            if (x == "3")
                $("#generalizzato_select").show();
            else
                $("#generalizzato_select").hide();
            $("#generalizzato").change(function () {
                var val = this.value;
                if (val == "3")
                    $("#generalizzato_select").show();
                else
                    $("#generalizzato_select").hide();
            });

            var x = $("#infortunato").val();
            if (x == "1")
                $("#infortunato_select").show();
            else
                $("#infortunato_select").hide();
            $("#infortunato").change(function () {
                var val = this.value;
                if (val == "1")
                    $("#infortunato_select").show();
                else
                    $("#infortunato_select").hide();
            });

        });

        Livewire.on('load-pedone', (value) => {
            $(".pedone").html(value);
        });

        Livewire.on('set-default-value', (id, text, element) => {

            $('.' + element).select2("val", $('.' + element + " option:contains('" + text + "')").val());

        });
        Livewire.on('add-default-value', (id, text, element) => {
            var newOption = new Option(text, id, false, false);
            $('.' + element).append(newOption).val(id).trigger('change');

            if (element == "data_conducenti" || element == "data_passeggero_0" || element == "data_passeggero_1" ||
                element == "data_passeggero_2" || element == "data_passeggero_3") {
                $('#' + element + "_cinture").hide();
                $('.' + element + "_edit").hide();
                $('.' + element + "_remove").hide();
                $('.' + element + "_add").hide();
                if (id > 0) {
                    $('.' + element + "_edit").show();
                    $('.' + element + "_remove").show();
                    $('.' + element + "_add").hide();
                    $('#' + element + "_cinture").show();
                } else
                    $('.' + element + "_add").show();

            }

        });

        Livewire.on('close-modal', () => {

            $("#anagraficaParte").modal('hide');
            $("#veicoloParte").modal('hide');
            $("#pedoneModal").modal('hide');
            $("#accertatoriModal").modal('hide');
            $("#allegatiModal").modal('hide');
        });

        Livewire.on('close-modal-parte-comune', () => {
            const selectFields = [
                'data_polizze',
                'data_proprietari',
                'data_conducenti',
                'data_passeggero_0',
                'data_passeggero_1',
                'data_passeggero_2',
                'data_passeggero_3',
                'data_infortunato_extra_0',
                'data_infortunato_extra_1',
                'data_infortunato_extra_2',
                'data_infortunato_extra_3'
            ];

            selectFields.forEach(field => {
                if ($(`.${field}`).length) {
                    $(`.${field}`).val(null).trigger('change');
                    if ($(`.${field}`).data('select2')) {
                        $(`.${field}`).select2('destroy');
                    }
                }
            });

            $("#veicoloDataParte").modal('hide');
        });
        $(document).on('click', '[data-dismiss="modal"]', function (e) {
            const modalId = $(this).closest('.modal').attr('id');
            if (modalId === 'veicoloDataParte') {
                e.preventDefault();
                Livewire.emit('closeAndResetModal');
            }
        });

        Livewire.on('attachments', (allegati) => {
            $("#attachments").html('');
            allegati.split("|").forEach(function (item) {
                $("#attachments").append(item + "<br>");
            });
        });

        Livewire.on('updateAnagrafica', (data, progressive) => {
            @this.updateAnagraficaParteCoinvolta(data, progressive);
        });


        Livewire.on('showLoading', (cls) => {
            $("." + cls).hide();
            $("." + cls + "Text").show();
        });

        Livewire.on('hideLoading', (cls) => {
            $("." + cls).show();
            $("." + cls + "Text").hide();
        });


        $(document).ready(function () {
            $(document).on('click', '.btPatente', function () {
                $(".btPatente").hide();
                $(".btPatenteText").show();
            });
            $(document).on('click', '.btTarga', function () {
                $(".btTarga").hide();
                $(".btTargaText").show();
            });
        });

        Livewire.on('load-polizza-modal', () => {
            $('.valida_dal').on('change', function (e) {
                @this.set('valida_dal', $(this).val());
            });

            $('.valida_al').on('change', function (e) {
                @this.set('valida_al', $(this).val());
            });

            $('.polizza_num').on('input', function (e) {
                @this.set('polizza_num', $(this).val());
            });

            $('.anagrafica_id').select2({
                dropdownParent: $('#polizzaParte'),
                theme: 'bootstrap4',
                ajax: {
                    url: '/anagrafica',
                    dataType: 'json'
                },
                width: '100%'
            }).on('change', function (e) {
                @this.set('anagrafica_id', $(this).val());
            });

            // Initialize Select2 for compagnia_id
            $('.compagnia_id').select2({
                dropdownParent: $('#polizzaParte'),
                theme: 'bootstrap4',
                ajax: {
                    url: '/compagnie',
                    dataType: 'json'
                },
                width: '100%'
            }).on('change', function (e) {
                @this.set('compagnia_id', $(this).val());
            });

            // Initialize Select2 for agenzia
            $('.agenzia').select2({
                dropdownParent: $('#polizzaParte'),
                theme: 'bootstrap4',
                ajax: {
                    url: '/polizze/agenzie',
                    dataType: 'json'
                },
                width: '100%'
            }).on('change', function (e) {
                @this.set('agenzia', $(this).val());
            });

            // Show modal event
            window.addEventListener('show-polizza-modal', event => {
                $('#polizzaParte').modal('show');
            });

            // Hide modal event
            window.addEventListener('hide-polizza-modal', event => {
                $('#polizzaParte').modal('hide');

            });
            Livewire.on('polizza-saved', (polizzaId, polizzaText) => {
                let $select = $('.data_polizze');
                $select.append(new Option(polizzaText, polizzaId, true, true)).trigger('change');
            });
        });

        Livewire.on('updatePolizzaSelects', data => {
            // Update anagrafica select
            if (data.anagrafica) {
                let option = new Option(data.anagrafica.text, data.anagrafica.id, true, true);
                $('.anagrafica_id').append(option).trigger('change');
            }

            // Update compagnia select
            if (data.compagnia) {
                let option = new Option(data.compagnia.text, data.compagnia.id, true, true);
                $('.compagnia_id').append(option).trigger('change');
            }
        });

    </script>
@endpush
