<title id="page-title">每日宝箱开卡星级数统计</title>
<div class="content_wrapper">
    	<div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <?php foreach ($types as $k => $v){?>
                                        <a style="margin:5px;" class="btn btn-success <?php if($type == $k){echo 'active';}?>" href="#statistics/cardAssertSummary/<?=$k?>" role="button"><?=$v?></a>
                                    <?php }?>
                                </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/cardAssertSummary/<?php echo $type; ?>" name="stanpform">
		                                <span class="gap"></span>
		                                <div class="form-group">
		                                    <label>统计时间</label>
		                                    <input type="text" class="form-control datetimepicker" value="<?php if($date) echo $date;?>" placeholder="统计时间" name="date" />
		                                </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>
                    <div class="table-responsive">
                        <table id="roleTable" class="table table-bordered table-hover"
                               data-toggle="table"
                               data-classes="table table-hover"
                               data-show-columns="true"
                               data-striped="true"
                               data-height="700">
                            <thead>
                            <tr>
                                <?php
                                foreach($columns as $key => $name){
                                    echo '<th style="text-align: center">'.$name.'</th>';
                                }
                                ?>
                            </tr>
                            </thead>
                            <tbody id="reportBody">
                            <?php foreach ( $records as  $row) { ?>
                                <tr data-json="<?php echo json_encode($row);?>">
                                    <?php foreach ( $columns as $key => $name) {?>
                                        <td style="text-align: center;vertical-align: middle;width:200px;">
                                            <?=$row[$key] ?? '-'?>
                                            <?php if(in_array($key, $caculRateColumns)){ $rate = number_format($row[$key]/$row['total']*100, 2);?>
                                                <br><span style="color: red"><?=$rate.'%'?></span>
                                            <?php }?>
                                        </td>
                                    <?php }?>
                                </tr>
                            <?php }?>
                            </tbody>
                        </table>
                    </div>


                    <div class="table-responsive">
                        <table id="roleTable" class="table table-bordered table-hover"
                               data-toggle="table"
                               data-classes="table table-hover"
                               data-show-columns="true"
                               data-striped="true"

                               data-height="700">
                            <thead>
                            <tr>
                                <th style="display: none">ID</th>
                                <?php if(!empty($chestTitle)){
                                    foreach ($chestTitle as $val){ ?>
                                        <th style="text-align: center"><?php echo $val;?></th>
                                    <?php }

                                }?>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            if(is_array($list)  && !empty($list)){
                                foreach ($list as $key => $vl) { ?>
                                    <tr>
                                        <td style="display: none; text-align: center""><?php echo $vl['type'];?></td>
                                        <td style="text-align: center"><?php echo $chestType[$vl['type']];?></td>
                                        <?php foreach ($vl['pro'] as $k=>$v){ ?>
                                            <td style="text-align: center"><?php echo $v['v']; ?><br><?=$v['pro']?></td>
                                        <?php } ?>
                                        <td style="text-align: center"><?php echo $vl['card'];?></td>
                                    </tr>
                                <?php } } else{?>
                                <tr>
                                    <td colspan="14">暂无数据</td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </aside>
            </div>
        </div>

    </div>
</div>
</div>
<!--<script type="text/javascript" src="--><?php //echo base_url();?><!--public/js/highcharts/highcharts.js"></script>-->
<!--<script src="https://code.highcharts.com.cn/highstock/highstock.js"></script>-->
<!--<script src="https://code.highcharts.com/modules/data.js"></script>-->
<!--<script src="https://code.highcharts.com/modules/heatmap.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">

    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        autoclose:true,
        zIndexOffset:906  //控制z-index
    });


    $(document).on("click","#exportAllData",function(){
        window.location.href = '/Export/cardGrantSta/<?php echo empty($type)?'card':$type; ?>/<?php echo $stime; ?>';
    });
</script>