{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<SCRIPT type="text/javascript">
<!--
function addaccount()
{
	document.aliasedit.action += '&addaccount=1';
	document.aliasedit.submit();
}

function addmailforward()
{
	document.aliasedit.action += '&addmailforward=1';
	document.aliasedit.submit();
}

function delaccount(id)
{
	document.aliasedit.action += '&delaccount=' + id;
	document.aliasedit.submit();
}

function delmailforward(mailforward)
{
	document.aliasedit.action += '&delmailforward=' + mailforward;
	document.aliasedit.submit();
}

function togglelogin()
{
	document.aliasedit.login.disabled =
		!document.aliasedit.login.disabled;
}
//-->
</SCRIPT>
<H1>{$layout.pagetitle}</H1>
<FORM name="aliasedit" method="POST" action="?m=aliasedit&id={$alias.id}">
<INPUT type="submit" class="hiddenbtn">
<TABLE class="lmsbox">
    <THEAD>
	<TR>
		<TD width="1%">
			<IMG src="img/alias.gif" alt="">
		</TD>
		<TD width="1%">
			<B>{trans("Login:")}</B>
		</TD>
		<TD width="98%">
			<INPUT type="text" name="alias[login]" id="login" value="{$alias.login}" required {tip text="Enter alias name" trigger="login"} size="20" {if $alias.domainalias}disabled{/if}>
			<INPUT type="checkbox" name="alias[domainalias]" id="domainalias" value="1" onchange="togglelogin()" {if $alias.domainalias}checked{/if}><label for="domainalias">{trans("domain alias")}</label>
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	<TR>
		<TD width="1%">
			<IMG src="img/domain.gif" alt="">
		</TD>
		<TD width="1%">
			<B>{trans("Domain:")}</B>
		</TD>
		<TD width="98%">
			<select name="alias[domainid]" {tip text="Select domain name" trigger="domainid"}>
				<option value="0" {if !$alias.domainid}SELECTED{/if}>{trans("— select domain —")}</option>
    				{foreach from=$domainlist item=item}
				<option value="{$item.id}"{if $item.id == $alias.domainid} SELECTED{/if}>{$item.name}</option>
	    			{/foreach}
			</select>
		</TD>
	</TR>
	<TR>
		<TD width="1%">
			<IMG src="img/account.gif" alt="">
		</TD>
		<TD width="1%">
			<B>{trans("Destination:")}</B>
		</TD>
		<TD width="98%">
			{foreach from=$alias.accounts item=account}
			{$account.login}@{$account.domain}
			<A href="javascript:delaccount({$account.id})"><IMG src="img/delete.gif" alt="" {tip text="Delete"}></A><BR>
			{/foreach}
			<SELECT size="1" name="alias[accountid]" {tip text="Select account" trigger="accountid"}>
				<OPTION value="0"{if !$alias.accountid} SELECTED{/if}>{trans("— select account —")}</OPTION>
				{foreach from=$accountlist item=item}
				<OPTION value="{$item.id}"{if $item.id == $alias.accountid} SELECTED{/if}>{$item.login}@{$item.domain}</OPTION>
				{/foreach}
			</SELECT>
			<A href="javascript:addaccount()"><IMG src="img/add.gif" alt="" {tip text="Add"}></A>
		</TD>
	</TR>
	<TR>
		<TD width="1%">
			<IMG src="img/forward.gif" alt="">
		</TD>
		<TD width="1%" NOWRAP>
			<B>{trans("Forward e-mail:")}</B>
		</TD>
		<TD WIDTH="98%">
			{foreach from=$alias.mailforwards item=mailforward}
			{$mailforward}
			<A href="javascript:delmailforward('{$mailforward}')"><IMG src="img/delete.gif" alt="" {tip text="Delete"}></A><BR>
			{/foreach}
			<INPUT type="text" name="alias[mailforward]" value="" {tip text="Enter destination e-mail address for redirect (optional)" trigger="mailforward"} size="25">
			<A href="javascript:addmailforward()"><IMG src="img/add.gif" alt="" {tip text="Add"}></A>
		</TD>
	</TR>
	<TR>
		<TD colspan="3" align="right" nowrap>
			<A href="javascript: document.aliasedit.submit();" accesskey="s">{trans("Submit")} <IMG SRC="img/save.gif" ALT=""></A>
			<A href="?m=aliaslist">{trans("Cancel")} <IMG SRC="img/cancel.gif" ALT=""></A>
		</TD>
	</TR>
    </TBODY>
</TABLE>
</FORM>
<SCRIPT type="text/javascript">
<!--//
$(function() {
	$('form[name="aliasedit"] [name="alias[login]"]').focus();
});
//-->
</SCRIPT>
{/block}
