<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Collection" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.tool.SzDateHelp" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.flow.*" %>
<%@ include file="/sessionInfo.jsp"%>
<% 
  String strLevel = "../../"; 
%> 
<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>
<%
    //获取提交的参数
    String sType = SzConvert.toZeroStr(request.getParameter("type"));
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String sPKEY = SzConvert.toZeroStr(request.getParameter("PKEY"));
    String sTable_type = "SZKC_CPFL";
%>
<%
    SzData szData = null;
    SzDataInfo szDataInfo = null;

    String sOPERATOR = request.getParameter("OPERATOR");
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    String sReadonly = "";
    boolean bReadonly = false;
    if (sOPERATOR.startsWith("detail")) {
        sReadonly = "readonly";
        bReadonly = true;
    }
    if (sOPERATOR.equals("detailPass")) {
    	LcFlowControl.readPass(LcTest.I_FORMID, iDLID_SESSION, Integer.parseInt(sKEY));
        sReadonly = "readonly";
        bReadonly = true;    	
    }
    //读取数据
    LcTestInfo lcTestInfo = null;
    LcTest lcTest = new LcTest();
    if (!sKEY.equals("0")) {
        lcTestInfo = (LcTestInfo)lcTest.getInfoByKey(Integer.parseInt(sKEY));
    }
    if (lcTestInfo == null) {
        lcTestInfo = new LcTestInfo();
        lcTestInfo.setXX2(szLoginInfo_SESSION.getDLXM());
        lcTestInfo.setXX3(SzDateHelp.getTimeStr());
    } else {
    }
    //流程相关
    //根据已经有的信息ID，读取流程ID
    LcFlowControl lcFlowControl = new LcFlowControl();
    //取得流程权限信息
    LcFlowPopedomInfo lcFlowPopedomInfo = lcFlowControl.getFlowPopedomInfo(LcTest.I_FORMID, Integer.parseInt(sKEY));
    
    int iFlowID = lcFlowPopedomInfo.getFlowID();
	boolean hasSend = lcFlowPopedomInfo.isHasSend();
	boolean isLastStep = lcFlowPopedomInfo.isLastStep();
	boolean canSend = lcFlowPopedomInfo.isCanSend();
	boolean canFinish = lcFlowPopedomInfo.isCanFinish();
	boolean canDeny = lcFlowPopedomInfo.isCanDeny();
	boolean canUntread = lcFlowPopedomInfo.isCanUntread();
	boolean canSkip = lcFlowPopedomInfo.isCanSkip();
	boolean canModifyForm = lcFlowPopedomInfo.isCanModifyForm();
	if (bReadonly) {
		canModifyForm = false;
	}
	if (canModifyForm || sOPERATOR.startsWith("add") || sOPERATOR.startsWith("update")) {
		 sReadonly = "";
	} else {
		 sReadonly = "readonly";		
	}
	//如果不能修改表单，则
	//System.out.println(iFlowID + "==" + sKEY + "==" + canModifyForm);
	//System.out.println("==" + LcFlowControl.fieldPopedom(LcTest.I_FORMID, iFlowID, Integer.parseInt(sKEY), canModifyForm));
%>

<body>
<!-----上面的工具栏------>
<form name="formUpdate" method="post">
  <!---使用流程的时候需要使用--->
  <input type="hidden" name="LCID_FLOW" value="0">
  <input type="hidden" name="BZID_FLOW" value="0">
  <input type="hidden" name="BZRYID_FLOW" value="0">  
  
  <input type="hidden" name="PKEY" value="<%=sPKEY%>">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
  <input type="hidden" name="KEY" value="<%=sKEY%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="detailCount" value="0">
  
<%@ include file="title.jsp"%>
<table width="100%">
  <tr>
    <td>
    <% if (!bReadonly) { %>
      <!-- 流程相关 -->
      <% if (!hasSend) { %>
        <%=SzPageHelp.saveButton()%>      
        <input type="button" name="btnAdd" class="btnClass" value="发送" OnClick="javascript:FormSaveConfirm(formUpdate, 'control.jsp?OPERATOR=send', 'transact');">
      <% } else {%>    
        <input type="button" name="btnAdd" class="btnClass" value="保存" OnClick="javascript:FormSave(formUpdate, 'control.jsp?OPERATOR=transactUpdate');">
      <% } %>
      <!-- 下面操作只在办理的过程中才会有 --> 
      <%
        out.println( LcHelp.sendButton(canSend));
        out.println( LcHelp.finishButton(canFinish));
        out.println( LcHelp.denyButton(canDeny));
        out.println( LcHelp.untreadButton(canUntread, iFlowID ));
        out.println( LcHelp.skipButton(canSkip, iFlowID));
      %>   
            
    <% } %>
      <%=SzPageHelp.backButton()%>
    </td>
  </tr>
</table>

<!-----信息维护------>
<TABLE id=SZFORMtable1 style="CURSOR: hand" cellSpacing=0 borderColorDark=#ffffff cellPadding=3 width=650 borderColorLight=#c0c0c0 border=1>
<DIV id=divSZFORMtable1 style="BACKGROUND: #c0c0c0; CURSOR: hand; HEIGHT: 20px; display:none;"><INPUT id=XX1 size=10 name=XX1><INPUT id=XX7 size=10 name=XX7><INPUT id=XX8 size=10 name=XX8></DIV>
<TBODY>
<TR id=SZFORMtr1>
<TD class=trMouseOut id=SZFORMtd1 style="CURSOR: hand">申请人员</TD>
<TD class=trMouseOut id=SZFORMtd2 style="CURSOR: hand"><INPUT class=txtClass1 id=XX2 size=10 name=XX2 <%=sReadonly%> ></TD>
<TD class=trMouseOut id=SZFORMtd3 style="CURSOR: hand">申请时间</TD>
<TD class=trMouseOut id=SZFORMtd4 style="CURSOR: hand"><INPUT class=txtClass1 id=XX3 readOnly size=10 value="2008-04-18 10:09" name=XX3></TD></TR>
<TR id=SZFORMtr2>
<TD class=trMouseOut id=SZFORMtd5 style="CURSOR: hand">申请原因</TD>
<TD class=trMouseOut id=SZFORMtd6 style="CURSOR: hand" colSpan=3><TEXTAREA class=areaClass2 id=XX4 name=XX4 <%=sReadonly%> ></TEXTAREA></TD></TR>
<TR id=SZFORMtr3>
<TD class=trMouseOut id=SZFORMtd9 style="CURSOR: hand">部门领导审批</TD>
<TD class=trMouseOut id=SZFORMtd10 style="CURSOR: hand" colSpan=3><TEXTAREA class=areaClass2 id=XX5 name=XX5 <%=sReadonly%> ></TEXTAREA></TD></TR>
<TR id=SZFORMtr4>
<TD class=trMouseOut id=SZFORMtd13 style="CURSOR: hand">总经理审批</TD>
<TD class=trMouseOut id=SZFORMtd14 style="CURSOR: hand" colSpan=3><TEXTAREA class=areaClass2 id=XX6 name=XX6 <%=sReadonly%> ></TEXTAREA></TD></TR></TBODY></TABLE>
</form>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="type" value="<%=sType%>">
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  //动态的隐藏
  var oDivSZFORMtable1 = document.getElementById("divSZFORMtable1");  
  if (oDivSZFORMtable1 != null) { 
    oDivSZFORMtable1.style.display="none"; 
  } 
  //动态的加入XX2的值
  var oXX1 = document.getElementById("XX1");  
  if (oXX1 != null) { 
    oXX1.value = "<%=lcTestInfo.getXX1()%>"; 
  } 
  var oXX2 = document.getElementById("XX2");  
  if (oXX2 != null) { 
    oXX2.value = "<%=lcTestInfo.getXX2()%>"; 
  } 
  var oXX3 = document.getElementById("XX3");  
  if (oXX3 != null) { 
    oXX3.value = "<%=lcTestInfo.getXX3()%>"; 
  } 
  var oXX4 = document.getElementById("XX4");  
  if (oXX4 != null) {
    var vXX4 = "<%= SzConvert.toJsStr(lcTestInfo.getXX4())%>";
    oXX4.value = toJavaStr(vXX4); 
  } 
  var oXX5 = document.getElementById("XX5");  
  if (oXX5 != null) { 
    oXX5.value = "<%=lcTestInfo.getXX5()%>"; 
  } 
  var oXX6 = document.getElementById("XX6");  
  if (oXX6 != null) { 
    oXX6.value = "<%=lcTestInfo.getXX6()%>"; 
  } 
  var oXX7 = document.getElementById("XX7");  
  if (oXX7 != null) { 
    oXX7.value = "<%=lcTestInfo.getXX7()%>"; 
  } 
  var oXX8 = document.getElementById("XX8");  
  if (oXX8 != null) { 
    oXX8.value = "<%=lcTestInfo.getXX8()%>"; 
  } 
  //判断是否有明细，如果有就动态增加   
</script>
<%=LcFlowControl.fieldPopedom(LcTest.I_FORMID, iFlowID, Integer.parseInt(sKEY), canModifyForm) %>
<script language="javascript">
  function FormCheck(formName) {
    //检查是否可以保存
    if (!notNum(formName.XX7, "XX7")) {
      return false;
    }
    if (!notNum(formName.XX8, "XX8")) {
      return false;
    }  
    return true;
  }

  function FormSave(formName, url) {
		if (!FormCheck(formName)) {
		  return false;
		}
    //保存前把流程ID、流程步骤ID、表单ID、信息ID等写到信息里面
    //流程相关
    formName.LCID_FLOW.value = flowDraft.formList.LCID.value;

    formName.action = url;
    formName.submit();      
  }
  
  function FormSaveConfirm(formName, url, vOPERATOR) {
	if (!FormCheck(formName)) {
		return false;
	}
    //保存前把流程ID、流程步骤ID、表单ID、信息ID等写到信息里面
    //流程相关
    formName.LCID_FLOW.value = flowDraft.formList.LCID.value;
    formName.BZRYID_FLOW.value = ValueOfCheck(flowDraft.formList.BZRYID);
    
    var vMessage = "";
    if (vOPERATOR=="transact") {
      vMessage = "确定要发送？";
      if (formName.BZRYID_FLOW.value == "0" || formName.BZRYID_FLOW.value == "") {
    	  alert("请至少选择一个办理人员！");
    	  return false;
      }      
    } else if (vOPERATOR=="transactFinish") {
      vMessage = "确定要办结？";    
    } else if (vOPERATOR=="transactDeny") {
      vMessage = "确定要否决？";    
    }
    
    if (confirm(vMessage)) {
      formName.action = url;
      formName.submit();      
    }
  }  
  
  //需要传递的参数：流程ID，操作类型
  function transactWin(vFlowID, vOPERATOR) {
    var vUrl = "../../flow/flow/untread_win.jsp";
    if (vOPERATOR == "transactUntread") {
    
    } else if (vOPERATOR == "transactSkip") {
    
    }
    vUrl += "?OPERATOR=" + vOPERATOR + "&FlowID=" + vFlowID;
    window.showModalDialog(vUrl,window,"status=no;dialogWidth=680px;dialogHeight=580px");  
  }
  
  function transactSubmit() {
      formUpdate.action = "control.jsp";
      formUpdate.submit();  
  }
</script>
</body>


<!--流程相关 包含流程的frame页面 -->
<iframe id="flowDraft" src="../../flow/flow/draft.jsp?type=<%=iFlowID%>&FormID=<%=LcTest.I_FORMID%>&InfoID=<%=sKEY%>&OPERATOR=<%=sOPERATOR%>" frameborder="0" width="650" height="1000"></iframe>


