<?php helper(['letter', 'logo']); ?>
<?= $this->extend('layouts/print') ?>
<?= $this->section('content') ?>

<style>
    @page {
        size: 21.5cm 33.0cm;
        margin: 1.2cm 1.0cm 1.2cm 1.0cm;
    }
    @media print {
        .no-print { display: none !important; }
        #surat-sppd { page-break-after: always; }
        #sppd-lampiran { page-break-after: always; page-break-before: always; }
        #sppd-laporan { page-break-before: always; }
    }
    .sppd-table th, .sppd-table td {
        border: 1px solid #000;
        padding: 4px 6px;
        vertical-align: top;
    }
    #sppd-laporan {
        margin-left: 0.5cm;
        margin-right: 0.5cm;
    }
</style>

<div class="no-print" style="padding:10px 0 16px; display:flex; gap:10px;">
    <button onclick="window.print()" class="btn-print">
        <i class="bi bi-printer"></i> Cetak
    </button>
    <button onclick="window.history.back()" class="btn-back">
        <i class="bi bi-arrow-left"></i> Kembali
    </button>
</div>

<?php
$start    = $log['date_start'] ?? $log['letter_date'];
$end      = $log['date_end']   ?? $log['letter_date'];
$cityFrom = $letterSettings['city'] ?? $schoolSettings['city'] ?? '';
$cityTo   = !empty($log['destination']) ? $log['destination'] : ($log['origin'] ?? '-');

// Hitung jumlah hari
$hariCount = 1;
if ($start && $end) {
    $diff = (int) round((strtotime($end) - strtotime($start)) / 86400) + 1;
    $hariCount = max(1, $diff);
}
?>

<div id="surat" style="font-family: 'Bookman Old Style', Bookman, Georgia, serif; font-size: 11pt;">
<!-- =============================================
     LEMBAR 1: SURAT PERINTAH PERJALANAN DINAS
     ============================================= -->
<div id="surat-sppd" style="margin-bottom: 15px;">
    
    <?= view('letter/_kop') ?>

    <!-- Metadata Below KOP -->
    <div style="display: flex; justify-content: flex-end; font-size: 9.5pt; margin-bottom: 10px; line-height: 1.25;">
        <table style="border-collapse: collapse;">
            <tr>
                <td style="width: 80px;">Lembar ke</td>
                <td style="width: 10px;">:</td>
                <td>I / II / III / IV</td>
            </tr>
            <tr>
                <td>Kode No</td>
                <td style="width: 10px;">:</td>
                <td>..................</td>
            </tr>
            <tr>
                <td>Nomor</td>
                <td style="width: 10px;">:</td>
                <td><?= esc($log['letter_number']) ?></td>
            </tr>
        </table>
    </div>

    <!-- JUDUL -->
    <div style="text-align: center; margin-bottom: 15px;">
        <div style="font-size: 12.5pt; font-weight: bold; text-transform: uppercase; text-decoration: underline; letter-spacing: 0.5px; margin: 0;">
            SURAT PERINTAH PERJALANAN DINAS
        </div>
    </div>

    <!-- TABEL SPPD -->
    <table class="sppd-table" style="width: 100%; border-collapse: collapse; font-size: 11pt; line-height: 1.4; border: 1px solid #000; margin-bottom: 15px;">
        <tr>
            <td style="width:25px; text-align:center;">1</td>
            <td style="width:230px;">Pejabat berwenang yang memberi perintah</td>
            <td>Kepala <?= esc($schoolSettings['school_name'] ?? '') ?></td>
        </tr>
        <tr>
            <td style="text-align:center;">2</td>
            <td>Nama pegawai yang diperintahkan</td>
            <td style="font-weight:bold;"><?= esc(format_person_name($log['officer_name'] ?? '')) ?></td>
        </tr>
        <tr>
            <td style="text-align:center;">3</td>
            <td>
                a. Pangkat dan golongan<br>
                b. Jabatan<br>
                c. Gaji Pokok<br>
                d. Tingkat menurut peraturan perjalanan dinas
            </td>
            <td>
                a. <?= esc($log['officer_rank'] ?? '-') ?> <?= !empty($log['officer_nip']) ? ' &nbsp; NIP. ' . esc($log['officer_nip']) : '' ?><br>
                b. <?= esc($log['officer_position'] ?? '-') ?><br>
                c. -<br>
                d. Dinas
            </td>
        </tr>
        <tr>
            <td style="text-align:center;">4</td>
            <td>Maksud perjalanan dinas</td>
            <td><?= esc($log['task_description'] ?? '-') ?></td>
        </tr>
        <tr>
            <td style="text-align:center;">5</td>
            <td>Alat angkutan yang dipergunakan</td>
            <td><?= esc($log['transport'] ?? '-') ?></td>
        </tr>
        <tr>
            <td rowspan="2" style="text-align:center; vertical-align: middle;">6</td>
            <td>a. Tempat berangkat</td>
            <td><?= esc($cityFrom) ?></td>
        </tr>
        <tr>
            <td>b. Tempat tujuan</td>
            <td><?= esc($log['origin'] ?? '-') ?></td>
        </tr>
        <tr>
            <td rowspan="3" style="text-align:center; vertical-align: middle;">7</td>
            <td>a. Lamanya perjalanan dinas</td>
            <td><?= $hariCount ?> hari</td>
        </tr>
        <tr>
            <td>b. Tanggal berangkat</td>
            <td><?= format_tanggal_indonesia($start) ?></td>
        </tr>
        <tr>
            <td>c. Tanggal harus kembali</td>
            <td><?= format_tanggal_indonesia($end) ?></td>
        </tr>
        <tr>
            <td style="text-align:center; vertical-align: top; padding: 4px 6px;">8.</td>
            <td colspan="2" style="padding: 0; vertical-align: top;">
                <table style="width: 100%; border-collapse: collapse; border: none; font-size: 11pt; line-height: 1.45;">
                    <tr>
                        <td style="width: 150px; border: none; border-right: 1px solid #000; padding: 4px 6px; font-weight: bold; text-align: center; text-decoration: underline; vertical-align: top;">Pengikut :</td>
                        <td style="width: 220px; border: none; border-right: 1px solid #000; padding: 4px 6px; font-weight: bold; text-align: center; text-decoration: underline; vertical-align: top;">Nama :</td>
                        <td style="width: 70px; border: none; border-right: 1px solid #000; padding: 4px 6px; font-weight: bold; text-align: center; text-decoration: underline; vertical-align: top;">Umur</td>
                        <td style="border: none; padding: 4px 6px; font-weight: bold; text-align: center; text-decoration: underline; vertical-align: top;">Hubungan Keluarga/Keterangan :</td>
                    </tr>
                    <tr>
                        <td style="border: none; border-right: 1px solid #000; border-top: 1px solid #000; padding: 6px; height: 90px; vertical-align: top; line-height: 1.6;">
                            1.<br>
                            2.<br>
                            3.<br>
                            4.
                        </td>
                        <td style="border: none; border-right: 1px solid #000; border-top: 1px solid #000; padding: 6px; height: 90px; vertical-align: top;"></td>
                        <td style="border: none; border-right: 1px solid #000; border-top: 1px solid #000; padding: 6px; height: 90px; vertical-align: top;"></td>
                        <td style="border: none; border-top: 1px solid #000; padding: 6px; height: 90px; vertical-align: top;"></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td style="text-align:center;">9</td>
            <td>
                Pembebanan Anggaran<br>
                a. Instansi<br>
                b. Mata anggaran
            </td>
            <td>
                <br>
                a. <?= esc($schoolSettings['school_name'] ?? '') ?><br>
                b. <?= esc($log['budget_source'] ?? '-') ?>
            </td>
        </tr>
        <tr>
            <td style="text-align:center;">10</td>
            <td>Keterangan lain-lain</td>
            <td>—</td>
        </tr>
    </table>

    <!-- TTD HALAMAN 1 -->
    <div style="margin-top: 15px; font-size: 11pt; line-height: 1.35;">
        <table style="width: 100%;">
            <tr>
                <td style="width: 55%;"></td>
                <td style="text-align: left;">
                    <div>Dikeluarkan di : <?= esc($cityFrom) ?></div>
                    <div style="margin-bottom: 8px;">Pada tanggal &nbsp;: <?= format_tanggal_indonesia($log['letter_date']) ?></div>
                    <div style="font-weight: bold; margin-bottom: 50px; line-height: 1.3;">
                        Pejabat Pembuat Komitmen<br>
                        <?= esc($schoolSettings['school_name'] ?? '') ?>,
                    </div>
                    <div>
                        <strong style="text-decoration: underline;"><?= esc(format_person_name($schoolSettings['principal_name'] ?? '')) ?></strong>
                    </div>
                    <div>NIP. <?= esc($schoolSettings['principal_nip'] ?? '-') ?></div>
                </td>
            </tr>
        </table>
    </div>
</div>


<!-- =============================================
     LEMBAR 2: TANDA BERANGKAT / TIBA (LAMPIRAN SPPD)
     ============================================= -->
<div id="sppd-lampiran" style="padding-top: 10px; font-size: 11pt; line-height: 1.3;">
    <!-- Tabel Pengesahan Perjalanan (Tiba di / Berangkat dari) -->
    <table style="width: 100%; border-collapse: collapse; border: 1px solid #000; margin-bottom: 10px;">
        <!-- BARIS I: BERANGKAT DARI KEDUDUKAN ASAL (SEKARANG DALAM KOTAK) -->
        <tr>
            <td style="width: 50%; border: 1px solid #000; padding: 6px; vertical-align: top; height: 110px;">
                <!-- Kosong -->
            </td>
            <td style="width: 50%; border: 1px solid #000; padding: 6px; vertical-align: top; height: 110px;">
                <table style="width: 100%; font-size: 11pt; line-height: 1.3;">
                    <tr>
                        <td style="width: 120px; vertical-align: top;">Berangkat dari</td>
                        <td style="width: 10px; vertical-align: top;">:</td>
                        <td style="vertical-align: top;"><?= esc($cityFrom) ?></td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Pada tanggal</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;"><?= format_tanggal_indonesia($start) ?></td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Ke</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;"><?= esc($cityTo) ?></td>
                    </tr>
                </table>
                <div style="margin-top: 8px; text-align: center; font-size: 11pt;">
                    Kepala <?= esc($schoolSettings['school_name'] ?? '') ?>,
                    <div style="height: 35px;"></div>
                    <div style="font-weight: bold; text-decoration: underline;"><?= esc(format_person_name($schoolSettings['principal_name'] ?? '')) ?></div>
                    <div>NIP. <?= esc($schoolSettings['principal_nip'] ?? '-') ?></div>
                </div>
            </td>
        </tr>

        <!-- BARIS II: KONTEN -->
        <tr>
            <td style="width: 50%; border: 1px solid #000; border-bottom: hidden !important; padding: 6px 6px 0; vertical-align: top;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px; vertical-align: top;">II. Tiba di</td>
                        <td style="width: 10px; vertical-align: top;">:</td>
                        <td style="vertical-align: top;"><?= esc($cityTo) ?></td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">pada tanggal</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Kepala</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                </table>
            </td>
            <td style="width: 50%; border: 1px solid #000; border-bottom: hidden !important; padding: 6px 6px 0; vertical-align: top;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px; vertical-align: top;">Berangkat dari</td>
                        <td style="width: 10px; vertical-align: top;">:</td>
                        <td style="vertical-align: top;"><?= esc($cityTo) ?></td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">pada tanggal</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Kepala</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                </table>
            </td>
        </tr>
        <!-- BARIS II: TANDA TANGAN (SEJAJAR) -->
        <tr>
            <td style="width: 50%; border: 1px solid #000; border-top: hidden !important; padding: 0 6px 6px; vertical-align: bottom;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px;"></td>
                        <td style="width: 10px;"></td>
                        <td style="vertical-align: bottom;">
                            <div style="border-bottom: 1px solid #000; height: 35px; margin-bottom: 4px; width: 200px;"></div>
                            <div style="width: 200px; text-align: left;">NIP. </div>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 50%; border: 1px solid #000; border-top: hidden !important; padding: 0 6px 6px; vertical-align: bottom;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px;"></td>
                        <td style="width: 10px;"></td>
                        <td style="vertical-align: bottom;">
                            <div style="border-bottom: 1px solid #000; height: 35px; margin-bottom: 4px; width: 200px;"></div>
                            <div style="width: 200px; text-align: left;">NIP. </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>

        <!-- BARIS III: KONTEN -->
        <tr>
            <td style="width: 50%; border: 1px solid #000; border-bottom: hidden !important; padding: 6px 6px 0; vertical-align: top;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px; vertical-align: top;">III. Tiba di</td>
                        <td style="width: 10px; vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">pada tanggal</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Kepala</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                </table>
            </td>
            <td style="width: 50%; border: 1px solid #000; border-bottom: hidden !important; padding: 6px 6px 0; vertical-align: top;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px; vertical-align: top;">Berangkat dari</td>
                        <td style="width: 10px; vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">ke</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">pada tanggal</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Kepala</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                </table>
            </td>
        </tr>
        <!-- BARIS III: TANDA TANGAN (SEJAJAR) -->
        <tr>
            <td style="width: 50%; border: 1px solid #000; border-top: hidden !important; padding: 0 6px 6px; vertical-align: bottom;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px;"></td>
                        <td style="width: 10px;"></td>
                        <td style="vertical-align: bottom;">
                            <div style="border-bottom: 1px solid #000; height: 35px; margin-bottom: 4px; width: 200px;"></div>
                            <div style="width: 200px; text-align: left;">NIP. </div>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 50%; border: 1px solid #000; border-top: hidden !important; padding: 0 6px 6px; vertical-align: bottom;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px;"></td>
                        <td style="width: 10px;"></td>
                        <td style="vertical-align: bottom;">
                            <div style="border-bottom: 1px solid #000; height: 35px; margin-bottom: 4px; width: 200px;"></div>
                            <div style="width: 200px; text-align: left;">NIP. </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>

        <!-- BARIS IV: KONTEN -->
        <tr>
            <td style="width: 50%; border: 1px solid #000; border-bottom: hidden !important; padding: 6px 6px 0; vertical-align: top;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px; vertical-align: top;">IV. Tiba di</td>
                        <td style="width: 10px; vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">pada tanggal</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Kepala</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                </table>
            </td>
            <td style="width: 50%; border: 1px solid #000; border-bottom: hidden !important; padding: 6px 6px 0; vertical-align: top;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px; vertical-align: top;">Berangkat dari</td>
                        <td style="width: 10px; vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">ke</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">pada tanggal</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Kepala</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;">...................................</td>
                    </tr>
                </table>
            </td>
        </tr>
        <!-- BARIS IV: TANDA TANGAN (SEJAJAR) -->
        <tr>
            <td style="width: 50%; border: 1px solid #000; border-top: hidden !important; padding: 0 6px 6px; vertical-align: bottom;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px;"></td>
                        <td style="width: 10px;"></td>
                        <td style="vertical-align: bottom;">
                            <div style="border-bottom: 1px solid #000; height: 35px; margin-bottom: 4px; width: 200px;"></div>
                            <div style="width: 200px; text-align: left;">NIP. </div>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 50%; border: 1px solid #000; border-top: hidden !important; padding: 0 6px 6px; vertical-align: bottom;">
                <table style="width: 100%; font-size: 11pt;">
                    <tr>
                        <td style="width: 120px;"></td>
                        <td style="width: 10px;"></td>
                        <td style="vertical-align: bottom;">
                            <div style="border-bottom: 1px solid #000; height: 35px; margin-bottom: 4px; width: 200px;"></div>
                            <div style="width: 200px; text-align: left;">NIP. </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>

        <!-- BARIS V: KONTEN -->
        <tr>
            <td style="width: 50%; border: 1px solid #000; border-bottom: hidden !important; padding: 6px 6px 0; vertical-align: top;">
                <table style="width: 100%; font-size: 11pt; line-height: 1.3;">
                    <tr>
                        <td style="width: 135px; vertical-align: top;">V. Tiba kembali di</td>
                        <td style="width: 10px; vertical-align: top;">:</td>
                        <td style="vertical-align: top;"><?= esc($cityFrom) ?></td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Tanggal</td>
                        <td style="vertical-align: top;">:</td>
                        <td style="vertical-align: top;"><?= format_tanggal_indonesia($end) ?></td>
                    </tr>
                </table>
            </td>
            <td style="width: 50%; border: 1px solid #000; border-bottom: hidden !important; padding: 6px 6px 0; vertical-align: top;">
                <table style="width: 100%; font-size: 11pt; line-height: 1.3;">
                    <tr>
                        <td style="text-align: justify; line-height: 1.25; font-size: 11pt;">
                            Telah diperiksa, dengan keterangan bahwa pernyataan tersebut di atas benar dilakukan atas perintahnya atas semata-mata untuk kepentingan jabatan dalam waktu yang sesingkat-singkatnya.
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <!-- BARIS V: TANDA TANGAN (SEJAJAR) -->
        <tr>
            <td style="width: 50%; border: 1px solid #000; border-top: hidden !important; padding: 4px 6px 6px; vertical-align: bottom;">
                <table style="width: 100%; font-size: 11pt; line-height: 1.3;">
                    <tr>
                        <td style="text-align: center; font-weight: bold;">
                            Pejabat Pembuat Komitmen<br>
                            <?= esc($schoolSettings['school_name'] ?? '') ?>,
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 35px;"></td>
                    </tr>
                    <tr>
                        <td style="text-align: center;">
                            <strong style="text-decoration: underline;"><?= esc(format_person_name($schoolSettings['principal_name'] ?? '')) ?></strong><br>
                            NIP. <?= esc($schoolSettings['principal_nip'] ?? '-') ?>
                        </td>
                    </tr>
                </table>
            </td>
            <td style="width: 50%; border: 1px solid #000; border-top: hidden !important; padding: 4px 6px 6px; vertical-align: bottom;">
                <table style="width: 100%; font-size: 11pt; line-height: 1.3;">
                    <tr>
                        <td style="text-align: center; font-weight: bold;">
                            Pejabat Pembuat Komitmen<br>
                            <?= esc($schoolSettings['school_name'] ?? '') ?>,
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 35px;"></td>
                    </tr>
                    <tr>
                        <td style="text-align: center;">
                            <strong style="text-decoration: underline;"><?= esc(format_person_name($schoolSettings['principal_name'] ?? '')) ?></strong><br>
                            NIP. <?= esc($schoolSettings['principal_nip'] ?? '-') ?>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>

    <!-- V. CATATAN LAIN-LAIN -->
    <table style="width: 100%; border-collapse: collapse; border: 1px solid #000; margin-bottom: 8px; font-size: 11pt;">
        <tr>
            <td style="padding: 4px; line-height: 1.3; vertical-align: top;">
                <strong>V. CATATAN LAIN-LAIN:</strong>
                <div style="height: 15px;"></div>
            </td>
        </tr>
    </table>

    <!-- VI. PERHATIAN -->
    <div style="font-size: 11pt; line-height: 1.35; text-align: justify; border: 1px solid #000; padding: 5px; border-radius: 4px; background-color: #f8f9fa;">
        <strong>VI. PERHATIAN:</strong> Pejabat yang berwenang menerbitkan SPD, pegawai yang melakukan perjalanan dinas, para pejabat yang mengesahkan tanggal keberangkatan/kedatangan serta bendahara pengeluaran bertanggung jawab berdasarkan peraturan-peraturan Keuangan Negara apabila negara mendapat kerugian akibat kesalahan, kelalaian, dan kealpaannya.
    </div>
</div>


<!-- =============================================
     LEMBAR 3: LAPORAN HASIL PERJALANAN DINAS
     ============================================= -->
<div id="sppd-laporan" style="padding-top: 10px; font-family: 'Bookman Old Style', Bookman, Georgia, serif; font-size: 11pt; line-height: 1.45;">
    <div style="text-align: center; margin-bottom: 15px; font-weight: bold; text-decoration: underline; font-size: 11pt;">
        LAPORAN HASIL PERJALANAN DINAS
    </div>

    <table style="width: 100%; border-collapse: collapse; margin-bottom: 15px; font-size: 11pt; line-height: 1.65;">
        <tr>
            <td style="width: 220px; vertical-align: top;">Pegawai yang melaksanakan tugas</td>
            <td style="width: 15px; vertical-align: top;">:</td>
            <td style="font-weight: bold; vertical-align: top;"><?= esc(format_person_name($log['officer_name'] ?? '')) ?></td>
        </tr>
        <tr>
            <td style="vertical-align: top;">Nomor / Tanggal SPPD</td>
            <td style="vertical-align: top;">:</td>
            <td style="vertical-align: top;"><?= esc($log['letter_number']) ?> / <?= format_tanggal_indonesia($log['letter_date']) ?></td>
        </tr>
        <tr>
            <td style="vertical-align: top;">Pejabat yang memerintahkan</td>
            <td style="vertical-align: top;">:</td>
            <td style="vertical-align: top;">Kepala <?= esc($schoolSettings['school_name'] ?? '') ?></td>
        </tr>
        <tr>
            <td style="vertical-align: top;">Dasar perjalanan dinas</td>
            <td style="vertical-align: top;">:</td>
            <td style="vertical-align: top;"><?= esc($log['budget_source'] ?? '-') ?></td>
        </tr>
        <tr>
            <td style="vertical-align: top;">Tempat tujuan</td>
            <td style="vertical-align: top;">:</td>
            <td style="vertical-align: top;"><?= esc($log['origin'] ?? '-') ?></td>
        </tr>
        <tr>
            <td style="vertical-align: top;">Maksud perjalanan dinas</td>
            <td style="vertical-align: top;">:</td>
            <td style="vertical-align: top;"><?= esc($log['task_description'] ?? '-') ?></td>
        </tr>
        <tr>
            <td style="vertical-align: top;">Lama perjalanan dinas</td>
            <td style="vertical-align: top;">:</td>
            <td style="vertical-align: top;"><?= $hariCount ?> hari</td>
        </tr>
        <tr>
            <td style="vertical-align: top;">Tanggal berangkat</td>
            <td style="vertical-align: top;">:</td>
            <td style="vertical-align: top;"><?= format_tanggal_indonesia($start) ?></td>
        </tr>
    </table>

    <div style="font-weight: bold; margin-bottom: 6px;">Hasil perjalanan dinas:</div>
    <div style="margin-bottom: 20px; line-height: 2.0;">
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
        <p style="margin: 0; line-height: 2.0; font-family: 'Bookman Old Style', serif; font-size: 11pt;">...............................................................................................................................................................</p>
    </div>

    <table style="width: 100%; margin-top: 40px; font-size: 11pt; line-height: 1.35;">
        <tr>
            <td style="width: 50%; text-align: center; vertical-align: top;">
                <div>Pejabat atasan langsung</div>
                <div style="height: 55px;"></div>
                <div>
                    <strong style="text-decoration: underline;"><?= esc(format_person_name($schoolSettings['principal_name'] ?? '')) ?></strong>
                </div>
                <div>NIP. <?= esc($schoolSettings['principal_nip'] ?? '-') ?></div>
            </td>
            <td style="width: 50%; text-align: center; vertical-align: top;">
                <div>Pegawai yang melaksanakan tugas</div>
                <div style="height: 55px;"></div>
                <div>
                    <strong style="text-decoration: underline;"><?= esc(format_person_name($log['officer_name'] ?? '')) ?></strong>
                </div>
                <?php if (!empty($log['officer_nip'])): ?>
                <div><?= esc($log['teacher_id_label'] ?? 'NIP') ?>. <?= esc($log['officer_nip']) ?></div>
                <?php endif; ?>
            </td>
        </tr>
    </table>
</div>
</div>

<?= $this->endSection() ?>