<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="#payment/goodsPaySuccess" 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>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>商品</label>
                                            <input type="text" class="form-control" value="<?php if($gname) echo $gname;?>" placeholder="商品" name="gname" />
                                        </div>
                                        <span class="gap"></span>
                                        <div class="form-group">
                                            <label>平台类型:</label>
                                            <select  name="sid" id="sid" class="selectpicker show-tick form-control">
                                                <option value="999" <?php if($sid == 999){echo "selected";} ?>>--全部--</option>
                                                <option value="1" <?php if($sid == 1){echo "selected";} ?>>安卓</option>
                                                <option value="2" <?php if($sid == 2){echo "selected";} ?>>IOS</option>
                                                <option value="-1" <?php if($sid == -1){echo "selected";} ?>>测试</option>
                                            </select>
                                        </div>
                                        <span class="gap"></span>
                                        <button type="submit" class="btn btn-primary">查询</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        
        
		<?php
			foreach($goodsAll as $k => $v){
		?>

        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i><?php echo $goods[$v]; ?></header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div id="container<?php echo $k; ?>" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
        
        <?php
			}
		?>
		
    </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">


<?php
	foreach($goodsAll as $k => $v){
?>

Highcharts.chart('container<?php echo $k; ?>', {
    chart: {
        zoomType: 'xy'
    },
    title: {
        text: '<?php echo $goods[$v]; ?> 购买成功率'
    },
    subtitle: {
        text: '左坐标轴数量，右坐标轴百分比'
    },
    xAxis: {
        categories: [<?php echo "'".implode("','", $dayList)."'";?>]
    },
    yAxis: [{ // Primary yAxis
            labels: {
                format: '{value}',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            title: {
                text: '数值',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            }
        }, { // Secondary yAxis
            title: {
                text: '百分比',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            labels: {
                format: '{value} %',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            opposite: true
    }],
    tooltip: {
        shared: true
    },
    series: [{
        name: '成功率',
        yAxis: 1,
        data: [<?php
	        foreach($dayList as $d_k => $d_v){
	        	if($d_k < count($dayList)-1){
	        		if(empty($retSuccess[$d_k][$v]) || empty($retAll[$d_k][$v])){
	        			echo "0,";
	        		}else{
	        			echo round($retSuccess[$d_k][$v] / $retAll[$d_k][$v] * 100,2).",";
	        		}
	        		
	        	}else{
	        		if(empty($retSuccess[$d_k][$v]) || empty($retAll[$d_k][$v])){
	        			echo "0";
	        		}else{
	        			echo round($retSuccess[$d_k][$v] / $retAll[$d_k][$v] * 100,2);
	        		}
	        		
	        	}
	        	
	        }
        ?>],
        tooltip: {
            valueSuffix: '%'
        }
    },{
        name: '下单数',
        data: [<?php
	        foreach($dayList as $d_k => $d_v){
        		if(empty($retAll[$d_k][$v])){
        			echo "0,";
        		}else{
        			echo $retAll[$d_k][$v].",";
        		}
	        }
        ?>]
    },{
        name: '购买成功数',
        data: [<?php
	        foreach($dayList as $d_k => $d_v){
        		if(empty($retSuccess[$d_k][$v])){
        			echo "0,";
        		}else{
        			echo $retSuccess[$d_k][$v].",";
        		}
	        }
        ?>]
    },{
        name: '下单率(下单数/DAU)',
        yAxis: 1,
        data: [<?php
	        foreach($dayList as $d_k => $d_v){
        		if(empty($retAll[$d_k][$v]) || empty($retDau[$d_k])){
        			echo "0,";
        		}else{
        			echo round($retAll[$d_k][$v]/$retDau[$d_k]*100,2).",";
        		}
	        }
        ?>],
        tooltip: {
            valueSuffix: '%'
        }
    }]
});

<?php
	}
?>

</script>