{include file="page_header.htm"}
{insert_scripts files="../js/utils.js"}

<form name="order_form" action="order.php" method="post" id="order_form">
<div class="table-div" style="margin-bottom: 5px">
	<table width="100%" cellpadding="3" cellspacing="1">
		<tr>
		<td colspan="4">
			<div align="center">
			{if $prev_order}
			<input name="prev" type="button" class="button" onClick="location.href='order.php?act=detail&order_id={$prev_order.order_id}';" value="前一个订单"  />
			{/if}
			{if $next_order}
			<input name="next" type="button" class="button" onClick="location.href='order.php?act=detail&order_id={$next_order.order_id}';" value="后一个订单"  />
			{/if}
			</div>
		</td>
		</tr>
		
		<tr>
		<th colspan="4">基本信息</th>
		</tr>
	
		<tr>
		<td width="18%"><div align="right"><strong>订单号：</strong></div></td>
		<td width="34%">{$order.order_no}</td>
		<td width="15%"><div align="right"><strong>订单状态：</strong></div></td>
		<td style="color:#FF0000;">
				{if $order.status == 0}
				未付款
				{elseif $order.status == 1}
				已付款
				{elseif $order.status == 2}
				已发货
				{elseif $order.status == 3}
				完成
				{elseif $order.status == 4}
				取消
				{elseif $order.status == 5}
				退货
				{/if}
		</td>
		</tr>
		
	<tr>
	<td><div align="right"><strong>快递方式：</strong></div></td>
	<td><div> {$order.shipping_name} </div></td>
	<td><div align="right"><strong>下单时间：</strong></div></td>
	<td>{$order.date_added}</td>
	</tr>
	<tr>
	<td><div align="right"><strong>支付方式：</strong></div></td>
	<td>{$order.payment_method}</td>
	<td><div align="right"><strong>付款时间：</strong></div></td>
	<td>{$order.payment_time}</td>
	</tr>
	<tr>
	<td><div align="right"><strong>配送方式：</strong></div></td>
	<td>{$order.shipping_method}</td>
	<td><div align="right"><strong>发货时间：</strong></div></td>
	<td>{$order.shipping_time}</td>
	</tr>
	<tr>
	<td><div align="right"><strong>发货单号：</strong></div></td>
	<td>{$order.shipping_no}</td>
	<td><div align="right"></div></td>
	<td>&nbsp;</td>
	</tr>
	
	<tr>
	<th colspan="4">收货人信息</th>
	</tr>
	<tr>
	<td><div align="right"><strong>收货人：</strong></div></td>
	<td>{$order.name}</td>
	<td><div align="right"><strong>电子邮件：</strong></div></td>
	<td>{$order.shipping_email}</td>
	</tr>
	<tr>
	<td><div align="right"><strong>地址：</strong></div></td>
	<td>{$order.province_name}{$order.city_name}{$order.district_name}{$order.shipping_address}</td>
	<td><div align="right"><strong>邮编：</strong></div></td>
	<td>{$order.shipping_zip}</td>
	</tr>
	<tr>
	<td><div align="right"><strong>电话：</strong></div></td>
	<td>{$order.shipping_tel}</td>
	<td><div align="right"><strong>手机：</strong></div></td>
	<td>{$order.shipping_mobile}</td>
	</tr>
	</table>
</div>

<div class="table-div" style="margin-bottom: 5px">
	<table width="100%" cellpadding="3" cellspacing="1">
	<tr>
	<th colspan="8" scope="col">产品信息</th>
	</tr>
	<tr>
	<td scope="col"><div align="center"><strong>产品名</strong></div></td>
	<td scope="col"><div align="center"><strong>货号</strong></div></td>
	<td scope="col"><div align="center"><strong>价格</strong></div></td>
	<td scope="col"><div align="center"><strong>数量</strong></div></td>
	<td scope="col"><div align="center"><strong>属性</strong></div></td>
	<td scope="col"><div align="center"><strong>小计</strong></div></td>
	</tr>
	{foreach from=$order_product item=list}
	<tr>
	<td>{$list.name}</td>
	<td>{$list.model}</td>
	<td><div align="right">￥{$list.price}元</div></td>
	<td><div align="right">{$list.quantity}</div></td>
	<td>{$list.attr}</td>
	<td><div align="right">￥{$list.total}元</div></td>
	</tr>
	{/foreach}
	</table>
</div>

<div class="table-div" style="margin-bottom: 5px">
	<table width="100%" cellpadding="3" cellspacing="1">
	<tr>
	<th>费用信息</th>
	</tr>
	
	<tr>
	<td><div align="right">商品总金额：￥{$order.order_amount} + 运费：￥{$order.shipping_fee}+支付费用：￥{$order.payment_fee}</div></td>
	</tr>


	<tr>
	<td><div align="right"> 总计：<strong>￥{$order.total_amount} 元</strong></div></td>
	</tr>

	</table>
</div>

<div class="table-div" style="margin-bottom: 5px">
	<table cellpadding="3" cellspacing="1">
	<tr>
	<th colspan="6">操作信息</th>
	</tr>
	<tr>
	<td><div align="right"><strong>操作备注：</strong></div></td>
	<td colspan="5" style="padding-top:10px; padding-bottom:10px;"><textarea name="remark" id="remark" cols="80" rows="3" class="FormSmall">{$order.remark}</textarea></td>
	</tr>
	<tr>
	<td>
	<div align="right"><strong>当前可执行操作：</strong> </div></td>
	
	<td colspan="5"  style="padding-top:10px;padding-bottom:10px;">    
	<input type="hidden" name="order_id" id="order_id" value="{$order.order_id}" />
	<input name="confirm" type="button" value="确认" onclick="submit_info();" class="bginput" />
	{if $order.status == 0}
	<input name="btn_payment" type="button" value="已付款" onclick="order_status(1);" class="bginput" />
	<input name="btn_cancel" type="button" value="取消" onclick="order_status(4);" class="bginput" />
	{elseif $order.status == 1}
	发货单号:<input name="shipping_no" id="shipping_no" type="text" value="{$order.shipping_no}" size="23" class="FormSmall" /> <input name="btn_shipping" type="button" value="发货" onclick="order_status(2);" class="bginput" />
	<input name="btn_complete" type="button" value="完成" onclick="order_status(3);" class="bginput" />
	{elseif $order.status == 2}
	<input name="btn_complete" type="button" value="完成" onclick="order_status(3);" class="bginput" />
	<input name="btn_return" type="button" value="退货" onclick="order_status(5);" class="bginput" />
	{elseif $order.status == 3}
	{/if}
	</td>
	</tr>
	</table>
</div>
</form>

<script type="text/javascript">
{literal}
function order_status(status){
	var flag = true;
	if(status == 1 && confirm("确认已付款?")){
		flag = false;
	}else if(status == 4 && confirm("确认取消?")){
		flag = false;
	}else if(status == 2 && confirm("确认发货?")){
		flag = false;
	}else if(status == 3 && confirm("确认完成?")){
		flag = false;
	}else if(status == 5&& confirm("确认退货?")){
		flag = false;
	}
	
	if(flag == true){
		return ;
	}

	var order_id = $('#order_id').val();
	var shipping_no = $('#shipping_no').val();
	
	$.ajax({
			url:"order.php",
			type:"post",
			dataType:"json",
			data:{"act":"status","id":order_id,"status":status,"shipping_no":shipping_no,"is_ajax":1},
			beforeSend:function(){
				$("#loading").fadeIn("fast");
			},
			complete:function(){
				$("#loading").stop();
				$("#loading").fadeOut("fast");
			},
			success:function(result){
			  if (result.error == 0){
				location.href='order.php?act=detail&id='+order_id;
			  }
		}
	});	
}

function submit_info(){
	var order_id = $('#order_id').val();
	var remark=$('#remark').val();
	
	$.ajax({
			url:"order.php",
			type:"post",
			dataType:"json",
			data:{"act":"remark","id":order_id,"remark":remark,"is_ajax":1},
			beforeSend:function(){
				$("#loading").fadeIn("fast");
			},
			complete:function(){
				$("#loading").stop();
				$("#loading").fadeOut("fast");
			},
			success:function(result){
			  if (result.error == 0){
					alert('提交成功。');
				  
			  }
			}
	});
}
{/literal}
</script>

{insert_scripts files="validator.js"}
{include file="page_footer.htm"}