var collectionModule = (function () { 




 
 
 $('#ramount').on('keyup',function(){
 var ramount11=parseFloat($("#ramount").val());
 $("#ramount2").val(ramount11);
 
 });






    $('.supplierName-select-box').on('change',function(){
//alert("hi");
        var cid = $(this).val();
		//alert(cid);
		
        if(cid) {
			
            $.ajax({
				
                url: base_url+'fetchAjaxData/fetchpurpaymentPendingwo.php?cid='+cid,
                dataType: "json",
                type: 'GET',        
                success: function(data) {
                   $("#pamount").val(data[0].pamount.toFixed(2));
                },
                error: function() {
                    console.log('An error has occurred');
                }                
            });
            $.ajax({
                url: base_url+'fetchAjaxData/fetchpurchaseBillList.php?cid='+cid,
                dataType: "json",
                type: 'GET',        
                success: function(data) {
                                      
                    $("#pend_bill_list option").remove();
                    var selected = '<option value="">Select purchase Bill </option>';
                    $(data).each(function(index,value) {
                      selected =selected+"<option value='"+this.purchaseBillNo+"'>"+this.inv+"</option> ";
                    });
                    $("#pend_bill_list").append(selected);
                   
                },
                error: function() {
                    console.log('An error has occurred');
                }                
            });
        }

    });

    
    //paymentreference
	$( document ).ready(function() {
		//alert("hi");
	var ptype=$('#paymenttype').val();
	
	if(ptype=='cash')
	{
		$('#cash').show();
            $('.paymentreference').hide();
			$('#transactionno').hide();
			$('.bank').hide();
	}
	
	else {
            $('.paymentreference').show();
			$('#transactionno').show();
			$('.bank').show();
			$('#cash').hide();
			
			
        }
		
		
		
	
	
    $('.collect-paymenttype').on('change',function(){

        console.log('paymenttype :'+$(this).val());
        var paymentType = $(this).val();
        if(paymentType == 'cash') {
			$('#cash').show();
            $('.paymentreference').hide();
			$('#transactionno').hide();
			$('.bank').hide();
			
        } else {
            $('.paymentreference').show();
			$('#transactionno').show();
			$('.bank').show();
			$('#cash').hide();
			
			
        }

    });
	  });
})();