<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10 toolbar">
		${h.form(url('lists-index', list_type=c.list_type), method='get', id='msgsearch')}
		<div class="row-fluid">
			% if hasattr(c, 'q') and c.q:
			<div class="span3">${_('About %(n)s results (%(t)s seconds)') % dict(n=c.total_found, t=c.search_time)}</div>
			<div class="span6"><input type="text" class="input-block-level" name="q" value="${c.q}" /></div>
			% else:
			<div class="span3 hidden-phone">&nbsp;</div>
			<div class="span6"><input type="text" class="input-block-level" name="q" placeholder="Search lists" /></div>
			% endif
			<div class="span3 hidden-phone"><button class="btn btn-small btn-success"><i class="icon-search"></i> ${_('Search')}</button></div>
		</div>
		${h.end_form()}
	</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 toolbar">
		${self.paging(h.do_pagination(c.page), 'sliststop')}
	</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">
		<table class="table table-bordered">
		<thead>
		<tr>
		    <th class="lists_heading_hash hidden-phone">${_('#')}</th>
			<th class="lists_heading_from">${_('From address')}</th>
		    <th class="lists_heading_to hidden-phone">${_('To address')}</th>
		    <th class="lists_heading_action">${_('Action')}</th>
		</tr>
		</thead>
		<tbody>
		% for i, listitem in enumerate(c.page.items):
		    <tr id="list-id-${listitem.id}">
		        <td class="lists_hash hidden-phone">${listitem.id}</td>
				<td class="lists_from fat">${listitem.from_address}</td>
		        <td class="lists_to hidden-phone">${listitem.to_address}</td>
		        <td class="lists_action">${h.link_to(h.literal('<i class="icon-remove red"></i>'), url('list-delete', listid=listitem.id))}</td>
		    </tr>
		% endfor
		% if not c.page.items:
		<tr><td class="spanrow" colspan="4">${_('No items found')}</td></tr>
		% endif
		</tbody>
		</table>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10 toolbar">${self.paging(h.do_pagination(c.page), 'slistsbottom')}</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="space-6"></div>
<%def name="list_sorter(text, col)">
% if c.direction == 'dsc':
<%
   rlink = '&uarr;'
   rdirection = 'asc'
%>
% else:
<%
   rlink = '&darr;'
   rdirection = 'dsc'
%>
% endif
% if c.order_by == col:
${text} ${h.link_to(h.literal(rlink), url('list-pages-byfield', list_type=c.list_type, page=c.page.page, direction=rdirection, order_by=col))}
% else:
${h.link_to(h.literal(text), url('list-pages-byfield', list_type=c.list_type, page=c.page.page, direction=c.direction, order_by=col))}
% endif
</%def>

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

<%def name="submenu()">
<div class="navbar navbar-static-top">
    <div class="navbar-inner">
        <div class="nav-collapse collapse">
            <ul class="nav navbar-nav">
                <li class="nav_item">${h.link_to(_('Approved senders'), url('lists-index', list_type=1))}</li>
                <li class="nav_item">${h.link_to(_('Banned senders'), url('lists-index', list_type=2))}</li>
                <li class="nav_item">${h.link_to(_('Add to List'), url('lists-add'), id='list-add')}</li>
            </ul>
        </div>
    </div>
</div>
</%def>

<%def name="localscripts()">
<script type="text/javascript">
var setitems_url = "${url(controller='lists', action='setnum')}";
var baruwa_custom_name = "${config.get('baruwa.custom.name', 'Baruwa')}";
</script>
${h.javascript_link(h.media_url() + 'js/vendor/jquery.address-1.4.min.js',
h.media_url() + 'js/vendor/trunk8.min.js',
h.media_url() + 'js/baruwa/lists.min.js')}
</%def>

<%def name="title()">${_('List management')}</%def>

<%def name="heading()">
% if int(c.list_type) == 1:
% if c.page.page_count > 0:
 ${_('Lists :: Approved senders :: Showing page %(page)d of %(count)d pages.') % dict(page=c.page.page, count=c.page.page_count)}\
% else:
 ${_('Lists :: Approved senders')}
% endif
% else:
% if c.page.page_count > 0:
 ${_('Lists :: Banned senders :: Showing page %(page)d of %(count)d pages.') % dict(page=c.page.page, count=c.page.page_count)}\
% else:
 ${_('Lists :: Banned senders')}
% endif
% endif
</%def>

<%def name="paging(page_nums, fieldname)">
% if c.page.page_count != 0:
<%
kwd = {}
if hasattr(c, 'q') and c.q:
	kwd['q'] = c.q
%>
<p>${_('Showing items %(i)d to %(l)d of %(count)d') % dict(i=c.page.first_item, l=c.page.last_item, count=c.page.item_count)}.</p>
<div class="limiter">
${_('Show items:')}
${h.pager_select(fieldname, str(c.page.items_per_page))}
${_('per page')}
</div>
<div class="pages">
% if c.page.page_count == 1:
-
% endif
% else:
<p>${_('No items found')}</p>
% endif
% if c.page.next_page != c.page.first_page and c.page.page != c.page.first_page:
<span>
	% if c.direction != 'dsc' or c.order_by != 'id':
	<% link_url =  url('list-pages-byfield', list_type=c.list_type, page=c.page.first_page, direction=c.direction, order_by=c.order_by, **kwd) %>
	% else:
	<% link_url = url('list-pages', list_type=c.list_type, page=c.page.first_page, **kwd) %>
	% endif
	${h.link_to(h.literal('<i class="icon-double-angle-left"></i>'), link_url)}
</span>
<span>...</span>
% endif
% if c.page.previous_page:
<span>
	% if c.direction != 'dsc' or c.order_by != 'id':
	<% link_url =  rl('list-pages-byfield', list_type=c.list_type, page=c.page.previous_page, direction=c.direction, order_by=c.order_by, **kwd) %>
	% else:
	<% link_url =  url('list-pages', list_type=c.list_type, page=c.page.previous_page, **kwd) %>
	% endif
	${h.link_to(h.literal('<i class="icon-angle-left"></i>'), link_url)}
</span>
% endif
% for linkpage in page_nums:
% 	if linkpage == c.page.page:
<span><b>${linkpage}</b></span>
% 	else:
<span>
    % if c.direction != 'dsc' or c.order_by != 'id':
    <% link_url =  url('list-pages-byfield', list_type=c.list_type, page=linkpage, direction=c.direction, order_by=c.order_by, **kwd) %>
    % else:
    <% link_url =  url('list-pages', list_type=c.list_type, page=linkpage, **kwd) %>
    % endif
	${h.link_to(h.literal(linkpage), link_url)}
</span>
% 	endif
% endfor
% if c.page.next_page:
<span>
    % if c.direction != 'dsc' or c.order_by != 'id':
    <% link_url =  url('list-pages-byfield', list_type=c.list_type, page=c.page.next_page, direction=c.direction, order_by=c.order_by, **kwd) %>
    % else:
    <% link_url = url('list-pages', list_type=c.list_type, page=c.page.next_page, **kwd) %>
    % endif
	${h.link_to(h.literal('<i class="icon-angle-right"></i>'), link_url)}
</span>
% endif
% if c.page.next_page != c.page.page_count and c.page.page != c.page.page_count and c.page.page_count != 0:
<span>...</span>
<span>
    % if c.direction != 'dsc' or c.order_by != 'id':
    <% link_url =  url('list-pages-byfield', list_type=c.list_type, page=c.page.page_count, direction=c.direction, order_by=c.order_by, **kwd) %>
    % else:
    <% link_url = url('list-pages', list_type=c.list_type, page=c.page.page_count, **kwd) %>
    % endif
	${h.link_to(h.literal('<i class="icon-double-angle-right"></i>'), link_url)}
</span>
% endif
% if c.page.page_count != 0:
</div>
% else:
<div class="pages">-</div>
% endif
</%def>
<%inherit file="../base.html"/>

