<script src="<?php echo $this->basePath('js/plugins/echarts/echarts.min.js'); ?>"></script>
<script src="<?php echo $this->basePath('js/plugins/echarts/theme/shine.js'); ?>"></script>
<div class="content-wrapper">
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>
        <h1 class="pull-right" id="dbshop-menu-top">
            <?php echo $this->HelpUrl('salesStatistics'); ?>
        </h1>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <h2 class="page-header">
                            <?php echo $this->translate('销售情况'); ?>
                        </h2>
                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td><span class="text-bold"><?php echo $this->translate('今日销售额'); ?>：</span><?php echo $this->todayOrderAmount; ?></td>
                                    <td><span class="text-bold"><?php echo $this->translate('本周销售额'); ?>：</span><?php echo $this->weekOrderAmount; ?></td>
                                    <td><span class="text-bold"><?php echo $this->translate('本月销售额'); ?>：</span><?php echo $this->monthOrderAmount; ?></td>
                                    <td><span class="text-bold"><?php echo $this->translate('全部销售额'); ?>：</span><?php echo $this->orderAmount; ?></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="row">
                            <?php
                            $form = $this->form;
                            $form->prepare();
                            echo $this->form()->openTag($form);
                            ?>
                            <div class="col-xs-5 text-right">
                                <a href="<?php echo $this->url('analysis', ['action' => 'salesStatistics'], ['query' => ['type' => 'week', 'userGroupId' => $form->get('userGroupId')->getValue()]]); ?>" class="btn <?php echo $this->type == 'week' ? 'btn-primary' : 'btn-default'; ?>"><?php echo $this->translate('本周'); ?></a>
                                &nbsp;&nbsp;
                                <a href="<?php echo $this->url('analysis', ['action' => 'salesStatistics'], ['query' => ['type' => 'month', 'userGroupId' => $form->get('userGroupId')->getValue()]]); ?>" class="btn <?php echo $this->type == 'month' ? 'btn-primary' : 'btn-default'; ?>"><?php echo $this->translate('本月'); ?></a>
                            </div>
                            <div class="col-xs-2">
                                <?php echo $this->formElement($form->get('userGroupId')); ?>
                            </div>
                            <div class="col-xs-2">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="fa fa-calendar" aria-hidden="true"></i></span>
                                    <?php echo $this->formElement($form->get('startDate')); ?>
                                </div>
                            </div>
                            <div class="col-xs-2">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="fa fa-calendar" aria-hidden="true"></i></span>
                                    <?php echo $this->formElement($form->get('endDate')); ?>
                                </div>
                            </div>
                            <div class="col-xs-1">
                                <button type="submit" class="btn btn-info"><?php echo $this->translate('查看'); ?></button>
                            </div>
                            <?php echo $this->form()->closeTag(); ?>
                        </div>
                        <div id="sales_chart" style="width: 100%;height: 400px;margin-top: 40px;">
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </section>
</div>
<script type="text/javascript">
    laydate.render({elem: '#startDate'});
    laydate.render({elem: '#endDate'});

    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('sales_chart'), 'shine');
    option = {
        title: {
            text: '<?php echo $this->translate('销售走势图表'); ?>'
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        legend: {
            data:['<?php echo $this->translate('销售金额'); ?>']
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis : [
            {
                type : 'category',
                data : [<?php echo $this->dataStr; ?>]
            }
        ],
        yAxis : [
            {
                type : 'value'
            }
        ],
        series : [
            {
                name:'<?php echo $this->translate('销售额'); ?>',
                type:'bar',
                data:[<?php echo $this->orderAmountStr; ?>]
            }
        ]
    };
    myChart.setOption(option);
</script>