<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>Vip开通人数</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div id="container1" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
            
            <div class="col-sm-12">
                <div class="table-responsive">
                    <table id="reportTable" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                        <thead>
                            <tr>
                                <th style="text-align: center;vertical-align: middle;">等级</th>
								<?php
									foreach($data as $k => $v){
										echo '<th style="text-align: center;vertical-align: middle;">'.$k.'</th>';
									}
								?>
                                <th style="text-align: center;vertical-align: middle;">合计</th>
                            </tr>
                        
                        </thead>
                        <tbody id="reportBody">
                        	<tr>
                        		<th style="text-align: center;vertical-align: middle;">已开通</th>
                        		<?php
									foreach($data as $k => $v){
										echo '<td style="text-align: center;vertical-align: middle;">'.$v.'</td>';
									}
								?>
                        		<td style="text-align: center;vertical-align: middle;"><?php echo array_sum($data); ?></td>
                        	</tr>
                        	<tr>
                        		<th style="text-align: center;vertical-align: middle;">未开通</th>
                        		<?php
									foreach($data2 as $k => $v){
										echo '<td style="text-align: center;vertical-align: middle;">'.$v.'</td>';
									}
								?>
                        		<td style="text-align: center;vertical-align: middle;"><?php echo array_sum($data2); ?></td>
                        	</tr>
                        	<tr>
                        		<th style="text-align: center;vertical-align: middle;">开通率</th>
                        		<?php
									foreach($data as $k => $v){
										echo '<td style="text-align: center;vertical-align: middle;">'.(empty($v) || empty($data2[$k])?0:round($v / ($v + $data2[$k]) * 100,2)).'%</td>';
									}
								?>
                        		<td style="text-align: center;vertical-align: middle;"></td>
                        	</tr>
                        	<tr>
                        		<th style="text-align: center;vertical-align: middle;">合计</th>
                        		<?php
									foreach($data as $k => $v){
										echo '<td style="text-align: center;vertical-align: middle;">'.($v+$data2[$k]).'</td>';
									}
								?>
                        		<td style="text-align: center;vertical-align: middle;"><?php echo array_sum($data2)+array_sum($data); ?></td>
                        	</tr>
                        </tbody>
                    </table>
                </div>
            </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('container1', {
        chart: {
            type: 'line'
        },
        title: {
            text: 'Vip开通人数'
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            categories: [<?php echo implode(",",array_keys($data)); ?>]
        },
        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
	    }],
        series: [
            {
                name:'已开通',
                data:[<?php echo implode(',',$data); ?>]
            },{
                name:'未开通',
                data:[<?php echo implode(',',$data2); ?>]
            },{
		        name: '开通率',
		        yAxis: 1,
		        data: [<?php
			        foreach($data as $k => $v){
		        		if(empty($v) || empty($data2[$k])){
		        			echo "0,";
		        		}else{
		        			echo round($v / ($v + $data2[$k]) * 100,2).",";
		        		}
			        }
		        ?>],
		        tooltip: {
		            valueSuffix: '%'
		        }
		    }
        ]
    });


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