<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">
    	<aside>
            <header><i class="fa fa-fw fa-file"></i>发放&消耗</header>
            <section>
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-sm-12">
                            <a style="margin:5px;" class="btn btn-primary " href="#statistics/assetsSta/1" role="button">金币</a>
                            <a style="margin:5px;" class="btn btn-primary " href="#statistics/assetsSta/2" role="button">体力</a>
                            <a style="margin:5px;" class="btn btn-primary " href="#statistics/assetsSta/5" role="button">钻石</a>
                            <a style="margin:5px;" class="btn btn-primary " href="#statistics/assetsSta/3" role="button">净消耗曲线</a>
                        </div>
                    </div>
                </div>
            </section>
        </aside>
        <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/assetsSta/<?php echo $type?>" name="stanpform">
                                        <input type="hidden" name="moneyinout_post" 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>
</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">

    Highcharts.chart('container', {
        chart: {
            type: 'line'
        },
        title: {
            text: '金币体力钻石消耗曲线'
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            categories: [<?php foreach ($data as $key=>$row){ echo '"'.$row['date'].'",';}?>]
        },
        yAxis: [{ // Primary yAxis
            labels: {
                format: '{value}',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            title: {
                text: '金币数值',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            }
        }, { // Primary yAxis
            labels: {
                format: '{value}',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            title: {
                text: '体力数值',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            opposite: true
        }, { // Primary yAxis
            labels: {
                format: '{value}',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            title: {
                text: '钻石数值',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            opposite: true
        }],
        plotOptions: {
            line: {
                dataLabels: {
                    enabled: true
                },
                enableMouseTracking: false
            }
        },
        series: [
            {
                name:'金币',
                data:[<?php foreach ($data as $key=>$row){ echo array_sum($row['money']['low']) - array_sum($row['money']['add']).',';}?>]
            },
            {
                name:'体力',
                yAxis: 1,
                data:[<?php foreach ($data as $key=>$row){ echo array_sum($row['spins']['low']) - array_sum($row['spins']['add']).',';}?>]
            },
            {
                name:'钻石',
                yAxis: 2,
                data:[<?php foreach ($data as $key=>$row){ echo array_sum($row['diamond']['low']) - array_sum($row['diamond']['add']).',';}?>]
            },
            {
                name:'人均净消耗金币',
                yAxis: 1,
                data:[<?php foreach ($data as $key=>$row){
                	if(empty($row['todayLogin'])){
                		echo "0,";
                	}else{
                		echo round(((array_sum($row['money']['low']) - array_sum($row['money']['add'])) / $row['todayLogin']),2).',';
                	}
                }?>]
            },
            {
                name:'人均净消耗钻石',
                yAxis: 1,
                data:[<?php foreach ($data as $key=>$row){
                	if(empty($row['todayLogin'])){
                		echo "0,";
                	}else{
                		echo round(((array_sum($row['diamond']['low']) - array_sum($row['diamond']['add'])) / $row['todayLogin']),2).',';
                	}
                }?>]
            },
            {
                name:'人均净消耗体力',
                yAxis: 1,
                data:[<?php foreach ($data as $key=>$row){
                	if(empty($row['todayLogin'])){
                		echo "0,";
                	}else{
                		echo round(((array_sum($row['spins']['low']) - array_sum($row['spins']['add'])) / $row['todayLogin']),2).',';
                	}
                }?>]
            }
        ]
    });


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