<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>
<style type="text/css">
    .col-xs-5ths {
        border: solid lightgray 1px;
        width: 16.66%;
        float:left;
        border-left:none;
        text-align: center;
        height: 110px;
        border-bottom: none;
    }
    .col-xs-5ths:first-child {
        border-left:solid lightgray 1px;
    }
    .header-data {
        font-size: 35px;
        font-weight: 500;
    }
    .col-xs-5ths label {
        font-weight: 500;
        font-size: 18px;
        margin-bottom: 0;
        margin-top:10px;
    }
    .second-row > .col-xs-5ths {
        border-bottom: solid lightgray 1px;
    }
    .section-first {
        margin-left: 15px;
        margin-right: 15px;
    }
    .chart-pos {
        margin-right: -65%;
    }

    @media screen and (max-width:700px) {
        .col-xs-5ths {
            position: relative;
        }
        .col-xs-5ths label {
            font-size: 1rem;
        }

        .header-data {
            font-size: 1.5rem;
            font-weight: bold;
            margin-top: 1rem;
        }

        .chart-pos {
            position: absolute;
            bottom: 9%;
        }
    }
</style>
<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">
                            <form class="form-inline" role="form" method="POST" action="#statistics/giveCardSta" name="stanpform">
                                <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>
                                
                                <button type="submit" class="btn btn-primary">查询</button>
                            </form>
                        </div>
                    </div>
                </div>
            </section>
        </aside>
        <div class="row">
            <div class="col-sm-6">
                <aside>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <aside>
                                        <section>
                                            <div class="container-fluid">
                                                <div class="row">
                                                    <div id="box"></div>
                                                </div>
                                            </div>
                                        </section>
                                    </aside>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
            <div class="col-sm-6">
                <aside>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <aside>
                                        <section>
                                            <div class="container-fluid">
                                                <div class="row">
                                                    <div id="box2"></div>
                                                </div>
                                            </div>
                                        </section>
                                    </aside>
                                </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" src="<?php echo base_url();?>public/js/highcharts/modules/export-data.js"></script>
<script type="text/javascript">
    //设置图表导出格式选项
    Highcharts.setOptions({
        lang: {
            printChart: '打印图表',
            downloadJPEG: '下载 JPEG 文件',
            downloadPDF: '下载 PDF   文件',
            downloadPNG: '下载 PNG  文件',
            downloadSVG: '下载 SVG  文件',
            downloadCSV: '下载 CSV  文件',
            downloadXLS: '下载 XLS   文件',
            viewData: '查看数据表格'
        },
        navigation: {
            menuItemStyle: {
                padding: '6px 14px'
            }
        },
        exporting: {
            url: ''
        },
        credits: {
            text: '',
            url: ''
        }
    });

    $("#box").css("height",($("#box").height() + 2000) + "px");
    $("#box").css("width",$("#box").width() + "px");
    Highcharts.chart('box', {
        chart: {
            type: 'bar'
        },
        title: {
            text: '赠送卡片排行榜 - 天'
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            categories: [<?php 
            	$i = 1;
            	foreach($todaydata as $k => $v){
            		if(count($todaydata) == $i++){
            			echo '"'.$k.'"';
            		}else{
            			echo '"'.$k.'",';
            		}
            		
            	}
            ?>],
            title: {
                text: null
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: '',
                align: 'high'
            },
            labels: {
                overflow: 'justify'
            }
        },
        tooltip: {
            valueSuffix: ''
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true,
                    allowOverlap: true // 允许数据标签重叠
                }
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            x: -40,
            y: 100,
            floating: true,
            borderWidth: 1,
            backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
            shadow: true
        },
        series: [{
            name: '数量',
            data: [<?php echo implode(",",$todaydata); ?>]
        }]
    });
    
	$("#box2").css("height",($("#box2").height() + 2000) + "px");
    $("#box2").css("width",$("#box2").width() + "px");
    Highcharts.chart('box2', {
        chart: {
            type: 'bar'
        },
        title: {
            text: '赠送卡片排行榜 - 全部'
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            categories: [<?php 
            	$i = 1;
            	foreach($alldata as $k => $v){
            		if(count($todaydata) == $i++){
            			echo '"'.$k.'"';
            		}else{
            			echo '"'.$k.'",';
            		}
            		
            	}
            ?>],
            title: {
                text: null
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: '',
                align: 'high'
            },
            labels: {
                overflow: 'justify'
            }
        },
        tooltip: {
            valueSuffix: ''
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true,
                    allowOverlap: true // 允许数据标签重叠
                }
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            x: -40,
            y: 100,
            floating: true,
            borderWidth: 1,
            backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
            shadow: true
        },
        series: [{
            name: '数量',
            data: [<?php echo implode(",",$alldata); ?>]
        }]
    });
</script>

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