<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.util.Iterator" %>
<%@ 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.formEngine2.*" %>
<%@ page import="net.sz600.flow.*" %>
<%@ 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>
<%
    //获取提交的参数
    int iFormID = SzConvert.toInt(request.getParameter("FormID"));
	
    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 flowType = SzConvert.toZeroStr(request.getParameter("flowType"));
    String typeName = "";
		BdFormControl formControl = new BdFormControl();
    String assistant = "";
    if (iFormID >0) {
    	assistant = SzConvert.toZeroStr(formControl.getAssistant(iFormID));  
    }


    boolean bPress = false;
		if ((";" + assistant + ";").indexOf(";6;") >=0) {
			bPress = true;
		}    
		boolean bSkip = false;
		if ((";" + assistant + ";").indexOf(";7;") >=0) {
			bSkip = true;
		}      
    if (sType.equals("0")) {
    	typeName = "催办";
    	if (!bPress) {
    		out.println("本模块没有此功能");
    		out.println(SzPageHelp.backButton());
    		return;
    	}
    	
    } else if (sType.equals("1")) {
    	typeName = "跳转";
    	if (!bSkip) {
    		out.println("本模块没有此功能");
    		out.println(SzPageHelp.backButton());
    		return;
    	}
    }

    String sTable_type = "";
    //读取数据
    LcAssistant sssistant  = new  LcAssistant();
    LcAssistantInfo assistantInfo = null;
    String sCond = "CBBDID=" + iFormID + " AND CBLX=" + sType;
    //不是管理员，只能看到自己的 
    if (flowType.equals("1")) {
    	sCond += " and (CBRY = " + iDLID_SESSION + ")"; 
    } else if (flowType.equals("2")) {
    	sCond += " and (',' + CBBCBRID + ',' LIKE '%," + iDLID_SESSION + ",%')"; 
    } else if (!isBarManager_SESSION) { 
    	sCond += " and (CBRY = " + iDLID_SESSION + " or " + " ',' + CBBCBRID + ',' LIKE '%," + iDLID_SESSION + ",%')"; 
    }
 
 
    if (!sPKEY.equals("0")) {
        sCond += "";
    }
    String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField")); 
    int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder"))); 
    if (sSortField.equals("")) { 
    	sSortField = "CBID";
    	iSortOrder = SzProperties.I_SortOrder_DESC;
    } 
    int iCurrentPage = 1;
    try {
        iCurrentPage =  Integer.parseInt(sPage);
    }catch(Exception e) {
    }

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

    SzPageInfo pageInfo = sssistant.getPageInfo();
    int iPageCount = pageInfo.getPageCount();
    int iRecordCount = pageInfo.getRecordCount();
    iCurrentPage = pageInfo.getCurrentPage();
    int i = 0;
    SzData szData = null;  
%>
<!-----上面的工具栏------>
<%@ include file="/share/title.jsp"%>
<table width="100%">
  <form name="formBar" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <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="FormID" value="<%=iFormID%>">   
  <tr>
    <td>
      <%
        if (isBarManager_SESSION) {
    	    out.println(SzPageHelp.deleteButton());
        }
      	String s_id[] = {"0","1","2"};
      	String s_name[] = {"全部","我发出的" + typeName + "信息","我接收的" + typeName + "信息"};
      	out.println(SzPageHelp.radioSubmit("flowType", s_id, s_name, flowType));
      %>      
    </td>
  </tr>
  </form>
</table>

<!-----信息列表----->
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <form name="formList" method="post">
  <input type="hidden" name="FormID" value="<%=iFormID%>">   
  <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%>"> 
  <tr class="trClassTitle">
    <td width="5"><input type="checkbox" name="chkCheckAll" OnClick="javascript:CheckAll(formList, chkCheckAll, 'chkId');"></td>
    <td ><%=SzPageHelp.sortTitle("信息标题", "CBXXBT", sSortField, iSortOrder)%></td>
    <td width="120"><%=SzPageHelp.sortTitle(typeName + "姓名", "CBRYXM", sSortField, iSortOrder)%></td>
    <td width="120"><%=SzPageHelp.sortTitle(typeName + "时间", "CBSJ", sSortField, iSortOrder)%></td>
    <td width="120"><%=SzPageHelp.sortTitle("被" + typeName + "姓名", "CBBCBRXM", sSortField, iSortOrder)%></td>
    <td><%=SzPageHelp.sortTitle(typeName + "说明", "CBSM", sSortField, iSortOrder)%></td>        
    <td>状态</td>
    <td>操作</td>
  </tr>
<%
		int iState = 0;
		String stateName = "";
		LcFlowControl lcFlowControl = new LcFlowControl();
		String sLink = "";

		String sOperatorName = "";
		String disabled = "";
    while (iter != null && iter.hasNext()) {
    	assistantInfo = (LcAssistantInfo)iter.next();
      i++;
      
      //判断当前步骤的办理情况     
      iState = lcFlowControl.getPersonState(assistantInfo.getCBBZID());
      stateName = lcFlowControl.getStepStateName(iState);
      
      //连接，如果是办理中，而且有本人，进入办理！！（）
      //sLink = formControl.getUrl(assistantInfo.getCBBDID(), assistantInfo.getCBXXID(),3);
      sLink = "../../share/formEngine2/detail_win.jsp?FormID=" + assistantInfo.getCBBDID() + "&KEY=" + assistantInfo.getCBXXID() + "&from=3&type=" + sType;
    	sOperatorName = "详情";       
			disabled = "";
		/*
    	if (iState == 1) {
    	  disabled = "disabled";
    	  if (("," + assistantInfo.getCBBCBRID() + ",").indexOf("," + iDLID_SESSION + ",") >=0) {
        	  sLink = formControl.getUrl(assistantInfo.getCBBDID(), assistantInfo.getCBXXID(),1);
        	  sOperatorName = "办理";    		  
    	  }
    
      }
			*/
    %>
  <tr>
    <td width="5" title="<%=i%>"><input type="checkbox" name="chkId" id="chkId" value="<%=assistantInfo.getCBID()%>" <%=disabled%> ></td>
    <td><a href="<%=sLink%>"><%=assistantInfo.getCBXXBT()%></a>&nbsp;</td>
    <td><%=assistantInfo.getCBRYXM()%>&nbsp;</td>
    <td><%=assistantInfo.getCBSJ()%>&nbsp;</td>
    <td><%=assistantInfo.getCBBCBRXM()%>&nbsp;</td>
    <td><%=assistantInfo.getCBSM()%>&nbsp;</td>
	  <td><%=stateName%>&nbsp;</td>
    <td>
      <a href="<%=sLink%>"><%=sOperatorName%></a>
    </td>
  </tr>
<%
    }
    out.println(SzPageHelp.outIndexTableTr(i, SzProperties.I_PageSize, 8));
%>

  </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%>"> 
  <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%>"> 
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
