<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../conn/conn.asp" -->
<!--#include file="../../Inc/Commoncode.asp" -->
<!--#include file="../checkvalid.asp"-->
<%
If Not FRAdminLevel(404) Then
	Call ErrorMsg()
End If
Dim Action
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Finereason HRCMS 7.0 后台管理系统</title>
<link href="../css/style<%=sk%>.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../inc/input.js"></script>
<script language="javascript">
function insertText(labelstr)
{
document.labelform.LabelContent.focus();
var sel=document.selection;
if (sel!=null) 
   {
   var mg=sel.createRange();
   if (mg!=null)
        {
        mg.text=labelstr;
        }
   }
}
</script><script language="javascript">
<!--
function fnRemoveBrank(strSource)
{
 return strSource.replace(/^\s*/,'').replace(/\s*$/,'');
}
function String.prototype.lenB()
{
return this.replace(/[^\x00-\xff]/g,"**").length;
}
function Juge(theForm)
{
  if (fnRemoveBrank(theForm.LabelName.value) == "")
  {
    alert("请输入标签名称!");
    theForm.LabelName.focus();
    return (false);
  }
  if (fnRemoveBrank(theForm.LabelContent.value) == "")
  {
    alert("请输入标签内容!");
    theForm.LabelContent.focus();
    return (false);
  } 
   if (fnRemoveBrank(theForm.Labelorder.value) != "")
  {
	  var objv = fnRemoveBrank(theForm.Labelorder.value);
	  var pattern = /^[0-9]+$/;
	  flag = pattern.test(objv);
	  if(!flag)
	  {
		alert("标签级别要求为数字!请重新输入。");
		theForm.Labelorder.focus();
		return (false);
	   }
   } 
 }
 //-->
</script></head>
<body>
<%
Action=trim(Request("Action"))
select case Action
	Case "Add"
		Call ShowData()
	Case "Modify"
		Call ShowData()
	Case "SaveData"
		Call SaveData()
end select
Sub ShowData()
LabelID=trim(request.QueryString("LabelID"))
If LabelID<>"" and IsNumeric(LabelID) Then
	sql="select * from JOB_Label where LabelID=" & LabelID
	set rs=server.CreateObject (FR_HR_RS)
	rs.open sql,conn,1,1
	if not rs.eof then
		LabelName=Rs("LabelName")
		LabelName=Replace(LabelName,"{$FR_","")
		LabelName=Replace(LabelName,"}","")
		LabelType=Rs("LabelType")
		LabelContent=Rs("LabelContent")
		LabelIntro=Rs("LabelIntro")
		Labelorder=Rs("Labelorder")
	end if
	rs.Close
	Set rs=Nothing
else
LabelName=""
LabelContent="请输入标签内容..."
LabelIntro="请输入标签介绍..."
Labelorder=0
End If
%>
<table width="51%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th colspan="2" align="right"><%if LabelID<>"" then:Response.Write("编辑"&LabelName):else:Response.Write("添加静态"):end if%>标签</th>
  </tr>
  <form action="?Action=SaveData&LabelID=<%=LabelID%>" method="post" name="labelform" onSubmit="return Juge(this)">
  <tr>
    <td width="22%" align="right">标签名称：</td>
    <td width="78%">{$FR_<input name="LabelName" type="text" size="15" value="<%=LabelName%>" <%if LabelID<>"" and LabelType=<5 then Response.Write("readonly")%> />
      }请输入中文汉字作为标签名称</td>
  </tr>
  
  <tr>
    <td align="right">可插入的标签：</td>
    <td><a style="cursor:hand" onClick="javascript:insertText('{$FR_网站名称}');">网站名称</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_网站标题}')">网站标题</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_网站网址}')">网站网址</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_LOGO地址}')">LOGO地址</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_网站版权}')">网站版权</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_网站关键字}')">网站关键字</a><br><a style="cursor:hand" onClick="javascript:insertText('{$FR_网站描述}')">网站描述</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_联系人}')">联系人</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_联系地址}')">联系地址</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_联系电话}')">联系电话</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_联系传真}')">联系传真</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_管理员名称}')">管理员名称</a><br><a style="cursor:hand" onClick="javascript:insertText('{$FR_管理员邮箱}')">管理员邮箱</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_系统目录}')">系统目录</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_管理员目录}')">管理员目录</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_页尾导航}')">页尾导航</a> | <a style="cursor:hand" onClick="javascript:insertText('{$FR_网站版权}')">网站版权</a></td>
  </tr>
  <tr>
    <td align="right">标签内容：</td>
    <td><textarea id="LabelContent" name="LabelContent" cols="60" rows="10"><%=LabelContent%></textarea></td>
  </tr>
  
  <tr>
    <td align="right">标签介绍：</td>
    <td><textarea name="LabelIntro" cols="60" rows="4"><%=LabelIntro%></textarea></td>
  </tr>
  <tr>
    <td align="right">标签级别：</td>
    <td><input name="Labelorder" type="text" size="4" value="<%=Labelorder%>">
      级别较高标签将被优先转换</td>
  </tr>
  <tr>
    <td colspan="2" align="center"><input name="Submit" type="submit" class="inputs" value="保　存">
      <input name="Submit2" type="reset" class="inputs" value="重　置">　
       <input name="Submit3" type="button" class="inputs" value="取  消" onClick="window.close();">    </td>
  </tr>
  </form>
</table>
<%End Sub%>
</body>
</html>
<%Sub SaveData()
	LabelID=trim(request.QueryString("LabelID"))
	LabelName=Trim(Request.Form("LabelName"))
	LabelContent=Trim(Request.Form("LabelContent"))
	LabelIntro=Trim(Request.Form("LabelIntro"))
	Labelorder=Trim(Request.Form("Labelorder"))
	If LabelName="" Then
		Response.Write ("<script language=JavaScript>{alert('请输入标签名称！');history.back();}</script>")
		Response.End 
	End If
	If LabelContent="" Then
		Response.Write ("<script language=JavaScript>{alert('请输入标签内容！');history.back();}</script>")
		Response.End
	End If
	If Labelorder="" then
		Labelorder=0
	end if
	LabelName=Replace(LabelName,LabelName,"{$FR_"&LabelName&"}")
	'判断默认方案下是否有同名的标签名称存在
	if LabelID="" then
		sql="select LabelName from job_label where LabelName='"&LabelName&"' and projectid="&DefaultTPID&""
		set rs=Server.CreateObject(FR_HR_RS)
		rs.open sql,conn,1,1
		if not rs.eof then
			Response.Write ("<script language=JavaScript>{alert('同名的标签名称已经存在！');history.back();}</script>")
			Response.End
		end if
		rs.close
		set rs=nothing
	end if

	set rs=Server.CreateObject(FR_HR_RS)
	if LabelID<>"" and IsNumeric(LabelID) then
	sql="select * from JOB_Label where LabelID=" & LabelID
	else
	sql="select * from JOB_Label"
	end if
	rs.open sql,conn,1,3
	if LabelID="" then
	rs.AddNew
	rs("LabelType")=5
	rs("Labeladddate")=now()
	end if
	rs("LabelName")=LabelName
	rs("LabelContent")=LabelContent
	rs("LabelIntro")=LabelIntro
	rs("Labelorder")=Labelorder
	rs("Labeleditdate")=now()
	rs("projectid")=DefaultTPID
	rs.update
	rs.close
	set rs=nothing
	Response.Write ("<script language=JavaScript>{alert('操作成功！');window.opener.location.reload();window.close();}</script>")
	Response.End
end sub
%>