<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 class="form-inline" role="form" method="POST" action="#statistics/returnQuality" name="stanpform">
                                        <input type="hidden" value="1" name="payuserpost"/>
                                        <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="remain_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="remain_etime" />
                                        </div>
                                        <button type="submit" class="btn btn-primary">查询</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        
        <?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;
            }
        }
        ?>
                                            
		
        <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="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 colspan="1" style="text-align: center;vertical-align: middle;">每日新增</th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">累计新增</th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">单价</th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">留存率</th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">DAU</th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">DNU/DAU</th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">ARPU</th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">日收入</th></th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">累计收入</th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">每日支出</th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">累计支出</th>
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">ROI_1d</th>
	                                            <!--<th colspan="1" style="text-align: center;vertical-align: middle;">ROI_30d</th>-->
	                                            <th colspan="1" style="text-align: center;vertical-align: middle;">盈亏</th>
	                                        </tr>
                                        
                                        </thead>
                                        <tbody id="reportBody">
                                        <?php
                                         if(is_array($out)){
                                         	$i = 1;
                                            foreach($out as $k => $val){
                                                ?>
                                                <tr>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $i==1?$k."(".$val['date'].")":($i==count($out)?$k."(".$val['date'].")":$k);$i++;?></td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $val['new_player']; ?></td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $val['new_player_total']; ?></td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $val['cpi']; ?></td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $val['remain_new_last']; ?>%</td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $val['dau']; ?></td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo round($val['new_player'] / $val['dau'],4); ?></td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $val['arpu']; ?></td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $val['revenue']; ?></td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $val['revenue_total']; ?></td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $val['adexpend']; ?></td>
                                                	<td style="white-space: nowrap" rowspan="1"><?php echo $val['adexpend_total']; ?></td>
                                                	<td style="white-space: nowrap" rowspan="1">
                                                		<?php 
                                                			//echo round(($val['revenue'] / $val['new_player']) / $val['adexpend'],4); 
                                                			echo round((($val['revenue'] - $val['ad_estimate_income']) / $val['new_player']) / $val['cpi'],4);
                                                		?>
                                                	</td>
                                                	<?php
                                                		$differ = $val['revenue_total'] - $val['adexpend_total'];
                                                		
                                                	?>
                                                	<td style="white-space: nowrap;color:#fff;background:<?php echo $differ > 0?'green':'red'; ?>" rowspan="1"><?php echo ($differ > 0?'+':'-').$differ; ?></td>
                                                </tr>
                                               
                                                <?php
                                            }
                                         }
                                        ?>
                                        </tbody>
                                    </table>
                                </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>