<!-- Bayar Tagihan Individu -->
<div class="modal fade" id="bayarTagihan" tabindex="-1" role="dialog" aria-labelledby="bayarTagihanTitle" 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="bayarTagihanTitle">
                    Bayar Tagihan Individu!
                </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/aktifitas/tagihan/bayar'); ?>
                <input type="hidden" name="<?= $this->security->get_csrf_token_name(); ?>" value="<?= $this->security->get_csrf_hash(); ?>" style="display: none">
                <div class="form-group">
                    <label>NIK / Nomor HP / No Regist Anggota</label>
                    <input type="number" class="form-control" hidden value="<?= $jadwal_arisan['id'] ?>" id="jadwal_id" name="jadwal_id" placeholder="Nama Kelompok Arisan" required>
                    <input type="number" class="form-control" hidden value="<?= $jadwal_arisan['regist_arisan'] ?>" id="regist_arisan" name="regist_arisan" placeholder="Nama Kelompok Arisan" required>
                    <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">
                    <div class="form-row mb-4">
                        <div class="col">
                            <label>Bayar</label>
                            <input type="text" class="form-control" placeholder="Total Bayar" readonly id="ttl_bayar2" name="ttl_bayar2">
                        </div>
                        <div class="col">
                            <label>Tagihan</label>
                            <input type="text" class="form-control" placeholder="Total Tagihan" readonly id="ttl_tagihan" name="ttl_tagihan">
                        </div>
                        <div class="col">
                            <label>Iuran</label>
                            <input type="text" class="form-control" placeholder="Iuran Bulanan" readonly id="iuran_bulanan" name="iuran_bulanan">
                        </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 jadwal_id = $("#jadwal_id").val();
        var regist_arisan = $("#regist_arisan").val();
        $.ajax({
            type: "POST",
            url: '<?= base_url('arisan/data/cek_arisan') ?>',
            data: {
                nik: nik,
                data_jadwal: jadwal_id,
                regist_arisan: regist_arisan
            },
            success: function(data) {
                var json = data,
                    obj = JSON.parse(json);
                if (obj > 1) {
                    $('#ttl_bayar2').val();
                    $('#ttl_tagihan').val();
                    $('#iuran_bulanan').val();
                    $('#ttl_bayar').val();
                } else {
                    $('#ttl_bayar2').val(obj.ttl_bayar);
                    $('#ttl_tagihan').val(obj.ttl_tagihan);
                    $('#iuran_bulanan').val(obj.iuran_bulanan);
                    $('#ttl_bayar').val(obj.ttl_bayar);
                    $('#id_anggota').val(obj.id_anggota);
                }
            }
        })
    }
</script>