<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.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>
                    <header><i class="fa fa-fw fa-file"></i>查询</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-inline" role="form" method="POST" action="#statistics/moneyinout" name="stanpform">
                                        <input type="hidden" name="fromsta_np" value="1">
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>开始时间</label>
                                            <input type="text" class="form-control datetimepicker" value="<?php if($stime) echo $stime;?>" placeholder="开始时间" name="moneyinout_stime" />
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>结束时间</label>
                                            <input type="text" class="form-control datetimepicker" value="<?php if($etime) echo $etime;?>" placeholder="结束时间" name="moneyinout_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>
                        </div>
                    </section>
                </aside>
            </div>
        </div>

        <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 class="col-sm-12">
                                <div class="form-group">
                                    <label style="font-weight: normal">消耗：<?php echo '('.$inFlowStr.')';?></label>
                                    <label style="font-weight: normal">发放：<?php echo '('.$outFlowStr.')';?></label>
                                    <label style="font-weight: normal">其他：<?php echo '('.$otherFlowStr.')';?></label>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
            </aside>
        </div>

    </div>
</div>
</div>
<script type="text/javascript" src="<?php echo base_url();?>public/js/highcharts/highcharts.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>public/js/highcharts/modules/exporting.js"></script>
<script type="text/javascript">


    var chart = Highcharts.chart('container', {
        title: {
            text: '金币流入流出'
        },
        xAxis: {
            categories: [<?php echo "'".implode("','", $dayList)."'";?>]
        },
        plotOptions: {
            series: {
                stacking: 'normal'
            }
        },
        yAxis: [{ // Primary yAxis
            labels: {
//            format: '{value / 1000}  K',
                formatter: function (){
                    var value = this.value,
                        valueB,valueM, valueK;
                    if(1 < Math.abs(valueB =value / 1000000000)) {
                        return valueB + 'B';
                    }else if(1 < Math.abs(valueM=value / 1000000)) {
                        return valueM + 'M';
                    }else if(1 < Math.abs(valueK = value / 1000)) {
                        return valueK + 'K';
                    }else {
                        return 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: [{
            type: 'column',
            name: '消耗汇总',
            data: [<?php echo implode(",", $inFlowMoney);?>],
            stack: 'inFlowSummary'
        }, {
            type: 'column',
            name: '发放汇总',
            data: [<?php echo implode(",", $outFlowMoney);?>],
            stack: 'outFlowSummary'
        }
        <?php echo $seriesStr;?>
        , {
            type: 'line',
            name: '消耗率(消耗/发放)',
            yAxis: 1,
            data: [<?php echo implode(",", $outFlowPercent);?>],
            tooltip: {
                valueSuffix: '%'
            }
        }]
    });

</script>
<script type="text/javascript">
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });
</script>