{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
{if $layout.module=="domainsearch"}{assign var=suffix value="&s=1"}{/if}
<H1>{$layout.pagetitle}</H1>
<TABLE class="lmsbox">
    <THEAD>
	<TR>
		<TD width="95%" NOWRAP>
			<IMG src="img/domain.gif" alt=""> <A href="?m={$layout.module}{$suffix}&amp;o=name{if $listdata.direction == "asc" && $listdata.order == "name"},desc{/if}"><B>{trans("Name:")}</B></A> {if $listdata.order == "name"}<IMG src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">{/if}
		</TD>
		<TD width="1%" align="center" NOWRAP>
			<IMG src="img/empty.gif" alt="" height="16"><A href="?m={$layout.module}{$suffix}&amp;o=id{if $listdata.direction == "asc" && $listdata.order == "id"},desc{/if}">{trans("ID:")}</A> {if $listdata.order == "id"}<IMG src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">{/if}
		</TD>
                <TD width="1%" NOWRAP>
                    <IMG src="img/empty.gif" alt="" height="16"><A href="?m={$layout.module}{$suffix}&amp;o=type{if $listdata.direction == "asc" && $listdata.order == "type"},desc{/if}">{trans("Type:")}</A> {if $listdata.order == "type"}<IMG src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">{/if}
                </TD>
		<TD width="1%" NOWRAP>
			<IMG src="img/customer.gif" alt=""> <A href="?m={$layout.module}{$suffix}&amp;o=customer{if $listdata.direction == "asc" && $listdata.order == "customer"},desc{/if}">{trans("Customer:")}</A> {if $listdata.order == "customer"}<IMG src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">{/if}
		</TD>
		<TD width="1%" NOWRAP>
		    <IMG src="img/empty.gif" alt="" height="16">
		    <A href="?m={$layout.module}{$suffix}&amp;o=cnt{if $listdata.direction == "asc" && $listdata.order == "cnt"},desc{/if}">{trans("Accounts:")}</A> {if $listdata.order == "cnt"}<IMG src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">{/if}
		</TD>
		<TD width="1%" NOWRAP>
			<IMG src="img/empty.gif" alt="" height="16">
			<B>{t a=$listdata.total}Total: $a{/t}</B>
		</TD>
	</TR>
	<TR>
	        <TD colspan="6">
			<TABLE cellpadding="0" cellspacing="0" width="100%">
				<TR>
					<TD width="1%" NOWRAP>
		        			<FORM method="GET" action="?m={$layout.module}" name="filter">
							<INPUT type="submit" class="hiddenbtn">
							<INPUT type="HIDDEN" name="m" value="{$layout.module}">
							{if $suffix}<INPUT type="HIDDEN" name="s" value="1">{/if}
							<INPUT type="HIDDEN" name="page" value="1">
							<B>{trans("Filter:")} </B>
							{trans("Owner:")}
							<SELECT size="1" name="c" OnChange="document.filter.submit();">
								<OPTION value=""{if $listdata.customer == ""} SELECTED{/if}>{trans("— all owners —")}</OPTION>
			        				<OPTION value="0"{if $listdata.customer == "0"} SELECTED{/if}>{trans("SYSTEM DOMAIN")}</OPTION>
								{foreach from=$customerlist item=customer}
				    					<OPTION value="{$customer.id}"{if $customer.id == $listdata.customer} SELECTED{/if}>{$customer.customername|truncate:40:"&hellip;":true}</OPTION>
								{/foreach}
							</SELECT>
							&nbsp;{trans("Name:")}
							<SELECT size="1" name="f" OnChange="document.filter.submit();">
								<OPTION value=""{if $listdata.name == ""} SELECTED{/if}>{trans("— all —")}</OPTION>
								{foreach from=$domaincount item=item key=key}
				    					<OPTION value="{$key}"{if $key == $listdata.name} SELECTED{/if}>{$key}...</OPTION>
								{/foreach}
							</SELECT>
						</FORM>
					</TD>
					<TD width="99%" align="right" nowrap>
						<A href="?m=domainadd&amp;cid={$listdata.customer}">{trans("New Domain")} <IMG src="img/save.gif" alt=""></A>
					</TD>
		    		</TR>
			</TABLE>
		</TD>
	</TR>
	{if $listdata.total != 0}
	<TR>
		<TD class="lms-ui-pagination" COLSPAN="6">
			{include file="scroller.html" loop=$domainlist adlink=$suffix}
		</TD>
	</TR>
	{/if}
    </THEAD>
    <TBODY>
	{cycle values="light,lucid" print=false}
	{section name=domainlist loop=$domainlist start=$start max=$pagelimit}
	<TR class="highlight {cycle}" data-name="{$domainlist[domainlist].name}">
		<TD NOWRAP onclick="return self.location.href='?m=domaininfo&amp;id={$domainlist[domainlist].id}'">
			<IMG src="img/domain.gif" alt=""{if $domainlist[domainlist].description} {tip text=$domainlist[domainlist].description}{/if}><B> {$domainlist[domainlist].name}</B>
		</TD>
		<TD align="right" NOWRAP onclick="return self.location.href='?m=domaininfo&amp;id={$domainlist[domainlist].id}'">
			({$domainlist[domainlist].id|string_format:"%04d"})
		</TD>
                <TD NOWRAP onclick="return self.location.href='?m=domaininfo&amp;id={$domainlist[domainlist].id}'">
            		{$domainlist[domainlist].type}
                </TD>
		<TD align="left" NOWRAP onclick="return self.location.href='?m=domaininfo&amp;id={$domainlist[domainlist].id}'">
			{if $domainlist[domainlist].ownerid}
			<IMG src="img/customer.gif" alt="">
			<A href="?m=customerinfo&amp;id={$domainlist[domainlist].ownerid}">{$domainlist[domainlist].customername|truncate:45:"&hellip;":true} ({$domainlist[domainlist].ownerid|string_format:"%04d"})</A>
			{/if}
		</TD>
		<TD align="right" onclick="return self.location.href='?m=domaininfo&amp;id={$domainlist[domainlist].id}'">
			{$domainlist[domainlist].cnt|default:0}
		</TD>
		<TD align="right" NOWRAP>
			<A class="delete-domain" href="?m=domaindel&id={$domainlist[domainlist].id}"><IMG src="img/delete.gif" alt="{trans("Delete")}" title="{trans("Delete")}"></A>
			<A href="?m=domainedit&amp;id={$domainlist[domainlist].id}"><IMG src="img/edit.gif" alt="{trans("Edit")}" title="{trans("Edit")}"></A>
			<A href="?m=domaininfo&amp;id={$domainlist[domainlist].id}"><IMG src="img/info.gif" alt="{trans("Info")}" title="{trans("Info")}"></A>
		</TD>
	</TR>
	{sectionelse}
	<tr>
		<td colspan="6" class="empty-table">
			{trans("No such domains in database.")}
		</td>
	</tr>
	{/section}
    </TBODY>
    <TFOOT>
	{if $listdata.total != 0}
	<TR>
		<TD class="lms-ui-pagination" COLSPAN="6">
			{include file="scroller.html" loop=$domainlist adlink=$suffix}
		</TD>
	</TR>
	{/if}
	<TR>
		<TD colspan="5" align="right">
			<B>{trans("Total:")} {sum array=$domainlist column="cnt"}</B>
		</TD>
		<TD align="right" nowrap>
			<A href="?m=domainadd&amp;cid={$listdata.customer}">{trans("New Domain")} <IMG src="img/save.gif" alt=""></A>
		</TD>
	</TR>
    </TFOOT>
</TABLE>
	<script>
		$('.delete-domain').click(function() {
			var name = $(this).closest('tr').attr('data-name');
			confirmDialog($t("Are you sure, you want to delete domain: '$a' and all accounts/aliases in that domain?", name), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
	</script>
{/block}
