<html>

<head>
    <title>Invoice Pembayaran</title>
    <style>
    #tabel {
        font-size: 15px;
        border-collapse: collapse;
    }

    #tabel td {
        padding-left: 5px;
        border: 1px solid black;
    }
    </style>
</head>

<?php
function penyebut($nilai)
{
    $nilai = abs($nilai);
    $huruf = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
    $temp = "";
    if ($nilai < 12) {
        $temp = " " . $huruf[$nilai];
    } else if ($nilai < 20) {
        $temp = penyebut($nilai - 10) . " belas";
    } else if ($nilai < 100) {
        $temp = penyebut($nilai / 10) . " puluh" . penyebut($nilai % 10);
    } else if ($nilai < 200) {
        $temp = " seratus" . penyebut($nilai - 100);
    } else if ($nilai < 1000) {
        $temp = penyebut($nilai / 100) . " ratus" . penyebut($nilai % 100);
    } else if ($nilai < 2000) {
        $temp = " seribu" . penyebut($nilai - 1000);
    } else if ($nilai < 1000000) {
        $temp = penyebut($nilai / 1000) . " ribu" . penyebut($nilai % 1000);
    } else if ($nilai < 1000000000) {
        $temp = penyebut($nilai / 1000000) . " juta" . penyebut($nilai % 1000000);
    } else if ($nilai < 1000000000000) {
        $temp = penyebut($nilai / 1000000000) . " milyar" . penyebut(fmod($nilai, 1000000000));
    } else if ($nilai < 1000000000000000) {
        $temp = penyebut($nilai / 1000000000000) . " trilyun" . penyebut(fmod($nilai, 1000000000000));
    }
    return $temp;
}

function terbilang($nilai)
{
    if ($nilai < 0) {
        $hasil = "minus " . trim(penyebut($nilai));
    } else {
        $hasil = trim(penyebut($nilai));
    }
    return $hasil;
}

?>

<body style='font-family:tahoma; font-size:12pt;'>
    <table cellspacing='0' style='width: 100%; font-size:12pt; font-family:calibri;  border-collapse: collapse;'
        border='0'>
        <tr>
            <td width='50%'><img src="<?= base_url('assets/') ?>img/logo_invoice.png" width="80%" alt="avatar"></td>
            <td></td>
            <td width='50%' style="text-align: right;"><b style="font-size: 25pt;">Kwitansi Pembayaran</b>
            </td>
        </tr>
        <!-- Rincian Data Beli -->
        <tr>
            <td width='50%'>
                Anggota : <?= substr($data_invoice['nm_anggota'], 0, 15) ?></br>
                No Telp : <?= $data_invoice['no_hp'] ?>
            </td>
            <td></td>
            <td width='50%' style='text-align:right'>#<?= $data_invoice['kd_invoice'] ?></br>
                <?= date('d', strtotime($data_invoice['tgl_pembayaran']))  ?>
                <?= $this->mycustom->bulanIndo(date('m', strtotime($data_invoice['tgl_pembayaran'])))  ?>
                <?= date('Y', strtotime($data_invoice['tgl_pembayaran']))  ?>
            </td>
        </tr>
    </table><br>
    <table cellspacing='0' style='width: 100%; font-size:12pt; font-family:calibri;  border-collapse: collapse;'
        border='0'>
        <tr>
            <td width='50%' style='text-align:center'>Keterangan</td>
            <td width='25%' style='text-align:center'>Iuran</td>
            <td width='25%' style='text-align:center'>Total Harga</td>
        </tr>
        <!-- Rincian Data Beli -->
        <?php foreach ($data_rinci as $Data_rinci) : ?>
        <tr>
            <td>
                <?php if ($Data_rinci->produk_id == '21') : ?>
                Iuran Kelompok <?= $Data_rinci->nm_kelompok ?> Arisan Heboh <br>
                Regist Undian <?= $Data_rinci->regist_undian ?>; Undian Ke - <?= $Data_rinci->undian_ke ?>
                <?php else : ?>
                Iuran Arisan Motor <?= $Data_rinci->ket_arisan ?> Ke - <?= $Data_rinci->nm_kelompok ?><br>
                Undian Ke - <?= $Data_rinci->undian_ke ?>; Lelang Ke - <?= $Data_rinci->lelang_ke ?>
                <?php endif; ?>
            </td>
            <td style='text-align:right'><?= number_format($Data_rinci->bayar, 0, ',', '.') ?>,-</td>
            <td style='text-align:right'><?= number_format($Data_rinci->bayar, 0, ',', '.') ?>,-</td>
        </tr>
        <?php endforeach; ?>
        <tr>
            <td></td>
            <td></td>
            <td><br></td>
        </tr>
        <tr>
            <td style="text-align: center;">
            </td>
            <td>
                <div style='text-align:right'>Total : </div>
            </td>
            <td style='text-align:right'><?= number_format($data_invoice['ttl_bayar'], 0, ',', '.') ?>,-</td>
        </tr>
        <tr>
            <td></td>
            <td><br></td>
        </tr>
    </table>
    <table cellspacing='0' style='width: 100%; font-size:12pt; font-family:calibri;  border-collapse: collapse;'
        border='0'>
        <tr>
            <td width='35%' align='center'>Diterima Oleh,</br></br><u>( <?= $data_marketing['nm_panggilan'] ?> )</u>
            </td>
            <td width='30%' style="text-align: center;">
                <img src="<?= base_url('assets/') ?>img/stempel_diterima.png" width="100%" alt="avatar">
            </td>
            <td width='35%' align='center'>
                Kasir,</br></br><u>( <?= $data_kasir['nm_panggilan'] ?> )</u>
            </td>
        </tr>
    </table>
    <!-- Hapus -->
</body>

</html>