<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">
                            @if(!$this->validated)
                                <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>
                            @endif
                        </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-7">
                                        <select class="form-control anagraficaClass"
                                                data-progressive="{{ $p->progressive }}"
                                                style="width:100%"
                                                @if($this->validated) disabled="disabled" @endif>
                                            <option value="{{ $p->anagrafica }}">
                                                {{ $this->getAnagrafica($p->anagrafica) }}
                                            </option>
                                        </select>
                                    </div>
                                    <div class="col-sm-5">
                                        @if (!$this->validated)
                                            @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-success"><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
                                        @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-lg-7 col-md-5">
                                            <select class="form-control veicoliClass"
                                                data-progressive="{{ $p->progressive }}"
                                                style="width:100%"
                                                @if($this->validated) disabled="disabled" @endif>
                                                <option value="{{ $p->veicolo }}">
                                                    {{ $this->getVeicolo($p->veicolo) }}
                                            </select>
                                        </div>
                                        <div class="col-lg-5 col-md-7">
                                            @if (!$this->validated)
                                                @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-success"><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
                                            @endif
                                        </div>
                                    </div>
                                @endif
                            </div>
                        </div>
                        <div class="row">
                            @if (!$this->validated)
                                <div class="col-sm-6 pl-3">
                                    <button class="btn btn-success"
                                        wire:click.prevent="removeParteCoinvolta({{ $p->progressive }})">Elimina</button>
                                </div>
                            @endif
                        </div>


                    </div>

                    <div class="row">
                        <div class="col-sm-12">
                            <hr size="1">
                        </div>
                    </div>
                @endforeach
                @if (!$this->validated)
                    <button class="btn btn-primary"
                    wire:click.prevent="addParteCoinvolta()">Aggiungi</button>
                @endif
            </div>
        </div>
    </div>
</div>
