{include file="header.tpl" page_name=$page_name sys_name=$sys_name}
<div align="center">
{$admin_nav}
{if $do == 'admincper' or $do == 'user_add' or $do == 'user_edit'}
{literal}
	<script type="text/javascript">
    function delmodel(id){
       var f = window.confirm('确定要删除该管理员吗？');
	   if (f ==true)
	       window.location="admincp.php?action=managectrller&do=adminer_del&id="+id;
		else
		return false;
	}
    </script>
{/literal}
<table width="98%" border="0" cellpadding="0" cellspacing="0" class="adminMenu g-margin" align="center">
	<tr>
	  <td><b>管理菜单：</b> <a href="?action={$action}&do=admincper">管理员列表</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="?action={$action}&do=user_add">添加管理员</a></td>
	</tr>
</table>
{/if}
  {if $do == 'admincper' or $do ==''}
<table width="98%" border="0" cellpadding="0" cellspacing="0" class="tableborder tableborder_line">

      <tr class="header">
        <td width="10%" >管理员编号</td>
        <td width="16%" >用户名</td>
		 <td width="15%" >添加人</td>
        <td width="12%">最近登陆IP</td>
        <td width="14%" >添加时间</td>
        <td width="17%" >最近登陆时间</td>
        <td width="9%" >操作</td>
      </tr>
    {section name=i loop=$data}
    <tr>
      <td align="center">{$data[i].id}</td>
      <td  class="center">{$data[i].admin_user}</td>
	  <td class="center">{$data[i].add_user}</td>
      <td class="center">{$data[i].last_login_ip}</td>
      <td class="center">{$data[i].add_time}</td>
      <td class="center">{$data[i].last_login}</td>
      <td style="cursor:pointer;"><a href="?action={$action}&do=user_edit&id={$data[i].id}">编辑</a> {if $manager_data.is_orgin eq '1'}{if $data[i].is_orgin neq '1'}  | <span onclick="delmodel({$data[i].id},'user_info')">删除</span> {/if} {/if}</td>
    </tr>
    {/section}
    </tbody>
</table>
{if $show_page}<div align="center"  style="width:98%; padding:5px 0px;">{$show_page}</div> {/if}
  {/if}
{if $do == 'user_add' or $do == 'user_edit'}

<div class="notice_msg">注意:对创始人的权限设置将不起作用,也就是说创始人拥有所有权限. <font color="#FF0000">&nbsp;&nbsp;当前用户为{if $manager_data.is_orgin eq '1'}<b>创始人</b>{else}<b>普通管理员</b>{/if}</font></div>

<table width="98%" border="0" cellspacing="0" cellpadding="0"  class="tableborder">
  <form autocomplete="off" action="{if $do == 'user_add'}admincp.php?action=managectrller&type=core&do=adminer_add{else}admincp.php?action=managectrller&type=core&do=sure_edit{/if}" method="post" enctype="multipart/form-data" name="myformadd">
      <tr>
        <td colspan="2" align="center" class="header"><div align="center"><strong>{if $do == 'user_add'} 管 理 员 添 加 {else} 编 辑 管 理 员 {/if}</strong></div></td>
      </tr>
    <tr>
      <td width="13%" class="header">管理员名称：</td>
      <td width="87%" >
      {if $do eq 'user_add'}
      <input name="data[admin_user]" id ="admin_user"   type="text"  value="" />
      	{else}
        <input name="data[admin_user]" id ="admin_user"  type="hidden" value="{$data[0].admin_user}" />
        {$data[0].admin_user}
      {/if}
        <font color="#FF0000">*</font> {if $do == 'user_edit'}<input name="data[id]" type="hidden" id="data[id]" value="{$data[0].id}" /><input name="ori_admin_pwd" type="hidden" id="ori_admin_pwd" value="{$data[0].admin_pwd}" />{/if}</td>
      </tr>
    <tr>
      <td class="header">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
      <td ><input name="ra_pwd_new" type="password" id="admin_pwd" value="" />
        <font color="#FF0000">*</font>  &nbsp;{if $do eq 'user_edit'}如若不修改密请保留为空{/if}</td>
    </tr>
    {if $do eq 'user_add'}
    <tr>
      <td class="header">确认密码：</td>
	   <td ><input name="ra_pwd_old" id="ra_pwd" type="password" value="" />
	     <font color="#FF0000">*</font></td>
      </tr>
      {/if}
    <tr>
      <td  class="header">权限分配：</td>
	  <td>
      {literal}
      	<script type="text/javascript">
	$(document).ready(function(){
		$("input[type='checkbox']").each(function(i){
			if($(this).attr('checked')==true)$(this).attr('disabled',false);
		});
	});
       function select_one(obj){
		var checked = $(obj).attr('checked');
		var val = $(obj).val();
		if(checked==true){
			$('.'+val).attr({'checked':true,'disabled':false});
		}else{
			$('.'+val).attr({'checked':false,'disabled':true});		
		}
	}
	function select_two(obj){
		return select_one(obj);
	}
	function select_three(obj,id){
		var checked = $(obj).attr('checked');
		if(checked==true){
			$("#"+id+'_c').find('input').attr({'checked':true,'disabled':false});
		}else{
			$("#"+id+'_c').find('input').attr({'checked':false,'disabled':true});		
		}
	}
        </script>
      {/literal}
<div  class="common_form">
        {foreach from=$group_list item=list key=key}
      
<div class="roles">
<div class="sub_title"><input type="checkbox"  class="form_checkbox"  onclick="select_one(this);" name="group[]" value="{$list.p}" {if $list.checked=='1'} checked="checked"{/if}/><label>{$list.name}</label></div>
      {if $list.childrens}
      {foreach from = $list.childrens item = twos}
<div class="two">
<input type="checkbox" value="{$twos.p}"  class="{$list.p}" name="group[]" {if $twos.checked=='1'}checked="checked"{/if}  disabled="disabled" onclick="select_two(this);"/>{$twos.name}</div>
      {if $twos.childrens}
      <div class="three">
      {foreach from=$twos.childrens item=three}
      <input type="checkbox" name="group[]" class="{$list.p} {$twos.p} form_checkbox" onclick="select_three(this,{$three.id});" disabled="disabled"  {if $three.checked=='1'}checked="checked"{/if} value="{$three.p}"/>{$three.name}&nbsp;&nbsp;
            <!--for class four-->
                        {if $three.childrens}
                    <div class="four" id="{$three.id}_c">
                        {foreach from =$three.childrens item=four}
                            <input type="checkbox" name="group[]" class="form_checkbox"  disabled="disabled" {if $four.checked=='1'} checked="checked"{/if} value="{$four.id}"/>{$four.name} &nbsp;&nbsp;
                        {/foreach}
                    </div>
                {/if}
      {/foreach}
      </div>
       {/if}<!--end two-->
              {/foreach}
      {/if}
        </div>
        {/foreach}        
    </div>
     	
	<!-- <input type="hidden" size="200" name="pri_val" id = "pri_val"/> -->
	 </td>
    </tr>
    <tr>
      <td colspan="2" align="center" class="header"><div align="center">
        <input type="submit" name="btnsubmit" value="{if $do == 'user_add'} 添 加 {else} 编 辑 {/if}" />
      </div></td>
    </tr>
    </form>
</table>
{/if}


{if $do == 'popedom' or $do == 'group_add' or $do == 'group_edit'}
<table width="98%" border="0" cellpadding="0" cellspacing="0" class="adminMenu g-margin" align="center">
	<tr>
	  <td><b>管理菜单：</b> <a href="?action={$action}&do=popedom">用户组列表</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="?action={$action}&amp;do=group_add">添加用户组</a></td>
	</tr>
</table>
{/if}
{if $do == 'popedom'}
admincp.php?action=deal&
<table width="98%" border="0" cellspacing="0" cellpadding="0"  class="tableborder">

      <tr class="header">
        <td colspan="2">编号</td>
        <td colspan="2">权限名称</td>
        <td colspan="2">权限</td>
        <td colspan="2">状态</td>
        <td width="21%" colspan="2">操作</td>
      </tr>
    {section name=i loop=$data}
    <tr>
      <td colspan="2">{$data[i].id}</td>
      <td colspan="2">{$data[i].name}</td>
      <td colspan="2">{$data[i].pri_config}</td>
      <td colspan="2">{if $data[i].state==1}开启{else}关闭{/if}</td>
      <td colspan="2" style="cursor:pointer;"><a href="?action=core&do=group_edit&id={$data[i].id}">编辑</a> | <span onclick="delmodel({$data[i].id},'user_group')">删除</span></td>
    </tr>
    {/section}
    </form>
</table>
{/if}

{if $do == 'group_add' or $do == 'group_edit'}
<table width="30%" border="0" cellspacing="0" cellpadding="0"  class="tableborder">
  <form action="{if $do == 'group_add'}admincp.php?action=deal&type=core&do=grup_add{else}admincp.php?action=deal&type=core&do=grup_edit&group_id={$data[0].id}{/if}" method="post" name="myform">
      <tr> 
        <td colspan="2" align="center" class="header"><div align="center"><strong>{if $do == 'group_add'} 用 户 组 添 加 {else} 编 辑 用 户 组 {/if}</strong></div></td>
      </tr>
    <tr>
      <td width="12%" class="header">组&nbsp;&nbsp;&nbsp;&nbsp;名:</td>
      <td width="31%" ><input name="data[name]" type="text" value="{$data[0].name}" /></td>
      </tr>
    <tr>
      <td class="header">组权限:</td>
      <td ><input type="text" name="data[pri_config]" value="{$data[0].pri_config}"/></td>
      </tr>
    <tr>
      <td class="header">状&nbsp;&nbsp;&nbsp;&nbsp;态:</td>
      <td >
	  <select name="data[state]">
	  	<option value="1" {if $data[0].state == '1'}selected{/if}>启用</option>
	    <option value="0" {if $data[0].state == '0'}selected{/if}>关闭</option>
      </select>      </td>
      </tr>
    <tr>
      <td colspan="2" align="center" class="header">
	  <div align="center">
	  <input type="submit" name="Submit" value="{if $do == 'group_add'} 添 加 {else} 编 辑 {/if}" />
	  </div>
	  </td>
      </tr>
    </form>
</table>
{/if}
</div>
{include file="footer.tpl"}