<!--#include file="../../conn/conn.asp" -->
<!--#include file="../../Inc/Commoncode.asp" -->
<!--#include file="../../Inc/Commonfunction.asp" -->
<!--#include file="../../FCKeditor/fckeditor.asp" -->
<!--#include file="../checkvalid.asp" -->
<%
dim wid
wid=request("wid")
if wid="" or not Isnumeric(wid) then wid=10
If Not FRAdminLevel(307&wid) Then
	Call ErrorMsg()
End If
Dim action
Dim typeid
sUploadDir=UpFilesPath("Article")
newsid=request.QueryString("newsid")
action=request.QueryString("action")
select case action
	case "save"
		call SaveData()
end select
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>HR资讯类别管理</title>
<link href="../css/style<%=sk%>.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../inc/input.js"></script>
</head>
<script type="text/javascript">
function String.prototype.lenB()
{
return this.replace(/[^\x00-\xff]/g,"**").length;
}
function check()
{
if(document.form1.I_title.value=="")
{
alert("请输入资讯标题!");
document.form1.I_title.focus();
return (false);
}
if(document.form1.I_typeid.value=="资讯类别")
{
alert("请选择资讯类别!");
return (false);
}
if(document.form1.I_overview.value!="")
{
  if ((document.form1.I_overview.value).lenB()>=400)
  {
	 alert("资讯简介太长了，要求不多于200个字符!");
	 document.form1.I_overview.focus();
	 return (false);
  }
}
var oEditor =FCKeditorAPI.GetInstance("I_content"); 
var Content=oEditor.GetXHTML(); 
if(Content=="") 
{ 
alert("请输入资讯内容！"); 
oEditor.Focus();//获取焦点 
return false; 
}
}
function show()
{
	if (document.getElementById("I_ispic").checked==true)
	{document.getElementById("I_pic").style.display="block";}
	else
	{document.getElementById("I_pic").style.display="none";}
}
function opw(url,name,width,height) 
{
	window.open(url,name,''+'width='+width+',height='+height+',scrollbars=yes'+'');
}
</script>
<style type="text/css">
.tableBorder td{ height:20px;}
</style>
<body>
<%if (newsid<>"" and Isnumeric(newsid)) then
	sql="select * from JOB_News where N_id="&newsid&" and N_cid="&wid&""
	set rs=Server.CreateObject("ADODB.RecordSet")
	rs.open sql,conn,1,1
	if not rs.eof then
		I_title=rs("N_title")
		I_content=rs("N_content")
		I_typeid=rs("N_sid")
		I_channelid=rs("N_cid")
		I_iscommand=rs("N_iscommond")
		I_author=rs("N_author")
		I_editor=rs("N_editor")
		I_from=rs("N_from")
		I_pic=rs("N_pic")
		I_ispic=rs("N_ispic")
		I_homecommand=rs("N_homecommond")
		I_addtime=rs("N_addtime")
		I_overview=rs("N_overview")
		I_sorttitle=rs("N_sorttit")
		I_color=rs("N_color")
		I_addtime=rs("N_addtime")
	end if
	rs.close
	set rs=nothing
end if
%>
<table width="98%" border="0" cellspacing="1" cellpadding="2" align=center class="tableBorder"> 
  <tr> 
     <th height=25><%=ChannelNametitle(wid)%>管理</th> 
  </tr> 
  <tr>
    <td height=25><span class="bodytitle"><font color="ff6600"><b class="style1">　管理选项</b></font></span>： <a href="newsadd.asp?wid=<%=wid%>">添加<%=ChannelNametitle(wid)%></a> | <a href="index.asp?wid=<%=wid%>">管理<%=ChannelNametitle(wid)%></a> | <a href="newssort.asp?wid=<%=wid%>#type">添加信息类别</a> | <a href="newssort.asp?wid=<%=wid%>">管理信息类别</a> | [<a href="javascript:location.reload()">刷新页面</a>] </td>
  </tr>
</table>
<table width="98%" border="0" cellspacing="1" cellpadding="2" align=center class="tableBorder mt6">
  <tr>
    <th colspan="2"><%=ChannelNametitle(wid)%>文章<%if typeid="" then%>添加<%else%>修改<%end if%></th>
  </tr>
<form name="form1" action="newsadd.asp?wid=<%=wid%>&action=save&newsid=<%=newsid%>&picold=<%=I_pic%>" method="post" onsubmit="return check();">
  <tr>
    <td width="10%" align="right">资讯标题：</td>
    <td width="90%">&nbsp;<select name="I_sorttitle">
		<option value="" selected="selected"></option>
        <option value="[组图]" <%if I_sorttitle="[组图]" then%>selected="selected"<%end if%>>[组图]</option>
        <option value="[推荐]" <%if I_sorttitle="[推荐]" then%>selected="selected"<%end if%>>[推荐]</option>
        <option value="[注意]" <%if I_sorttitle="[注意]" then%>selected="selected"<%end if%>>[注意]</option>
      </select>
       <input name="I_title" type="text" id="I_title" size="50" value="<%=I_title%>" />
       &nbsp; <select name="I_color">
	   <option value='' selected>颜色</option> 
			<option value='#000000' style='background-color:#000000' <%if I_color="#000000" then%>selected="selected"<%end if%>></option> 
			<option value='#008000' style='background-color:#008000' <%if I_color="#008000" then%>selected="selected"<%end if%>></option> 
			<option value='#800000' style='background-color:#800000' <%if I_color="#800000" then%>selected="selected"<%end if%>></option> 
			<option value='#808000' style='background-color:#808000' <%if I_color="#808000" then%>selected="selected"<%end if%>></option> 
			<option value='#0000FF' style='background-color:#0000FF' <%if I_color="#0000FF" then%>selected="selected"<%end if%>></option> 
			<option value='#FF0000' style='background-color:#FF0000' <%if I_color="#FF0000" then%>selected="selected"<%end if%>></option> 
       </select>      </td>
  </tr>
  <tr>
    <td align="right">资讯类别：</td>
    <td>&nbsp;<select name="I_typeid">
	<%if newsid="" then%>
	<option value="资讯类别" selected="selected">请选择资讯类别</option>
	<%else%>
	<option value="<%=I_typeid%>" selected><%=InfoType(I_typeid)%>&nbsp;类信息</option>
	<%end if%>
	<%
		set Infotypers=server.createobject("ADODB.Recordset")
		Infotypesql="select * from JOB_NewsSort where S_cid="&wid&" order by S_order asc"
		Infotypers.open Infotypesql,conn,1,1
		do while not Infotypers.eof
			response.write"<option value="&Infotypers("S_id")&">"&Infotypers("S_name")&"&nbsp;类信息</option>"
			Infotypers.movenext
		loop
		Infotypers.close
		set Infotypers=nothing
	%>
      </select>　　<a href="newssort.asp?wid=<%=wid%>#type"><font color="#FF0000">添加</font></a> </td>
  </tr>
  <tr>
    <td align="right">资讯属性：</td>
    <td>&nbsp;<input name="I_iscommand" type="checkbox" class="checkbox" value="1" <%if I_iscommand=1 then%>checked="checked"<%end if%> />
      小类推荐
        <input name="I_homecommand" type="checkbox" class="checkbox" value="1" <%if I_homecommand=1 then%>checked="checked"<%end if%> />
        首页推荐
        <input name="I_ispic" type="checkbox" class="checkbox" id="I_ispic" onclick="javascript:show();" value="1" <%if I_ispic=1 then%>checked="checked"<%end if%> />
        图片资讯（必须上传图片）</td>
  </tr>
  <tr id="I_pic" <%if I_ispic=0 then%>style="display:none;"<%end if%>>
    <td align="right">资讯图片：</td>
    <td>&nbsp;<input name="I_pic" type="text" id="I_pic" value="<%=I_pic%>" size="40" readonly/> 
    <input name="upfile" type="button" class="inputs" onClick="javascript:opw('../inc/job_up.asp?fromForm=form1&fromEdit=I_pic&saveTo=<%=sUploadDir%>&showPath=','adpic',420,165)" value="浏览文件"></td>
  </tr>
  <tr>
    <td align="right">资讯作者：</td>
    <td>&nbsp;<input name="I_author" type="text" id="I_author" value="<%=I_author%>" size="40" /> 
    <font color='blue'><=【<font color='green' onclick="document.form1.I_author.value='未知'" style="cursor:pointer;">未知</font>】</font></td>
  </tr>
  <tr>
    <td align="right">资讯来源：</td>
    <td>&nbsp;<input name="I_from" type="text" id="I_from" value="<%=I_from%>" size="40" /> 
    <font color='blue'><=【<font color='green' onclick="document.form1.I_from.value='互联网'" style="cursor:pointer;">互联网</font>】</font></td>
  </tr>
  <tr>
    <td align="right">添加时间：</td>
    <td>&nbsp;<input name="I_addtime" type="text" size="40" <%if newsid="" then%>value="<%=now()%>"<%else%>value="<%=I_addtime%>"<%end if%> /> <font color='blue'><=【<font color='green' onclick="document.form1.I_addtime.value='<%=now()%>'" style="cursor:pointer;"><%=now()%></font>】</font></td>
  </tr>
  <tr>
    <td width="10%" align="right">资讯简介：</td>
    <td width="90%">&nbsp;<textarea name="I_overview" cols="90" rows="4"><%=I_overview%></textarea>
      只限200个字符</td>
  </tr>
  <tr>
    <td align="right">资讯内容：<br />
      (换行请按&nbsp;&nbsp;&nbsp; Shift+Enter)</td>
    <td><% 
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath = InstallDir&FR_HR_Editor
oFCKeditor.ToolbarSet = "Default"
oFCKeditor.Config("SkinPath") = InstallDir&FR_HR_Editor&"editor/skins/silver/"
oFCKeditor.Width = "100%"
oFCKeditor.Height = "400"
oFCKeditor.Value = I_content
oFCKeditor.Create "I_content"
%>
</td>
  </tr>
  <tr>
    <td width="10%" align="right">责任编辑：</td>
    <td width="90%">&nbsp;<input type="text" name="I_editor" value="<%=I_editor%>" /> <font color='blue'><=【<font color='green' onclick="document.form1.I_editor.value='<%=Request.Cookies("admin_name")%>'" style="cursor:pointer;"><%=Request.Cookies("admin_name")%></font>】</font></td>
  </tr>
  <tr>
    <td colspan="2" class="td30" align="center"><input name="Submit" type="submit" class="inputs" <%if newsid="" then%>value="添加资讯"<%else%>value="修改资讯"<%end if%>/>　　
    <input name="Submit2" type="reset" class="inputs" <%if id="" then%>value="取消添加"<%else%>value="取消修改"<%end if%>/></td>
  </tr>
</form>
</table>
<!--#include file="../inc/copy.asp" -->
</body>
</html>
<%
'保存数据
Sub SaveData()
	picold=request.QueryString("picold")
	I_sorttitle=Replace_Text(request.Form("I_sorttitle"))
	I_title=Replace_Text(request.Form("I_title"))
	I_color=Replace_Text(request.Form("I_color"))
	I_typeid=Replace_Text(request.Form("I_typeid"))
	I_iscommand=Replace_Text(request.Form("I_iscommand"))
	if I_iscommand="" then
		I_iscommand=0
	end if
	I_homecommand=Replace_Text(request.Form("I_homecommand"))
	if I_homecommand="" then
		I_homecommand=0
	end if
	I_ispic=Replace_Text(request.Form("I_ispic"))
	if I_ispic="" then
		I_ispic=0
	end if
	I_pic=Replace_Text(request.Form("I_pic"))
	I_author=Replace_Text(request.Form("I_author"))
	I_from=Replace_Text(request.Form("I_from"))
	I_addtime=request.Form("I_addtime")
	if I_istolink="" then
		I_istolink=0
	end if
	I_overview=Replace_Text(request.Form("I_overview"))
	if len(I_overview)>200 then
		response.Write("<script>alert(""资讯简介不要超过200个字符!"");history.go(-1);</script>")
		response.End()
	end if
	I_content=request.Form("I_content")
	if I_content="" then
		response.Write("<script>alert(""请输入资讯内容!"");history.go(-1);</script>")
		response.End()
	end if
	I_editor=Replace_Text(request.Form("I_editor"))


	if newsid="" then
		sql="select N_id from JOB_News where N_title='"&I_title&"' and N_cid="&wid&""
	else
		sql="select N_id from JOB_News where N_title='"&I_title&"' and N_cid="&wid&" and N_id<>"&newsid&""
	end if
	set rs=Server.CreateObject("ADODB.RecordSet")
	rs.open sql,conn,1,1
	if not rs.eof then
		response.Write("<script>alert(""资讯["&I_title&"]已经加过了，请不要重复添加!"");history.go(-1);</script>")
		response.End()
	end if
	rs.close
	'如果是修改资讯,则判断是否修改了图片，是则删除系统原来存在的图片
	if newsid<>"" then
		if I_ispic=1 then
			if StrComp(I_pic,picold)<>0 then
				picold="../../Upfiles/Article/"+picold
				call DoDelFile(picold)
			end if
		end if
	end if
	'添加和更新资讯

	if newsid="" then
		sqls="select * from JOB_News"
	else
		sqls="select * from JOB_News where N_id="&newsid
	end if
	set rss=Server.CreateObject("ADODB.RecordSet")
	rss.open sqls,conn,3,3
	if newsid="" then
		rss.addnew
	end if
		rss("N_title")=I_title
		rss("N_content")=I_content
		rss("N_sid")=I_typeid
		rss("N_cid")=wid
		rss("N_iscommond")=I_iscommand
		rss("N_author")=I_author
		rss("N_editor")=I_editor
		rss("N_from")=I_from
		rss("N_pic")=I_pic
		rss("N_ispic")=I_ispic
		rss("N_addtime")=I_addtime
		rss("N_overview")=I_overview
		rss("N_sorttit")=I_sorttitle
		rss("N_color")=I_color
		rss("N_homecommond")=I_homecommand
	rss.update
	rss.close
	set rss=nothing	
	'读出新添加的文章的编号生成，如果设置生成的话 
	set rs=conn.execute("select * from JOB_news where N_title='"&I_title&"'")
		Nid=rs("N_id")
	set rs=nothing
	Call NewsContentHtml(Nid)
	if newsid<>"" then
		response.Write("<script>alert(""修改资讯完成!"");location.href=""index.asp?wid="&wid&""";</script>")
	else
		response.Write("<script>alert(""添加资讯完成!"");location.href=""index.asp?wid="&wid&""";</script>")
	end if
	response.End()
End Sub


%>