<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../conn/conn.asp"-->
<!--#include file="../../Inc/Commoncode.asp" -->
<!--#include file="../../inc/CommonFunction.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_Common.asp
'	作    用：通用页面参数管理
'	最后更新：Fine Sincere (Mr.Hou)
'	最后日期：2007-5-11
'
'************************************************************
If Not FRAdminLevel(309) 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_common.asp"
sUploadDir=UpFilesPath("Common")
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">
<link href="../css/style<%=sk%>.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../inc/input.js"></script>
</head>
<script LANGUAGE="JavaScript">
function check()
{
if (document.form.title.value=="")
{
alert("请输入自定义页面标题！")
document.form.title.focus()
document.form.title.select()
return
}
if (document.form.htmlname.value=="")
{
alert("请输入html文件名！")
document.form.htmlname.focus()
document.form.htmlname.select()
return
}
document.form.submit()
}
</script><script language="JavaScript" type="text/JavaScript">
function ConfirmDel(ID,Name)
{
   if(confirm("您确定要删除自定义页面【"+Name+"】吗？\n\n警告：此操作不可恢复，请慎重操作！"))
     location.href="<%=strFileName%>?Action=Del&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><body>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th height=22 class="tableHeaderText">通用页面管理 </th>
  </tr>
  <tr>
    <td height="22"><font color="ff6600"><b class="style1">　管理选项</b></font>：<a href="Admin_Common.asp">管理首页</a> | <a href="Admin_Common.asp?Action=Add">添加自定义页面</a> | [<a href="javascript:location.reload()">刷新页面</a>]</td>
  </tr>
  <tr>
    <td height="22"><font color="ff6600"><b class="style1">　通用页面</b></font>：<%Call CommonPage()%> 
      <a href="Admin_Common.asp?Action=Create&IsDefault=<%=FR_HR_True%>">生成页面</a></td>
  </tr>
  <tr>
    <td height="22"><font color="ff6600"><b class="style1">自定义页面</b></font>：<%Call CustomPage()%>
      <a href="Admin_Common.asp?Action=Create&IsDefault=<%=FR_HR_False%>"> 生成页面</a></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 "Create"
		Call Createcommonhtml()
	Case Else
		Call main()
End Select

if FoundErr=True then
	call Show_Err()
end if

Conn.Close
Set Conn=Nothing
%>
<%
sub main()
Set rs= Server.CreateObject(FR_HR_RS)
	sql="select * from JOB_common order by id desc"
	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">
    <th height="22" colspan="7">自定义页面管理</th>
	</tr>
	  <tr align="center">
		<td width="6%" height="22"><strong>编号</strong></td>
		<td width="25%"><strong>页面标题</strong></td> 
		<td width="22%"><strong>HTML文件名</strong></td>
		<td width="10%"><strong>页尾显示</strong></td>
		<td width="19%"><strong>最后修改时间</strong></td>
		<td width="12%"><strong>操作选项</strong></td>
	    <td width="6%"><strong>选中</strong></td>
	  </tr>
	<%
		do while not rs.eof
		ID=Rs("id")
		Titles=Rs("Title")
		htmlname=Rs("htmlname")
		DateAndTime=Rs("DateAndTime")
		IsShow=Rs("IsShow")
		IsDefault=Rs("IsDefault")
	%>
	  <tr onMouseOver="this.style.background='#FFFFCC'" onMouseOut="this.style.background='#EEF7FD'" align="center">
		<td align="center"><%=ID%></td>
		<td align="left"> &nbsp;<%=Titles%></td> 
		<td align="left"> &nbsp;<a href="<%=InstallDir%>About/<%=htmlname%>" target="_blank" title="查看"><%=htmlname%></a></td>
		<td align="center"><%if IsShow = True Then:Response.Write("是"):else:Response.Write("否"):end if%></td>
		<td align="center"><%=DateAndTime%></td>
		<td align="center">
		  <a href="<%=strFileName%>?Action=Modify&ID=<%=ID%>">
修改</a><%if IsDefault = False then%> 
<a href="javascript:ConfirmDel(<%=ID%>,'<%=Titles%>');">删除</a><%end if%></td>
	    <td align="center"><input name="ID" type="checkbox" class="checkbox" value="<%=ID%>" /></td>
	  </tr>
	<%
		i=i+1
		if i>=MaxPerPage then exit do
		rs.movenext
		loop
	%>
		  <tr align="center">
	    <td colspan="7" 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="7"><%If totalput>0 Then
	Call Showpage(strFileName,totalput,MaxPerPage,false,true,"个页面")
End If%></td>
	      </tr>
</form>
	</table>
<%End Sub%>
<%
Sub ShowData()
	id=trim(request.QueryString("id"))
	If id<>"" Then
		If IsNumeric(id)=False Then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>参数错误！</li>"
			Exit Sub
		End If
		sql="select * from job_common where id=" & 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("title")
		htmlname=rs("htmlname")
		htmlname=left(htmlname,len(htmlname)-5)
		templateid=rs("templateid")
		content=rs("content")
		IsShow=rs("IsShow")
		end if
		rs.Close
		Set rs=Nothing
	End If
%>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th height=22 colspan="2" class="tableHeaderText"><%if id<>"" then%>修改<%else%>添加<%end if%>页面 </th>
  </tr>
  <form action="admin_common.asp?Action=SaveData" method="post" name="form">
  <tr>
    <td width="88" align="right">页面标题：</td>
    <td width="841"><input type="text" name="title" value="<%=titles%>" /><input type="hidden" name="commonid" value="<%=id%>">
      <span class="f00">如：关于我们</span></td>
  </tr>
  <tr>
    <td align="right">HTML文件名：</td>
    <td><input name="htmlname" type="text" value="<%=htmlname%>" size="14" /> <span class="00f">.html</span> <span class="f00">如：aboutus</span></td>
  </tr>
  <tr>
    <td align="right">选择模板：</td>
    <td><select name="templateid">
	  <option value="" selected>请选择模板</option>
	  <%set rsc=server.CreateObject("adodb.recordset")
	  sqlc="select * from JOB_Template where ChannelID=9999 and typeid=9 order by TemplateID desc"
	  rsc.open sqlc,conn,1,1
		if not rsc.eof then
		do while not rsc.eof
			if  templateid = rsc("TemplateID") then
				response.write "<option value="&rsc("TemplateID")&" selected>"&rsc("TemplateName")&"</option>"
			else
				response.write "<option value="&rsc("TemplateID")&">"&rsc("TemplateName")&"</option>"
			end if
		rsc.movenext
		loop
		else
			response.write "<option value=0>暂无模板</option>"
		end if
		rsc.close
		set rsc=nothing%>
      </select>
    </td>
  </tr>
  <tr>
    <td align="right">页面内容：</td>
    <td><!--<textarea name="content" style="display:none"><%=content%></textarea>--><% 
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 align="right">页尾显示：</td>
    <td><input name="IsShow" type="radio" class="checkbox" value="<%=FR_HR_True%>"<%If IsShow = True Then%> checked="checked"<%End If%>  />
是&nbsp;
<input name="IsShow" type="radio" class="checkbox" value="<%=FR_HR_False%>"<%If IsShow = False Then%> checked="checked"<%End If%> />
否&nbsp;&nbsp;选择“是”显示出来。</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="Submit" type="submit" class="inputs" onClick="check()" value=" 提 交 " />&nbsp;<input name="Submit3" type="reset" class="inputs" value=" 重 置 " /></td>
  </tr>
  </form>
</table>
<%end sub%>
<%sub Createcommonhtml()
IsDefault=Trim(Request("IsDefault"))
if IsDefault<>"" then
set rs=conn.execute("select * from JOB_common where IsDefault = "&IsDefault&" order by id asc")
else
Response.Write("参数错误！")
Response.end()
end if
do while not rs.eof
if rs("templateid")<>"" then
	'读取数据库里面对应的模板的内容
	sqlt="select * from JOB_Template where TemplateID="&rs("templateid")&""
	set rst=Server.CreateObject(FR_HR_RS)
	rst.open sqlt,conn,1,1
	if not rst.eof then
		htm=rst("TemplateContent")
		htm=replace(htm,"{$FR_通用页面内容}",""&rs("content")&"")
		htm=replace(htm,"{$FR_通用标题}",""&rs("title")&"")
		htm=ReplaceLableFlag(ReplaceAllLabel(htm))
		Set fso = Server.CreateObject("Scripting.FileSystemObject")
		if not fso.FolderExists(server.MapPath(InstallDir&HTMLPath&"About/")) Then fso.CreateFolder (server.MapPath(InstallDir&HTMLPath&"About/"))
		HtmlFileName=Server.MapPath(InstallDir&HTMLPath&"About/"&rs("htmlname")&"")
		Set fout = fso.CreateTextFile(HtmlFileName)
		fout.WriteLine CreateHTMLReplace(htm)
		fout.close
		set fout = nothing
	end if
	rst.close
	set rst=nothing
end if
rs.movenext
loop
rs.close
set rs=nothing
Call Show_Suc("生成完成!","admin_common.asp")
end sub
%>
</body>
</html>
<%
'通用页面
Sub CommonPage()
	Set rs= Server.CreateObject(FR_HR_RS)
	sql="select * from JOB_common where IsDefault = "&FR_HR_True&" order by ID desc"
	rs.open sql,conn,1,1
	if not rs.eof then
	do while not rs.eof
	Response.Write("<a href='admin_common.asp?Action=Modify&id="&rs("id")&"'>"&rs("title")&"</a> | ")
	if rs.eof then exit do
	rs.movenext
	loop
	else
	Response.Write("暂无页面！")
	end if
	rs.close
	set rs=nothing
End Sub
'自定义页面
Sub CustomPage()
	Set rs= Server.CreateObject(FR_HR_RS)
	sql="select * from JOB_common where IsDefault = "&FR_HR_False&" order by ID desc"
	rs.open sql,conn,1,1
	if not rs.eof then
	do while not rs.eof
	Response.Write("<a href='admin_common.asp?Action=Modify&id="&rs("id")&"'>"&rs("title")&"</a> | ")
	if rs.eof then exit do
	rs.movenext
	loop
	else
	Response.Write("暂无页面！")
	end if
	rs.close
	set rs=nothing
End Sub
%>
<%
Sub SaveData()
'On Error Resume Next
id=request.form("commonid")
'response.Write id
if id<>"" And IsNumeric(id)=False then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>参数错误！</li>"
	Exit Sub
	'id=CLng(id)
end if
titles=Replace_Text(request.form("title"))
htmlname=Replace_Text(request.form("htmlname"))
htmlname=htmlname&".html"
templateid=request.form("templateid")
content=request.form("content")
IsShow=request.form("IsShow")
if titles="" then
response.write"<SCRIPT language=JavaScript>alert('您没有填写自定义页面标题，请返回重新填写！');"
response.write"javascript:history.go(-1)</script>"
response.end
end if
if htmlname="" then
response.write"<SCRIPT language=JavaScript>alert('您没有填写html文件名，请返回重新填写！');"
response.write"javascript:history.go(-1)</script>"
response.end
end if
if templateid="" then
response.write"<SCRIPT language=JavaScript>alert('您没有选择模板，请返回重新选择！');"
response.write"javascript:history.go(-1)</script>"
response.end
end if
if templateid=0 then
response.write"<SCRIPT language=JavaScript>alert('系统暂无通用模板，请进入模板管理添加！');"
response.write"javascript:history.go(-1)</script>"
response.end
end if
if content="" then
response.write"<SCRIPT language=JavaScript>alert('您没有填写自定义页面内容，请返回重新填写！');"
response.write"javascript:history.go(-1)</script>"
response.end
end if

set rs1=server.CreateObject(FR_HR_RS)
'检测页面名称是否存在
if id<>"" then
sql1="select * from job_common where title='"&titles&"' and id<>"&id&""
else
sql1="select * from job_common where title='"&titles&"'"
end if
rs1.open sql1,conn,1,1
if not(rs1.eof and rs1.bof) then
	response.write "<script>alert(""对不起，自定义页面名称重复！"");history.go(-1);</script>"
	response.end
else
	set rs=server.CreateObject(FR_HR_RS)
	if id<>"" then
		sql="select * from job_common where id="&id
		rs.open sql,conn,1,3
	else
		sql="select * from job_common"
		rs.open sql,conn,1,3
		rs.addnew
		rs("IsDefault")=FR_HR_False
	end if
	rs("title")=titles
	rs("htmlname")=htmlname
	rs("templateid")=templateid
	rs("content")=content
	rs("IsShow")=IsShow
	rs("dateandtime")=now()
	rs.update
	rs.close
	set rs=nothing
	
	'生成文件
	if templateid<>"" and Isnumeric(templateid) then
		'读取数据库里面对应的模板的内容
		sqlt="select TemplateContent from JOB_Template where TemplateID="&templateid&""
		set rst=Server.CreateObject(FR_HR_RS)
		rst.open sqlt,conn,1,1
		if not rst.eof then
			htm=rst("TemplateContent")
			htm=replace(htm,"{$FR_通用页面内容}",""&content&"")
			htm=replace(htm,"{$FR_通用标题}",""&titles&"")
			htm=ReplaceLableFlag(ReplaceAllLabel(htm))
			Set fso = Server.CreateObject("Scripting.FileSystemObject")
			if not fso.FolderExists(server.MapPath(InstallDir&HTMLPath&"About/")) Then fso.CreateFolder (server.MapPath(InstallDir&HTMLPath&"About/"))
			HtmlFileName=Server.MapPath(InstallDir&HTMLPath&"About/"&htmlname&"")
			Set fout = fso.CreateTextFile(HtmlFileName)
			fout.WriteLine CreateHTMLReplace(htm)
			fout.close
			set fout = nothing
		end if
		rst.close
		set rst=nothing
	end if
		
	response.write "<script>alert(""操作成功！"");location.href=""admin_common.asp"";</script>"
	Response.end()
end if
rs1.close
set rs1=nothing
End sub
sub Del()
	id=trim(Request("id"))
	if id="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>参数不足！</li>"
		exit sub
	end if
	sql="select * from job_common where id In("& 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
%>
<!--#include file="../inc/copy.asp" -->