<#assign title="按时间统计">
<#include "/admin/head.ftl">
<section class="vbox">
    <section class="scrollable wrapper">
        <div class="panel panel-default">
            <div class="panel-body">
                <form id="theform" name="theform" onsubmit="return false;">
                    <div class="row">

                        <div class="col-xs-12 col-sm-6 col-md-3 form-group">
                            <div class="input-group">
                                <label class="input-group-addon" for="saleName1">销售</label>
                                <input type="text" id="saleName" name="saleName" class="form-control"></input>
                            </div>
                        </div>

                        <div class="col-xs-12 col-sm-6 col-md-3 form-group">
                            <div class="input-group">
                                <label class="input-group-addon" for="orderStartAt">开始时间</label>
                                <input type="date" id="orderStartAt" name="orderStartAt" class="form-control"></input>
                            </div>
                        </div>

                        <div class="col-xs-12 col-sm-6 col-md-3 form-group">
                            <div class="input-group">
                                <label class="input-group-addon" for="orderEndAt">结束时间</label>
                                <input type="date" id="orderEndAt" name="orderEndAt" class="form-control"></input>
                            </div>
                        </div>

                        <div class="col-xs-12 col-sm-6 col-md-3 form-group">
                            <div class="input-group">
                                <label class="input-group-addon" for="roomName">包厢</label>
                                <input type="text" id="roomName" name="roomName" class="form-control"></input>
                            </div>
                        </div>

                        <div class="col-xs-12 col-sm-6 col-md-3 form-group">
                            <div class="input-group">
                                <label class="input-group-addon" for="customerName">客户</label>
                                <input type="text" id="customerName" name="customerName" class="form-control"></input>
                            </div>
                        </div>

                        <div class="col-xs-12 col-sm-6 col-md-3 form-group">
                            <div class="input-group">
                                <label for="statistics" class="input-group-addon">统计方式</label>
                                <select id="statistics" name="statistics" class="form-control">
                                    <option value="D">按天统计</option>
                                    <option value="W">按周统计</option>
                                    <option value="M">按月度统计</option>
                                    <option value="Q">按季度统计</option>
                                    <option value="Y">按年度统计</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 col-sm-6 col-md-3 form-group">
                            <button id="searchOrder" type="button" class="btn btn-success btn-s-xs">查询</button>
                        </div>
                    </div>
                </form>
                <table id="thetable"></table>
            </div>
        </div>
    </section>
</section>
<#include "/admin/foot.ftl">
<script>
    initTable();
    $('#searchOrder').click(function () {
        initTable();
    });

    function responseHandler(root) {
        return { "total": root.pagination.count, "rows": root.data };
    }


    function initTable() {
        $('#thetable').bootstrapTable('destroy').bootstrapTable({
            url: '/admin/statistics_order_search.json',
            method: 'get',
            queryParams: function (params) {
                $('#theform').serializeArray().forEach(function fn(v) {
                    params[v.name] = v.value;
                });
                return params;
            },
            responseHandler: responseHandler,
            idField: 'times',
            exportDataType: 'all',
            exportTypes: ['txt', 'excel'],
            dataShowExport: true,
            search: false,
            sortStable: false,
            sidePagination: 'server',
            pagination: true,
            columns: [
                {
                    field: 'times',
                    title: '时间'
                }, {
                    field: 'orderCount',
                    title: '订单数量'
                }, {
                    field: 'totalAmount',
                    title: '消费金额合计'
                }, {
                    field: 'totalCommission',
                    title: '佣金合计'
                }, {
                    field: 'activeRoomCount',
                    title: '活跃包厢数量'
                }
            ]
        });
    }
</script>

