<div class="row layout-spacing">
    <div class="col-lg-12">
        <div class="statbox widget box box-shadow">
            <div class="widget-content widget-content-area">
                <table id="style-3" class="table style-3  table-hover">
                    <thead>
                        <tr>
                            <th class="text-center">Nomor</th>
                            <th class="text-center">Identitas</th>
                            <th class="text-center">Alamat</th>
                            <th class="text-center">Pinjaman</th>
                            <th class="text-center">Kontrak</th>
                            <th class="text-center">Jaminan</th>
                            <th class="text-center">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($pinjaman_lunas as $Data_lunas) : ?>
                        <tr>
                            <td class="text-left">
                                <?= $Data_lunas->kontrak_id ?><br>
                                <center>
                                    <?php if ($Data_lunas->status_kontrak == 'AKTIF') : ?>
                                    <span class="shadow-none badge badge-primary">AKTIF</span>
                                    <?php elseif ($Data_lunas->status_kontrak == 'MACET') : ?>
                                    <span class="shadow-none badge badge-danger">MACET</span>
                                    <?php elseif ($Data_lunas->status_kontrak == 'LUNAS_LANCAR') : ?>
                                    <span class="shadow-none badge badge-success">LUNAS</span>
                                    <?php elseif ($Data_lunas->status_kontrak == 'LUNAS_MACET') : ?>
                                    <span class="shadow-none badge badge-warning">LUNAS</span>
                                    <?php endif; ?>
                                </center>
                            </td>
                            <td class="text-left">
                                NIK : <?= $Data_lunas->nik ?><br>
                                Nama : <?= $Data_lunas->nm_anggota ?><br>
                                TTL : <?= $Data_lunas->tempat_lahir ?>,
                                <?= date('d', strtotime($Data_lunas->tgl_lahir)) . ' ' . $this->mycustom->bulanIndo(date('m', strtotime($Data_lunas->tgl_lahir))) . ' ' .  date('Y', strtotime($Data_lunas->tgl_lahir))  ?><br>
                                No HP : <?= $Data_lunas->no_hp ?>
                            </td>
                            <td class="text-left">
                                <?= $Data_lunas->alamat_lengkap ?><br>
                                RT. <?= $Data_lunas->nm_rt ?> / RW. <?= $Data_lunas->nm_rw ?>, Ds.
                                <?= $Data_lunas->nm_desa ?><br>
                                Kec. <?= $Data_lunas->nm_kecamatan ?>, <?= $Data_lunas->kot_kab ?>,<br>
                                <?= $Data_lunas->prov ?><br>
                            </td>
                            <td class="text-left">
                                Pinjaman : Rp <?= number_format($Data_lunas->pokok_pinjaman, 0, ',', '.') ?>,- <br>
                                Tempo :
                                <?php if ($Data_lunas->aturan_id == 2) :
                                        echo '8X - Dua Mingguan';
                                    else :
                                        echo '12X - Mingguan';
                                    endif ?>
                                <br>
                                Angsuran : Rp <?= number_format($Data_lunas->bsr_angsuran, 0, ',', '.') ?>,- <br>
                                Pengajuan :
                                <?= date('d', strtotime($Data_lunas->tgl_pengajuan)) . ' ' . $this->mycustom->bulanIndo(date('m', strtotime($Data_lunas->tgl_pengajuan))) . ' ' .  date('Y', strtotime($Data_lunas->tgl_pengajuan))  ?>
                            </td>
                            <td class="text-left">
                                Pot. Admin : Rp <?= number_format($Data_lunas->bsr_admin, 0, ',', '.') ?>,- <br>
                                Pot. RK : Rp <?= number_format($Data_lunas->bsr_rk, 0, ',', '.') ?>,- <br>
                                Simp/Angsuran : Rp <?= number_format($Data_lunas->bsr_simpanan, 0, ',', '.') ?>,-
                                <br>
                                Jasa/Angsuran : Rp <?= number_format($Data_lunas->bsr_jasa, 0, ',', '.') ?>,- <br>
                            </td>
                            <?php if ($Data_lunas->jaminan == 'Y') : ?>
                            <td class="text-left">
                                <?php foreach ($data_jaminan as $Data_jaminan) :
                                            if ($Data_lunas->nomor_kontrak == $Data_jaminan->kontrak_id) :
                                                $bulan = date('m', strtotime($Data_lunas->tgl_pengajuan));
                                                $tahun = date('Y', strtotime($Data_lunas->tgl_pengajuan));
                                        ?>
                                <?= $Data_jaminan->nm_agungan ?><br>
                                <a href="<?= base_url('assets/foto_jaminan/' . $tahun . '/' . $bulan . '/' . $Data_jaminan->foto_1) ?>"
                                    target="_blank">Gambar 01</a><br>
                                <a href="<?= base_url('assets/foto_jaminan/' . $tahun . '/' . $bulan . '/' . $Data_jaminan->foto_2) ?>"
                                    target="_blank">Gambar 02</a><br>
                                <a href="<?= base_url('assets/foto_jaminan/' . $tahun . '/' . $bulan . '/' . $Data_jaminan->foto_3) ?>"
                                    target="_blank">Gambar 03</a><br>
                                <a href="<?= base_url('assets/foto_jaminan/' . $tahun . '/' . $bulan . '/' . $Data_jaminan->foto_4) ?>"
                                    target="_blank">Gambar 04</a>
                                <?php
                                            endif;
                                        endforeach; ?>
                            </td>
                            <?php else : ?>
                            <td class="text-center">
                                Tidak Ada Jaminan
                            </td>
                            <?php endif; ?>
                            <td class="text-center">
                                <a class="btn btn-primary btn-sm"
                                    href="<?= base_url('marketing/kegiatan/kontrak_pinjaman/' . $this->encrypt->encode($Data_lunas->kontrak_id)) ?>"
                                    style="color: white;">Detail</a>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>