<div class="no-break">
    <table style="width: 100%; border-collapse: collapse;">
        <tr>
            <td style="border: 1px solid #000;">
                <table>
                    <tr>
                        <td>
                           {{ $permohonan->debiture->branch->name ?? '' }} {{ formatTanggalIndonesia($permohonan->penilaian->waktu_penilaian) }}
                        </td>
                    </tr>

                    <tr>
                        <td>
                            TTD
                        </td>
                    </tr>
                </table>
                <table style="width: 100%; border-collapse: collapse; text-align: center;">
                    <tr>
                        @if (isset($forminspeksi['signature']['penilai']['image']) && !empty($forminspeksi['signature']['penilai']['image']))
                            @php
                                $imagePath = $forminspeksi['signature']['penilai']['image'];

                                $isBase64 = str_starts_with($imagePath, 'data:image');

                                if (!$isBase64) {
                                    $relativePath = str_replace(url('storage') . '/', '', $imagePath);
                                    $absolutePath = storage_path('app/public/' . $relativePath);
                                } else {
                                    $absolutePath = $imagePath;
                                }

                            @endphp
                            <td style="width: 100px;">
                                <img style="width: 100px;" src="{{ $absolutePath }}" alt="">
                            </td>
                        @endif

                        @if (isset($forminspeksi['signature']['cabang']))
                            @php
                                $imagePath = $forminspeksi['signature']['cabang']['image'];

                                $isBase64 = str_starts_with($imagePath, 'data:image');

                                if (!$isBase64) {
                                    $relativePath = str_replace(url('storage') . '/', '', $imagePath);
                                    $absolutePath = storage_path('app/public/' . $relativePath);
                                } else {
                                    $absolutePath = $imagePath;
                                }

                            @endphp
                            <td style="width: 100px;">
                                <img style="width: 100px;" src="{{ $absolutePath }}" alt="">
                            </td>
                        @endif


                        @if (isset($forminspeksi['signature']['debitur']))
                            <td style="width: 100px;">
                                <img style="width: 100px;" src="{{ $forminspeksi['signature']['debitur']['image'] }}"
                                    alt="Debitur/Perwakilan">
                            </td>
                        @endif

                        <!-- K.J.P.P -->
                        @if (isset($forminspeksi['signature']['kjjp']))
                            <td style="width: 100px;">
                                <img style="width: 100px;" src="{{ $forminspeksi['signature']['kjjp']['image'] }}"
                                    alt="KJPP">
                            </td>
                        @endif
                    </tr>


                    <tr>
                        @if (isset($forminspeksi['signature']['penilai']['name']))
                            <td style=" text-align: center">
                                <span>{{ ucwords(strtolower($forminspeksi['signature']['penilai']['name'])) }}</span>
                                <br />
                                <span>{{ ucwords(strtolower('PENILAI')) }}</span>
                            </td>
                        @endif
                        @if (isset($forminspeksi['signature']['cabang']['name']))
                            <td style=" text-align: center">
                                <span>{{ ucwords(strtolower($forminspeksi['signature']['cabang']['name'])) }}</span>
                                <br />
                                <span>{{ ucwords(strtolower('CABANG')) }}</span>
                            </td>
                        @endif
                        @if (isset($forminspeksi['signature']['debitur']['name']))
                            <td style=" text-align: center">
                                <span>{{ ucwords(strtolower($forminspeksi['signature']['debitur']['name'])) }}</span>
                                <br />
                                <span>{{ ucwords(strtolower('DEBITUR/PERWAKILAN')) }}</span>
                            </td>
                        @endif
                        @if (isset($forminspeksi['signature']['kjjp']['name']))
                            <td style=" text-align: center">
                                <span>{{ ucwords(strtolower($forminspeksi['signature']['kjjp']['name'])) }}</span>
                                <br />
                                <span>{{ strtoupper('K.J.P.P') }}</span>
                            </td>
                        @endif
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>


<footer id="footer">
    Cabang : {{ $permohonan->debiture->branch->name ?? '' }}
</footer>
<script type="text/php">
    if (isset($pdf)) {
        $pdf->page_script('
            $font = $fontMetrics->get_font("Arial, Helvetica, sans-serif", "normal");
            $size = 10;
            $pageText = $PAGE_NUM;
            $y = 800;
            $x = 550;
            $pdf->text($x, $y, $pageText, $font, $size);
        ');
    }
</script>
</body>

</html>
