<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
		<ul id="msgops">
			<li>${h.link_to(_('Export Domains'), url('domains-export-byorg', orgid=c.orgid) if c.orgid else url('domains-export'))}</li>
		</ul>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="space-6"></div>
${s.searchbox(url('domains-search'), [('o', c.orgid),]) if c.orgid 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>
${h.form(url.current(), method='post')}
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10" id="bulkdomain">
		<div class="row-fluid">
			<div class="span4 hidden-phone"></div>
			<div class="span2 half">${h.radio('whatdo', 'delete', label='Delete', class_='fieldcontrols')}</div>
			<div class="span2 half">${h.radio('whatdo', 'disable', label='Disable', class_='fieldcontrols')}</div>
			<div class="span2 half">${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>
<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 class="grid">
			<th class="domains_heading_hash domains_check">${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')}</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 org in 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 blue"></i>'), url('accounts-bydom', domid=domain.id))}</td>
			<td class="hidden-phone">${h.literal(functions.item_status(domain.status))}</td>
			<td>${h.link_to(h.literal('<i class="icon-cog blue"></i>'), url('domain-settings', domainid=domain.id), title=_("Manage settings"))}</td>
			<td>${h.link_to(h.literal('<i class="icon-edit blue"></i>'), url(controller='domains', action='edit', domainid=domain.id), title=_("Edit Domain"))}</td>
			<td>${h.link_to(h.literal('<i class="icon-remove red"></i>'), url(controller='domains', action='delete', domainid=domain.id), title=_("Delete Domain"))}</td>
		</tr>
		% endfor
		</tbody>
		</table>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
${h.end_form()}\
<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()">\
% if c.page.page_count != 0:
${ungettext('Domains :: Showing page %(page)d of %(count)d page.', 'Domains :: Showing page %(page)d of %(count)d pages.', c.page.page_count) % dict(page=c.page.page, count=c.page.page_count)}
% else:
${_('Domains ::')}
% endif
</%def>

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

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

<%def name="submenu()">
% if c.user.is_superadmin:
<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(_('Add a domain'), url(controller='domains', action='add'))}</li>
            </ul>
        </div>
    </div>
</div>
% endif
</%def>

<%def name="paging(page_nums, fieldname)">
% if c.page.page_count != 0:
<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>
	${h.link_to(h.literal('<i class="icon-double-angle-left"></i>'), url('domains-byorg-pages', orgid=c.orgid, page=c.page.first_page) if c.orgid else url('domain-pages', page=c.page.first_page))}
</span>
<span>...</span>
% endif
% if c.page.previous_page:
<span>
	${h.link_to(h.literal('<i class="icon-angle-left"></i>'), url('domains-byorg-pages', orgid=c.orgid, page=c.page.previous_page) if c.orgid else url('domain-pages', page=c.page.previous_page))}
</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('domains-byorg-pages', orgid=c.orgid, page=linkpage) if c.orgid else url('domain-pages', page=linkpage))}
</span>
% 	endif
% endfor
% if c.page.next_page:
<span>
	${h.link_to(h.literal('<i class="icon-angle-right"></i>'), url('domains-byorg-pages', orgid=c.orgid, page=c.page.next_page) if c.orgid else url('domain-pages', page=c.page.next_page))}
</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.literal('<i class="icon-double-angle-right"></i>'), url('domains-byorg-pages', orgid=c.orgid, page=c.page.page_count) if c.orgid else url('domain-pages', page=c.page.page_count))}
</span>
% endif
% if c.page.page_count != 0:
</div>
% else:
<div class="pages">-</div>
% endif
</%def>

<%def name="localscripts()">\
<script type="text/javascript">
var setitems_url = "${url(controller='domains', 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/baruwa/domains.min.js')}
</%def>
<%namespace name="s" file="../includes/search.html"/>
<%namespace name="functions" file="../includes/functions.html"/>
<%inherit file="../base.html"/>

