<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Map" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.*" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.guide.*" %>
<%@ include file="/sessionInfo.jsp"%>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
</head>
<%
    //获取提交的参数
    String sType = SzConvert.toZeroStr(request.getParameter("type"));
    String sPKEY = SzConvert.toZeroStr(request.getParameter("PKEY"));
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String sSearchName = SzConvert.strWriteData(request.getParameter("txtSearchName"));
    String XXFL = SzConvert.toZeroStr(request.getParameter("XXFL"));
    String FirstMKBH = SzConvert.toZeroStr(request.getParameter("FirstMKBH"));
    String FirstMKBH2 = SzConvert.toZeroStr(request.getParameter("FirstMKBH2"));
    
    Guide guide = new Guide();
    GuideInfo guideInfo = null;
    String sCond = "1=1";
		if (sType.equals("1")) {
			sCond = SzSqlConvert.getFuncLen() + "(ZNBH)=" + SzLevelNumber.I_NUMBER_LEN;
		} else if (sType.equals("2")) {
			sCond =  SzSqlConvert.getFuncLen() + "(ZNBH)<=" + SzLevelNumber.I_NUMBER_LEN * 2;
		}   
	  if (!FirstMKBH.equals("0")) {
	    sCond += " AND ZNBH LIKE '" + FirstMKBH + "%'";
	  }		
	  if (!FirstMKBH2.equals("0")) {
		    sCond += " AND ZNBH LIKE '" + FirstMKBH2 + "%'";
		}		  
    String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField"));
    int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder")));
    if (sSortField.equals("")) {
    	sSortField = "ZNBH";
    	iSortOrder = SzProperties.I_SortOrder_ASC;
    }
    int iCurrentPage = 1;
    try {
        iCurrentPage =  Integer.parseInt(sPage);
    }catch(Exception e) {
    }

    Iterator iter = guide.getArrayList(sCond, sSortField, iSortOrder, iCurrentPage, sSearch).iterator();

    SzPageInfo pageInfo = guide.getPageInfo();
    int iPageCount = pageInfo.getPageCount();
    int iRecordCount = pageInfo.getRecordCount();
    iCurrentPage = pageInfo.getCurrentPage();
    int i = 0;
    
%>
<!-----上面的工具栏------>
<%@ include file="/share/title.jsp"%>
<table width="100%">
  <form name="formBar" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">  
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>">
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">
  <tr>
    <td>
    <input type="button" name="btnAdd" class="btnClass" value="添加" OnClick="javascript:GoUrl('update.jsp?OPERATOR=add&KEY=0&FirstMKBH=<%=FirstMKBH%>&FirstMKBH2=<%=FirstMKBH2%>');">
      <% out.println(SzPageHelp.deleteButton()); %>
      <%=SzPageHelp.numberSelectTreeSubmit("SZXT_CZZN", "ZNID", "ZNBT", "ZNBH", "FirstMKBH", FirstMKBH, "txtClass1", SzSqlConvert.getFuncLen() + "(ZNBH)=" + SzLevelNumber.I_NUMBER_LEN) %>
      <%=SzPageHelp.numberSelectTreeSubmit("SZXT_CZZN", "ZNID", "ZNBT", "ZNBH", "FirstMKBH2", FirstMKBH2, "txtClass1", "ZNBH LIKE '" + FirstMKBH + "%' AND " + SzSqlConvert.getFuncLen() + "(ZNBH)=" + SzLevelNumber.I_NUMBER_LEN * 2) %>          
      <input type="radio" name="type" value="0" <% if (sType.equals("0")) { %>checked<% } %> OnClick="javascript:FormSubmit(formBar, 'index.jsp');">
      不限制      
      <input type="radio" name="type" value="1" <% if (sType.equals("1")) { %>checked<% } %> OnClick="javascript:FormSubmit(formBar, 'index.jsp');">
      仅显示一级  
      <input type="radio" name="type" value="2" <% if (sType.equals("2")) { %>checked<% } %> OnClick="javascript:FormSubmit(formBar, 'index.jsp');">
      仅显示两级      
    </td>
  </tr>
  </form>
</table>

<!-----信息列表----->
<table width="100%" border="1"  class="tableClass" cellpadding="1" cellspacing="0">

  <form name="formList" method="post">
  <input type="hidden" name="page" value="<%=iCurrentPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>">
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">
  <input type="hidden" name="FirstMKBH" value="<%=FirstMKBH%>">
  <input type="hidden" name="FirstMKBH2" value="<%=FirstMKBH2%>">      
  <tr class="trClassTitle">
    <td width="5"><input type="checkbox" name="chkCheckAll" OnClick="javascript:CheckAll(formList, chkCheckAll, 'chkId');"></td>
    <td><%=SzPageHelp.sortTitle("标题", "ZNBT", sSortField, iSortOrder)%></td>    
    <td width="120"><%=SzPageHelp.sortTitle("发布时间", "ZNSJ", sSortField, iSortOrder)%></td>
    <td width="80"><%=SzPageHelp.sortTitle("发布人员", "ZNDLXM", sSortField, iSortOrder)%></td>
    <td width="40">操作</td>
  </tr>
<%
    
    while (iter != null && iter.hasNext()) {
        guideInfo = (GuideInfo)iter.next();
        i++;

%>
  <tr  onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'">
    <td width="5" title="<%=i%>"><input type="checkbox" name="chkId" id="chkId" value="<%=guideInfo.getZNBH()%>"></td>
    <td title="<%=guideInfo.getZNBH()%>" id="td<%=guideInfo.getZNBH()%>"
        OnMouseDown="javascript:ClickElement('<%=guideInfo.getZNBH()%>','<%=guideInfo.getZNBT()%>');" 
        OnMouseUp="javascript:UpElement('<%=guideInfo.getZNBH()%>','<%=guideInfo.getZNBT()%>');"        
        OnSelectStart="return false;"
        >
    <%=SzLevelNumber.getLevelSpace(guideInfo.getZNBH())%><%=guideInfo.getZNBT()%>&nbsp;</td>
	<td><%=guideInfo.getZNSJ()%>&nbsp;</td>
    <td><%=guideInfo.getZNDLXM()%>&nbsp;</td>
    <td width="60">
      <% out.println( SzPageHelp.detailButton(sType, guideInfo.getZNID()) );%>
      <% out.println( SzPageHelp.updateButton(sType, guideInfo.getZNID(), true) );%>
    </td>

  </tr>
<%
    }
    int iLen = 5;
    out.println(SzPageHelp.outIndexTableTr(i, SzProperties.I_PageSize, iLen));
%>

  </form>
</table>

<!-----下面的工具栏------>
<table width="100%">
  <form name="formPage" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="txtSearchName" value="<%=sSearchName%>">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>">
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">
  <input type="hidden" name="XXFL" value="<%=XXFL%>">  
  <input type="hidden" name="FirstMKBH" value="<%=FirstMKBH%>">
  <input type="hidden" name="FirstMKBH2" value="<%=FirstMKBH2%>">      
  <tr>
    <td align="right">
      <%@ include file="/share/page/page_include.jsp"%>
    </td>
  </tr>
  </form>
</table>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="page" value="<%=iCurrentPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="txtSortField" value="<%=sSortField%>">
  <input type="hidden" name="txtSortOrder" value="<%=iSortOrder%>">  
  <input type="hidden" name="FirstMKBH" value="<%=FirstMKBH%>">
  <input type="hidden" name="FirstMKBH2" value="<%=FirstMKBH2%>">    
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  //点下鼠标
  var vMKBH_PRIO = "";
  var vMKMC_PRIO = "";
  function ClickElement(vBH, vName) {
  	vMKBH_PRIO = vBH;
  	vMKMC_PRIO = vName;
  	event.srcElement.style.background = "#abcdef";
  }
  
  //松开鼠标
  function UpElement(vBH, vName) {
  	event.srcElement.style.background = "#abcdef";
 		var vMKBH = vBH;
 		var vM = "[" + vMKMC_PRIO + "]和[" + vName + "]确定要互换位置"
 		if (vMKBH_PRIO != "" && vMKBH != "" && vMKBH_PRIO != vMKBH) {
 	  	if (vMKBH_PRIO.length > vMKBH.length && vMKBH_PRIO.indexOf(vMKBH) ==0) {
 			alert("下级不能跟上级互换位置");
 	  	} else {
 	      event.srcElement.style.background = "#abcdef";
 	      if (confirm(vM)) { 
 					document.location.href="control.jsp?OPERATOR=change&MKBH_PRIO=" + vMKBH_PRIO + "&MKBH=" + vMKBH + "&type=<%=sType%>&FirstMKBH=<%=FirstMKBH%>";
 		  	}
 	  	}
 		}

    event.srcElement.style.background = "#ffffff";
    //找到之前的
    var tdObj = document.getElementById("td" + vMKBH_PRIO);
    if (tdObj != null) {
    	tdObj.style.background = "#ffffff";
    }
    vMKBH_PRIO = "";
  }
  
  
</script>