<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
	<!-- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	| 房佳（专业的新房分销ERP管理系统）
	+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	| Copyright (c) 2008-2019 http://fj.ytsofts.cn/ All rights reserved.
	+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	| 本系统由淮南市银泰软件科技有限公司提供技术支持
	+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	| QQ号：984784483
	+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
		<meta http-equiv="Cache-Control" content="no-siteapp"/>
		<link rel="Bookmark" href="/Public/favicon.ico">
		<link rel="Shortcut Icon" href="/Public/favicon.ico"/>
		<link rel="stylesheet" type="text/css" href="/Public/static/h-ui/css/H-ui.min.css" />
		<link rel="stylesheet" type="text/css" href="/Public/static/h-ui.admin/css/H-ui.admin.css"/>
		<link rel="stylesheet" type="text/css" href="/Public/lib/Hui-iconfont/1.0.8/iconfont.css"/>
		<link rel="stylesheet" type="text/css" href="/Public/static/h-ui.admin/css/style.css"/>
		
	<link rel="stylesheet" type="text/css" href="/Public/lib/layui/css/layui.css">
	<style type="text/css">
		.red {
			color: red;
		}
		.red input {
			color: red;
		}
		.tbgd{
			position: fixed;
			background: #fff;
			margin-top: -40px;
			width: 100%;
			z-index: 999;
		}
	</style>

	</head>
	<body>
		
	<div style="position:fixed;top:0;width: 100%; border-top-style: solid;border-top-width: 2px;border-top-color: #009688;z-index: 999;"></div>
	<form class="layui-form" action="/admin/rbac/access2" method="post">
		<input type="hidden" name="rid" value="<?php echo ($rid); ?>" id=""/>
		<div class="layui-tab">
			<ul class="layui-tab-title tbgd">
				<?php if(is_array($categorys)): $i = 0; $__LIST__ = $categorys;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li <?php if(($i) == "1"): ?>class="layui-this"<?php endif; ?>>
						<?php echo ($vo["name"]); ?>
					</li><?php endforeach; endif; else: echo "" ;endif; ?>
			</ul>
			<div class="layui-tab-content" style="margin-top: 40px;">
				<?php if(is_array($categorys)): $i = 0; $__LIST__ = $categorys;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><div class="layui-tab-item <?php if(($i) == "1"): ?>layui-show<?php endif; ?>">
						<table class="table table-border table-bordered table-hover table-bg">
							<?php if($vo['is_sign']): ?><!-- <判断循环状态> -->
								<?php if($vo['is_sign'] == 1): $zhuangtai = $fyzhuangtai; ?>
									<?php else: ?>
									<?php $zhuangtai = $kyzhuangtai; endif; ?>
								<!-- </判断循环状态> -->
								<tr class="text-c">
									<th></th>
									<th>不限</th>
									<?php if(is_array($zhuangtai)): foreach($zhuangtai as $key=>$so): ?><th><?php echo ($so["lxming"]); ?></th><?php endforeach; endif; ?>
								</tr>
								<?php if(is_array($vo['child'])): $i = 0; $__LIST__ = $vo['child'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$m): $mod = ($i % 2 );++$i;?><tr class="text-c">
										<th><?php echo ($m['name']); ?></th> 
										<?php if(($m['type'] == 1) or ($m['type'] == 2)): ?><td>
												<?php switch($m['type']): case "1": ?><input type="checkbox" name="access[<?php echo ($m['node_id']); ?>]" value="<?php echo ($m['node_id']); ?>_0_0" <?php echo _is_have_node($m['config'],$rid,0,0,1);?>><?php break;?>
													<?php case "2": ?><div style="width: 120px;display:inline-block;" class="red">
															<select name="access[<?php echo ($m['node_id']); ?>]">
																<option value="">禁止</option>
																<option value="<?php echo ($m['node_id']); ?>_0_0" <?php echo _is_have_node($m['config'],$rid,0,0,2);?>>所有</option>
																<?php if(is_array($bumen_arr_level)): foreach($bumen_arr_level as $key=>$so): ?><option value="<?php echo ($m['node_id']); ?>_<?php echo ($key+1); ?>_0" <?php echo _is_have_node($m['config'],$rid,$key+1,0,2);?>>本<?php echo ($so); ?></option><?php endforeach; endif; ?>
																<option value="<?php echo ($m['node_id']); ?>_<?php echo count($bumen_arr_level)+1;?>_0" <?php echo _is_have_node($m['config'],$rid,count($bumen_arr_level)+1,0,2);?>>本人</option>
															</select>
														</div><?php break; endswitch;?>
											</td>
											<?php if(is_array($zhuangtai)): foreach($zhuangtai as $key=>$so): ?><td>--</td><?php endforeach; endif; endif; ?>
										<?php if($m['type'] == 3): ?><td>--</td>
											<?php if(is_array($zhuangtai)): foreach($zhuangtai as $key=>$zso): ?><td>
													<div style="width: 120px;display:inline-block;" class="red">
														<select name="access[<?php echo ($m['node_id']); ?>-<?php echo ($zso['lxid']); ?>]">
															<option value="">禁止</option>
															<option value="<?php echo ($m['node_id']); ?>_0_<?php echo ($zso['lxid']); ?>" <?php echo _is_have_node($m['config'],$rid,0,$zso['lxid'],2);?>>所有</option>
															<?php if(is_array($bumen_arr_level)): foreach($bumen_arr_level as $key=>$so): ?><option value="<?php echo ($m['node_id']); ?>_<?php echo ($key+1); ?>_<?php echo ($zso['lxid']); ?>" <?php echo _is_have_node($m['config'],$rid,$key+1,$zso['lxid'],2);?>>本<?php echo ($so); ?></option><?php endforeach; endif; ?>
															<option value="<?php echo ($m['node_id']); ?>_<?php echo count($bumen_arr_level)+1;?>_<?php echo ($zso['lxid']); ?>" <?php echo _is_have_node($m['config'],$rid,count($bumen_arr_level)+1,$zso['lxid'],2);?>>本人</option>
														</select>
													</div>
												</td><?php endforeach; endif; endif; ?>
									</tr><?php endforeach; endif; else: echo "" ;endif; ?>
								<?php else: ?>
								<?php if(is_array($vo['child'])): $i = 0; $__LIST__ = $vo['child'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$m): $mod = ($i % 2 );++$i;?><tr class="text-c">
										<th><?php echo ($m['name']); ?></th>
										<?php if(is_array($m['child'])): $i = 0; $__LIST__ = $m['child'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$s): $mod = ($i % 2 );++$i;?><td>
												<?php switch($s['type']): case "1": ?><input type="checkbox" name="access[<?php echo ($s['node_id']); ?>]" title="<?php echo ($s['name']); ?>" value="<?php echo ($s['node_id']); ?>_0_0" <?php echo _is_have_node($s['config'],$rid,0,0,1);?>><?php break;?>
													<?php case "2": echo ($s['name']); ?>
														<div style="width: 120px;display:inline-block;" class="red">
															<select name="access[<?php echo ($s['node_id']); ?>]">
																<option value="">禁止</option>
																<option value="<?php echo ($s['node_id']); ?>_0_0" <?php echo _is_have_node($s['config'],$rid,0,0,2);?>>所有</option>
																<?php if(is_array($bumen_arr_level)): foreach($bumen_arr_level as $key=>$so): ?><option value="<?php echo ($s['node_id']); ?>_<?php echo ($key+1); ?>_0" <?php echo _is_have_node($s['config'],$rid,$key+1,0,2);?>>本<?php echo ($so); ?></option><?php endforeach; endif; ?>
																<option value="<?php echo ($s['node_id']); ?>_<?php echo count($bumen_arr_level)+1;?>_0" <?php echo _is_have_node($s['config'],$rid,count($bumen_arr_level)+1,0,2);?>>本人</option>
															</select>
														</div><?php break; endswitch;?>
											</td><?php endforeach; endif; else: echo "" ;endif; ?>
									</tr><?php endforeach; endif; else: echo "" ;endif; endif; ?>
						</table>
					</div><?php endforeach; endif; else: echo "" ;endif; ?>
			</div>
			<div style="line-height:50PX;">&nbsp;</div>
			<div class="layui-form-item" style="width:100%;height:50px;margin:0 auto;background:#fff;position:fixed;bottom:0;text-align:center;border-top-style: solid;border-top-width: 1px;border-top-color: #009688;padding-top: 5px;">
				<div class="layui-form-item" style="margin-left: -15px;">
					<button class="layui-btn layui-btn-radius" lay-submit="" lay-filter="demo1">
						<i class="Hui-iconfont">&#xe603;</i> 立即提交
					</button>
					<button type="reset" class="layui-btn layui-btn-radius layui-btn-primary">
						<i class="Hui-iconfont">&#xe72a;</i> 重置
					</button>
					<button type="button" class="layui-btn layui-btn-radius layui-btn-primary" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name));">
						<i class="Hui-iconfont">&#xe706;</i> 关闭
					</button>
				</div>
			</div>
		</div>
	</form>

		<script type="text/javascript" src="/Public/lib/jquery/1.9.1/jquery.min.js"></script> 
		<script type="text/javascript" src="/Public/lib/layer/2.4/layer.js"></script>
		<script type="text/javascript" src="/Public/static/h-ui/js/H-ui.min.js"></script>
		<script type="text/javascript" src="/Public/static/h-ui.admin/js/H-ui.admin.js"></script>
		<script>
			$(document).ready(function(){
				$(document).bind("contextmenu",function(e){
					return false;
				});
			});
		</script>
		
	<script src="/Public/lib/layui1/layui.js" charset="utf-8"></script>
	<script>
		layui.use(['element','form', 'layedit', 'laydate'], function(){
			var element = layui.element
			,form = layui.form
			,layer = layui.layer
			,layedit = layui.layedit
			,laydate = layui.laydate;
			//监听提交
			form.on('submit(demo1)', function(data){
				var access = JSON.stringify(data.field);
				$.ajax({
					url:'<?php echo U('Rbac/access');?>',
					type:"post",
					data:{access:access},
					dataType:"json",
					success:function(data){
						if (data.status==1) {
							var index = parent.layer.getFrameIndex(window.name);//获取窗口索引
							parent.layer.msg(data.info);//父级页面提示成功信息
							parent.layer.close(index);//关闭弹出的子页面窗口
						}else{
							layer.msg(data.info,{anim: 6});//错误提示
						}
					},
				});
				return false;
			});
		});
	</script>

	</body>
</html>