{include file="public/header" /}
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.order_manage}</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
    <div class="fixed-empty"></div>
    <form method="get" action="" name="formSearch" id="formSearch">
        <table class="search-form">
            <tbody>
                <tr>
                    <th><label>{$Think.lang.order_number}</label></th>
                    <td><input class="txt2" type="text" name="order_sn" value="{$Think.get.order_sn}" /></td>
                    <th>{$Think.lang.store_name}</th>
                    <td><input class="txt-short" type="text" name="store_name" value="{$Think.get.store_name}" /></td>
                    <th><label>{$Think.lang.order_state}</label></th>
                    <td colspan="4"><select name="order_state" class="querySelect">
                            <option value="">{$Think.lang.ds_please_choose}</option>
                            <option value="10" {if condition="$Think.get.order_state eq '10'"}selected{/if}>{$Think.lang.order_state_new}</option>
                            <option value="20" {if condition="$Think.get.order_state eq '20'"}selected{/if}>已付款</option>
                            <option value="40" {if condition="$Think.get.order_state eq '40'"}selected{/if}>{$Think.lang.order_state_success}</option>
                            <option value="0" {if condition="$Think.get.order_state eq '0'"}selected{/if}>{$Think.lang.order_state_cancel}</option>
                        </select></td>

                </tr>
                <tr>
                    <th><label for="query_start_time">{$Think.lang.order_time_from}</label></th>
                    <td><input class="txt date" type="text" value="{$Think.get.query_start_time}" id="query_start_time" name="query_start_time">
                        <label for="query_start_time">~</label>
                        <input class="txt date" type="text" value="{$Think.get.query_end_time}" id="query_end_time" name="query_end_time"/></td>
                    <th>{$Think.lang.buyer_name}</th>
                    <td><input class="txt-short" type="text" name="buyer_name" value="{$Think.get.buyer_name}" /></td> <th>付款方式</th>
                    <td>
                        <select name="payment_code" class="w100">
                            <option value="">{$Think.lang.ds_please_choose}</option>
                            <?php foreach($payment_list as $val) { ?>
                            <?php if ($val['payment_code'] == 'offline') continue;?>
                            <option {if condition="$Think.get.payment_code eq $val.payment_code"}selected{/if} value="<?php echo $val['payment_code']; ?>"><?php echo $val['payment_name']; ?></option>
                            <?php } ?>
                        </select>
                    </td>
                    <td>
                        <input type="submit" id="submit" value="{$Think.lang.ds_query}">
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
    <div class="explanation" id="explanation">
        <div class="title" id="checkZoom">
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span id="explanationZoom" title="收起提示" class="arrow"></span>
        </div>
        <ul>
            <li>点击查看操作将显示订单（包括电子兑换码）的详细信息</li>
            <li>未付款的订单可以点击取消操作来取消订单</li>
            <li>如果平台已确认收到买家的付款，但系统支付状态并未变更，可以点击收到货款操作，并填写相关信息后更改订单支付状态</li>
        </ul>
    </div>


    <div style="text-align:right;"><a class="btns" target="_blank" href="index.php?<?php echo $_SERVER['QUERY_STRING'];?>&op=export_step1"><span>{$Think.lang.ds_export}Excel</span></a></div>
    <table class="ds-default-table">
        <thead>
            <tr class="thead">
                <th>{$Think.lang.order_number}</th>
                <th>{$Think.lang.store_name}</th>
                <th>{$Think.lang.buyer_name}</th>
                <th class="align-center">{$Think.lang.order_time}</th>
                <th class="align-center">{$Think.lang.order_total_price}</th>
                <th class="align-center">{$Think.lang.payment}</th>
                <th class="align-center">{$Think.lang.order_state}</th>
                <th class="align-center">{$Think.lang.ds_handle}</th>
            </tr>
        </thead>
        <tbody>
            <?php if(count($order_list)>0){?>
            <?php foreach($order_list as $order){?>
            <tr class="hover">
                <td><?php echo $order['order_sn'];?></td>
                <td><?php echo $order['store_name'];?></td>
                <td><?php echo $order['buyer_name'];?></td>
                <td class="nowrap align-center"><?php echo date('Y-m-d H:i:s',$order['add_time']);?></td>
                <td class="align-center"><?php echo $order['order_amount'];?></td>
                <td class="align-center"><?php echo orderPaymentName($order['payment_code']);?></td>
                <td class="align-center"><?php echo $order['state_desc'];?></td>
                <td class="w144 align-center"><a href="{:url('/Admin/Vrorder/show_order',['order_id'=>$order.order_id])}">{$Think.lang.ds_view}</a>

                    <!-- 取消订单 -->
                    <?php if($order['if_cancel']) {?>
                    | <a href="javascript:void(0)" onclick="if (confirm('{$Think.lang.order_confirm_cancel}')) {
                                location.href = '{:url(' / Admin / Vrorder / change_state',['state_type'=>'cancel','order_id'=>$order.order_id])}'
                            }">
                        {$Think.lang.order_change_cancel}</a>
                    <?php }?>

                    <!-- 收款 -->
                    <?php if($order['if_system_receive_pay']) {?>
                    | <a href="{:url('/Admin/Vrorder/change_state',['state_type'=>'receive_pay','order_id'=>$order.order_id])}">
                        {$Think.lang.order_change_received}</a>
                    <?php }?>
                </td>
            </tr>
            <?php }?>
            <?php }else{?>
            <tr class="no_data">
                <td colspan="15">{$Think.lang.ds_no_record}</td>
            </tr>
            <?php }?>
        </tbody>
        <tfoot>
            <tr class="tfoot">
                <td colspan="15" id="dataFuncs">{$show_page}</td>
            </tr>
        </tfoot>
    </table>
</div>
<script type="text/javascript">
    $(function () {
        $('#query_start_time').datepicker({dateFormat: 'yy-mm-dd'});
        $('#query_end_time').datepicker({dateFormat: 'yy-mm-dd'});
    });
</script> 
