<%@ 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.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ page import="net.sz600.weboffice.*" %>
<%@ 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 sOPERATOR = request.getParameter("OPERATOR");
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    
    int iFormID = SzConvert.toInt(request.getParameter("FormID"));
    int iInfoID = SzConvert.toInt(sKEY);
    //取得表单的信息
    String moduleName = "";
    String formName = "";
		LcForm lcForm = new LcForm();
		LcFormInfo lcFormInfo = null;    
    if (iFormID == 0) {
    	moduleName = SzConvert.toSpaceStr(request.getParameter("moduleName"));
    	formName = SzConvert.toSpaceStr(request.getParameter("formName")); 
    	//
    	iFormID = lcForm.getKeyByCond(moduleName, formName); 
    } else {
    	lcFormInfo = (LcFormInfo)lcForm.getInfoByKey(iFormID);    
    	if (lcFormInfo != null) {
    		moduleName = lcFormInfo.getBDLJ();
    		formName = lcFormInfo.getBDBY1();  
    	}
    } 
    //System.out.println("moduleName=" + moduleName);
    //System.out.println("formName=" + formName);
    if (moduleName.equals("") || formName.equals("")) {
    	out.println("还没有设置相关表单信息！");
    	return;
    }   
    BdFormControl bdFormControl = new BdFormControl();

    
    String sHTML = "";    
	BdValueControl bdValueControl = new BdValueControl(moduleName, formName);	
	sHTML = bdValueControl.getHTML();
	
	//获取附件名
	String assistant = bdValueControl.getAssistant();
	String sTableAnnex = bdValueControl.getTableAnnex();
	String sEditor    = bdValueControl.getEditor();
	String sWeboffice = bdValueControl.getWebOffice();
	String sTemplateSelect = bdValueControl.getTemplateSelect();
	
	boolean hasFlow   = bdValueControl.getHasFlow();
	boolean hasAnnex  = false;
	if (!sTableAnnex.equals("")) {
		hasAnnex = true;
	}
%>
<%
    SzData szData = null;
    SzDataInfo szDataInfo = null;

    String sReadonly = "";
    boolean bReadonly = false;
    if (sOPERATOR.startsWith("detail")) {
        sReadonly = "readonly";
        bReadonly = true;
    }
    if (sOPERATOR.equals("detailPass")) {
    	LcFlowControl.readPass(iFormID, iDLID_SESSION, Integer.parseInt(sKEY));
        sReadonly = "readonly";
        bReadonly = true;    	
    }
    //读取数据
	String value_str[] = null;
    if (!sKEY.equals("0")) {
    	value_str = (String[])bdValueControl.getInfoByKey(Integer.parseInt(sKEY));
    	//System.out.println("value_str==aaaa=============" + value_str);
    }    
    String loginID = SzConvert.toSpaceStr(bdValueControl.getLoginID(value_str));
    if (loginID.equals("")) {
    	loginID = Integer.toString(iDLID_SESSION);
    }
    
    //2010-2-21
    BdPopedom bdPopedom = new BdPopedom();        
    String strDenyField = bdPopedom.getDenyField(iFormID, 0, iDLID_SESSION);
    String strDenyField2 = bdPopedom.getDenyField(iFormID, Integer.parseInt(sKEY), iDLID_SESSION); 
%>
<%    
    //流程相关
    //根据已经有的信息ID，读取流程ID
    LcFlowControl lcFlowControl = new LcFlowControl();
    //取得流程权限信息
    LcFlowPopedomInfo lcFlowPopedomInfo = lcFlowControl.getFlowPopedomInfo(iFormID, 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";		
	}
	
	boolean canDraftSave = false;
	boolean canDraftSend = false;
	boolean canTransactSave = false;
	if (hasFlow && !hasSend) {
		canDraftSave = true;
		canDraftSend = true;
	} else if (hasFlow && hasSend) {
		canTransactSave = true;
	} else if (!hasFlow) {
		canDraftSave = true;
	}
	boolean isTransact = false;
	if (sOPERATOR.startsWith("transact")) {
		isTransact = true;	
	}
	
	//EditType //// 0 显示  1 起草 2 批改 3 审核
	String sEditType = "0";
	if (sOPERATOR.startsWith("add") || (sOPERATOR.startsWith("update") && hasFlow)) {
		sEditType = "1";
	} else if (sOPERATOR.startsWith("update") && !hasFlow) {
		sEditType = "2";
	} else if (sOPERATOR.startsWith("transact")) {
		sEditType = "3";
	} 
%>


<body>

<!-----上面的工具栏------>
<% if (hasAnnex) { %>
<form name="formUpdate" method="post" ENCTYPE="multipart/form-data">
<% } else { %>
<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="RYBLYJ_FLOW" value="">   
  
  <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">
  <input type="hidden" name="detailCount1" value="0">
  <input type="hidden" name="detailCount2" value="0">
  <input type="hidden" name="detailCount3" value="0">
  <input type="hidden" name="detailCount4" value="0">  
  <input type="hidden" name="FormID" value="<%=iFormID%>">  
  <input type="hidden" name="loginID" value="<%=loginID%>"> 
  <input type="hidden" name="szContent" value=""> 
  <input type="hidden" name="RecordID" value="">    
<table width="100%" id="table1">
  <tr>
    <td>
      <% out.println( SzPageHelp.button("打印","javascript:Print();") );%>
      <% out.println( SzPageHelp.button("关闭","javascript:window.close();") );%>
    </td>
  </tr>
</table>

<!-----信息维护------>
<div id="divForm">
<%=sHTML %>
<% if (hasFlow && BdFormHelp.canPrintFlow(assistant)) { %>
<!--流程相关 包含流程的frame页面 -->
<%@ include file="../../flow/flow/draft_include.jsp"%>
<% } %>
</div>
</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%>">
  <input type="hidden" name="FormID" value="<%=iFormID%>"> 
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript" src="../../share/js/formTool.js"></script>
<%=bdValueControl.updateViewJs(Integer.parseInt(sKEY), session, sOPERATOR, canModifyForm, strDenyField, strDenyField2)%>
<%=bdValueControl.detailJs(Integer.parseInt(sKEY), "print", canModifyForm)%>
<%=LcFlowControl.fieldPopedom(iFormID, iFlowID, Integer.parseInt(sKEY), canModifyForm, isTransact) %>
<%=bdValueControl.saveCheckJs()%>
<script language="javascript">
  hideAll(formUpdate.btnSelect);
  hideAll(formUpdate.pop1);
    
  function Print() {
	var tit = document.title;
	
	document.title = "";
	table1.style.display = "none";
	
	window.print();
	
	document.title = tit;
	table1.style.display = "";	
  }  
  
  //initialJs("<%=moduleName%>","<%=formName%>");


</script>

</body>
<%
out.println(SzPageHelp.calendarFrame2());
out.println(SzPageHelp.calendar2Frame2());
%>

