function save_previus_due() { 

	
	if ($('#pre_due').is(":checked"))
	{
  		var pre_due = $('#pre_due').val();
	}
	else
	{
		var pre_due = '';
	}
	if ($('#payment_late_fine').is(":checked"))
	{
  		var payment_late_fine = $('#payment_late_fine').val();
	}
	else
	{
		var payment_late_fine = '';
	}
	var shift_id = $("#shift_id").val();
	var medium_id = $("#medium_id").val();
	var class_id = $("#class_id").val();
	var dept_id = $("#dept_id").val();
	//var std_id = $.trim($("#std_uniq_id").val());
	var month = $('select[name="month"]').val();
	var year = $('select[name="year"]').val();
	var payment_last_date = $('input[name="payment_last_date"]').val();
	var oper = 'prdu';
	if (confirm("Are You Confirmed To Continue!") == true) {
	var datast_prdu ="oper="+oper+"&shift_id="+shift_id+"&medium_id="+medium_id+"&class_id="+class_id+"&dept_id="+dept_id+"&month="+month+"&year="+year+"&pre_due="+pre_due+"&payment_last_date="+payment_last_date+"&payment_late_fine="+payment_late_fine;
	$(".loading").show();
	$('.loading').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;'>Data Generating.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
	//alert(datast_prdu);
	//alert(datast_schfs);


	
	if(shift_id==""){
		alert("Please Select Shift");
		$('#shift_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(medium_id==""){
		alert("Please Select Medium");
		$('#medium_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(class_id==""){
		alert("Please Select Class");
		$('#class_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(dept_id==""){
		alert("Please Select Deparment");
		$('#dept_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(month==""){
		alert("Select Month");
		$('#month').focus();
		return false;
	}
	else if(year==""){
		alert("select Year");
		$('#year').focus();
		return false;
	}else if(pre_due==='' && payment_late_fine==''){
	alert("Checked Any One Or Both");
		$('#pre_due').focus();
		$(".loading").hide();
		document.getElementById("pre_due").disabled = false;
		return false;
	}
	/*else if(pre_due==""){
		alert("Are You Agree ?");
		$('#pre_due').focus();
		$(".loading").hide();
		document.getElementById("previus_due").disabled = false;
		return false;
	}*/
	
	else{
		$.ajax({
			type:"post",
			url:"module/fees/class_generate_fee_ajax.php",
			data:datast_prdu ,
			success:function(result){
				alert(result);
				$(".loading").hide();
			}
		});
	}
  }else{
	  
	  }

	
}


function save_other_fee() { 

	
	if ($('#other_fee').is(":checked"))
	{
  		var other_fee = $('#other_fee').val();
	}
	else
	{
		var other_fee = '';
	}
	
	var shift_id = $("#shift_id").val();
	var medium_id = $("#medium_id").val();
	var class_id = $("#class_id").val();
	var dept_id = $("#dept_id").val();
	//var std_id = $.trim($("#std_uniq_id").val());
	var month = $('select[name="month"]').val();
	var year = $('select[name="year"]').val();
	var payment_last_date = $('input[name="payment_last_date"]').val();
	var oper = 'other';
	if (confirm("Are You Confirmed To Continue!") == true) {
	var datast_other ="oper="+oper+"&shift_id="+shift_id+"&medium_id="+medium_id+"&class_id="+class_id+"&dept_id="+dept_id+"&month="+month+"&year="+year+"&other_fee="+other_fee+"&payment_last_date="+payment_last_date;
	$(".loading").show();
	$('.loading').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;'>Data Generating.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
	//alert(datast_other);
	//alert(datast_schfs);


	
	if(shift_id==""){
		alert("Please Select Shift");
		$('#shift_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(medium_id==""){
		alert("Please Select Medium");
		$('#medium_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(class_id==""){
		alert("Please Select Class");
		$('#class_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(dept_id==""){
		alert("Please Select Deparment");
		$('#dept_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(month==""){
		alert("Select Month");
		$('#month').focus();
		return false;
	}
	else if(year==""){
		alert("select Year");
		$('#year').focus();
		return false;
	}else if(other_fee===''){
	alert("Checked Other Fee");
		$('#other_fee').focus();
		$(".loading").hide();
		document.getElementById("other_fee").disabled = false;
		return false;
	}else{
		$.ajax({
			type:"post",
			url:"module/fees/class_generate_fee_ajax.php",
			data:datast_other ,
			success:function(result){
				alert(result);
				$(".loading").hide();
			}
		});
	}
  }else{
	  
	  }

	
}

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

function save_scholar() { 

	
	if ($('#scholar_generate').is(":checked"))
	{
	  var scholar_generate = $('#scholar_generate').val();
	}
	else
	{
		var scholar_generate = '';
	}
	var shift_id = $("#shift_id").val();
	var medium_id = $("#medium_id").val();
	var class_id = $("#class_id").val();
	var dept_id = $("#dept_id").val();
	var month = $('select[name="month"]').val();
	var year = $('select[name="year"]').val();
	var oper = 'schfs';
	var payment_last_date = $('input[name="payment_last_date"]').val();

	var datast_schfs ="oper="+oper+"&shift_id="+shift_id+"&medium_id="+medium_id+"&class_id="+class_id+"&dept_id="+dept_id+"&month="+month+"&year="+year+"&scholar_generate="+scholar_generate+"&payment_last_date="+payment_last_date;
	//alert(datast_schfs);
	$(".loading").show();
	$('.loading').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;'>Data Generating.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
	//alert(datast_schfs);

	
	if(shift_id==""){
		alert("Please Select Shift");
		$('#shift_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(medium_id==""){
		alert("Please Select Medium");
		$('#medium_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(class_id==""){
		alert("Please Select Class");
		$('#class_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(dept_id==""){
		alert("Please Select Deparment");
		$('#dept_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(month==""){
		alert("Select Month");
		$('#month').focus();
		return false;
	}
	else if(year==""){
		alert("select Year");
		$('#year').focus();
		return false;
	}
	else if(scholar_generate==""){
		alert("Are You Agree ?");
		$('#scholar_generate').focus();
		$(".loading").hide();
		document.getElementById("scholar").disabled = false;
		return false;
	}
	
	else{
		$.ajax({
			type:"post",
			url:"module/fees/class_generate_fee_ajax.php",
			data:datast_schfs ,
			success:function(result){
				alert(result);
				$(".loading").hide();
			}
		});
	}

	
}



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

function save_atd_fine() { 
	var shift_id = $("#shift_id").val();
	var medium_id = $("#medium_id").val();
	var class_id = $("#class_id").val();
	var dept_id = $("#dept_id").val();
	var month = $('select[name="month"]').val();
	var year = $('select[name="year"]').val();
	var abs_fine = $('input[name="abs_fine"]:checked').val();
	var abs_fine_head = $('#abs_fine_head').val();

	var late_fine = $('input[name="late_fine"]:checked').val();
	var late_fine_head = $('#late_fine_head').val();

	//alert(abs_fine);

	var oper = 'afs';
	var payment_last_date = $('input[name="payment_last_date"]').val();

	var datast_afs ="oper="+oper+"&shift_id="+shift_id+"&medium_id="+medium_id+"&class_id="+class_id+"&dept_id="+dept_id+"&month="+month+"&year="+year+"&abs_fine="+abs_fine+"&abs_fine_head="+abs_fine_head+"&late_fine="+late_fine+"&late_fine_head="+late_fine_head+"&payment_last_date="+payment_last_date;
	//alert(datast_afs);
	$(".loading").show();
	$('.loading').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;'>Data Generating.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
	
	if(shift_id==""){
		alert("Please Select Shift");
		$('#shift_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(medium_id==""){
		alert("Please Select Medium");
		$('#medium_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(class_id==""){
		alert("Please Select Class");
		$('#class_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(dept_id==""){
		alert("Please Select Deparment");
		$('#dept_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(month==""){
		alert("Select Month");
		$('#month').focus();
		return false;
	}
	else if(year==""){
		alert("select Year");
		$('#year').focus();
		return false;
	}
	else if(abs_fine!="absent_fine" && late_fine!="late_fine"){
		alert("Checked Any One");
		$('#abs_fine').focus();
		$(".loading").hide();
		document.getElementById("atd_fine").disabled = false;
		return false;
	}
	else if(abs_fine=="absent_fine" && abs_fine_head==""){
		alert("Write Absent Fee Head");
		$('#abs_fine_head').focus();
		$(".loading").hide();
		return false;
	}
	else if(late_fine=="late_fine" && late_fine_head==""){
		alert("Write Late Fee Head");
		$('#late_fine_head').focus();
		$(".loading").hide();
		return false;
	}

	else{
		$.ajax({
			type:"post",
			url:"module/fees/class_generate_fee_ajax.php",
			data:datast_afs ,
			success:function(result1){
				alert(result1);
				$(".loading").hide();
			}
		});
	}



}


function calcul() { 
var class_id 		= $("#class_id").val();
var step_id 		= $("#step_id").val();
var year 			= $("#year").val();
var total_count 	= $("#total_count").val();
//alert(step_id);

if(class_id==""){
			alert("Please Select Class. Otherwise Not Show Unpaid Invoice.");
			$('#class_id').focus();
			return false;
		}else{
				if(step_id==3){
					if(total_count>0){
						alert('Please Previous Due Calculate.');
					}
				}
				var str="class_id="+class_id+"&step_id="+step_id+"&year="+year;
				$.ajax({
						type:"post",
						url:"module/fees/class_wise_calculate_ajax.php",
						data:str ,
						success:function(result){
							//alert(result);
							$("#calcul_info").html(result);
						}
					});
		}
}

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

function save_monthly_fee() { 
	var shift_id 	= $("#shift_id").val();
	var medium_id 	= $("#medium_id").val();
	var class_id 	= $("#class_id").val();
	var dept_id 	= $("#dept_id").val();
	var month 		= $('select[name="month"]').val();
	var year 		= $('select[name="year"]').val();	
	var fee_ids 	= $('input[name="fee_ids"]').val();
	var payment_last_date = $('input[name="payment_last_date"]').val();
	var oper = 'mfs';

	var datast_mfs ="oper="+oper+"&shift_id="+shift_id+"&medium_id="+medium_id+"&class_id="+class_id+"&dept_id="+dept_id+"&month="+month+"&year="+year+"&fee_ids="+fee_ids+"&payment_last_date="+payment_last_date;
	$(".loading").show();
	$('.loading').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;text-align:center;'>Data Generating.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
	
	if(shift_id==""){
		alert("Please Select Shift");
		$('#shift_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(medium_id==""){
		alert("Please Select Medium");
		$('#medium_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(class_id==""){
		alert("Please Select Class");
		$('#class_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(dept_id==""){
		alert("Please Select Department");
		$('#dept_id').focus();
		$(".loading").hide();
		return false;
	}
	else if(month==""){
		alert("Select Month");
		$('#month').focus();
		return false;
	}
	else if(year==""){
		alert("select Year");
		$('#year').focus();
		return false;
	}
	else if(fee_ids==""){
		alert("Checked any Fee Type");
		$('.fee_id').focus();
		$(".loading").hide();
		document.getElementById("test").disabled = false;
		return false;
	}
	else{
		$.ajax({
			type:"post",
			url:"module/fees/class_generate_fee_ajax.php",
			data:datast_mfs ,
			success:function(result){
					alert(result);
					$(".loading").hide();
			}
		});
		/*$.ajax({
			type:"post",
			url:"module/fees/class_generate_fee_ajax2.php",
			data:datast_mfs ,
			success:function(result1){
				//alert(result1);
				if(result1!=2){
					if(result1==0){
						if (confirm("Attention Please! Your Previous Month Not Entry. Are You Agree To Contine ...") == true){
						//alert(result);
						$.ajax({
								type:"post",
								url:"module/fees/class_generate_fee_ajax.php",
								data:datast_mfs ,
								success:function(result){
									alert(result);
									$(".loading").hide();
								}
							});
						}else{
							$(".loading").hide();
						}
					}else{
						$.ajax({
								type:"post",
								url:"module/fees/class_generate_fee_ajax.php",
								data:datast_mfs ,
								success:function(result){
									alert(result);
									$(".loading").hide();
								}
							});
						}
				}else{
						$.ajax({
								type:"post",
								url:"module/fees/class_generate_fee_ajax.php",
								data:datast_mfs ,
								success:function(result){
									alert(result);
									$(".loading").hide();
								}
							});
					}
			}
		});*/
		/*$.ajax({
			type:"post",
			url:"module/fees/class_generate_fee_ajax.php",
			data:datast_mfs ,
			success:function(result){
				alert(result);
				$(".loading").hide();
			}
		});*/
	}

	
}


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

function monthly_fee_select() {

    var permited =[];
    $('input[name="fee_id[]"]').each(function () {
       if($(this).is(':checked')==true)
        {
          permited.push(this.value);
        }
    });                
     var s = $('#fee_token').val(permited);
  
}

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

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

function edit_call_medium(id){
	var str="shift_id="+id;
	$("#e_medium_id").load("module/settings/get_medium_list_for_form.php",str);
}

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


function call_department(id){
	var str="class_id="+id;
	$("#dept_id").load("module/settings/get_department_list_for_form.php",str);
}

function edit_call_class(id){
	var str="medium_id="+id;
	$("#e_class_id").load("module/settings/get_class_list_for_form.php",str);
}

function edit_call_dept(id){
	var str="class_id="+id;
	$("#e_dept_id").load("module/settings/get_department_list_for_form.php",str);
}

