@include('lpj::surveyor.components.print-out.header')

<div style="border: 1px solid #000;">
    <table
        style="width: 100%; border-top: none; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">

        <tr>
            <td style="text-align: center; margin-top: 5px; ">
                <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                    Tujuan Penilaian
                </h2>
            </td>
        </tr>
    </table>
    <table style="width: 100%;">
        <tr>
            <td style="vertical-align: top;">
                <table>
                    <tr>

                        <td style="width: 25%; padding: 2px;">Tujuan Penilai</td>
                        <td style="width: 1%; padding: 2px;">:</td>
                        <td style="vertical-align: top;  padding: 2px;">
                            {{ $permohonan->tujuanPenilaian->name ?? '' }}</td>
                    </tr>
                    <tr>
                        <td style="width: 25%; padding: 2px; vertical-align: top;">Cabang/Pemohon</td>
                        <td style="width: 1%; vertical-align: top;">:</td>
                        <td style="vertical-align: top;  vertical-align: top;">
                            {{ $permohonan->debiture->branch->name ?? '' }} / {{ $permohonan->user->name ?? '' }}
                        </td>
                    </tr>
                </table>
            </td>

            <td style="vertical-align: top;">
                <table>
                    <tr>
                        <td style="width: 25%; padding: 2px; vertical-align: top;">Tanggal Dibuat</td>
                        <td style="width: 1%; vertical-align: top;">:</td>
                        <td style="vertical-align: top;  vertical-align: top;">
                            {{ formatTanggalIndonesia($permohonan->created_at) }}
                        </td>
                    </tr>
                    <tr>

                        <td style="width: 25%; padding: 2px;">
                            Tanggal Survey</td>
                        <td style="width: 1%; padding: 2px;">:</td>
                        <td style="vertical-align: top;  padding: 2px;">
                            {{ formatTanggalIndonesia($permohonan->penilaian->tanggal_kunjungan) }}</td>
                    </tr>

                </table>
            </td>
        </tr>
    </table>

    <table
        style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">

        <tr>
            <td style="text-align: center; margin-top: 5px; ">
                <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                    Identitas Debitur
                </h2>
            </td>
        </tr>
    </table>
    <table style="width: 100%">
        <tr>
            <td style="width: 20%; padding: 2px; vertical-align: top;">Nama</td>
            <td style="width: 1%; vertical-align: top;">:</td>
            <td style="vertical-align: top; width: 79%;">{{ $permohonan->debiture->name ?? '' }}</td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2px;">Nama Wakil</td>
            <td style="width: 1%;  padding: 2px;">:</td>
            <td style="vertical-align: top;  padding: 2px;">
                @if (isset($forminspeksi['asset']['debitur_perwakilan']) && !empty($forminspeksi['asset']['debitur_perwakilan']))
                    @foreach ($forminspeksi['asset']['debitur_perwakilan'] as $key => $item)
                        {{ $item }}
                    @endforeach
                @endif
            </td>
        </tr>
        <tr>
            <td style="width: 20%; padding: 2px;">Hubungan Calon debitur</td>
            <td style="width: 1%;  padding: 2px;">:</td>
            <td style="vertical-align: top;  padding: 2px;">
                @if (isset($forminspeksi['asset']['debitur_perwakilan']) && !empty($forminspeksi['asset']['debitur_perwakilan']))
                    @foreach ($forminspeksi['asset']['debitur_perwakilan'] as $key => $item)
                        {{ $item }}
                    @endforeach
                @endif
            </td>
        </tr>
    </table>

    <table
        style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">

        <tr>
            <td style="text-align: center; margin-top: 5px; ">
                <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                    Lokasi Jaminan
                </h2>
            </td>
        </tr>
    </table>
    <table style="width: 100%">


        <tr>
            <td width="20%">Nama Jalan</td>
            <td style="width: 1%; vertical-align: top;">:</td>
            <td> {{ $forminspeksi['nama_jalan'] ?? '' }}</td>
        </tr>
        <tr>
            <td width="20%">Perumahan/Gang</td>
            <td style="width: 1%; vertical-align: top;">:</td>
            <td> {{ $forminspeksi['perumahan_gang'] ?? '' }}</td>
        </tr>
        <tr>
            <td width="20%">Blok/Nomor</td>
            <td style="width: 1%; vertical-align: top;">:</td>
            <td> {{ $forminspeksi['blok_nomor'] ?? '' }}</td>
        </tr>
        <tr>
            <td>Kelurahan</td>
            <td style="width: 1%; vertical-align: top;">:</td>
            <td>{{ $alamat['village_code'] ?? '' }}</td>
        </tr>
        <tr>
            <td>Kecamatan</td>
            <td style="width: 1%; vertical-align: top;">:</td>
            <td>{{ $alamat['district_code'] ?? '' }}</td>
        </tr>
        <tr>
            <td>Kotamadya</td>
            <td style="width: 1%; vertical-align: top;">:</td>
            <td> {{ $alamat['city_code'] ?? '' }}</td>
        </tr>
        <tr>
            <td>Propinsi</td>
            <td style="width: 1%; vertical-align: top;">:</td>
            <td>{{ $alamat['province_code'] ?? '' }}</td>
        </tr>

    </table>

    <div class="no-break" style="border-bottom: 1px solid #000;">
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">

            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        STATUS KEPEMILIKAN, HUBUNGAN DAN PENGHUNI
                    </h2>
                </td>
            </tr>
        </table>

        <table>
            @include('lpj::component.print-out-dokument')

            <tr>
                @php
                    // Ambil nilai sesuai dan tidak sesuai
                    $hubCadebSesuai = $forminspeksi['asset']['hub_cadeb']['sesuai'] ?? null;
                    $hubCadebTidakSesuai = $forminspeksi['asset']['hub_cadeb']['tidak sesuai'] ?? null;
                @endphp
                <td style="vertical-align: top;">Hubungan Pemilik Jaminan dengan Debitur</td>
                <td style="width:1%; padding: 2px; vertical-align: top;">:</td>
                <td>
                    <div style="margin-bottom: 10px;">
                        <label>
                            <input type="radio" name="hubCadebStatus" value="sesuai"
                                {{ $hubCadebSesuai ? 'checked' : '' }}> Sesuai
                        </label>
                        <label style="margin-left: 20px;">
                            <input type="radio" name="hubCadebStatus" value="tidak sesuai"
                                {{ $hubCadebTidakSesuai ? 'checked' : '' }}> Tidak Sesuai
                        </label>
                    </div>

                    @if (!empty($basicData['hubCadeb']))
                        <table>
                            <tr>
                                @php $count = 0; @endphp
                                @foreach ($basicData['hubCadeb'] as $item)
                                    <td>
                                        <label>
                                            <input type="checkbox"
                                                {{ isset($item->name) && ($hubCadebSesuai === $item->name || $hubCadebTidakSesuai === $item->name) ? 'checked' : '' }}>
                                            {{ $item->name ?? '' }}
                                        </label>
                                    </td>
                                    @php $count++; @endphp

                                    @if ($count % 3 === 0)
                            </tr>
                            <tr>
                    @endif
                    @endforeach

                    @if ($count % 3 !== 0)
                        @for ($i = 0; $i < 3 - ($count % 3); $i++)
                <td></td>
                @endfor
                @endif
            </tr>
        </table>
        @endif
        </td>
        </tr>


        <tr>

            @php
                $statusKey = isset($forminspeksi['asset']['hub_cadeb_penghuni']['sesuai']) ? 'sesuai' : 'tidak sesuai';
                $selectedData = $forminspeksi['asset']['hub_cadeb_penghuni'][$statusKey] ?? null;
            @endphp

            <td style="vertical-align: top; width: 20%; padding: 2px;">Hubungan Penghuni Jaminan dengan Debitur</td>
            <td style="width:1%; padding: 2px; vertical-align: top;">:</td>
            <td style="vertical-align: top;">
                @if (isset($selectedData))
                    {{ $selectedData ?? '' }}
            </td>
            @endif
            </td>
        </tr>
        </table>
    </div>

    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">
            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        Data data jaminan
                    </h2>
                </td>
            </tr>
        </table>

        <table style="width: 100%;">
            <tr>
                <td style="vertical-align: top; width: 25%;">Kendaraan</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">
                    <table style="width: 100%;">
                        @if (isset($basicData['modelAlatBerat']))
                            @foreach ($basicData['modelAlatBerat'] as $item)
                                <tr>
                                    <td width="40%">
                                        <label class="form-label max-w-56 gap-2.5">
                                            <input class="checkbox" name="kendaraan[]" type="checkbox"
                                                value="{{ $item->name }}"
                                                {{ in_array($item->name, old('kendaraan', $forminspeksi['kendaraan'] ?? [])) ? 'checked' : '' }} />
                                            {{ $item->name }}
                                        </label>
                                    </td>
                                    <td width="1%"></td>
                                    <td width="100%">
                                        <p>{{ old('kendaraan_input.' . $loop->index, $forminspeksi['kendaraan_input'][$loop->index] ?? '') }}
                                        </p>
                                    </td>
                                </tr>
                            @endforeach
                        @endif
                    </table>
                </td>
            </tr>

            @php
                $inputDataJaminan = [
                    [
                        'label' => 'Nama Pesawat',
                        'name' => 'nama_pesawat',
                        'value' => old('nama_pesawat', $forminspeksi['nama_pesawat'] ?? ''),
                        'index' => 0,
                    ],
                    [
                        'label' => 'Model',
                        'name' => 'model',
                        'value' => old('model', $forminspeksi['model'] ?? ''),
                        'index' => 1,
                    ],
                    [
                        'label' => 'Nomor Registrasi',
                        'name' => 'nomor_registrasi',
                        'value' => old('nomor_registrasi', $forminspeksi['nomor_registrasi'] ?? ''),
                        'index' => 2,
                    ],
                    [
                        'label' => 'Tahun Pembuatan',
                        'name' => 'tahun_pembuatan',
                        'value' => old('tahun_pembuatan', $forminspeksi['tahun_pembuatan'] ?? ''),
                        'index' => 3,
                    ],
                    [
                        'label' => 'Certificate of Airworthines (C of A)',
                        'name' => 'certificate_of_airworthines',
                        'value' => old(
                            'certificate_of_airworthines',
                            $forminspeksi['certificate_of_airworthines'] ?? '',
                        ),
                        'index' => 4,
                    ],
                    [
                        'label' => 'Certificate of Registration (C of A)',
                        'name' => 'certificate_of_registration',
                        'value' => old(
                            'certificate_of_registration',
                            $forminspeksi['certificate_of_registration'] ?? '',
                        ),
                        'index' => 5,
                    ],

                    [
                        'label' => 'Total Service Hours (TSN - Total Time Since New)',
                        'name' => 'total_service_hours',
                        'value' => old('total_service_hours', $forminspeksi['total_service_hours'] ?? ''),
                        'index' => 6,
                    ],
                    [
                        'label' => 'Total Service Cycles (CSN - Cycle Since New)',
                        'name' => 'total_service_cycles',
                        'value' => old('total_service_cycles', $forminspeksi['total_service_cycles'] ?? ''),
                        'index' => 7,
                    ],
                ];
            @endphp
            @foreach ($inputDataJaminan as $item)
                <tr>
                    <td width="20%" style="vertical-align: top;">{{ $item['label'] }}</td>
                    <td width="1%" style="vertical-align: top;">:</td>
                    <td width="100%" style="vertical-align: top;">
                        {{ $item['value'] ?? '' }}
                    </td>
                </tr>
            @endforeach
        </table>
    </div>
    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">
            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        Maintainence Data
                    </h2>
                </td>
            </tr>
        </table>

        <table style="width: 100%;">
            @php
                $inputMaintenece = [
                    [
                        'label' => 'Last A Check',
                        'name' => 'last_a_check',
                        'value' => old('last_a_check', $forminspeksi['last_a_check'] ?? ''),
                        'index' => 0,
                    ],
                    [
                        'label' => 'Next A Check',
                        'name' => 'next_a_check',
                        'value' => old('next_a_check', $forminspeksi['next_a_check'] ?? ''),
                        'index' => 1,
                    ],
                    [
                        'label' => 'Last B Check',
                        'name' => 'last_b_check',
                        'value' => old('last_b_check', $forminspeksi['last_b_check'] ?? ''),
                        'index' => 2,
                    ],
                    [
                        'label' => 'Next B Check',
                        'name' => 'next_b_check',
                        'value' => old('next_b_check', $forminspeksi['next_b_check'] ?? ''),
                        'index' => 3,
                    ],
                    [
                        'label' => 'Last C Check',
                        'name' => 'last_c_check',
                        'value' => old('last_c_check', $forminspeksi['last_c_check'] ?? ''),
                        'index' => 4,
                    ],
                    [
                        'label' => 'Next C Check',
                        'name' => 'next_c_check',
                        'value' => old('next_c_check', $forminspeksi['next_c_check'] ?? ''),
                        'index' => 5,
                    ],
                    [
                        'label' => 'Next D Check (Overhaul)',
                        'name' => 'next_d_check',
                        'value' => old('next_d_check', $forminspeksi['next_d_check'] ?? ''),
                        'index' => 6,
                    ],
                    [
                        'label' => 'Last D Check (Overhaul)',
                        'name' => 'last_d_check',
                        'value' => old('last_d_check', $forminspeksi['last_d_check'] ?? ''),
                        'index' => 7,
                    ],
                ];
            @endphp

            @foreach ($inputMaintenece as $item)
                <tr>
                    <td width="20%" style="vertical-align: top;">{{ $item['label'] }}</td>
                    <td width="1%" style="vertical-align: top;">:</td>
                    <td width="100%" style="vertical-align: top;">
                        {{ $item['value'] ?? '' }}
                    </td>
                </tr>
            @endforeach

            <tr>
                <td style="vertical-align: top;">Deskripsi/Keterangan Lain Lain</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">{{ $forminspeksi['deskripsi_maintenence'] ?? '' }}</td>
            </tr>
        </table>
    </div>

    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">
            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        Fungsi konfigurasi
                    </h2>
                </td>
            </tr>
        </table>

        <table style="width: 100%;">
            @php

                $inputFungsiKonfigurasi = [
                    [
                        'label' => 'Instrument Landing System (ILS)',
                        'name' => 'instrument_landing_system',
                        'value' => $forminspeksi['instrument_landing_system'] ?? '',
                        'index' => 0,
                    ],
                    [
                        'label' => 'Traffic Collision Avoidance System (TCAS)',
                        'name' => 'traffic_collision_avoidance_system',
                        'value' => $forminspeksi['traffic_collision_avoidance_system'] ?? '',
                        'index' => 1,
                    ],
                    [
                        'label' => 'Windshear',
                        'name' => 'windshear',
                        'value' => $forminspeksi['windshear'] ?? '',
                        'index' => 2,
                    ],
                    [
                        'label' => 'Electronic Flight Instrument System (EFIS)',
                        'name' => 'electronic_flight',
                        'value' => $forminspeksi['electronic_flight'] ?? '',
                        'index' => 3,
                    ],
                    [
                        'label' => 'Winglets ',
                        'name' => 'winglets',
                        'value' => $forminspeksi['winglets'] ?? '',
                        'index' => 4,
                    ],
                ];
            @endphp
            @foreach ($inputFungsiKonfigurasi as $item)
                <tr>
                    <td width="20%" style="vertical-align: top;">{{ $item['label'] }}</td>
                    <td width="1%" style="vertical-align: top;">:</td>
                    <td width="100%" style="vertical-align: top;">
                        {{ $item['value'] ?? '' }}
                    </td>
                </tr>
            @endforeach

            <tr>
                <td style="vertical-align: top;">Deskripsi/Keterangan Lain Lain</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">{{ $forminspeksi['deskripsi_maintenence'] ?? '' }}
                </td>
            </tr>
        </table>
    </div>


    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">
            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        Kondisi Kabin pesawat
                    </h2>
                </td>
            </tr>
        </table>

        <table style="width: 100%;">
            @php
            $kondisiKabin = [
                [
                    'label' => 'Maksimal Penumpang',
                    'name' => 'maksimal_penumpang',
                    'value' => $forminspeksi['maksimal_penumpang'] ?? '',
                    'index' => 0,
                ],
                [
                    'label' => 'Jumlah Kursi',
                    'name' => 'jumlah_kursi',
                    'value' => $forminspeksi['jumlah_kursi'] ?? '',
                    'index' => 1,
                ],
                [
                    'label' => 'Kursi Pramugari/Pramugara',
                    'name' => 'kursi_pramugari_pramugara',
                    'value' => $forminspeksi['kursi_pramugari_pramugara'] ?? '',
                    'index' => 2,
                ],
                [
                    'label' => 'Kartu Fitur keselamatan',
                    'name' => 'kartu_fitur_keselamatan',
                    'value' => $forminspeksi['kartu_fitur_keselamatan'] ?? '',
                    'index' => 3,
                ],
                [
                    'label' => 'Sabuk Pengaman',
                    'name' => 'sabuk_pengaman',
                    'value' => $forminspeksi['sabuk_pengaman'] ?? '',
                    'index' => 4,
                ],
                [
                    'label' => 'Lampu Kabin',
                    'name' => 'lampu_kabin',
                    'value' => $forminspeksi['lampu_kabin'] ?? '',
                    'index' => 5,
                ],
                [
                    'label' => 'Lampu Pintu Keluar',
                    'name' => 'lampu_pintu_keluar',
                    'value' => $forminspeksi['lampu_pintu_keluar'] ?? '',
                    'index' => 6,
                ],
                [
                    'label' => 'Intercom Kabin',
                    'name' => 'intercom_kabin',
                    'value' => $forminspeksi['intercom_kabin'] ?? '',
                    'index' => 7,
                ],
            ];
        @endphp
            @foreach ($kondisiKabin as $item)
                <tr>
                    <td width="20%" style="vertical-align: top;">{{ $item['label'] }}</td>
                    <td width="1%" style="vertical-align: top;">:</td>
                    <td width="100%" style="vertical-align: top;">
                        {{ $item['value'] ?? '' }}
                    </td>
                </tr>
            @endforeach

            <tr>
                <td style="vertical-align: top;">Deskripsi/Keterangan Lain Lain</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">{{ $forminspeksi['deskripsi_maintenence'] ?? '' }}
                </td>
            </tr>
        </table>
    </div>


    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">
            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        Kondisi Struktur Pesawat
                    </h2>
                </td>
            </tr>
        </table>

        <table style="width: 100%;">
            @php

                $kondisiStrukturPesawat = [
                    [
                        'label' => 'Badan pesawat',
                        'name' => 'badan_pesawat',
                        'value' => $forminspeksi['badan_pesawat'] ?? '',
                        'index' => 0,
                    ],
                    [
                        'label' => 'Sayap Pesawat',
                        'name' => 'sayap_pesawat',
                        'value' => $forminspeksi['sayap_pesawat'] ?? '',
                        'index' => 1,
                    ],
                    [
                        'label' => 'Ekor peswat',
                        'name' => 'ekor_pesawat',
                        'value' => $forminspeksi['ekor_pesawat'] ?? '',
                        'index' => 2,
                    ],
                    [
                        'label' => 'Landing Gear',
                        'name' => 'landing_gear',
                        'value' => $forminspeksi['landing_gear'] ?? '',
                        'index' => 3,
                    ],
                    [
                        'label' => 'Sabuk Pengaman',
                        'name' => 'sabuk_pengaman',
                        'value' => $forminspeksi['sabuk_pengaman'] ?? '',
                        'index' => 4,
                    ],
                    [
                        'label' => 'Sistem Pengelasan',
                        'name' => 'sistem_pengelasan',
                        'value' => $forminspeksi['sistem_pengelasan'] ?? '',
                        'index' => 5,
                    ],
                ];
            @endphp
            @foreach ($kondisiStrukturPesawat as $item)
                <tr>
                    <td width="20%" style="vertical-align: top;">{{ $item['label'] }}</td>
                    <td width="1%" style="vertical-align: top;">:</td>
                    <td width="100%" style="vertical-align: top;">
                        {{ $item['value'] ?? '' }}
                    </td>
                </tr>
            @endforeach

            <tr>
                <td style="vertical-align: top;">Deskripsi/Keterangan Lain Lain</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">{{ $forminspeksi['deskripsi_maintenence'] ?? '' }}
                </td>
            </tr>
        </table>
    </div>


    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">
            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        Fungsi Navigasi dan Komunikasi
                    </h2>
                </td>
            </tr>
        </table>

        <table style="width: 100%;">
            @php

                $fungsiNavigasi = [
                    [
                        'label' => 'Gps',
                        'name' => 'gps',
                        'value' => $forminspeksi['gps'] ?? '',
                        'index' => 0,
                    ],
                    [
                        'label' => 'Radar',
                        'name' => 'radar',
                        'value' => $forminspeksi['radar'] ?? '',
                        'index' => 1,
                    ],
                    [
                        'label' => 'Radio Komunikasi',
                        'name' => 'radio_komunikasi',
                        'value' => $forminspeksi['radio_komunikasi'] ?? '',
                        'index' => 2,
                    ],
                    [
                        'label' => 'Lampu Navigasi',
                        'name' => 'lampu_navigasi',
                        'value' => $forminspeksi['lampu_navigasi'] ?? '',
                        'index' => 3,
                    ],
                    [
                        'label' => 'Sistem Autopilot',
                        'name' => 'sistem_autopilot',
                        'value' => $forminspeksi['sistem_autopilot'] ?? '',
                        'index' => 4,
                    ],
                ];
            @endphp
            @foreach ($fungsiNavigasi as $item)
                <tr>
                    <td width="20%" style="vertical-align: top;">{{ $item['label'] }}</td>
                    <td width="1%" style="vertical-align: top;">:</td>
                    <td width="100%" style="vertical-align: top;">
                        {{ $item['value'] ?? '' }}
                    </td>
                </tr>
            @endforeach

            <tr>
                <td style="vertical-align: top;">Deskripsi/Keterangan Lain Lain</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">{{ $forminspeksi['deskripsi_maintenence'] ?? '' }}
                </td>
            </tr>
        </table>
    </div>


    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">
            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        Kondisi Sistem Bahan Bakar dan Hidrolic
                    </h2>
                </td>
            </tr>
        </table>

        <table style="width: 100%;">
            @php

                $kondisiSistem = [
                    [
                        'label' => 'Tangki Bahan Bakar',
                        'name' => 'tangki_bahan_bakar',
                        'value' => $forminspeksi['tangki_bahan_bakar'] ?? '',
                        'index' => 0,
                    ],
                    [
                        'label' => 'Saluran & Pipa Bahan Bakar',
                        'name' => 'saluran_pipa_bahan_bakar',
                        'value' => $forminspeksi['saluran_pipa_bahan_bakar'] ?? '',
                        'index' => 1,
                    ],
                    [
                        'label' => 'Pompa Bahan Bakar',
                        'name' => 'pompa_bahan_bakar',
                        'value' => $forminspeksi['pompa_bahan_bakar'] ?? '',
                        'index' => 2,
                    ],
                    [
                        'label' => 'Sistem Hidrolik Utama',
                        'name' => 'sistem_hidrolik_utama',
                        'value' => $forminspeksi['sistem_hidrolik_utama'] ?? '',
                        'index' => 3,
                    ],
                    [
                        'label' => 'Sistem Pendigin Hidrolik',
                        'name' => 'sistem_pendigin_hidrolik',
                        'value' => $forminspeksi['sistem_pendigin_hidrolik'] ?? '',
                        'index' => 4,
                    ],
                ];
            @endphp
            @foreach ($kondisiSistem as $item)
                <tr>
                    <td width="20%" style="vertical-align: top;">{{ $item['label'] }}</td>
                    <td width="1%" style="vertical-align: top;">:</td>
                    <td width="100%" style="vertical-align: top;">
                        {{ $item['value'] ?? '' }}
                    </td>
                </tr>
            @endforeach

            <tr>
                <td style="vertical-align: top;">Deskripsi/Keterangan Lain Lain</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">{{ $forminspeksi['deskripsi_maintenence'] ?? '' }}
                </td>
            </tr>
        </table>
    </div>

    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">
            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        Kondisi Mesin dan Propulis
                    </h2>
                </td>
            </tr>
        </table>

        <table style="width: 100%;">
            @php

                $kondisiMesin = [
                    [
                        'label' => 'Mesin Utama',
                        'name' => 'mesin_utama',
                        'value' => $forminspeksi['mesin_utama'] ?? '',
                        'index' => 0,
                    ],
                    [
                        'label' => 'Sistem Pendorong',
                        'name' => 'sistem_pendorong',
                        'value' => $forminspeksi['sistem_pendorong'] ?? '',
                        'index' => 1,
                    ],
                    [
                        'label' => 'Sistem Pendigin Mesin',
                        'name' => 'sistem_pendigin_mesin',
                        'value' => $forminspeksi['sistem_pendigin_mesin'] ?? '',
                        'index' => 2,
                    ],
                    [
                        'label' => 'Sistem pelumasan',
                        'name' => 'sistem_pelumasan',
                        'value' => $forminspeksi['sistem_pelumasan'] ?? '',
                        'index' => 3,
                    ],
                    [
                        'label' => 'Filter dan Perangkat Pendukung',
                        'name' => 'filter_dan_perangkat_pendukung',
                        'value' => $forminspeksi['filter_dan_perangkat_pendukung'] ?? '',
                        'index' => 4,
                    ],
                ];
            @endphp
            @foreach ($kondisiMesin as $item)
                <tr>
                    <td width="20%" style="vertical-align: top;">{{ $item['label'] }}</td>
                    <td width="1%" style="vertical-align: top;">:</td>
                    <td width="100%" style="vertical-align: top;">
                        {{ $item['value'] ?? '' }}
                    </td>
                </tr>
            @endforeach

            <tr>
                <td style="vertical-align: top;">Deskripsi/Keterangan Lain Lain</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">{{ $forminspeksi['deskripsi_maintenence'] ?? '' }}
                </td>
            </tr>
        </table>
    </div>

    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">
            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        Fungsi keselamatan dan darurat
                    </h2>
                </td>
            </tr>
        </table>

        <table style="width: 100%;">
            @php

                $fungsiKeselamatan = [
                    [
                        'label' => 'Jaket pelampung',
                        'name' => 'jaket_pelampung',
                        'value' => $forminspeksi['jaket_pelampung'] ?? '',
                        'index' => 0,
                    ],
                    [
                        'label' => 'Pintu darurat',
                        'name' => 'pintu_darurat',
                        'value' => $forminspeksi['pintu_darurat'] ?? '',
                        'index' => 1,
                    ],
                    [
                        'label' => 'Alat Pemadaman Kebakaran',
                        'name' => 'alat_pemadaman_kebakaran',
                        'value' => $forminspeksi['alat_pemadaman_kebakaran'] ?? '',
                        'index' => 2,
                    ],
                    [
                        'label' => 'Sistem Alaram Darurat',
                        'name' => 'sistem_alaram_darurat',
                        'value' => $forminspeksi['sistem_alaram_darurat'] ?? '',
                        'index' => 3,
                        'index' => 3,
                    ],
                    [
                        'label' => 'Sekoci',
                        'name' => 'sekoci',
                        'value' => $forminspeksi['sekoci'] ?? '',
                        'index' => 4,
                    ],
                    [
                        'label' => 'Masker Oksigen',
                        'name' => 'masker_oxigen',
                        'value' => $forminspeksi['masker_oxigen'] ?? '',
                        'index' => 5,
                    ],
                    [
                        'label' => 'Sabuk Pengaman',
                        'name' => 'sabuk_pengaman',
                        'value' => $forminspeksi['sabuk_pengaman'] ?? '',
                        'index' => 6,
                    ],
                ];
            @endphp
            @foreach ($fungsiKeselamatan as $item)
                <tr>
                    <td width="20%" style="vertical-align: top;">{{ $item['label'] }}</td>
                    <td width="1%" style="vertical-align: top;">:</td>
                    <td width="100%" style="vertical-align: top;">
                        {{ $item['value'] ?? '' }}
                    </td>
                </tr>
            @endforeach

            <tr>
                <td style="vertical-align: top;">Deskripsi/Keterangan Lain Lain</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">{{ $forminspeksi['deskripsi_maintenence'] ?? '' }}
                </td>
            </tr>
        </table>
    </div>

    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">
            <tr>
                <td style="text-align: center; margin-top: 5px; ">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        Interior dan Sistem Pendukung Kabin
                    </h2>
                </td>
            </tr>
        </table>

        <table style="width: 100%;">
            @php

                $inputStrukturPeswat = [
                    [
                        'label' => 'Sistem ventilasi & AC',
                        'name' => 'sistem_ventilasi_ac',
                        'value' => $forminspeksi['sistem_ventilasi_ac'] ?? '',
                        'index' => 0,
                    ],
                    [
                        'label' => 'Sistem Penerangan Kabin',
                        'name' => 'sistem_penerangan_kabin',
                        'value' => $forminspeksi['sistem_penerangan_kabin'] ?? '',
                        'index' => 1,
                    ],
                    [
                        'label' => 'Panel Informasi Penumpang',
                        'name' => 'panel_informasi_penumpang',
                        'value' => $forminspeksi['panel_informasi_penumpang'] ?? '',
                        'index' => 2,
                    ],
                    [
                        'label' => 'Sistem Hiburan Kabin',
                        'name' => 'sistem_hiburan_kabin',
                        'value' => $forminspeksi['sistem_hiburan_kabin'] ?? '',
                        'index' => 3,
                    ],
                ];
            @endphp
            @foreach ($inputStrukturPeswat as $item)
                <tr>
                    <td width="20%" style="vertical-align: top;">{{ $item['label'] }}</td>
                    <td width="1%" style="vertical-align: top;">:</td>
                    <td width="100%" style="vertical-align: top;">
                        {{ $item['value'] ?? '' }}
                    </td>
                </tr>
            @endforeach

            <tr>
                <td style="vertical-align: top;">Deskripsi/Keterangan Lain Lain</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">{{ $forminspeksi['deskripsi_maintenence'] ?? '' }}
                </td>
            </tr>
        </table>
    </div>
    <div>
        <table
            style="width: 100%; border-top: 1px solid #000; border-bottom: 1px solid #000; border-collapse: collapse; border-left: none; border-right: none;">


            <tr>
                <td style="text-align: center; margin-top: 5px;">
                    <h2 style=" text-transform: uppercase; text-align: center; margin: 0;">
                        ANalisa Fakta
                    </h2>

                </td>
            </tr>
        </table>

        <table style="width: 100%">
            <tr>
                <td width="25%" style="vertical-align: top;">Faktor Positif</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">
                    @isset($forminspeksi['fakta_positif'])
                        <table style="width: 100%; border-collapse: collapse;">
                            @foreach ($forminspeksi['fakta_positif'] as $key => $item)
                                <tr>
                                    <td>{!! nl2br(e($item)) !!}</td>
                                </tr>
                            @endforeach
                        </table>
                    @endisset
                </td>
            </tr>
            <tr>
                <td width="25%" style="vertical-align: top;">Faktor Negatif</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">
                    @php
                        $faktaNegatif = $forminspeksi['fakta_negatif'] ?? [];
                        $faktaNegatifFiltered = is_array($faktaNegatif)
                            ? array_filter($faktaNegatif, function ($item) {
                                return !empty(trim($item));
                            })
                            : [];
                    @endphp

                    @if (!empty($faktaNegatifFiltered))
                        <table style="width: 100%; border-collapse: collapse;">
                            @foreach ($faktaNegatifFiltered as $key => $item)
                                <tr>
                                    <td>{!! nl2br(e($item)) !!}</td>
                                </tr>
                            @endforeach
                        </table>
                    @else
                        <p>Tidak ada faktor negatif yang teridentifikasi.</p>
                    @endif
                </td>
            </tr>



            <tr>
                <td width="20%" style="vertical-align: top;">Catatan yang perlu di perhatikan</td>
                <td width="1%" style="vertical-align: top;">:</td>
                <td width="100%" style="vertical-align: top;">
                    @php
                        $faktaNegatif = $forminspeksi['catatan'] ?? [];
                        $faktaNegatifFiltered = is_array($faktaNegatif)
                            ? array_filter($faktaNegatif, function ($item) {
                                return !empty(trim($item));
                            })
                            : [];
                    @endphp

                    @if (!empty($faktaNegatifFiltered))
                        <table style="width: 100%; border-collapse: collapse;">
                            @foreach ($faktaNegatifFiltered as $key => $item)
                                <tr>
                                    <td>{!! nl2br(e($item)) !!}</td>
                                </tr>
                            @endforeach
                        </table>
                    @else
                        <p>Tidak ada faktor negatif yang teridentifikasi.</p>
                    @endif
                </td>
            </tr>
        </table>
    </div>



</div>


@include('lpj::surveyor.components.print-out.footer')
