#@layout()

#define script()
<script>

    function deliver(id) {
        openlayer('发货','#(CPATH)/admin/order/deliver/'+id);
    }

    function openlayer(title,url) {
        layer.data = {};
        layer.open({
            type: 2,
            title: title,
            anim: 2,
            shadeClose: true,
            shade: 0.5,
            area: ['70%', '90%'],
            content: url,
            end: function () {
                if (layer.data.needRefresh){
                    location.reload();
                }
            }
        });
    }

</script>
#end

#define content()
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            订单列表
            <small>Order List</small>
        </h1>
    </section>

    <section class="content-header text-tap">
        <div class="row">

            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-red">
                    <div class="inner">
                        <h3>#(todayOrderCount ?? 0)</h3>

                        <p>今日订单</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-pie-graph"></i>
                    </div>
                </div>
            </div>
            <!-- ./col -->

            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-aqua">
                    <div class="inner">
                        <h3>#(monthOrderCount ?? 0)</h3>

                        <p>本月订单</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-bag"></i>
                    </div>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-green">
                    <div class="inner">
                        <h3>#(mouthPaymentAmount ?? 0)</h3>

                        <p>本月销售</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-stats-bars"></i>
                    </div>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-yellow">
                    <div class="inner">
                        <h3>#(mountOrderUserCount ?? 0)</h3>

                        <p>本月购买用户</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-person"></i>
                    </div>
                </div>
            </div>
            <!-- ./col -->

        </div>

    </section>

    <section class="content">

        <div class="row">
            <div class="col-xs-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <form class="form-horizontal actionPanel" action="#(CPATH)/admin/order" method="get">
                            <div class="row">
                                <div class="form-group col-xs-4">
                                    <label class="col-sm-3 control-label">商品</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" name="productTitle" value="#(productTitle)">
                                    </div>
                                </div>
                                <div class="form-group col-xs-4">
                                    <label class="col-sm-3 control-label">订单号</label>
                                    <div class="col-sm-9">
                                        <input class="form-control" name="ns" value="#(ns)">
                                    </div>
                                </div>
                                <div class="form-group col-xs-4">
                                    <button type="submit" class="btn btn-primary ">查询</button>
                                    <button type="reset" class="btn btn-default">重置</button>
                                    <a class="btn"> 更多<i class="fa fa-fw fa-angle-down"></i> </a>
                                </div>
                            </div>
                            <!-- /.box-body -->
                        </form>

                    </div>
                    <!-- /.box-header -->
                    <div class="box-body ">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th style="text-align: center">商品</th>
                                <th style="text-align: center">数量</th>
                                <th style="text-align: center">单价</th>
                                <th style="text-align: center">总价</th>
                                <th style="text-align: center">操作</th>
                            </tr>


                            #for(order : page.list ??)
                            <tr>
                                <td colspan="5" bgcolor="#fff">
                                    <div class="box box-dashboard" style="margin-bottom: 0px">
                                        <div class="box-header with-border row">
                                            <div class="col-lg-10">
                                                订单号：#(order.ns ??)
                                                #if(order.isFinished())
                                                （<span style="">#(order.tradeStatusStr ??)</span>）
                                                #elseif(order.isPaySuccess() )
                                                （<span style="color:green">#(order.tradeStatusStr ??)</span>）
                                                #elseif(order.isClosed())
                                                (<span>#(order.tradeStatusStr ??)</span>）
                                                #else
                                                （<span style="color:red">#(order.tradeStatusStr ??)</span>）
                                                #end

                                                总金额：<span style="padding-right: 20px">#(order.orderRealAmount ??)</span>

                                                #if(order.isPaySuccess() || order.isClosed())
                                                支付状态：<span style="padding-right: 20px">#(order.payStatusStr ??)</span>
                                                #else
                                                支付状态：<span style="color:red;padding-right: 20px">#(order.payStatusStr ??)</span>
                                                #end

                                                #if(order.isDeliveried() || order.isClosed())
                                                物流状态：<span style="padding-right: 20px">#(order.deliveryStatusStr ??)</span>
                                                #else
                                                物流状态：<span style="color:red;padding-right: 20px">#(order.deliveryStatusStr ??)</span>
                                                #end

                                                发票状态：<span style="padding-right: 20px">#(order.invoiceStatusStr ??)</span>
                                            </div>
                                            <div class="col-lg-2" style="text-align: right">
                                                <h3 class="box-title">
                                                    #if(!order.isUnpay() && !order.isClosed() && !order.isDeliveried())
                                                    <a href="javascript:;" onclick="deliver('#(order.id)')">发货</a>
                                                    #end
                                                    <a href="#(CPATH)/admin/order/detail/#(order.id)">详情</a>
                                                </h3>
                                            </div>
                                        </div>
                                        <!-- /.box-header -->
                                        <div class="box-body no-padding">
                                            <table class="table table-striped">
                                                <tbody>
                                                #for(item : order.items)
                                                <tr>
                                                    <td style="width: 20%;text-align: center">
                                                        #(item.product_title ??)
                                                    </td>
                                                    <td style="width: 20%;text-align: center">
                                                        #(item.product_count ??)
                                                    </td>
                                                    <td style="width: 20%;text-align: center">
                                                        #(item.product_price ??)
                                                    </td>
                                                    <td style="width: 20%;text-align: center">
                                                        #(item.product_price * item.product_count ??)
                                                    </td>
                                                    <td style="width: 20%;text-align: center">
                                                        --
                                                    </td>
                                                </tr>
                                                #end
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            #end

                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <div class="row">
                            <div class="col-sm-12">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.box -->
            </div>
        </div>

    </section>


</div>
#end
