<%@ page contentType="text/html; charset=GBK" %>
<%@ page import = "zr.zrpower.entity.sys.SessionUser" %>
<%@ page import = "zr.zrpower.ejb.sys.UIService" %>

<%@ page import = "zr.zrpower.ejb.sys.SeManageService" %>
<%@ page import = "java.lang.Object"%>
<%@ page import = "java.util.*"%>
<HTML>
<%
SessionUser user = (SessionUser)session.getAttribute("userinfo");
UIService userUI =new UIService();
SeManageService SeService =new SeManageService();
String strFile_ID="";

String strFLOWID  = request.getParameter("FLOWID"); //得到流程标识ID或表名
String strDOCID  = request.getParameter("DOCID");   //得到文档ID
String strAID  = request.getParameter("AID");       //当前活动ID(不是流程类型时为空)
String strTYPE = request.getParameter("TYPE");      //得到显示类型(1 管理所有附件 2 管理个人上传的附件 3 浏览附件)
String parentload = request.getParameter("parentload"); //上传附件后是否刷新父窗口

String strList ="";
if (strTYPE.equals("1")){
   strList = SeService.ShowSysAttFile(strFLOWID,strDOCID,"");//得到附件显示列表
}else
{
   strList = SeService.ShowSysAttFile(strFLOWID,strDOCID,user.getUserID());//得到附件显示列表
}
String strShowList = SeService.GetSysFileNameList(strFLOWID,strDOCID);
int Attnum = SeService.GetAttNum(strFLOWID,strDOCID);

%>
<HTML>
<HEAD>
<TITLE></TITLE>
<META http-equiv="Content-Type" content="text/html; charset=GBK">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<link REL="stylesheet" type="text/css" href="../css/<%=user.getUserCSS()%>">
<SCRIPT LANGUAGE="JavaScript" src="../script/Public.js"></SCRIPT>
<script type="text/javascript" src="../../dwr/engine.js"></script>
<script type="text/javascript" src="../../dwr/interface/ForumManageBean.js"></script>
<script type="text/javascript" src="../../dwr/util.js"></script>
<Script Language="JavaScript">
function Check(theForm){
  if (RegForm.DOCID.value == "")
  {
    alert("请先保存数据后再上传附件。");
    return (false);
  }
  if (theForm.flFile_Name.value == ""){
    alert("请选择要上传的附件。");
    theForm.flFile_Name.focus();
    return (false);
  }

  if (theForm.pTitle.value=="")
  {
    theForm.pTitle.value = theForm.flFile_Name.value;
  }

  //=====
  var strAID ='<%=strAID%>';
  if(strAID=="mail"){
    var aa =theForm.flFile_Name.value;
    ForumManageBean.getFileSize(aa,
      function(items){
              if(items<=102400){
               document.RegForm.submit();
              }else{
               alert("您上传的单个附件文件过大。系统控制不得上传大于100M的文件！");
              }

      }
    );

  }else{
   return true;
  }
  //=====

}


function Del_File(){
  if ((trim(RegForm.attlist.value)=='')) {
    alert("请选择要删除的文件!");
  }else{
    if (confirm("确定是否删除该文件?")){
      location.href="FileDel.jsp?ID="+RegForm.attlist.value+"&FLOWID="+RegForm.FLOWID.value+"&DOCID="+RegForm.DOCID.value+"&AID="+RegForm.AID.value+"&TYPE="+RegForm.TYPE.value;
    }
  }
}
function parentload()
{
   <%if (parentload!=null && !strFLOWID.equals("mail")){%>
       //parent.window.location.reload();
   <%}%>
}

function insertTitle(tValue){

    document.getElementById("pTitle").value = tValue;

}


</script>
</HEAD>
<BODY  onload="parentload();" class="BodyMain1" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<%
//清空用户的文件ID
user.setUserFileID("");

%>
<FORM method="post" name="RegForm" enctype="multipart/form-data" action="../../actionsysattmanage.do"  onsubmit="return Check(this)">
  <input type="hidden" name="FLOWID" value="<%=strFLOWID%>">
  <input type="hidden" name="DOCID" value="<%=strDOCID%>">
  <input type="hidden" name="AID" value="<%=strAID%>">
  <input type="hidden" name="TYPE" value="<%=strTYPE%>">
  <input type="hidden" name="ATTNUM" value="<%=Attnum%>">
  <input type="hidden" name="pTitle" value="">

  <%if (strTYPE.equals("3")){%>
     <TABLE border="0" width="100%">
       <TR>
         <TD class="PutdSet" width="20%"><FONT face=仿宋_GB2312 size=4>浏览附件：</font></TD>
         <TD width="48%"><%=strShowList%></TD>
         <TD></TD>
       </TR>
     </TABLE>
  <%}else{%>
  <TABLE border="0" width="100%">
    <TR>
      <TD class="PutdSet" width="20%">添加附件：</TD>
      <TD width="48%"><input type="file" name="flFile_Name" onChange="if(this.value)insertTitle(this.value);" size="40" class="text" maxlength="254"></TD>
      <TD>
        <table cellspacing="0" cellpadding="0" border='0'><tr>
             <%=userUI.ClickButton("上传附件","JavaScript:if(Check(document.RegForm)){document.RegForm.submit();}","buttonSave.gif",user.getUserImage())%>
        </tr></table>
       </TD>
    </TR>
    <TR>
      <TD class="PutdSet" width="20%">已传附件：</TD>
      <TD width="48%"><%=strList%></TD>
      <TD>
        <table cellspacing="0" cellpadding="0" border='0'><tr>
             <%=userUI.ClickButton("删除附件","JavaScript:Del_File();","buttonDelete.gif",user.getUserImage())%>
        </tr></table>
     </TD>
    </TR>
    <TR>
      <TD class="PutdSet" width="20%">浏览附件：</TD>
      <TD width="48%"><%=strShowList%></TD>
      <TD></TD>

    </TR>
  </TABLE>
  <%}%>
</FORM>
</BODY>
</HTML>
<%
//清空相关对象
user = null;
userUI = null;
SeService = null;
%>
