<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 id="fromSelect" class="form-inline" role="form" method="POST" action="#statistics/userGroupSta/<?php echo $id;?>" name="stanpform">
                                        <input type="hidden" name="fromsta_userGroup" value="1">
                                        <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>

                                        <button type="button" class="btn btn-success" id="exportAllData">导出全部分组统计数据</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <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>
                                            <th style="text-align: center;vertical-align: middle;">人数</th>
                                            <th style="text-align: center;vertical-align: middle;">付费人数</th>
                                            <th style="text-align: center;vertical-align: middle;">付费率</th>
                                            <th style="text-align: center;vertical-align: middle;">ARPU</th>
                                            <th style="text-align: center;vertical-align: middle;">ARPPU</th>
                                            <th style="text-align: center;vertical-align: middle;">付费总额</th>
                                            <th style="text-align: center;vertical-align: middle;">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody id="reportBody">
                                        <?php  foreach($dayList as $k => $val){ ?>
                                            <tr>
                                                <td style="white-space: nowrap" rowspan="1"><?php echo $val;?></td>
                                                <td style="white-space: nowrap" rowspan="1"><?php echo $count[$k];?></td>
                                                <td style="white-space: nowrap" rowspan="1"><?php echo $list[$k]['payNum'];?></td>
                                                <td style="white-space: nowrap" rowspan="1"><?php echo empty($list[$k]['payRate'])?0:$list[$k]['payRate'];?>%</td>
                                                <td style="white-space: nowrap" rowspan="1"><?php echo $list[$k]['ARPU'];?></td>
                                                <td style="white-space: nowrap" rowspan="1"><?php echo $list[$k]['ARPPU'];?></td>
                                                <td style="white-space: nowrap" rowspan="1"><?php echo $list[$k]['payTotal'];?></td>
                                                <td style="white-space: nowrap" rowspan="1"><button class="btn btn-success" onclick="exportData(<?php echo str_replace('-','',$val);?>)" role="button">导出</button></td>
                                            </tr>
                                        <?php }  ?>
                                        </tbody>
                                    </table>
                                </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">
    //选择日期
    function exportData(date) {
        var num = prompt("请输入导出数量");
        var id  = <?php echo $id??0;?>;
        num     = parseInt(num);
        if(num>0){
            window.location.href="/Export/userGroup/"+date+"/"+id+"/"+num
        }
    }

    $(document).on("click","#exportAllData",function(){
        var stime = $("#fromSelect").find("input[name='stime']").val();
        var etime = $("#fromSelect").find("input[name='etime']").val();
        window.location.href="/Export/userGroupSta/"+stime+"/"+etime
    });

    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });
</script>