<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/inviteEventSta" 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>邀请事件统计</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="3"  style="text-align: center;vertical-align: middle;">日期</th>
                                                <th colspan="12" style="text-align: center;vertical-align: middle;">类型</th>
                                            </tr>
                                            <tr>
                                            	
                                            	<?php
                                            		//$typeArr = [1=>'系统邀请',2=>'FB邀请',3=>'messenger邀请',4=>'邀请码邀请'];
                                            		// $typeArr = [1=>'系统邀请',2=>'FB邀请',3=>'messenger邀请'];
                                            		// $eventArr = [1=>'邀请按钮点击',2=>'发送邀请',3=>'邀请成功'];
                                              //  	foreach ($typeArr as $name) {
                                              //  		echo '<th colspan="3" style="text-align: center;vertical-align: middle;">'.$name.'</th>';
                                              //  	}
                                                ?>
                                                <th colspan="4" style="text-align: center;vertical-align: middle;">FB邀请</th>
                                                <th colspan="4" style="text-align: center;vertical-align: middle;">邀请码邀请</th>
                                                <th colspan="4" style="text-align: center;vertical-align: middle;">合计</th>
                                            </tr>
                                            <tr>
                                            	<?php
                                                	// foreach ($typeArr as $type => $v) {
                                                	// 	foreach($eventArr as $event => $name){
                                                	// 		if($type == 1 && in_array($event,[2,3])){
                                                 //   			continue;
                                                 //   		}
                                                 //   		if($type == 3 && in_array($event,[2])){
                                                 //   			continue;
                                                 //   		}
                                                	// 		echo '<th style="text-align: center;vertical-align: middle;">'.$name.'</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;">邀请成功率(发送/成功)</th>
                                                
                                                <th style="text-align: center;vertical-align: middle;">系统邀请按钮点击</th>
                                                <th style="text-align: center;vertical-align: middle;">message邀请按钮点击</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;">发送邀请</th>
                                                <th style="text-align: center;vertical-align: middle;">邀请成功数</th>
                                                <th style="text-align: center;vertical-align: middle;">邀请成功率(发送/成功)</th>
                                            </tr>
                                            </thead>
                                            <tbody id="reportBody" style="overflow-y: scroll;">
                                            <?php
                                            if(is_array($data)){
                                                foreach ($data as $key => $val) {
                                                    ?>
                                                    <tr>
                                                        <?php echo '<td style="text-align: center;vertical-align: middle;">'.$key.'</td>'; ?>
                                                        <?php
                                                        // foreach ($typeArr as $type => $v) {
                                                        // 	foreach($eventArr as $event => $name){
                                                        // 		if($type == 1 && in_array($event,[2,3])){
                                                        // 			continue;
                                                        // 		}
                                                        // 		if($type == 3 && in_array($event,[2])){
                                                        // 			continue;
                                                        // 		}
                                                        //     	echo '<td>'.(empty($val[$event][$type])?0:$val[$event][$type]).'</td>';
                                                        // 	}
                                                        // }
                                                        
                                                        ?>
                                                        
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo empty($val[1][2])?0:$val[1][2];?></td>
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo empty($val[2][2])?0:$val[2][2];?></td>
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo empty($val[3][2])?0:$val[3][2];?></td>
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo empty($val[2][2]) || empty($val[3][2])?0:round($val[3][2]/$val[2][2],4) * 100;?>%</td>
                                                        
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo empty($val[1][1])?0:$val[1][1];?></td>
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo empty($val[1][3])?0:$val[1][3];?></td>
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo empty($val[3][4])?0:$val[3][4];?></td>
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo empty($val[3][4]) || empty($val[1][1]) || empty($val[1][3])?0:round($val[3][4]/($val[1][3]+$val[1][1]),4) * 100;?>%</td>
                                                        
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo intval($val[1][2]+$val[1][1]+$val[1][3]); ?></td>
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo empty($val[2][2])?0:$val[2][2];?></td>
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo intval($val[3][2]+$val[3][4]);?></td>
                                                        <td style="text-align: center;vertical-align: middle;"><?php echo empty($val[2][2]) || empty($val[3][2]) || empty($val[3][4])?0:round(($val[3][2]+$val[3][4])/$val[2][2],4) * 100;?>%</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
    });
</script>