<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cetak Termal</title>
    <style>
        /* CSS Umum */
        body {
            font-family: Arial, sans-serif;
            font-size: 8px;
            margin: 0;
            padding: 0;
            width: 58mm;
            /* Lebar standar printer termal */
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        .header,
        .footer {
            text-align: center;
        }

        .line {
            border-top: 1px dashed #000;
            margin: 5px 0;
        }

        .terbilang {
            font-style: italic;
            font-size: 11px;
        }

        .ppn {
            font-style: italic;
            font-size: 11px;
        }

        /* Kolom Deskripsi dan Harga */
        .table-item td {
            vertical-align: top;
        }

        .description {
            width: 60%;
            /* Deskripsi lebih lebar */
            word-wrap: break-word;
        }

        .qty {
            width: 10%;
            /* Lebar qty */
            text-align: center;
        }

        .price {
            width: 30%;
            /* Harga lebih sempit */
            text-align: right;
        }
    </style>
</head>

<body>
    <!-- Header -->
    <div class="header">
        <img src="<?= base_url('images/logo.png'); ?>" width="50" height="30">
        <b><?= $abdulradjak['NamaPerusahaan']; ?></b><br>
        <?= $abdulradjak['AlamatPerusahaan']; ?><br>
        <small>Telp: <?= $abdulradjak['TeleponPerusahaan']; ?>, Fax: <?= $abdulradjak['FaxPerusahaan']; ?></small>
    </div>
    <div class="line"></div>

    <!-- Detail Pasien -->
    <table style=" font-size: 10px">
        <tr>
            <td>Case ID</td>
            <td>: <?= $dt['Case ID']; ?></td>
        </tr>
        <tr>
            <td>Nama</td>
            <td>: <?= $dt['PatientName']; ?></td>
        </tr>
        <tr>
            <td>Tgl Kunjungan</td>
            <td>: <?= date('d-m-Y', strtotime($dt['Intake Date'])); ?></td>
        </tr>
        <tr>
            <td>Tgl Close</td>
            <td>: <?= date('d-m-Y', strtotime($dt['Closed Date'])); ?></td>
        </tr>
        <tr>
            <td>Penjamin</td>
            <td>: <?= $dt['CompanyName']; ?></td>
        </tr>
    </table>
    <div class="line"></div>

    <!-- Detail Transaksi -->
    <table class="table-item" style=" font-size: 10px">
        <thead>
            <tr>
                <th class="description">Deskripsi</th>
                <th class="qty">Qty</th>
                <th class="price">Harga</th>
            </tr>
        </thead>
        <tbody>
            <?php
            $sum = 0;
            $charge = 0;
            foreach ($StatmentDetail as $d):
                $sum += $d['Ppn'];
                $charge += $d['Charge'];
                $total = $sum + $charge;
            ?>
                <tr>
                    <td class="description"><?= $d['Description']; ?></td>
                    <td class="qty"><?= $d['Qty']; ?></td>
                    <td class="price"><?= number_format($d['Charge'], 0); ?></td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
    <div class="line"></div>

    <!-- Total -->
    <table style=" font-size: 10px">
        <tr>
            <td class="description">Total</td>
            <td class="qty"></td>
            <td class="price"><?= number_format($total, 0); ?></td>
        </tr>
        <tr>
            <td class="description">Bayar</td>
            <td class="qty"></td>
            <td class="price"><?= number_format($tpayment['AmountPaid'], 0); ?></td>
        </tr>
        <tr>
            <td class="description">Sisa Dibayar</td>
            <td class="qty"></td>
            <?php $topaid =  $tpayment['AmountPaid'] - $total; ?>
            <td class="price"><?= number_format($topaid, 0); ?></td>
        </tr>
    </table>
    <small style="">
        <p class="ppn">*Harga Sudah Termasuk PPN 11%</p>
    </small>
    <div class="line"></div>
    <table style="width: 100%;font-size:10px; ">
        <tr>
            <?php $tgl = date('Y-m-d'); ?>
            <td style="width: 50%; text-align: center;">
                Pasien <br>
                <?php
                $ttdUrl =  'http://public.radjakclinics.com/Klinik/Cengkareng/images/uploadsign/generalConsent/' . $ttd['tandatangan_1'];
                if (@getimagesize($ttdUrl)) {
                ?>
                    <img style="height: 70px;" src="<?= $ttdUrl; ?>" alt=""> <br>
                <?php } else {
                    echo "<br><br><br><br>";
                }
                ?>
                <?= $dt['PatientName']; ?>
            </td>
            <td style="width: 50%; text-align: center;">
                Jakarta, <?= date('d-m-Y'); ?><br>
                Diterima Oleh,<br><br><br>
                <u><?= $user['nama']; ?></u>
            </td>
        </tr>
    </table>
    <!-- Footer -->
    <!-- <div class="footer" style=" font-size: 10px">
        Jakarta, <?= date('d-m-Y'); ?><br>
        Diterima Oleh,<br><br><br>
        <u>Petugas Kasir</u>
    </div> -->
</body>

</html>