<%@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 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.cid.value) == "")
  {
    alert("请选择频道!");
    theForm.cid.focus();
    return (false);
  }
    if (fnRemoveBrank(theForm.tid.value) == "")
  {
    alert("请选择栏目!");
    theForm.tid.focus();
    return (false);
  } 
    var objv = fnRemoveBrank(theForm.imgnum.value);
	var pattern = /^[0-9]+$/;
	flag = pattern.test(objv);
	if(!flag)
	{
	alert("图片数量应该为整数数字!");
	theForm.imgnum.focus();
	return (false);
	} 
    var objv = fnRemoveBrank(theForm.imgw.value);
	var pattern = /^[0-9]+$/;
	flag = pattern.test(objv);
	if(!flag)
	{
	alert("图片宽度应该为整数数字!");
	theForm.imgw.focus();
	return (false);
	}  
  	var objv = fnRemoveBrank(theForm.imgh.value);
	var pattern = /^[0-9]+$/;
	flag = pattern.test(objv);
	if(!flag)
	{
	alert("图片高度应该为整数数字!");
	theForm.imgh.focus();
	return (false);
	} 
    if (fnRemoveBrank(theForm.order.value) == "")
  {
    alert("请选择排序方式!");
    theForm.order.focus();
    return (false);
  } 
	var objv = fnRemoveBrank(theForm.font_left.value);
	var pattern = /^[0-9]+$/;
	flag = pattern.test(objv);
	if(!flag)
	{
	alert("标题字数应该为整数数字!");
	theForm.font_left.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()
ChannelID=trim(Request("ChannelID"))
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")
		LabelContent=Replace(LabelContent,"{$GetSlide(","")
		LabelContent=Replace(LabelContent,")}","")
		LabelContents=Split(LabelContent,",")
		LabelIntro=Rs("LabelIntro")
		Labelorder=Rs("Labelorder")
	end if
	rs.Close
	Set rs=Nothing
if ChannelID<>"" then
cid=ChannelID
else
	if LabelContents(0)=chr(34)&"-1"&chr(34) then
	cid="-1"
	else
	cid=LabelContents(0)
	end if
end if
tid=LabelContents(1)
flashid=LabelContents(2)
imgnum=LabelContents(3)
imgw=LabelContents(4)
imgh=LabelContents(5)
tjnews=LabelContents(6)
tjhome=LabelContents(7)
homepic=LabelContents(8)
homehot=LabelContents(9)
order=LabelContents(10)
font_left=LabelContents(11)
else
LabelName=""
LabelIntro="请输入标签介绍..."
Labelorder=0
End If
if ChannelID<>"" then
	cid=ChannelID
else
	cid="-1"
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 align="right">标签名称：</td>
    <td>{$FR_<input name="LabelName" type="text" size="15" value="<%=LabelName%>" <%if LabelID<>"" and LabelType=<5 then Response.Write("readonly")%> />
      }请输入中文汉字作为标签名称</td>
  </tr>
  <tr>
    <td width="22%" align="right">所属频道：</td>
    <td width="78%">
      <select name="cid" onChange="javascript:window.location='GetSlide.asp?Action=<%=Action%>&LabelID=<%=LabelID%>&ChannelID='+this.options[this.selectedIndex].value;">
        <option value="-1" <%if cid="-1" then Response.Write("selected") %>>当前频道</option>
		<option value="0" <%if cid="0" then Response.Write("selected") %>>全部频道</option>
		<%sql="select * from JOB_Channel where ModuleType=10"
			set rsw=conn.execute(sql)
			if not rsw.eof then
			do while not rsw.eof%>
			<option value="<%=rsw("ChannelID")%>" <%if cid=trim(rsw("ChannelID")) then Response.Write("selected") %>><%=rsw("ChannelName")%></option>
		<%rsw.movenext
			loop
			end if
			rsw.close
			set rsw=nothing%>
      </select></td>
  </tr>
  <tr>
    <td align="right">所属栏目：</td>
    <td><label>
      <select name="tid">
	  <option value="">请选择栏目</option>
       <option value="0" <%if tid="0" then Response.Write("selected") %>>所有栏目</option>
        <%
		if cid<>"-1" and cid<>"0" and cid<>"" then
		set rsw=conn.execute("select * from job_hrnewsType where type_fid="&cid&" order by date desc")
		do while not rsw.eof%>
        <option value="<%=rsw("typeid")%>" <%if tid=trim(rsw("typeid")) then Response.Write("selected") %>><%=rsw("type")%></option>
        <%rsw.movenext
loop
rsw.close
set rsw=nothing
end if
%>
      </select>
    </label></td>
  </tr>
  <tr>
    <td align="right">显示样式：</td>
    <td>
      <input name="flashid" type="radio" class="checkbox" value="1" <%if flashid=1 then Response.Write("checked")%>>
      样式一
    <input name="flashid" type="radio" class="checkbox" value="2" <%if flashid=2 then Response.Write("checked")%>> 
    样式二 
    <input name="flashid" type="radio" class="checkbox" value="3" <%if flashid=3 then Response.Write("checked")%>>
    样式三 
    <input name="flashid" type="radio" class="checkbox" value="4" <%if flashid=4 then Response.Write("checked")%>>
    样式四 
    <input name="flashid" type="radio" class="checkbox" value="5" <%if flashid=5 then Response.Write("checked")%>>
    样式五</td>
  </tr>
  <tr>
    <td align="right">图片数量：</td>
    <td><input name="imgnum" type="text" size="4" value="<%=imgnum%>">
      张</td>
  </tr>
  <tr>
    <td align="right">图片大小：</td>
    <td>宽
      <input name="imgw" type="text" size="4" value="<%=imgw%>">
    像素 高
    <input name="imgh" type="text" size="4" value="<%=imgh%>">
像素</td>
  </tr>
  <tr>
    <td align="right">标题字数：</td>
    <td><input name="font_left" type="text" size="4" value="<%=font_left%>"></td>
  </tr>
  <tr>
    <td align="right">文章属性：</td>
    <td><input name="tjnews" type="checkbox" class="checkbox" id="tjnews" value="1" <%if tjnews=1 then Response.Write("checked")%>>小类推荐&nbsp;
      <input name="tjhome" type="checkbox" class="checkbox" id="tjhome" value="1" <%if tjhome=1 then Response.Write("checked")%>>
首页推荐&nbsp;
<input name="homepic" type="checkbox" class="checkbox" id="homepic" value="1" <%if homepic=1 then Response.Write("checked")%>>
首页推荐(图)&nbsp;
<input name="homehot" type="checkbox" class="checkbox" id="homehot" value="1" <%if homehot=1 then Response.Write("checked")%> >
频道头条(图)</td>
  </tr>
  <tr>
    <td align="right">排序方式：</td>
    <td><label>
      <select name="order">
        <option value="newsid desc" <%if order="newsid desc" then Response.Write("selected")%>>按ID正序排列</option>
		<option value="newsid asc" <%if order="newsid asc" then Response.Write("selected")%>>按ID反序排列</option>
		<option value="hits desc" <%if order="hits desc" then Response.Write("selected")%>>按点击次数</option>
		<option value="Dateandtime desc" <%if order="Dateandtime desc" then Response.Write("selected")%>>按时间正序排列</option>
		<option value="Dateandtime asc" <%if order="Dateandtime asc" then Response.Write("selected")%>>按时间反序排列</option>
      </select>
    </label></td>
  </tr>
  <tr>
    <td align="right">标签介绍：</td>
    <td><label>
      <textarea name="LabelIntro" cols="60" rows="4"><%=LabelIntro%></textarea>
    </label></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"><label>
      <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();">
    </label></td>
  </tr>
  </form>
</table>
<%End Sub%>
</body>
</html>
<%Sub SaveData()
	LabelID=trim(request.QueryString("LabelID"))
	LabelName=Trim(Request.Form("LabelName"))
	
	If LabelName="" Then
		Response.Write ("<script language=JavaScript>{alert('请输入标签名称！');history.back();}</script>")
		Response.End 
	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
	
	cid=Trim(Request.Form("cid"))
	if cid="-1" then
		cid=chr(34)&cid&chr(34)
	end if
	tid=Trim(Request.Form("tid"))
	flashid=Trim(Request.Form("flashid"))
	imgnum=Trim(Request.Form("imgnum"))
	imgw=Trim(Request.Form("imgw"))
	imgh=Trim(Request.Form("imgh"))
	tjnews=Trim(Request.Form("tjnews"))
	if tjnews="" then
	tjnews=0
	end if
	tjhome=Trim(Request.Form("tjhome"))
	if tjhome="" then
	tjhome=0
	end if
	homepic=Trim(Request.Form("homepic"))
	if homepic="" then
	homepic=0
	end if
	homehot=Trim(Request.Form("homehot"))
	if homehot="" then
	homehot=0
	end if
	order=Trim(Request.Form("order"))
	font_left=Trim(Request.Form("font_left"))
	LabelContent="{$GetSlide("&cid&","&tid&","&flashid&","&imgnum&","&imgw&","&imgh&","&tjnews&","&tjhome&","&homepic&","&homehot&","&order&","&font_left&")}"
	LabelIntro=Trim(Request.Form("LabelIntro"))
	Labelorder=Trim(Request.Form("Labelorder"))
	If Labelorder="" then
		Labelorder=0
	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")=6
	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
%>