{:tpl head}
<table cellpadding="0" cellspacing="1" class="table_list">
 <caption>权限管理</caption>
  <tr>
   <td>
    <strong>管理选项：</strong>
    <a href="?c=access&a=add">添加节点</a> |
    <a href="?c=access">管理节点</a>
   </td>
  </tr>
</table>
<!--{:if $a == 'add' || $a == 'edit'}-->
<table cellpadding="0" cellspacing="1" class="table_form">
 <caption>
 {:if $a == 'add'}添加{:else}编辑{:/if}节点
 </caption>
 <form name="addaccess" action="?c=access&a={:$a}" method="post">
 <input type="hidden" name="info[id]" value="{:$data['id']}" />
 <input type="hidden" name="forward" value="{:$referer}" />
 <tr>
   <td width="25%" align="right">上级节点：</td>
   <td>
   <select name="info[pid]" id="pid">
    <option value="0">无（作为一级节点）</option>
    <!--{:loop $parents $access}-->
    <option value="{:$access['id']}"{:Tag::selected($access['id'], $data['pid'])}>{:$access['name']}</option>
    <!--{:/loop}-->
   </select>
   </td>
 </tr>
 <tr>
  <td align="right">节点名称：</td>
  <td><input name="info[name]" type="text" size="20" value="{:$data['name']}" require="true" datatype="require" msg="节点名称不能为空"> <span class="fred">*</span></td>
 </tr>
 <tr>
  <td align="right">控制器(control)：</td>
  <td>
   <input type="text" name="info[control]" size="20" value="{:$data['control']}" />
  </td>
 </tr>
 <tr>
  <td align="right">方法(action)：</td>
  <td>
   <input type="text" name="info[action]" size="20" value="{:$data['action']}" />
  </td>
 </tr>
 <tr>
  <td align="right">模块(module)：</td>
  <td>
   <input type="text" name="info[module]" size="20" value="{:$data['module']}" /><span class="fblue"> 一般公共模型才需要用到该参数</span>
  </td>
 </tr>
 <tr>
  <td align="right">节点描述：</td>
  <td>
   <input type="text" name="info[description]" size="50" value="{:$data['description']}" />
  </td>
 </tr>
 <tr>
  <td align="right">菜单显示：</td>
  <td>
   <input name="info[ismenu]" type="radio" value="1"{:Tag::checked($data['ismenu'],1)} onclick="is_menu(this)" />是&nbsp;&nbsp;
   <input name="info[ismenu]" type="radio" value="0"{:Tag::checked($data['ismenu'],0)} onclick="is_menu(this)" />否&nbsp;&nbsp;
  </td>
 </tr> 
 <tbody id="menuset" style="display:{:if $data['ismenu'] == 0}none{:/if}">
 <tr>
  <td align="right">打开窗口：</td>
  <td>
   <select name="info[target]">
    <option value="_self"{:Tag::selected('_self', $data['target'])}>当前窗口</option>
    <option value="_blank"{:Tag::selected('_blank', $data['target'])}>新窗口</option>
    <option value="left"{:Tag::selected('left', $data['target'])}>左窗口</option>
    <option value="right"{:Tag::selected('right', $data['target'])}>右窗口</option>
   </select>
  </td>
 </tr>
 <tr>
  <td align="right">自定义菜单：</td>
  <td>
   <input name="info[iscustom]" type="radio" value="1"{:Tag::checked($data['iscustom'],1)} />是&nbsp;&nbsp;
   <input name="info[iscustom]" type="radio" value="0"{:Tag::checked($data['iscustom'],0)} />否&nbsp;&nbsp;
   <span class="fred">指样式不同于普通菜单，例如：“内容管理”菜单</span>
  </td>
 </tr>
 </tbody>
 <tr>
  <td align="right">
   管理员设置：<br /><span class="fred">不选表示不做限制&nbsp;</span><br />
   {:if $data['isparent']}赋予下级节点相同设置<input type="checkbox" name="inherit" value="1" />&nbsp;{:/if}
  </td>
  <td>
  {:loop $role $k $v}
  <input type="checkbox" name="info[roleids][]" value="{:$k}"{:if in_array($k, $data['roleids'])} checked{:/if} />{:$v['name']}（{:$v['description']}）<br />
  {:/loop}
  </td>
 </tr>
 <tr>
  <td colspan="2" height="30" align="center">
   <button type="submit" name="submit">&nbsp;提交&nbsp;</button>
   <button type="button" onclick="history.back()">&nbsp;返回&nbsp;</button>
  </td>
 </tr>
 </form>
</table>
<script type="text/javascript" src="../../statics/js/validator.js"></script>
<script type="text/javascript"> 
function is_menu(obj){
	if(obj.value == 1) $('#menuset').show();
	else $('#menuset').hide();
}		
$(function(){
	$('form').checkForm(1);
})
</script>
<!--{:elseif $a == 'defaults'}-->
<table cellpadding="0" cellspacing="1" class="table_list" id="list_access">
 <caption>
 管理节点
 </caption>
 <form name="myform" method="post" action="">
 <input type="hidden" name="selids" value="">
 <tr align="center">
  <th width="5%"><input name="checkbox" type="checkbox" onclick="checkorno(this,this.form.ids)" /></th>
  <th>节点名称</th>
  <th width="10%">ID</th>
  <th width="15%">角色ID</th>
  <th width="10%">排序</th>
  <th width="7%">菜单</th>
  <th width="30%">管理操作</th>
 </tr>
 {:loop $data $v}
 <tr align="center">
  <td><input name="ids" type="checkbox" value="{:$v['id']}"></td>
  <td>{:$v['name']}</td>
  <td>{:$v['id']}</td>
  <td>{:$v['roleids']}</td>
  <td><input name="orderid[{:$v['id']}]" type="text" size="2" value="{:$v['orderid']}"></td>
  <td class="fgreen">{:if $v['ismenu']}√{:/if}</td>
  <td>
   <!--{:if $pid == 0}-->
   <!--{:if $v['control'] == ''}-->
   <a href="?c=access&id={:$v['id']}">子节点</a> | 
   <!--{:else}-->
   <span class="gray">子节点</span> | 
   <!--{:/if}-->
   <a href="?c=access&a=add&id={:$v['id']}">添加</a> | 
   <!--{:/if}-->
   <a href="?c=access&a=edit&id={:$v['id']}">修改</a> | 
   <a href="?c=access&a=del&id={:$v['id']}">删除</a></td>
 </tr>
 {:/loop}
 <tr>
  <td height="20" colspan="7" class="align_c">
   <button name="select1" onClick="selAll(this.form.ids)" type="button">全选</button>
   <button name="select2" onClick="noSelAll(this.form.ids)" type="button">反选</button>
   <button name="order" type="button" onClick="subform(this.form,this.form.ids,'?c=access&a=order','')">排序</button>
   <button name="reset" type="reset">重置</button>
   <!--{:if $pid}-->
   <button type="button" onclick="location.href='?c=access'">返回</button>
   <!--{:/if}-->
  </td>
 </tr>
 </form>
</table>
{:if $pages}<div class="pages">{:$pages}</div>{:/if}
<!--{:/if}-->
{:tpl foot}