<link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/plugins/datatables/jquery.dataTables.min.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/plugins/datatables/extensions/Responsive/css/dataTables.responsive.css">
<div class="content_wrapper">
    <div id="msg-tip"></div>

    <style>
        .change {
            background: lightgoldenrodyellow;
        }
        .td-nowrap {
            white-space: nowrap;
        }
    </style>

    <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/ltv/2" >
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>开始时间</label>
                                            <input type="text" class="form-control datetimepicker" value="<?php echo $stime?>" placeholder="开始时间" name="stime" />
                                        </div
                                        <span class="gap"></span>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>结束时间</label>
                                            <input type="text" class="form-control datetimepicker" value="<?php echo $etime?>" placeholder="结束时间" name="etime" />
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>类型:</label>
                                            <select  name="flag" id="flag" class="selectpicker show-tick form-control">
                                                <option value="1" <?php echo $flag == 1 ? "selected" : ""; ?> >--全部--</option>
                                                <option value="2" <?php echo $flag == 2 ? "selected" : ""; ?>>安卓</option>
                                                <option value="3" <?php echo $flag == 3 ? "selected" : ""; ?>>IOS</option>
                                            </select>
                                        </div>
                                        <span class="gap"></span>
                                        <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>LTV统计</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>


<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>
<script src="<?php echo base_url();?>public/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url();?>public/plugins/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<script src="<?php echo base_url();?>public/js/common.js?version=1"></script>
<script type="text/javascript">
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });

    var chart = Highcharts.chart('container', {
        chart: {
            zoomType: 'xy'
        },
        title: {
            text: 'LTV统计'
        },
        subtitle: {
            text: '左坐标轴数量，右坐标轴百分比'
        },
        xAxis: [{
            categories: [<?php echo "'".implode("','", $dayList)."'";?>],
            crosshair: true
        }],
        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
        }],
        tooltip: {
            shared: true
        },
        plotOptions: {
            spline: {
                marker: {
                    enabled: true
                }
            }
        },
        series: [
            <?php foreach([1,3,7,30,60,90] as $num){ ?>
            {
            name: 'LTV<?php echo $num; ?>',
            data: [
                <?php foreach ($dayList as $day){
                    if(empty($data[$day]['ltv'.$num])){
                        echo "[".$day.",0],";
                    }else{
                        echo "[".$day.",".$data[$day]['ltv'.$num]."],";
                    }
            } ?>
            ],
            },
            <?php } ?>
        ]
    });
</script>