<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_Sales")="0" AND (Session("Manager")="1" OR (JudgePopedomTF(Session("UserName"),"SK300000000") AND JudgePopedomTF(Session("UserName"),"SK300000101")))) then Call ReturnError()%>
<%
'AddNew
if RQ("Action")="Add" and F("S_Di")<>"" and F("S_Title")<>"" and F("S_Content")<>"" then
Call ChkIsOuter()
set rs=server.createobject("adodb.recordset")
sql="select * from SK_Activity"
rs.open sql,conn,1,3
rs.AddNew
rs("SK_Di")=NoCSSHackInput(F("S_Di"))
rs("SK_Title")=NoCSSHackInput(F("S_Title"))
rs("SK_Principal")=NoCSSHackInput(F("S_Principal"))
rs("SK_Agent")=NoCSSHackInput(F("S_Agent"))
rs("SK_Atime")=NoCSSHackInput(F("S_Atime"))
rs("SK_Btime")=NoCSSHackInput(F("S_Btime"))
rs("SK_Content")=NoCSSHackContent(F("S_Content"))
rs("SK_SalesID")=Session("UID")
rs("SK_Addor")=Session("Oname")
rs("SK_Time")=Now()

'自定义字段部分开始
set RsField=Server.createobject("adodb.recordset")
sqlField="SELECT * from SK_SalesFields where SK_Di=0 and SK_ShowOnForm=0"
RsField.Open sqlField,conn,1,1
A=0
while not RsField.eof
A=A+1
rs(""&RsField("SK_FieldName")&"")=NoCSSHackInput(F(""&RsField("SK_FieldName")&""))
RsField.movenext
wend
RsField.close
Set RsField=Nothing

set RsOption=Server.createobject("adodb.recordset")
sqlOption="SELECT * from SK_SalesOptions where SK_Di=0 and SK_ShowOnForm=0"
RsOption.Open sqlOption,conn,1,1
B=0
while not RsOption.eof
B=B+1
rs(""&RsOption("SK_FieldName")&"")=NoCSSHackInput(F(""&RsOption("SK_FieldName")&""))
RsOption.movenext
wend
RsOption.close
Set RsOption=Nothing
'自定义字段部分结束

rs.Update
rs.Close 
set rs=Nothing
'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" src="../Inc/Check.js"></script>
<script language="javascript" src="../Inc/Calendar.js"></script>
<script language="javascript" src="../Inc/jquery.js"></script>
<SCRIPT language=javascript src="../inc/Openwin.js"></SCRIPT>
<script>
window.onbeforeunload = function()
{
if (document.body.offsetWidth-50 < event.clientX && event.clientY<0)
{
return "是否关闭当前窗口？关闭本窗口将放弃发布信息！";
}
}
</script>
<style type="text/css">
<!--
body {
margin: 5px 0px 5px 0px;
overflow-x: hidden;
}
-->
</style>
<SCRIPT language=JavaScript>
function Form1_Validator(theForm)
{

if(form1.S_Di.value ==""){
alert("对不起,请选择活动类别!");
form1.S_Di.focus();
return false;
}

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

return true;
}
</SCRIPT>
</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 name="thisForm" id="form1" method="post" action="?Action=Add" onSubmit="return Form1_Validator(this)"> 
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6">
<tr>
  <td width="14%" class="SK_Text2">活动类别</td>
  <td colspan="3" class="SK_Text1"><select name="S_Di">
<option value="" selected>---请选择---</option>
<%
Set rs1=Server.CreateObject("ADODB.RecordSet") 
sql1="SELECT * from SK_SystemCategory where SK_Di=41 order by CategoryID asc" 
rs1.Open sql1,conn,1,1
do while not rs1.eof
%><option value="<%=rs1("CategoryID")%>"><%=rs1("SK_Name")%></option>
<%
rs1.movenext
loop
rs1.close
set rs1=Nothing
%></select> <font color=red>*</font></td>
  <td width="15%" class="SK_Text2">活动主题</td>
  <td width="47%" class="SK_Text1"><input name="S_Title" type="text" size="40"> <font color=red>*</font></td>
</tr>
<tr>
  <td class="SK_Text2">负责人员</td>
  <td colspan="3" class="SK_Text1"><input name="S_Principal" type="text" size="20"></td>
  <td class="SK_Text2">经办人员</td>
  <td class="SK_Text1"><input name="S_Agent" type="text" size="20"></td>
</tr>
<tr>
  <td class="SK_Text2">开始日期</td>
  <td colspan="3" class="SK_Text1"><input name="S_Atime" type="text" size="12" onClick="new Calendar().show(this);" readOnly /></td>
  <td class="SK_Text2">结束日期</td>
  <td class="SK_Text1"><input name="S_Btime" type="text" size="12" onClick="new Calendar().show(this);" readOnly /></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"> <font color=red>*</font></td>
</tr>
<%
'自定义选项开始
set RsOptions=server.createobject("adodb.recordset")
sqlOptions="SELECT * from SK_SalesOptions where SK_Di=0 and SK_ShowOnForm=0 Order by SK_OrderID asc"
RsOptions.Open sqlOptions,conn,1,1
if RsOptions.bof and RsOptions.eof then
else
%>
<tr>
  <td colspan="6" class="SK_Title1">自定义选项</td>
</tr>
<tr>
  <td colspan="6" class="SK_Text1">
<%
Response.write"<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""1"">"
for Optionsi=1 to RsOptions.recordCount '变量i从1循环到数据库中的全部记录数 
if (Optionsi mod 2 =1) then '每个tr即每行显示1个记录,可根据需要自行修改, 将左边的1修改为2即显示两行。
response.write "<tr>" 
end if
Response.write"<td class=""SK_Text2"" width=""14%"">"&RsOptions("SK_Title")&"</td><td class=""SK_Text1""><select name="&RsOptions("SK_FieldName")&">"

Set rsOptionsDetail=Server.CreateObject("ADODB.RecordSet") 
sqlOptionsDetail="SELECT * from SK_SalesOptionsDetail where SK_OptionsID="&RsOptions("FieldID")&"" 
rsOptionsDetail.Open sqlOptionsDetail,conn,1,1
Response.write"<option value="""" selected>--请选择--</option>"
do while not rsOptionsDetail.eof
Response.write"<option value="&rsOptionsDetail("OptionsDetailID")&">"&rsOptionsDetail("SK_OName")&"</option>"
rsOptionsDetail.movenext
loop
rsOptionsDetail.close
set rsOptionsDetail=Nothing

Response.write"</select></td>"
if (Optionsi mod 2 = 0) then '每个tr即每行显示1个记录,可根据需要自行修改, 将左边的1修改为2即显示两行。
response.write "</tr>" 
end if 
RsOptions.movenext 
next 
Response.write"</table>"
%>
</td>
</tr>
<%
end if
RsOptions.close
set RsOptions=Nothing
'自定义选项结束

'自定义字段开始
set RsFields=server.createobject("adodb.recordset")
sqlFields="SELECT * from SK_SalesFields where SK_Di=0 and SK_ShowOnForm=0 Order by SK_OrderID asc"
RsFields.Open sqlFields,conn,1,1
if RsFields.bof and RsFields.eof then
else
%>
<tr>
  <td colspan="6" class="SK_Title1">自定义字段</td>
</tr>
<tr>
  <td colspan="6" class="SK_Text1">
<%
Response.write"<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""1"">"
for Fieldsi=1 to RsFields.recordCount '变量i从1循环到数据库中的全部记录数 
if (Fieldsi mod 2 =1) then '每个tr即每行显示1个记录,可根据需要自行修改, 将左边的1修改为2即显示两行。
response.write "<tr>" 
end if
Response.write"<td class=""SK_Text2"" width=""14%"">"&RsFields("SK_Title")&"</td><td class=""SK_Text1""><input type=""text"" size=""20"" name="&RsFields("SK_FieldName")&" title="&RsFields("SK_Tips")&"></td>"
if (Fieldsi mod 2 = 0) then '每个tr即每行显示1个记录,可根据需要自行修改, 将左边的1修改为2即显示两行。
response.write "</tr>" 
end if 
RsFields.movenext 
next 
Response.write"</table>"
%>
</td>
</tr>
<%
end if
RsFields.close
set RsFields=Nothing
'自定义字段结束
%>
<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" /></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>