<div class="modal fade" id="tambahAnggotaHeboh" tabindex="-1" role="dialog" aria-labelledby="tambahAnggotaHebohTitle" 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="tambahAnggotaHebohTitle">
                    Tambah Anggota 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('keuangan/laporan_arisan/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_belum as $Arisan_heboh_belum) : ?>
                            <option value="<?= $Arisan_heboh_belum->id ?>">Arisan Heboh Kelompok
                                <?= $Arisan_heboh_belum->nm_kelompok ?>
                            </option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label>Nomor Induk Kependudukan ( NIK )</label>
                    <input type="number" class="form-control" onkeyup="ceknikheboh()" id="nik_anggota" name="nik_anggota" 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="tah_nm_anggota" name="tah_nm_anggota" placeholder="Nama Anggota Kelompok Arisan" required>
                </div>
                <div class="form-group">
                    <label>Jenis Kelamin</label>
                    <select class="form-control" id="tah_jk" name="tah_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="tah_alamat_lengkap" id="tah_alamat_lengkap" cols="30" rows="2" placeholder="Mis. Jalan, Sekolah, Perumahan, Dst" required></textarea>
                </div>
                <div class="form-group">
                    <label for="">Pilih Kabupaten / Kota</label>
                    <select class="form-control" id="kota_kabupaten" name="kota_kabupaten" required>
                        <option value="PILIH">Pilih Kabupaten / Kota</option>
                        <?php foreach ($data_kota as $Data_kota) : ?>
                            <option value="<?= $Data_kota->kot_kab ?>"><?= $Data_kota->kot_kab ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-row mb-4">
                    <div class="col-6">
                        <label for="">Pilih Kecamatan</label>
                        <select class="form-control" id="kecamatan_baru" name="kecamatan_baru" required>
                        </select>
                    </div>
                    <div class="col-6">
                        <label for="">Pilih Desa</label>
                        <select class="form-control" id="dk_ds" name="dk_ds" required>
                        </select>
                    </div>
                </div>
                <div class="form-row mb-4">
                    <div class="col">
                        <label for="">RT</label>
                        <select class="form-control" id="tah_nm_rt" name="tah_nm_rt" required>
                            <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">
                        <label for="">RW</label>
                        <select class="form-control" id="tah_nm_rw" name="tah_nm_rw" required>
                            <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-group">
                    <label>Tempat Tanggal Lahir</label>
                    <div class="form-row mb-4">
                        <div class="col">
                            <input type="text" class="form-control" id="tah_tempat_lahir" name="tah_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="tah_tgl_lahir" name="tah_tgl_lahir" placeholder="Tanggal Lahir" required>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label>Nomor HP</label>
                    <input type="number" class="form-control" id="tah_no_hp" name="tah_no_hp" placeholder="Nomor HP" required>
                </div>
                <div class="form-group">
                    <label>Pekerjaan</label>
                    <input type="text" class="form-control" id="tah_pekerjaan" name="tah_pekerjaan" placeholder="Potongan Admin Setiap Bulan" required>
                </div>
                <div class="form-group">
                    <label>Suami / Istri</label>
                    <input type="text" class="form-control" id="tah_suami_istri" name="tah_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>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-outline-primary" data-dismiss="modal">
                    Close
                </button>
                <button type="submit" id="simpanAnggotaArisanHeboh" name="simpanAnggotaArisanHeboh" class="btn btn-primary">Tambah</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 ceknikheboh() {
        var nik = $("#nik_anggota").val();
        $.ajax({
            type: "POST",
            url: '<?= base_url('keuangan/data/cek_anggota') ?>',
            data: 'nik=' + nik,
            success: function(data) {
                var json = data,
                    obj = JSON.parse(json);
                if (obj > 1) {
                    $('#tah_nm_anggota').val();
                    $('#tah_jk').val();
                    $('#tah_alamat_lengkap').val();
                    $('#tah_kode_pos').val();
                    $('#tah_nm_rt').val();
                    $('#tah_kecamatan_baru').val();
                    $('#tah_dk_ds').val();
                    $('#tah_nm_rt').val();
                    $('#tah_nm_rw').val();
                    $('#tah_tempat_lahir').val();
                    $('#tah_tgl_lahir').val();
                    $('#tah_no_hp').val();
                    $('#tah_pekerjaan').val();
                    $('#tah_alamat_id').val();
                    $('#tah_suami_istri').val();
                    $('#tah_foto_ktplama').val();
                } else {
                    $('#tah_nm_anggota').val(obj.nm_anggota);
                    $('#tah_jk').val(obj.jk);
                    $('#tah_alamat_lengkap').val(obj.alamat_lengkap);
                    $('#kota_kabupaten').html(obj.kota_kabupaten);
                    $('#kecamatan_baru').html(obj.kecamatan_baru);
                    $('#dk_ds').html(obj.dk_ds);
                    $('#tah_nm_rt').val(obj.nm_rt);
                    $('#tah_nm_rw').val(obj.nm_rw);
                    $('#tah_tempat_lahir').val(obj.tempat_lahir);
                    $('#tah_tgl_lahir').val(obj.tgl_lahir);
                    $('#tah_no_hp').val(obj.no_hp);
                    $('#tah_pekerjaan').val(obj.pekerjaan);
                    $('#tah_suami_istri').val(obj.suami_istri);
                    $('#tah_foto_ktplama').val(obj.foto_ktp);
                }
            }
        })
    }
</script>

<!-- Script_alamat Baru -->
<script type="text/javascript">
    $('#kota_kabupaten').change(function() {
        var nm_kot_kab = $(this).val();
        $.ajax({
            type: 'POST',
            url: '<?= base_url('keuangan/kot_kab') ?>',
            data: 'nm_kot_kab=' + nm_kot_kab,
            success: function(response) {
                $('#kecamatan_baru').html(response);
            }
        });
    });

    $('#kecamatan_baru').change(function() {
        var nm_kecamatan = $(this).val();
        $.ajax({
            type: 'POST',
            url: '<?= base_url('keuangan/kecamatan') ?>',
            data: 'nm_kecamatan=' + nm_kecamatan,
            success: function(response) {
                $('#dk_ds').html(response);
            }
        });
    });
</script>