<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 (Session("Manager")="1" OR JudgePopedomTF(Session("UserName"),"SK900000006")) then Call ReturnError1()%>
<%
'AddNew
if RQ("Action")="Add" and F("Di")<>"" then
Call ChkIsOuter()

If F("FieldName")="" Then
Response.Write("<script LANGUAGE='javascript'>alert('对不起，字段名称不能为空!');history.go(-1);</script>")
Response.End
end if

If Len(F("FieldName"))<=3 Then
Response.Write("<script LANGUAGE='javascript'>alert('对不起，字段名称长度必须大于3!');history.go(-1);</script>")
Response.End
end if

If Left(F("FieldName"),3)<>"CU_" Then
Response.Write("<script LANGUAGE='javascript'>alert('对不起，字段名称格式有误，必须以""CU_开头""!');history.go(-1);</script>")
Response.End
end if

If F("Title")="" Then
Response.Write("<script LANGUAGE='javascript'>alert('对不起,字段别名不能为空！');history.go(-1);</script>")
Response.End
end if

set rs=server.createobject("adodb.recordset")
sql="select * from SK_ServiceField where SK_Di="&F("Di")&" and SK_FieldName='"&F("FieldName")&"'"
rs.open sql,conn,1,3
if not rs.eof or not rs.bof then
Response.Write("<script LANGUAGE='javascript'>alert('对不起,该字段名称已经存在！');history.go(-1);</script>")
Response.End
end if
rs.AddNew
rs("SK_Di")=NoCSSHackInput(F("Di"))
rs("SK_FieldName")=NoCSSHackInput(F("FieldName"))
rs("SK_Title")=NoCSSHackInput(F("Title"))
rs("SK_Tips")=NoCSSHackInput(F("Tips"))
rs("SK_ShowOnForm")=NoCSSHackInput(F("ShowOnForm"))
rs("SK_OrderID")=NoCSSHackInput(F("OrderID"))
rs.Update
rs.Close 
set rs=nothing
if F("Di")=0 then
conn.execute("alter table [SK_Services] add "&NoCSSHackInput(F("FieldName"))&" char(200)")
end if

'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")="新建自定义字段："&F("FieldName")&""
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 language=javascript src="../inc/common.js"></SCRIPT>
<SCRIPT language=JavaScript>
window.onbeforeunload = function()
{
if (document.body.offsetWidth-50 < event.clientX && event.clientY<0)
{
return "是否关闭当前窗口？关闭本窗口将放弃新增信息！";
}
}

function Form1_Validator(theForm)
{
if(form1.FieldName.value ==""){
   alert("对不起,字段名称不能为空!");
   form1.FieldName.focus();
   return false;
}
if(form1.Title.value ==""){
   alert("对不起,字段别名不能为空!");
   form1.Title.focus();
   return false;
}

 return true;
}

Setdisplay(1);function Setdisplay(s){if (s==3||s==6||s==7){ $("OptionsArea").style.display="";} else $("OptionsArea").style.display="none";if (s==7)$("darea").style.display="";else $("darea").style.display="none";if(s==9)$("extarea").style.display="";else $("extarea").style.display="none"; if(s==10)$("editorarea").style.display="";else $("editorarea").style.display="none";if (s==2||s==10) $("heightarea").style.display="";else $("heightarea").style.display="none"}
</Script>
<style type="text/css">
<!--
body {
margin: 5px 0px 5px 0px;
overflow-x: hidden;
}
-->
</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 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 class="SK_Text2">所属表名</td>
  <td class="SK_Text1"><select name="Di">
    <option value="0">客服列表</option>
  </select>  <font color=red>* 新建后不允许修改。</font>
  </td>
</tr>
<tr><td width="13%" class="SK_Text2">字段名称</td>      
<td width="87%" class="SK_Text1"><input name="FieldName" type="text" id="FieldName" value="CU_" size="30" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')"> <font color=red>* 为了和系统字段区分，必须以“CU_”开头，新建后不允许修改。</font></td>
</tr>
<tr>
<td class="SK_Text2">字段别名</td>
<td class="SK_Text1"><input name="Title" type="text" size="30"> <font color=red>* 便于在管理项目中显示</font></td>
</tr>
<tr>
<td class="SK_Text2">附加提示</td>
<td class="SK_Text1"><textarea name="Tips" cols="50" rows="6"></textarea> <font color=red>在输入框旁边的提示信息</font></td> 
</tr>
<tr>
<td class="SK_Text2">是否启用</td>
<td class="SK_Text1"><select name="ShowOnForm">
  <option value="0" selected>是</option>
  <option value="1">否</option>
</select></td></tr>

<tr>
<td class="SK_Text2">排序序号</td>
<td class="SK_Text1"><input name="OrderID" type="text" value="1" size="10" maxlength="4"> <font color=red>序号越小，排在越前面</font></td>
</tr>
<tr>
<td colspan="4" 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>