<!-- Tambah Anggota Lelang -->
<div class="modal fade" id="bayar_detail" tabindex="-1" role="dialog" aria-labelledby="bayar_detailTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-scrollable modal-lg modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="bayar_detailTitle">
                    Bayar Iuran Arisan Heboh!
                </h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <?php echo form_open_multipart('kasir/arisan/kelompok_heboh/crud'); ?>
                <input type="hidden" name="<?= $this->security->get_csrf_token_name(); ?>" value="<?= $this->security->get_csrf_hash(); ?>" style="display: none">
                <div class="form-group">
                    <label for="regist_arisan">Silahkan Pilih Kelompok Arisan</label>
                    <select class="form-control" id="regist_arisan" name="regist_arisan" required>
                        <?php foreach ($arisan_heboh as $Arisan_heboh) : ?>
                            <option value="<?= $Arisan_heboh->id ?>">Kelompok Arisan Heboh
                                <?= $Arisan_heboh->nm_kelompok ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label>NIK / Nomor HP / No Regist Anggota</label>
                    <input type="number" class="form-control" onkeyup="cek_nik()" id="nik" name="nik" placeholder="Masukkan NIK / Nomor HP / No Regist Anggota" required>
                    <input type="number" class="form-control" hidden id="id_anggota" name="id_anggota" placeholder="Masukkan NIK / Nomor HP / No Regist Anggota">
                </div>
                <div class="form-group">
                    <label>Nama Anggota</label>
                    <input type="text" class="form-control" readonly id="nm_anggota" name="nm_anggota" placeholder="Masukkan NIK / Nomor HP / No Regist Anggota">
                </div>
                <div class="form-group">
                    <div class="form-row mb-4">
                        <div class="col">
                            <label>Iuran</label>
                            <input type="text" class="form-control" placeholder="Bayar Iuran" readonly id="jml_iuran" name="jml_iuran">
                        </div>
                        <div class="col">
                            <label>Besar Iuran</label>
                            <input type="text" class="form-control" placeholder="Besaran Iuran" readonly id="besar_iuran" name="besar_iuran">
                        </div>
                        <div class="col">
                            <label>Total Iuran</label>
                            <input type="text" class="form-control" placeholder="Total Bayar Iuran" readonly id="ttl_iuran" name="ttl_iuran">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="form-row mb-4">
                        <div class="col">
                            <label>Tunggakan</label>
                            <input type="text" class="form-control" placeholder="Total Tunggakan" readonly id="jml_tunggakan" name="jml_tunggakan">
                        </div>
                        <div class="col">
                            <label>Besar Tunggakan</label>
                            <input type="text" class="form-control" placeholder="Besaran Tunggakan Iuran" readonly id="besar_tunggakan" name="besar_tunggakan">
                        </div>
                        <div class="col">
                            <label>Total Tunggakan</label>
                            <input type="text" class="form-control" placeholder="Total Tunggakan Iuran" readonly id="ttl_tunggakan" name="ttl_tunggakan">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label>Total Bayar</label>
                    <input type="number" class="form-control" readonly id="ttl_bayar" name="ttl_bayar" placeholder="Target Anggota Kelompok Arisan" required>
                    <input type="number" hidden class="form-control" value="<?= $data_id_login ?>" id="login_id" name="login_id" placeholder="Total Bayar Tagihan Anggota Arisan" required>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-outline-primary" data-dismiss="modal">
                    Close
                </button>
                <button type="submit" id="simpanBayarAnggota" name="simpanBayarAnggota" class="btn btn-primary">Bayar</button>
            </div>
            <?php echo form_close(); ?>
        </div>
    </div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
    function cek_nik() {
        var nik = $("#nik").val();
        var regist_arisan = $("#regist_arisan").val();
        $.ajax({
            type: "POST",
            url: '<?= base_url('kasir/data/cek_tagihan_arisan_heboh') ?>',
            data: {
                nik: nik,
                regist_arisan: regist_arisan
            },
            success: function(data) {
                var json = data,
                    obj = JSON.parse(json);
                if (obj > 1) {
                    $('#id_anggota').val();
                    $('#jml_iuran').val();
                    $('#besar_iuran').val();
                    $('#ttl_iuran').val();
                    $('#jml_tunggakan').val();
                    $('#besar_tunggakan').val();
                    $('#ttl_tunggakan').val();
                    $('#ttl_bayar').val();
                    $('#nm_anggota').val();
                } else {
                    $('#id_anggota').val(obj.id_anggota);
                    $('#jml_iuran').val(obj.jml_iuran);
                    $('#besar_iuran').val(obj.besar_iuran);
                    $('#ttl_iuran').val(obj.ttl_iuran);
                    $('#jml_tunggakan').val(obj.jml_tunggakan);
                    $('#besar_tunggakan').val(obj.besar_tunggakan);
                    $('#ttl_tunggakan').val(obj.ttl_tunggakan);
                    $('#ttl_bayar').val(obj.ttl_bayar);
                    $('#nm_anggota').val(obj.nm_anggota);
                }
            }
        })
    }
</script>