<!--// $Id$ //-->
<style>

	#qrcode-image {
		margin-top: 0.4em;
		padding: 0.4em;
		background-color: white;
	}

	#show-more-less {
		margin-left: 2em;
		width: 3em;
	}

	ul.excludedgroups {
		margin-block-end: 0.5em;
	}

	ul {
		padding-inline-start: 2em;
	}

</style>
<table class="lmsbox" style="width: 100%;" cellpadding="3">
	<colgroup>
		<col style="width: 1%;">
		<col style="width: 1%;">
		<col style="width: 98%;">
	</colgroup>
	<thead>
		<tr>
			<td class="nobr" colspan="3">
				{icon name="login"}
				<strong>{$userinfo.login} ({$userinfo.id|string_format:"%04d"})</strong>
			</td>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>
				{icon name="user"}
			</td>
			<td class="nobr">
				<strong>{trans("First name:")}</strong>
			</td>
			<td>
				<strong>{$userinfo.firstname|escape}</strong>
			</td>
		</tr>
		<tr>
			<td>
				{icon name="user"}
			</td>
			<td class="nobr">
				<strong>{trans("Last name:")}</strong>
			</td>
			<td>
				<strong>{$userinfo.lastname|escape}</strong>
			</td>
		</tr>
{if $userinfo.issuer}
		<tr>
			<td>
				{icon name="document"}
			</td>
			<td class="nobr">
				<strong>{trans("Issuer")}</strong>
			</td>
			<td>
				{$userinfo.issuer|escape}
			</td>
		</tr>
{/if}
{if $userinfo.position}
		<tr>
			<td class="nobr">
				{icon name="info"}
			</td>
			<td>
				<strong>{trans("Position:")}</strong>
			</td>
			<td>
				{$userinfo.position}
			</td>
		</tr>
{/if}
{if $userinfo.email}
		<tr>
			<td>
				{icon name="mail"}
			</td>
			<td>
				<strong>{trans("E-mail:")}</strong>
			</td>
			<td>
				<a href="mailto:{$userinfo.email}">{$userinfo.email}</a>
			</td>
		</tr>
{/if}
{if $userinfo.phone}
		<tr>
			<td>
				{icon name="sms"}
			</td>
			<td>
				<strong>{trans("Phone:")}</strong>
			</td>
			<td>
				{$userinfo.phone}
			</td>
		</tr>
{/if}
		<tr>
			<td>
				{icon name="options"}
			</td>
			<td>
				<strong>{trans("Notification:")}</strong>
			</td>
			<td>
				{if !$userinfo.ntype}{trans("none")}{else}{$userinfo.ntype}{/if}
			</td>
		</tr>
		<tr>
			<td>
				{if $userinfo.access}
					{icon name="connected"}
				{else}
					{icon name="disconnected"}
				{/if}
			</td>
			<td>
				<strong>{trans("Account active:")}</strong>
			</td>
			<td>
				{if $userinfo.access}{icon name="checked" tip="yes"}{else}-{/if}
			</td>
		</tr>
{if $userinfo.accessfrom || $userinfo.accessto}
		<tr>
			<td>
				{icon name="calendar"}
			</td>
			<td>
				<strong>{trans("Access period")}</strong>
			</td>
			<td>
				{if $userinfo.accessfrom}<strong>{trans("from")}:</strong> {$userinfo.accessfrom}{/if}
				{if $userinfo.accessto}<strong>{trans("to")}:</strong> {$userinfo.accessto}{/if}
			</td>
		</tr>
{/if}
{if $userinfo.passwdforcechange}
		<tr>
			<td>
				{icon name="password"}
			</td>
			<td class="nobr">
				<strong>{trans("Force password change:")}</strong>
			</td>
			<td class="nobr">
				{trans("yes")}
			</td>
		</tr>
{/if}
		<tr>
			<td>
				{icon name="password"}
			</td>
			<td class="nobr">
				<strong>{trans("Two factor authentication:")}</strong>
			</td>
			<td class="nobr">
				{if $userinfo.twofactorauth}
					{trans("yes")}
					{if ConfigHelper::checkPrivilege('user_management')}
						&nbsp;&nbsp;
						{button icon="password" id="secretkey-show-button" label="Show secret key"}
						{button icon="password" id="secretkey-hide-button" label="Hide secret key" visible=false}
					{/if}
				{else}
					{trans("no")}
				{/if}
			</td>
		</tr>
{if ConfigHelper::checkPrivilege('user_management') && $userinfo.twofactorauth}
		<tr id="secretkey" style="display: none;">
			<td colspan="2"></td>
			<td>
				{$userinfo.twofactorauthsecretkey}
				<br>
				<img id="qrcode-image" src="data:image/png;base64, {$qrcode_image}">
			</td>
		</tr>
{/if}
		<tr>
			<td class="valign-top">
				{icon name="ipnetwork"}
			</td>
			<td class="valign-top nobr">
				<strong>{trans("Allowed hosts")}</strong>
			</td>
			<td class="nobr">
				{if $userinfo.hosts}{nl2br($userinfo.hosts|escape)}{else}{trans("all")}{/if}
			</td>
		</tr>
		<tr>
			<td class="valign-top">
				{icon name="ipnetwork"}
			</td>
			<td class="valign-top nobr">
				<strong>{trans("Trusted hosts")}</strong>
			</td>
			<td class="nobr">
				{if $userinfo.trustedhosts}{nl2br($userinfo.trustedhosts|escape)}{else}{trans("<!trusted-hosts>none")}{/if}
			</td>
		</tr>
		<tr>
			<td>
				{icon name="password"}
			</td>
			<td class="nobr">
				<strong>{trans("Password expiration:")}</strong>
			</td>
			<td class="nobr">
				{$_PASSWDEXPIRATIONS[$userinfo.passwdexpiration]}
			</td>
		</tr>
		<tr>
			<td>
				{icon name="password"}
			</td>
			<td class="nobr">
				<strong>{trans("Last password change:")}</strong>
			</td>
			<td class="nobr">
				{$userinfo.passwdlastchange}
			</td>
		</tr>
		<tr>
			<td>
				{icon name="permissions"}
			</td>
			<td class="nobr">
				<strong>{trans("Access rights:")}</strong>
			</td>
			<td>
				<ul>
					{foreach $accesslist as $access}
						{if $access.enabled}
							<li class="acl">{$access.name}</li>
						{/if}
					{/foreach}
				</ul>
			</td>
		</tr>

		<tr>
			<td>
				{icon name="usergroup"}
			</td>
			<td class="nobr">
				<strong>{trans("User groups:")}</strong>
			</td>
			<td>
				{foreach $userinfo.usergroups as $item}
					{if $item@first}<ul>{/if}
						<li><a href="?m=usergroupinfo&id={$item.id}">{$item.name}</a></li>
					{if $item@last}</ul>{/if}
				{/foreach}
			</td>
		</tr>

		<tr>
			<td>
				{icon name="customergroup"}
			</td>
			<td class="nobr">
				<strong>{trans("Excluded groups:")}</strong>
			</td>
			<td>
				{foreach $excludedgroups as $item}
					{if $item@first}<ul class="excludedgroups">{/if}
					<li class="acl excludedgroup"{if $item@iteration > 10} style="display: none;"{/if}><a href="?m=customergroupinfo&id={$item.id}">{$item.name}</a></li>
					{if $item@last}
						</ul>
						{if $item@iteration > 10}
							{button icon="more" tip="Show more/less" id="show-more-less"}
						{/if}
					{/if}
				{foreachelse}
				-
				{/foreach}
			</td>
		</tr>

		<tr>
			<td>
				{icon name="division"}
			</td>
			<td class="nobr">
				<strong>{trans("Divisions:")}</strong>
			</td>
			<td>
				{foreach $user_divisions as $item}
					{if $item@first}<ul>{/if}
					<li><a href="?m=divisionedit&id={$item.id}">{$item.label|escape}</a></li>
					{if $item@last}</ul>{/if}
				{/foreach}
			</td>
		</tr>

		<tr>
			<td></td>
			<td class="nobr">
				<strong>{trans("Last login:")}</strong>
			</td>
			<td>
				{$userinfo.lastlogin}, {$userinfo.lastloginip} {if $userinfo.lastloginip != $userinfo.lastloginhost}({$userinfo.lastloginhost}){/if}
			</td>
		</tr>
		<tr>
			<td></td>
			<td class="nobr">
				<strong>{trans("Last failed login:")}</strong>
			</td>
			<td>
				{$userinfo.faillogin}, {$userinfo.failedloginip} {if $userinfo.failedloginip != $userinfo.failedloginhost}({$userinfo.failedloginhost}){/if}
			</td>
		</tr>
		{block name="other-information"}
		{/block}
		<tr>
			<td colspan="3" class="lms-ui-box-buttons">
				{if $layout.logid ne $userinfo.id}
					{if !$userinfo.access}
						{button label="Connect" icon="disconnected" href="?m=useraccess&id={$userinfo.id}&access=1"}
					{else}
						{button label="Disconnect" icon="connected" href="?m=useraccess&id={$userinfo.id}&access=0"}
					{/if}
				{/if}
				{button type="link-button" label="Edit" icon="edit" href="?m=useredit&id={$userinfo.id}"}
				{button label="Delete" icon="delete" id="delete-user" data_href="?m=userdel&id={$userinfo.id}"}
				{if $layout.logid ne $userinfo.id}
					{if ConfigHelper::checkPrivilege('superuser')}
						{button label="Switch to" icon="login" href="?m=userswitch&id={$userinfo.id}"}
					{/if}
					{button label="Force password change" icon="password" href="?m=useredit&id={$userinfo.id}&forcepasswdchange=1"}
				{/if}
				{button type="link-button" label="Change password" icon="password" href="?m=userpasswd&id={$userinfo.id}"}
				{button type="link-button" label="Change network password" icon="password" href="?m=userpasswd&id={$userinfo.id}&net=1"}
				{button type="link-button" label="User list" icon="list" href="?m=userlist"}
			</td>
		</tr>
	</tbody>
</table>
<script>

	$('#delete-user').click(function() {
		confirmDialog($t("Are you sure, you want to irreversibly delete that user account?"), this).done(function() {
			location.href = $(this).attr('data-href');
		});
		return false;
	});

	$(function() {
		$('#secretkey-show-button').click(function() {
			$(this).hide();
			$('#secretkey-hide-button').show();
			$('#secretkey').show();
		});

		$('#secretkey-hide-button').click(function() {
			$(this).hide();
			$('#secretkey-show-button').show();
			$('#secretkey').hide();
		});

		$('#remove-trusted-devices').click(function() {
			confirmDialog($t("Are you sure you want to remove all trusted devices?"), this).done(function() {
				location.href = '?m=useredit&id={$userinfo.id}&removetrusteddevices=1';
			});
			return false;
		});

		$('#show-more-less').click(function() {
			$('.excludedgroup:nth-child(n+10)').toggle();
			$(this).find('i').toggleClass('lms-ui-icon-more lms-ui-icon-less');
		});
	});

</script>
