<script type="text/javascript">
$(function(){
	var hourchart = $('#hourchart');
	var oHourChart = new Chart(hourchart, {
		type: 'line',
		data: {
			labels: [{{foreach from=$aStats.aHourVisits item=aHourStat}}"{{if $aHourStat.iHour == 0}}24{{else}}{{$aHourStat.iHour}}{{/if}}:00",{{if $aHourStat@last}}"24:00"{{/if}}{{/foreach}}],
			datasets: [{
				label: '{{$lang.Stats_visits}}/100',
				data: [{{foreach from=$aStats.aHourVisits item=aHourStat}}{{$aHourStat.iVisits/100}},{{if $aHourStat@last}}{{$aStats.aHourVisits[0].iVisits/100}}{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 109, 208, 241, 0.2 )'
			},
			{
				label: '{{$lang.Stats_orders}}',
				data: [{{foreach from=$aStats.aHourOrders item=aHourStat}}{{$aHourStat.iOrders}},{{if $aHourStat@last}}{{$aStats.aHourOrders[0].iOrders}}{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 112, 211, 73, 0.5 )'
			},
			{
				label: '{{$lang.Stats_quantity}}',
				data: [{{foreach from=$aStats.aHourOrders item=aHourStat}}{{$aHourStat.iQuantitySum}},{{if $aHourStat@last}}{{$aStats.aHourOrders[0].iQuantitySum}}{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 255, 102, 0, 0.3 )'
			}]
		},
		options: {
			scales: {
				xAces: [{
					type: 'linear',
					position: 'bottom'
				}]
			}
		}
	});
	var monthchart = $('#monthchart');
	var oMonthChart = new Chart(monthchart, {
		type: 'line',
		data: {
			labels: [{{foreach from=$aStats.aMonthVisits item=aMonthStat}}"{{$lang['Month'|cat:$aMonthStat.iMonth]}}",{{if $aMonthStat@last}}"{{$lang['Month1']}}"{{/if}}{{/foreach}}],
			datasets: [{
				label: '{{$lang.Stats_visits}}/100',
				data: [{{foreach from=$aStats.aMonthVisits item=aMonthStat}}{{$aMonthStat.iVisits/100}},{{if $aMonthStat@last}}{{$aStats.aMonthVisits[1].iVisits/100}}{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 109, 208, 241, 0.2 )'
			},
			{
				label: '{{$lang.Stats_orders}}',
				data: [{{foreach from=$aStats.aMonthOrders item=aMonthStat}}{{$aMonthStat.iOrders}},{{if $aMonthStat@last}}{{$aStats.aMonthOrders[1].iOrders}}{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 112, 211, 73, 0.5 )'
			},
			{
				label: '{{$lang.Stats_quantity}}',
				data: [{{foreach from=$aStats.aMonthOrders item=aMonthStat}}{{$aMonthStat.iQuantitySum}},{{if $aMonthStat@last}}{{$aStats.aMonthOrders[1].iQuantitySum}}{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 255, 102, 0, 0.3 )'
			}]
		},
		options: {
			scales: {
				xAces: [{
					type: 'linear',
					position: 'bottom'
				}]
			}
		}
	});
	var last5yearschart = $('#last5yearschart');
	var oLast5YearsChart = new Chart(last5yearschart, {
		type: 'line',
		data: {
			labels: [{{foreach from=$aStats.a5YearsVisits item=aMonthStat}}"{{$aMonthStat.sMonth}}"{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
			datasets: [{
				label: '{{$lang.Stats_visits}}/100',
				data: [{{foreach from=$aStats.a5YearsVisits item=aMonthStat}}{{$aMonthStat.iVisits/100}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 109, 208, 241, 0.2 )'
			},
			{
				label: '{{$lang.Stats_orders}}',
				data: [{{foreach from=$aStats.a5YearsOrders item=aMonthStat}}{{$aMonthStat.iOrders}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 112, 211, 73, 0.5 )'
			},
			{
				label: '{{$lang.Stats_quantity}}',
				data: [{{foreach from=$aStats.a5YearsOrders item=aMonthStat}}{{$aMonthStat.iQuantitySum}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 255, 102, 0, 0.3 )'
			}]
		},
		options: {
			scales: {
				xAces: [{
					type: 'linear',
					position: 'bottom'
				}]
			}
		}
	});
	var last30dayschart = $('#last30dayschart');
	var oLast30DaysChart = new Chart(last30dayschart, {
		type: 'line',
		data: {
			labels: [{{foreach from=$aStats.a30DaysVisits item=aDayStat}}"{{$aDayStat.sDay}}"{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
			datasets: [{
				label: '{{$lang.Stats_visits}}/100',
				data: [{{foreach from=$aStats.a30DaysVisits item=aDayStat}}{{$aDayStat.iVisits/100}}{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 109, 208, 241, 0.2 )'
			},
			{
				label: '{{$lang.Stats_orders}}',
				data: [{{foreach from=$aStats.a30DaysVisits item=aDayStat}}{{$aStats.a62DaysOrders[$aDayStat.sDay].iOrders}}{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 112, 211, 73, 0.5 )'
			},
			{
				label: '{{$lang.Stats_quantity}}',
				data: [{{foreach from=$aStats.a30DaysVisits item=aDayStat}}{{$aStats.a62DaysOrders[$aDayStat.sDay].iQuantitySum}}{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 255, 102, 0, 0.3 )'
			}]
		},
		options: {
			scales: {
				xAces: [{
					type: 'linear',
					position: 'bottom'
				}]
			}
		}
	});
	
	var last90dayschart = $('#last90dayschart');
	var oLast90DaysChart = new Chart(last90dayschart, {
		type: 'line',
		data: {
			labels: [{{foreach from=$aStats.a90DaysVisits item=aDayStat}}"{{$aDayStat.sDay}}"{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
			datasets: [{
				label: '{{$lang.Stats_visits}}/100',
				data: [{{foreach from=$aStats.a90DaysVisits item=aDayStat}}{{$aDayStat.iVisits/100}}{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 109, 208, 241, 0.2 )'
			},
			{
				label: '{{$lang.Stats_orders}}',
				data: [{{foreach from=$aStats.a90DaysVisits item=aDayStat}}{{$aStats.a90DaysOrders[$aDayStat.sDay].iOrders}}{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 112, 211, 73, 0.5 )'
			},
			{
				label: '{{$lang.Stats_quantity}}',
				data: [{{foreach from=$aStats.a90DaysVisits item=aDayStat}}{{$aStats.a90DaysOrders[$aDayStat.sDay].iQuantitySum}}{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 255, 102, 0, 0.3 )'
			}]
		},
		options: {
			scales: {
				xAces: [{
					type: 'linear',
					position: 'bottom'
				}]
			}
		}
	});
	
	var lastyearchart = $('#lastyearchart');
	var oLastYearChart = new Chart(lastyearchart, {
		type: 'line',
		data: {
			labels: [{{foreach from=$aStats.aLastYearVisits item=aWeekStat}}"{{$aWeekStat.sWeek}}"{{if !$aWeekStat@last}},{{/if}}{{/foreach}}],
			datasets: [{
				label: '{{$lang.Stats_visits}}/100',
				data: [{{foreach from=$aStats.aLastYearVisits item=aWeekStat}}{{$aWeekStat.iVisits/100}}{{if !$aWeekStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 109, 208, 241, 0.2 )'
			},
			{
				label: '{{$lang.Stats_orders}}',
				data: [{{foreach from=$aStats.aLastYearVisits item=aWeekStat}}{{$aStats.aLastYearOrders[$aWeekStat.sWeek].iOrders}}{{if !$aWeekStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 112, 211, 73, 0.5 )'
			},
			{
				label: '{{$lang.Stats_quantity}}',
				data: [{{foreach from=$aStats.aLastYearVisits item=aWeekStat}}{{$aStats.aLastYearOrders[$aWeekStat.sWeek].iQuantitySum}}{{if !$aWeekStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 255, 102, 0, 0.3 )'
			}]
		},
		options: {
			scales: {
				xAces: [{
					type: 'linear',
					position: 'bottom'
				}]
			}
		}
	});
	
	var refererchart = $('#refererchart');
	var oRefererChart = new Chart(refererchart, {
		type: 'pie',
		data: {
			labels: [{{foreach from=$aStats.aRefererStats item=aRefererStat}}"{{if empty( $aRefererStat.sDomain )}}{{$lang.Referer_null}}{{else}}{{$aRefererStat.sDomain}}{{/if}} ({{$aRefererStat.iVisits}})"{{if !$aRefererStat@last}},{{/if}}{{/foreach}}],
			datasets: [{
				data: [
					{{foreach from=$aStats.aRefererStats item=aRefererStat}}"{{$aRefererStat.iVisits}}"{{if !$aRefererStat@last}},{{/if}}{{/foreach}}
				],
				backgroundColor: [
					{{foreach from=$aStats.aRefererStats item=aRefererStat}}'#{{if $aReferersColors[$aRefererStat.sDomain]}}{{$aReferersColors[$aRefererStat.sDomain]}}{{else}}dadada{{/if}}'{{if !$aRefererStat@last}},{{/if}}{{/foreach}}
				]
			}]
		}
	});
	
	var refererchart2 = $('#refererchart2');
	var oRefererChart2 = new Chart(refererchart2, {
		type: 'pie',
		data: {
			labels: [{{foreach from=$aStats.aRefererStats item=aRefererStat}}{{if !empty( $aRefererStat.sDomain )}}"{{$aRefererStat.sDomain}} ({{$aRefererStat.iVisits}})"{{if !$aRefererStat@last}},{{/if}}{{/if}}{{/foreach}}],
			datasets: [{
				data: [
					{{foreach from=$aStats.aRefererStats item=aRefererStat}}{{if !empty( $aRefererStat.sDomain )}}"{{$aRefererStat.iVisits}}"{{if !$aRefererStat@last}},{{/if}}{{/if}}{{/foreach}}
				],
				backgroundColor: [
					{{foreach from=$aStats.aRefererStats item=aRefererStat}}{{if !empty( $aRefererStat.sDomain )}}'#{{if $aReferersColors[$aRefererStat.sDomain]}}{{$aReferersColors[$aRefererStat.sDomain]}}{{else}}dadada{{/if}}'{{if !$aRefererStat@last}},{{/if}}{{/if}}{{/foreach}}
				]
			}]
		}
	});
	
	var timechart3 = $('#timechart3');
	var oTimeChart3 = new Chart(timechart3, {
		type: 'bar',
		data: {
			labels: [{{foreach from=$aStats.aBuyTimes3 item=aMonthStat}}"{{$aMonthStat.sMonth}}"{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
			datasets: [{
				label: 'i < 1h',
				data: [{{foreach from=$aStats.aBuyTimes3 item=aMonthStat}}{{$aMonthStat.iLowerThan1h}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 112, 211, 73, 0.5 )'
			},{
				label: '1h < i < 12h',
				data: [{{foreach from=$aStats.aBuyTimes3 item=aMonthStat}}{{$aMonthStat.iLowerThan12h}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 72, 162, 37, 0.5 )'
			},{
				label: '12h < i < 1d',
				data: [{{foreach from=$aStats.aBuyTimes3 item=aMonthStat}}{{$aMonthStat.iLowerThan1Day}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 46, 119, 18, 0.5 )'
			},{
				label: '1d < i < 3d',
				data: [{{foreach from=$aStats.aBuyTimes3 item=aMonthStat}}{{$aMonthStat.iLowerThan3Days}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 213, 221, 0, 0.5 )'
			},{
				label: '3d < i < 7d',
				data: [{{foreach from=$aStats.aBuyTimes3 item=aMonthStat}}{{$aMonthStat.iLowerThan7Days}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 221, 140, 0, 0.5 )'
			},{
				label: '7d < i < 30d',
				data: [{{foreach from=$aStats.aBuyTimes3 item=aMonthStat}}{{$aMonthStat.iLowerThan30Days}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 221, 94, 0, 0.5 )'
			},{
				label: '30d < i',
				data: [{{foreach from=$aStats.aBuyTimes3 item=aMonthStat}}{{$aMonthStat.iHigherThan30Days}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 221, 52, 0, 0.5 )'
			}]
		},
		options: {
			scales: {
				xAces: [{
					type: 'linear',
					position: 'bottom'
				}]
			}
		}
	});
	
	var timechart = $('#timechart');
	var oTimeChart = new Chart(timechart, {
		type: 'line',
		data: {
			labels: [{{foreach from=$aStats.aBuyTimes item=aMonthStat}}"{{$aMonthStat.sMonth}}"{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
			datasets: [/*{
				label: '{{$lang.Stats_min_time}}',
				data: [{{foreach from=$aStats.aBuyTimes item=aMonthStat}}{{$aMonthStat.iMinTime/(3600)}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 109, 208, 241, 0.2 )'
			},*/
			{
				label: '{{$lang.Stats_avg_time}}',
				data: [{{foreach from=$aStats.aBuyTimes item=aMonthStat}}{{$aMonthStat.iAvgTime/(3600)}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 112, 211, 73, 0.5 )'
			}/*,
			{
				label: '{{$lang.Stats_max_time}}',
				data: [{{foreach from=$aStats.aBuyTimes item=aMonthStat}}{{$aMonthStat.iMaxTime/(3600)}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 255, 102, 0, 0.3 )'
			}*/,
			{
				label: '{{$lang.Orders_avarage}}',
				data: [{{foreach from=$aStats.aBuyTimes item=aMonthStat}}{{$aStats.a5YearsOrders[$aMonthStat.sMonth].iOrders/30}}{{if !$aMonthStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 255, 102, 0, 0.3 )'
			}]
		},
		options: {
			scales: {
				xAces: [{
					type: 'linear',
					position: 'bottom'
				}]
			}
		}
	});
	
	var timechart2 = $('#timechart2');
	var oTimeChart2 = new Chart(timechart2, {
		type: 'line',
		data: {
			labels: [{{foreach from=$aStats.aBuyTimes2 item=aDayStat}}"{{$aDayStat.sDay}}"{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
			datasets: [/*{
				label: '{{$lang.Stats_min_time}}',
				data: [{{foreach from=$aStats.aBuyTimes2 item=aDayStat}}{{$aDayStat.iMinTime/(3600)}}{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 109, 208, 241, 0.2 )'
			},*/
			{
				label: '{{$lang.Stats_avg_time}}',
				data: [{{foreach from=$aStats.aBuyTimes2 item=aDayStat}}{{$aDayStat.iAvgTime/(3600)}}{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 112, 211, 73, 0.5 )'
			}/*,
			{
				label: '{{$lang.Stats_max_time}}',
				data: [{{foreach from=$aStats.aBuyTimes2 item=aDayStat}}{{$aDayStat.iMaxTime/(3600)}}{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 255, 102, 0, 0.3 )'
			}*/,
			{
				label: '{{$lang.Orders}}',
				data: [{{foreach from=$aStats.aBuyTimes2 item=aDayStat}}{{$aStats.a62DaysOrders[$aDayStat.sDay].iOrders}}{{if !$aDayStat@last}},{{/if}}{{/foreach}}],
				backgroundColor: 'rgba( 255, 102, 0, 0.3 )'
			}]
		},
		options: {
			scales: {
				xAces: [{
					type: 'linear',
					position: 'bottom'
				}]
			}
		}
	});
});
</script>

<h1>{{$lang.Hour_stats}}</h1>
<canvas id="hourchart" width="400" height="100"></canvas>
<table>
	<tr class="hours"> <th>{{$lang.Stats_hour}}    </th>{{foreach from=$aStats.aHourVisits item=aHourStat}}<th>{{if $aHourStat.iHour == 0}}24{{else}}{{$aHourStat.iHour}}{{/if}}:00</th>{{/foreach}}</tr>
	<tr class="visits"><th>{{$lang.Stats_visits}}  </th>{{foreach from=$aStats.aHourVisits item=aHourStat}}<td>{{$aHourStat.iVisits}}</td>{{/foreach}}</tr>
	<tr class="orders"><th>{{$lang.Stats_orders}}  </th>{{foreach from=$aStats.aHourOrders item=aHourStat}}<td>{{$aHourStat.iOrders}}</td>{{/foreach}}</tr>
	<tr class="orders"><th>{{$lang.Stats_quantity}}</th>{{foreach from=$aStats.aHourOrders item=aHourStat}}<td>{{$aHourStat.iQuantitySum}}</td>{{/foreach}}</tr>
</table>

<h1 style="margin-top:20px;">{{$lang.Month_stats}}</h1>
<canvas id="monthchart" width="400" height="100"></canvas>
<table>
	<tr class="months"><th>{{$lang.Stats_month}}   </th>{{foreach from=$aStats.aMonthVisits item=aMonthStat}}<th>{{$lang['Month'|cat:$aMonthStat.iMonth]}}</th>{{/foreach}}</tr>
	<tr class="visits"><th>{{$lang.Stats_visits}}  </th>{{foreach from=$aStats.aMonthVisits item=aMonthStat}}<td>{{$aMonthStat.iVisits}}</td>{{/foreach}}</tr>
	<tr class="orders"><th>{{$lang.Stats_orders}}  </th>{{foreach from=$aStats.aMonthOrders item=aMonthStat}}<td>{{$aMonthStat.iOrders}}</td>{{/foreach}}</tr>
	<tr class="orders"><th>{{$lang.Stats_quantity}}</th>{{foreach from=$aStats.aMonthOrders item=aMonthStat}}<td>{{$aMonthStat.iQuantitySum}}</td>{{/foreach}}</tr>
</table>

<h1 style="margin-top:20px;">{{$lang.Last30DaysStats}}</h1>
<canvas id="last30dayschart" width="400" height="100"></canvas>

<h1 style="margin-top:20px;">{{$lang.Last90DaysStats}}</h1>
<canvas id="last90dayschart" width="400" height="100"></canvas>

<h1 style="margin-top:20px;">{{$lang.LastYearStats}}</h1>
<canvas id="lastyearchart" width="400" height="100"></canvas>

<h1 style="margin-top:20px;">{{$lang.Last5YearsStats}}</h1>
<canvas id="last5yearschart" width="400" height="100"></canvas>

<h1 style="margin-top:20px;">{{$lang.RefererStats}}</h1>
<canvas id="refererchart" width="200" height="100"></canvas>

<h1 style="margin-top:20px;">{{$lang.RefererStats2}}</h1>
<canvas id="refererchart2" width="200" height="100"></canvas>

<h1 style="margin-top:20px;">{{$lang.TimeNeededYear}}</h1>
<canvas id="timechart" width="400" height="100"></canvas>

<h1 style="margin-top:20px;">{{$lang.TimeNeeded2Months}}</h1>
<canvas id="timechart2" width="400" height="100"></canvas>

<h1 style="margin-top:20px;">{{$lang.TimeNeededYear}}</h1>
<canvas id="timechart3" width="400" height="100"></canvas>

<h1 style="margin-top:20px;">{{$lang.RefererStatsCurrentMonth}}</h1>
<table>
	<thead><tr><th></th><th>{{$lang.Name}}</th><th>{{$lang.Stats_visits}}</th><th>{{$lang.Entry_cost}}</th><th>{{$lang.Stats_orders}}</th><th>{{$lang.Stats_quantity}}</th><th>{{$lang.Orders_summary}}</th><th>{{$lang.Margin}}</th><th>{{$lang.Profit}}</th><th>{{$lang.Profit}} %</th><th>{{$lang.Conversion}}</th></tr></thead>
	<tbody>
		{{foreach from=$aStats.aRefVisitsCurrentMonth item=aRefererStat}}
			<tr>
				<td><div style="display: inline-block; width: 10px; height: 10px; background-color: #{{$aRefererStat.sColor}};"></div></td>
				<td>{{$aRefererStat.sName}}</td>
				<td>{{$aRefererStat.iVisits}}</td>
				<td>{{$aRefererStat.fCost}}</td>
				<td>{{$aStats.aRefOrdersCurrentMonth[$aRefererStat.sName].iOrders}}</td>
				<td>{{$aStats.aRefOrdersCurrentMonth[$aRefererStat.sName].iSumQuantity}}</td>
				<td>{{$aStats.aRefOrdersCurrentMonth[$aRefererStat.sName].fSumPrice}}</td>
				<td>{{$aStats.aRefOrdersCurrentMonth[$aRefererStat.sName].fMargin}}</td>
				<td {{if $aStats.aRefOrdersCurrentMonth[$aRefererStat.sName].fMargin - $aRefererStat.fCost < 0}}style="color: red; font-weight: bold;"{{/if}}>{{$aStats.aRefOrdersCurrentMonth[$aRefererStat.sName].fMargin - $aRefererStat.fCost}}</td>
				<td {{if $aStats.aRefOrdersCurrentMonth[$aRefererStat.sName].fMargin - $aRefererStat.fCost < 0}}style="color: red; font-weight: bold;"{{/if}}>{{round( ( $aStats.aRefOrdersCurrentMonth[$aRefererStat.sName].fMargin / $aRefererStat.fCost - 1 )* 100, 2 )}}%</td>
				<td>{{round( $aStats.aRefOrdersCurrentMonth[$aRefererStat.sName].iOrders / $aRefererStat.iVisits * 100, 2 )}}%</td>
			</tr>
		{{/foreach}}
	</tbody>
</table>

<h1 style="margin-top:20px;">{{$lang.RefererStatsLastMonth}}</h1>
<table>
	<thead><tr><th></th><th>{{$lang.Name}}</th><th>{{$lang.Stats_visits}}</th><th>{{$lang.Entry_cost}}</th><th>{{$lang.Stats_orders}}</th><th>{{$lang.Stats_quantity}}</th><th>{{$lang.Orders_summary}}</th><th>{{$lang.Margin}}</th><th>{{$lang.Profit}}</th><th>{{$lang.Profit}} %</th><th>{{$lang.Conversion}}</th></tr></thead>
	<tbody>
		{{foreach from=$aStats.aRefVisitsLastMonth item=aRefererStat}}
			<tr>
				<td><div style="display: inline-block; width: 10px; height: 10px; background-color: #{{$aRefererStat.sColor}};"></div></td>
				<td>{{$aRefererStat.sName}}</td>
				<td>{{$aRefererStat.iVisits}}</td>
				<td>{{$aRefererStat.fCost}}</td>
				<td>{{$aStats.aRefOrdersLastMonth[$aRefererStat.sName].iOrders}}</td>
				<td>{{$aStats.aRefOrdersLastMonth[$aRefererStat.sName].iSumQuantity}}</td>
				<td>{{$aStats.aRefOrdersLastMonth[$aRefererStat.sName].fSumPrice}}</td>
				<td>{{$aStats.aRefOrdersLastMonth[$aRefererStat.sName].fMargin}}</td>
				<td {{if $aStats.aRefOrdersLastMonth[$aRefererStat.sName].fMargin - $aRefererStat.fCost < 0}}style="color: red; font-weight: bold;"{{/if}}>{{$aStats.aRefOrdersLastMonth[$aRefererStat.sName].fMargin - $aRefererStat.fCost}}</td>
				<td {{if $aStats.aRefOrdersLastMonth[$aRefererStat.sName].fMargin - $aRefererStat.fCost < 0}}style="color: red; font-weight: bold;"{{/if}}>{{round( ( $aStats.aRefOrdersLastMonth[$aRefererStat.sName].fMargin / $aRefererStat.fCost - 1 )* 100, 2 )}}%</td>
				<td>{{round( $aStats.aRefOrdersLastMonth[$aRefererStat.sName].iOrders / $aRefererStat.iVisits * 100, 2 )}}%</td>
			</tr>
		{{/foreach}}
	</tbody>
</table>

<h1 style="margin-top:20px;">{{$lang.RefererStatsCurrentYear}}</h1>
<table>
	<thead><tr><th></th><th>{{$lang.Name}}</th><th>{{$lang.Stats_visits}}</th><th>{{$lang.Entry_cost}}</th><th>{{$lang.Stats_orders}}</th><th>{{$lang.Stats_quantity}}</th><th>{{$lang.Orders_summary}}</th><th>{{$lang.Margin}}</th><th>{{$lang.Profit}}</th><th>{{$lang.Profit}} %</th><th>{{$lang.Conversion}}</th></tr></thead>
	<tbody>
		{{foreach from=$aStats.aRefVisitsCurrentYear item=aRefererStat}}
			<tr>
				<td><div style="display: inline-block; width: 10px; height: 10px; background-color: #{{$aRefererStat.sColor}};"></div></td>
				<td>{{$aRefererStat.sName}}</td>
				<td>{{$aRefererStat.iVisits}}</td>
				<td>{{$aRefererStat.fCost}}</td>
				<td>{{$aStats.aRefOrdersCurrentYear[$aRefererStat.sName].iOrders}}</td>
				<td>{{$aStats.aRefOrdersCurrentYear[$aRefererStat.sName].iSumQuantity}}</td>
				<td>{{$aStats.aRefOrdersCurrentYear[$aRefererStat.sName].fSumPrice}}</td>
				<td>{{$aStats.aRefOrdersCurrentYear[$aRefererStat.sName].fMargin}}</td>
				<td {{if $aStats.aRefOrdersCurrentYear[$aRefererStat.sName].fMargin - $aRefererStat.fCost < 0}}style="color: red; font-weight: bold;"{{/if}}>{{$aStats.aRefOrdersCurrentYear[$aRefererStat.sName].fMargin - $aRefererStat.fCost}}</td>
				<td {{if $aStats.aRefOrdersCurrentYear[$aRefererStat.sName].fMargin - $aRefererStat.fCost < 0}}style="color: red; font-weight: bold;"{{/if}}>{{round( ( $aStats.aRefOrdersCurrentYear[$aRefererStat.sName].fMargin / $aRefererStat.fCost - 1 )* 100, 2 )}}%</td>
				<td>{{round( $aStats.aRefOrdersCurrentYear[$aRefererStat.sName].iOrders / $aRefererStat.iVisits * 100, 2 )}}%</td>
			</tr>
		{{/foreach}}
	</tbody>
</table>