@php
    use App\Helpers\DateHelper;
    $rilasciataDaMap = [
        1 => 'Comune',
        2 => 'Motorizzazione',
        4 => 'MCTC',
        5 => 'MIT',
        6 => 'UCO',
        7 => 'Prefettura',
    ];
    $documentTypes = [
        1 => "Carta d'Identità",
        2 => 'Patente',
        3 => 'Passaporto',
        4 => 'Altro'
    ];
@endphp
<style>
    .striped-table {
        width: 100%;
        border-collapse: collapse;
    }

    .striped-table th, .striped-table td {
        border: 1px solid #000;
        padding: 8px;
    }

    .striped-table tr:nth-child(even) {
        background-color: #f2f2f2;
    }

    .striped-table tr:nth-child(odd) {
        background-color: #fff;
    }
</style>
@if ($datiVeicolo?->conducente_uguale_proprietario == 0)
    <table class="table-content striped-table" width="100%">
        <tr>
            <td width="25%" style="text-align: center; font-size: 20px;">
                <table class="">
                    <tr class="tr-sub-title" >
                        <td style="border:none !important;" class="bold">PROPRIETARIO</td>
                    </tr>
                </table>
            </td>
            <td width="75%">
                <table class="striped-table">
                    @if ($datiVeicolo?->proprietario?->rag_soc)
                        <tr>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">RAGIONE SOCIALE:</td>
                            <td width="75%" class="veicolo-content-cell" style="padding-bottom: 10px !important;" colspan="3">
                                {{ $datiVeicolo?->proprietario?->rag_soc ?? '' }}
                            </td>
                        </tr>
                        @if ($datiVeicolo?->proprietario?->anag_foreign_residence_country)
                        <tr>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">SEDE LEGALE - PAESE ESTERO:</td>
                            <td width="75%" class="veicolo-content-cell" colspan="3" style="padding-bottom: 10px !important;">
                                {{ $datiVeicolo?->proprietario?->foreign_residence_country_value?->name ?? '' }}
                            </td>
                        </tr>
                        <tr>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">SEDE LEGALE - CITTA ESTERO:</td>
                            <td width="75%" class="veicolo-content-cell" colspan="3" style="padding-bottom: 10px !important;">
                                {{ $datiVeicolo?->proprietario?->anag_foreign_residence_city ?? '' }}
                            </td>
                        </tr>
                    @else
                        <tr>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">SEDE LEGALE - COMUNE:</td>
                            <td width="75%" class="veicolo-content-cell" colspan="3" style="padding-bottom: 10px !important;">
                                {{ $datiVeicolo?->proprietario?->sede_legale_town_id_value?->title ?? '' }}
                            </td>
                        </tr>
                        <tr>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">SEDE LEGALE - PROVINCIA:</td>
                            <td width="75%" class="veicolo-content-cell" colspan="3" style="padding-bottom: 10px !important;">
                                {{ $datiVeicolo?->proprietario?->sede_legale_prov_id_value?->title ?? '' }}
                            </td>
                        </tr>
                    @endif
                        <tr>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">SEDE LEGALE - INDIRIZZO:</td>
                            <td width="75%" class="veicolo-content-cell" colspan="3" style="padding-bottom: 10px !important;">
                                {{ $datiVeicolo?->proprietario?->sede_legale_address ?? '' }}
                            </td>
                        </tr>
                        <tr>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">SEDE LEGALE - CAP:</td>
                            <td width="75%" class="veicolo-content-cell" colspan="3" style="padding-bottom: 10px !important;">
                                {{ $datiVeicolo?->proprietario?->sede_legale_cap ?? '' }}
                            </td>
                        </tr>
                        <tr>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">TELEFONO:</td>
                            <td width="25%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                {{ $datiVeicolo?->proprietario?->phone ?? '' }}
                            </td>
                        </tr>
                        <tr>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">PARTITA IVA:</td>
                            <td width="25%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                {{ $datiVeicolo?->proprietario?->vat ?? '' }}
                            </td>
                        </tr>
                    @else
                        <tr>
                            <td width="15%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">COGNOME:</td>
                            <td width="25%" class="veicolo-content-cell">
                                {{ $datiVeicolo?->proprietario?->lastname ?? '' }}
                            </td>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">NOME:</td>
                            <td width="35%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                {{ $datiVeicolo?->proprietario?->firstname ?? '' }}
                            </td>
                        </tr>
                        <tr>
                            <td width="15%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">NATO A:</td>
                            <td width="25%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                @if ($datiVeicolo?->proprietario?->nazionalita == 1)
                                    {{ $datiVeicolo?->proprietario?->birth_town_id_value?->title ?? 'N/A' }}
                                @else
                                    {{ $datiVeicolo?->proprietario?->localita_straniera ?? '' }}
                                @endif
                            </td>
                            <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">NATO IL:</td>
                            <td width="25%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                {{ (!empty($datiVeicolo?->proprietario?->birth_date) && Carbon\Carbon::parse($datiVeicolo->proprietario->birth_date)->year > 0) ? Carbon\Carbon::parse($datiVeicolo->proprietario->birth_date)->format('d/m/Y') : '-' }}
                            </td>
                        </tr>

                        @if (!$datiVeicolo?->proprietario?->residenza_town_id)
                            <tr>
                                <td width="15%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">RESIDENTE A:</td>
                                <td width="25%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                    {{ $datiVeicolo?->proprietario?->residenza_town_id_value?->title ?? '' }}
                                </td>
                                <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">IN</td>
                                <td width="25%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                    {{ $datiVeicolo?->proprietario?->residenza_address ?? '' }}
                                </td>
                            </tr>
                        @endif

                        @if ($datiVeicolo?->proprietario?->documento_tipo || $datiVeicolo?->proprietario?->documento_numero)
                            <tr>
                                <td width="20%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">DOCUMENTO:</td>
                                <td width="20%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                    {{ $documentTypes[$datiVeicolo?->proprietario?->documento_tipo] ?? '' }}
                                </td>
                                <td width="30%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">NUMERO:</td>
                                <td width="25%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                    {{ $datiVeicolo?->proprietario?->documento_numero ?? '' }}
                                </td>
                            </tr>
                        @endif

                        @if (!$datiVeicolo?->proprietario?->foreign_country)
                            @php
                                $rilDa = $rilasciataDaMap[$datiVeicolo?->proprietario?->documento_rilasciato_da] ?? '';
                            @endphp
                            <tr>
                                <td width="15%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">RILASCIATA DA:</td>
                                <td width="25%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">{{ $rilDa }}</td>
                                <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">DI</td>
                                <td width="35%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                    {{ $datiVeicolo?->proprietario?->documento_rilasciato_da_town_id_value?->title ?? '' }}
                                </td>
                            </tr>
                        @else
                            <tr>
                                <td width="15%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">RILASCIATA DA:</td>
                                <td width="25%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                    {{ $datiVeicolo?->proprietario?->docuemento_rilasciato_da_di_altro ?? '' }}
                                </td>
                                <td width="25%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">DI:</td>
                                <td width="35%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                    {{ $datiVeicolo?->proprietario?->documento_rilasciato_da_di_foreign_country_value?->name ?? '' }}{{ $datiVeicolo?->proprietario?->documento_rilasciato_da_di_foreign_localita ?? '' }}
                                </td>
                            </tr>
                        @endif

                        @if ($datiVeicolo?->proprietario?->mobile ?? '')
                            <tr>
                                <td width="15%" class="veicolo-title-cell" style="padding-bottom: 10px !important;">TELEFONO:</td>
                                <td width="25%" class="veicolo-content-cell" style="padding-bottom: 10px !important;">
                                    {{ $datiVeicolo?->proprietario?->mobile ?? '' }}
                                </td>
                            </tr>
                        @endif
                    @endif
                </table>
            </td>
        </tr>
    </table>
@endif
