<?php
	$this->display(tpl('head'));
	$type[$group[type]]="checked";
	$if_admin[$group[if_login_admin]]="checked";
	$Article_yz[$setting[Article_yz]]="checked";
	$comment_yz[$setting[comment_yz]]="checked";
	$comment_yzm[$setting[comment_yzm]]="checked";
	$comment_add[$setting[comment_add]]="checked";
	$if_login_user[$group['if_login_user']]="checked";
	if($group[if_login_admin]==0){
		$if_login_admin_display=" style='display:none'";
	}
?>
<style>
		.layui-tab{
				padding-left: 20px;
		}
		.layui-form-select {
		    position: relative;
		    width: 30%;
		}
		.layui-input-my {
		    display: block;
		    width: 30%;
		    padding-left: 10px;
		}
		.layui-form-label {
		    float: left;
		    display: block;
		    padding: 9px 15px;
		    width: 150px;
		    font-weight: 400;
		    text-align: right;
		}
		.layui-form-select{
			display: none;
		}
		.layui-form select {
		    display:  initial;
		    width: 30%;
		}
		.layui-form-checkbox{
			margin-bottom: 5px;
			margin-top: 5px;
		}
		.names{
			font-weight: bold;
			font-size: 16px;
		}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  	<legend>用户组属性修改</legend>
</fieldset>
<form  class="layui-form" method="post">
	<table class="layui-table my-tabel">
		<tr>
			<td>用户组名称</td>
			<td>
				<input name="name" value="<?php echo $group[name] ?>" class="layui-input layui-input-my" type="text" >
			</td>
		</tr>
		<tr>
			<td>用户组类型</td>
			<td>
				<input name="type" value="0" lay-filter="type" title="系统组" type="radio" <?php echo $type[0] ?>>
		   		<input name="type" value="1" lay-filter="type" title="会员组" type="radio" <?php echo $type[1] ?>>
			</td>
		</tr>
		<tr>
			<td>是否允许登录后台</td>
			<td>
				<input name="if_login_admin" value="1" lay-filter="if_login_admin" title="允许" type="radio" <?php echo $if_admin[1] ?>>
		   		<input name="if_login_admin" value="0" lay-filter="if_login_admin" title="不允许" type="radio" <?php echo $if_admin[0] ?>>
			</td>
		</tr>
		<tr>
			<td>是否禁止登录会员中心</td>
			<td>
				<input name="if_login_user" value="1" lay-filter="if_login_user" title="允许" type="radio" <?php echo $if_login_user[1] ?>>
		   		<input name="if_login_user" value="0" lay-filter="if_login_user" title="不允许" type="radio" <?php echo $if_login_user[0] ?>>
			</td>
		</tr>
		<tr id="if_login_admin_display" <?php echo $if_login_admin_display ?>>
			<td>给予后台权限</td>
			<td>
				<table class="layui-table">
					<tr>
						<td colspan="2" class="names">主权限</td>
					</tr>
					<tr>
						<td>允许登入后台必须的权限</td>
						<td>
							<input type="checkbox" name="setting[power][index][]" value="index" title="后台首页" checked>
					 		<input type="checkbox" name="setting[power][index][]" value="map" title="map页面" checked>
					 		<input type="checkbox" name="setting[power][index][]" value="login" title="登入页面" checked>
					 		<input type="checkbox" name="setting[power][index][]" value="out" title="退出后台" checked><br>
					 		<input type="checkbox" name="setting[power][index][]" value="modular" title="如果需要授权其他模块管理权限，必选" checked>
					 		<input type="checkbox" name="setting[power][index][]" value="plugin" title="如果需要授权插件管理权限，必选" checked>
						</td>
					</tr>
					<?php foreach((array)C('POWER') AS $action=>$row){ ?>
					<tr>
						<td><?php echo $row[name] ?></td>
						<td>
							<?php foreach((array)$row[power] AS $job=>$r){
								$checked="";
								foreach((array)$setting[power][$action] AS $j){
									if($job==$j){
										$checked='checked';
									}
								}
							?>
					 		<input type="checkbox" name="setting[power][<?php echo $action ?>][]" value="<?php echo $job ?>" title="<?php echo $r[name] ?>" <?php echo $checked ?>>
							<?php } ?>
						</td>
					</tr>
					<?php } ?>

				</table>
				<?php foreach((array)$Modular_DB AS $action=>$row){ ?>
				<table class="layui-table">
					<tr>
						<td colspan="2" class="names"><?php echo $row[name] ?>权限设置</td>
					</tr>
					<?php foreach((array)$row[POWER] AS $action=>$rows){?>
					<tr>
						<td><?php echo $rows[name] ?></td>
						<td>
							<?php 
							foreach((array)$rows[power] AS $job=>$r){
								$checked="";
								foreach((array)$setting[power][$row[table].'power'][$action] AS $j){
									if($job==$j){
										$checked='checked';
									}
								}
							?>
	 						<input type="checkbox" name="setting[power][<?php echo $row[table] ?>power][<?php echo $action?>][] " value="<?php echo $job ?>" title="<?php echo $r[name] ?>" <?php echo $checked ?>>
							<?php } ?>
						</td>
					</tr>
					<?php } ?>
				</table>
				<?php } ?>
				<table class="layui-table">
					<tr>
						<td class="names">插件权限</td>
					</tr>
					<tr>
						<td>
							<?php foreach((array)$plugin_DB AS $action=>$row){ ?>
							<table class="layui-table">
								<tr>
									<td colspan="2" class="names"><?php echo $row[name] ?>权限设置</td>
								</tr>
								<?php foreach((array)$row[POWER] AS $action=>$rows){?>
								<tr>
									<td><?php echo $rows[name] ?></td>
									<td>
										<?php 
										foreach((array)$rows[power] AS $job=>$r){
											$checked="";
											foreach((array)$setting[power][$row[table].'power'][$action] AS $j){
												if($job==$j){
													$checked='checked';
												}
											}
										?>
				 						<input type="checkbox" name="setting[power][<?php echo $row[table] ?>power][<?php echo $action?>][] " value="<?php echo $job ?>" title="<?php echo $r[name] ?>" <?php echo $checked ?>>
										<?php } ?>
									</td>
								</tr>
								<?php } ?>
							</table>
							<?php } ?>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>允许上传文件的类型</td>
			<td>
				<input name="setting[upfiles_type]"  class="layui-input layui-input-my" type="text" value="<?php echo $setting[upfiles_type] ?>">
			</td>
		</tr>
		
		<tr>
			<td colspan="2" class="my_button">
				<input type="hidden" name="id" value="<?php echo $id ?>" />
				<input type="hidden" name="step" id="step" value="edit" />
				<button class="layui-btn">提交</button>
			</td>
		</tr>
	</table>
</form>
<script>
	layui.use(['form'], function(){
	  	var form = layui.form;
	  	form.on('radio(if_login_admin)', function(data){
	  		if(data.value==1){
	  			document.getElementById("if_login_admin_display").style.display="";
	  		}else{
	  			document.getElementById("if_login_admin_display").style.display="none";
	  		}
	  	})
	});
</script>
<?php $this->display(tpl('foot')); ?>
