<!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>
<meta http-equiv="Content-Type" content="text/html; charset=<!--{$page_charset}-->" />

<title>管理员</title>
<!--{include file="<!--{$cptplpath}-->headerjs.tpl"}-->
<!--{assign var='pluginevent' value=XHook::doAction('adm_head')}-->
</head>
<body>
<!--{assign var='pluginevent' value=XHook::doAction('adm_main_top')}-->
<!--{include file="<!--{$cptplpath}-->lang_all.tpl"}-->
<!--{if $a eq "group"}-->
<div class="main-wrap">
  <div class="path"><p>当前位置：系统设置<span>&gt;&gt;</span>管理员设置<span>&gt;&gt;</span><a href="<!--{$cpfile}-->?c=admin&a=group">权限列表</a></p></div>
  <div class="main-cont">
    <h3 class="title"><a href="<!--{$cpfile}-->?c=admin&a=addgroup" class="btn-general"><span>添加权限</span></a>权限列表</h3>
	<form action="<!--{$cpfile}-->?c=admin" method="post" name="myform" id="myform" style="margin:0">
	<input type="hidden" name="a" id="a" value="del" />
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table" align="center">
	  <thead class="tb-tit-bg">
	  <tr>
	    
		<th width="10%"><div class="th-gap">名称</div></th>
		<th width="10%"><div class="th-gap">资源类型</div></th>
		<th width="10%"><div class="th-gap">所属分组</div></th>
                <th width="50%"><div class="th-gap">权限码</div></th>
		<th width="20%"><div class="th-gap">操作</div></th>
	  </tr>
	  </thead>
	  <tfoot class="tb-foot-bg"></tfoot>
	  <!--{foreach $admin as $volist}-->
	  <tr onMouseOver="overColor(this)" onMouseOut="outColor(this)">
	        
		<td align="center"> <!--{$volist.name}--></td>		
		<td align="center">系统后台</td>
		<td  align="center"><!--{$volist.group}--></td>
	<td ><!--{$volist.right}--></td>
		<td align="center"><a href="<!--{$cpfile}-->?c=admin&a=editgroup&id=<!--{$volist.id}-->&page=<!--{$page}-->" class="icon-edit">编辑</a>&nbsp;&nbsp;<a href="<!--{$cpfile}-->?c=admin&a=delgroup&id[]=<!--{$volist.id}-->" onClick="{if(confirm('确定要删除吗?')){return true;} return false;}" class="icon-del">删除</a></td>
	  </tr>
	  <!--{foreachelse}-->
      <tr>
	    <td colspan="5" align="center">暂无信息</td>
	  </tr>
	  <!--{/foreach}-->
	  <!--{if $total>0}-->
	  <tr>
	
		<td class="hback" colspan="7">共[ <b><!--{$total}--></b> ]条记录</td>
	  </tr>
	  <!--{/if}-->
	</table>
	</form>
	<!--{if $pagecount>1}-->
	<table width='95%' border='0' cellspacing='0' cellpadding='0' align='center' style="margin-top:10px;">
	  <tr>
		<td align='center'><!--{$showpage}--></td>
	  </tr>
	</table>
	<!--{/if}-->
  </div>
</div>

<!--{/if}-->
<!--{if $a eq "addgroup"}-->
<div class="main-wrap">
  <div class="path"><p>当前位置：系统设置<span>&gt;&gt;</span>管理员帐号<span>&gt;&gt;</span><a href="<!--{$cpfile}-->?c=admin&a=addrole">编辑权限</a></p></div>
  <div class="main-cont">
	<h3 class="title"><a href="<!--{$cpfile}-->?c=admin&a=group" class="btn-general"><span>返回列表</span></a>编辑权限</h3>
    <form name="myform" id="myform" method="post" action="<!--{$cpfile}-->?c=admin" onsubmit='return adsubmit();' />
    <input type="hidden" name="a" value="saveaddgroup" />
	<table cellpadding='3' cellspacing='3' class='tab'>
	  <tr>
		<td class='hback_1' width="15%">权限资源名称：<span class='f_red'>*</span></td>
		<td class='hback' width="85%">
                    <input type="text" name="name" id="adminname" class="input-150" /> <span class='f_red' id="dadminname"></span> <font color="#999999"></font>
                </td>
	  </tr>
	 
	  <tr>
		<td class='hback_1'>所属分组： </td>
		<td class='hback'>
                                       <select class="small form-control" id="group" name="group" style="width: 163px;">
                                             <!--{foreach $group as $vo}-->
                                               
							<option value="<!--{$vo}-->"><!--{$vo}--></option>
					 <!--{/foreach}-->
                                                
					</select>
                </td>
	  </tr>
            <tr>
		<td class='hback_1'>添加权限码： </td>
		<td class='hback'>
                    <select class="small form-control" id="controller" onblur="get_act_list(this)">
						<option value="">选择控制器</option>
						<!--{foreach $planList as $vo}-->
							<option value="<!--{$vo}-->"><!--{$vo}--></option>
						 <!--{/foreach}-->
					</select>
					<span style="color:#F00; display:none;">@</span>
					<select id="act_list">
						<option value="">选择控制器</option>
						<!--{foreach $planList as $vo}-->
                                                    
							<option value="<!--{$vo}-->"><!--{$vo}--></option>
						 <!--{/foreach}-->
					</select>
					<a class="ncap-btn" onclick="add_right()">添加</a>
					<p class="notic">
					</p>
                    </td>
	  </tr>
            <tr>
		<td class='hback_1'>权限码： </td>
		<td class='hback'>
                    <table>
						<tr><th style="width:80%">权限码</th><th style="width: 50px;text-align: center;" >操作</th></tr>
						<tbody id="rightList">
						<!--{foreach $info as $vo}-->
							 <tr><td><input name="right[]" type="text" value="<!--{$vo}-->" class="form-control" style="width:300px;"></td>
								<td style="text-align: center;"><a class="ncap-btn" href="javascript:;" onclick="$(this).parent().parent().remove();">删除</a></td></tr>
						 <!--{/foreach}-->
						</tbody>
					</table>
                    </td>
	  </tr>
	  <tr>
		<td class='hback_none'></td>
		<td class='hback_none'><input type="submit" name="btn_save" class="button" value="添加保存" /></td>
	  </tr>
	</table>
	</form>
  </div>
  <div style="clear:both;"></div>
</div>
<!--{/if}-->

<!--{if $a eq "editgroup"}-->
<div class="main-wrap">
  <div class="path"><p>当前位置：系统设置<span>&gt;&gt;</span>管理员帐号<span>&gt;&gt;</span>编辑帐号</p></div>
  <div class="main-cont">
	<h3 class="title"><a href="<!--{$cpfile}-->?c=admin&<!--{$comeurl}-->" class="btn-general"><span>返回列表</span></a>编辑帐号</h3>
    <form name="myform" id="myform" method="post" action="<!--{$cpfile}-->?c=admin" />
    <input type="hidden" name="a" value="saveeditgroup" />
	<input type="hidden" name="id" value="<!--{$info.id}-->" />
	<table cellpadding='3' cellspacing='3' class='tab'>
	  <tr>
		<td class='hback_1' width="15%">权限资源名称：<span class='f_red'>*</span></td>
		<td class='hback' width="85%">
                    <input type="text" name="name" value="<!--{$info.name}-->" id="adminname" class="input-150" /> <span class='f_red' id="dadminname"></span> <font color="#999999"></font>
                </td>
	  </tr>
	 
	  <tr>
		<td class='hback_1'>所属分组： </td>
		<td class='hback'>
                                       <select class="small form-control" id="group" name="group" style="width: 163px;">
                                             <!--{foreach $group as $vo}-->
                                               
                                             <option <!--{if $info.group eq <!--{$vo}-->}-->selected<!--{/if}--> value="<!--{$vo}-->"><!--{$vo}--></option>
					 <!--{/foreach}-->
                                                
					</select>
                </td>
	  </tr>
            <tr>
		<td class='hback_1'>添加权限码： </td>
		<td class='hback'>
                    <select class="small form-control" id="controller" onblur="get_act_list(this)">
						<option value="">选择控制器</option>
						<!--{foreach $planList as $vo}-->
							<option value="<!--{$vo}-->"><!--{$vo}--></option>
						 <!--{/foreach}-->
					</select>
					<span style="color:#F00; display:none;">@</span>
					<select id="act_list">
						<option value="">选择控制器</option>
						<!--{foreach $planList as $vo}-->
                                                    
							<option value="<!--{$vo}-->"><!--{$vo}--></option>
						 <!--{/foreach}-->
					</select>
					<a class="ncap-btn" onclick="add_right()">添加</a>
					<p class="notic">
					</p>
                    </td>
	  </tr>
            <tr>
		<td class='hback_1'>权限码： </td>
		<td class='hback'>
                    <table>
						<tr><th style="width:80%">权限码</th><th style="width: 50px;text-align: center;" >操作</th></tr>
						<tbody id="rightList">
						<!--{foreach $info.right as $vo}-->
							 <tr><td><input name="right[]" type="text" value="<!--{$vo}-->" class="form-control" style="width:300px;"></td>
								<td style="text-align: center;"><a class="ncap-btn" href="javascript:;" onclick="$(this).parent().parent().remove();">删除</a></td></tr>
						 <!--{/foreach}-->
						</tbody>
					</table>
                    </td>
	  </tr>
	  <tr>
		<td class='hback_none'></td>
		<td class='hback_none'><input type="submit" name="btn_save" class="button" value="添加保存" /></td>
	  </tr>
	</table>
	</form>
  </div>
  <div style="clear:both;"></div>
</div>
<!--{/if}-->

</body>
</html>

<script type="text/javascript">
	function add_right(){
		var a = [];
		$('#rightList .form-control').each(function(i,o){
			if($(o).val() != ''){
				a.push($(o).val());
			}
		})
		var ncode = $('#controller').val();
		if(ncode !== ''){
			var temp = ncode+'@'+ $('#act_list').val();
			if($.inArray(temp,a) != -1){
				layer.msg('此权限码已经添加！', {icon: 2,time: 1000});
				return false;
			}
		}
		var strtr = '<tr>';
		if(ncode!= ''){
			strtr += '<td><input type="text" name="right[]" value="'+ncode+'@'+ $('#act_list').val()+'" class="form-control" style="width:300px;"></td>';
		}else{
			strtr += '<td><input type="text" name="right[]" value="" class="form-control" style="width:300px;"></td>';
		}
		strtr += '<td style="text-align: center;"><a href="javascript:;" class="ncap-btn" onclick="$(this).parent().parent().remove();">删除</a></td>';
		$('#rightList').append(strtr);
	}
	function get_act_list(obj){
         var c=$(obj).val();
    
         var url="<!--{$cpfile}-->?c="+c+"&a=ajax_get_action"
		$.ajax({
			url: url,
			type:'get',
			dataType:'html',
			success:function(res){
				$('#act_list').empty().append(res);
			}
		});
	}
	function adsubmit(){
   
		if($('input[name=name]').val() == ''){
			layer.msg('权限名称不能为空！', {icon: 2,time: 1000});
			return false;
		}

		if($('input[name="right\[\]"]').length == 0){
			layer.msg('权限码不能为空！', {icon: 2,time: 1000});
			return false;
		}

		$('#adminHandle').submit();
	}
</script>