<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
		<h3 class="head smaller lighter blue">${_('Add Filters')}</h3>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
${filter.form()}
<div class="space-6"></div>
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
		<h3 class="head smaller lighter blue">${_('Reports')}</h3>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="space-6"></div>
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
		<div class="row-fluid">
			<div class="span4">
				<ul class="reports">
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Top Senders by Quantity'), url('reports-display', reportid=1))}</li>
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Top Senders by Volume'), url('reports-display', reportid=2))}</li>
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Top Sender Domains by Quantity'), url('reports-display', reportid=3))}</li>
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Top Sender Domains by Volume'), url('reports-display', reportid=4))}</li>
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Spam Score Distribution'), url('reports-display', reportid=9))}</li>
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Top Mail hosts'), url('reports-display', reportid=10))}</li>
		        </ul>
			</div>
			<div class="span4">
				<ul class="reports">
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Top Recipients by Quantity'), url('reports-display', reportid=5))}</li>
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Top Recipients by Volume'), url('reports-display', reportid=6))}</li>
					% if c.user.account_type != 3:
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Top Recipient Domains By Quantity'), url('reports-display', reportid=7))}</li>
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Top Recipient Domains By Volume'), url('reports-display', reportid=8))}</li>
					% endif
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Message Totals'), url('reports-display', reportid=11))}</li>
		            <li><i class="icon-star blue"></i> ${h.link_to(_('Full message list'), url(controller='messages', action='listing'))}</li>
		        </ul>
			</div>
			<div class="span4">
				<div class="row-fluid">
					<div class="span5 real-half">
						${_('Message count')}
					</div>
					<div class="span7 real-half" id="msgcount">
						${c.count}
					</div>
				</div>
				<div class="row-fluid">
					<div class="span5 real-half">
						${_('Oldest message')}
					</div>
					<div class="span7 real-half" id="newestmsg">
						${_('No messages found') if c.data[0][0] is None else h.datetimeformat(h.format_date(c.data[0].newest, c.tzinfo), format='%Y-%m-%d %H:%M:%S %z (%Z)')}
					</div>
				</div>
				<div class="row-fluid">
					<div class="span5 real-half">
						${_('Newest message')}
					</div>
					<div class="span7 real-half" id="oldestmsg">
						${_('No messages found') if c.data[0][0] is None else h.datetimeformat(h.format_date(c.data[0].oldest, c.tzinfo), format='%Y-%m-%d %H:%M:%S %z (%Z)')}
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
		<div class="row-fluid">
			<div class="span6">
				<div class="row-fluid" id="afilters">
					<h3 class="head smaller lighter blue" id="active_filters">${_('Active Filter(s)')}</h3>
				</div>
				<%
				filterdict = dict(c.FILTER_ITEMS)
				filterbydict = dict(c.FILTER_BY) 
				%>
				% for index, f in enumerate(c.active_filters): 
				<div class="row-fluid afr">
			        <div class="span1 half">
			            ${h.link_to(h.literal('<i class="icon-remove red"></i>'), url('delete-filter', filterid=index))}
			        </div>
			        <div class="span1 half">
				        ${h.link_to(h.literal('<i class="icon-save green"></i>'), url('save-filter', filterid=index))}
			        </div>
			        <div class="span10 half">
			            ${filterdict[f['field']]} ${filterbydict[f['filter']]} ${f['value']}
			        </div>
				</div>
				% endfor
				% if not c.active_filters:
				<div class="row-fluid afr">
				    <div class="span12">${_('No active filters at the moment')}</div>
				</div>
				% endif
			</div>
			<div class="span6">
				<div class="row-fluid" id="sfilters">
					<h3 class="head smaller lighter blue">${_('Saved Filter(s)')}</h3>
				</div>
				% for sf in c.saved_filters:
				<div class="row-fluid sfr">
			        <div class="span1 half">
			            ${h.link_to(h.literal('<i class="icon-remove red"></i>'), url('delete-storedfilter', filterid=sf['id']))}
			        </div>
			        <div class="span1 half">
						% if not sf['loaded']:
							${h.link_to(h.literal('<i class="icon-upload-alt blue"></i>'), url('load-filter', filterid=sf['id']))}
						% else:
							${h.literal('<i class="icon-plus red"></i>')}
						% endif
			        </div>
			        <div class="span10 half">
			            ${sf['name']}
			        </div>
				</div>
				% endfor
				% if not c.saved_filters:
				<div class="row-fluid sfr">
				    <div class="span12">${_('No saved filters at the moment')}</div>
				</div>
				% endif
			</div>
		</div>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="space-6"></div>


<%def name="headers()">
</%def>

<%def name="title()">${_('Reports')}</%def>
<%def name="heading()">${_('Reports')}</%def>
<%def name="submenu()">&nbsp;</%def>
<%def name="localscripts()">
% if 'lang' in session and session['lang']:
<% baruwalang = session['lang'] %>
% else:
<% baruwalang = 'en' %>
% endif
${h.stylesheet_link(h.media_url() + 'css/vendor/datepicker.css')}
${h.javascript_link(h.media_url() + 'js/vendor/jquery.clearform.min.js',
h.media_url() + 'js/vendor/jquery.maskedinput.min.js',
h.media_url() + 'js/vendor/bootstrap-datepicker.min.js',
#h.media_url() + 'js/vendor/locales/bootstrap-datepicker.' + baruwalang + '.js',
h.media_url() + 'js/baruwa/reports.common.min.js',
h.media_url() + 'js/baruwa/reports.min.js')}
</%def>
<%namespace name="filter" file="../reports/form.html"/>
<%inherit file="../base.html"/>
