<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>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <form class="form-inline" role="form" method="POST" action="#statistics/treasureRewardSta" 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>
                                    </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>基础数据</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 style="text-align: center;vertical-align: middle;">消耗金币</th>
                                                <th style="text-align: center;vertical-align: middle;">产出金币</th>
                                            </tr>
                                            </thead>
                                            <tbody id="reportBody">
                                            <?php
                                            function formatChipRound($value, $round=2){
                                                $value = ceil($value);
                                                if(1 <= abs($valueB = round($value / 1000000000, $round))) {
                                                    return  $valueB . 'B';
                                                }else if(1 <= abs($valueM=round($value / 1000000, $round))) {
                                                    return $valueM . 'M';
                                                }else if(1 <= abs($valueK=round($value / 1000, $round))) {
                                                    return $valueK . 'K';
                                                }else {
                                                    return $value;
                                                }
                                            }
                                            ?>
                                            <?php for ($i=1;$i<=$showData['max'];$i++) { ?>
                                                <tr>
                                                    <td style="white-space: nowrap" rowspan="3"><?php echo $i;?></td>
                                                    <td style="white-space: nowrap">总值</td>
                                                    <td style="white-space: nowrap"><?php echo formatChipRound($showData['add'][$i]['sum']);?></td>
                                                    <td style="white-space: nowrap"><?php echo formatChipRound($showData['spend'][$i]['sum']);?></td>
                                                </tr>
                                                <tr>
                                                    <td style="white-space: nowrap">参与人数</td>
                                                    <td style="white-space: nowrap"><?php echo $showData['add'][$i]['count'];?></td>
                                                    <td style="white-space: nowrap"><?php echo $showData['spend'][$i]['count'];?></td>
                                                </tr>
                                                <tr>
                                                    <td style="white-space: nowrap">参与人均</td>
                                                    <td style="white-space: nowrap"><?php echo $showData['add'][$i]['count'] == 0 ? 0 : formatChipRound(intval($showData['add'][$i]['sum']/$showData['add'][$i]['count']));?></td>
                                                    <td style="white-space: nowrap"><?php echo $showData['spend'][$i]['count'] == 0 ? 0 : formatChipRound(intval($showData['spend'][$i]['sum']/$showData['spend'][$i]['count']));?></td>
                                                </tr>
                                            <?php } ?>
                                            </tbody>

                                        </table>
                                    </div>

                                    <!--                                        <nav>-->
                                    <!--                                            <ul class="pagination">-->
                                    <!--                                                <li class="disabled"><a href="#">共<span class="pagetotal">--><?php //echo $totalNum;?><!--</span>条</a></li>-->
                                    <!--                                                --><?php //echo $pageurl;?>
                                    <!--                                            </ul>-->
                                    <!--                                        </nav>-->
                                </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
    });
</script>