<%@ page contentType="text/html;charset=UTF-8" %>
<%@ 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.flow.*" %>
<%@ 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 CopyFlow(FlowID) {
    if (confirm("确定要复制流程？")) {
        formPage.action="control.jsp?OPERATOR=copy&FlowID=" + FlowID;
        formPage.submit();
    }
  }
</script>
</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 LCFL = SzConvert.toZeroStr(request.getParameter("LCFL"));
    String LCSYBD = SzConvert.toZeroStr(request.getParameter("LCSYBD"));
    String LCLX = SzConvert.toZeroStr(request.getParameter("LCLX"));
    
    String sTable_type = "";
    //读取数据
    LcFlow lcFlow = new LcFlow();
    LcFlowInfo lcFlowInfo = null;
    String sCond = "LCGSID=" + szCOMPANY_SESSION;
    boolean canAdd_SESSION = false;
    boolean canPrint_SESSION = false;
    boolean canDelete_SESSION = false;
    boolean canUpdate_SESSION = false;
    //管理资料，只有管理员和有权限的人才能添加。有权限的人员可以查看、修改、删除
    if (isBarManager_SESSION) {
        canAdd_SESSION = true;
        canPrint_SESSION = true;
        canDelete_SESSION = true;
        canUpdate_SESSION = true;
    }

    if (!sPKEY.equals("0")) {
        sCond += "";
    }
    if (!LCFL.equals("0")) {
        sCond += " and LCFL =" + LCFL;
    }
    if (!LCSYBD.equals("0")) {
        sCond += " and LCSYBD =" + LCSYBD;
    }
    sCond += " and LCLX ='" + LCLX + "'";
        
    String sSortField = SzConvert.toSpaceStr(request.getParameter("txtSortField"));
    int iSortOrder    = Integer.parseInt(SzConvert.toZeroStr(request.getParameter("txtSortOrder")));
    if (sSortField.equals("")) {
      sSortField = "LCID";
      iSortOrder = SzProperties.I_SortOrder_DESC;
    }
    int iCurrentPage = 1;
    try {
        iCurrentPage =  Integer.parseInt(sPage);
    }catch(Exception e) {
    }

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

    SzPageInfo pageInfo = lcFlow.getPageInfo();
    int iPageCount = pageInfo.getPageCount();
    int iRecordCount = pageInfo.getRecordCount();
    iCurrentPage = pageInfo.getCurrentPage();
    int i = 0;
    SzData szData = null;
    
%>
<!-----上面的工具栏------>
<%@ include file="/flow/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%>">
  <tr>
    <td>
    <%
      if (Integer.parseInt(LCLX) == 0) {
      	out.println(SzPageHelp.addButtonSubmit(canAdd_SESSION)); 
      	out.println(SzPageHelp.deleteButton(canDelete_SESSION));      	      	
      } 
      out.println(SzPageHelp.idSelectTreeSubmit("SZLC_FL","FLID","FLMC","FLBH","LCFL",Integer.parseInt(LCFL), "txtClass1","FLGSID=" + szCOMPANY_SESSION));
    %>
    <%//=SzPageHelp.idSelectSubmit("SZLC_SPBD","BDID","BDMC", "LCSYBD",Integer.parseInt(LCSYBD), "txtClass1")%>
    <input type="radio" name="LCLX" value="0" onClick="this.form.submit();" <% if (LCLX.equals("0")) {%>checked<%}%> >模板
    <input type="radio" name="LCLX" value="1" onClick="this.form.submit();" <% if (LCLX.equals("1")) {%>checked<%}%> >从模板发起的流程
    <input type="radio" name="LCLX" value="2" onClick="this.form.submit();" <% if (LCLX.equals("2")) {%>checked<%}%> >临时发起的流程
    <%
    	//
    	if (!net.sz600.check.SzHasp.getInstance().hasDog()) {
    		out.println("<b>&nbsp;&nbsp;授权自定义的流程数量：" + net.sz600.check.SzHasp.getInstance().getFlowCount() + "<br>");
    	}
    %>    
    </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="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 width="100"><%=SzPageHelp.sortTitle("流程分类", "LCFL", sSortField, iSortOrder)%></td>
    <td ><%=SzPageHelp.sortTitle("流程名称", "LCMC", sSortField, iSortOrder)%></td>
    <td ><%=SzPageHelp.sortTitle("流程类型", "LCLX", sSortField, iSortOrder)%></td>
    <td ><%=SzPageHelp.sortTitle("所属表单", "LCSYBD", sSortField, iSortOrder)%></td>    
    <td>操作</td>
  </tr>
<%
    LcType lcType = new LcType();
    Map mapLCFL = lcType.getMainHashMap("1=1");
    
    LcForm lcForm = new LcForm();
    Map mapLCBD = lcForm.getMainHashMap("1=1");
    String sDefault = "";
    while (iter != null && iter.hasNext()) {
        lcFlowInfo = (LcFlowInfo)iter.next();
        i++;
        sDefault = "";
        if (lcFlowInfo.getLCMR() ==1) {
        	sDefault = "<font color='red'>[默认]</font>";
        }
%>
  <tr  onMouseOver="javascript:this.className='trMouseOver'" onMouseOut="javascript:this.className='trMouseOut'">
    <td width="5" title="<%=i%>"><input type="checkbox" name="chkId" id="chkId" value="<%=lcFlowInfo.getLCID()%>"></td>
    <td><%=SzConvert.toSpaceStr(mapLCFL.get(new Integer( lcFlowInfo.getLCFL() )))%>&nbsp;</td>
    <td><%=lcFlowInfo.getLCMC()%>&nbsp;</td>
    <td><%=lcFlow.getTypeName(lcFlowInfo.getLCLX())%>&nbsp;</td>
    <td><%=SzConvert.toSpaceStr(mapLCBD.get( new Integer(lcFlowInfo.getLCSYBD())) ) + sDefault%> &nbsp;</td>    
    <td>
      <a href="javascript:FormSubmit(formPage,'update.jsp?OPERATOR=detail&type=<%=sType%>&KEY=<%=lcFlowInfo.getLCID()%>');">详情</a>
      <%
      	//2015-01增加判断
      	if (Integer.parseInt(LCLX) == 0) {
      		out.println( SzPageHelp.updateButton(sType, lcFlowInfo.getLCID(), canUpdate_SESSION) );
      		out.println( SzPageHelp.operatorFunc("复制流程", "CopyFlow(" + lcFlowInfo.getLCID() + ");"));
      	}
      %>
      <a href="../step/index.jsp?type=<%=lcFlowInfo.getLCID()%>&LCLX=<%=LCLX%>">流程步骤</a>
    </td>
  </tr>
<%
    }
    out.println(SzPageHelp.outIndexTableTr(i, SzProperties.I_PageSize, 6));
%>

  </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="LCLX" value="<%=LCLX%>" >
  <input type="hidden" name="LCFL" value="<%=LCFL%>" >
  <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>
