<%!
from baruwa.lib.filters import default
%>
<% 
account_types = {1: _('Administrator'), 2: _('Domain Administrator'), 3: _('User')}
account_type = account_types[c.account.account_type]
%>
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
		<ul id="msgops">
		  % if len(c.account.signatures) < 2:
			<li>${h.link_to(_('Add signatures'), url('account-sigs-add', userid=c.account.id))}</li>
		  % endif
		  % if c.user.is_admin:
		    <li>${h.link_to(_('Add alias address'), url(controller='accounts', action='addaddress', userid=c.account.id))}</li>
			<li>${h.link_to(_('Update account'), url(controller='accounts', action='edit', userid=c.account.id))}</li>
			<li>${h.link_to(_('Delete account'), url('account-delete', userid=c.account.id))}</li>
		    % if not c.account.is_superadmin and c.account.local:
		  	 <li>${h.link_to(_('Change password'), url('accounts-pw-change', userid=c.account.id))}</li>
		    % endif
		  % else:
		    % if c.account.local:
		  	<li>${h.link_to(_('Change password'), url('accounts-pw-uchange', userid=c.account.id))}</li>
		    % else:
		    <li>${_('Change password')}</li>
		    % endif
			<li>${h.link_to(_('Update account'), url('account-edit', userid=c.account.id))}</li>
		  % endif
		</ul>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
    	<h3 class="head smaller lighter blue">${_("Showing: %(a)s account details") % dict(a=c.account.username)}</h3>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Username')}:
			</div>
			<div class="span6 real-half">
				${c.account.username}
			</div>
		</div>	
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Full names')}:
			</div>
			<div class="span6 real-half">
				${c.account.firstname} ${c.account.lastname}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Email Address')}:
			</div>
			<div class="span6 real-half">
				${c.account.email}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Account status')}:
			</div>
			<div class="span6 real-half">
				${functions.item_status(c.account.active)}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Timezone')}:
			</div>
			<div class="span6 real-half">
				${c.account.timezone}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Last login')}:
			</div>
			<div class="span6 real-half">
				${h.datetimeformat(h.format_date(c.account.last_login, c.tzinfo), format='%Y-%m-%d %H:%M:%S %z (%Z)')}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Account created on')}:
			</div>
			<div class="span6 real-half">
				${h.datetimeformat(h.format_date(c.account.created_on, c.tzinfo), format='%Y-%m-%d %H:%M:%S %z (%Z)')}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Account type')}:
			</div>
			<div class="span6 real-half">
				${account_type} [ ${_('Local account') if c.account.local else _('External account')} ]
			</div>
		</div>
		% if c.account.is_domain_admin:
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Organizations')}:
			</div>
			<div class="span6 real-half">
				<%
				orglinks = []
				for org in c.account.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}
			</div>
		</div>
		% endif
		% if c.account.is_peleb:
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Domains')}:
			</div>
			<div class="span6 real-half">
				<%
				domlinks = [domain.name for domain in c.account.domains]
				%>
				${', '.join(domlinks)}
			</div>
		</div>
		% endif
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Perform Spam checks')}:
			</div>
			<div class="span6 real-half">
				${functions.item_status(c.account.spam_checks)}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Send reports')}:
			</div>
			<div class="span6 real-half">
				${functions.item_status(c.account.send_report)}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Spam Low Score')}:
			</div>
			<div class="span6 real-half">
				${c.account.low_score|default}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Spam High Score')}:
			</div>
			<div class="span6 real-half">
				${c.account.high_score|default}
			</div>
		</div>
		<div class="row-fluid">
		    <h3 class="head smaller lighter blue">${_('Alias Addresses')}</h3>
		</div>
		% if c.account.addresses:
		% 	for address in c.account.addresses:
			<div class="row-fluid">
				<div class="span9">
					${address.address}
				</div>
				<div class="span1 half">
					${functions.item_status(address.enabled)}
				</div>
				<div class="span1 half">
					% if c.user.is_admin:
					${h.link_to(h.literal('<i class="icon-edit blue"></i>'), url('address-edit', addressid=address.id), title=_("Update alias address"))}
					% else:
					${h.literal('<i class="icon-edit blue"></i>')}
					% endif
				</div>
				<div class="span1 half">
					% if c.user.is_admin:
					${h.link_to(h.literal('<i class="icon-remove red"></i>'), url('address-delete', addressid=address.id), title=_("Delete alias address"))}
					% else:
					${h.literal('<i class="icon-remove red"></i>')}
					% endif
				</div>
			</div>
		% 	endfor
		% else:
			<div class="row-fluid">
				<div class="span12">${_('No alias addresses configured')}</div>	 
			</div>
		% endif
		<div class="row-fluid">
		    <h3 class="head smaller lighter blue">${_('Email Signatures')}</h3>
		</div>
		% if c.account.signatures:
		% 	for sig in c.account.signatures:
			<div class="row-fluid">
				<div class="span9">
					${_('Text signature') if sig.signature_type == 1 else _('HTML Signature')}
				</div>
				<div class="span1 half">
					${functions.item_status(sig.enabled)}
				</div>
				<div class="span1 half">
					${h.link_to(h.literal('<i class="icon-edit blue"></i>'), url('account-sigs-edit', sigid=sig.id), title=_("Edit email signatures"))}
				</div>
				<div class="span1 half">
					${h.link_to(h.literal('<i class="icon-remove red"></i>'), url('account-sigs-delete', sigid=sig.id), title=_("Delete email signatures"))}
				</div>
			</div>
		% 	endfor
		% else:
			<div class="row-fluid">
				<div class="span12">${_('No Email Signatures configured')}</div>	 
			</div>
		% endif
	</div>
	<div class="span1 hidden-phone"></div>
</div>

<%def name="title()">\
${_('Accounts :: Account details :: %(a)s') % dict(a=c.account.username)}
</%def>
<%def name="heading()">\
${self.title()}
</%def>
<%def name="headers()">
</%def>
<%def name="submenu()">\
% if c.account.is_admin:
<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(_('Apps & API'), url('api-pages-index', userid=c.account.id))}</li>
            </ul>
        </div>
    </div>
</div>
% endif
</%def>
<%def name="localscripts()">\
</%def>
<%namespace name="functions" file="../includes/functions.html"/>
<%inherit file="../base.html"/>
