<%@ 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="/sessionInfoWeixin.jsp"%>
<% 
  String strLevel = "../"; 
%> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
<%@ include file="/share/oa_app_title.jsp"%>
 <link href="<%=strLevel_SESSION%>app/images/soarwell_css.css" rel="stylesheet" type="text/css" />
 <script type="text/javascript" src="<%=strLevel_SESSION%>share/js/commonTool.js"></script>
 <script type="text/javascript" src="<%=strLevel_SESSION%>app/share/appWinOpen.js"></script>  
 <script language="javascript">
  function OpenUserSelectWinApp() {
    var vUrl = "../../share/organize/user_win2_app.jsp?type=all"
    	+ "&objName=formUpdate.JSDLXM"
    	+ "&objId=formUpdate.JSDLID";
  	//window.open(vUrl,"","left=10,top=10,scrollbars=yes,resizable=yes,status=yes,width=400px,height=430px");
  	//window.showModalDialog(vUrl,window,"status=no;dialogWidth=680px;dialogHeight=450px");  
    var vElementTop = getElementTop(window.event.srcElement);
    var vWebHeight = document.body.scrollHeight;    
    DivWinOpen(vUrl, vElementTop, vWebHeight);  	
  } 
 </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 = "";
    	
    	/*
    	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>
<!-----上面的工具栏------>
<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="/app/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 height="227" width="100%" border="0" cellspacing="3" cellpadding="3" style="border:#D7D7D9 1px solid;">
				<input type="hidden" name="JSDLID" class="txtClass1" value="<%=JSDLID%>">
        <input type="hidden" name="JSBMID" class="txtClass1" value="<%=JSBMID%>">
        <input type="hidden" name="JSDLXM2" class="txtClass1" value="">
    		<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="hidden" name="MSDLID" class="txtClass1" value="<%=MSDLID%>">
        <input type="hidden" name="MSBMID" class="txtClass1" value="">
        <input type="hidden" name="MSBMMC" class="txtClass1" value="">        
  <tr>
    <td><span class="product_content">内部收件人</span><input type="button" value="选择接收人员或部门" class="btnClassLong" OnClick="javascript:OpenUserSelectWinApp();" >
     [<a style="cursor:hand" onclick="javascript:outMsg.style.display=outMsg.style.display=='block'?'none':'block';">外部</a>]
    	<br><br><span class='padding5'></span><textarea name="JSDLXM" class="areaClass2" readonly><%=JSDLXM%></textarea> 
    </td>
  </tr> 
  
  <tr id="outMsg" style="display:none">
    <td><span class="product_content">外部收件邮箱地址</span>
    	<br><span class='padding5'></span>
			 <textarea name="JSYJDZ" class="areaClass2"><%=JSYJDZ%></textarea>    	
    	<br><span class="product_content">发送外部邮件的本人邮箱</span>
    	<br><span class='padding5'></span>
        <%=yjForeign.idSelectForeign("WBID", "txtClass2", iDLID_SESSION) %>     
    </td>        	
  </tr> 
  <tr>
    <td><span class="product_content">邮件标题</span>
    	<br><span class='padding5'></span><input type="text" name="FSBT" class="txtClass2" value="<%=FSBT%>">   
    	<br>
        <input type="checkbox" name="alert" value="1" checked>消息提醒
        <!-- <input type="checkbox" name="alert2" value="1">手机提醒 -->
        <input type="checkbox" name="alertWeixin" value="1" checked>微信提醒
    </td>
  </tr>  
  <tr>
    <td><span class="product_content">内容</span>
    	<br><span class='padding5'></span><textarea id="FSNR" name="FSNR" class="areaClass2"><%=FSNR%></textarea>  
    </td>
  </tr>  
  <tr>
    <td><span class="product_content">附件</span>
    	<br><span class='padding5'></span><%=SzPageHelp.updateAnnexNew2(yjMail.strAnnexTable, "" + yjMailInfo.getFSID(), strLevel_SESSION)%>  
    </td>
  </tr>     

</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">

  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();
  }  

</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----------------------------------------->
<div id="divWinOpenBg"></div>
<div id="divWinOpen">
 <iframe id="frameWinOpen" frameborder="0"  width="100%" height="100%"></iframe>
</div>
</body>
