{set:
	$start = IFilter::act(IReq::get('start'));
	$end   = IFilter::act(IReq::get('end'));
	$countData = statistics::spandAvg($start,$end);
}

{js:my97date}
{js:chart}
<div class="breadcrumbs" id="breadcrumbs">
	<ul class="breadcrumb">
		<li>
			<i class="home-icon fa fa-home"></i>
			<a href="#">统计</a>
		</li>
		<li>
			<a href="#">基础数据统计</a>
		</li>
		<li class="active">人均消费统计</li>
	</ul>
</div>
<div class="content">
	<form action='{url:/}' method='get' class="form-inline" name="searchForm">
		<input type='hidden' name='controller' value='market' />
		<input type='hidden' name='action' value='spanding_avg' />

		<div class="input-group">
			<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
			<input type="text" name='start' class="form-control" value='{$start}' pattern='date' empty onFocus="WdatePicker()" placeholder="起始时间"/>
		</div>

		<div class="input-group">
			<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
			<input type="text" name='end' pattern='date' value='{$end}' class="form-control" empty onFocus="WdatePicker()" placeholder="结束时间"/>
		</div>

		<button class="btn btn-default" type="button" onclick="submitForm('spanding_avg');">
		    <i class="fa fa-search"></i> 查询
		</button>

		<button class="btn btn-default" onclick="submitForm('spanding_report')">
		    <i class="fa fa-file-excel-o"></i> 导出报表
		</button>
	</form>

	<div class="box" style="margin-top:20px">
		<div class="box-header">
			人均消费统计，更清楚了解每月用户对销售产品消费情况，更清楚的了解销售产品处在什么趋势，为你下一步的营销计划做出更好的判定！
		</div>
		<div class="box-body">
			<div id="myChart" style="min-height:350px;"></div>
		</div>
	</div>
</div>

<script type='text/javascript'>
//图表生成
$(function()
{
	//图标模板
	var option = {
		title:
		{
			text:'人均消费统计'
		},
		xAxis:
		{
			name:'时间',
			data:{echo:JSON::encode(array_keys($countData))},
		},
		yAxis:
		{
			name:'金额(元)',
		},
		series:
		[
			{
				name:'消费金额',
				type:'line',
				data:{echo:JSON::encode(array_values($countData))}
			}
		],
		tooltip:
		{
			show:true
		}
	};
	echarts.init(document.getElementById('myChart')).setOption(option);
});

//修改表单提交内容
function submitForm(action)
{
	$('[name="action"]').val(action);
	formSubmit("searchForm");
}
</script>
