
$(document).keypress(function(event) {
    var keycode = (event.keyCode ? event.keyCode : event.which);

    if(keycode == '13'){
    	  var mod_id = $("#mod_id").val();
        var invoice = $("#invoice").val();
        var datastr = "invoice="+invoice+"&mod_id="+mod_id;
    	$("#call_det_invoice").load("module/fees/fee_receive.php",datastr);
    }
  
});

$("#search").click(function(){
      var mod_id 	= $("#mod_id").val();
      var invoice 	= $("#invoice").val();
      var datastr 	= "invoice="+invoice+"&mod_id="+mod_id;
	  $("#call_det_invoice").show();
	$('#call_det_invoice').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;'>Data Generating.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
      $("#call_det_invoice").load("module/fees/fee_receive.php",datastr);
 });
// =============================================================

$("#submit12").click(function(){
    var discount 	= $("#discount").val();
    var inv 		= $("#inv").val();
    var mod_id 		= $("#mod_id_1").val();
    var amount 		= $("#amount").val();
	var last_payment_date = $("#last_payment_date").val();
	var chk_today 		= $("#today").val();
    var datastr 	= "invoice="+inv+"&discount="+discount+"&amount="+amount+"&mod_id="+mod_id;
	
    if(chk_today>last_payment_date){
		 if (confirm("Are You Confirmed To Add Late Fine!") == true) {
			 $('#call_det_invoice').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;'>Data Generating.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
		$("#call_det_invoice").load("module/fees/fee_receive_chk.php",datastr);
		 }else{
			$.ajax({
			type:"get",
			url:"module/fees/fee_rec_conf.php",
			data:datastr ,
			success:function(result){
			  //alert(result);
				load();
				 //$("#main_content_div").load("module/fees/fee_collection.php");
				}
			});	 
		 }
	}else{
		$.ajax({
			type:"get",
			url:"module/fees/fee_rec_conf.php",
			data:datastr ,
			success:function(result){
			  //alert(result);
				load();
				 //$("#main_content_div").load("module/fees/fee_collection.php");
				}
			});	
		}
	
    /*if(parseFloat(discount)>parseFloat(amount)){
    	alert("Please Enter Discount Amount Less Then or Equal Payable Amount");
    	$('#discount').focus();
    	return false;
    }else{
		$.ajax({
			type:"get",
			url:"module/fees/fee_rec_conf.php",
			data:datastr ,
			success:function(result){
			  //alert(result);
				load();
				 //$("#main_content_div").load("module/fees/fee_collection.php");
			}
    	});
  	}*/
});

$("#submit13").click(function(){
    var discount 	= $("#discount").val();
    var inv 		= $("#inv").val();
    var mod_id 		= $("#mod_id_1").val();
    var amount 		= $("#amount").val();
	var last_payment_date = $("#last_payment_date").val();
	var chk_today 		= $("#today").val();
    var datastr 	= "invoice="+inv+"&discount="+discount+"&amount="+amount+"&mod_id="+mod_id;
	//alert(3);
	if (confirm("Are You Confirmed To Payment!") == true) {
		if(parseFloat(discount)>parseFloat(amount)){
			alert("Please Enter Discount Amount Less Then or Equal Payable Amount");
			$('#discount').focus();
			return false;
		}else{
			$.ajax({
				type:"get",
				url:"module/fees/fee_rec_conf.php",
				data:datastr ,
				success:function(result){
				  //alert(result);
					load();
					 //$("#main_content_div").load("module/fees/fee_collection.php");
				}
			});
		}
	}else{
		
		}
});

/* function load(){
	var std_id = $("#std_id").val();
	alert(std_id);
	var month = $("#_month").val();
	alert(month);
	var year = $("#_year").val();
	alert(year);
	var section_id = $("#_section_id").val();
	alert(section_id);
    $("#main_content_div").load("module/fees/student_invoice_pdf.php?stdid=std_id&month=month&year=year&section_id=section_id");
} */




function load(){
	var invoice = $("#invoice").val();
    var datastr = "invoice="+invoice;
    $("#main_content_div").load("module/fees/print_invoice.php",datastr);
}
$("#go_back").click(function(){
	 $("#main_content_div").load("module/fees/fee_collection.php");
	
});


