<!--#include file="admin_conn.asp"-->
<%
chkLogin
dim action : action = be("get","action")

select case action
	case else : headAdmin "用户组管理" :main
end select
dispseObj()

sub main
	Dim pagenum,arr1 : pagenum = be("all","page")
	if isN(pagenum) or not isNum(pagenum) then pagenum = 1
	if pagenum < 1 then pagenum = 1
	pagenum = clng(pagenum)
	Dim sql : sql = "SELECT ug_id,ug_name,ug_type,ug_popedom,ug_upgrade,ug_popvalue FROM {pre}user_group ORDER BY ug_popvalue DESC"
	Dim rs : Set rs = objdb.db(sql,"rs1")
%>
<script language="javascript">
$(document).ready(function(){
	$("#form2").validate({
		rules:{
			ug_name:{
				required:true,
				stringCheck:true,
				maxlength:32
			},
			ug_popvalue:{
				number:true
			},
			ug_upgrade:{
				number:true
			}
		}
	});
	$('#form1').form({
		onSubmit:function(){
			if(!$("#form1").valid()) {return false;}
		},
	    success:function(data){
	        $.messager.alert('系统提示', data, 'info',function(){
	        location.href=location.href;
	        });
	    }
	});
	$('#form2').form({
		onSubmit:function(){
			if(!$("#form2").valid()) {return false;}
		},
	    success:function(data){
	        $.messager.alert('系统提示', data, 'info');
	    }
	});
	$("#btnDel").click(function(){
			if(confirm('确定要删除吗')){
				$("#form1").attr("action","admin_ajax.asp?action=del&flag=batch&tab={pre}user_group");
				$("#form1").submit();
			}
			else{return false}
	});
	$("#btnAdd").click(function(){
		$('#form2').form('clear');
		$("#flag").val("add");
		$('#win1').window('open'); 
	});
	$("#btnCancel").click(function(){
		location.href= location.href;
	});
});
function edit(id)
{
	$('#form2').form('clear');
	$("#flag").val("edit");
	$('#win1').window('open');
	$.get('admin_ajax.asp?action=getinfo&tab={pre}user_group&col=ug_id&val='+id,function(obj){
		$("#ugid").val(obj.ug_id);
		$("#ug_name").val(obj.ug_name);
		$("#ug_popvalue").val(obj.ug_popvalue);
		$("#ug_upgrade").val(obj.ug_upgrade);
		$("input[name='ug_type']").each(function(i) {
			if(obj.ug_type.indexOf( "," + $(this).val() + "," ) !=-1 ){
				$(this).attr("checked", true);
			}
        });
        $("input[name='ug_popedom']").each(function(i) {
			if(obj.ug_popedom.indexOf( "," + $(this).val() + "," ) !=-1 ){
				$(this).attr("checked", true);
			}
        });
	},"json");
}
</script>
<form action="" method="post" id="form1" name="form1">
<table class="tb">
	<tr>
	<td width="4%">&nbsp;</td>
	<td>用户组名称</td>
	<td width="15%">组内人数</td>
	<td width="15%">购买所需积分</td>
	<td width="15%">权限值</td>
	<td width="15%">操作</td>
    </tr>
	<%
		if rs.eof then
	%>
    <tr><td align="center" colspan="7">没有任何记录!</td></tr>
    <%
		else
		Dim i,flag
		rs.PageSize = app_pagenum
	    rs.AbsolutePage = pagenum
	  	for i = 1 to rs.PageSize
	  	if rs.eof then exit for
	%>
	<td><%if app_reggroup <> rs("ug_id") then %>
	<input name="ug_id" type="checkbox" id="ug_id" value="<%=rs("ug_id")%>"/><%end if%></td>
	<td>
	<%=rs("ug_name")%>
	</td>
	<td>
	<%=objdb.DB("SELECT count(u_id) FROM {pre}user WHERE u_group="&rs("ug_id"),"exe")(0)%>
	</td>
	<td><%=rs("ug_upgrade")%></td>
	<td><%=rs("ug_popvalue")%></td>
	<td>
	<a href="javascript:void(0)" onclick="edit('<%=rs("ug_id")%>');return false;">修改</a> | <%if app_reggroup <> rs("ug_id") then %><a href="admin_ajax.asp?action=del&tab={pre}user_group&ug_id=<%=rs("ug_id")%>" onClick="return confirm('确定要删除吗?');">删除</a><%end if%></td>
    </tr>
	<%
	rs.MoveNext
	next
	end if
	%>
	<tr>
	<tr>
	<td colspan="7">全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'ug_id')" />
	&nbsp;<input type="button" id="btnDel" value="批量删除" class="input" />
	&nbsp;<input type="button" id="btnAdd" value="添加"  class="input"/>
	</td></tr>
	<tr align="center">
	<td colspan="7">
	<%=pagelist_manage(rs.PageCount,pagenum,rs.RecordCount,app_pagenum,"admin_user_group.asp?page={p}")%>
	</td>
	</tr>
</table>
</form>

<div id="win1" class="easyui-window" title="窗口" style="padding:5px;width:550px;" closed="true" closable="false" minimizable="false" maximizable="false">
<form action="admin_ajax.asp?action=save&tab={pre}user_group" method="post" name="form2" id="form2">
<table class="tb">
	<input id="ugid" name="ugid" type="hidden" value="">
	<input id="flag" name="flag" type="hidden" value="">
	<tr>
	<td width="30%">会员组名称：</td>
	<td><INPUT id="ug_name" size=20 value="" name="ug_name">
	</td>
	</tr>
	<tr>
	<td>包含分类：<br></td>
	<td>
	<%
	for i=0 to ubound(cachevodtype)
		arr1 = cachevodtype(i)
		if (i mod 4) =0 then writeA "<br>"
	%>
	<input type="checkbox" name="ug_type" value="<%=arr1(0)%>"/><%=arr1(1)%>
	<%
	next
	%>
	</td>
	</tr>
	<tr>
	<td>视频权限：<br></td>
	<td>
	<input type="checkbox" name="ug_popedom" value="1" checked/>浏览分类页
	<input type="checkbox" name="ug_popedom" value="2" checked/>浏览内容页
	<input type="checkbox" name="ug_popedom" value="3" checked/>浏览播放页
	<input type="checkbox" name="ug_popedom" value="4" checked/>浏览下载页
	</td>
    </tr>
	<tr>
	<td>升级所需积分：<br>(使用积分购买组权限)</td>
	<td>
	<INPUT id="ug_upgrade" size=20 value="0" name="ug_upgrade">
	</td>
    </tr>
	<tr>
	<td>权限值：<br>(数值越大权限越高)</td>
	<td>
	<INPUT id="ug_popvalue" size=20 value="0" name="ug_popvalue">
	</td>
	</tr>
	<tr align="center">
      <td colspan="2"><input class="input" type="submit" value="保存" id="btnSave"> <input class="input" type="button" value="返回" id="btnCancel"> </td>
    </tr>
</table>
</form>
</div>
</body>
</html>
<%
objdb.c(rs)
end sub
%>