 <!-- Tambah Anggota Lelang -->
 <div class="modal fade" id="bayarAngsuran" tabindex="-1" role="dialog" aria-labelledby="bayarAngsuranTitle"
     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="bayarAngsuranTitle">
                     Bayar Angsuran Pinjaman!
                 </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('kasir/koperasi/bayar_angsuran/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 Kontrak Pinjaman</label>
                     <input type="number" class="form-control" onkeyup="cek_kontrak()" id="kontrak_id" name="kontrak_id"
                         placeholder="Masukkan NIK / Nomor HP / Nomor Kontrak" required>
                     <input type="number" class="form-control" hidden id="anggota_id" name="anggota_id"
                         placeholder="Masukkan NIK / Nomor HP / No Regist Anggota">
                 </div>
                 <div class="form-group">
                     <label>Nama Anggota</label>
                     <input type="text" class="form-control" readonly id="nm_anggota" name="nm_anggota"
                         placeholder="Masukkan NIK / Nomor HP / No Regist Anggota">
                 </div>
                 <div class="form-group">
                     <div class="form-row mb-4">
                         <div class="col">
                             <label>Besar Angsuran</label>
                             <input type="text" class="form-control" placeholder="Besar Angsuran" readonly
                                 id="bsr_bayar" name="bsr_bayar">
                         </div>
                         <div class="col">
                             <label>Angsuran Ke</label>
                             <input type="text" class="form-control" placeholder="Pembayaran Angsuran Ke" readonly
                                 id="angs_ke" name="angs_ke">
                         </div>
                         <div class="col">
                             <label>Jatuh Tempo</label>
                             <input type="text" class="form-control" placeholder="Tanggal Jatuh Tempo" readonly
                                 id="tgl_tempo" name="tgl_tempo">
                         </div>
                     </div>
                 </div>
                 <div class="form-group">
                     <div class="form-row mb-4">
                         <div class="col">
                             <label>Tunggakan</label>
                             <input type="text" class="form-control" placeholder="Total Tunggakan" readonly
                                 id="jml_tunggakan" name="jml_tunggakan">
                         </div>
                         <div class="col">
                             <label>Besar Tunggakan</label>
                             <input type="text" class="form-control" placeholder="Besaran Tunggakan Iuran" readonly
                                 id="besar_tunggakan" name="besar_tunggakan">
                         </div>
                         <div class="col">
                             <label>Total Tunggakan</label>
                             <input type="text" class="form-control" placeholder="Total Tunggakan Iuran" readonly
                                 id="ttl_tunggakan" name="ttl_tunggakan">
                         </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" required>
                 </div>
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-outline-primary" data-dismiss="modal">
                     Close
                 </button>
                 <button type="submit" id="simpanBayarAngsuranPinjaman" name="simpanBayarAngsuranPinjaman"
                     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 src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
 <script type="text/javascript">
     function cek_kontrak() {
         var kontrak_id = $("#kontrak_id").val();
         $.ajax({
             type: "POST",
             url: '<?= base_url('kasir/data/cek_tagihan_angsuran_anggota') ?>',
             data: {
                 kontrak_id: kontrak_id
             },
             success: function(data) {
                 var json = data,
                     obj = JSON.parse(json);
                 if (obj > 1) {
                     $('#anggota_id').val();
                     $('#nm_anggota').val();
                     $('#bsr_bayar').val();
                     $('#angs_ke').val();
                     $('#tgl_tempo').val();
                     $('#jml_tunggakan').val();
                     $('#besar_tunggakan').val();
                     $('#ttl_tunggakan').val();
                     $('#ttl_bayar').val();
                 } else {
                     $('#anggota_id').val(obj.anggota_id);
                     $('#nm_anggota').val(obj.nm_anggota);
                     $('#bsr_bayar').val(obj.bsr_bayar);
                     $('#angs_ke').val(obj.angs_ke);
                     $('#tgl_tempo').val(obj.tgl_tempo);
                     $('#jml_tunggakan').val(obj.jml_tunggakan);
                     $('#besar_tunggakan').val(obj.besar_tunggakan);
                     $('#ttl_tunggakan').val(obj.ttl_tunggakan);
                     $('#ttl_bayar').val(obj.ttl_bayar);
                 }
             }
         })
     }
 </script>