<!-- Notifikasi Mulai Undian -->
<div class="modal fade" id="undian_detail" tabindex="-1" role="dialog" aria-labelledby="undian_detailTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <?php if ($data_arisan['produk_id'] == 21) : ?>
                    <h5 class="modal-title" id="undian_detailTitle">Mulai Undian Arisan</h5>
                <?php else : ?>
                    <h5 class="modal-title" id="undian_detailTitle">Mulai Lelang Arisan</h5>
                <?php endif; ?> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x">
                        <line x1="18" y1="6" x2="6" y2="18"></line>
                        <line x1="6" y1="6" x2="18" y2="18"></line>
                    </svg>
                </button>
            </div>
            <div class="modal-body" id="detail_body">
                <?php echo form_open_multipart('arisan/aktifitas/undian/crud'); ?>
                <input type="hidden" name="<?= $this->security->get_csrf_token_name(); ?>" value="<?= $this->security->get_csrf_hash(); ?>" style="display: none">
                <center>
                    <?php if ($data_arisan['produk_id'] == 21) : ?>
                        <h3>Kelompok Arisan Heboh Ke-<?= $data_arisan['nm_kelompok'] ?></h3>
                        <h5> Undian Ke <?= $jadwal_arisan['undian_ke'] ?> </h5>
                        <small>*Jika dirasa sudah memenuhi target dan S&K yang berlaku, silahkan mulai undian!
                        </small>
                    <?php else : ?>
                        <h3>Kelompok Arisan Motor <br> <?= $data_arisan['ket_arisan'] ?>
                            ke-<?= $data_arisan['nm_kelompok'] ?></h3>
                        <h5> Undian Ke- <?= $jadwal_arisan['undian_ke'] ?> & Lelang Ke-<?= $jadwal_arisan['lelang_ke'] ?>
                        </h5>
                        <small>*Jika dirasa sudah memenuhi target dan S&K yang berlaku, silahkan mulai lelang!
                        </small>
                    <?php endif; ?>
                    <input type="text" class="form-control" hidden value="<?= $jadwal_arisan['regist_arisan'] ?>" id="regist_arisan" name="regist_arisan" required>
                    <input type="text" class="form-control" hidden value="<?= $jadwal_arisan['id'] ?>" id="jadwal_id" name="jadwal_id" required>
                </center>
            </div>
            <div class="modal-footer">
                <button class="btn" data-dismiss="modal"><i class="flaticon-cancel-12"></i> Batal</button>
                <?php if ($data_arisan['produk_id'] == 21) : ?>
                    <button type="submit" id="mulaiUndianArisan" name="mulaiUndianArisan" class="btn btn-primary">Mulai
                        Undian</button>
                <?php else : ?>
                    <button type="submit" id="mulaiLelangArisan" name="mulaiLelangArisan" class="btn btn-primary">Mulai
                        Lelang</button>
                <?php endif; ?>
            </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);
                }
            }
        })
    }

    function cek_nikkeluarga() {
        var nik = $("#nik2").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) {
                    $('#id_anggota2').val();
                } else {
                    $('#id_anggota2').val(obj.id_anggota);
                }
            }
        })
    }
</script>