	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>



	<script src="../assets/js/jquery.min.js"></script>
	<script src="../assets/js/popper.min.js"></script>
	<script src="../assets/js/bootstrap.min.js"></script>
	<script src="../assets/js/jquery.datatables.min.js"></script>
	<script src="../assets/js/datatables-bootstrap5.min.js"></script>
	<script src="../assets/js/chart.js"></script>


	<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
	<!-- Make sure you put this AFTER Leaflet's CSS -->
	<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
</body>

<script type="text/javascript">


	$(document).ready(function(){

		$('.select2').select2();

		$("body").on("change",".pilih_anggota",function(){
			var id = $(this).val();
			var data = "id="+id;
			$.ajax({			
				url: 'ajax_anggota.php',
				type: 'post',
				dataType: 'json',
				data: data, 
				success: function(result){
					$(".tampil-angg_id").val(result[0]);
					$(".tampil-angg_no").val(result[1]);
					$(".tampil-angg_nama").val(result[2]);
					$(".tampil-angg_alamat").val(result[3]);
				}
			});
		});

		$("body").on("change",".pilih_angg_simp",function(){
			var id = $(this).val();
			var data = "id="+id;
			$.ajax({			
				url: 'ajax_angg_simp.php',
				type: 'post',
				dataType: 'json',
				data: data, 
				success: function(result){
					$(".tampil-angg_id").val(result[0]);
					$(".tampil-angg_no").val(result[1]);
					$(".tampil-angg_nama").val(result[2]);
					$(".tampil-angg_alamat").val(result[3]);
				}
			});
		});
		
		$("body").on("change",".pilih_pinjaman",function(){
			var id = $(this).val();
			var data = "id="+id;
			$.ajax({			
				url: 'ajax_pinjaman.php',
				type: 'post',
				dataType: 'json',
				data: data, 
				success: function(result){
					$(".tampil-id_pinj").val(result[0]);
					$(".tampil-pinj_no").val(result[1]);
					$(".tampil-pinj_angg_no").val(result[2]);
					$(".tampil-pinj_nama").val(result[3]);
					$(".tampil-pinj_alamat").val(result[4]);
				}
			});
		});













		$('#table-datatable').DataTable({
			'paging'      : true,
			'lengthChange': false,
			'searching'   : true,
			'ordering'    : true,
			'info'        : true,
			'autoWidth'   : true,
			"pageLength": 15
		});

		ValidateForm();

		$("body").on("change keyup",".nilai", function(){		
			ValidateForm();
		});

		function ValidateForm() {

			var formInvalid = false;
			var terisi = 0;
			$('.nilai').each(function() {
				if ($(this).val() === '') {
					formInvalid = true;
				}else{
					terisi++;
				}
			});
			
			if(terisi == 0){
				$(".kirim").hide();
			}else{
				$(".kirim").show();
			}
		}

	});

</script>


	<script type="text/javascript">
		
		$(document).ready(function(){
			$("body").on("keyup change",".rupiah", function(){
				var x = formatRupiah(this.value, 'Rp. ');
				var ini = $(this).val(x);
				
			});
			// var rupiah = document.getElementByClassName('rupiah');
			// rupiah.addEventListener('keyup', function(e){
			// // tambahkan 'Rp.' pada saat form di ketik
			// // gunakan fungsi formatRupiah() untuk mengubah angka yang di ketik menjadi format angka
			// 	rupiah.value = formatRupiah(this.value, 'Rp. ');
			// });

		/* Fungsi formatRupiah */
			function formatRupiah(angka, prefix){
				var number_string = angka.replace(/[^,\d]/g, '').toString(),
				split   		= number_string.split(','),
				sisa     		= split[0].length % 3,
				rupiah     		= split[0].substr(0, sisa),
				ribuan     		= split[0].substr(sisa).match(/\d{3}/gi);

			// tambahkan titik jika yang di input sudah menjadi angka ribuan
				if(ribuan){
					separator = sisa ? '.' : '';
					rupiah += separator + ribuan.join('.');
				}

				rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
				return prefix == undefined ? rupiah : (rupiah ? 'Rp. ' + rupiah : '');
			}
		});
		

	</script>


</html>