<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ include file="../../common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../../common/top.jsp"%>
<!--%@ include file="../../common/analysis.jsp"%-->
<title>成绩分析-教研室-区县统计</title>
</head>
<body>
<div id="content">
	<%@ include file="menu.jsp"%>
	<div id="area">
	<div class="breadcrumb">当前位置：教研室报告 &gt; <span>区县统计</span></div>
	<form id="paraForm" name="paraForm" action="post" target="reportFrame">
	   <div class="area-header">　
	   		<input type="hidden" class="report-parameter" name="area_code" value="${areaCode}"/>
			<%@ include file="../common/exam-select.jsp"%>
			<%@ include file="../common/class-type-select.jsp"%>
			<%@ include file="../common/graduate-type-select.jsp"%>
			<%@ include file="../common/report-button.jsp"%>
	   </div>
	   </form>
	   <div class="area-body">
	   	<iframe id="reportFrame" name="district/report_all.cpt" width="100%" height="100%" frameBorder="0" scrolling="no"></iframe>
	</div>
	</div>
</div>
<%@ include file="../../common/footer.jsp"%>
<script>
$(function(){
	$('#reportButton').click(function(){
		var class_type = $("#class_type").val();
		if(class_type==1){
			$("#reportFrame").attr("name","district/report_arts.cpt");
		}else if(class_type==2){
			$("#reportFrame").attr("name","district/report_science.cpt");
		}else{
			$("#reportFrame").attr("name","district/report_all.cpt");
		}
		var reportName = $('#reportFrame').attr('name');
		var parameter = '';
		$('.report-parameter').each(function(index, obj){
			var name = $(this).attr('name');
			var value = $(this).val();
			if(name!=undefined && name!=''){
				if(value==undefined || value.length==0){
					alert("请确认所有报表条件已选择！");
					parameter = '';
					return false;
				}else{
					parameter = parameter + "&" + name + "=" + value;
				}
			}
		});
		$('.report-parameter-optional').each(function(index, obj){
			var name = $(this).attr('name');
			var value = $(this).val();
			if(name!=undefined && name!=''){
				if(value!=undefined && value.length>0){
					parameter = parameter + "&" + name + "=" + value;
				}
			}
		});
		$('.warning').each(function(){
			$(this).show();
		});
		if(parameter.length>0){
			$('#reportButton').attr("disabled","disabled");
			var reportURL = cjkEncode("${properties['report.server']}/"+reportName+parameter);
			$('#reportFrame').attr('src',reportURL);
		}
	})
	$('.warning-close a').click(function(){
		$(this).parent().parent().hide();
	});
	$('#reportFrame').load(function(){
		$('#reportButton').removeAttr("disabled");
	})
})

//cjkEncode方法的实现代码，放在网页head中或者用户自己的js文件中  
function cjkEncode(text) {                                                                            
  if (text == null) {         
    return "";         
  }         
  var newText = "";         
  for (var i = 0; i < text.length; i++) {         
    var code = text.charCodeAt (i);          
    if (code >= 128 || code == 91 || code == 93) {  //91 is "[", 93 is "]".         
      newText += "[" + code.toString(16) + "]";         
    } else {         
      newText += text.charAt(i);         
    }         
  }         
  return newText;         
}
</script>
</body>
</html>

