<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="source/admin/template/style/admin.css" rel="stylesheet" type="text/css" />
<script src="include/js/jsmain.js" type="text/javascript"></script>
<script src="include/js/admin.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
	actualpay();
	$("#favorable").change(function(){actualpay();});
	$(".searchauto").change(function(){$("#search").submit();});
	$("input[name='state']").change(function(){
		$("#sendgoods").removeClass("none");
		if($("input[name='state']:checked").val()=='0'){$("#sendgoods").addClass("none");}
	});
})
function actualpay(){
	price=parseFloat($("#total").text())-parseFloat($("#favorable").val());
	$("#actualpay").text(price.toFixed(2));
}
function logistics_add(){
	$('#logistics').append('<dl><dt>物流名称：</dt><dd><input name="name[]" type="text" class="int" /></dd><dd>默认价格：</dd><dd><input name="price[]" type="text" class="int" style="width:50px;" /> 元</dd><dd onclick="$(this).parent().remove()" style="cursor:pointer; color:#039">[删除]</dd></dl>');
}
<?php if($Gets=='orderedit'){ ?>
function orderedit(){
	var ordereditid=<?php echo $d['state']; ?>;
	var state=$("input[name='state']:checked").val();
	if(ordereditid==0){
		if(state==1||state==2||state==9){
			if (confirm("当前订单原状态为未支付，如果您修改为已支付之后状态，系统将自动处理订单相关发货行为(包括虚拟自动发货)，您确定要修改订单状态吗？")){
				$("#ordereditf").submit();
			}
			return false;
		}
	}
	$("#ordereditf").submit();
}
<?php } ?>
</script>
</head>

<body>
<div class="maintop">当前位置：<?php echo $toptxt ?></div>
<div class="main"><div class="oper"><?php echo $opers ?></div>
<?php if($Gets=='orderedit'){ ?>
        <div class="info">
        <form action="?c=a_goods&a=orderedit&run=1" method="post" id="ordereditf">
        <input name="id" type="hidden" value="<?php echo $d['id'] ?>" />
        <dl><dt>订单号：</dt><dd><?php echo $d['orderid'] ?></dd></dl>
        <dl><dt>下单时间：</dt><dd><input name="addtime" type="text" class="int" value="<?php echo date('Y-m-d H:i',$d['addtime']); ?>" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" /></dd></dl>
        <dl><dt>状态：</dt><dd><?php order_state($d['state'],1); ?></dd></dl>
        <?php if($d['virtual']!=1){?>
        <dl <?php if($d['state']=='0')echo 'class="none"'; ?> id="sendgoods"><dt>发货信息：</dt><dd>
        <?php $sendgoods=unserialize($d['sendgoods'])?>
        <!--物流发货信息与支付接口匹配，请勿修改参数内容，并且当支付接口为担保交易时，非常重要 -->
        物流公司：<input type="text" style="width:70px;" name="logistics_name" value="<?php echo $sendgoods['logistics_name'] ?>" class="int"> 
		物流单号：<input type="text" style="width:110px;" name="invoice_no" value="<?php echo $sendgoods['invoice_no'] ?>" class="int"> 
		物流类型：<select name="transport_type">
					<option value="EXPRESS" <?php if($sendgoods['transport_type']=='EXPRESS')echo 'selected="selected"'; ?>>快递</option>
					<option value="EMS" <?php if($sendgoods['transport_type']=='EMS')echo 'selected="selected"'; ?>>EMS</option>
					<option value="POST" <?php if($sendgoods['transport_type']=='POST')echo 'selected="selected"'; ?>>平邮</option>
                </select></dd></dl>
        <?php }?>
        <?php if($d['state']>0){ ?>
        <dl><dt>付款时间：</dt><dd><?php echo date('Y-m-d H:i',$d['paytime']); ?></dd></dl>
        <dl><dt>支付平台单号：</dt><dd><?php 
        if($d['payment']!='admin'){
        echo payment($d['payment']).'：';echo $d['paymentno'];
        }else{echo '通过后台修改订单状态，未通过支付平台';}
         ?></dd><dd>支付：<strong><?php echo $d['actualpay']; ?></strong> 元</dd></dl>
        <?php if($d['state']==9&&$d['virtual']==1){?>
            <dl style=" color:#C00;"><dt>虚拟货物：</dt><dd>
            <?php 
            $p_virtual=syDB('product_virtual')->findAll(array('oid'=>$d['id'],'state'=>1));
            foreach($p_virtual as $pv){
            echo '<strong>货号(卡号)</strong>：'.$pv['number'].'<br>';
            } ?>
            </dd></dl>
        <?php } ?>
        <?php } ?>
        <dl><dt>订单通知：</dt><dd><textarea name="rnote" style="width:300px; height:50px;" class="int"><?php echo $d['rnote'] ?></textarea></dd><dd class="t">反馈给会员查看，可填写备注、特殊情况、反馈信息等</dd></dl>
        <dl><dt>购买内容：</dt><dd><table class="tablist" style="line-height:130%">
		  <tr class="trbg">
            <td>商品</td>
            <td>单价</td>
            <td>数量</td>
            <td>物流</td>
            <td>小计</td>
          </tr>
         <?php foreach($goods[0] as $v){ ?>
          <tr>
            <td class="tdleft"><strong><?php echo $v['title'] ?></strong><br /><?php echo $v['attribute_txt'] ?></td>
            <td><?php echo $v['price'] ?></td>
            <td><?php echo $v['quantity'] ?></td>
            <td><?php if($d['virtual']!=1){?><?php echo $d['logistics'] ?><br /><?php echo $v['logistics_price'] ?>元<?php }else{echo '自动发货';}?></td>
            <td><strong><?php echo $v['total'] ?></strong>元</td>
          </tr>
         <?php  } ?>
         <tr>
            <td colspan="5">合计：<span id="total" style="font-weight:bold;"><?php echo $goods[1] ?></span> 元 (含运费)</td>
          </tr>
        </table></dd></dl>
        <dl style="border:0"><dt>&nbsp;</dt><dd class="t"><strong>价格计算说明</strong>:单个商品物流费用为“商品运费×数量”，单个商品小计为“商品单价×数量”加上“商品运费×商品数量”。</dd></dl>
        <dl><dt>优惠金额：</dt><dd><input name="favorable" id="favorable" type="text" class="int" value="<?php echo $d['favorable']; ?>" /> 元</dd></dl>
        <dl><dt>实际需支付：</dt><dd style="font-size:14px; font-weight:bold; color:#C00; font-family:Verdana, Geneva, sans-serif;"><span id="actualpay"></span> 元</dd><dd class="t">需支付金额为总金额减去优惠金额</dd></dl>
        <dl><dt>购买用户：</dt><dd><?php if($d['uid']==0){echo '游客';}else{echo memberinfo($d['uid'],'user');} ?></dd></dl>
<?php if($d['virtual']!=1){?>
        <dl><dt>收货信息：</dt><dd>
        <?php $info=unserialize($d['info'])?>
        <table cellspacing="5">
       <tr><td align="right">真实姓名：</td><td><input type="text" name="info[name]" id="name" class="int" value="<?php echo $info['name']?>"/></td></tr>
       <tr><td align="right">手机：</td><td><input type="text" name="info[phone]" id="phone" class="int" value="<?php echo $info['phone']?>"/></td></tr>
       <tr><td align="right">固定电话：</td><td><input type="text" name="info[tel]" id="tel" class="int" value="<?php echo $info['tel']?>"/></td></tr>
       <tr><td align="right">Email：</td><td><input type="text" name="info[email]" id="email" class="int" value="<?php echo $info['email']?>"/></td></tr>
       <tr><td align="right">邮编：</td><td><input type="text" name="info[zipcode]" id="zipcode" class="int" value="<?php echo $info['zipcode']?>"/></td></tr>
       <tr><td align="right">所在省：</td><td><input type="text" name="info[address1]" id="address1" class="int" value="<?php echo $info['address1']?>"/></td></tr>
       <tr><td align="right">所在市：</td><td><input type="text" name="info[address2]" id="address2" class="int" value="<?php echo $info['address2']?>"/></td></tr>
       <tr><td align="right">详细地址：</td><td><textarea name="info[address]" id="address" class="int" style="width:300px; height:50px;"><?php echo $info['address']?></textarea></td></tr>
</table>
        </dd></dl>
<?php }?>
        <dl><dt>用户备注：</dt><dd><textarea name="unote" class="int" style="width:300px; height:50px;"><?php echo $d['unote'] ?></textarea></dd></dl>
        <dl><dt>订单备注：</dt><dd><textarea name="anote" style="width:300px; height:70px;" class="int"><?php echo $d['anote'] ?></textarea></dd><dd class="t">仅在后台管理可见，用于管理员记录交易中的特殊情况备查。</dd></dl>
        <dl><dt>&nbsp;</dt><dd><input type="button" value="提 交" class="btnbig" onclick="orderedit();" /></dd></dl>
        </form>
        </div>
<?php } ?>
<?php if($Gets==''){ ?>
<table width="100%">
  <tr>
    <td>
    <form action="" method="get" id="search">
    <input name="c" type="hidden" value="a_goods" />
     <select name="state" class="searchauto">
      <option value="">全部</option>
      <?php order_state($state,2); ?>
    </select>
    订单号：<input name="orderid" type="text" style="width:120px;" value="<?php echo syClass('syController')->syArgs('orderid',1); ?>" />
    会员ID：<input name="uid" type="text" style="width:60px;" value="<?php echo syClass('syController')->syArgs('uid',1); ?>" />
    <input name="search" type="submit" value="查找" class="btnmini" />
    </form></td>
  </tr><tr><td height="5"></td></tr>
</table>
    <table width="100%" class="tablist">
      <tr class="trbg">
        <td width="150">订单号</td>
        <td width="100">总金额</td>
        <td width="100">优惠金额</td>
        <td width="130">用户</td>
        <td width="120">下单时间</td>
        <td width="110">状态</td>
        <td>操作</td>
      </tr>
    <?php foreach($lists as $v){ ?>
      <tr>
        <td><a href="?c=a_goods&a=orderedit&id=<?php echo $v['id']; ?>"><?php echo $v['orderid']; ?></a></td>
        <td><?php $total=order_goods(unserialize($v['goods']),$v['logistics']);echo $total[1]; ?></td>
        <td><?php echo $v['favorable']; ?></td>
        <td><?php if($v['uid']==0){echo '游客';}else{echo memberinfo($v['uid'],'user');} ?></td>
        <td><?php echo date('Y-m-d H:i',$v['addtime']); ?></td>
        <td><?php order_state($v['state']); ?></td>
        <td><a href="?c=a_goods&a=orderedit&id=<?php echo $v['id']; ?>">编辑</a><?php if($v['state']==0){ ?>&nbsp;&nbsp;<a href="?c=a_goods&a=orderdel&id=<?php echo $v['id']; ?>">删除</a><?php } ?></td>
      </tr>
    <?php } ?>
    </table>
    <table width="100%"><tr><td height="35"><ul class="pages"><?php echo $pages; ?></ul></td></tr></table>
<?php } ?>
<?php if($Gets=='tadd' || $Gets=='tedit'){ ?>
    <ul class="switchs"><li id="s1">基本设置</li><?php if($molds!='member'){?><li id="s2" class="c">选择使用本规格的栏目</li><?php }?></ul>
        <div class="info">
        <form action="?c=a_goods&a=<?php echo $postgo ?>&run=1" method="post">
        <input name="tid" type="hidden" value="<?php echo $d['tid'] ?>" />
        <div id="infos1">
            <dl><dt>规格名称：</dt><dd><input name="name" type="text" class="int" value="<?php echo $d['name'] ?>" /></dd></dl>
            <dl><dt>排序：</dt><dd><input name="orders" type="text" class="int" style="width:30px;" value="<?php if($d!=''){echo $d['orders'];}else{echo '0';} ?>" /></dd><dd class="t">越大越靠前</dd></dl>
            <dl><dt>状态：</dt><dd><input <?php if($d['isshow']==1||$d['isshow']==''){echo 'checked="checked"';} ?> name="isshow" type="radio" value="1" />开启 <input <?php if($d['isshow']=='0'){echo 'checked="checked"';} ?> name="isshow" type="radio" value="0" />关闭</dd></dl>
        </div>
        <div id="infos2" class="none">
            <dl style="border:0;"><dt>所属栏目：</dt><dd><input id="alltype" type="button" value="全选" class="btnmini" onclick="alls('classtype[]','alltype');" style="padding:0" /></dd><dd class="t">选择此规格在哪些栏目启用(可多选)</dd></dl>
            <dl><dt>&nbsp;</dt><dd>
            <?php foreach($typesdb as $v){
            if($v['molds']=='product'){
            ?>
                <?php if($v['n']>0){echo '|';}echo str_repeat('--',$v['n']);?><label><input type="checkbox" name="classtype[]" value="<?php echo $v['tid']; ?>" id="id_<?php echo $v['tid']; ?>" <?php if(strpos($d['classtype'],'|'.$v['tid'].'|')!==FALSE)echo 'checked="checked" '; ?>  onclick="checkboxs('#id_<?php echo $v['tid'];?>','<?php echo $types->leafid($v['tid']);?>','id_');"/><?php echo $v['name'];?></label><br />
            <?php }} ?>
            </dd>
            </dl>
        </div>
        <dl><dt>&nbsp;</dt><dd><input type="submit" value="提 交" class="btnbig" /></dd></dl>
        </form>
        </div>
    </div>
<?php } ?>
<?php if($Gets=='attribute'){ ?>
    <table width="100%" class="tablist">
      <tr class="trbg">
        <td width="40">ID</td>
        <td width="150">操作</td>
        <td>规格名称</td>
        <td width="80">状态</td>
        <td width="220">规格操作</td>
      </tr>
    <?php foreach($lists as $v){ ?>
      <tr>
        <td><?php echo $v['tid']; ?></td>
        <td><a href="?c=a_goods&a=add&tid=<?php echo $v['tid']; ?>">添加选项</a>&nbsp;&nbsp;<a href="?c=a_goods&a=option&tid=<?php echo $v['tid']; ?>">选项管理</a></td>
        <td class="tdleft"><a href="?c=a_goods&a=option&tid=<?php echo $v['tid']; ?>"><?php echo $v['name']; ?></a></td>
        <td><?php if($v['isshow']==1){echo '开启';}else{echo '<span style="color:#C00">关闭</span>';} ?></td>
        <td><a href="?c=a_goods&a=tedit&tid=<?php echo $v['tid']; ?>">编辑</a>&nbsp;&nbsp;<a href="?c=a_goods&a=tdel&tid=<?php echo $v['tid']; ?>">删除</a></td>
      </tr>
    <?php } ?>
    </table>
    </div>
<?php } ?>
<?php if($Gets=='add' || $Gets=='edit'){ ?>
        <div class="info">
        <form action="?c=a_goods&a=<?php echo $postgo ?>&run=1" method="post">
        <input name="sid" type="hidden" value="<?php echo $d['sid'] ?>" />
        <dl><dt>所属规格：</dt><dd><select name="tid">
          <option>选择所属规格</option>
          <?php foreach($attribute_type as $v){ ?>
          <option value="<?php echo $v['tid'] ?>"<?php if($d['tid']==$v['tid']||$ctid==$v['tid'])echo ' selected="selected"'; ?>><?php echo $v['name'] ?></option>
          <?php } ?>
        </select></dd></dl>
        <dl><dt>选项名称：</dt><dd><input name="name" type="text" class="int" value="<?php echo $d['name'] ?>" /></dd></dl>
        <dl><dt>排序：</dt><dd><input name="orders" type="text" class="int" style="width:30px;" value="<?php if($d!=''){echo $d['orders'];}else{echo '0';} ?>" /></dd><dd class="t">越大越靠前</dd></dl>
        <dl><dt>状态：</dt><dd><input name="isshow" type="radio" value="1"<?php if($d['isshow']==1||$d['isshow']=='')echo ' checked="checked"'; ?> />显示&nbsp;<input name="isshow" type="radio" value="0"<?php if($d['isshow']==0 && $Gets=='edit')echo ' checked="checked"'; ?> />关闭</dd></dl>
        <dl><dt>&nbsp;</dt><dd><input type="submit" value="提 交" class="btnbig" /></dd></dl>
        </form>
        </div>
    </div>
<?php } ?>
<?php if($Gets=='option'){ ?>
    <table width="100%" class="tablist">
      <tr class="trbg">
        <td width="40">ID</td>
        <td width="200">所属规格</td>
        <td>选项名称</td>
        <td width="80">状态</td>
        <td width="120">操作</td>
      </tr>
    <?php foreach($lists as $v){ ?>
      <tr>
        <td><?php echo $v['sid']; ?></td>
        <td><?php echo attributetype($v['tid'],'name'); ?></td>
        <td class="tdleft"><a href="?c=a_goods&a=edit&sid=<?php echo $v['sid']; ?>"><?php echo $v['name']; ?></a></td>
        <td><?php if($v['isshow']==1){echo '开启';}else{echo '<span style="color:#C00">关闭</span>';} ?></td>
        <td><a href="?c=a_goods&a=edit&sid=<?php echo $v['sid']; ?>">编辑</a>&nbsp;&nbsp;<a href="?c=a_goods&a=del&sid=<?php echo $v['sid']; ?>">删除</a></td>
      </tr>
    <?php } ?>
    </table>
    </div>
<?php } ?>

<?php if($Gets=='logistics'){ ?>
    	<form action="?c=a_goods&a=logisticsedit" method="post">
    	<div class="info" id="logistics">
        <dl style="border:0"><dd class="t">增删改都需要执行“提交更新”操作才可生效。</dd></dl>
        <?php foreach($lists as $k=>$v){ ?>
        <dl><dt>物流名称：</dt><dd><input name="name[]" type="text" class="int" value="<?php echo $k ?>" /></dd><dd>默认价格：</dd><dd><input name="price[]" type="text" class="int" value="<?php echo $v ?>" style="width:50px;" /> 元</dd><dd onclick="$(this).parent().remove()" style="cursor:pointer; color:#039">[删除]</dd></dl>
        <?php } ?>
        </div>
        <div class="info">
        <dl><dt>&nbsp;</dt><dd><input type="button" onclick="logistics_add()" value="增 加" class="btnbig" /> <input type="submit" value="提交更新" class="btnbig" /></dd></dl>
        </div>
        </form>
    </div>
<?php } ?>
</body>
</html>
