<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzLevelNumber" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.bulletin.*" %>
<%@ include file="/sessionInfo.jsp"%>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<script language="javascript">
  function save() {
    formUpdate.id1.value = 1;
    formUpdae.submit();
  }
</script>
</head>
<%
	//声明一个变量，接受更新页面传来的id，用来判断是否更新
 	HolidayXml holiday = new HolidayXml();
	String id1 = SzConvert.strWriteData(request.getParameter("id1"));
	String selectYear = SzConvert.toZeroStr(request.getParameter("selectYear"));
	if(id1.equals("1")){
  	//保存
		holiday.updateXml(request);
  	//out.println(SzPageHelp.jsAlert("保存成功"));
	}

  //读取数据
  ArrayList list = holiday.getList();
	int iSize = list.size() + 10;
	
	String value_str[] = null;

%>

<body >
<!-----上面的工具栏------>
<%@ include file="/share/title.jsp"%>
<form name="formUpdate" method="post" action="index.jsp?id=1" style="margin: 0px;" onsubmit="return check();">
<input type="hidden" name="id1" value="0">
<table width="100%">
  <tr>
    <td>
		<% if (isBarManager_SESSION) { %>
		<input type="submit"  class="btnClass" value="保存" onClick="javascript:save();">
		<% } %>
		<%
			String s_id[] = new String[100];
			for (int i=0; i<100; i++) {
				s_id[i] = Integer.toString(2015 + i);
			}
  		
 		 	out.println(SzPageHelp.selectArraySubmit(s_id, s_id, "selectYear", selectYear, "txtClass1")); 
		%>    
    </td>
    <td align="right">        
    </td>
  </tr>
</table>


		<table width="750"  bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="5" cellspacing="0">
				  <tr>
				  		<td align="center" width="30">序</td>
					    <td align="center">日期</td>
					    <td align="center">类型</td>
					    <td align="center">备注</td>					    
				  </tr>
		<% 
    	String str_id4[] = {"节假日","工作日"};
    	String str_name4[] = {"节假日","工作日"};
    	String tr= "<tr style='display:none;'>";
    	
			for (int i=0; i<iSize; i++) {
				if (i<list.size()) {
					value_str = (String[])list.get(i);
				} else {
					value_str = new String[3];
					SzConvert.initialArray(value_str,"");
				}
				if (value_str == null) {
					value_str = new String[3];
					SzConvert.initialArray(value_str,"");
				}
				tr= "<tr>";
				if (!selectYear.equals("") && !selectYear.equals("0")) {
					if (value_str[0].equals("")) {
						
					} else if (value_str[0].indexOf("-")<=0 || !value_str[0].substring(0, value_str[0].indexOf("-")).equals(selectYear)) {
						tr= "<tr style='display:none;'>";
					}					
				}
				out.println(tr);
		
		%>
				  
				  		<td align="center"><%=i + 1 %></td>
					    <td align="center"><input type="text" class="txtClass100" name="date<%=i%>" id="date<%=i%>" value="<%=value_str[0] %>">
					    <%=SzPageHelp.calendar2Select2("formUpdate.date" + i)%>
					    </td>
					    <td align="center">
    					<%
					    	out.println(SzPageHelp.select("type" +i, "type" + i, str_id4, str_name4, value_str[2], "txtClass100"));
    					%>  					    
					    </td>					    
					    <td align="center"><input type="text" class="txtClass350" name="name<%=i%>" value="<%=value_str[1] %>"></td>

				  </tr>
    <% } %>				  

		<input type="hidden" name="date_count" value="<%=iSize%>">	  
			
		</table>
</form>
</body>


<script language="javascript">
  	
	//将提交的信息进行验证
  function check(){
    var vCount = formUpdate.date_count.value;
    var date = "";
    var type = "";
    for (var v=0; v<vCount; v++) {
    	date = document.getElementById("date" + v);
    	type = document.getElementById("type" + v);
    	if (date != null && type == null) {
    		alert("请选择" + v + "行的类型");
    	}
    }
		return true;
  }
  
     
</script>
<%
    ////如果要使用日历控件，必须输出这个calendarFrame
    out.println(SzPageHelp.calendar2Frame2());
%>