 <!-- Tambah Anggota Lelang -->
 <div class="modal fade" id="pelunasan_pinjaman" tabindex="-1" role="dialog" aria-labelledby="pelunasan_pinjamanTitle"
     aria-hidden="true">
     <div class="modal-dialog modal-dialog-scrollable modal-lg modal-lg" role="document">
         <div class="modal-content">
             <div class="modal-header">
                 <h5 class="modal-title" id="pelunasan_pinjamanTitle">
                     Bayar Lunas 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/beranda/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_kontrak2()" id="kontrak_id_lunas"
                         name="kontrak_id_lunas" placeholder="Masukkan Nomor Kontrak Pinjaman" required>
                     <input type="number" class="form-control" hidden id="anggota_id_lunas" name="anggota_id_lunas"
                         placeholder="Masukkan Nomor Kontrak Pinjaman">
                 </div>
                 <div class="form-group">
                     <label>NIK & Nama Anggota</label>
                     <input type="text" class="form-control" readonly id="nm_anggota_lunas" name="nm_anggota_lunas"
                         placeholder="Nomor Induk Kependudukan dan Nama Anggota">
                 </div>
                 <div class="form-group">
                     <div class="form-row mb-6">
                         <div class="col">
                             <label>Angsuran Ke</label>
                             <input type="text" class="form-control" placeholder="Bayar Angsuran Ke" readonly
                                 id="angs_ke_lunas" name="angs_ke_lunas">
                         </div>
                         <div class="col">
                             <label>Sampai Ke</label>
                             <input type="text" class="form-control" placeholder="Sampai Angsuran Ke" readonly
                                 id="angs_sampai" name="angs_sampai">
                         </div>
                     </div>
                 </div>
                 <div class="form-group">
                     <label>Total Bayar Angsuran</label>
                     <input type="number" class="form-control" readonly id="bayar_angsuran" name="bayar_angsuran"
                         placeholder="Total Bayar Angsuran" required>
                 </div>
                 <div class="form-group">
                     <div class="form-row mb-6">
                         <div class="col">
                             <label>Tunggakan Ke</label>
                             <input type="text" class="form-control" placeholder="Bayar Tunggakan Angsuran Ke" readonly
                                 id="tunggakan_ke" name="tunggakan_ke">
                         </div>
                         <div class="col">
                             <label>Sampai Ke</label>
                             <input type="text" class="form-control" placeholder="Sampai Tunggakan Angsuran Ke" readonly
                                 id="tunggakan_sampai" name="tunggakan_sampai">
                         </div>
                     </div>
                 </div>
                 <div class="form-group">
                     <label>Total Bayar Tunggakan</label>
                     <input type="number" class="form-control" readonly id="bayar_tunggakan" name="bayar_tunggakan"
                         placeholder="Total Tunggakan Angsuran" required>
                 </div>
                 <div class="form-group">
                     <label>Total Bayar</label>
                     <input type="number" class="form-control" readonly id="ttl_bayar_lunas" name="ttl_bayar_lunas"
                         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="simpanBayarLunasAngsuranBeranda" name="simpanBayarLunasAngsuranBeranda"
                     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_kontrak2() {
         var kontrak_id_lunas = $("#kontrak_id_lunas").val();
         $.ajax({
             type: "POST",
             url: '<?= base_url('kasir/data/cek_tagihan_lunas_angsuran_anggota') ?>',
             data: {
                 kontrak_id: kontrak_id_lunas
             },
             success: function(data) {
                 var json = data,
                     obj = JSON.parse(json);
                 if (obj > 1) {
                     $('#anggota_id_lunas').val();
                     $('#nm_anggota_lunas').val();
                     $('#angs_ke_lunas').val();
                     $('#angs_sampai').val();
                     $('#bayar_angsuran').val();
                     $('#tunggakan_ke').val();
                     $('#tunggakan_sampai').val();
                     $('#bayar_tunggakan').val();
                     $('#ttl_bayar_lunas').val();
                 } else {
                     $('#anggota_id_lunas').val(obj.anggota_id_lunas);
                     $('#nm_anggota_lunas').val(obj.nm_anggota_lunas);
                     $('#angs_ke_lunas').val(obj.angs_ke_lunas);
                     $('#angs_sampai').val(obj.angs_sampai);
                     $('#bayar_angsuran').val(obj.bayar_angsuran);
                     $('#tunggakan_ke').val(obj.tunggakan_ke);
                     $('#tunggakan_sampai').val(obj.tunggakan_sampai);
                     $('#bayar_tunggakan').val(obj.bayar_tunggakan);
                     $('#ttl_bayar_lunas').val(obj.ttl_bayar_lunas);
                 }
             }
         })
     }
 </script>