<!--#include file="../fy.Function.asp"-->
<!--#include file="../../fy_inc/cls_pageview.asp"-->
<% If Not fycms.ChkAdmin() Then  Call fycms.Alert("对不起，您没有操作权限！","")
 %><!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>会员空间模版</title>
<link rel="stylesheet" type="text/css" href="../css/base.css">
<link rel="stylesheet" type="text/css" href="../css/content.css">
</head>
<body>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 空间模板文件夹管理</div>
    <div class="opers">
    	<a href="?A=Add" class="btn<%If Request("A")="Add" Then echo " btn_primary" %>">添加模板文件夹</a>
    </div>
   
	 <% 
  	Dim templets,UserSet,A,Action,rs,RsSql,ID
	Action = Request("A")
	ID=ChkNumeric(Request("ID"))
	If Not fycms.ChkAdmin() Then   Call fycms.Alert("对不起，你没有操作权限！","")
 	Select Case Action
			Case "Edit","Add"
				Call Main()
				Call AddEdit()
			Case "AddSave"
				Call AddSave
			Case "ESave"
				Call ESave
			Case "del"
				Call Del()
 			Case Else
				Call Main()
	End Select
	
	IF Action = "Del" Then
		If ID="1" Then  Call fycms.ActErr("该模板文件夹禁止删除","user/fy.temp.asp",""):response.end
		fycms.ACTEXE("Delete From templets_fy Where ID=" & ID)		
		Call fycms.ActErr("删除模板文件夹成功","user/fy.temp.asp","")
 	End IF
	
	
	sub AddSave()
		 templets = fycms.S("templets")
		 UserSet = fycms.S("UserSet")
 		 IF fycms.S("templets") = "" Then
		 	Call fycms.Alert("模板文件夹名称不能为空!",""):Exit Sub
		 End if
  		 Set Rs = Server.CreateObject("adodb.recordset")
		  RsSql = "select * from templets_fy"
		  Rs.Open RsSql, Conn, 1, 3
		  Rs.AddNew
		  Rs("templets") = templets
		  Rs("UserSet") = UserSet
  		  Rs.Update
		 Call fycms.ActErr("操作成功","User/fy.temp.asp","")
	end sub 
	sub ESave()
		 templets = fycms.S("templets")
		 UserSet = fycms.S("UserSet")
 		 IF fycms.S("templets") = "" Then
		 	Call fycms.Alert("模板文件夹名称不能为空!",""):Exit Sub
		 End if
 		 Set Rs = Server.CreateObject("adodb.recordset")
		  RsSql = "select * from templets_fy where id="&ID
		  Rs.Open RsSql, Conn, 1, 3
		  if not rs.eof then 
			  Rs("templets") = templets
			  Rs("UserSet") = UserSet
 			  Rs.Update
		  end if 
		 Call fycms.ActErr("操作成功","User/fy.temp.asp","")
	end sub 
	sub main()
	Dim strLocalUrl,pages
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
 	Dim intPageNow
	intPageNow = request.QueryString("page")
 	Dim intPageSize, strPageInfo
	intPageSize = 30
 	Dim arrinfo, i,GroupSettingSet
	Dim sql, sqlCount
	sql = "SELECT [ID], [templets],[UserSet]" & _
		" FROM [templets_fy]" & _
		"ORDER BY [ID] ASC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [templets_fy]"

		Dim clsRecordInfo
		Set clsRecordInfo = New Cls_PageView
			clsRecordInfo.intRecordCount = 2816
			clsRecordInfo.strSqlCount = sqlCount
			clsRecordInfo.strSql = sql
			clsRecordInfo.intPageSize = intPageSize
			clsRecordInfo.intPageNow = intPageNow
			clsRecordInfo.strPageUrl = strLocalUrl
			clsRecordInfo.strPageVar = pages
		clsRecordInfo.objConn = Conn		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
 %>
	
	
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
 
      <tr>
      <th>ID</th>
	  <th>模板文件夹名称</th>
	  <th>模板文件夹属性</th>
	  <th>管理操作</th>
	  </tr>
    </thead>
	 <%
 		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
 	%>
    <tr >
      <td align="center"><%=arrinfo(0,i)%></td>
	  <td align="center"><%=arrinfo(1,i)%></td>
      <td align="center"><%=arrinfo(2,i)%></td>
      <td  align="center"><a href="?A=Edit&ID=<%=arrinfo(0,i)%>">修改</a>┆
	 <a href="?A=Del&ID=<%=arrinfo(0,i)%>" onClick="return confirm('确认删除此模板文件夹吗?')">删除</a></td>
    </tr>
	
  	<% 
	Next
	End If
	%>

	</table>
    <div class="pagelist">
    	<%= strPageInfo%>
   </div>
<% end sub %>

<% Sub AddEdit() 
	if Action="Add" Then
		A="AddSave"
 	Else
		Set Rs=server.CreateObject("adodb.recordset") 
		Rs.OPen "Select * from templets_fy Where ID = "&ID,Conn,1,1
		templets = Rs("templets")
		UserSet = Rs("UserSet")
  		A="ESave"
	end if

%>



    <form name="form1" method="post"  action="?A=<%= A %>">
    <div class="divtable"> 
        <dl>
            <dt>模板文件夹名称</dt>
            <dd>
                <input name="templets" type="text" class="Ainput" id="templets" value="<%=templets  %>" size="50">    
            </dd>
         </dl>
        
        <dl>
            <dt>可选择此模板的会员组 (不选为不限制会员组)</dt>
            <dd>
               <%= fycms.GetGroup_CheckBox("UserSet",UserSet,5)  %>
             </dd>
         </dl>
 
            <dl>
            <dt class="vhid">提交：</dt>
            <dd><input name="ID" type="hidden" id="ID" value="<%= ID %>">
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
				<input name="Submit2" type="reset" class="btn" value="  重置  ">
            </dd>
         </dl>
        
    </div>
    </form>

<script language="JavaScript" type="text/javascript">
 
function CheckForm()
{ var form=document.form1;
	 if (form.templets.value=='')
		{ alert("请输入模板文件夹名称!");   
		  form.templets.focus();    
		   return false;
		} 
	    form.submit();
        return true;
	}
</script>

<% end sub  %>

</div>
</body>
</html>
