<?php 
//****************************************请求权限****************************************
require("locked.php");                                                                 //*
setlocked(-1);                                                                         //*
//****************************************************************************************
?>
<html>
<head>
<meta charset="utf-8">
<title>权限设置</title>
<link rel="stylesheet" href="myCss.css" type="text/css" />
<script language="javascript" type="text/javascript" src="myJs.js"></script>
</head>

<body>
<?php
include("cnn.php");
$_SESSION[Uid]=$mysqli->real_escape_string($_GET[keyword]);//设置全局会话，用于操作权限表时使用，该变量用于userRightSubmit.php文件中；
$sql=$mysqli->query('select * from power where Uid="'.$_SESSION[Uid].'" order by Rid');
$info=$sql->fetch_array(MYSQLI_BOTH);
?>
<form action="userRightSubmit.php" method="post" name="form1">
<table id="mytable1">
<tr>
<td align="center" width="80px">用户ID</td>
<td align="center" width="80px">权限ID</td>
<td align="center" width="110px">权限名称</td>
<td align="center" width="80px">权限值</td>
</tr>
<?php
if($info){ //如果存在数据；
do{
?>
<tr>
<td align="center" width="100px"><?php echo $info['Uid']; ?></td>
<td align="center" width="100px"><?php echo $info['Rid']; ?></td>
<td align="center" width="150px"><?php echo $info['Rname']; ?></td>
<td align="center" width="100px"><input name="Rvalue[]" type="checkbox" <?php if($info['Rvalue']==-1){ echo 'checked="checked"'; } ?> value="<?php echo $info['Uid'].','.$info['Rid']; ?>" /></td>
</tr>
<?php
}while($info=$sql->fetch_array(MYSQLI_BOTH));
?>
<tr>
<td colspan="4" align="center">
<input name="checkAll1" type="button" onClick="checkAll()" value="全选" />
<input name="uncheckAll1" type="button" onClick="uncheckAll()" value="全不选" />
<input name="insert" type="submit" value="提交" />
</td>
</tr>
</table>
</form>
<?php
}else{
?>
	<tr>
    <td colspan="4" align="left">
    工号[1001]为管理员账号，只拥有“用户管理”功能！
    </td>
    </tr>
    </table>
    </form>
<?php
}
$sql->free();
$mysqli->close();
?>
<script language="javascript" type="text/javascript">
<!--
mytable("mytable1");

var $=document.getElementsByName("Rvalue[]");

function checkAll(){
	for(var i=0;i<$.length;i++){
		//if($[i].type=='checkbox'){
			$[i].checked=true;
		//}
	}
}

function uncheckAll(){
	for(var i=0;i<$.length;i++){
		//if($[i].type=='checkbox'){
			$[i].checked=false;
		//}
	}
}
//-->
</script>
</body>
</html>