<?php
!defined('ADMIN')&&die("<meta http-equiv='refresh' content=0;url='/'>");
if(ADMIN<2)Js_to("没有权限！",URL._1.D.L.D);
FN("title","订单查询");
global $z,$i,$title;
_F("top");
$id=N;
$arr=array('等待处理','买家已退单','商家已接单','商家已拒单','已送达','申请退货','拒绝退货','争议处理中','订单完结');
?>
<tt id="tw"></tt>
<fieldset class="form">
<legend><h1><b><var><img src="system/img/left.gif" /></var><dfn class="hide"><img src="system/img/right.gif" /></dfn></b>　<a href="<?php echo URL._1.D._2.D?>"><?php echo $title?></a></h1></legend>
<?php
if(_3=='i'){
	$r=$z->R('order','o_id='._4.(ADMIN<20?' and (n_uid='.UID.' or uid='.UID.')':''));
	if($r)$n=$z->R('new','id='.$r['n_id']);
	echo '<h2>订单号：<i class="red">'._4.'</i></h2>';
	if(!$r)echo '对不起，订单号<i class="red">'._4.'</i>不存在！';
	else{
?>
<ul><dt><b>订购时间：</b></dt><dd><p><?php echo date('Y-m-d H:i:s',$r['atime'])?></p></dd></ul>
<ul><dt><b>订购项目：</b></dt><dd><p><a href="<?php echo URL.'p-'.$n['url'].HZ?>" target="_blank" class="zi"><?php echo $n['title']?></a></p></dd></ul>
<ul><dt><b>订购数量：</b></dt><dd><p><?php echo $r['shuliang']?></p></dd></ul>
<ul><dt><b>总金额：</b></dt><dd><p><?php echo $r['jine']?></p></dd></ul>
<ul><dt><b>订购者id：</b></dt><dd><p><a href="<?php echo URL._1.D.'hy/'.$r['uid'].HZ?>" target="_blank" class="zi"><b><?php echo $r['uid']?></b></a></p></dd></ul>
<ul><dt><b>联系人：</b></dt><dd><p><?php echo $r['lxr']?></p></dd></ul>
<ul><dt><b>联系电话：</b></dt><dd><p><?php echo $r['dianhua']?></p></dd></ul>
<ul><dt><b>联系邮箱：</b></dt><dd><p><?php echo $r['umail']?></p></dd></ul>
<ul><tt></tt></ul>
<form action="" method="post">
<ul><dt><b>操作：</b></dt><dd><li>
<select name="yn">
<?php
foreach($arr as $k=>$v){
	echo "<option value='{$k}' ".($r['yn']==$k?'selected ':'').">{$v}</option>\n";
}?>
</select>
<input type="hidden" name="cgi" value="order" />
</li></dd></ul>
<ul><tt></tt></ul>
<ul><dt><b>备注：</b></dt><dd><p><textarea name="note" class="w8" rows="6"><?php echo $r['note']?></textarea></p></dd></ul>
<ul>
<big><input type="submit" id="s" value="OK (确 定 提 交)" /></big>
</ul>
</form>
<?php
	}}else{?>
<script>
function souzi(a,b){
	if(a!=undefined){
		if(b)return window.location.href="<?php echo URL._1.D._2.D?>1/0/0/"+a+"/";
		if(a==''){
			tanchuang('错误，会员id必须大于0！');tuitan(3);return ;
		}
		return window.location.href="<?php echo URL._1.D._2.D?>1/0/"+a+"/";
	}
	var zi=document.getElementById("zi").value;
	if(zi==''){
		tanchuang('错误，订单号码必须大于0！');tuitan(3);return ;
	}
	window.location.href="<?php echo URL._1.D._2.D?>1/"+zi+"/0/";
}
</script>
<tt></tt>
<div class="fieldset form ">
<big><samp>&#9682;</samp><span class="del">&#9681;</span>更多操作<del> </del></big>
<div>
<main id="sozi">
<dd>
<input type="text" id="zi" placeholder="请输入订单号" onfocus="this.select()" value="<?php echo _4&&is_numeric(_4)?_4:''?>">
<b onclick="souzi()">搜索订单号</b>　
<?php
$_4=_4==N?'n':_4;
if(ADMIN>19){?>
<input type="text" id="z2" placeholder="请输入会员号" onfocus="this.select()" value="<?php echo _5?_5:''?>">
<b onclick="souzi($('#z2').val())">搜索会员号</b>　
<?php }?>
<a href="<?php echo URL._1.D._2.'/1/n'.HZ?>"><b<?php echo $_4=='n'?' class="red"':''?>>我售出的</b></a>
<a href="<?php echo URL._1.D._2.'/1/u'.HZ?>"><b<?php echo $_4=='u'?' class="red"':''?>>我购买的</b></a>
<?php
if(ADMIN>19){?>
<select onchange="souzi(this.value,1)">
<option>==按状态查询==</option>
<option value="9"<?php if(_6==9)echo ' selected'?>>全部订单</option>
<?php
foreach($arr as $k=>$v){
	echo "<option value='{$k}' ".(_6!=N&&_6==$k?'selected ':'').">{$v}</option>\n";
}?>
</select>
<?php }?>
</dd>
<p></p>
</main>
</div>
</div>
<tt></tt>
<?php
$p=intval(_3)?intval(_3):1;
$d=20;
$a=($p-1)*$d;
if(ADMIN<20||_5==N)
	$tj=is_numeric(_4)?'o_id='._4.' and (n_uid='.UID.' or uid='.UID.')':(_4=='u'?'uid':'n_uid').'='.UID;
else{
	$yn=_6==9?'':'yn='.intval(_6);
	$tj=_4?(_4?'o_id='._4:''):(_5?'uid='._5:$yn);
}

$s=$z->S("order",$tj);
$fenye=URL._1.D._2."/";
$m=ceil($s/$d);
$dir=S($p,$m,$s,$fenye,D._4.D._5.D);
$r=$z->A('order',$tj." order by id desc limit $a,$d");
foreach($r as $v){
	$nid='n'.$v['n_id'];
	$n=$$nid=isset($$nid)?$$nid:$z->R('new','id='.$v['n_id']);
	$cz=ADMIN>19?'　<a href="'.URL._1.D._2.D.'i/'.$v['o_id'].HZ.'" class="red">[ 操作 ]</a>':'';
	echo '<h2><img src="system/img/'.($v['yn']==8?'note_ok.gif':'warning.gif').'" /> 订单号: '.$v['o_id'].'　[ <i class="lan">'.$arr[$v['yn']].'</i> ]'.$cz.'</h2><p><img src="system/img/rect.gif" /> <b>订购时间：</b>'.date('Y年m月d日 H:i',$v['atime']).'　<b>单价：</b>'.$v['danjia'].'　<b>数量：</b>'.$v['shuliang'].'　<b>金额：</b>'.$v['jine'].'元　<br><img src="system/img/htm.png" /> <b>订购项目：</b> <a href="'.URL.'p-'.$n['url'].HZ.'" target="_blank" class="lv">'.$n['title'].'</a>'.(_5!=N?'　<img src="system/img/uid.gif" /> UID=<a href="'.URL._1.D._2.D.'1/0/'.$v['uid'].HZ.'" class="cheng">'.$v['uid'].'</a>':'').'</p><hr>';
}
if(!$r)echo '<i class="red">对不起，没有查到订单！</i>';
?>
<tt></tt>
<dir><?php echo $dir.' <span>（共'.$s.'条）</span>'?></dir>
<?php }?>
<ul><tt></tt></ul>
<ul><tt></tt></ul>
</fieldset>
<?php
_F("end");