<?php
$coun = count($detail);

if ($konsumen['no_hp'] == '-') {
    $no_hp = '-';
} else {
    $no_hp = hp_1(hp_2($konsumen['no_hp']));
    $no_hp = phone_number($no_hp);
}
$tdetail -= $potongan_harga;
if ($tdetail == $total->total and $pajak == 0) {
    $stamp = $lunas;
    $alt = '';
    $logo = $logo_lunas;
    $color = $dropship['warna_lunas'];
    $_waicon = $waicon['color'];
    $_mail = $mail['color'];
    $_fbicon = $fbicon['color'];
    $_igicon = $igicon['color'];
} elseif ($tdetail == $total->total and $pajak > 0) {
    $stamp = $lunas;
    $alt = '';
    $logo = $logo_lunas;
    $color = $dropship['warna_lunas'];
    $_waicon = $waicon['color'];
    $_mail = $mail['color'];
    $_fbicon = $fbicon['color'];
    $_igicon = $igicon['color'];
} elseif ($tdetail != $total->total and $pajak == 0) {
    $stamp = $blunas;
    $alt = '';
    $logo = $logo_blunas;
    $color = $dropship['warna_blunas'];
    $_waicon = $waicon['bw'];
    $_mail = $mail['bw'];
    $_fbicon = $fbicon['bw'];
    $_igicon = $igicon['bw'];
} elseif ($tdetail != $total->total and $pajak > 0) {
    $stamp = $blunas;
    $alt = '';
    $logo = $logo_blunas;
    $color = $dropship['warna_blunas'];
    $_waicon = $waicon['bw'];
    $_mail = $mail['bw'];
    $_fbicon = $fbicon['bw'];
    $_igicon = $igicon['bw'];
} else {
    $stamp = $blunas;
    $alt = '';
    $logo = $logo_blunas;
    $color = $dropship['warna_blunas'];
    $_waicon = $waicon['bw'];
    $_mail = $mail['bw'];
    $_fbicon = $fbicon['bw'];
    $_igicon = $igicon['bw'];
}
if ($cetak->status == 'batal') {
    $stamp = '';
    $alt = 'BATAL';
    $color = '#333';
    $_waicon = $waicon['bw'];
    $_mail = $mail['bw'];
    $_fbicon = $fbicon['bw'];
    $_igicon = $igicon['bw'];
}

?>
<!doctype html>
<html>

    <head>
        <meta charset="utf-8">
        <title>Cetak Invoice</title>
        <link href="<?php echo $favicon; ?>" rel="icon">
        <style>
        @page {
            margin: 0.5cm 0 0 0;
        }

        body {
            margin-top: 0cm;
            margin-left: 0.5cm;
            margin-right: 1cm;
            margin-bottom: 0cm;
            font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
        }

        <?php if ($html=='Y') {
            ?>.invoice-box {
                width: 200mm;
                margin: 0 auto;
                padding: 20px;
                font-size: <?php echo $font_size;
                ?>px;
                font-weight: <?php echo $font_wight;
                ?>;
                line-height: 18px;
                font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
                color: #555;
                background: #fff;
            }

            .gbr {
                width: 100%;
                position: relative;
                top: 30px
            }

            .gbr .qris {
                position: absolute;
                bottom: 0;
                left: 0;
                z-index: 100;
            }

            <?php
        }

        else {
            ?>.invoice-box {
                width: 100%;
                margin: 0 auto;
                padding: 10px;
                font-size: <?php echo $font_size;
                ?>px;
                font-weight: <?php echo $font_wight;
                ?>;
                line-height: 18px;
                font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
                color: #555;
            }

            .qris {
                position: absolute;
                bottom: 50px;
                left: 20px;
                z-index: 100
            }

            <?php
        }

        ?>

        /** Define the footer rules **/
        footer {

            position: fixed;
            bottom: 0cm;
            left: 0cm;
            right: 0cm;
            height: 0.5cm;
            padding: 5px;

            /** Extra personal styles **/
            background-color: <?php echo $color;
            ?>;
            color: white;
            text-align: center;
        }

        .invoice-box table {
            width: 100%;
            line-height: inherit;
            text-align: left;
        }

        .invoice-box table td {
            padding: 0 5px 0 5px;
            vertical-align: top;
        }

        .invoice-box table tr td:nth-child(2) {}

        .invoice-box table tr.top table td {
            padding-bottom: 0;
        }

        .invoice-box table tr.top table td.title {
            font-size: 45px;
            line-height: 45px;
            color: #333;
        }

        .invoice-box table tr.information table td {}

        .invoice-box table tr.heading td {
            background: <?php echo $color;
            ?>;
            color: #fff;
            font-weight: normal;
            padding: 5px;
            text-transform: uppercase;
        }

        .invoice-box table tr.details td {
            padding-bottom: 20px;
        }

        .invoice-box table tr.item td {
            border-bottom: 1px solid <?php echo $color;
            ?>;
        }

        .invoice-box table tr.item td {
            border-bottom: 1px solid <?php echo $color;
            ?>;
        }

        .invoice-box table tr.item1:first-child td {
            border-bottom: 1px dotted <?php echo $color;
            ?>;
        }

        .invoice-box table tr.item2:first-child td {
            border-bottom: 1px solid <?php echo $color;
            ?>;
        }

        .invoice-box table tr.item2:last-child td {
            border-top: 1px dotted <?php echo $color;
            ?>;
            border-bottom: 1px solid <?php echo $color;
            ?>;
        }

        .invoice-box table tr.kepada td {
            font-weight: bold;
            color: #fff;

        }


        .invoice-box table tr.item.last td {}

        .invoice-box table tr.total {
            font-weight: bold;
            text-align: right;
        }

        .invoice-box table tr.hormat {
            font-weight: bold;
            text-align: left;
        }

        .invoice-box table tr.pelanggan {
            font-weight: bold;
            text-align: center;
        }

        .invoice-box table td.total {
            text-align: right;
        }

        .invoice-box table td.tgl {
            font-weight: bold;
            border-bottom: 1px dotted #000;
        }

        .invoice-box table td.tkepada {
            background: <?php echo $color;
            ?>;
            width: 15% !important
        }

        .invoice-box table tr.alamat {
            color: #000;
            width: 50% !important;
            vertical-align: top !important;
        }

        .invoice-box table tr.kepada td.tkepada {
            border-bottom: 1px dotted #fff;
        }

        .invoice-box table tr.kepada td.talamat {
            background: <?php echo $color;
            ?>;
            width: 12% !important border-bottom:2px solid <?php echo $color;
            ?>;
        }

        .invoice-box table tr.kepada td.bawah {
            color: #000;
            border-bottom: 1px dotted #000;
            font-weight: normal;
            width: 25% !important
        }

        .invoice-box table tr.alamat td.nomor {
            font-weight: bold;
            vertical-align: text-bottom !important;
        }

        .invoice-box table td.total1 {
            border-left: 1px solid <?php echo $color;
            ?>;
            border-top: 1px solid <?php echo $color;
            ?>;
            border-bottom: 1px dotted <?php echo $color;
            ?>;
        }

        .invoice-box table td.total2 {
            border-top: 1px solid <?php echo $color;
            ?>;
            border-right: 1px solid <?php echo $color;
            ?>;
            border-bottom: 1px dotted <?php echo $color;
            ?>;
            text-align: right;
            font-weight: bold;
        }

        .invoice-box table td.lunas1 {
            border-left: 1px solid <?php echo $color;
            ?>;
            border-bottom: 1px solid <?php echo $color;
            ?>;
            background: <?php echo $color;
            ?>;
            color: #fff;
        }

        .invoice-box table td.lunas2 {
            border-right: 1px solid <?php echo $color;
            ?>;
            border-bottom: 1px solid <?php echo $color;
            ?>;
            text-align: right;
            font-weight: bold;
            background: <?php echo $color;
            ?>;
            color: #fff;
        }

        .invoice-box table td.umuka1 {
            border-left: 1px solid <?php echo $color;
            ?>;
            border-bottom: 1px dotted <?php echo $color;
            ?>;
        }

        .invoice-box table td.umuka2 {
            border-right: 1px solid <?php echo $color;
            ?>;
            border-bottom: 1px dotted <?php echo $color;
            ?>;
            text-align: right;
            font-weight: bold;
        }

        .invoice-box table td.sisa1 {
            border-left: 1px solid <?php echo $color;
            ?>;
            border-bottom: 1px solid <?php echo $color;
            ?>;
        }

        .invoice-box table td.sisa2 {
            border-right: 1px solid <?php echo $color;
            ?>;
            border-bottom: 1px solid <?php echo $color;
            ?>;
            text-align: right;
            font-weight: bold;
        }

        .invoice-box table td.ttd {
            border-bottom: 1px dotted <?php echo $color;
            ?>;
            text-align: center;
            font-weight: bold;
        }

        .invoice-box table td.border {
            border-right: 1px dotted <?php echo $color;
            ?>;
        }


        .invoice-box .table img {
            position: fixed;
            z-index: -1000;
            width: 200px;
        }

        .watermark {
            top: -100px;
            left: 25%;
            margin: 0;
            auto;
            width: 4.5cm;
            height: auto;
            opacity: 0.2;
            position: relative;
            z-index: 10;

            /** Your watermark should be behind every content**/
        }

        .alamat {
            font-size: 11pt;
        }

        .sosmed {
            font-size: 8pt;
        }
        </style>
        <?php if ($html == 'Y') { ?>
        <style>
        @media print {
            .invoice-box {
                width: 210mm;
                margin: auto;
                padding: 10px;
                font-size: <?php echo $font_size;
                ?>px;
                font-weight: <?php echo $font_wight;
                ?>;
                line-height: 18px;
                font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
                color: #555;
            }

            .invoice-box table {
                width: 100%;
                line-height: inherit;
                text-align: left;
            }

            .invoice-box table td {
                padding: 0 5px 0 5px;
                vertical-align: top;
            }

            .invoice-box table tr td:nth-child(2) {}

            .invoice-box table tr.top table td {
                padding-bottom: 0;
            }

            .invoice-box table tr.top table td.title {
                font-size: 45px;
                line-height: 45px;
                color: #333;
            }

            .invoice-box table tr.information table td {}

            .invoice-box table tr.heading td {
                background: #<?php echo $color;
                ?>;
                color: #fff;
                font-weight: normal;
                padding: 5px;
                text-transform: uppercase;
            }

            .invoice-box table tr.details td {
                padding-bottom: 20px;
            }

            .invoice-box table tr.item td {
                border-bottom: 1px solid #000;

            }

            .invoice-box table tr.kepada td {
                font-weight: bold;
                color: #fff;
            }

            .invoice-box table tr.item.last td {}

            .invoice-box table tr.total {
                font-weight: bold;
                text-align: right;
            }

            .invoice-box table tr.hormat {
                font-weight: bold;
                text-align: left;
            }

            .invoice-box table tr.pelanggan {
                font-weight: bold;
                text-align: center;
            }

            .invoice-box table td.total {
                text-align: right;
            }

            .invoice-box table td.tgl {
                font-weight: bold;
                border-bottom: 1px dotted #000;
            }

            .invoice-box table td.tkepada {
                background: #<?php echo $color;
                ?>;
                width: 15% !important
            }

            .invoice-box table tr.kepada td.bawah {
                color: #000;
                width: 25% !important
            }

            .invoice-box table td.nomor {
                font-weight: bold;
            }

            .invoice-box table td.total1 {
                border-left: 1px solid <?php echo $color;
                ?>;
                border-top: 1px solid <?php echo $color;
                ?>;
                border-bottom: 1px dotted <?php echo $color;
                ?>;
            }

            .invoice-box table td.total2 {
                border-top: 1px solid <?php echo $color;
                ?>;
                border-right: 1px solid <?php echo $color;
                ?>;
                border-bottom: 1px dotted <?php echo $color;
                ?>;
                text-align: right;
                font-weight: bold;
            }

            .invoice-box table td.lunas1 {
                border-left: 1px solid <?php echo $color;
                ?>;
                border-bottom: 1px solid <?php echo $color;
                ?>;
            }

            .invoice-box table td.lunas2 {
                border-right: 1px solid <?php echo $color;
                ?>;
                border-bottom: 1px solid <?php echo $color;
                ?>;
                text-align: right;
                font-weight: bold;
            }

            .invoice-box table td.umuka1 {
                border-left: 1px solid <?php echo $color;
                ?>;
                border-bottom: 1px dotted <?php echo $color;
                ?>;
            }

            .invoice-box table td.umuka2 {
                border-right: 1px solid <?php echo $color;
                ?>;
                border-bottom: 1px dotted <?php echo $color;
                ?>;
                text-align: right;
                font-weight: bold;
            }

            .invoice-box table td.sisa1 {
                border-left: 1px solid <?php echo $color;
                ?>;
                border-bottom: 1px solid <?php echo $color;
                ?>;
            }

            .invoice-box table td.sisa2 {
                border-right: 1px solid <?php echo $color;
                ?>;
                border-bottom: 1px solid <?php echo $color;
                ?>;
                text-align: right;
                font-weight: bold;
            }

            .invoice-box table td.ttd {
                border-bottom: 1px dotted #000;
                text-align: center;
                font-weight: bold;
            }

            .invoice-box table td.border {
                border-right: 1px dotted #000;
            }


            .invoice-box .table img {
                position: fixed;
                z-index: -1000;
            }

            .watermark {
                width: 4.5cm;
                height: auto;
                opacity: 0.2;
                position: absolute;
                z-index: 10;

                /** Your watermark should be behind every content**/
            }

            .sosmed {
                font-size: 8pt;
            }
        }
        </style>
        <script type="text/javascript">
        <!--
        window.print();
        window.onfocus = function() {
            window.close();
        }
        //
        -->
        </script>
        <?php }

        $deskripsi = $dropship['alamat_toko'];

$wa = $email = $_fb = $fb = '';
if ($dropship['telp_toko'] != '-') {
    $_wa = '<img src="'.$_waicon.'" alt="" height="10" />';
    $wa = $info['phone'];
}
if ($dropship['email_toko'] != '-') {
    $_email = '<img src="'.$_mail.'" alt="" height="10" />';
    $email = $dropship['email_toko'];
}

$_ig = '';
$ig = '';

if ($konsumen['tampil'] == 1) {
    $nama = $konsumen['perusahaan'];
    $perusahaan = cek_jenis_lembaga($konsumen['jenis']);
    $telp = phone_number($konsumen['no_telp']);
    $alamat = $konsumen['alamat_lembaga'];
} else {
    $nama = $konsumen['nama'];
    $perusahaan = cek_jenis_lembaga($konsumen['jenis']);
    $telp = phone_number($konsumen['no_hp']);
    $alamat = $konsumen['alamat'];
}
if (!empty($dropship['alamat_surat'])) {
    $alamat_surat = $dropship['alamat_surat'];
} else {
    $alamat_surat = $info['keywords'];
}
?>
        <style>
        img.logo {
            max-width: 400px;
            max-height: 100px
        }
        </style>
    </head>

    <body>
        <?php if ($show_footer == 0) { ?>
        <footer>
            <?php echo $dropship['nama_toko']; ?> © <?php echo date('Y'); ?>
        </footer>
        <?php } ?>
        <div class="invoice-box">

            <table width="100%" cellpadding="0" cellspacing="0">
                <tr class="alamat">
                    <td colspan="4" rowspan="7" valign="top" style="width:50%!important">
                        <img class="logo" src="<?php echo $logo; ?>" alt="" /><br>
                        <span class="alamat"><?php echo $deskripsi; ?></span><br>
                        <?php echo $_wa; ?>&nbsp;<span
                            class="sosmed"><?php echo $wa; ?></span>&nbsp;<?php echo $_email; ?>&nbsp;<span
                            class="sosmed"><?php echo $email; ?></span>&nbsp;<?php echo $_fb; ?>&nbsp;<span
                            class="sosmed"><?php echo $fb; ?></span>&nbsp;<?php echo $_ig; ?>&nbsp;<span
                            class="sosmed"><?php echo $ig; ?></span>
                    </td>
                    <td colspan="2" class="tgl"><?php echo $alamat_surat; ?>,
                        <?php echo date_time($cetak->tgl_trx, false); ?> | Jam Order: <?php echo invoice_order_time($cetak); ?></td>
                </tr>
                <tr class="kepada">
                    <td class="tkepada">Kepada Yth.</td>
                    <td width="72" class="bawah"><?php echo $nama; ?></td>
                </tr>
                <tr class="kepada">
                    <td class="tkepada">Perusahaan</td>
                    <td class="bawah"><?php echo $perusahaan; ?></td>
                </tr>
                <tr class="kepada">
                    <td class="tkepada">Telp</td>
                    <td class="bawah"><?php echo $telp; ?></td>
                </tr>
                <tr class="kepada">
                    <td class="talamat">Alamat</td>
                    <td rowspan="2" class="bawah"><?php echo $alamat; ?></td>
                </tr>
                <tr class="kepada">
                    <td class="tkepada">&nbsp;</td>
                </tr>
                <tr class="alamat">
                    <td colspan="2" class="nomor">NO. ORDER #<?php echo $cetak->id_transaksi; ?></td>
                </tr>
            </table>

            <table style="width:100%;margin-top:5px" cellpadding="0" cellspacing="0">
                <tr class="heading">
                    <td style="width:15%!important">Produk</td>
                    <td style="width:20%!important">Nama_Barang/Merk</td>
                    <td>Keterangan</td>
                    <td align="left" style="width:10%!important">Ukuran</td>
                    <td align="center" style="width:8%!important">qty</td>
                    <td style="width:10%!important;text-align:right">Harga</td>
                    <?php if ($cdiskon > 0) { ?>
                    <td style="width:5%!important;text-align:right">Disc%</td>
                    <?php } ?>
                    <td class="total" style="width:16%!important">Total harga</td>
                </tr>
                <?php
            $no = 1;
$totalb = 0;
$_totalb = 0;
$subtotal = 0;
$_subtotal = 0;
$sisa = 0;
$diskon = 0;
$tambahan = 0;
$finishing = '';
foreach ($detail as $val) {
    $diskon = $val['jumlah'] * $val['harga'] * $val['diskon'] / 100;
    $tambah_harga = ($val['harga'] * $dropship['persen']) / 100;
    $harga = $val['harga'] + $tambah_harga;
    $totalb = $val['jumlah'] * $harga - $diskon;
    $_subtotal += $totalb;
    $_totalb = $val['jumlah'] * $val['harga'] - $diskon;
    $subtotal += $_totalb;
    $tambahan = $tambah_harga;

    if (!empty($finishing)) {
        $item1 = 'item1';
        $item2 = 'item2';
    } else {
        $item1 = 'item';
        $item2 = 'item';
    }
    $satuan = '';
    if ($val['status_hitung'] == 0) {
        $satuan = get_satuan($val['satuan']);
    }

    ?>
                <tr class="<?php echo $item1; ?>">
                    <td class="border"><?php echo $val['title']; ?></td>
                    <td class="border"><?php echo $val['nbahan']; ?></td>
                    <td class="border"><?php echo $val['keterangan']; ?></td>
                    <td class="border" align="left"><?php echo $val['ukuran']; ?></td>
                    <td align="center" class="border"><?php echo $val['jumlah']; ?> <?php echo $satuan; ?></td>
                    <td class="border" align="right"><?php echo rp($harga); ?></td>
                    <?php if ($cdiskon > 0) { ?>
                    <td class="border" align="right"><?php echo rp($val['diskon']); ?></td>
                    <?php } ?>
                    <td class="total"><?php echo rp($totalb); ?></td>
                </tr>
                <?php
        if (!empty($val['detail'])) {
            $finishing = json_decode($val['detail']);

            if (!empty($finishing)) {
                ?>
                <tr class="<?php echo $item2; ?>">
                    <td colspan="5">
                        <?php

                            echo 'Catatan : ';
                foreach ($finishing->data as $key => $vals) {
                    echo ' | '.$vals->isi.' | ';
                }

                ?>
                    </td>
                </tr>
                <?php }
            }
    ++$no;
}
$pajak = ($subtotal * $cetak->pajak) / 100;
$sisa = $pajak + $subtotal - $total->total - $potongan_harga;
$cek_bayar = $pajak + $subtotal;
$numItems = count($bdetail);
$rowspan = $numItems + 2;
?>

            </table>

            <table class="table" style="width:100%;margin-top:10px" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="11%" rowspan="<?php echo $rowspan; ?>" align="left" style="width:35%!important"><?php
        if ($alt == 'BATAL') {
            echo "<span style='color:red'>ORDER DI BATALKAN</span>";
        } else {
            echo 'BAYAR :';
            if ($total->total != 0) {
                if (isset($cara)) {
                    echo strtoupper($cara->nama_bayar);
                }
            } else {
                echo 'PIUTANG';
            }
        }
        if ($cashback > 0) {
            echo ' | CASHBACK : '.rp($cashback);
        }
?><br>
                        <?php if (!empty($dropship['rekening_toko'])) { ?>

                        <span style="font-size:8pt;line-height:12px">
                            No. Rekening : <BR><?php echo $dropship['rekening_toko']; ?>
                        </span>
                        <?php } ?>
                    </td>
                    <td width="17%" align="center" style="width:20%!important">HORMAT KAMI</td>
                    <td width="0%">&nbsp;</td>
                    <td width="21%" align="center" style="width:20%!important">PEMESAN</td>
                    <td width="1%">&nbsp;</td>
                    <td width="9%" class="total1" style="width:12%">Total Order</td>
                    <td width="16%" class="total2" style="width:19%"><?php echo rp($_subtotal); ?></td>
                </tr>

                <?php if ($cetak->pajak > 0) {?>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td class="umuka1">Pajak <?php echo $cetak->pajak; ?>%</td>
                    <td class="umuka2"><?php echo rp($pajak); ?></td>
                </tr>
                <?php } ?>
                <?php if ($potongan_harga > 0) {?>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td class="umuka1">Diskon </td>
                    <td class="umuka2"><?php echo rp($potongan_harga); ?></td>
                </tr>
                <?php } ?>
                <?php
$urutan = 0;

$i = 0;
$ni = 1;
$_jumlah_bayar = 0;
$jml_bayar = 0;
$lunas = false;
foreach ($bdetail as $val) {
    $_jumlah_bayar = $val['jml_bayar'] + $tambahan;
    if ($sisa == 0 and $cdetail == 1 and $val['jml_bayar'] == $cek_bayar) {
        if ($jumlah_bayar > $total->total) {
            $jumlah_bayar += $tambahan;
        } else {
            $jumlah_bayar = $total->total + $tambahan;
        }
        echo '<tr class="lunas">
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td class="umuka1">Jml. Bayar</td>
							<td class="umuka2">'.rp($jumlah_bayar).'</td>
							</tr>';
        echo '<tr class="lunas">
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td class="lunas1">Kembalian</td>
							<td class="lunas2">'.rp($kembalian).'</td>
							</tr>';
    } elseif ($sisa > 0 and $cdetail >= 1 and $val['jml_bayar'] != $cek_bayar) {
        echo '<tr>
							 
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td class="umuka1">Bayar ke-'.$ni.'</td>
							<td class="umuka2">'.rp($val['jml_bayar']).'</td>
							</tr>';
    } else {
        echo '<tr>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>';
        if ($cdetail > 1 and $total->total != $cek_bayar) {
            echo '<td class="umuka1">Bayar ke-'.$ni.'</td>';
        } elseif ($cdetail > 1 and $total->total == $cek_bayar) {
            if (++$i === $numItems) {
                $lunas = true;
                $jml_bayar = $val['jml_bayar'];
                if ($jumlah_bayar > $val['jml_bayar']) {
                    $_jumlah_bayar = $jumlah_bayar + $tambahan;
                }
                echo '<td class="umuka1">Pelunasan</td>';
            } else {
                echo '<td class="umuka1">Bayar ke-'.$ni.'</td>';
            }
        } else {
            echo '<td class="umuka1">Pelunasan</td>';
        }

        echo '<td class="umuka2">'.rp($_jumlah_bayar).'</td>
							</tr>';
    }
    ++$ni;
}

if ($jumlah_bayar > $jml_bayar and $lunas == true) {
    $jumlah_bayar = $jumlah_bayar;

    ?>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td class="lunas1">Kembalian</td>
                    <td class="lunas2"><?php echo rp($kembalian); ?></td>
                </tr>
                <?php } ?>
                <tr>
                    <?php
        if ($jumlah_bayar > $jml_bayar and $lunas == true and $ni > 3) { ?>
                    <td>&nbsp;</td>
                    <?php } ?>
                    <td class="ttd"><?php echo $dropship['nama_ttd']; ?></td>
                    <td>&nbsp;</td>
                    <td class="ttd"><?php echo $konsumen['nama']; ?></td>
                    <td>&nbsp;</td>

                    <?php if ($sisa > 0) { ?>
                    <td class="sisa1">Piutang</td>
                    <td class="sisa2"><?php echo rp($sisa+$tambahan); ?></td>
                    <?php } else { ?>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <?php } ?>
                </tr>
                <tr>
                    <td colspan="8" align="right" style="font-size:6pt">dicetak pada
                        <?php echo dtimes(date('Y-m-d H:i:s')); ?> | <?php if (isset($cara)) {
                            echo $cetak->cetak.' x cetak';
                        } ?></td>
                </tr>
                <tr>
                    <?php if ($alt == 'BATAL') { ?>
                    <td colspan="8" align="right" style="font-size:12pt;width:30%!important;line-height:12pt;color:red">
                        Keterangan : <?php echo $cetak->history; ?>
                    </td>
                    <?php } else { ?>
                    <td colspan="8" align="right" style="font-size:6pt;width:30%!important;line-height:6pt">
                        <?php echo base64_decode($info['footer_invoice']); ?>
                    </td>
                    <?php } ?>
                </tr>
            </table>
			<img class="watermark" src="<?php echo $stamp; ?>" width="100px" alt="" />
			<?php if (!empty($qr_available)) { ?>
			<div class="gbr">
				<?php if (!empty($qr_is_tracking)) { ?><div style="position:absolute;bottom:108px;left:0;width:180px;text-align:center;font-size:8pt;font-weight:600;"><?=htmlspecialchars($qr_label, ENT_QUOTES, 'UTF-8');?></div><?php } ?>
				<img class="qris" src="<?=$kode_qris;?>" width="100px" height="100px" alt="" />
			</div>
			<?php } ?>

        </div>
    </body>

</html>
