{include "header.inc.html"}
{$scoreLang = $lang.admin.userscore.form}
<div class="content_box">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>{$lang.admin.userscore.name}</strong><br />
		<span class="english">{$lang.admin.userscore.name_en}</span> </span> </div>
	</div>
{if $smarty.get.act=="edit" || $smarty.get.act=="add"}
<div class="userForm">
<form class="form" action="" method="post" id="userForm">
<input type="hidden" name="act" value="{$smarty.get.act}" />
{if $smarty.get.act=="edit"}
<input type="hidden" name="id" value="{$smarty.get.id}" />
{/if}
{if $smarty.get.act=="add"}
<input type="hidden" name="inajax" value="1" />
{/if}

{if $config.user.loginName}
<div class="form-line">
<label class="label">{$scoreLang.loginName}：</label><div class="element"><input type="text" class="text w200 readonly" name="loginName" value="{$userInfo.loginName}" {if $smarty.get.act!="add"} readonly{/if} /></div>
</div>
{/if}
<div class="form-line">
<label class="label">{$scoreLang.score}：</label><div class="element"><input type="text" class="text w200" name="score" value="{$userInfo.score}" /> <label class="tip">数字，扣除积分请填写负数</label></div>
</div>
<div class="form-line">
<label class="label">类型：</label><div class="element"><select name="typeId"><option value="">类型</option><option value="22">添加积分</option><option value="23">扣除积分</option></select></div>
</div>
<div class="form-line">
<label class="label">是否有效：</label><div class="element"><input type="radio" name="iStatus" value="1" id="iStatus1" /><label for="iStatus1"> 有效</label> <input type="radio" name="iStatus" value="0" id="iStatus0" /><label for="iStatus0"> 无效</label><label for="iStatus" generated="true" class="error"></label></div>
</div>
<div class="form-line">
<label class="label">备注：</label><div class="element"><input type="text" class="text w200" name="remark" value="{$userInfo.remark}" /></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">
<div class="left">
<form action="{$adminUrl}userscore" method="get" class="form">
<label class="label">{$lang.admin.user.form.loginName}：</label><input type="text" name="key" value="{$key}" autocomplete="off" /><input type="submit" class="btn_sub" value="{$lang.form.search}" /> 请输入会员名精确搜索
</form>
</div>
<div class="right"><a class="button" href="{$adminUrl}userscore/act/add/">添加积分记录</a></div>
<div class="clear"></div>
</div>

 <table class="table-ca table_1" id="tInfo">
 <tr sid="{$item.id}">
<th class="w60">{$lang.form.id}</th><th class="w60">用户ID</th><th class="">{$scoreLang.score}</th><th class="w100">订单</th><th class="w50">状态</th><th>备注</th><th class="w130">提交时间</th><th class="w50">操作</th></tr>
{userscore limit=15 key="$key"}
<tr sid="{$item.id}">
<td>{$item.id}</td><td class="w100 J-user-anchor" sid="{$item.userId}">{$item.userId}</td><td class="w50">{$item.score}</td><td>{$item.orderId}</td><td><img src="{$baseUrl}static/images/{if $item.iStatus==1}yes{else}no{/if}.gif"></td><td>{$item.remark}{if $item.orderId} 订单：{$item.orderId}{/if}</td><td>{$item.posttime|date_format:"Y-m-d H:i:s"}</td><td><a href="javascript:void(0)" class="delBtn" title="{$lang.del}">{$lang.del}</a></td>
</tr>
{/userscore}
</table>
<div class="page">
{$key=$key|escape:"url"}
{if $key}
{$key = "/key/$key"}
{/if}
	<div class="pagin fr">{pager allCount=$allCount url="/qkadmin/usercore$key/page/" number="false"}</div>
</div>
{/if}
</div><!--.content_box-->
<script type="text/javascript">
$(function(){
	$(".button").button();
	$(".delBtn").click(function(){
		if(!confirm(lang[4])){ return false; }
		var tr = $(this).parent("td").parent("tr");
		var id = tr.attr("sid");
		if(!id || !parseInt(id)){ return false; }
		$.ajax({
			type:"POST",
			url:"{$adminUrl}userscore",
			data:"inajax=1&act=del&id="+id,
			dataType:"json",
			success:function(json){
				if(json.success){
					tr.slideUp().remove();
				}else{
					qlib.tips(json.message);
				}
			}
		})
	});
});
{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 },
			score:{ required:true,number:true },
			typeId:{ required:true },
			iStatus:{ required:true}
		},
		messages:{
			loginName:{ required:"请填写登录名" },
			score:{ required:"请填写要增加或扣除的积分数量",number:"积分只能是数字" },
			typeId:{ required:"请选择操作类型" },
			iStatus:{ required:"请选择是否有效"}
		},
		submitHandler:function(){
			$("#userForm").ajaxSubmit({ dataType:"json",success:showResponse });//
		}
	});
	function showResponse(rt,xt,xhr,form){
		alert(rt.message);
		if(rt.success){
			location.href="{$adminUrl}userscore/";
		}
	}
});
{/if}
</script>
{include "footer.inc.html"}