<%@ page contentType="text/html; charset=GBK"%>
<%@ page import = "zr.zrpower.common.util.SysPreperty"%>
<%@ page import = "zr.zrpower.entity.sys.SessionUser"%>
<%@ page import = "zr.zrpower.ejb.sys.UIService"%>
<%@ page import = "zr.zrpower.flowengine.service.FlowControl"%>
<%@ page import = "zr.zrpower.collectionengine.service.CollectionService"%>

<%@ page import = "java.lang.Object"%>

<%
SessionUser user = (SessionUser)session.getAttribute("userinfo");
UIService userUI =new UIService();
FlowControl FControl = new FlowControl();

CollectionService Coll = new CollectionService();

String strID = request.getParameter("ID");//配置ID
if (strID==null){strID = "";}

String strDOCID = request.getParameter("DOCID");//文档ID
if (strDOCID==null){strDOCID = "";}

String strREADONLY = request.getParameter("READONLY");//只读 1 是
if (strREADONLY==null){strREADONLY = "";}

String strATT = request.getParameter("ATT");//是否有附件 1 是
if (strATT==null){strATT = "";}

String strISOPEN = request.getParameter("ISOPEN");//是否新窗口打开 1 是
if (strISOPEN==null){strISOPEN = "";}

String strRELOAD = request.getParameter("RELOAD");//关闭时是否刷新父窗口 1 是
if (strRELOAD==null){strRELOAD = "";}


String getREURL = "";
String strREURL = request.getParameter("REURL");//保存后返回路径
if (strREURL==null){strREURL = "";}

//说明；如 REURL=QueryPage.do?ID=00000013&CID=01 ,传递时参数传不过来，需改成:REURL=QueryPage.do?ID=00000013,CID=01
//所以要把,替换成&
getREURL = strREURL.replaceAll(",","&");

String strDRead = "";
String strARead = "1";

if (strREADONLY.equals("1"))
{
   strDRead = "&coll_READ=1";
   strARead = "3";
}


String strISDELETE = request.getParameter("ISDELETE");//是否删除
if (strISDELETE==null){strISDELETE = "";}
if (strISDELETE.equals("1"))//执行删除操作
{
   Coll.datadelete(strDOCID,strID);
}

%>
<HTML>
<HEAD>
<TITLE><%=SysPreperty.getProperty().SystemName%><%=SysPreperty.getProperty().Versoin%></TITLE>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset=GBK">
<link REL="stylesheet" type="text/css" href="../zrsysmanage/css/<%=user.getUserCSS()%>">
<SCRIPT LANGUAGE="JavaScript" src="../zrsysmanage/script/Public.js"></SCRIPT>
<script type='text/javascript' src="Print/PrintFuncs.js"></script>
<%if("6".equals(user.getUserWINDOWTYPE())){ %>
<LINK type="text/css" rel="stylesheet" href="../zrsysmanage/html5/css/style_tables.css">
<SCRIPT LANGUAGE="JavaScript" src="../zrsysmanage/html5/script/jquery-2.0.3.min.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="../zrsysmanage/html5/layer/layer.js"></SCRIPT>
<script type="text/javascript" src="../zrsysmanage/html5/script/systype.js"></SCRIPT>
<%}%>


</HEAD>

<BODY class="BodyMain">
<Form name="recordfrm" method="post" action="">
<input type="hidden" name="type" value="0">
<!--HTML Head表单头显示[显示内容,图标文件,用户肤色的图片文件夹]-->

          <tr><td align="center">

          <table border='0' width="100%"  height="100%" cellspacing="0" cellpadding="0" align=center id="table1">
           <tr>
             <td  width="100%">

             <%if (strISDELETE.equals("1")){%>
             <center>
             <Font class="WriteSign">提示：正在删除数据,请等待...</font>
             </center>
             <%}else{%>

             <table border='0' width="100%"  height="100%" cellspacing="0" cellpadding="0" align=center>

                 <tr>
                  <td height="100%">
                  <!--采集引擎(传递参数:配置ID，活动ID，业务ID值,关联ID值,  返回参数:业务ID值,关联ID值,标题)-->
                  <iframe id=CollDataTable name=CollDataTable src="../collengine.do?COLL_AID=<%=strID%>&coll_PKID=<%=strDOCID%>&coll_FKID=<%=strDOCID%>&coll_MODE=2<%=strDRead%>" border=0 frameborder=0 width=100% height=100%></iframe>
                  <iframe id=CollPrint name=CollPrint src="../collengine.do?COLL_AID=<%=strID%>&coll_PKID=<%=strDOCID%>&coll_FKID=<%=strDOCID%>&coll_MODE=3<%=strDRead%>" border=0 frameborder=0 width=1 height=1></iframe>
                  </td>
                 </tr>
                 <%if (strATT.equals("1")){%>
                 <tr>
                    <td height="85">
                       <iframe id=att name=att src="../zrsysmanage/att/AttAddFrm.jsp?FLOWID=<%=strID%>&DOCID=<%=strDOCID%>&AID=<%=strID%>&TYPE=<%=strARead%>" border=0 frameborder=0 width=100% height=100%></iframe>

                    </td>
                 </tr>
                 <%}%>
                 <tr>
                    <td height="10">
                       <div id="wait" style="display:none" align="center">
                        <Font class="WriteSign">正在处理,请等待...</font>
                       </div>
                    </td>
                 </tr>

                 <tr>
                      <td height="28"  align="center">

                       <table cellspacing="0" cellpadding="0" border='0'><tr>
                       <%if (!strREADONLY.equals("1")){%>
                        <%=userUI.ClickButton1("保存","saveColl();","buttonSave.gif",user.getUserImage())%>

                        <%if (strDOCID.length()>0){%>
                        <%=userUI.ClickButton1("删除","deletedata();","buttonCancel.gif",user.getUserImage())%>

                        <%}}else{%>

                        <%=userUI.ClickButton1("打印","Javascript:formPrint();","IcoPrint.gif",user.getUserImage())%>

                        <%}%>
                        <%if (strISOPEN.equals("1")){%>
                            <%if("html5.css".equals(user.getUserCSS())){ %>
                            <%=userUI.ClickButton1("关闭","Javascript:parent.layer.closeAll();","buttonClose.gif",user.getUserImage())%>
                            <%}else{ %>
                            <%=userUI.ClickButton1("关闭","reclose();","buttonClose.gif",user.getUserImage())%>
                            <%} %>
                        <%}else{
                          if (strREURL.length()>0)
                          {
                          %>
                           <%=userUI.ClickButton1("返回","reurl();","buttonReturn.gif",user.getUserImage())%>
                        <%}}%>

                      </tr></table>

                      </td>
                 </tr>
                 <tr><td height="5"></td></tr>

             </table>
             <%}%>

             </td>
             <td width="2"></td>
          </tr></table>


          </td></tr>
<!--HTML Foot显示表单尾-->
<%=userUI.ShowFootHtml()%>
</form>
</BODY>

<SCRIPT language="javascript" type="text/javascript">
var sid = "";
//采集引擎处理后执行的函数(表单ID，关联ID,标题)
function save_return(PKID,FKID,TITLE){
   if (PKID==null || PKID.length==0)
   {alert("保存失败！");
   }
   sid = PKID;
    <%if (strATT.equals("1")){%>
    //重调附件
    window.att.location.href= "zrsysmanage/att/AttAddFrm.jsp?FLOWID=<%=strID%>&DOCID="+PKID+"&AID=<%=strID%>&TYPE=<%=strARead%>";
    //----
   <%}%>
   ShowWainForWin("none");

   <%if (strISOPEN.equals("1")){%>
        reclose();
   <%}else{
     if (strREURL.length()>0)
     {
     %>
        location.href="<%=getREURL%>";
   <%}}%>
}

function saveColl(){
   //显示提示
   ShowWainForWin("");
   //调用采集引擎保存
   window.CollDataTable.saveColl();
}
//提示框 Value=""表示显示  Value="none"表示隐藏
function ShowWainForWin(Value){
    //显示/隐藏提交提示
    document.getElementById("wait").style.display=Value;

}

function deletedata(){
  if (confirm("确定要删除吗？"))
  {
    var id="<%=strDOCID%>";
    if (id.length==0)
    {id=sid;}
    location.href="collengine.jsp?ID=<%=strID%>&DOCID="+id+"&READONLY=<%=strREADONLY%>&ATT=<%=strATT%>&ISOPEN=<%=strISOPEN%>&REURL=<%=strREURL%>&ISDELETE=1";
  }
}

function reurl(){
    location.href="<%=getREURL%>";
}
function reclose(){
    <%if (strRELOAD.equals("1")){%>
    window.opener.location.reload();
    <%}%>
    window.close();
}
function reclose1(){

    <%if("html5.css".equals(user.getUserCSS())){ %>
    parent.layer.closeAll();
    <%}else{%>
    window.close();
    <%}%>
}

//隐藏模板上div的id 包含 show的。
function initValue(){
        var showdiv=document.CollDataTable.document.getElementsByTagName('div');
        var id="";
        for(var i=1; i<showdiv.length; i++)
        {
          id = showdiv[i].id;
          if(id.indexOf("show") >= 0 )
          {showdiv[i].style.display="none";}
        }
}
<%if (strREADONLY.equals("1")){%>
setTimeout("initValue();",1000);
<%}%>

 <%if (strISDELETE.equals("1") && strISOPEN.equals("1")){%>
 setTimeout("reclose1();",1000);
 <%}%>
  <%if (strISDELETE.equals("1") && !strISOPEN.equals("1")){%>
 setTimeout("reurl();",1000);
 <%}%>

//网页打印
function openprint()
{
  var w,h,s;
  var IndexWin = null;
  var url = "Print/DoPrint.jsp?AID=<%=strID%>&DOCID=<%=strDOCID%>";

  w = screen.availWidth - 4;
  h = screen.availHeight - 43;
  s = "directories=no,left=0,top=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no,width=" + w + ",height=" + h;
  IndexWin = window.open(url,"print",s);
  IndexWin.moveTo(-4,-4);
  IndexWin.focus();
}

function formPrint(){

ZRPRINT=getZrprint();
ZRPRINT.PRINT_INIT("表单打印");

var strFormHtml=document.CollPrint.document.body.innerHTML;
ZRPRINT.ADD_PRINT_HTM(50,50,'96%','96%',strFormHtml);
ZRPRINT.SET_PRINT_STYLEA(0,"HOrient",3);
ZRPRINT.SET_PRINT_STYLEA(0,"VOrient",3);
ZRPRINT.SET_SHOW_MODE("HIDE_PAPER_BOARD",1);
ZRPRINT.SET_SHOW_MODE("LANDSCAPE_DEFROTATED",1);
ZRPRINT.SET_SHOW_MODE("SHOW_SCALEBAR",true);//语句控制显示标尺
ZRPRINT.PREVIEW();
}

</SCRIPT>
</HTML>
<%
user = null;
userUI  = null;
FControl  = null;
%>
