// ===============================
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 call_department(id){
	var datastr="class_id="+id;
	$("#department_id").load("module/settings/get_department_list_for_form.php",datastr);
}
function call_std_type(id){
		var datastr="department_id="+id;
	$("#student_type_id").load("module/settings/get_student_type_list_for_form.php",datastr);
}
function call_section(id){
		var datastr="student_type_id="+id;
	$("#section_id").load("module/settings/get_section_list_for_form.php",datastr);
}


function show_edit(invoice_no){

var datastr = "invoice_no="+invoice_no;
//alert(datastr);
$("#model_table_value_edit").load("module/fees/fee_edit_invoice.php",datastr);

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

}

$("#btn_fee_head_search").click(function(){

	var month 	= $("#month").val();
	var year 	= $("#year").val();
	
	var dataStr="month="+month+"&year="+year;
	$('#fee_head_wise_summary').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;'>Data Generating.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
	 //alert(dataStr);
		$("#fee_head_wise_summary").load("module/fees/get_fee_head_summary.php",dataStr);

});

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 invoice_no = $(this).find('td:eq(2) input#e_invoice').val();

	  var datastr="oper="+oper+"&e_fee_head="+e_fee_head+"&e_amount="+e_amount+"&id="+id+"&invoice_no="+invoice_no;
          //alert(datastr);

		  	if(e_fee_head==""){
			alert("Enter Fee Head");
			$('#e_fee_head').focus();
			}
			else if(e_amount==""){
				alert("Enter Amount");
				$('#e_amount').focus();
			}	
			
			
			else{
				$.ajax({
					type:"post",
					url:"module/fees/edit_fee_invoice_ajax.php",
					data:datastr ,
					success:function(result){	
						$(".section_wise_scholarship").load("module/fees/sec_scholar_std_list.php",datastr);
						alert(result);	
					}
				});
			}

	});
	
}

// ===============
function call_std_invoice(){
	var month = $("#month").val();
	var year = $("#year").val();
	var shift_id = $("#shift_id").val();
	var medium_id = $("#medium_id").val();
	var class_id = $("#class_id").val();
	var department_id = $("#department_id").val();
	var student_type_id = $("#student_type_id").val();
	var section_id = $("#section_id").val();

	var datastr="section_id="+section_id+"&month="+month+"&year="+year;
	$(".section_wise_invoice").show();
	$('.section_wise_invoice').html("<span style='color:#2e8965;font-size:16px;font-weight:bold;'>Data Generating.... Please Wait.  <img src='php_crud/img/preloader.gif' /></span>");
	
	if(month==""){
		alert("Select Month");
		$('#month').focus();
		return false;
	}
	else if(year==""){
		alert("Select Year");
		$('#year').focus();
		$(".section_wise_invoice").hide();
		return false;
	}
	else if(shift_id==""){
		alert("Select Shift");
		$('#shift_id').focus();
		$(".section_wise_invoice").hide();
		return false;
	}
	else if(medium_id==""){
		alert("Select Medium");
		$('#medium_id').focus();
		$(".section_wise_invoice").hide();
		return false;
	}
	else if(class_id==""){
		alert("Select Class");
		$('#class_id').focus();
		$(".section_wise_invoice").hide();
		return false;
	}
	else if(department_id==""){
		alert("Select Department");
		$('#department_id').focus();
		$(".section_wise_invoice").hide();
		return false;
	}
	else if(student_type_id==""){
		alert("Select Student Type");
		$('#student_type_id').focus();
		$(".section_wise_invoice").hide();
		return false;
	}
	else if(section_id==""){
		alert("Select Section");
		$('#section_id').focus();
		$(".section_wise_invoice").hide();
		return false;
	}
	else{
		$('#first_part').css('display','none');
		$(".section_wise_invoice").load("module/fees/sec_std_invoice_list.php",datastr);
	}
}

function sec_wise_invoice_print(){
//alert(1);
    var month = $("#month").val();
	var year = $("#year").val();
	var shift_id = $("#shift_id").val();
	var medium_id = $("#medium_id").val();
	var class_id = $("#class_id").val();
	var department_id = $("#department_id").val();
	var student_type_id = $("#student_type_id").val();
	var section_id = $("#section_id").val();

	var datastr="shift_id="+shift_id+"&medium_id="+medium_id+"&class_id="+class_id+"&department_id="+department_id+"&student_type_id="+student_type_id+"&section_id="+section_id+"&month="+month+"&year="+year;

   //var finalpdf = month ;
    alert(datastr);
	if(month==""){
		alert("Select Month");
		$('#month').focus();
		return false;
	}
	else if(year==""){
		alert("Select Year");
		$('#year').focus();
		return false;
	}
	
	else if(shift_id==""){
		alert("Select Shift");
		$('#shift_id').focus();
		return false;
	}
	else if(medium_id==""){
		alert("Select Medium");
		$('#medium_id').focus();
		return false;
	}
	else if(class_id==""){
		alert("Select Class");
		$('#class_id').focus();
		return false;
	}
	else if(department_id==""){
		alert("Select Department");
		$('#department_id').focus();
		return false;
	}
	else if(student_type_id==""){
		alert("Select Student Type");
		$('#student_type_id').focus();
		return false;
	}
	else if(section_id==""){
		alert("Select Section");
		$('#section_id').focus();
		return false;
	}
	
	//exit();
	//var finalpdf = "month="+month+"&section_id="+section_id;

	//alert(finalpdf);
	//var pdf_value = $('#pdf_gen').val();

	//alert(pdf_value);

	//alert(datastr_sc);

	else{
		$.ajax({
			type:"post",
			url:"module/fees/invoice_report.php",
			data:datastr ,
			success:function(result){
				alert(result);
					//window.open('<?php echo $bs_url; ?>');
			}
		});
		
	}
}
function invoice_copy(inv_id,copy_type){
	//alert('hello');
	var datastr = "invoice_id="+inv_id+"&copy_type="+copy_type;
	//alert(datastr);
	window.open("module/fees/student_invoice_single_copy_pdf.php?"+datastr);
}
function all_invoice_copy(inv_id){
	//alert('hello');
	var datastr = "invoice_id="+inv_id;
	window.open("module/fees/student_invoice_all_copies_pdf.php?"+datastr);
	
}
