<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.flow.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.database.SzPageInfo" %>
<%@ page import="net.sz600.system.SzProperties" %>
<%@ page import="net.sz600.system.SzPageHelp" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ 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">
</head>
<%@ include file="title.jsp"%>
<%
    String moduleName = "";
    String formName = "";
    String sFlowID = SzConvert.toZeroStr(request.getParameter("FlowID"));     //流程ID
    String sStepID = SzConvert.toZeroStr(request.getParameter("StepID"));     //步骤ID 
    String sFormID = SzConvert.toZeroStr(request.getParameter("FormID"));  //表单ID  
    String TJID = SzConvert.toZeroStr(request.getParameter("TJID"));
    //根据表单取得moduleName, formName
    LcForm lcForm = new LcForm();
    LcFormInfo lcFormInfo = null;
    lcFormInfo = (LcFormInfo)lcForm.getInfoByKey(Integer.parseInt(sFormID));
    if (lcFormInfo != null) {
    	moduleName = lcFormInfo.getBDLJ();
    	formName = lcFormInfo.getBDBY1();
    }
    //取得流程名称
    LcFlow lcFlow = new LcFlow();
    String sFlowName = lcFlow.getMainByKey(Integer.parseInt(sFlowID));
    //取得步骤名称
    LcStep lcStep = new LcStep();
    String sStepName = lcStep.getMainByKey(Integer.parseInt(sStepID));
    
    //读取条件信息    
    LcCondFinish lcCondFinish = new LcCondFinish();
    LcCondFinishInfo lcCondFinishInfo = null;
    lcCondFinishInfo = (LcCondFinishInfo)lcCondFinish.getInfoByCond("TJLCID=" + sFlowID + " AND TJBZID=" + sStepID);
    if (lcCondFinishInfo == null) {
	lcCondFinishInfo = new LcCondFinishInfo();
    }	

%>

<table width="100%">
  <form name="formBar" method="post">
  <tr>
    <td align="center">
      <input type="button" value="保存" OnClick="javascript:FormSave(formUpdate, 'condFinish_control.jsp');">&nbsp;
      <input type="button" value="返回" onClick="document.location.href='index.jsp?type=<%=sFlowID%>'">
    </td>
  </tr>
  </form>
</table>
<b>设置办结条件</b><br>
当本步骤满足条件时，可办结，不需要再发给下一步骤。<br>
如：请假天数1天时，只需要部门负责人审批；如请假天数超过3天时，需要总经理审批<br>
<b>表单名称：</b><%=formName%>&nbsp;
<b>流程名称：</b><%=sFlowName %>&nbsp;
<b>步骤名称：</b><%=sStepName %>&nbsp;
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <form name="formUpdate" method="post">
  <input type="hidden" name="FormID" value="<%=sFormID%>"> 
  <input type="hidden" name="FlowID" value="<%=sFlowID%>">
  <input type="hidden" name="StepID" value="<%=sStepID%>">
  <input type="hidden" name="TJID" value="<%=lcCondFinishInfo.getTJID()%>"> 
  <input type="hidden" name="OPERATOR" value="add"> 
  <tr>
    <td>条件说明:</td>
    <td><input type="text" name="TJSM" class="txtClass2" value="<%=lcCondFinishInfo.getTJSM()%>"> 
    </td>
  </tr>
  <tr>
    <td>SQL条件:</td>
    <td><textarea name="TJTJ" class="areaClass2"><%=lcCondFinishInfo.getTJTJ()%></textarea>
    </td>
  </tr>  
 
  </form>
</table>
<%
    BdFormControl bdFormControl = new BdFormControl();
    bdFormControl.getMapStatic(moduleName, formName);
    Map formMap  = bdFormControl.getFormMap();
    Map tableMap = bdFormControl.getTableMap();
    Map fieldMap = bdFormControl.getFieldMap();
    
		BdFormInfo bdFormInfo = null;
		bdFormInfo = (BdFormInfo)formMap.get(new String(moduleName + "-" + formName));  
    if (bdFormInfo == null) {
      bdFormInfo = new BdFormInfo();
    }
    
		BdFormTableInfo bdFormTableInfo = null;
		Collection collFormTable = null;
		collFormTable = (Collection)tableMap.get(new String(moduleName + "-" + formName));
		Iterator iterFormTable = null;

		//字段信息
		BdFormFieldInfo bdFormFieldInfo = null;
		Collection collFormField = null;
		collFormField = (Collection)fieldMap.get(new String(moduleName + "-" + formName));
		Iterator iterFormField = null;    

    if (collFormTable != null) {
      iterFormTable = collFormTable.iterator();
    }

    if (collFormField != null) {
      iterFormField = collFormField.iterator();
    }
%>
<table width="100%" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">

  <tr class="trClassTitle">
    <td>字段名</td>
    <td>中文名</td>
    
    <td>字段名</td>
    <td>中文名</td>
        
    <td>字段名</td>
    <td>中文名</td>
        
  </tr>   
<%
    int j = 0;
    int i = 0;
    String tableName = "";
    String tableId = "";
    String objectStr = "";
    String tableType = "";

    String sCheck = "";
    while (iterFormTable != null && iterFormTable.hasNext()) {
        bdFormTableInfo = (BdFormTableInfo)iterFormTable.next();
        if (bdFormTableInfo.getGLBM().equals("")) {
            continue;
        }
        if (bdFormTableInfo.getGLLX().equals("1")) {
            continue;
        }        
        tableName = bdFormTableInfo.getGLBM();
        tableId = bdFormTableInfo.getGLID();
        //读取字段
        i=0;
        
        //本表已经设置的

%>
  <tr class="trClassTitle">
    <td colspan="20" align="left">对应的表：<%=bdFormTableInfo.getGLSM()%>&nbsp;<%=bdFormTableInfo.getGLBM()%></td>
  </tr>
<%
        sCheck = "";
        iterFormField = collFormField.iterator();
        while ((iterFormField != null && iterFormField.hasNext())) {
            bdFormFieldInfo = null;
            if (iterFormField != null && iterFormField.hasNext()) {
                bdFormFieldInfo = (BdFormFieldInfo)iterFormField.next();
            }
            if (!tableId.equals(bdFormFieldInfo.getTableId())) {
                continue;
            }
            //字段是隐藏的，跳过

            if (i==0) {
            	out.println("<tr>");
            }
            sCheck = "";

            
%>
    <td align="left"><%=bdFormFieldInfo.getZDMC()%></td>
    <td align="left"><%=bdFormFieldInfo.getZDSM()%></td>
<%
            i ++;
            if (i==3) {
            	i = 0;
				out.println("</tr>");
			}
       } //while ends
       if (i < 3) {
       	   for (int k=i; k<3; k++) {
    	       out.println("<td>&nbsp;</td>");
    	       out.println("<td>&nbsp;</td>");
           }
       	   out.println("</tr>");
       }
       j++;
   }
%>
   <input type="hidden" name="tableCount" value="<%=j%>" >
  </form>
</table>

<br>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">

  
  function FormSave(formName, url) {
  	//名称不能为空
    if (!notSpace(formName.TJSM, "条件说明")) {
      return false;
    }
    if (!notSpace(formName.TJTJ, "SQL条件")) {
      return false;
    }  
    formName.action = url;
    formName.submit();

  }


</script>
