{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<h1>{$layout.pagetitle|escape}</h1>
<form method="POST" action="{if $target}{$target}{else}?m=userpasswd&id={$passwd.id}{/if}{if !empty($net)}&net=1{/if}" name="password">
<input type="submit" class="hiddenbtn">
<table class="lmsbox">
	<thead>
		<tr>
			<td colspan="2" class="nobr">
				{icon name="password"}
				<strong>
					{if empty($net)}
						{trans("Enter new password")}
					{else}
						{trans("Enter new network password")}
					{/if}
				</strong>
			</td>
		</tr>
	</thead>
	<tbody>
		{if $current_password_required}
			<tr>
				<td class="text-right nobr">
					<strong>{trans("Current password")}</strong>
				</td>
				<td class="nobr">
					<input type="password" name="password[currentpasswd]"
						{tip trigger="currentpasswd"} required autocomplete="{if $passwd.id == $layout.logid}current-password{else}new-password{/if}">
				</td>
			</tr>
		{/if}
		<tr>
			<td class="text-right nobr">
				<strong>{trans("New password")}</strong>
			</td>
			<td class="nobr">
				<input type="password" name="password[passwd]"{if !$net} required{/if} {tip trigger="passwd"} autocomplete="new-password">
				{button type="link" icon="password" tip="Generate new password and copy it to clipboard" id="genpasswd" class="lms-ui-button-clipboard" data_clipboard_handler="1"}
			</td>
		</tr>
		<TR>
			<TD class="text-right nobr">
				<strong>{trans("Repeat password")}</strong>
			</TD>
			<TD class="nobr">
				<input type="password" name="password[confirm]"{if !$net} required{/if} {tip text="Confirm password" trigger="passwd"} autocomplete="new-password">
			</TD>
		</TR>
		<TR>
			<TD class="lms-ui-box-buttons" colspan="2">
				{button type="submit" icon="save" label="Submit"}
			</TD>
		</TR>
	</tbody>
</table>
</form>
<script>

	$(function() {
		{if isset($current_password_required)}
			$('form[name="password"] [name="password[currentpasswd]"]').focus();
		{else}
			$('form[name="password"] [name="password[passwd]"]').focus();
		{/if}

		$("#genpasswd").on("lms:clipboard:click", function(e) {
			var newPassword = generate_random_string({ConfigHelper::getConfig('users.default_password_length', 14)}, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
			$('[name="password[passwd]"],[name="password[confirm]"]').val(newPassword);
			e.result = newPassword;
		});
	});

</script>
{/block}
