<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">
                                    <a style="margin:5px;" class="btn btn-primary <?php if($type != 1){echo 'active';}?>" href="#remain/tableIndex" role="button">表格</a>
                                    <a style="margin:5px;" class="btn btn-primary <?php if($type == 1){echo 'active';}?>" href="#remain/index" role="button">图表</a>
                                    <a style="margin:5px;" class="btn btn-primary <?php if($type == 1){echo 'active';}?>" href="#remain/remainGuestFb" role="button">游客/FB</a>
                                    <a style="margin:5px;" class="btn btn-primary <?php if($type == 1){echo 'active';}?>" href="#remain/remainGuestFb/2" role="button">VIVO</a>
                                </div>
                            </div>
                        </div>
                    </section>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-inline" role="form" method="POST" action="#statistics/remainGuestFb" name="stanpform">
                                        <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="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="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>用户留存 VIVO</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 class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>用户留存 VIVO</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <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 rowspan="2" style="text-align: center;vertical-align: middle;">日期</th>
                                                <th rowspan="2" style="text-align: center;vertical-align: middle;">类型</th>
                                                <th colspan="7" style="text-align: center;vertical-align: middle;">新增玩家</th>
                                                <th colspan="7" style="text-align: center;vertical-align: middle;">活跃玩家</th>
                                            </tr>
                                            <tr>
                                                <?php
                                                foreach(['新增','活跃'] as $name){
                                                    foreach($config as $val){
                                                        echo '<th style="text-align: center;vertical-align: middle;">'.$name.$val.'留存</th>';
                                                    }
                                                }
                                                ?>
                                            </tr>
                                            </thead>
                                            <tbody id="reportBody" style="overflow-y: scroll;">
                                            <?php
                                            if(is_array($date)){
                                                foreach ($date as $val) {
                                                    ?>
                                                    <tr>
                                                        <?php echo '<td style="text-align: center;vertical-align: middle;">'.$val.'</td>'; ?>
                                                        <td>VIVO</td>
                                                        <?php
                                                        foreach(['Remain'=>'新增','ActRemain'=>'活跃'] as $key => $name){
                                                            foreach ($config as $r) {
                                                                echo '<td>'.$data[$val][3]['day'.$r.$key].'</td>';
                                                            }
                                                        }
                                                        ?>
                                                    </tr>
                                                <?php } } else{?>
                                                <tr>
                                                    <td colspan="10">暂无数据</td>
                                                </tr>
                                            <?php } ?>
                                            </tbody>

                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </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">
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });

    Highcharts.chart('container', {
        chart: {
            type: 'line'
        },
        title: {
            text: '用户留存 VIVO'
        },
        subtitle: {
            text: ''
        },
        xAxis: {
            categories: [<?php
                foreach(['新增','活跃'] as $name){
                    foreach($config as $val){
                        echo "'".$name.$val."',";
                    }
                }
                ?>]
        },
        yAxis: {
            title: {
                text: '数值'
            }
        },
        plotOptions: {
            line: {
                dataLabels: {
                    enabled: true
                },
                enableMouseTracking: false
            }
        },
        series: [
            <?php foreach ($date as $val) { ?>
            {
            name: '<?php echo $val; ?>',
            data: [<?php
                foreach(['Remain'=>'新增','ActRemain'=>'活跃'] as $key => $name){
                    foreach ($config as $r) {
                        if(empty($data[$val][3]['day'.$r.$key])){
                            echo "0,";
                        }else{
                            echo "'".$data[$val][3]['day'.$r.$key]."',";
                        }
                    }
                }
                ?>]
        },
            <?php } ?>
        ]
    });
</script>