{include "header.inc.html"}
{$userLang = $lang.admin.user.form}
<div class="content_box mw1100">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>{$lang.admin.user.name}</strong><br />
		<span class="english">{$lang.admin.user.name_en}</span> </span>
		<div class="toolbar_menu">
			<a href="{$adminUrl}user/act/add">添加用户</a>
		</div>
		 </div>
	</div>
<div class="userForm">
 {if $smarty.get.act=="edit" || $smarty.get.act=="add"}
<form class="form" action="" method="post" id="userForm">
<input type="hidden" name="act" value="{$smarty.get.act}" />
<input type="hidden" name="inajax" value="1" />
{if  $smarty.get.act=="edit"}
<div class="form-line">
<label class="label">用户ID：</label><div class="element"><input type="text" class="w200" name="id" value="{$userInfo.id}" {if $smarty.get.act!="add"} readonly{/if} /></div>
</div>
{/if}
<div class="form-line">
<label class="label">{$userLang.email}：</label><div class="element"><input type="text" class="text w200" name="email" value="{$userInfo.email}" /></div>
</div>
{if $cfg_lang=="zh-cn"}
<div class="form-line">
<label class="label">{$userLang.name}：</label><div class="element"><input type="text" class="text w200" name="name" value="{$userInfo.name}" /></div>
</div>
<div class="form-line">
<label class="label">{$userLang.certNo}：</label><div class="element"><input type="text" class="text w200" name="certNo" value="{$userInfo.certNo}" maxlength=18 /></div>
</div>
<div class="form-line">
<label class="label">{$userLang.inviter}：</label><div class="element"><input type="text" class="w200" name="inviter" value="{$userInfo.inviter}"{if $smarty.get.act!="add"} readonly{/if} /></div>
</div>
<div class="form-line">
<label class="label">{$userLang.mobile}：</label><div class="element"><input type="text" class="text w200" name="mobile" value="{$userInfo.mobile}"/></div>
</div>

{else}
<div class="form-line">
<label class="label">{$userLang.firstName}：</label><div class="element"><input type="text" class="text w200" name="firstName" value="{$userInfo.firstName}" /></div>
</div>
<div class="form-line">
<label class="label">{$userLang.lastName}：</label><div class="element"><input type="text" class="text w200" name="lastName" value="{$userInfo.lastName}" /></div>
</div>
{/if}
{if $config.user.nickname}
<div class="form-line">
<label class="label">{$userLang.nickname}：</label><div class="element"><input type="text" class="text w200" name="nickname" value="{$userInfo.nickname}" /></div>
</div>
{/if}
<div class="form-line"{if not $config.multiAdmin} style="display:none"{/if}>
<label class="label">{$userLang.group}：</label><div class="element"><select name="groupId"><option value="0">普通用户</option><option value="1"{if $userInfo.groupId==1} selected{/if}>管理员</option></select></div>
</div>
<div class="form-line none">
<label class="label">代理级别：</label><div class="element"><select name="levelId">{userlevel limit="false"}<option value="{$item.id}"{if $item.id==$userInfo.levelId} selected{/if}>{$item.name}</option>{/userlevel}</select></div>
</div>


<div class="form-line">
<label class="label">{$userLang.password}：</label><div class="element"><input type="text" class="text w200" name="loginPwd" value="" /> {$userLang.passwordTips}</div>
</div>
<div class="form-line none">
<label class="label">信用额度：</label><div class="element"><input type="text" class="text w200" name="creditLine" value="" /> {$userLang.creditLine}</div>
</div>

<div class="form-line">
<label class="label"></label><div class="element"><input class="btn_sub" type="submit" value="{$lang.form.submit}"></div>
</div>
</form>
</div>
 {else}
<div class="tool">
{if $smarty.get.act=="list" || $smarty.get.act==""}<a id="deleteChecked" class="ui-btn">删除所选</a>{/if}
<form action="{$adminUrl}user/" method="get" class="form" style="width:500px;display:inline;">
会员ID：<input type="text" name="userId" class="checkUserId w80" value="{$smarty.get.userId}" /> 关键字：<input type="text" name="key" value="{$key}" /><input type="submit" class="btn_sub" value="{$lang.form.search}" />
</form>
<div class="clear"></div>
</div>


 <table class="table-ca table_1" id="tInfo">
 <tr>
<th class="w30"><input type="checkbox" value="1" name="allid" id="checkall" /></th><th class="w60">{$lang.form.id}</th><th class="w150">{$userLang.email}</th><th class="w100">手机</th><th class="w60">验证</th><th class="w100">{$userLang.name}</th><th class="w60">余额</th>{if $config.user.nickname}<th class="w100">昵称</th>{/if}{if $config.multiAdmin}<th class="w100">合作账户绑定</th>{/if}{config name="credit"}{if $credit.id}<th class="w80">授信额度</th>{/if}{/config}<th class="w120">上次登录时间</th><th class="w30">激活</th><th class="w100">操作</th>
 </tr>
{user limit=15 key="$key"}
<tr sid="{$item.id}">
<td><input type="checkbox" name="id[]" value="{$item.id}" /></td><td>{$item.id}</td><td>{$item.email}</td><td>{$item.mobile}</td><td>{if $item.emailActivationTime}<span class="ico-auth ico-email"></span>{/if}{if $item.mobileActivationTime}<span class="ico-auth ico-mobile"></span>{/if}</td><td>{if $cfg_lang=="zh-cn"}{$item.name}{else}{$item.firstName} {$item.lastName}{/if}</td><td>{$item.amount}</td>
{if $config.user.nickname}<td><div class="w90 nowrap">{$item.nickname}</div></td>{/if}
<td>{if $item.auth.qq}<span class="ico-auth ico-qq"></span>{/if} {if $item.auth.weibo}<span class="ico-auth ico-weibo"></span>{/if}  {if $item.auth.alipay}<span class="ico-auth ico-alipay"></span>{/if} {if $item.auth.taobao}<span class="ico-auth ico-taobao"></span>{/if} {if $item.auth.baidu}<span class="ico-auth ico-baidu"></span>{/if}</td>
{config name="credit"}{if $credit.id}<td>{$item.creditLine}</td>{/if}{/config}<td title="{$item.lastLoginIp}">{if $item.lastLoginTime}{$item.lastLoginTime|date_format:'Y-m-d H:i:s'}{/if}</td>
<td><img src="{$baseUrl}static/images/{if $item.activated==1}yes{else}no{/if}.gif" title="{if $item.activated==1}已激活{else}未激活{/if}"></td>
<td>
<a href="{$adminUrl}user/act/edit/id/{$item.id}" class="modBtn" title="{$lang.edit}">{$lang.edit}</a><a href="{$adminUrl}order/act/list/userId/{$item.id}/" class="orderIcon" title="{$lang.userOrderList}"></a><a href="javascript:void(0)" class="delBtn" title="{$lang.del}">{$lang.del}</a>
<a href="{$adminUrl}user/act/quicklogin/id/{$item.id}" target="_blank">登录</a>
</td>
</tr>
{/user}
</table>
<div class="page">
{$key=$key|escape:"url"}
{if $key}
{$key = "/key/$key"}
{/if}
	<div class="pagin fr">{pager allCount=$allCount url="/qkadmin/user$key/page/" number="false"}</div>
</div>
{/if}
</div><!--.content_box-->
<script type="text/javascript">
{if $smarty.get.act=="add"}
$(function(){
/*
$("input[name='loginName']").val("loginName");
$("input[name='email']").val("qkweb@qq.com");
$("input[name='name']").val("测试");
$("input[name='certNo']").val("412811198510270537");
$("input[name='mobile']").val("13323850053");
$("input[name='loginPwd']").val("123456");
*/
	$("#userForm").validate({
		rules:{
			loginName:{ required:true },
			email:{ required:true,email:true },
			name:{ required:true },
			certNo:{ required:true,minlength:15,maxlength:18 },
			mobile:{ required:true,minlength:11,maxlength:11 },
			loginPwd:{ required:true }
		},
		submitHandler:function(){
			$("#userForm").ajaxSubmit({ dataType:"json",success:showResponse });//
		}
	});
	function showResponse(rt,xt,xhr,form){
		alert(rt.message);
		if(rt.success){
			location.href="{$adminUrl}user/";
		}
	}
	$("select[name='distributionDistrictId']")
});
{else}
$(function(){
	$("#userForm").validate({
		rules:{ email:{ required:true } },messages:{ email:{ required:'请填写邮箱' } },submitHandler:function(){
			$("#userForm").ajaxSubmit({	dataType:'json',success:function(json){ if(json.success){ qlib.tips({ icon:'success',msg:json.message }); if($("input[name='act']").val()=='add'){ $("#userForm").find("input[type='text']").val(''); } }else{ qlib.tips({ icon:'error',msg:json.message }); } },error:function(){ qlib.tips({ icon:'error',msg:'Ajax处理失败' }); } });
			return false;
		}
	});
	$("a.delBtn").click(function(){ if(!confirm("删除不可恢复，是否确认删除？"))return false;var tr=$(this).parent("td").parent("tr"),sid=tr.attr("sid");$.ajax({ type:"POST",url:"{$adminUrl}user",data:{ act:"del",inajax:1,id:sid },dataType:'json',success:function(json){ if(json.success){ tr.remove(); }else{ qlib.tips(json.message); } },error:function(){ alert('ajax操作失败'); }}) });
	$("a#deleteChecked").button().click(function(){
		if(!confirm(lang[4])){ return false; }		
		var id = [];
		$("input[name='id[]']:checkbox:checked").each(function(index){
			id[index] = $(this).val();
			var sid = $(this).val();
			if(sid){
				var tr = $(this).parent("td").parent("tr");
				var sdata = "inajax=1&act=del&id="+sid;
				$.ajax({
					type:"POST",
					url:"{$adminUrl}user",
					data:sdata,
					dataType:"json",
					success:function(data){
						if(data.success){
							tr.fadeOut("slow").remove();
						}else{
							alert(data.message);
						}
					}
				});			
			}
		});
	});
});
{/if}
</script>
{include "footer.inc.html"}