<!-- Bayar Arisan Heboh -->
<div class="modal fade" id="bayarTagihanHeboh" tabindex="-1" role="dialog" aria-labelledby="bayarTagihanHebohTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="bayarTagihanHebohTitle">
                    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('arisan/beranda/bayar/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>Silahkan Pilih Kelompok Arisan</label>
                    <select class="form-control" id="arisan_heboh" name="arisan_heboh" required>
                        <?php foreach ($arisan_heboh as $Arisan_heboh) : ?>
                            <option value="<?= $Arisan_heboh->id ?>">Kelompok <?= $Arisan_heboh->nm_kelompok ?> Arisan Heboh
                            </option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label>Masukkan Nomor Arisan / NIK / Nomor HP</label>
                    <input type="number" class="form-control" onkeyup="cek_nik()" id="nik_heboh" name="nik_heboh" placeholder="Masukkan Nomor Arisan / NIK / Nomor HP" required>
                </div>
                <div class="form-group">
                    <label>Status Anggota</label>
                    <input type="text" class="form-control" readonly id="status_anggota" name="status_anggota" placeholder="Status Anggota">
                    <input type="number" class="form-control" hidden id="anggota_id" name="anggota_id" placeholder="Anggota ID" required>
                    <input type="number" class="form-control" hidden id="regist_undian" name="regist_undian" placeholder="Nomor Register Undian Arisan ID" required>
                    <input type="number" class="form-control" hidden id="jadwal_id" name="jadwal_id" placeholder="Nomor Register Undian Arisan ID" required>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-outline-primary" data-dismiss="modal">
                    Close
                </button>
                <button type="submit" id="tambahBayarArisanHeboh" name="tambahBayarArisanHeboh" 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_heboh").val();
        var regist_arisan = $("#arisan_heboh").val();
        $.ajax({
            type: "POST",
            url: '<?= base_url('arisan/beranda/cek_arisan') ?>',
            data: {
                nik: nik,
                regist_arisan: regist_arisan
            },
            success: function(data) {
                var json = data,
                    obj = JSON.parse(json);
                if (obj > 1) {
                    $('#status_anggota').val();
                    $('#anggota_id').val();
                    $('#regist_undian').val();
                    $('#ttl_bayar').val();
                    $('#jadwal_id').val();
                } else {
                    $('#status_anggota').val(obj.status_anggota);
                    $('#anggota_id').val(obj.anggota_id);
                    $('#regist_undian').val(obj.regist_undian);
                    $('#jadwal_id').val(obj.jadwal_id);
                }
            }
        })
    }
</script>