<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%> 
<%@ include file="../common/init.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="fragment" content="!">
  
  <link rel="stylesheet" href="print.css" media="print" />
  
  <style type="text/css">
  	body{
  		 margin: 0 1 0 1;
  	}

  		p{
  			line-height:1.5em;
  			font-size:4mm;
  		}
  		table{
  			border-collapse: collapse;
  		}
  		table th,table td{
  			padding:1px;
  		}
  		.block-center{
  			display: block;
  			margin:0 auto;
  		}
  		.text-right{
  			text-align: right;
  		}
  		.text-center{
  			text-align: center;
  		}
  		p.text-indent{
  			text-indent: 2em;
  		}
  		.page{
  			/**margin-top:25mm;**/
  			page-break-after: always;
  		}
  		.whole{
  			page-break-inside: avoid;
  		}
  </style>
  <!--[if lte IE 8]
<script src="js/json2.js"></script>
<![endif]-->


</head>
<body>
	<c:forEach items="${list}" var="row">
		<div class="page Section1">
			<c:if test="${row.provCode != 10 }">
				<h3 style="font-size:4.5mm;" >${row.provName}高等教育自学考试办公室：</h3>
				<p style="font-size:4mm;" class="text-indent">按全国考委的要求，现将我省承担${config.examTime}全国统考课程的${label}<a style="display: ${printType == 1 ? '' : 'none' }">（<c:if test="${row.paperType == 'BLANK'}">白纸两份</c:if><c:if test="${row.paperType == 'ACID'}">白纸、硫酸纸各一份</c:if>）</a>寄给你们，请查收。</p>
			</c:if>
			<c:if test="${row.provCode == 10 }">
				<h3 style="font-size:4.5mm;" >全国高等教育自学考试指导委员会办公室：</h3>
				<p style="font-size:4mm;" class="text-indent">按全国考委的要求，现将我省承担${config.examTime}全国统考课程的${label}<a style="display: ${printType == 1 ? '' : 'none' }">（<c:if test="${row.paperType == 'BLANK'}">白纸一份</c:if><c:if test="${row.paperType == 'ACID'}">白纸、硫酸纸各一份</c:if>）</a>寄给你们，请查收。</p>
			</c:if>
			
			<div class="block-center text-center">
				<c:if test="${printType == 1 }">
				 	<c:set var="courseCount" value="0" />
				 	<c:forEach items="${row.courseGroups}" var="courseGroup">
				 		<c:set var="courseCount" value="${fn:length(courseGroup) + courseCount}" />
					</c:forEach>
				 </c:if>
				<c:if test="${printType == 2}">
			 		<c:set var="courseCount" value="${fn:length(row.courses)}" />
				</c:if>	
				
				<!-- 当课程数量小于等于30，只需打印一个表格 -->
				<c:if test="${courseCount <= 30 }">	 
					<table border="1" style="margin-left:25%;font-size:3.5mm;">
						<thead>
							<tr>
								<th width="30">序</th>
								<th width="60">代码</th>
								<th width="160">课程名称</th>
								<th width="80">专用答题卡</th>
							</tr>
						</thead>
						<tbody>
							<!-- 试卷 -->
							 <c:if test="${printType == 1 }">
							 	<c:set var="globalIndex" value="0" />
							 	<c:forEach items="${row.courseGroups}" var="courseGroup">
								 	<c:forEach items="${courseGroup}" var="c" varStatus="idx">
								 		<c:set var="globalIndex" value="${globalIndex + 1}" />
										<tr>
											<td>${globalIndex}</td>
											<td>${c.courseCode}</td>
											<td nowrap="nowrap">${c.courseName}</td>
											<td nowrap="nowrap">${c.zyDesc}</td>
											<%--<c:if test="${idx.index == 0}">
												<td rowspan="${fn:length(courseGroup)}" >
													<c:if test="${c.paperFormat == '所有' }">
														<!--合卷<br/>网评卷<br/>各一<br/>份     2016-01-20 张璇要求把“分卷”改成“网评卷” -->
														网评卷<!-- 2017-07-11 张晶晶要求去掉“合卷”-->
													</c:if>
													<c:if test="${c.paperFormat != '所有' }">
														${c.paperFormat}
													</c:if>
												</td>
											</c:if> --%>
										</tr>
									</c:forEach>
								</c:forEach>
							 	
							 </c:if>
							 <!-- 答案 -->
							 <c:if test="${printType == 2}">
							 	<c:forEach items="${row.courses}" var="c" varStatus="idx">
									<tr>
										<td>${idx.index+1}</td>
										<td>${c.courseCode}</td>
										<td nowrap="nowrap">${c.courseName}</td>
										<c:if test="${idx.index == 0}">
											<!-- 国家的答案只打印一份 -->
											<c:if test="${c.paperFormat == '所有' }">
												<td rowspan="${row.courseCount }" >答案<br />一份</td>
											</c:if>
											<!-- 其他省份的答案打印两份 -->
											<c:if test="${c.paperFormat != '所有' }">
												<td rowspan="${row.courseCount }" >答案<br />两份</td>
											</c:if>
										</c:if>
									</tr>
								</c:forEach>
							 </c:if>
						</tbody>
					</table>
				</c:if>
				
				<!-- 当课程数量大于30，一行打印两个表格 -->
				<c:if test="${courseCount > 30 }">
					<!-- 表格1：打印1~30 -->
					<table border="1" style="font-size:3.5mm;float:left;">
						<thead>
							<tr>
								<th width="30">序</th>
								<th width="60">代码</th>
								<th width="160">课程名称</th>
								<th width="80">专用答题卡</th>
							</tr>
						</thead>
						<tbody>
							<!-- 试卷 -->
							 <c:if test="${printType == 1 }">
							 	<c:set var="globalIndex" value="1" />
							 	<c:forEach items="${row.courseGroups}" var="courseGroup">
								 	<c:forEach items="${courseGroup}" var="c" varStatus="idx">
								 		<c:if test="${globalIndex <= 30 }">
											<tr>
												<td>${globalIndex}</td>
												<td>${c.courseCode}</td>
												<td nowrap="nowrap">${c.courseName}</td>
												<td nowrap="nowrap">${c.zyDesc}</td>
												<%-- <c:if test="${idx.index == 0}">
													<!-- 记录当前分组开始的index，为表格2开头合并单元格数量提供计算依据 -->
													<c:set var="curGroupStartIdx" value="${globalIndex}" /> 
													<td rowspan="${(fn:length(courseGroup) <= (31-globalIndex)) ? (fn:length(courseGroup)) : (31-globalIndex)}" >
														<c:if test="${c.paperFormat == '所有' }">
															<!--合卷<br/>网评卷<br/>各一<br/>份     2016-01-20 张璇要求把“分卷”改成“网评卷” -->
															网评卷<!-- 2017-07-11 张晶晶要求去掉“合卷”-->
														</c:if>
														<c:if test="${c.paperFormat != '所有' }">
															${c.paperFormat}
														</c:if>
													</td>
												</c:if> --%>
											</tr>
										</c:if>
										<c:set var="globalIndex" value="${globalIndex + 1}" />
									</c:forEach>
								</c:forEach>
							 	
							 </c:if>
							 <!-- 答案 -->
							 <c:if test="${printType == 2}">
							 	<c:forEach items="${row.courses}" var="c" varStatus="idx" end="29">
									<tr>
										<td>${idx.index+1}</td>
										<td>${c.courseCode}</td>
										<td nowrap="nowrap">${c.courseName}</td>
										<td nowrap="nowrap">${c.zyDesc}</td>
										<%-- <c:if test="${idx.index == 0}">
											<!-- 国家的答案只打印一份 -->
											<c:if test="${c.paperFormat == '所有' }">
												<td rowspan="30" >答案<br />一份</td>
											</c:if>
											<!-- 其他省份的答案打印两份 -->
											<c:if test="${c.paperFormat != '所有' }">
												<td rowspan="30" >答案<br />两份</td>
											</c:if>
										</c:if> --%>
									</tr>
								</c:forEach>
							 </c:if>
						</tbody>
					</table>
					<!-- 表格2：打印31~结束 -->
					<table border="1" style="font-size:3.5mm;float:right;">
						<thead>
								<th width="30">序</th>
								<th width="60">代码</th>
								<th width="160">课程名称</th>
								<th width="80">专用答题卡</th>
						</thead>
						<tbody>
							<!-- 试卷 -->
							 <c:if test="${printType == 1 }">
							 	<c:set var="globalIndex" value="1" />
							 	<c:forEach items="${row.courseGroups}" var="courseGroup">
								 	<c:forEach items="${courseGroup}" var="c" varStatus="idx">
								 		<c:if test="${globalIndex > 30 }">
											<tr>
												<td>${globalIndex}</td>
												<td>${c.courseCode}</td>
												<td nowrap="nowrap">${c.courseName}</td>
												<td nowrap="nowrap">${c.zyDesc}</td>
												<%-- <c:if test="${idx.index == 0}">													
													<td rowspan="${fn:length(courseGroup)}" >${c.paperFormat}</td>
												</c:if>
												<c:if test="${idx.index != 0 && globalIndex == 31}">													
													<td rowspan="${fn:length(courseGroup) - globalIndex + curGroupStartIdx}" >
														<c:if test="${c.paperFormat == '所有' }">
															<!--合卷<br/>网评卷<br/>各一<br/>份     2016-01-20 张璇要求把“分卷”改成“网评卷” -->
															网评卷<!-- 2017-07-11 张晶晶要求去掉“合卷”-->
														</c:if>
														<c:if test="${c.paperFormat != '所有' }">
															${c.paperFormat}
														</c:if>
													</td>
												</c:if> --%>
											</tr>
										</c:if>
										<c:set var="globalIndex" value="${globalIndex + 1}" />
									</c:forEach>
								</c:forEach>
							 	
							 </c:if>
							 
							 <!-- 答案 -->
							 <c:if test="${printType == 2}">
							 	<c:forEach items="${row.courses}" var="c" varStatus="idx" begin="30">
									<tr>
										<td>${idx.index+1}</td>
										<td>${c.courseCode}</td>
										<td nowrap="nowrap">${c.courseName}</td>
										<td nowrap="nowrap">${c.zyDesc}</td>
										<%-- <c:if test="${idx.index == 30}">
											<!-- 国家的答案只打印一份 -->
											<c:if test="${c.paperFormat == '所有' }">
												<td rowspan="${row.courseCount-30 }" >答案<br />一份</td>
											</c:if>
											<!-- 其他省份的答案打印两份 -->
											<c:if test="${c.paperFormat != '所有' }">
												<td rowspan="${row.courseCount-30 }" >答案<br />两份</td>
											</c:if>
										</c:if> --%>
									</tr>
								</c:forEach>
							 </c:if>
						</tbody>
					</table>
					<div style="clear:both;"></div>
				</c:if>
			</div>
			<p class="text-right" style="line-height:1em">${config.sendAddress}</p>
			<p class="text-right" style="line-height:1em"><fmt:formatDate value="<%=new Date() %>"  pattern="M/d/yyyy" /></p>
			<div class="whole">
			<hr />
			<h2 class="text-center">回  执</h2>
			<h3 style="font-size:4.5mm;">${config.sendAddress}</h3>
			<p class="text-indent">你命题中心寄来的${config.examTime}全国统考课程的${label}收悉，经核实无误，特此回告。</p>
			<c:if test="${row.provCode != 10 }">
				<p class="text-right" style="line-height:1em">
					<span style="text-decoration: underline;">&nbsp;${row.provName}&nbsp;</span>
					高等教育自学考试办公室（盖章）
				</p>
			</c:if>
			<c:if test="${row.provCode == 10 }">
				<p class="text-right" style="line-height:1em">
					全国高等教育自学考试指导委员会办公室（盖章）
				</p>
			</c:if>
			<p class="text-right" style="line-height:1em">年&nbsp;&nbsp;月&nbsp;&nbsp;日</p>
			</div>
		</div>
	</c:forEach>
</body>
</html>
