{include "header.inc.html"}
{$myorderLang = $lang.admin.myorder.form}
<div class="content_box">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>{$lang.admin.myorder.name}</strong><br />
		<span class="english">{$lang.admin.myorder.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}
<input type="hidden" name="inajax" value="1" />

{if $config.user.loginName}
<div class="form-line">
<label class="label">{$myorderLang.loginName}：</label><div class="element"><input type="text" class="text w200 readonly" name="loginName" value="{$myorderInfo.userInfo.loginName}" {if $smarty.get.act!="add"} readonly{/if} /></div>
</div>
{/if}
<div class="form-line">
<label class="label">商户：</label><div class="element"><input type="text" class="text w200" name="merchant" value="{$myorderInfo.merchant}" /> <label class="tip"></label></div>
</div>
<div class="form-line">
<label class="label">金额：</label><div class="element"><input type="text" class="text w200" name="amount" value="{$myorderInfo.amount}" /> <label class="tip"></label></div>
</div>
<div class="form-line">
<label class="label">收件人：</label><div class="element"><input type="text" class="text w200" name="receiver" value="{$myorderInfo.receiver}" /> <label class="tip"></label></div>
</div>
<div class="form-line">
<label class="label">收件人电话：</label><div class="element"><input type="text" class="text w200" name="mobile" value="{$myorderInfo.mobile}" /> <label class="tip"></label></div>
</div>
<div class="form-line">
<label class="label">收件时间：</label><div class="element"><input type="text" class="text w200" name="receiveTime" value="{$myorderInfo.receiveTime|date_format:'Y-m-d'}" /> <label class="tip"></label></div>
</div>
<div class="form-line">
<label class="label">发货内容：</label><div class="element"><input type="text" class="text w200" name="content" value="{$myorderInfo.content}" /> <label class="tip"></label></div>
</div>

<div class="form-line">
<label class="label">提交时间：</label><div class="element">{$myorderInfo.posttime|date_format:"Y-m-d H:i:s"}</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}myorder/act/list/" method="post" class="form">
<label class="label">{$lang.admin.user.form.loginName}：</label><input type="text" name="key" value="{$key}" autocomplete="off" /><input class="btn_sub" type="submit" value="搜索"> 请输入会员名精确搜索
</form>
</div>
<div class="right none"><a class="button" href="{$adminUrl}userscore/act/add/">添加积分记录</a></div>
<div class="clear"></div>
</div>


 <table class="table-ca table_1" id="tInfo">
 <tr>
<th class="w60">{$lang.form.id}</th><th class="">{$myorderLang.loginName}</th><th class="">商户</th><th class="">金额</th><th class="">收件人</th><th class="w100">收件人电话</th><th class="w100">收件时间</th><th>发货内容</th><th class="w70">审核状态</th><th class="w130">提交时间</th><th class="w50">操作</th></tr>
{myorder limit=15 key="$key"}
<tr sid="{$item.id}">
<td>{$item.id}</td><td class="w100">{$item.userInfo.loginName}</td>
<td>{$item.merchant}</td><td>{$item.amount}</td>
<td class="w50">{$item.receiver}</td><td>{$item.mobile}</td><td>{$item.receiveTime|date_format:"Y-m-d"}</td><td>{$item.content}</td>
<td class="changeStatus" title="点击更改审核状态">{if $item.iStatus==0}未审核{else if $item.iStatus==25}审核通过{else if $item.iStatus==26}审核失败{/if}</td>
<td>{$item.posttime|date_format:"Y-m-d H:i:s"}</td><td><a href="{$adminUrl}myorder/act/edit/id/{$item.id}" class="modBtn" title="{$lang.edit}">{$lang.edit}</a><a href="{$adminUrl}myorder/act/del/id/{$item.id}" class="delBtn delLink" title="{$lang.del}">{$lang.del}</a></td>
</tr>
{/myorder}
</table>
<div class="page">
{$key=$key|escape:"url"}
{if $key}
{$key = "/key/$key"}
{/if}
	<div class="pagin fr">{pager allCount=$allCount url="/admin/myorder$key/page/" number="false"}</div>
</div>
{/if}
</div><!--.content_box-->
<div id="statusDialog" class="none statusDialog">
<form id="auditForm" method="post" name="auditForm" class="form" action="{$adminUrl}/myorder">
<input type="hidden" name="inajax" value="1" />
<input type="hidden" name="act" value="audit" />
<input type="hidden" name="id" id="auditId" value="" />
<div class="form-line">
<label class="label">审核结果：</label><div class="element"><input type="radio" name="iStatus" id="iStatus25" value="25"><label for="iStatus25"> 通过</label>  <input type="radio" name="iStatus" id="iStatus26" value="26"><label for="iStatus26"> 不通过</label> <label generated="true" for="iStatus" class="error"></label></div></div>
<div class="form-line none scoreLine"><label class="label">增加积分：</label><div class="element"><input type="text" name="score" value="" autocomplete="off" /></div></div>
</form>
</div>
<script type="text/javascript">
{literal}
$(function(){
	$(".button").button();
	$("input[name='iStatus']").click(function(){
		$(".scoreLine").show();
		var val = $(this).val();
		var label = "";
		if(parseInt(val,10)==25){label = "增加积分";}else{label="扣除积分";$("input[name='score']").val(0);}
		$(".scoreLine").find("label.label").eq(0).text(label+"：");
	})
	$(".changeStatus").click(function(){
		var sid = $(this).parent("tr").attr("sid");
		$("input#auditId").val(sid);
		$("#statusDialog").dialog({ modal:true,title:"审核用户发货单",width:450,height:200,buttons:{ "确定":function(){
				$("#auditForm").submit();
			},"取消":function(){ $("#statusDialog").dialog("close");} } })
	});

	$("#auditForm").validate({
		rules:{
			iStatus:{required:true},
			score:{required:true,number:true}
		},
		messages:{
			iStatus:{required:"请选择审核结果"},
			score:{required:"请填写积分数额",number:"积分必须是数字"}	
		},
		submitHandler:function(){
			$("#auditForm").ajaxSubmit({dataType:"json",success:showResponse});
		}
	});
	function showResponse(rt,st,xhr,form){
		if(rt.success){
			$("#statusDialog").dialog("close");
			if(rt.data.id){
				if(rt.data.iStatus==25){statusStr="审核通过";}else{statusStr="审核失败";}
				$("tr[sid='"+rt.data.id+"']").find("td.changeStatus").text(statusStr);
			}
		}else{
			alert(rt.message);
		}
		$("input[name='iStatus']").removeAttr("checked");
		$("input[name='score']").val("");
	}
});
{/literal}
{if $smarty.get.act=="add" || $smarty.get.act=="edit"}
$(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");
*/
	$("input[name='receiveTime']").datepicker(dateconfig||{});

	$("#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}myorder/";
		}
	}
});
{/if}
</script>
{include "footer.inc.html"}