<!--// $Id$ //-->
{box title="Login data"}
<div class="card">
	<div class="card-header">
		<strong>{trans("Login data")}</strong>
	</div>
	<ul class="list-group list-group-flush">
		<li class="list-group-item">
			<strong>{trans("Customer ID")}:</strong>{$userinfo.id|string_format:"%04d"}
		</li>
		<li class="list-group-item">
			<strong>{trans("PIN")}:</strong>******
			{if ConfigHelper::checkConfig('userpanel.pin_changes') || isset($passwd_change_required)}
				{button id="updatepinbtn" class="btn btn-primary btn-sm" data_toggle="modal" data_target="#updatepinbox" accesskey="P" icon="modify" label="Change"}
			{/if}
		</li>
	</ul>
</div>

{/box}

{$pin_tip = ConfigHelper::getConfig('customers.pin_restriction_description', ConfigHelper::getConfig('phpui.pin_restriction_description'))}

<div class="modal fade" id="updatepinbox" tabindex="-1" role="dialog" aria-labelledby="updatepinbox" aria-hidden="true">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title">{trans("PIN Update")}</h4>
				{button class="close" data_dismiss="modal" icon="cancel"}
			</div>
			<div class="modal-body">
				{if isset($passwd_change_required)}
					<div class="alert alert-danger">{trans("PIN change required!")}</div>
				{/if}
				{if $error.oldpin}
				<div class="alert alert-danger">{$error.oldpin}</div>
				{/if}
				{if $error.pin}
				<div class="alert alert-danger">{$error.pin}</div>
				{/if}
				<form name="userpin" method="post" action="?m=info&f=updatepin">
					<div class="form-group">
						<label for="oldpin"><strong>{trans("Current PIN")}:</strong></label>
						<input id="oldpin" type="password" class="form-control" name="userdata[oldpin]" placeholder="{trans("Enter current PIN")}">
					</div>
					<div class="form-group">
						<label for="pin"><strong>{trans("New PIN")}:</strong></label>
						<input id="pin" type="password" class="form-control" name="userdata[pin]" placeholder="{trans("Enter new PIN")}"{if $pin_tip} title="{$pin_tip}"{/if}>
					</div>
					<div class="form-group">
						<label for="pin2"><strong>{trans("New PIN confirm")}:</strong></label>
						<input id="pin2" type="password" class="form-control" name="userdata[pin2]" placeholder="{trans("Enter new PIN (again)")}"{if $pin_tip} title="{$pin_tip}"{/if}>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				{button type="submit" class="btn btn-danger" href="javascript:document.userpin.submit()" accesskey="A" icon="save" label="Save"}
				{button class="btn btn-secondary" data_dismiss="modal" icon="close" label="Close"}
			</div>
		</div>
	</div>
</div>

<script>

	$(function() {
		$('#updatepinbtn').click(function() {
			$($(this).attr('data-target')).find('.alert').remove();
		});

		{if $error.oldpin || $error.pin || $error.pin2 || isset($passwd_change_required)}
			$('#updatepinbox').modal('show');
		{elseif isset($error) && !isset($error.files)}
			$('#updateuserinfobox').modal('show');
		{/if}
	});

</script>
