<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/cardSourceSta">
                                        <span class="gap"></span>
                                        
                                        <div class="form-group">
                                            <label>查询玩家:</label>
                                            
                                            <input type="text" class="form-control" value="<?php if($uid) echo $uid;?>" placeholder="uid" name="uid" />
                                        </div>
                                        <span class="gap"></span>
                                        <button type="submit" class="btn btn-primary">查询</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
            <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="/#statistics/cardSourceSta">
                                    	<input type="hidden" value="1" name="payuserpost"/>
                                        <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: 600px; margin: 0 auto"></div>
                            </div>
                        </div>
                    </section>
                </aside>
            </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 id="container2" style="min-width: 310px; height: 600px; margin: 0 auto"></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">
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });
	
		
	// 构建图表
	var chartSum = Highcharts.chart('container',{
		title: {
			text: '总值<?php echo array_sum($total);?>'
		},
		tooltip: {
			pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
		},
		plotOptions: {
			pie: {
				allowPointSelect: true,
				cursor: 'pointer',
				dataLabels: {
					enabled: true,
					format: '<b>{point.name}</b>: {point.percentage:.1f} %',
					style: {
						color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
					},
					connectorColor: 'silver'
				}
			}
		},
		series: [{
			type: 'pie',
			name: '占比',
			data: [
				<?php
					foreach($type as $k => $v){
				?>
				{
					name: '<?php echo $v; ?>',
					sliced: true,
					selected: true,
					y:<?php echo ($total[$k] / array_sum($total)); ?>
				},
				<?php
					}
				?>
			]
		}]
	});
	
	var chart = Highcharts.chart('container2', {
        chart: {
            type: 'column'
        },
        title: {
            text: ''
        },
        xAxis: {
            categories: [<?php 
            	foreach($date as $k => $v){
            		echo $v.",";
            	}
            ?>]
        },
        yAxis: {
            allowDecimals: false,
            min: 0,
            title: {
                text: '数量'
            }
        },
        tooltip: {
            formatter: function () {
                return '<br/>' +
                    this.series.name + ': ' + this.y + '<br/>' +
                    '总量: ' + this.point.stackTotal;
            }
        },
        plotOptions: {
            column: {
                stacking: 'normal'
            }
        },
        series: [<?php foreach ($type as $k => $v){
        		
        	?>
            {
                name: '<?php echo $v;?>',
                data: [<?php 
                	foreach($data as $d_k => $d_v){
                		if(isset($d_v[$k])){
                			echo $d_v[$k].",";
                		}else{
                			echo "0,";
                		}
                	}
                ?>],
                stack: '成功' // stack 值相同的为同一组
            },
            <?php 
        		}
        	?>
        ]
    });
</script>