{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<H1>{$layout.pagetitle}</H1>
<TABLE class="lmsbox">
    <THEAD>
	<TR>
		<TD width="1%">
			<img src="img/account.gif" alt="">
		</TD>
		<TD width="1%">
			<B>{trans("Login:")}</B>
		</TD>
		<TD width="98%">
			<B>{$account.login}</B>
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	<TR>
	    <TD width="100%" colspan="3" class="container">
		<TABLE width="100%" cellpadding="0">
		    <TR>
			<TD width="50%" style="vertical-align: top">
			    <TABLE width="100%" cellpadding="3">
				<TR>
				    <TD width="1%">
					<img src="img/domain.gif" alt="">
				    </TD>
				    <TD width="1%" nowrap>
					<B>{trans("Domain:")}</B>
				    </TD>
				    <TD width="98%">
					<a href="?m=domaininfo&id={$account.domainid}">{$account.domain}</a>
				    </TD>
				</TR>
			    	<TR>
				    <TD width="1%">
					<img src="img/customer.gif" alt="">
				    </TD>
				    <TD width="1%">
					<B>{trans("Owner:")}</B>
		    		    </TD>
				    <TD width="98%">
    					    {if !$account.ownerid}{trans("SYSTEM ACCOUNT")}
					    {else}<A href="?m=customerinfo&id={$account.ownerid}">{$account.customername}</A>{/if}
				    </TD>
				</TR>
				{if $account.realname}
				<TR>
				    <TD width="1%">
					<img src="img/name.gif" alt="">
				    </TD>
				    <TD width="1%" nowrap>
					<B>{trans("First/last or Company name:")}</B>
				    </TD>
				    <TD width="98%">
					{$account.realname}
				    </TD>
				</TR>
				{/if}
				<TR>
				    <TD width="1%">
					<img src="img/home.gif" alt="">
				    </TD>
				    <TD width="1%" nowrap>
					<B>{trans("Homedir:")}</B>
				    </TD>
				    <TD width="98%">
					{$account.home}
				    </TD>
				</TR>
				<TR>
				    <TD width="1%">
					<img src="img/calendar.gif" alt="">
				    </TD>
				    <TD width="1%" nowrap>
					<B>{trans("Expiration date:")}</B>
				    </TD>
				    <TD width="98%">
					{if $account.expdate}{$account.expdate|date_format:"Y-m-d"}{else}{trans("not expire")}{/if}
				    </TD>
			    	</TR>
				{if $account.mail_forward}
				<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%">
					<a href="mailto:{$account.mail_forward}">{$account.mail_forward}</a>
				    </TD>
			    	</TR>
				{/if}
				{if $account.mail_bcc}
				<TR>
				    <TD width="1%">
					<img src="img/forward.gif" alt="">
				    </TD>
				    <TD width="1%" nowrap>
					<B>{trans("BCC e-mail:")}</B>
				    </TD>
				    <TD width="98%">
					<a href="mailto:{$account.mail_bcc}">{$account.mail_bcc}</a>
				    </TD>
			    	</TR>
				{/if}
			    </TABLE>
			</TD>
			<TD width="50%" style="vertical-align: top">
			    <TABLE width="100%" cellpadding="3">
				<TR>
				    <TD width="1%">
					<img src="img/account.gif" alt="">
				    </TD>
				    <TD width="1%">
					<B>{trans("Type/Quota:")}</B>
				    </TD>
				    <TD width="98%">
						<table width="100%">
							{foreach $_ACCOUNTTYPES as $typeidx => $type}
							{if ($account.type & $typeidx) == $typeidx}
							<tr>
								<td style="width: 1%;" class="nobr">
									{$type.label}
								</td>
								<td style="width: 1%;">[</td>
								<td style="width: 1%;" class="text-right nobr">
									{$idx='quota_'|cat:$type.alias}
									{$account[$idx]} MB
								</td>
								<td style="width: 97%;">]</td>
							</tr>
							{/if}
							{/foreach}
						</table>
				    </TD>
				</TR>
				{if $account.description}
				<TR>
				    <TD width="1%">
					<img src="img/info.gif" alt="">
				    </TD>
				    <TD width="99%" colspan="2">
					<TABLE WIDTH="100%" CELLPADDING="5">
					    <TR>
					        <TD CLASS="fall superlight">
					            {$account.description|replace:"\n":"<BR>"}
					        </TD>
					    </TR>
					</TABLE>
				    </TD>
			    	</TR>
				{/if}
			    </TABLE>
			</TD>
		    </TR>
		</TABLE>
	    </TD>
	</TR>
	<TR>
		<TD align="right" colspan="3">
			<A href="?m=accountedit&id={$account.id}" accesskey="E">{trans("Edit")} <img src="img/edit.gif" alt=""></A>
			<A href="?m=accountpasswd&id={$account.id}">{trans("Change password")} <img src="img/pass.gif" alt=""></A>
			<A href="?m=aliasadd&accountid={$account.id}">{trans("Create alias")} <img src="img/alias.gif" alt=""></A>
			<A id="delete-account" href="?m=accountdel&id={$account.id}">{trans("Delete")} <img src="img/delete.gif" alt=""></A>
		</TD>
	</TR>
    </TBODY>
</TABLE>
<BR>
<TABLE class="lmsbox">
    <THEAD>
	<TR>
		<TD width="99%" align="left" nowrap="nowrap">
			<IMG src="img/alias.gif" alt="">
			{if empty($account.aliases)}{$count = 0}{else}{$count = count($account.aliases)}{/if}
			<B>{t a=$count}Account aliases ($a):{/t}</B>
		</TD>
		<TD width="1%" align="right" nowrap>
		        <A href="?m=aliasadd&accountid={$account.id}">{trans("New alias")} &raquo;</A>&nbsp;
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	<TR>
		<TD WIDTH="100%" colspan="2">
			<TABLE class="lmsbox-inner">
                            <THEAD>
				<TR>
					<TD WIDTH="80%" NOWRAP><B>{trans("Login<!account>")}@{trans("Domain:")}</B></TD>
					<TD WIDTH="19%" NOWRAP>{trans("ID:")}</TD>
					<TD WIDTH="1%">&nbsp;</TD>
				</TR>
                            </THEAD>
                            <TBODY>
				{cycle name=assign values="light,lucid" print=false}
				{foreach from=$account.aliases item=alias}
				<TR class="highlight {cycle name=assign}" data-name="{$alias.login}@{$alias.domain}" data-bindname="{$alias.login}@{$alias.domain}">
					<TD WIDTH="80%" NOWRAP OnClick="return self.location.href='?m=aliasinfo&id={$alias.id}'">
					    <B>{$alias.login}@{$alias.domain}</B>
					</TD>
					<TD WIDTH="19%" NOWRAP OnClick="return self.location.href='?m=aliasinfo&id={$alias.id}'">
					    ({$alias.id|string_format:"%04d"})
					</TD>
					<TD WIDTH="1%" ALIGN="RIGHT" NOWRAP>
					    <A class="delete-alias-bind" href="?m=aliasedit&id={$alias.id}&delaccount={$account.id}"><IMG src="img/eraser.gif" alt="{trans("Delete assignment")}" title="{trans("Delete assignment")}"></A>
					    <A class="delete-alias" href="?m=aliasdel&id={$alias.id}"><IMG src="img/delete.gif" alt="{trans("Delete")}" title="{trans("Delete")}"></A>
					    <A href="?m=aliasedit&id={$alias.id}"><IMG src="img/edit.gif" alt="{trans("Edit")}" title="{trans("Edit")}"></A>
					    <A href="?m=aliasinfo&id={$alias.id}"><IMG src="img/info.gif" alt="{trans("Info")}" title="{trans("Info")}"></A>
					</TD>
				</TR>
				{foreachelse}
				<tr>
					<td colspan="3" class="empty-table">
						{trans("There are no aliases for that account.")}
					</td>
				</tr>
				{/foreach}
                            </TBODY>
			</TABLE>
		</TD>
	</TR>
    </TBODY>
</TABLE>
	<script>
		$('#delete-account').click(function() {
			confirmDialog($t("Are you sure, you want to delete that account?"), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
		$('.delete-alias').click(function() {
			var aliasname = $(this).closest('tr').attr('data-name');
			confirmDialog($t("Are you sure, you want to delete alias: '$a'?", aliasname), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
		$('.delete-alias-bind').click(function() {
			var aliasbindname = $(this).closest('tr').attr('data-bindname');
			confirmDialog($t("Are you sure, you want to delete assignment with alias: '$a'?", aliasbindname), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
	</script>
{/block}
