
function call_fee_std_list(class_id){
	var datastr = "class_id="+class_id;
	//alert(datastr);
	$('#fee_std_list').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;'>Data Loading.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
	$("#fee_std_list").load("module/fees/fee_std_list.php",datastr);
}


function create_invoice(){
	//var opr = 'inv_cr';
	var opr = 'yearly_inv_cr';
	
	var datastr = "opr="+opr;
	$('#message').show("");
	$('#message').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;text-align:center;'>Invoice Creating.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
		
		//$("#invoice_res").load("module/fees/fee_invoice_ajax.php",datastr);
		
		/*
		$('#invoice_res').load('module/fees/invoice_fee_summary.php',{},function(data)
		{
		//alert(data);
		});		
		*/
	
	$.ajax({
			type:"post",
			url:"module/fees/fee_invoice_ajax.php",
			data:datastr ,
			success:function(result){
				
				//alert(result);
				if(result==1){
				alert('Invoice Create Successful');
				$('#message').hide("");
				$("#invoice_summary").load('module/fees/invoice_fee_summary.php');
				$('#invoice_info').hide("");
				$('#invoice_button').hide("");
				}else{
						alert('New Data Not Available');
						$('#message').hide("");
						$('#invoice_info').show("");
						alert('fail');
					}
				
				
			}
		});
}





















function delete_all_null_invoice(){
	var opr = 'inv_del';
	var datastr = "opr="+opr;
	
	if (confirm("Are You Confirmed To Continue!") == true) {
	$('#message').html("<span style='color:red;font-size:20px;'>Invoice Deleting.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
	
	//$("#invoice_res").load("module/fees/fee_invoice_ajax.php",datastr);
	
	$.ajax({
			type:"post",
			url:"module/fees/fee_invoice_ajax.php",
			data:datastr ,
			success:function(result){
				//alert(result);
				if(result==4){
					$('#message').html("<span style='background-color:#FF0000; padding:10px; color:#FFFFFF;'>Delete Successful</sapn>");
					$("#message").show().delay(5000).fadeOut();
					
					}
				if(result==3){
					//alert(result);
					$('#message').html("<span style='background-color:#FF0000; padding:10px; color:#FFFFFF;'>UnInvoice Data Not Available</sapn>");
					$("#message").show().delay(5000).fadeOut();
					}
				
			}
		});
	
	}else{
		
		}
}






// ===================================


function call_medium(id){
	var datastr="shift_id="+id;
	$("#medium_id").load("module/settings/get_medium_list_for_form.php",datastr);
}
function call_class(id){
	var datastr="medium_id="+id;
	$("#class_id").load("module/settings/get_class_list_for_form.php",datastr);
}

function show_edit(student_id,month,year){

var datastr = "student_id="+student_id+"&month="+month+"&year="+year;
//alert(datastr);
$("#model_table_value_edit").load("module/fees/edit_invoice.php",datastr);

//$('.chzn-select').css("width","200px");

}

function delete_invoice(id,student_id,month,year,class_id){

    var operation = 'delete';
	var datastr="id="+id+"&operation="+operation;
	var datastr1 = "student_id="+student_id+"&month="+month+"&year="+year;
	var datastr2="class_id="+class_id;
	
	//var datastr2="section_id="+section_id;
	
	//alert(datastr);
	$.ajax({
			type:"post",
			url:"module/fees/fee_invoice_ajax.php",
			data:datastr ,
			success:function(result){
				
					$("#model_table_value_edit").load("module/fees/edit_invoice.php",datastr1);
				$("#fee_std_list").load("module/fees/fee_std_list.php",datastr2);
				alert(result);
				

			}
		});
	}



//==========================================//

function call_update_invoice(){


	

	var tr = $("#btn_invoice").parents('#modal-table_edit').find('div#model_table_value_edit table tbody tr');
	

	$(tr).each(function(){
		   //alert($(this).find('td:eq(1) select').val());
		  var oper='update';
		  var e_fee_head = $(this).find('td:eq(1) select').val();
		  var e_amount = $(this).find('td:eq(2) input#e_amount').val();
		  var id = $(this).find('td:eq(2) input#e_id').val();
		  var e_purpuse = $(this).find('td:eq(3) input#e_purpuse').val();

		  var datastr="oper="+oper+"&e_fee_head="+e_fee_head+"&e_amount="+e_amount+"&e_purpuse="+e_purpuse+"&id="+id;
         
         
		   

          //alert(datastr1);

		  	if(e_fee_head==""){
			alert("Enter Fee Head");
			$('#e_fee_head').focus();
			
			
			}
			else if(e_amount==""){
				alert("Enter Amount");
				$('#e_amount').focus();
				
			}	
			else if(e_purpuse==""){
				alert("Select Purpose");
				$('#e_purpuse').focus();

				
			
			}
			
			else{
				$.ajax({
					type:"post",
					url:"module/fees/fee_invoice_ajax.php",
					data:datastr ,
					success:function(result){	
						$(".section_wise_scholarship").load("module/fees/sec_scholar_std_list.php",datastr);
						alert(result);	
					}
				});
			}

	});


	
}

$("#invoice_show").click(function(){
 		 $("#inv_details").show();
		 $("#invoice_hide").show();
		 $("#invoice_show").hide();
 });

$("#invoice_hide").click(function(){
 		 $("#inv_details").hide();
		 $("#invoice_hide").hide();
		 $("#invoice_show").show();
 });