${s.searchbox(url('domains-search'), [('o', c.org),]) if c.org else s.searchbox(url('domains-search'))}
<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), 'seldomaintop')}</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="space-6"></div>
% if c.page.items:
${h.form(url(controller='domains'), method='post')}
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10" id="bulkdomain">
		<div class="row-fluid">
			<div class="span4"></div>
			<div class="span2">${h.radio('whatdo', 'delete', label='Delete', class_='fieldcontrols')}</div>
			<div class="span2">${h.radio('whatdo', 'disable', label='Disable', class_='fieldcontrols')}</div>
			<div class="span2">${h.radio('whatdo', 'enable', label='Enable', class_='fieldcontrols')}</div>
			<div class="span2"><button class="btn btn-small btn-success"><i class="icon-cog"></i> ${_('Process')}</button></div>
		</div>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="space-6"></div>
% endif
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
		<table class="table table-bordered table-condensed table-hover table-striped">
		<thead>
		<tr>
			<th>${h.checkbox('checkall')}</th>
			<th>${_('Domain Name')}</th>
			<th class="hidden-phone">${_('Organization')}</th>
			<th class="hidden-phone">${_('Accounts')}</th>
			<th class="hidden-phone">${_('Status')}</th>
			<th colspan="3">${_('Actions')}</th>
		</tr>
		</thead>
		<tbody>
		% if not c.page.items:
		<tr><td colspan="8">${_('No domains found matching: %s') % c.q}</td></tr>
		% endif
		% for domain in c.page.items:
		<tr id="domain-id-${domain.id}">
			<td>${h.checkbox('domainid', value=domain.id, class_='selector')}</td>
			<td>
				${h.link_to(domain.name, url(controller='domains', action='detail', domainid=domain.id))}
			</td>
			<td class="hidden-phone">
				<%
				orglinks = []
				for index, org in enumerate(domain.organizations):
					link = h.link_to(org.name, url('org-detail', orgid=org.id)) if c.user.is_superadmin else org.name
					orglinks.append(link)
				orglinks = ', '.join(orglinks)
				%>
				${orglinks|n}
			</td>
			<td class="hidden-phone">${h.link_to(h.literal('<i class="icon-user"></i>'), url('accounts-bydom', domid=domain.id))}</td>
			<td class="hidden-phone">${functions.item_status(domain.status)}</td>
			<td>${h.link_to(h.literal('<i class="icon-cog blue"></i>'), url('domain-settings', domainid=domain.id))}</td>
			<td>${h.link_to(h.literal('<i class="icon-edit"></i>'), url(controller='domains', action='edit', domainid=domain.id))}</td>
			<td>${h.link_to(h.literal('<i class="icon-remove red"></i>'), url(controller='domains', action='delete', domainid=domain.id))}</td>
		</tr>
		% endfor
		</tbody>
		</table>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
% if c.page.items:
${h.end_form()}\
% endif
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10 toolbar">${self.paging(h.do_pagination(c.page), 'seldomainbottom')}</div>
	<div class="span1 hidden-phone"></div>
</div>

<%def name="title()">\
${_('Domains :: Search results :: %(q)s :: Showing page %(page)d of %(count)d pages.') % dict(page=c.page.page, count=c.page.page_count, q=c.q) if c.page.page_count != 0 else _('Domains :: Search results :: %s') % c.q}
</%def>

<%def name="heading()">\
${_('Domains :: Search results :: %(q)s :: Showing page %(page)d of %(count)d pages.') % dict(page=c.page.page, count=c.page.page_count, q=c.q) if c.page.page_count != 0 else _('Domains :: Search results :: %s') % c.q}
</%def>

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

<%def name="paging(page_nums, fieldname)">
% if c.page.page_count != 0:
<%
kwd = {}
if c.org:
	kwd['o'] = c.org
%>
<p>${_('Showing results %(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:')}
${h.pager_select(fieldname, str(c.page.items_per_page))}
${_('results 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>
	${h.link_to(h.pager_img('first'), url.current(q=c.q, p=c.page.first_page, **kwd))}
</span>
<span>...</span>
% endif
% if c.page.previous_page:
<span>
	${h.link_to(h.pager_img('previous'), url.current(q=c.q, p=c.page.previous_page, **kwd))}
</span>
% endif
% for linkpage in page_nums:
% 	if linkpage == c.page.page:
<span class="curpage">${linkpage}</span>
% 	else:
<span>
	${h.link_to(h.literal(linkpage), url.current(q=c.q, p=linkpage, **kwd))}
</span>
% 	endif
% endfor
% if c.page.next_page:
<span>
	${h.link_to(h.pager_img('next'), url.current(q=c.q, p=c.page.next_page, **kwd))}
</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>
	${h.link_to(h.pager_img('last'), url.current(q=c.q, p=c.page.page_count, **kwd))}
</span>
% endif
% if c.page.page_count != 0:
</div>
% else:
<div class="pages">-</div>
% endif
</%def>

<%def name="submenu()"></%def>
<%def name="localscripts()">\
${h.javascript_link(h.media_url() + 'js/baruwa/domains.search.min.js')}
</%def>
<%namespace name="s" file="../includes/search.html"/>
<%namespace name="functions" file="../includes/functions.html"/>
<%inherit file="../base.html"/>
