<!--#include file="check.asp"-->
<%
Call hrPower(8.1,0)

act = Request("act")
id = Request("id")
pname = Request("name")

Dim powers
powers=array(_
"1.1|商户管理",_
"2.1|订单管理,2.2|成功订单,2.3|提交订单,2.4|发送订单",_
"3.1|结算管理,3.2|财务结算,3.3|商户支付,3.4|支付记录",_
"4.1|服务管理,4.2|分组列表,4.3|服务列表,4.4|分区统计,4.5|商户排行 ",_
"5.1|新闻管理",_
"6.1|奖品管理",_
"7.1|代理管理,7.2|代理结算,7.3|代理支付",_
"8.1|管 理 员,8.2|管 理 员,8.3|日志记录,8.4|结算支付统计",_
"9.1|通道管理"_
)
%>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><title>
	 权限管理
</title><link href="images/style.css" type="text/css" rel="stylesheet" />


</head>
<body style="margin: 0px;">
    <table border="0" width="100%">
        <tr class="pagehead">
            <td>
                &nbsp;&nbsp;<b>您现在所在位置：</b>
                <span id="lblNav"> 权限管理</span>
            </td>
            <td>
                <b></b>
            </td>
        </tr>
        <tr>
            <td colspan="3" style="padding: 6px">
                    <table cellspacing="0" cellpadding="0" width="100%" border="0">
                        <tr>
                            <td align="left" colspan="2" height="34" style="height: 28px; background-color: aliceblue"
                                valign="middle">
                                &nbsp; <strong>
                                    <span style="color:orange"><%=pname%></span>的权限设置中心
                                </strong>
                            </td>
                        </tr>



<script>
function savepurview(){
	var obj=document.form1;
	var name=obj.name.value;
	if(confirm("确定保存【"+name+"】的权限吗？")){
		var val=getSeleElementValue();
		document.form3.did.value=val;
		document.form3.submit();
	}
}
function CheckAll(obj){
	for (var i=0;i<obj.elements.length;i++)
	{
		var e=obj.elements[i];
		if (e.name != 'allbox')
		e.checked=obj.seleall.checked;//seleall为全选的name
	}
}
function getSeleElementValue(){
	var rvalue="";
	var e=document.form1;
	var l=e.elements.length;
	for (var i=0;i<l;i++){
		if (e.elements[i].name=="did" && e.elements[i].checked){
			rvalue+=e.elements[i].value+",";
		}
	}
	return(rvalue);
}
</script>
</head>

<body>
<%
Select Case act
	Case "purview"
		Call userpurviewsetting()
	Case "save"
		Call userpurviewsave()
	Case Else
		Call ReturnError("拒绝访问！")
End Select

Sub userpurviewsave()
	id = Request.Form("id")
	did = Replace(Request.Form("did")," ","")
	did = ","&did&","
	conn.execute("update H_admin set limit='"&did&"' where adminid="&id)

	'//修改记录信息//////////////////////////////////////////////////////////////////////////////////////
	log_Txt=""
	log_Txt=log_Txt&"管理员ID："&id&" 权限修改;"
	'//END修改记录信息////////////////////////////////////////////////////////////////////////////////////
	
	
	Call WriteLog(""&log_Txt&"",2)

	Call Succeed("保存成功！")
	'Call Succeed(did)
End Sub

Sub userpurviewsetting()
	set rs=conn.execute("select limit from H_admin where adminid="&id&" ")
	if rs.eof then
		rs.close
		Call ReturnError("参数错误！")
	end if
	powerString = rs(0)

%>
<style>
.tdli li{width:100px;padding-left:3px;float:left;line-height:110%;list-style:none;}
</style>
<form name="form1" method="post" action="purview.asp" onSubmit="return false;">

<%
For p=0 To Ubound(powers)
	If Instr(powers(p),",")>0 Then
		str_name = Split(Split(powers(p),",")(0),"|")(1)
		str_sid = Split(Split(powers(p),",")(0),"|")(0)
		more=True
	Else
		str_name = Split(powers(p),"|")(1)
		str_sid = Split(powers(p),"|")(0)
		more=False
	End If
	If Instr(powerString,","&str_sid&",")>0 Then
		checked = "checked"
	Else
		checked = ""
	End If
%>


                        <tr>
                            <td align="right" height="34" style="width: 180px; height: 28px" valign="middle"
                                class="leftTD dotted">
                                <input type="checkbox" name="did" value="<%=str_sid%>" <%=checked%> /><%=str_name%>
                            </td>
                            <td height="34" valign="middle" width="*" class="dotted">
                                <table id="CBLIndex" cellpadding="10" border="0">
	<tr>





	<%
	If more=True Then
	%>

		<%
			If Instr(powers(p),",")>0 Then
				ops = Split(powers(p),",")
				For o=1 To Ubound(ops)
					str_name = Split(ops(o),"|")(1)
					str_sid = Split(ops(o),"|")(0)
				
					If Instr(powerString,","&str_sid&",")>0 Then
						checked = "checked"
					Else
						checked = ""
					End If
					widthbig=""
					If Len(str_name)>5 Then widthbig=" style='width:150px;'"
		%>

<td><input id="CBLIndex_1" type="checkbox" name="did" value="<%=str_sid%>" <%=checked%> /><label for="CBLIndex_1"><%=str_name%></label></td>

			
		<%
				Next
			End If
		%>
	</tr>

	<%
	End If
	%>
</table></td>
                        </tr>
	
<%
Next
%>
                        <tr>
                            <td>
                            </td>
                            <td height="34" valign="middle">

<input title='全选' onClick="CheckAll(document.form1);" type="checkbox" name='seleall' />全选&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
			<button type="button" class="button-sub floatleft" onClick="savepurview();">确定</button>
</td>
                        </tr>
                    </table>
<input type="hidden" name="id" value="<%=id%>" />
<input type="hidden" name="name" value="<%=pname%>" />
</form>

<form name="form3" method="post" action="purview.asp">
<input type="hidden" name="did" value="0" />
<input type="hidden" name="act" value="save" />
<input type="hidden" name="id" value="<%=id%>" />
<input type="hidden" name="name" value="<%=pname%>" />
</form>
	<%		
End Sub
%>
</body>
</html>
<%
If IsObject(conn) Then
	conn.Close
	Set conn = Nothing
End If
%>