{include file="header.tpl" page_name=$page_name sys_name=$sys_name}
{literal}

      	<script  type="text/javascript">
        		function delete_group(id){//删除会员组
					$.get('admincp.php?action=core&do=deleteGroup&id='+id,function(d){
						var c = d.split('|');
						switch(c[0]){
							case '1':
								alert(c[1]);
								return false;
							break;
							case '2':
								alert(c[1]);
								window.location.href='admincp.php?action=core&do=popedom';
							break;
							default:alert(d);
						}
					})
				}
				
	 function fuzzy(obj)
	 {
	 	var objs=document.getElementById('fuzzy');
		
		
	 	if(obj.checked==true)
		{
			objs.style.display='';
		}else{
			objs.style.display='none';
			document.getElementById('login_ip').value='';
			document.getElementById('birthday').value='';
			document.getElementById('integral1').value='';
			document.getElementById('integral2').value='';
			document.getElementById('reg_time1').value='';
			document.getElementById('reg_time2').value='';
			document.getElementById('login_time1').value='';
			document.getElementById('login_time2').value='';
			document.getElementById('yxb1').value='';
			document.getElementById('yxb2').value='';
		}
	 	
	 }
</script>
{/literal}

<div align="center">

{$admin_nav}
{if $do == 'associator' or $do == 'user_add' or $do == 'user_edit' or $do == 'query' or $do == ''}
<table width="98%" border="0" cellpadding="0" cellspacing="0" class="adminMenu g-margin" align="center">
	<tr>
	  <td><b>管理菜单：</b> <a href="?action={$action}&do=associator">用户列表</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="?action={$action}&do=user_add">添加用户</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="admincp.php?action=core">用户搜索</a></td>
	</tr>
</table>
{/if}
{if $do == ''}
<form id="form1" name="form1" method="post" action="?action=core" autocomplete="off">
  <table width="98%" border="0" cellspacing="0" cellpadding="0" class="tableborder">
    <tr class="header">
      <td width="10%">&nbsp;</td>
      <td colspan="2">&nbsp;        &nbsp;&nbsp;说明：以下条件必须填写一个</td>
      </tr>
    <tr>
      <td>&nbsp;</td>
      <td width="10%">用户名&nbsp;&nbsp;&nbsp;&nbsp;：</td>
      <td width="82%"><input name="login_name" type="text" id="login_name" size="30" />
*多个请用,半角逗号分开。&nbsp;&nbsp;</td>
    </tr>
	      <tr>
      <td>&nbsp;</td>
      <td>性&nbsp;&nbsp;&nbsp;&nbsp;别&nbsp;&nbsp;&nbsp;&nbsp;：        </td>
      <td>
	  <select name="sex" id="sex">
         <option value="0">不限</option>
        <option value="男">男</option>
        <option value="女">女</option>
      </select>
	  </td>
      </tr>
    <tr>
      <td>&nbsp;</td>
      <td>用户组&nbsp;&nbsp;&nbsp;&nbsp;：        </td>
      <td>
	  <select name="group_id[]" size="4" multiple id="group_id">
	    {section name=i loop=$user_group}
		<option value="{$user_group[i].id}">{$user_group[i].name}</option>
		{/section}
      </select>
	  </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>E-Mail&nbsp;&nbsp;&nbsp;&nbsp;：        </td>
      <td><input name="email" type="text" id="email" size="30" /></td>
    </tr>
  <!--  <tr>
      <td>&nbsp;</td>
      <td>高级
        <input name="fuzzy_ok" type="checkbox" id="fuzzy_ok" onclick="fuzzy(this)" value="1" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3">
	  <table style="display:none;" id=fuzzy width="100%" border="0" cellspacing="0" cellpadding="0">
	   <tr >
      <td width="8%">&nbsp;</td>
      <td width="10%">登陆ip&nbsp;&nbsp;&nbsp;&nbsp;：        </td>
      <td width="82%"><input name="login_ip" type="text" id="login_ip" size="12" />
      说明：允许输入202.56或输入完整的IP。</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>会员生日：        </td>
      <td><input onfocus="new WdatePicker(this,'%Y-%M-%D',false)" name="birthday" type="text" id="birthday" size="12" /></td>
    </tr>
    
	<tr>
      <td>&nbsp;</td>
      <td>积&nbsp;&nbsp;&nbsp;&nbsp;分：        </td>
      <td><input onKeyUp="this.value=this.value=this.value.replace(/[^\d]|^[0]*[0][0]*$/,'');" name="integral1" type="text" id="integral1" size="10" />
&nbsp;-&nbsp;
<input onKeyUp="this.value=this.value=this.value.replace(/[^\d]|^[0]*[0][0]*$/,'');" name="integral2" type="text" id="integral2" size="10" /></td>
	</tr>
    <tr>
      <td>&nbsp;</td>
      <td> 时间段：        </td>
      <td><input onfocus="new WdatePicker(this,'%Y-%M-%D',false)" name="reg_time1" type="text" id="reg_time1" size="10" />
&nbsp;-&nbsp;
<input onfocus="new WdatePicker(this,'%Y-%M-%D',false)" name="reg_time2" type="text" id="reg_time2" size="10" />
*
注册时间</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td> 时间段：        </td>
      <td><input onfocus="new WdatePicker(this,'%Y-%M-%D',false)" name="login_time1" type="text" id="login_time1" size="10" />
&nbsp;-&nbsp;
<input onfocus="new WdatePicker(this,'%Y-%M-%D',false)" name="login_time2" type="text" id="login_time2" size="10" />
*最后访问</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>金&nbsp;&nbsp;&nbsp;&nbsp;钱：        </td>
      <td><input onKeyUp="this.value=this.value=this.value.replace(/[^\d]|^[0]*[0][0]*$/,'');" name="yxb1" type="text" id="yxb1" size="10" />
&nbsp;-&nbsp;
<input onKeyUp="this.value=this.value=this.value.replace(/[^\d]|^[0]*[0][0]*$/,'');" name="yxb2" type="text" id="yxb2" size="10" /></td>
    </tr>
	</table>
	  </td>
      </tr>-->
    <tr>
      <td>&nbsp;</td>
      <td colspan="2">
      	<input type="hidden" value="search"  name="task"/>
      <input type="submit" value="查询" /></td>
      </tr>
  </table>
</form>
{/if}
{if $do eq 'associator' || $do eq 'search_usr'}
<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="19%">积分</td>
        <td width="14%" >注册时间</td>
        <td width="17%" >最后登录时间</td>
        <td width="9%" >操作</td>
      </tr>
      <tbody>
    {if !$data}
    <tr>
      <td align="center" colspan="7"><font color=red>暂无会员。</font></td>
    </tr>
    {else}
    {foreach from =$data item=list}
    <tr>
      <td align="center">{$list.id}</td>
      <td>{$list.login_name}</td>
	  <td>{$list.name}</td>
      <td>{$list.integral}</td>
      <td>{$list.reg_time|date_format:"%Y-%m-%d"}</td>
      <td>{$list.login_time|date_format:"%Y-%m-%d"}</td>
      <td style="cursor:pointer;">
 <a href="?action=core&do=user_edit&id={$list.id}">编辑</a> | <a href="?action=core&do=user_delete&id={$list.id}">删除</a></td>
    </tr>
    {/foreach}
    {/if}
    
<tr><td colspan="7"><div align="center">{$show_page}</div></td></tr>
</tbody>
</table>
{/if}
<!--结束-->
{if $do == 'user_add' or $do == 'user_edit'}
{literal}
	<script type="text/javascript" src="../js/calendar/wdatepicker.js"></script>

{/literal}
<table width="98%" border="0" cellspacing="0" cellpadding="0"  class="tableborder">
  <form action="{if $do == 'user_add'}admincp.php?action=core{else}admincp.php?action=core{/if}" method="post" enctype="multipart/form-data" name="myform" autocomplete="off">
  <input type="hidden" value="{if $do eq 'user_add'}user_add{else}user_edit{/if}" name="task" />
      <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="12%" class="header">用户名：</td>
      <td width="88%" ><input name="data[login_name]" type="text" value="{$data[0].login_name}" />
        <font color="#FF0000">*</font>{if $do == 'user_edit'}<input name="data[id]" type="hidden" id="data[id]" value="{$data[0].id}" />{/if} </td>
      </tr>
    <tr>
      <td class="header">组权限：</td>
      <td >
	  <select name="data[group_id]">
        {$user_group}
      </select></td>
      </tr>
	  {if $do == 'user_add'}
    <tr>
      <td class="header">密&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
      <td ><input name="data[login_pwd]" type="password" id="data[login_pwd]" value="{$data[0].login_pwd}" />
        <font color="#FF0000">*</font></td>
    </tr>
	  {/if}
    <tr>
      <td class="header">E-Mail：</td>
	   <td ><input name="data[email]" type="text" value="{$data[0].email}" />
	     <font color="#FF0000">*</font></td>
      </tr>
    <tr>
      <td class="header">真实名：</td>
	   <td><input name="data[true_name]" type="text" value="{$data[0].true_name}" /></td>
    </tr>
    <tr>
      <td  class="header">性&nbsp;&nbsp;别：</td>
	   <td>
	   <select name="data[sex]">
	     <option value="保密" {if $data[0].sex == '保密'}selected{/if}>保密</option>
	     <option value="男" {if $data[0].sex == '男'}selected{/if}>男</option>
	     <option value="女" {if $data[0].sex == '女'}selected{/if}>女</option>
       </select>
	   </td>
    </tr>
    <tr>
     <td  class="header">生&nbsp;&nbsp;日：</td>
	   <td><input name="data[birthday]" onfocus="new WdatePicker(this,'%Y-%M-%D',false)" value="{$data[0].birthday|date_format:"%Y-%m-%d"}" id="datetime" type="text" /></td>
    </tr>
    <tr>
      <td  class="header">电&nbsp;&nbsp;话：</td>
	   <td><input name="data[telephone]" type="text" value="{$data[0].telephone}" /></td>
    </tr>
    <tr>
      <td  class="header">手&nbsp;&nbsp;机：</td>
	   <td><input name="data[mobile]" type="text" value="{$data[0].mobile}" /></td>
    </tr>
    <tr>
      <td  class="header">地&nbsp;&nbsp;址：</td>
	   <td><input name="data[address]" type="text" value="{$data[0].address}" /></td>
    </tr>
    <tr>
      <td  class="header">邮&nbsp;&nbsp;编：</td>
	   <td><input name="data[zipcode]" type="text" value="{$data[0].zipcode}" /></td>
    </tr>
    <tr>
      <td  class="header">Q&nbsp;&nbsp;&nbsp;&nbsp;Q：</td>
	   <td><input name="data[qq]" type="text" value="{$data[0].qq}" /></td>
    </tr>
    <tr>
      <td  class="header">M&nbsp;S&nbsp;N：</td>
	   <td><input name="data[msn]" type="text" value="{$data[0].msn}" /></td>
    </tr>
    <tr>
      <td  class="header">提&nbsp;&nbsp;问：</td>
	   <td>
	   <select name="data[question]" id="data[question]">
           <option value="我常用的ID" {if $data[0].question == '我常用的ID'}selected{/if}>我常用的ID</option>
           <option value="我的名字" {if $data[0].question == '我的名字'}selected{/if}>我的名字</option>
           <option value="我的出生地" {if $data[0].question == '我的出生地'}selected{/if}>我的出生地</option>
         </select>
	    </td>
    </tr>
    <tr>
      <td  class="header">回&nbsp;&nbsp;答：</td>
	   <td><input name="data[answer]" type="text" value="{$data[0].answer}" /></td>
    </tr>
    <tr>
       <td  class="header">头&nbsp;&nbsp;像：</td>
	   <td valign="middle"><input name="head_pic" type="file" id="head_pic" /><img src="../{$data[0].head_pic}" width="182" height="82"/></td>
    </tr>
    <tr>
      <td  class="header">状&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 == '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'}

<table width="98%" border="0" cellspacing="0" cellpadding="0"  class="tableborder tableborder_line">
  <form action="admincp.php?action=deal&type=settings&do=save" method="post" name="myform" autocomplete="off">
      <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">{if $data[i].is_system eq '1'}<font color="#FF0000">是</font>{else}否{/if}</td>
      <td colspan="2">{if $data[i].state==1}<font color="#FF0000">开启</font>{else}关闭{/if}</td>
      <td colspan="2" style="cursor:pointer;"><a href="?action=core&do=group_edit&id={$data[i].id}">编辑</a>  {if $data[i].is_system eq '0'}| <span onclick="delete_group('{$data[i].id}')">删除</span>{/if}</td>
    </tr>
    {/section}
    </form>
</table>
{/if}

{if $do == 'group_add' or $do == 'group_edit'}
<table width="98%" border="0" cellspacing="0" cellpadding="0"  class="tableborder">
  <form action="admincp.php?action=core" method="post" name="myform" autocomplete="off">
      <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="7%" class="header">组&nbsp;&nbsp;&nbsp;&nbsp;名:</td>
      <td width="93%" >
<input type="hidden" value="{$do}" name="task" />
      <input name="data[name]" type="text" value="{$data.name}" {if $data.is_system eq '1'} readonly="readonly" {/if}/> {if $data.is_system eq '1'}系统默认组,不允许改名{/if}</td>
      </tr>
    <tr>
      <td class="header">组权限:</td>
      <td >
      	<!--
        <input type="text" name="data[pri_config]" value="{$data[0].pri_config}"/>
        -->
     {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 = $.trim($(obj).val());
		if(val=='')return false;
		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>
        <style type="text/css">
.common_form{}
.common_form .two{ padding-left:30px;}
.common_form .sub_title{border:1px solid #A1A1A1; border-left:none; border-right:none; border-top:none;padding:8px 0px; margin:4px;}
.common_form .three{ padding:8px 8px 8px 60px;}
.common_form .four{ padding:8px 8px 8px 30px;}
        </style>
      {/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>
    
    
      </td>
      </tr>
    <tr>
      <td class="header">状&nbsp;&nbsp;&nbsp;&nbsp;态:</td>
      <td >
	  <select name="data[state]">
       {if $data.is_system eq '1'}
       <option value="1" {if $data.state == '1'}selected{/if}>启用</option>
       	{else}
        <option value="1" {if $data.state == '1'}selected{/if}>启用</option>
	    <option value="0" {if $data.state == '0'}selected{/if}>关闭</option>
        {/if}
      </select>      </td>
      </tr>
    <tr>
      <td colspan="2" align="center" class="header">
	  <div align="center">
      {if $do eq 'group_edit'}
      <input type="hidden" value="{$data.id}"  name="group_id"/>
      {/if}
	  <input type="submit" value="{if $do == 'group_add'} 添 加 {else} 编 辑 {/if}" />
	  </div>
	  </td>
      </tr>
    </form>
</table>
{/if}
</div>
{include file="footer.tpl"}
