<!-- Bayar Arisan Heboh -->
<div class="modal fade" id="bayarTagihanMotor" tabindex="-1" role="dialog" aria-labelledby="bayarTagihanMotorTitle" 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="bayarTagihanMotorTitle">
                    Bayar Iuran Arisan Motor!
                </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 for="id_arisan">Silahkan Pilih Kelompok Arisan</label>
                    <select class="form-control" id="id_arisan_motor" name="id_arisan_motor" required>
                        <?php foreach ($arisan_motor as $Arisan_motor) : ?>
                            <option value="<?= $Arisan_motor->id ?>">Arisan Motor <?= $Arisan_motor->ket_arisan ?> Ke
                                <?= $Arisan_motor->nm_kelompok ?>
                            </option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label for="regist_arisan">Masukkan Nomor Arisan / NIK / Nomor HP</label>
                    <input type="number" class="form-control" onkeyup="ceknikbayarmotor()" id="nik_bayarmotor" name="nik_bayarmotor" placeholder="Masukkan Nomor Arisan / NIK / Nomor HP" required>
                </div>
                <div class="form-group">
                    <label for="regist_arisan">Status Anggota</label>
                    <input type="text" class="form-control" readonly id="status_anggota_motor" name="status_anggota_motor" placeholder="Status Anggota">
                    <input type="number" class="form-control" hidden id="anggota_id_motor" name="anggota_id_motor" placeholder="Anggota ID" required>
                    <input type="number" class="form-control" hidden id="regist_undian_motor" name="regist_undian_motor" placeholder="Nomor Register Undian Arisan ID" required>
                    <input type="number" class="form-control" hidden id="jadwal_id_motor" name="jadwal_id_motor" 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="tambahBayarArisanMotor" name="tambahBayarArisanMotor" 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 ceknikbayarmotor() {
        var nik = $("#nik_bayarmotor").val();
        var regist_arisan = $("#id_arisan_motor").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_motor').val();
                    $('#anggota_id_motor').val();
                    $('#regist_undian_motor').val();
                    $('#ttl_bayar').val();
                    $('#jadwal_id_motor').val();
                } else {
                    $('#status_anggota_motor').val(obj.status_anggota);
                    $('#anggota_id_motor').val(obj.anggota_id);
                    $('#regist_undian_motor').val(obj.regist_undian);
                    $('#jadwal_id_motor').val(obj.jadwal_id);
                }
            }
        })
    }
</script>