<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../conn/conn.asp" -->
<!--#include file="../checkvalid.asp"-->
<!--#include file="../../inc/commoncode.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 Network All Rights Reserved.
' 版权所有 嘉挚科技 未经嘉挚公司授权不得用于任何商业用途
'
'#########################################################
If Not FRAdminLevel(402) Then
	Call ErrorMsg()
End If
Const strFileName="Admin_Template.asp"
const MaxPerpage=10
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
id=request.QueryString("id")
tid=request.QueryString("tid")
idt=request.QueryString("idt")
cid=request.QueryString("cid")
did=request.QueryString("did")
action=request.QueryString("action")

select case action
'更改模板为不默认
	case "no"
		if idt<>"" and Isnumeric(idt) then
			conn.execute("update JOB_Template set IsDefault="&FR_HR_False&" where TemplateID="&idt)
		else
			response.Redirect strFileName
		end if	
	
'更改模板为默认
	case "yes"
		if idt<>"" and Isnumeric(idt) then
			sql="select * from JOB_Template where TemplateID="&idt
			set rst=conn.execute(sql)
				ChannelID_t=rst("ChannelID")
				ProjectName_t=rst("ProjectName")
				typeid=rst("typeid")
				rst.close
				set rst=nothing
			conn.execute("update JOB_Template set IsDefault="&FR_HR_False&" where ChannelID="&ChannelID_t&" and ProjectName='"&ProjectName_t&"' and typeid="&typeid)
			conn.execute("update JOB_Template set IsDefault="&FR_HR_True&" where TemplateID="&idt)
		else
			response.Redirect strFileName
		end if
'复制模板
	case "copy"
		if cid<>"" and Isnumeric(cid) then
			sql="select * from JOB_Template where TemplateID="&cid
			set rsc=conn.execute(sql)
			if not rsc.eof then
				set rsf=server.CreateObject("adodb.recordset")
				sql="select * from JOB_Template"
				rsf.open sql,conn,1,3
				rsf.addnew
					rsf("ChannelID")=rsc("ChannelID")
					rsf("TemplateName")=rsc("TemplateName")&"副本"
					rsf("TemplateContent")=rsc("TemplateContent")
					rsf("IsDefault")=False
					rsf("ProjectName")=rsc("ProjectName")
					rsf("IsDefaultInProject")=rsc("IsDefaultInProject")
					rsf("Deleted")=rsc("Deleted")
					rsf("typeid")=rsc("typeid")
				rsf.update
				rsf.close
				set rsf=nothing
			end if
			rsc.close
			set rsc=nothing
		else
			response.Redirect strFileName
		end if	
'删除模板
	case "del"
		if did<>"" and Isnumeric(did) then
			conn.execute("delete from JOB_Template where TemplateID="&did)
		else
			response.Redirect strFileName
		end if
end select

if tid<>"" then
	if tid=0 then
		channelname="首页模板"
	elseif tid=9999 then
		channelname="通用页面"
	else
		channelname=ChannelNametitle(tid)
	end if
end if

if id="" then
	'读取默认的方案
	sqlt="select TemplateProjectID,TemplateProjectName from JOB_TemplateProject where IsDefault="&FR_HR_True&""
else
	sqlt="select TemplateProjectID,TemplateProjectName from JOB_TemplateProject where TemplateProjectID="&id&""
end if
set rst=Server.CreateObject(FR_HR_Rs)
rst.open sqlt,conn,1,1
if not rst.eof then
	ID=rst("TemplateProjectID")
	TemplateProjectName=rst("TemplateProjectName")
end if
rst.close
set rst=nothing
%>
<!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>
<title>网站模板管理</title>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th height="22" colspan="8" align="center" >模板管理</th>
  </tr>
  <tr>
    <td height="20" colspan="6"><span class="bodytitle"><font color="ff6600"><b class="style1">　管理选项</b></font>：</span><a href="Admin_AddTemp.asp">添加模板</a> | <a href="Admin_Template.asp?show=all">模板管理</a>&nbsp;&nbsp;[<a href="javascript:location.reload()">刷新页面</a>]</td>
  </tr>
  <tr>
    <td height="20" colspan="6">　<a href="Admin_Template.asp?tid=0&id=<%=id%>">首页模板</a>&nbsp;&nbsp;<%
			set rs=conn.execute("select * from JOB_Channel where Disabled="&FR_HR_False&" and ChannelType<>2 order by OrderID asc")
			if not rs.eof then
				do while not rs.eof
					response.write "<a href=Admin_Template.asp?tid="&rs("ChannelID")&"&id="&id&">"&rs("ChannelName")&"</a>&nbsp;&nbsp;"
				rs.movenext
				loop
			end if
			rs.close
			set rs=nothing
		%><a href="Admin_Template.asp?tid=9999&id=<%=id%>">通用页面</a>&nbsp;</td>
  </tr>
</table>

<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder mt6">
    <tr>
      <th height="22" colspan="12" align="center" ><%if tid="" then%><%=TemplateProjectName%><%else%><%=channelname%><%end if%></th>
    </tr>
	  <tr>
      <td width="46" height="20" align="center"><font color="ff6600"><b class="style1">模板ID</b></font></td>
      <td width="115" align="center"><font color="ff6600"><b class="style1">模板名称</b></font></td>
      <td width="86" align="center"><font color="ff6600"><b class="style1">所属频道</b></font></td>
      <td width="166" align="center"><font color="ff6600"><b class="style1">所属方案</b></font></td>
      <td width="67" align="center"><font color="ff6600"><b class="style1">是否默认</b></font></td>
      <td width="66" align="center"><font color="ff6600"><b class="style1">默认方案</b></font></td>
      <td width="123" align="center"><font color="ff6600"><b class="style1">模板类型</b></font></td>
      <td width="28" align="center"><font color="ff6600"><b class="style1">修改</b></font></td>
      <td width="30" align="center"><font color="ff6600"><b class="style1">删除</b></font></td>
      <td width="30" align="center"><font color="ff6600"><b class="style1">复制</b></font></td>
    </tr>
		<%
		set rs=server.CreateObject(FR_HR_RS)
		if tid="" then
			sql="select * from JOB_Template where ProjectName='"&TemplateProjectName&"' order by ProjectName,ChannelID,typeid"
		else
			sql="select * from JOB_Template where ChannelID="&tid&" and ProjectName='"&TemplateProjectName&"' order by ProjectName,ChannelID,typeid"
		end if
		rs.open sql,conn,1,1
		if not rs.eof then
		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)*MaxPerpage<totalPut then
			rs.move  (page-1)*MaxPerpage
		else
			page=1
		end if
		do while not rs.eof
	%>
    <tr onMouseOver="this.style.background='#FFFFCC'" onMouseOut="this.style.background='#EEF7FD'">
      <td width="46" height="20" align="center"><%=rs("TemplateID")%></td>
      <td width="115" align="center"><%=rs("TemplateName")%></td>
      <td width="86" align="center">
	  <%if rs("ChannelID")=0 then
	  	response.write "网站首页"
	  elseif rs("ChannelID")=9999 then
	  	response.write "通用频道"
	  else
	  	response.write ChannelNametitle(rs("ChannelID"))
	  end if
	  %></td>
      <td width="166" align="center"><%=rs("ProjectName")%></td>
      <td width="67" align="center">
	  	<%
		if rs("IsDefault") then
		response.write "<font color=green><a href="&strFileName&"?action=no&idt="&rs("TemplateID")&"&tid="&tid&">√</a></font>"
		else
		response.write "<font color=red><font color=green><a href="&strFileName&"?action=yes&idt="&rs("TemplateID")&"&tid="&tid&">×</a></font>"
		end if
		%></td>
      <td width="66" align="center"><%
			if rs("IsDefaultInProject") then
				response.write "<font color=green>√</font>"
			else
				response.write "<font color=red>×</font>"
			end if
		%></td>
      <td width="123" align="center"><%=myarray(rs("typeid"))%></td>
      <td width="28" align="center"><a href="Admin_AddTemp.asp?action=edit&id=<%=rs("TemplateID")%>">修改</a></td>
      <td width="30" align="center"><%if rs("IsDefault") then%>
<font color="#999999">删除</font>
<%else%><a href="<%=strFileName%>?action=del&did=<%=rs("TemplateID")%>&id=<%=id%>&tid=<%=tid%>">删除</a><%end if%></td>
      <td width="30" align="center"><a href="<%=strFileName%>?action=copy&cid=<%=rs("TemplateID")%>&id=<%=id%>&tid=<%=tid%>">复制</a></td>
    </tr>
	<%
		i=i+1
		if i>=MaxPerPage then exit do
		rs.movenext
		loop
		else
		%>
		<tr>
 			<td height="22" colspan="12" align="center" >暂无模板</td>
		</tr>
	<%		
	end if
	rs.close
	set rs=nothing
	If totalput>0 Then
	%>
	<tr>
	  <td height="22" colspan="12" align="center" ><%Call Showpage(strFileName&"?id="&id&"&tid="&tid,totalput,MaxPerPage,false,true,"套模板")%></td>
	</tr>
 	<%End If%>
</table>
<!--#include file="../inc/copy.asp" -->
</body>
</html>