<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../conn/conn.asp" -->
<!--#include file="../../Inc/Commoncode.asp" -->
<!--#include file="../../FCKeditor/fckeditor.asp" -->
<!--#include file="../checkvalid.asp"-->
<%
'************************************************************
'	Software name: Finereason HRCMS 7.0
'	软件名称:嘉缘人才网站内容管理系统 V7.0
'	Email: service@finereason.com . QQ:109530926
'	Web: http://www.finereason.com  http://www.yjys.net
'	Copyright (C) FineSincere Inc. All Rights Reserved.
'	版权所有 嘉挚科技 未经嘉挚公司授权不得用于任何商业用途
'
'	文件名称：Admin_Announce.asp
'	作    用：网站公告管理
'	最后更新：Fine Sincere (Mr.Hou)
'	最后日期：2007-5-14
'************************************************************
If Not FRAdminLevel(107) Then
	Call ErrorMsg()
End If
Response.Expires = 0 
Response.CacheControl = "no-cache" 
Response.ExpiresAbsolute = Now() - 1 
Dim Action
Dim page,i
Dim totalPut
const MaxPerpage=20
Const strFileName="Admin_Announce.asp"
sUploadDir=UpFilesPath("Announce")
page=Trim(Request("page"))
If page<>"" And IsNumeric(page) Then
	If page<1 Or Len(page)>10 Then
		page=1
	Else
    	page=CLng(page)
	End If
Else
	page=1
End If
%>
<!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" type="text/JavaScript">
function ConfirmDel(ID,Name)
{
   if(confirm("您确定要删除公告【"+Name+"】吗？\n\n警告：此操作不可恢复，请慎重操作！"))
     location.href="<%=strFileName%>?Action=Del&JOB_id="+ID
}
function unSelectAll()
{
    if(document.form1.chkAll.checked){
	document.form1.chkAll.checked = document.form1.chkAll.checked&0;
    } 	
}
function SelectAll(form)
{
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll"&&e.disabled!=true&&e.zzz!=1)
       e.checked = form.chkAll.checked;
    }
}
</script></head>
<body>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th height="22" colspan="2" align="center" class="tableHeaderText"><strong >网站公告管理</strong></th>
  </tr>
  <tr>
    <td height="24" colspan="2"><span class="bodytitle"><font color="ff6600"><b class="style1">　管理选项</b></font>：</span>&nbsp;<a href="<%=strFileName%>">管理公告首页</a>&nbsp;|&nbsp;<a href="<%=strFileName%>?Action=Add">添加公告</a>&nbsp;|&nbsp;<a href="<%=strFileName%>"></a>[<a href="javascript:location.reload()">刷新页面</a>]</td>
  </tr>
  <tr>
    <td width="82" height="21"><div align="right">频道：</div></td>
    <td width="845" height="21"><a href=Admin_Announce.asp?Action=&ChannelID=0>全部频道</a> | <%Call Channel()%></td>
  </tr>
</table>
<%
Action=trim(Request("Action"))
Select Case Action
	Case "Add"
		Call ShowData()
	Case "Modify"
		Call ShowData()
	Case "SaveData"
		Call SaveData()
	Case "Del"
		Call Del()
	Case Else
		Call main()
End Select

if FoundErr=True then
	call Show_Err()
end if
%>
<!--#include file="../inc/copy.asp"-->
<%
Conn.Close
Set Conn=Nothing
%>
<%Sub Channel()
Set rs= Server.CreateObject(FR_HR_RS)
	sql="select * from JOB_Channel where ChannelType<>2 order by OrderID asc"
	rs.open sql,conn,1,1
	if rs.eof and rs.bof then
	else
	do while not rs.eof
		ChannelID=Rs("ChannelID")
		ChannelName=Rs("ChannelName")
		Response.Write("<a href="&strFileName&"?Action=&ChannelID="&ChannelID&">"&ChannelName&"</a>&nbsp;|&nbsp;")
	rs.movenext
	loop
	end if
End Sub
%>
<%
sub main()
Set rs= Server.CreateObject(FR_HR_RS)
	ChannelID=trim(Request("ChannelID"))
	If ChannelID<>"" Then
	sql="select * from JOB_announce where JOB_ChannelID="&ChannelID&" order by JOB_id desc"
	else
	sql="select * from JOB_announce order by JOB_id desc"
	end if
	rs.open sql,conn,1,1
	if rs.eof and rs.bof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>暂无任何公告，请添加后再进行管理！</li>"
		exit sub
	else
		totalPut=rs.recordcount
		if (page-1)*MaxPerpage>totalput then
			if (totalPut mod MaxPerpage)=0 then
				page= totalPut \ MaxPerpage
			else
				page= totalPut \ MaxPerpage + 1
			end if
		end if
		if page=1 then
			Call MainInfo()
		else
			if (page-1)*MaxPerpage<totalPut then
				rs.move  (page-1)*MaxPerpage
				dim bookmark
				bookmark=rs.bookmark
				Call MainInfo()
			else
				page=1
				Call MainInfo()
			end if
		end if
	end if
	rs.close
	set rs=nothing
End Sub
%>
<%Sub MainInfo()%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="tableBorder mt6">
<form name="form1" method="Post" action="<%=strFileName%>">
	  <tr align="center">
		<td width="5%" height="22"><strong>编号</strong></td>
		<td width="47%"><strong>公告标题</strong></td> 
		<td width="18%"><strong>发布时间</strong></td>
		<td width="14%"><strong>所属频道</strong></td>
		<td width="11%"><strong>操作选项</strong></td>
	    <td width="5%"><strong>选中</strong></td>
	  </tr>
	<%
		do while not rs.eof
		JOB_ID=Rs("JOB_id")
		JOB_Title=Rs("JOB_Title")
		JOB_ChannelID=Rs("JOB_ChannelID")
		JOB_DateAndTime=Rs("JOB_DateAndTime")
	%>
	  <tr onMouseOver="this.style.background='#FFFFCC'" onMouseOut="this.style.background='#EEF7FD'" align="center">
		<td align="center"><%=JOB_ID%></td>
		<td align="left"><%=JOB_Title%></td> 
		<td align="center"><%=JOB_DateAndTime%></td>
		<td align="center"><%
		if JOB_ChannelID=0 then
		Response.Write("全部频道")
		else
		Set rst= Server.CreateObject(FR_HR_RS)
		sql1="select * from JOB_Channel where ChannelID="&JOB_ChannelID
		rst.open sql1,conn,1,1
		if not rs.eof then
		Response.Write(Rst("ChannelName"))
		end if
		rst.close
		set rst=nothing
		end if
		%></td>
		<td align="center">
		  <a href="<%=strFileName%>?Action=Modify&JOB_ID=<%=JOB_ID%>">
修改</a> 
<a href="javascript:ConfirmDel(<%=JOB_ID%>,'<%=JOB_Title%>');">删除</a></td>
	    <td align="center"><input name="JOB_ID" type="checkbox" class="checkbox" value="<%=JOB_ID%>" /></td>
	  </tr>
	<%
		i=i+1
		if i>=MaxPerPage then exit do
		rs.movenext
		loop
	%>
		  <tr align="center">
	    <td colspan="6" align="right"><input name="chkAll" type="checkbox" class="checkbox" onClick="SelectAll(this.form)" value="checkbox" />
          <input name="Action" type="hidden" value="Del" />
          选中所有项目&nbsp;&nbsp;&nbsp;&nbsp;将选定的项目:&nbsp;
<input name="submit" type="submit" class="inputs" value="批量删除" /></td>
	    </tr>
		  <tr align="center">
		    <td colspan="6"><%If totalput>0 Then
	Call Showpage(strFileName,totalput,MaxPerPage,false,true,"条公告")
End If%></td>
	      </tr>
</form>
	</table>
<%End Sub%>
<%
Sub ShowData()
	JOB_ID=trim(request.QueryString("JOB_ID"))
	If JOB_ID<>"" Then
		If IsNumeric(JOB_ID)=False Then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>参数错误！</li>"
			Exit Sub
		End If
		sql="select * from JOB_announce where JOB_ID=" & JOB_ID
		set rs=server.CreateObject (FR_HR_RS)
		rs.open sql,conn,1,1
		if rs.bof and rs.eof then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>此公告不存在或者已经删除！</li>"
			Exit Sub
		else
			Titles=Rs("JOB_Title")
			Content=Rs("JOB_Content")
			Author=Rs("JOB_Author")
			DateAndTime=Rs("JOB_DateAndTime")
			IsSelected=Rs("JOB_IsSelected")
			ChannelID=Rs("JOB_ChannelID")
			ShowType=Rs("JOB_ShowType")
			OutTime=Rs("JOB_OutTime")
		end if
		rs.Close
		Set rs=Nothing
	End If
%>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder mt10">
  <form name="form1" method="post" action="<%=strFileName%>">
    <tr class="title">
      <th height="22" colspan="4" align="center" ><strong>
        <%If JOB_ID<>"" Then%>
        修 改
        <%Else%>
        添 加
        <%End If%>
        公 告</strong></th>
    </tr>
    <tr>
      <td width="11%" height="22" align="right"><strong>公告标题：</strong></td>
      <td width="89%"><input maxlength="100" size="50" name="Title" value="<%=Titles%>" /></td>
    </tr>
    <tr>
      <td height="25" align="right"><strong>所属频道：</strong></td>
      <td><select name="ChannelID" size="1" class="lh17">
        <option value="0" selected="selected">全部频道</option>
		<%Set rst= Server.CreateObject(FR_HR_RS)
		sql1="select * from JOB_Channel order by OrderID asc"
		rst.open sql1,conn,1,1
		if rst.eof and rst.bof then
		else
		do while not rst.eof
		%>
		<option value="<%=Rst("ChannelID")%>" <%If Rst("ChannelID")=ChannelID Then%>selected="selected"<%End If%>><%=Rst("ChannelName")%></option>
		<%rst.movenext
		loop
		end if
		rst.close
		set rst=nothing
		%>
        </select>
        请选择此公告显示在什么位置</td>
    </tr>
    <tr>
      <td height="40" align="right"><strong>公告内容：</strong></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 = Content
oFCKeditor.Create "Content"
%></td>
    </tr>
    <tr>
      <td height="22" align="right"><strong>显示方式：</strong></td>
      <td><select name="ShowType" size="1" class="lh17">
        <option value="0" <%If ShowType=0 Then%>selected="selected"<%End If%>>全部</option>
        <option value="1"<%If ShowType=1 Then%>selected="selected"<%End If%>>滚动</option>
        <option value="2"<%If ShowType=2 Then%>selected="selected"<%End If%>>弹出</option>
                        </select></td>
    </tr>
    <tr>
      <td height="22" align="right"><strong>发布人员：</strong></td>
      <td><input maxlength="30" size="15" name="Author" <%If JOB_ID<>"" Then%>value="<%=Author%>"<%Else%>value="<%=Request.Cookies("admin_name")%>"<%End If%> /></td>
    </tr>
    <tr>
      <td height="22" align="right"><strong>发布时间：</strong></td>
      <td><input maxlength="100" size="25" name="DateAndTime" <%If JOB_ID<>"" Then%>value="<%=DateAndTime%>"<%Else%>value="<%=now()%>"<%End If%> /></td>
    </tr>
    <tr>
      <td height="22" align="right"><strong>有效期：</strong></td>
      <td><input maxlength="10" size="5" name="OutTime" <%If JOB_ID<>"" Then%>value="<%=OutTime%>"<%Else%>value="0"<%End If%> />
        天</td>
    </tr>
    <tr>
      <td height="27" align="right"><strong>是否最新：</strong></td>
      <td><input name="IsSelected" type="radio" class="checkbox" value="True"<%If IsSelected = True Then%> checked="checked"<%End If%>  />
是&nbsp;
<input name="IsSelected" type="radio" class="checkbox" value="False"<%If IsSelected = False Then%> checked="checked"<%End If%> />
否&nbsp;&nbsp;选择“是”显示出来，同时显示在首页上</td>
    </tr>
    <tr>
      <td height="40" colspan="2" align="center"><input name="JOB_ID" type="hidden" value="<%=JOB_ID%>" />
          <input name="Action" type="hidden" value="SaveData" />
          <input name="btnSave" type="submit" class="inputs" style="cursor:hand;" value="<%If JOB_ID<>"" Then%> 修 改 <%Else%> 添 加 <%End If%>" />
        &nbsp;
        <input name="btnCancel" type="button" class="inputs" style="cursor:hand;" onClick="window.location.href='<%=strFileName%>'" value=" 取 消 " />      </td>
    </tr>
  </form>
</table>
<%End Sub%>
<%
sub SaveData()
	JOB_id=trim(request("JOB_id"))
	if JOB_id<>"" And IsNumeric(JOB_id)=False then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>参数错误！</li>"
		Exit Sub
		JOB_id=CLng(JOB_id)
	end if
	Titles=Trim(Request.Form("Title"))
	Content=Trim(Request.Form("Content"))
	Author=Trim(Request.Form("Author"))
	DateAndTime=Request.Form("DateAndTime")
	IsSelected=Request.Form("IsSelected")
	ChannelID=Request.Form("ChannelID")
	ShowType=Request.Form("ShowType")
	OutTime=Trim(Request.Form("OutTime"))
	If Titles="" Then
		ErrMsg=ErrMsg &"<br><li>公告标题不能为空！</li>"
		FoundErr=True
	End If
	If Content="" Then
		ErrMsg=ErrMsg &"<br><li>公告内容不能为空！</li>"
		FoundErr=True
	End If
	If IsSelected="" Then
		ErrMsg=ErrMsg &"<br><li>请选择是否为最新！</li>"
		FoundErr=True
	End If
	
	If FoundErr=True Then
		Exit Sub
	End If

	set rs=Server.CreateObject(FR_HR_RS)
	If JOB_id<>"" Then
		sql="select * from JOB_Announce Where JOB_id="&JOB_id
	Else
		sql="select * from JOB_Announce"
	End If
	rs.open sql,conn,1,3
	If JOB_id="" Then
		rs.AddNew
	End If
	rs("JOB_Title")=Titles
	rs("JOB_Content")=Content
	rs("JOB_Author")=Author
	rs("JOB_DateAndTime")=DateAndTime
	rs("JOB_IsSelected")=IsSelected
	rs("JOB_ChannelID")=ChannelID
	rs("JOB_ShowType")=ShowType
	rs("JOB_OutTime")=OutTime
	rs.update
	rs.close
	set rs=nothing
    response.redirect strFileName
	response.End()
end sub
%>
<%
sub Del()
	JOB_id=trim(Request("JOB_id"))
	if JOB_id="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>参数不足！</li>"
		exit sub
	end if
	sql="select * from JOB_Announce where JOB_id In("& JOB_id &")"
    set rs=server.CreateObject ("Adodb.recordset")
	rs.open sql,conn,1,3
	if rs.bof and rs.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>公告不存在或者已被删除！</li>"
		exit sub
	else
		Do While Not(rs.Eof)
			rs.delete
			rs.update
			rs.MoveNext
		Loop
	end if
	rs.close
	set rs=nothing
    response.redirect strFileName
	response.End()
end sub
%>