<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/levelPaySta" name="stanpform">
                                        <input type="hidden" name="payuserpost" 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="payuserindex_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="payuserindex_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>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>
</div>
<!--<script type="text/javascript" src="--><?php //echo base_url().'public/js/chart/chart.js';?><!--"></script>-->
<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 chart1 = Highcharts.chart('container', {
        chart: {
            type: 'line'
        },
        title: {
            text: '关卡付费统计'
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            categories: [<?php echo "'".implode("','", $levelRange)."'";?>]
        },
        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
        }],
        plotOptions: {
            line: {
                dataLabels: {
                    enabled: true
                },
                enableMouseTracking: false
            }
        },
        series: [{
            name: '关卡付费总额',
            data: [<?php echo implode(",", $totalMoney);?>]
        },{
            name: '关卡付费订单数',
            data: [<?php echo implode(",", $totalRecord);?>]
        },{
            name: '首充次数订单数',
            data: [<?php echo implode(",", $firstNum);?>]
        },{
            name: '首次付费订单数',
            data: [<?php echo implode(",", $firstPayNum);?>]
        },{
            name: '付费人数',
            data: [<?php echo implode(",", $payLevel);?>]
        },{
            name: '付费率(%)',
            data: [<?php 
            	foreach($levelNum as $k => $v){
            		if(empty($payLevel[$k]) || empty($v)){
            			echo '0,';
            		}else{
            			echo round(($payLevel[$k]/$v)*100,2).',';
            		}
            	}
            ?>],
            yAxis: 1,
            tooltip: {
                valueSuffix: '%'
            }
        },{
            name: '首次付费率(%)',
            data: [<?php 
            	foreach($firstPayNum as $k => $v){
            		if(empty($totalRecord[$k]) || empty($v)){
            			echo '0,';
            		}else{
            			echo round(($v/$totalRecord[$k])*100,2).',';
            		}
            	}
            ?>],
            yAxis: 1,
            tooltip: {
                valueSuffix: '%'
            }
        }]
    });
	
	$(document).on("click","#all_checked1",function(){
    	$(".highcharts-legend-item").each(function(index){
    		chart1.series[index].show();//显示
    	})
    })
    $(document).on("click","#all_no_checked1",function(){
    	$(".highcharts-legend-item").each(function(index){
    		chart1.series[index].hide();//隐藏
    	})
    })

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