<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/giftEventSta" 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($date) echo $date;?>" placeholder="统计时间" name="date" />
		                                </div>
		                                <span class="gap"></span>
		                                <div class="form-group">
		                                    <label>价格</label>
		                                    <select class="form-control" name="price">
		                                    	<option value="all" <?php echo $price == "all"?"selected":""; ?> >全部</option>
		                                    	<option value="0.99" <?php echo $price == "0.99"?"selected":""; ?> >0.99</option>
		                                    	<option value="1.99" <?php echo $price == "1.99"?"selected":""; ?> >1.99</option>
		                                    	<option value="2.99" <?php echo $price == "2.99"?"selected":""; ?> >2.99</option>
		                                    	<option value="3.99" <?php echo $price == "3.99"?"selected":""; ?> >3.99</option>
		                                    	<option value="4.99" <?php echo $price == "4.99"?"selected":""; ?> >4.99</option>
		                                    	<option value="9.99" <?php echo $price == "9.99"?"selected":""; ?> >9.99</option>
		                                    	<option value="14.99" <?php echo $price == "14.99"?"selected":""; ?> >14.99</option>
		                                    	<option value="19.99" <?php echo $price == "19.99"?"selected":""; ?> >19.99</option>
		                                    	<option value="29.99" <?php echo $price == "29.99"?"selected":""; ?> >29.99</option>
		                                    	<option value="39.99" <?php echo $price == "39.99"?"selected":""; ?> >39.99</option>
		                                    	<option value="49.99" <?php echo $price == "49.99"?"selected":""; ?> >49.99</option>
		                                    	<option value="99.99" <?php echo $price == "99.99"?"selected":""; ?> >99.99</option>
		                                    </select>
		                                </div>
		                                <span class="gap"></span>
		                                <div class="form-group">
		                                    <label>折扣</label>
		                                    <select class="form-control" name="discount">
		                                    	<option value="all" <?php echo $discount == "all"?"selected":""; ?> >全部</option>
		                                    	<option value="0.03" <?php echo $discount == "0.03"?"selected":""; ?> >0.03</option>
		                                    	<option value="0.02" <?php echo $discount == "0.02"?"selected":""; ?> >0.02</option>
		                                    	<option value="0.016" <?php echo $discount == "0.016"?"selected":""; ?> >0.016</option>
		                                    </select>
		                                </div>
		                                <span class="gap"></span>
		                                <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>
	                <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;width:200px;">礼包ID</th>
	                                <th rowspan="2" style="text-align: center;vertical-align: middle;">礼包名称</th>
	                                <th rowspan="2" style="text-align: center;vertical-align: middle;">价格</th>
	                                <th colspan="5" style="text-align: center;vertical-align: middle;">统计</th>
	                            </tr>
	                            <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;">购买失败</th>
	                            </tr>
	                        </thead>
	                        <tbody id="reportBody">
	                        	<?php foreach($list as $goods){ ?>
	                        	<tr>
	                        		<td style="text-align: center;vertical-align: middle;"><?php echo $goods['gid']; ?></td>
	                        		<td style="text-align: center;vertical-align: middle;"><?php echo $goods['gname']; ?></td>
	                        		<td style="text-align: center;vertical-align: middle;"><?php echo $goods['gprice']; ?>$</td>
	                        		<?php
	                        			$types = [1=>'入口点击',2=>'自动弹出',3=>'购买点击',4=>'购买成功',5=>'购买失败'];
										foreach($types as $key => $name){
											echo '<td style="text-align: center;vertical-align: middle;">'.(empty($goods['sta'][$key])?0:$goods['sta'][$key]).'</td>';
										}
									?>
	                        	</tr>
	                        	<?php } ?>
	                        </tbody>
	                    </table>
	                </div>
                </aside>
            </div>
        </div>
        
        <div class="row">
            <div class="col-sm-12">
            	<aside>
            		<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;width:200px;">分组</th>
	                            </tr>
	                            <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;">购买失败</th>
	                            </tr>
	                        </thead>
	                        <tbody id="reportBody">
	                        	<?php foreach($group as $key => $row){ ?>
	                        	<tr>
	                        		<td style="text-align: center;vertical-align: middle;"><?php echo $key; ?></td>
	                        		<?php
	                        			$types = [1=>'入口点击',2=>'自动弹出',3=>'购买点击',4=>'购买成功',5=>'购买失败'];
										foreach($types as $key => $name){
											$number = 0;
											foreach($list as $listTemp){
												if(in_array($listTemp['gid'],$row)){
													$number += (empty($listTemp['sta'][$key])?0:$listTemp['sta'][$key]);
												}
											}
											echo '<td style="text-align: center;vertical-align: middle;">'.$number.'</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 type="text/javascript" src="<?php echo base_url();?>public/js/highcharts/modules/exporting.js"></script>
<script type="text/javascript">


</script>
<script type="text/javascript">
    //选择日期
    $('.datetimepicker').datepicker({
        language:'zh-CN',
        format:'yyyy-mm-dd',
        zIndexOffset:906  //控制z-index
    });
</script>