<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/plugins/datatables/jquery.dataTables.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/plugins/datatables/extensions/Responsive/css/dataTables.responsive.css">
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-inline" role="form" method="POST" action="#payment/orderStatusSummary" id="totalForm">

                                        <span class="gap"></span>
                                        <div class="form-group">
                                                <label>开始时间: </label>
                                                <input type="text" class="form-control datetimepicker" value="<?=$stime;?>" placeholder="开始时间" name="stime" />
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                                <label>结束时间: </label>
                                                <input type="text" class="form-control datetimepicker" value="<?=$etime;?>" placeholder="结束时间" name="etime" />
                                        </div>
                                        <button type="submit" class="btn btn-primary">查询</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        <!--图表-->
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>订单状态汇总</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
                            </div>
                            <button type="button" class="btn btn-primary" id="all_checked1">全选</button>
                            <button type="button" class="btn btn-primary" id="all_no_checked1">全不选</button>
                            <button type="button" class="btn btn-primary" onclick="initContainer()">折线图</button>
                            <button type="button" class="btn btn-primary" onclick="initContainer('column')">柱形图</button>
                        </div>
                    </section>
                </aside>
            </div>
        </div>

    </div>

</div>
<script type="text/javascript" src="<?php echo base_url();?>public/js/highcharts/highcharts.js"></script>
<script src="<?php echo base_url();?>public/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/validate/jquery.validate-1.15.0.min.js"></script>
<!--<script src="--><?php //echo base_url();?><!--public/js/payment/total.js"></script>-->
<script>
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });

    var chart1 = null;
    initContainer();
    function initContainer(type = 'line') {
        chart1 = Highcharts.chart('container', {
            chart: {
                // zoomType: 'xy'
                type: type
            },
            title: {
                text: '订单状态汇总'
            },
            subtitle: {
                text: '左坐标轴数量，右坐标轴百分比'
            },
            xAxis: [{
                categories: [<?php echo "'" . implode("','", $dayList) . "'";?>],
                crosshair: true
            }],
            yAxis: [
                { // Primary yAxis
                    labels: {
                        format: '{value}',
                        style: {
                            color: Highcharts.getOptions().colors[1]
                        }
                    },
                    title: {
                        text: '数值',
                        style: {
                            color: Highcharts.getOptions().colors[1]
                        }
                    }
                }
                // , { // Secondary yAxis
                //     title: {
                //         text: '百分比',
                //         style: {
                //             color: Highcharts.getOptions().colors[1]
                //         }
                //     },
                //     labels: {
                //         format: '{value} %',
                //         style: {
                //             color: Highcharts.getOptions().colors[1]
                //         }
                //     },
                //     opposite: true
                // }
            ],
            tooltip: {
                shared: true
            },

            series: [
                <?php foreach ($formatOrders as $status => $rowData){ ?>
                {
                    name: '<?=$statusMap[$status] ?? $status?>',
                    data: [<?php echo implode(",", $rowData);?>],
                    tooltip: {
                        valueSuffix: ''
                    }
                },
                <?php } ?>
            ]
        });
    }
</script>
