<html xmlns="http://www.w3.org/1999/xhtml">
<!--#include file="../Inc/Conn.asp" -->
<!--#include file="../Inc/SK.Session.asp" -->
<!--#include file="../Inc/SK.Funtion.asp" -->
<%if Not (getconfig("SK_Office")="0" AND (Session("Manager")="1") OR (JudgePopedomTF(Session("UserName"),"SK100000000") AND JudgePopedomTF(Session("UserName"),"SK100000702"))) then Call ReturnError()%>
<%
Dim Anum:Anum=5
'AddNew
if RQ("Action")="Send" and F("S_User")<>"" and F("S_Title")<>"" and F("S_Content")<>"" then
Call ChkIsOuter()

str2=split(F("S_User"),",")
for i=0 to ubound(str2)

set RsFuser=server.createobject("adodb.recordset")
SqlFuser="select * from SK_SystemUsers where SK_OName='"&str2(i)&"'"
RsFuser.open SqlFuser,conn,1,1

set rs=server.createobject("adodb.recordset")
sql="select * from SK_OfficeMsn"
rs.open sql,conn,1,3
rs.AddNew
rs("SK_Sender")=Session("UID")
rs("SK_Sendtime")=Now()
rs("SK_Receiver")=RsFuser("UsersID")
rs("SK_Title")=NoCSSHackInput(F("S_Title"))
rs("SK_Content")=NoCSSHackContent(F("S_Content"))
rs("SK_Importance")=NoCSSHackInput(F("S_Importance"))
rs("SK_Draft")=NoCSSHackInput(F("S_Draft"))
rs("SK_Del")="0"
rs("SK_SendDel")="0"
rs("SK_ReDel")="0"
rs("SK_Received")="0"
rs("SK_SystemUsers")=F("S_User")
rs.Update
rs.Close 
set rs=Nothing

if F("ReMsnID")<>"" then
set rs2=server.createobject("adodb.recordset")
sql2="SELECT * from SK_OfficeMsn where SK_Receiver="&Session("UID")&" and SK_Draft=0 and MsnID="&JCID(F("ReMsnID"))&""
rs2.Open sql2,conn,1,3
rs2("SK_Received")="2"
rs2.Update
end if

RsFuser.close
RsFuser=Nothing
next

'Event Begin
if getconfig("SK_Event")=0 then
set rsEvent=server.createobject("adodb.recordset")
sqlEvent="select * from SK_SystemEvent"
rsEvent.open sqlEvent,conn,1,3
rsEvent.AddNew
rsEvent("SK_Title")="发送消息："&NoCSSHackInput(F("S_Title"))&""
rsEvent("SK_User")=Session("UserName")
rsEvent("SK_Time")=Now()
rsEvent("SK_IP")=request.ServerVariables("Remote_Addr")
rsEvent.Update
rsEvent.Close 
set rsEvent=Nothing
end if
'Event End
Response.Write("<script LANGUAGE='javascript'>alert('恭喜你,消息发送成功！');window.close();window.opener.location.reload();</script>")
Response.End
end if
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>发送消息</title>
<META http-equiv=Page-Enter content=SKCRM>
<META http-equiv=Page-Exit content=SKCRM>
<META content="MSHTML 6.00.3790.2858" name=GENERATOR>
<LINK href="../images/style.css" type=text/css rel=stylesheet>

<script language="javascript">
window.onbeforeunload = function()
{
if (document.body.offsetWidth-50 < event.clientX && event.clientY<0)
{
return "是否关闭当前窗口？关闭本窗口将放弃发送消息！";
}
}

function InsAdd(){
var qF = "S_User";
var _R = showModalDialog('../System/SK.SDUsers.asp?toId='+form1.toId.value,0,"dialogWidth:700px;dialogHeight:400px;status:no");
if ("undefined" != typeof(_R) ){
form1.S_User.value = _R.S_User;
form1.S_UserID.value = _R.S_UserID;
form1.toId.value = _R.toId;
}
form1.elements[qF].focus();
}
function MM_Do(action){
var checkflag=true;
if(action=="sent"){
document.form1.action.value="sent";
}else if(action=="save"){
document.form1.action.value="save";
}
if(checkflag) document.form1.submit();
}

function Form1_Validator(theForm)
{ 
if (theForm.S_User.value == "")
{
alert("对不起,收件人不能为空!");
theForm.S_User.focus();
return (false);
}

if (theForm.S_Title.value == "")
{
alert("对不起,主题不能为空!");
theForm.S_Title.focus();
return (false);
}

return (true);
}
</script>
<style type="text/css">
<!--
body {
margin: 5px 0px 5px 0px;
overflow-x: hidden;
}
ul,li{ margin:0; padding:0; list-style:none}
ul{ padding:1px; border:0px;}
li { border-bottom:1px dashed #eee; padding:4px}
-->
</style>
</head>
<body>
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
<TBODY>
<tr>
<td class="SK_Td_Top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="12" height="25"><img src="../images/tab_03.gif" width="12" height="25" /></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="46%" valign="middle">发送消息</td>
<td width="54%"></td>
</tr>
</table></td>
<td width="16"><img src="../images/tab_07.gif" width="16" height="25" /></td>
</tr>
</table></td>
</tr>
<tr>
<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="8" background="../images/tab_12.gif"></td>
<td>

<form id="form1" name="thisForm" method="post" action="?Action=Send" onSubmit="return Form1_Validator(this)">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6">
<tr>
  <td width="17%" class="SK_Text2">收件人</td>
  <td width="83%" colspan="5" class="SK_Text1"> <input name="S_User" type="text" size="50" value="<%=F("ReUser")%>" readonly> 
  <a onClick="javascript:InsAdd()" style="cursor:hand"><img src="../images/SUser.gif" /></a>
<input type="hidden" name="toId">
<input type="hidden" name="S_UserID">
<font color=red>*</font></td>
</tr>
<tr>
  <td class="SK_Text2">主　题</td>
  <td colspan="5" class="SK_Text1"><input name="S_Title" type="text" size="40" value="<%=F("ReTitle")%>"> <font color=red>*</font></td>
</tr>


<tr>
  <td valign="top" class="SK_Text2">内　容</td>
  <td colspan="5" class="SK_Text1"><IFRAME ID="eWebEditor1" SRC="<%=getconfig("SK_EditorPath")%>/ewebeditor.htm?id=S_Content&style=mini" FRAMEBORDER="0" SCROLLING="no" WIDTH="600" HEIGHT="300"></IFRAME>
<input type="hidden" name="S_Content" value="<%=F("ReContent")%>"> <font color=red>*</font></td>
</tr>

<tr>
  <td valign="top" class="SK_Text2">重要度</td>
  <td colspan="5" class="SK_Text1"><select name="S_Importance">
<option value="2">保密</option>
<option value="1">重要</option>
<option value="0" selected>一般</option>
  </select>  <font color=red>*</font></td>
</tr>

<tr>
  <td valign="top" class="SK_Text2">设为草稿</td>
  <td colspan="5" class="SK_Text1"><select name="S_Draft">
<option value="1">是</option>
<option value="0" selected>否</option>
  </select>  <font color=red>*</font></td>
</tr>

<tr>
<td colspan="6" class="SK_Text">
<INPUT class="button1" type="submit" value=" 确定 "> 
<input type="button" value=" 关闭 " onClick="window.opener.location.reload();window.close();" class="button1" />
<%if F("ReTitle")<>"" then%>
<input type="button" value=" 返回 " onClick="history.go(-1);" class="button1">
<input type="hidden" name="ReMsnID" value="<%=F("ReMsnID")%>">
<%end if%>
</td>
</tr>
</table>
</form>
</td>
<td width="8" background="../images/tab_15.gif"></td>
</tr>
</table></td>
</tr>
<tr>
<td class="SK_Td_Foot">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" height="20"><img src="../images/tab_18.gif" width="12" height="20" /></td>
<td width="98%" class="SK_Td_Page"></td>
<td width="1%"><img src="../images/tab_20.gif" width="16" height="20" /></td>
</tr>
</table>

</td>
</tr>
</TBODY>
</table>
</body>
<%
Call CloseDB()
%>
</html>