{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
 {if $layout.module=="aliassearch"}{assign var=suffix value="&s=1"}{/if}
<H1>{$layout.pagetitle}</H1>
<TABLE class="lmsbox">
    <COLGROUP>
        <COL style="width: 41%;">
        <COL style="width: 1%;">
        <COL style="width: 57%;">
        <COL style="width: 1%;">
    </COLGROUP>
    <THEAD>
	<TR>
		<TH scope="col" class="nobr">
			<IMG src="img/alias.gif" alt=""> <A href="?m={$layout.module}{$suffix}&o=login{if $listdata.direction == "asc" && $listdata.order == "login"},desc{/if}">{trans("Login<!account>")}</A> {if $listdata.order == "login"}<IMG src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">{/if}
			@
			<A href="?m={$layout.module}{$suffix}&o=domain{if $listdata.direction == "asc" && $listdata.order == "domain"},desc{/if}">{trans("Domain:")}</A> {if $listdata.order == "domain"}<IMG src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">{/if}
		</TH>
		<TH scope="col" class="text-right lighter nobr">
                        <A href="?m={$layout.module}{$suffix}&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}
		</TH>
		<TH scope="col" class="text-right lighter nobr">
                        <IMG src="img/account.gif" alt=""> <A href="?m={$layout.module}{$suffix}&o=dest{if $listdata.direction == "asc" && $listdata.order == "dest"},desc{/if}">{trans("Destination:")}</A> {if $listdata.order == "dest"}<IMG src="img/{if $listdata.direction == "desc"}asc{else}desc{/if}_order.gif" alt="">{/if}
		</TH>
		<TH scope="col" class="nobr">
                        {t a=$listdata.total}Total: $a{/t}
		</TH>
	</TR>
	<TR>
		<TD colspan="3" class="nobr">
                                <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("Domain's owner:")}
                                        <SELECT size="1" name="u" 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;"}</OPTION>
                                                {/foreach}
                                        </SELECT>&nbsp;
                                        {trans("Domain:")}
                                        <SELECT size="1" name="d" OnChange="document.filter.submit();">
                                                <OPTION value=""{if $listdata.domainid == ""} SELECTED{/if}>{trans("— all —")}</OPTION>
                                        {foreach from=$domainlist item=item}
                                                <OPTION value="{$item.id}"{if $item.id == $listdata.domain} SELECTED{/if}>{$item.name}</OPTION>
                                        {/foreach}
                                        </SELECT>
                                </FORM>
                </TD>
                <TD class="text-right nobr">
                        <A href="?m=aliasadd{if $listdata.domain}&domainid={$listdata.domain}{/if}">{trans("New Alias")} <IMG src="img/save.gif" alt=""></A>
                </TD>
	</TR>
	{if $listdata.total != 0}
	<TR>
		<TD class="lms-ui-pagination" COLSPAN="4">
			{include file="scroller.html" loop=$aliaslist adlink=$suffix}
		</TD>
	</TR>
	{/if}
    </THEAD>
    <TBODY>
	{cycle values="light,lucid" print=false}
	{section name=aliaslist loop=$aliaslist start=$start max=$pagelimit}
	<TR class="highlight {cycle}{if $aliaslist[aliaslist].expdate != 0 && $aliaslist[aliaslist].expdate < $smarty.now} blend{/if}" data-name="{$aliaslist[aliaslist].login}@{$aliaslist[aliaslist].domain}">
		<TD onclick="return self.location.href='?m=aliasinfo&id={$aliaslist[aliaslist].id}';">
                        <SPAN class="nobr bold"><IMG src="img/alias.gif" ALT="" > {$aliaslist[aliaslist].login}@{$aliaslist[aliaslist].domain}</SPAN>
		</TD>
		<TD class="text-right" onclick="return self.location.href='?m=aliasinfo&id={$aliaslist[aliaslist].id}';">
			({$aliaslist[aliaslist].id|string_format:"%04d"})
		</TD>
		<TD onclick="return self.location.href='?m=aliasinfo&id={$aliaslist[aliaslist].id}';">
			{if $aliaslist[aliaslist].accounts}<IMG src="img/account.gif" alt="">{$aliaslist[aliaslist].accounts|replace:",":"<BR><IMG src=\"img/account.gif\" alt=\"\">"}{/if}<BR>
			{if $aliaslist[aliaslist].forwards}<IMG src="img/forward.gif" alt="">{$aliaslist[aliaslist].forwards|replace:",":"<BR><IMG src=\"img/forward.gif\" alt=\"\">"}{/if}
		</TD>
		<TD class="text-right">
			{assign var=alias value="`$aliaslist[aliaslist].login`@`$aliaslist[aliaslist].domain`"}
                        <SPAN class="nobr">
			<A class="delete-alias" href="?m=aliasdel&id={$aliaslist[aliaslist].id}"><IMG src="img/delete.gif" alt="{trans("Delete")}" title="{trans("Delete")}"></A>
			<A href="?m=aliasedit&id={$aliaslist[aliaslist].id}"><IMG src="img/edit.gif" alt="{trans("Edit")}" title="{trans("Edit")}"></A>
			<A href="?m=aliasinfo&id={$aliaslist[aliaslist].id}"><IMG src="img/info.gif" alt="{trans("Info")}" title="{trans("Info")}"></A>
                        </SPAN>
		</TD>
	</TR>
	{sectionelse}
	<tr>
		<td colspan="4" class="empty-table">
			{trans("No such aliases in database.")}
		</td>
	</tr>
	{/section}
	{if $listdata.total != 0}
	<TR>
		<TD class="lms-ui-pagination" colspan="4">
			{include file="scroller.html" loop=$aliaslist adlink=$suffix}
		</TD>
	</TR>
	{/if}
    </TBODY>
    <TFOOT>
	<TR>
		<TD colspan="2" class="text-right nobr">
                        <IMG SRC="img/info2.gif" alt=""> {t a=$listdata.total}Total: $a{/t}
		</TD>
		<TD colspan="2" class="text-right nobr">
                        <A href="?m=aliasadd{if $listdata.domain}&domainid={$listdata.domain}{/if}">{trans("New Alias")} <IMG src="img/save.gif" alt=""></A>
		</TD>
	</TR>
    </TFOOT>
</TABLE>
	<script>
		$('.delete-alias').click(function() {
			var name = $(this).closest('tr').attr('data-name');
			confirmDialog($t("Are you sure, you want to delete alias: '$a'?", name), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
	</script>
{/block}
