<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ 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.mail.*" %>
<%@ 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">
	<script type="text/javascript">
		function FCKeditor_OnComplete(editorInstance) {
			window.status = editorInstance.Description;
		}
	</script>
	<script type="text/javascript" src="<%=strLevel%>share/ckeditor/ckeditor.js"></script>	
	<script language="javascript" src="../share/js/commonTool.js"></script>
	<script language="javascript" src="../share/js/annexTool.js"></script>
</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 = SzConvert.toSpaceStr(request.getParameter("OPERATOR"));
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    
    //读取数据
    YjMailInfo yjMailInfo = null;
    YjMailNew yjMail = new YjMailNew();
    YjMailReceive yjMailReceive = new YjMailReceive();
    if (!sKEY.equals("0")) {
        yjMailInfo = (YjMailInfo)yjMail.getInfoByKey(Integer.parseInt(sKEY));
    }
    if (yjMailInfo == null) {
        yjMailInfo = new YjMailInfo();
    } else {
    }

    //接收人ID，接收人部门
    String JSDLID = "0";
    String JSBMID = "0";
    String JSDLXM = "";
    //抄送
    String CSDLID = "0";
    String CSBMID = "0";
    String CSDLXM = "";
    //密送
    String MSDLID = "0";
    String MSBMID = "0";
    String MSDLXM = "";
    
    String FSBT = "";
    String FSNR = "";
    String JSYJDZ = "";
    String sReadonly = "";
    boolean bReadonly = false;
    if (sOPERATOR.equals("detail")) {
        sReadonly = "readonly";
        bReadonly = true;
    } else if (sOPERATOR.equals("return")) {
    	//回复，读取原始邮件的内容
    	JSDLID = "" + yjMailInfo.getFSDLID();
    	JSDLXM = yjMailInfo.getFSDLXM();
    	JSBMID = "";
    	JSYJDZ = yjMailInfo.getFSYJDZ();
    	
    	/*
    	回复时不给抄送、密送回复
    	CSDLID = yjMailInfo.getCSDLID();
      CSBMID = yjMailInfo.getCSBMID();
      CSDLXM = yjMailInfo.getCSDLXM();
        
      MSDLID = yjMailInfo.getMSDLID();
      MSBMID = yjMailInfo.getMSBMID();
      MSDLXM = yjMailInfo.getMSDLXM();
      */
        
    	FSBT = "[回复]" + yjMailInfo.getFSBT();
    	FSNR = "==============邮件原始内容=============\n" + yjMailInfo.getFSNR();
    } else if (sOPERATOR.equals("transfer")) {
    	//2011-07-12
    	//回复，读取原始邮件的内容
    	//JSDLID = "" + yjMailInfo.getFSDLID();
    	//JSDLXM = yjMailInfo.getFSDLXM();
    	JSBMID = "";
    	FSBT = "[转发]" + yjMailInfo.getFSBT();
    	FSNR = "==============邮件原始内容=============<br>" + yjMailInfo.getFSNR();      	
    } else if (sOPERATOR.equals("update")) {
    	//从草稿里发送
    	JSDLID = yjMailReceive.getReceiveUserId(yjMailInfo.getFSID(), yjMail.intReceiveType);
    	JSDLXM = SzUserHelp.getLoginName(JSDLID);
    	JSBMID = "";
    	CSDLID = yjMailReceive.getReceiveUserId(yjMailInfo.getFSID(), yjMail.intReceiveTypeCS);
      CSBMID = "";
      CSDLXM = SzUserHelp.getLoginName(CSDLID);
          
      MSDLID = yjMailReceive.getReceiveUserId(yjMailInfo.getFSID(), yjMail.intReceiveTypeMS);
      MSBMID = "";
      MSDLXM = SzUserHelp.getLoginName(MSDLID);
        
    	FSBT = "" + yjMailInfo.getFSBT();
    	FSNR = "" + yjMailInfo.getFSNR(); 
    	JSYJDZ = yjMailReceive.getReceiveUserId(yjMailInfo.getFSID(), yjMail.intReceiveTypeYJ);
    }

  
    YjForeign yjForeign = new YjForeign();
%>
<script language="javascript">
  function LoadContent1() {
     window_onresize();
     var vUrl = "http://<%=sServer_SESSION%>:<%=sPort_SESSION%><%=sContext_SESSION%>/share/editor/load.jsp?tablename=SZYJ_XXFS&KEY=<%=sKEY%>";
     tbContentElement.LoadURL(vUrl);
  }
</script>
<body   onbeforeunload='return beforeFrameHtmlUnload();'>
<!-----上面的工具栏------>
<form name="formUpdate" method="post"  ENCTYPE="multipart/form-data">
  <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="OPERATOR2" value="<%=sOPERATOR%>">
  <input type="hidden" name="KEY" value="<%=sKEY%>">
  <input type="hidden" name="FSID" value="0">
  <input type="hidden" name="YJBZ" value="<%=yjMailInfo.getYJBZ()%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <!-- <input type="hidden" name="FSNR" value="">   -->    
<%@ include file="/share/title.jsp"%>
<table width="100%">
  <tr>
    <td>
    <% if (!bReadonly) { %>
      <%=SzPageHelp.button("发送","javascript:FormSend(formUpdate, 'control.jsp');")%>
      <%=SzPageHelp.button("保存草稿", "javascript:FormSave(formUpdate, 'control.jsp');")%>
    <% } %>
      <%=SzPageHelp.backButton()%>
    </td>
  </tr>
</table>

<!-----信息维护------>
<table width="750" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
  <tr>
    <td class="tdClassTitle">邮件标题</td>
    <td><input type="text" name="FSBT" class="txtClass2" value="<%=FSBT%>" style="width:350;">
        <!-- <input type="checkbox" name="FSHZ" value="1" >回执  -->
        <!-- <input type="checkbox" name="save" value="1" checked>存到已发送  -->
        <input type="checkbox" name="alert" value="1" checked>消息提醒
        <% if (ReadOaConfig.getAlert_button().indexOf("weixin") >=0) { %>
        <input type="checkbox" name="alertWeixin" value="1" checked>微信提醒
        <% } %>
        <% if (ReadOaConfig.getAlert_button().indexOf("sms") >=0) { %>
        <input type="checkbox" name="alert2" value="1">手机提醒
        <% } %>
    </td>
  </tr>
  <tr>
    <td class="tdClassTitle">收件人<br>
      <input type="button" class="btnClassShort" value="选择" OnClick="javascript:OpenFlowUserWin();">
    </td>
    <td><input type="hidden" name="JSDLID" class="txtClass1" value="<%=JSDLID%>">
        <input type="hidden" name="JSBMID" class="txtClass1" value="<%=JSBMID%>">
    <a style="cursor:hand" onclick="javascript:CSTR.style.display=CSTR.style.display=='block'?'none':'block';">抄送</a>
    <a style="cursor:hand" onclick="javascript:MSTR.style.display=MSTR.style.display=='block'?'none':'block';">密送</a>
    [<a style="cursor:hand" onclick="javascript:outMsg.style.display=outMsg.style.display=='block'?'none':'block';">外部</a>]
    <br>
    <textarea name="JSDLXM2" class="areaClass2" readonly></textarea><br>
    <textarea name="JSDLXM" class="areaClass2" readonly><%=JSDLXM%></textarea><br>
    </td>
  </tr>
  <tr id="CSTR" style="display:none;">
    <td class="tdClassTitle">抄送<br>
    		<input type="hidden" name="CSDLID" class="txtClass1" value="<%=CSDLID%>">
        <input type="hidden" name="CSBMID" class="txtClass1" value="">
        <input type="hidden" name="CSBMMC" class="txtClass1" value="">
      	<input type="button" class="btnClassShort" value="选择" OnClick="javascript:OpenWin34('../','formUpdate.CSDLID', 'formUpdate.CSDLXM');">
    </td>
    <td><textarea name="CSDLXM" class="areaClass2" readonly><%=CSDLXM%></textarea></td>
  </tr>
  <tr id="MSTR" style="display:none;">
    <td class="tdClassTitle">密送<br>
    		<input type="hidden" name="MSDLID" class="txtClass1" value="<%=MSDLID%>">
        <input type="hidden" name="MSBMID" class="txtClass1" value="">
        <input type="hidden" name="MSBMMC" class="txtClass1" value="">
      	<input type="button" class="btnClassShort" value="选择" OnClick="javascript:OpenWin34('../','formUpdate.MSDLID', 'formUpdate.MSDLXM');">
    </td>
    <td><textarea name="MSDLXM" class="areaClass2" readonly><%=MSDLXM%></textarea></td>
  </tr>
  <tr id="outMsg"  <% if (JSYJDZ.equals("")) { out.println("style='display:none'"); } %>>
    <td class="tdClassTitle">收件邮箱地址<br>
    <input type="button" class="btnClassShort" value="选择" OnClick="javascript:OpenIdMultWinSelf('SZCY_TXL', '', 'formUpdate.JSYJDZ');">
    
    <td>     <textarea name="JSYJDZ" class="areaClass2"><%=JSYJDZ%></textarea><br>
        本人外部邮箱帐号：<%=yjForeign.idSelectForeign("WBID", "txtClass350", iDLID_SESSION) %>
    </td>   
  </tr>      
  <tr> 
    <td class="tdClassTitle">附件</td> 
    <td><%=SzPageHelp.updateAnnexNew2(yjMail.strAnnexTable, "" + yjMailInfo.getFSID(), strLevel_SESSION)%></td> 
  </tr>   

</table>

<table width="750" border="0" cellpadding="1" cellspacing="0">
  <tr>
    <td valign="top">
		  <textarea id="FSNR" name="FSNR"><%=FSNR%></textarea>       
    </td>
  </tr>
</table>
	<script type="text/javascript">
    CKEDITOR.replace('FSNR', {
    	filebrowserBrowseUrl: '../share/ckeditor/uploader/browse.jsp',
    	filebrowserUploadUrl: '../share/ckeditor/uploader/upload.jsp'
    });
   </script>
</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">

  function FormSave(formName, url) {
    formName.OPERATOR.value = "add";
    
    //2011-07-16修改草稿问题
    var vKey = formName.KEY.value;
    if (vKey > 0) {
    	formName.OPERATOR2.value = "update";
    }
    /*
    formName.FSNR.value=tbContentElement.DocumentHTML;
    if (formName.FSNR.value == "undefined") {
         formName.FSNR.value = "";
    } 
    */   
		//2012-01-11增加
		vBeforeFrameHtmlUnload = false;	
		    
    formName.action = url;  
    formName.submit();
        
  }
  
  function FormSend(formName, url) {
    formName.OPERATOR.value = "send";
    /*
    formName.FSNR.value=tbContentElement.DocumentHTML;
    if (formName.FSNR.value == "undefined") {
         formName.FSNR.value = "";
    }
    */        
    //检查是否可以保存
    if (!notSpace(formName.FSBT, "邮件标题")) {
      return false;
    }
    if ( (isSpace(formName.JSDLID.value) || formName.JSDLID.value == "0")
        && (isSpace(formName.JSBMID.value) || formName.JSBMID.value == "0") 
        && isSpace(formName.JSYJDZ.value)) {
      alert("收件人不能为空");      
      return false;
    }  
    if ( !isSpace(formName.JSYJDZ.value) && isSpace(formName.WBID.value) ) {
      alert("发送外部邮件至少要选择一个本人其他邮箱地址");      
      return false;
    } 	
		//2012-01-11增加
		vBeforeFrameHtmlUnload = false;	
		
		document.getElementById("divLine").style.display = "block";		
		
    formName.action = url;
    formName.submit();
  }  
  //弹出窗口，选择人员。这里特定是流程里某个步骤的选择人员。
  function OpenFlowUserWin2() {
    var type = "all";
    var url = "user_win.jsp";
    //window.showModalDialog(url,window,"status=no;dialogWidth=750px;dialogHeight=450px");
    window.open(url,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=750,height450");
  } 
    
  //弹出窗口，选择人员。这里特定是流程里某个步骤的选择人员。
  function OpenFlowUserWin() {
    var type = "all";
    var url = "../share/organize/user_win2.jsp";

    url = url + "?objId=formUpdate.JSDLID&objName=formUpdate.JSDLXM";
    url = url + "&objDesc=formUpdate.JSBMID&objDescName=formUpdate.JSDLXM2";
    
    //window.showModalDialog(url,window,"status=no;dialogWidth=660px;dialogHeight=450px");
    window.open(url,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=660,height=450");
  }
  
  //弹出窗口
  function OpenIdMultWinMail(vTableName, objId, objName) {
    var type= "";
    var url = "id_mult_win_self.jsp";
    url = url + "?objId=" + objId + "&objName=" + objName + "&tableName=" + vTableName;
    //window.showModalDialog(url,window,"status=no;dialogWidth=580px;dialogHeight=350px");
 		window.open(url,"","left=100,top=100,scrollbars=yes,resizable=yes,status=yes,width=580,height=350");    
  }  
</script>
<div id="divLine" class="divLine" align="center" style="position:absolute;width:450;height:150px;left:150px;top:150px;padding:60px 0 0 0; margin:0px;overflow:auto;overflow:hidden;display:none; background-color:#dbdbdb;">
	<img src="<%=strSkin_SESSION%>/bar.gif">
</div><!---------------------------------------------------------------20120112 ting----------------------------------------->

</body>
