<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../../conn/conn.asp" -->
<!--#include file="../checkvalid.asp"-->
<!--#include file="../../Inc/Commoncode.asp" -->
<%If Not FRAdminLevel(403) Then
	Call ErrorMsg()
End If
'#########################################################
'
' 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.
' 版权所有 嘉挚科技 未经嘉挚公司授权不得用于任何商业用途
'
'#########################################################
SkinID=request.QueryString("id")
action=request.QueryString("action")
skinname=CheckStr(request.form("skinname"))
tempfa=CheckStr(request.form("tempfa"))
filename=CheckStr(request.form("filename"))
if InStr(filename,";")>0 then
Response.Write "<Script Language=javascript>alert('样式表文件名称错误！');history.back(-1)</Script>"  
Response.end
end if
Application("filename")=filename
imgpath=CheckStr(request.form("imgpath"))
content=request.form("content")
de=request.form("de")
if skinname<>"" and tempfa<>"0" and content<>"" then
	if action<>"edit" then
'*********************这是添加的**************************
		if de then
			set rsc=server.CreateObject("adodb.recordset")
			sql="select * from JOB_Skin where ProjectName='"&tempfa&"'"
			rsc.open sql,conn,1,3
			if not rsc.eof then
			do while not rsc.eof
				rsc("IsDefault")=False
			rsc.movenext
			loop
			end if
			rsc.close
			set rsc=nothing
		end if
'*********************查看方案是否默认*****************************
		set rsp=server.CreateObject("adodb.recordset")
		sql="select * from JOB_TemplateProject where TemplateProjectName='"&tempfa&"'"
		rsp.open sql,conn,1,1
			IsDefaultInProject=rsp("IsDefault")
		rsp.close
		set rsp=nothing
'**************************************************
		set rs=server.CreateObject ("adodb.recordset")
		sql="select * from JOB_Skin"
		rs.open sql,conn,1,3
		rs.addnew
		rs("SkinName")=SkinName
		rs("Skin_CSS")=server.HTMLEncode(content)
		rs("IsDefault")=de
		rs("ProjectName")=tempfa
		rs("IsDefaultInProject")=IsDefaultInProject
		rs("filename")=filename
		rs("imgpath")=imgpath
		rs.update
		rs.close
		set rs=nothing
	else
'*********************这是修改的**************************
		if de then
			set rsc=server.CreateObject("adodb.recordset")
			sql="select * from JOB_Skin where ProjectName='"&tempfa&"'"
			rsc.open sql,conn,1,3
			if not rsc.eof then
			do while not rsc.eof
				rsc("IsDefault")=False
			rsc.movenext
			loop
			end if
			rsc.close
			set rsc=nothing
		end if
		set rs=server.CreateObject ("adodb.recordset")
		sql="select * from JOB_Skin where SkinID="&SkinID
		rs.open sql,conn,1,3
		rs("SkinName")=SkinName
		rs("Skin_CSS")=server.HTMLEncode(content)
		rs("IsDefault")=de
		rs("ProjectName")=tempfa
		rs("filename")=filename
		rs("imgpath")=imgpath
		
		rs.update
		rs.close
		set rs=nothing
	end if
createcssfile()
response.write "<script language=javascript>alert('操作成功');location.href='Admin_Skin.asp?show=all';</script>"
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><title>模板管理</title>
<script language="javascript" src="../Inc/Admin.js"></script><script language="javascript">
function check(){
	if(form1.skinname.value=="")
	{
		alert("对不起样式名称不能为空！");
		return false;
	}
	if(form1.tempfa.value==0)
	{
		alert("对不起请选择样式方案！");
		return false;
	}
	if(form1.imgpath.value==0)
	{
		alert("对不起请输入图片包地址！");
		return false;
	}
	if(form1.content.value=="")
	{
		alert("对不起样式内容不能为空！");
		return false;
	}

	return true;
}

</script></head>
<body>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th height="22" align="center" >风格样式管理</th>
  </tr>
  <tr>
    <td height="20"><span class="bodytitle"><font color="ff6600"><b class="style1">　管理选项</b></font>：</span><a href="Admin_Addskin.asp">添加CSS</a> | <a href="Admin_Skin.asp?show=all">样式管理</a>&nbsp;&nbsp;[<a href="javascript:location.reload()">刷新页面</a>]</td>
  </tr>
</table>
<%
	if action="edit" and SkinID<>"" then
	set rs1=server.CreateObject("adodb.recordset")
	sql="select * from JOB_Skin where SkinID="&SkinID
	rs1.open sql,conn,1,1
	SkinName=rs1("SkinName")
	ProjectName=rs1("ProjectName")
	Skin_CSS=rs1("Skin_CSS")
	IsDefault=rs1("IsDefault")
	filename=rs1("filename")
	imgpath=rs1("imgpath")
	rs1.close
	set rs1=nothing
	end if
%>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder mt6">
  <form id="form1" name="form1" method="post" action="" onSubmit="return check();">
    <tr>
      <th height="22" colspan="4" align="center" >添加CSS </th>
    </tr>
    <tr>
      <td width="120" height="20" align="right">名称： </td>
      <td width="825" height="20"><input name="skinname" type="text" id="skinname" value="<%=SkinName%>" /></td>
    </tr>
    <tr>
      <td height="20" align="right">对应方案：</td>
      <td height="20"><select name="tempfa" id="tempfa">
        <option value="0">请选择方案</option>
        <%
				Set rs= Server.CreateObject(FR_HR_RS)
				sql="select * from JOB_TemplateProject order by TemplateProjectID desc"
				rs.open sql,conn,1,1
				do while not rs.eof
				if  ProjectName = rs("TemplateProjectName") then
					response.write "<option value="&rs("TemplateProjectName")&" selected>"&rs("TemplateProjectName")&"</option>"
				else
					response.write "<option value="&rs("TemplateProjectName")&">"&rs("TemplateProjectName")&"</option>"
				end if
				rs.movenext
				loop
				rs.close
				set rs=nothing

		  %>
      </select></td>
    </tr>
    <tr>
      <td height="20" align="right">生成文件：</td>
      <td height="20"><input name="filename" type="text" id="filename" value="<%=filename%>" size="10">.css
      说明:生成文件必须支持写文件到服务器,如不支持请清空</td>
    </tr>
    <tr>
      <td height="20" align="right">图片包路径：</td>
      <td height="20"><input name="imgpath" type="text" id="imgpath" value="<%=imgpath%>">
      说明:图片包路径最后必须包含"/"</td>
    </tr>
    <tr>
      <td height="20" align="right">内容：</td>
      <td height="20"><textarea name="content" rows="24" id="t1" style="width:100%;"><%=Skin_CSS%></textarea></td>
    </tr>
    <tr>
      <td height="20" align="right">是否默认：</td>
      <td height="20"><%
	  	if IsDefault=True then
	  %>
        <input name="de" type="radio" class="checkbox" value="True" checked="checked" />
		<% else %>
		        <input name="de" type="radio" class="checkbox" value="True" />
		<% end if %>
      是 　
      <%
	  	if IsDefault=False then
	  %>

      <input name="de" type="radio" class="checkbox" value="False" checked="checked" />
		<% else %>
      <input name="de" type="radio" class="checkbox" value="False" />
		<% end if %>
	   否</td>
    </tr>
    <tr>
      <td height="20" colspan="2" align="center">
        <input name="Submit" type="submit" class="inputs" value="<%
		if action="edit" then
		response.write "修改"
		else
		response.write "提交"
		end if
 %>" />
        &nbsp;
        <input name="Submit2" type="reset" class="inputs" value="重置" />
      </td>
    </tr>
  </form>
</table>
<!--#include file="../inc/copy.asp" -->
</body>
</html>
<%
Sub createcssfile()
	On error resume Next
	Dim Fso,filename,Skin_CSS
	Set FSO=Server.CreateObject(FR_HR_fso)
	If  Err Then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>您的服务器不支持写文件,CSS文件写入失败！</li>"
		Exit Sub
	end If
	filename=Application("filename")
	Skin_CSS=content
	Fso.CreateTextFile(Server.MapPath("../../css/"& filename &".css")).WriteLine(Skin_CSS)
	If  Err Then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>您的服务器不支持写文件,CSS文件写入失败！</li>"
		Exit Sub
	End If
	Set FSO=Nothing  
End Sub
%>