<!-- Modal Arisan Detail -->
<div class="modal fade" id="arisan_detail" tabindex="-1" role="dialog" aria-labelledby="arisan_detailTitle" 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="arisan_detailTitle">
                    Detail Data Arisan!
                </h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body" id="detail_body">
                <?php echo form_open_multipart('arisan/data/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>Nama Kelompok</label>
                    <input type="number" class="form-control" min="1" hidden id="regist_arisan" name="regist_arisan" placeholder="Nama Kelompok Arisan" required>
                    <input type="number" class="form-control" min="1" readonly id="nm_kelompok" name="nm_kelompok" placeholder="Nama Kelompok Arisan" required>
                </div>
                <div class="form-group">
                    <label>Anggota Kelompok Arisan</label>
                    <input type="number" class="form-control" min="1" id="ttl_anggota" name="ttl_anggota" placeholder="Target Anggota Kelompok Arisan" required>
                </div>
                <div class="form-group">
                    <label>Iuran per Bulan</label>
                    <input type="number" class="form-control" min="1" id="tagihan_iuran" name="tagihan_iuran" placeholder="Iuran per Bulan" required>
                </div>
                <div class="form-group">
                    <label>Tanggal Undian</label>
                    <input type="number" class="form-control" id="tgl_undian" name="tgl_undian" placeholder="Tentukan Tanggal Undian">
                </div>
                <div class="form-group">
                    <label>Tempo atau Lama Arisan Berjalan</label>
                    <input type="number" class="form-control" min="1" id="tempo" name="tempo" placeholder="Tempo atau Lama Arisan Berjalan" required>
                </div>
                <div class="form-group">
                    <label>Besaran Potongan Admin Pertama</label>
                    <input type="number" class="form-control" min="1" id="hg_modal" name="hg_modal" placeholder="Besaran Potongan Admin Pertama" required>
                </div>
                <div class="form-group">
                    <label>Potongan Admin Setiap Bulan</label>
                    <input type="number" class="form-control" min="1" id="fee_admin" name="fee_admin" placeholder="Potongan Admin Setiap Bulan" required>
                </div>
                <div class="form-group">
                    <label>Besaran Yang Diterima Anggota</label>
                    <input type="number" class="form-control" min="1" id="hg_jual" name="hg_jual" placeholder="Besaran Yang Diterima Anggota" required>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-outline-primary" data-dismiss="modal">
                    Close
                </button>
                <button type="submit" id="hapusDataArisan" name="hapusDataArisan" class="btn btn-danger">Hapus</button>
                <button type="submit" id="ubahDataArisan" name="ubahDataArisan" class="btn btn-primary">Ubah</button>
                <button type="submit" id="aktifDataArisan" name="aktifDataArisan" class="btn btn-success">Aktif</button>
            </div>
            <?php echo form_close(); ?>
        </div>
    </div>
</div>
<!-- Form Ajax Arisan Detail -->
<script type="text/javascript">
    $(document).on("click", "#detail_arisan", function() {
        var regist_arisan = $(this).data('regist_arisan');
        var nm_kelompok = $(this).data('nm_kelompok');
        var ttl_anggota = $(this).data('ttl_anggota');
        var tagihan_iuran = $(this).data('tagihan_iuran');
        var tempo = $(this).data('tempo');
        var hg_modal = $(this).data('hg_modal');
        var fee_admin = $(this).data('fee_admin');
        var hg_jual = $(this).data('hg_jual');
        $(".modal-body#detail_body #regist_arisan").val(regist_arisan);
        $(".modal-body#detail_body #nm_kelompok").val(nm_kelompok);
        $(".modal-body#detail_body #ttl_anggota").val(ttl_anggota);
        $(".modal-body#detail_body #tagihan_iuran").val(tagihan_iuran);
        $(".modal-body#detail_body #tempo").val(tempo);
        $(".modal-body#detail_body #hg_modal").val(hg_modal);
        $(".modal-body#detail_body #fee_admin").val(fee_admin);
        $(".modal-body#detail_body #hg_jual").val(hg_jual);
    })
</script>
<!-- Modal Arisan Detail -->
<div class="modal fade" id="anggota_detail" tabindex="-1" role="dialog" aria-labelledby="anggota_detailTitle" 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="anggota_detailTitle">
                    Detail Anggota Arisan
                </h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body" id="detail_body_anggota">
                <?php echo form_open_multipart('arisan/data/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>Nomor Induk Kependudukan ( NIK )</label>
                    <input type="number" class="form-control" onkeyup="ceknik()" id="nik" name="nik" placeholder="Nomor Induk Kependudukan ( NIK )" required>
                    <input type="text" class="form-control" hidden id="id_arisan" name="id_arisan" value="<?= $data_arisan['id'] ?>" placeholder="Nomor Induk Kependudukan ( NIK )" required>
                    <input type="text" class="form-control" hidden id="login_id" name="login_id" value="<?= $data_id_login ?>" placeholder="Nomor Induk Kependudukan ( NIK )" required>
                </div>
                <div class="form-group">
                    <label>Nama Panggilan</label>
                    <input type="text" class="form-control" id="nm_anggota" name="nm_anggota" placeholder="Nama Anggota Kelompok Arisan" required>
                    <input type="text" class="form-control" hidden id="regist_undian" name="regist_undian" placeholder="Nama Anggota Kelompok Arisan" required>
                </div>
                <div class="form-group">
                    <label>Jenis Kelamin</label>
                    <select class="form-control" id="jk" name="jk" required>
                        <option value="ok">Jenis Kelamin</option>
                        <option value="1">LAKI-LAKI</option>
                        <option value="2">PEREMPUAN</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>Alamat Lengkap</label>
                    <textarea class="form-control" name="alamat_lengkap" id="alamat_lengkap" cols="30" rows="2" placeholder="Mis. Jalan, Sekolah, Perumahan, Dst" required></textarea>
                </div>
                <div class="form-row mb-4">
                    <div class="col-6">
                        <input type="number" class="form-control" placeholder="Kode Pos" id="kode_pos" name="kode_pos" required>
                    </div>
                    <div class="col">
                        <select class="form-control" id="nm_rt" name="nm_rt" required>
                            <option value="ok">RT</option>
                            <option value="001">001</option>
                            <option value="002">002</option>
                            <option value="003">003</option>
                            <option value="004">004</option>
                            <option value="005">005</option>
                            <option value="006">006</option>
                            <option value="007">007</option>
                            <option value="008">008</option>
                            <option value="009">009</option>
                            <option value="010">010</option>
                            <option value="011">011</option>
                            <option value="012">012</option>
                            <option value="013">013</option>
                            <option value="014">014</option>
                            <option value="015">015</option>
                            <option value="016">016</option>
                            <option value="017">017</option>
                            <option value="018">018</option>
                            <option value="019">019</option>
                            <option value="020">020</option>
                        </select>
                    </div>
                    <div class="col">
                        <select class="form-control" id="nm_rw" name="nm_rw" required>
                            <option value="ok">RW</option>
                            <option value="001">001</option>
                            <option value="002">002</option>
                            <option value="003">003</option>
                            <option value="004">004</option>
                            <option value="005">005</option>
                            <option value="006">006</option>
                            <option value="007">007</option>
                            <option value="008">008</option>
                            <option value="009">009</option>
                            <option value="010">010</option>
                            <option value="011">011</option>
                            <option value="012">012</option>
                            <option value="013">013</option>
                            <option value="014">014</option>
                            <option value="015">015</option>
                            <option value="016">016</option>
                            <option value="017">017</option>
                            <option value="018">018</option>
                            <option value="019">019</option>
                            <option value="020">020</option>
                        </select>
                    </div>
                </div>
                <div class="form-row mb-4">
                    <div class="col-4">
                        <input type="text" class="form-control" placeholder="Desa/Kelurahan" id="nm_desa" name="nm_desa" required>
                        <small>*Contoh : Hadipolo, Klaling, Bulung Kulon, Bulung Cangkring, Honggosoco</small>
                    </div>
                    <div class="col-4">
                        <input type="text" class="form-control" placeholder="Kecamatan" id="nm_kecamatan" name="nm_kecamatan" required>
                        <small>*Contoh : Jekulo, Bae, Kudus Kota, Pati Kota, Dst</small>
                    </div>
                    <div class="col-4">
                        <input type="text" class="form-control" placeholder="Kota/Kabupaten" id="kot_kab" name="kot_kab" required>
                        <small>*Contoh : Kabupaten Kudus, Kota Semarang Dst</small>
                    </div>
                </div>
                <div class="form-group">
                    <input type="text" class="form-control" id="prov" name="prov" placeholder="Provinsi" required>
                    <small>*Contoh : Jawa Tengah, Bali, Lampung, Nusa Tenggara Timur, Dst</small>
                </div>
                <div class="form-group">
                    <label>Tempat Tanggal Lahir</label>
                    <div class="form-row mb-4">
                        <div class="col">
                            <input type="text" class="form-control" id="tempat_lahir" name="tempat_lahir" placeholder="Tempat Lahir" required>
                        </div>
                        <div class="col">
                            <input type="date" max='<?= date("Y-m-d", strtotime("-18 year")); ?>' class="form-control" id="tgl_lahir" name="tgl_lahir" placeholder="Tanggal Lahir" required>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label>Nomor HP</label>
                    <input type="number" class="form-control" id="no_hp" name="no_hp" placeholder="Nomor HP" required>
                </div>
                <div class="form-group">
                    <label>Pekerjaan</label>
                    <input type="text" class="form-control" id="pekerjaan" name="pekerjaan" placeholder="Potongan Admin Setiap Bulan" required>
                </div>
                <div class="form-group">
                    <label>Suami / Istri</label>
                    <input type="text" class="form-control" id="suami_istri" name="suami_istri" placeholder="Nama Suami atau Istri" required>
                    <small>*Jika belum menikah isi Belum Menikah, Duda, Janda</small>
                </div>
                <div class="form-group">
                    <label>Foto KTP</label>
                    <input type="file" class="form-control" id="foto_ktp" name="foto_ktp" placeholder="Foto KTP" required>
                    <input type="text" class="form-control" id="foto_ktplama" name="foto_ktplama" placeholder="Foto KTP" hidden>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-outline-primary" data-dismiss="modal">
                    Close
                </button>
                <button type="submit" id="gantiAnggotaArisanHeboh" name="gantiAnggotaArisanHeboh" class="btn btn-primary">Ganti Anggota</button>
            </div>
            <?php echo form_close(); ?>
        </div>
    </div>
</div>
<!-- Form Ajax Arisan Detail -->
<script type="text/javascript">
    $(document).on("click", "#detail_anggota", function() {
        var regist_undian = $(this).data('regist_undian');
        var nik = $(this).data('nik');
        var no_hp = $(this).data('no_hp');
        var nm_anggota = $(this).data('nm_anggota');
        var jk = $(this).data('jk');
        var alamat_lengkap = $(this).data('alamat_lengkap');
        var nm_rt = $(this).data('nm_rt');
        var nm_rw = $(this).data('nm_rw');
        var nm_desa = $(this).data('nm_desa');
        var nm_kecamatan = $(this).data('nm_kecamatan');
        var kot_kab = $(this).data('kot_kab');
        var prov = $(this).data('prov');
        var kd_pos = $(this).data('kd_pos');
        var tempat_lahir = $(this).data('tempat_lahir');
        var tgl_lahir = $(this).data('tgl_lahir');
        var pekerjaan = $(this).data('pekerjaan');
        var suami_istri = $(this).data('suami_istri');
        var foto_ktp = $(this).data('foto_ktp');
        $(".modal-body#detail_body_anggota #regist_undian").val(regist_undian);
        $(".modal-body#detail_body_anggota #nik").val(nik);
        $(".modal-body#detail_body_anggota #no_hp").val(no_hp);
        $(".modal-body#detail_body_anggota #nm_anggota").val(nm_anggota);
        $(".modal-body#detail_body_anggota #jk").val(jk);
        $(".modal-body#detail_body_anggota #alamat_lengkap").val(alamat_lengkap);
        $(".modal-body#detail_body_anggota #nm_rt").val(nm_rt);
        $(".modal-body#detail_body_anggota #nm_rw").val(nm_rw);
        $(".modal-body#detail_body_anggota #nm_desa").val(nm_desa);
        $(".modal-body#detail_body_anggota #nm_kecamatan").val(nm_kecamatan);
        $(".modal-body#detail_body_anggota #kot_kab").val(kot_kab);
        $(".modal-body#detail_body_anggota #prov").val(prov);
        $(".modal-body#detail_body_anggota #kode_pos").val(kd_pos);
        $(".modal-body#detail_body_anggota #tempat_lahir").val(tempat_lahir);
        $(".modal-body#detail_body_anggota #tgl_lahir").val(tgl_lahir);
        $(".modal-body#detail_body_anggota #pekerjaan").val(pekerjaan);
        $(".modal-body#detail_body_anggota #suami_istri").val(suami_istri);
        $(".modal-body#detail_body_anggota #foto_ktplama").val(foto_ktp);
    })
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
    function ceknik() {
        var nik = $("#nik").val();
        $.ajax({
            type: "POST",
            url: '<?= base_url('arisan/data/cek_anggota') ?>',
            data: 'nik=' + nik,
            success: function(data) {
                var json = data,
                    obj = JSON.parse(json);
                if (obj > 1) {
                    $('#nm_anggota').val();
                    $('#jk').val();
                    $('#alamat_lengkap').val();
                    $('#kode_pos').val();
                    $('#nm_rt').val();
                    $('#nm_rw').val();
                    $('#nm_desa').val();
                    $('#nm_kecamatan').val();
                    $('#kot_kab').val();
                    $('#prov').val();
                    $('#tempat_lahir').val();
                    $('#tgl_lahir').val();
                    $('#no_hp').val();
                    $('#pekerjaan').val();
                    $('#suami_istri').val();
                    $('#foto_ktplama').val();
                } else {
                    $('#nm_anggota').val(obj.nm_anggota);
                    $('#jk').val(obj.jk);
                    $('#alamat_lengkap').val(obj.alamat_lengkap);
                    $('#kode_pos').val(obj.kd_pos);
                    $('#nm_rt').val(obj.nm_rt);
                    $('#nm_rw').val(obj.nm_rw);
                    $('#nm_desa').val(obj.nm_desa);
                    $('#nm_kecamatan').val(obj.nm_kecamatan);
                    $('#kot_kab').val(obj.kot_kab);
                    $('#prov').val(obj.prov);
                    $('#tempat_lahir').val(obj.tempat_lahir);
                    $('#tgl_lahir').val(obj.tgl_lahir);
                    $('#no_hp').val(obj.no_hp);
                    $('#pekerjaan').val(obj.pekerjaan);
                    $('#suami_istri').val(obj.suami_istri);
                    $('#foto_ktplama').val(obj.foto_ktp);
                }
            }
        })
    }
</script>