<?php

use Jet\Tr;
use Jet\UI;
use Jet\Form;
use Jet\MVC_View;
use JetApplication\Application_Web_Pages;

/**
 * @var MVC_View $this
 * @var Form $form
 */
$form = $this->getRaw( 'login_form' );

$form->field( 'username' )->setPlaceholder( 'username' );
$form->field( 'password' )->setPlaceholder( 'password' );

$password_reset_page = Application_Web_Pages::resetPassword();
?>

<div class="col-md-6 offset-md-3 col-sm-8 offset-sm-2">
	<div class="card">
		<h5 class="card-header">
			<?= Tr::_( 'Sign In' ) ?>
			<?php require '_language_select.phtml'; ?>
		</h5>

		<?= $form->start() ?>
		<div class="card-body">
			<?php if( $form->getCommonMessage() ): ?>
				<div id="login-alert" class="alert alert-danger">
					<?= $form->getCommonMessage() ?>
				</div>
			<?php endif; ?>

			<div style="margin-bottom: 25px" class="input-group">
				<div class="input-group-prepend">
					<span class="input-group-text"><?= UI::icon( 'user' ) ?></span>
				</div>
				<?= $form->field( 'username' )->input() ?>
			</div>

			<div style="margin-bottom: 25px" class="input-group">
				<div class="input-group-prepend">
					<span class="input-group-text"><?= UI::icon( 'lock' )->setTag( 'i' ) ?></span>
				</div>
				<?= $form->field( 'password' )->input() ?>
			</div>
			
			<div style="display: grid;grid-template-columns: 1fr 1fr;">
				<div>
					<?php if($password_reset_page): ?>
					<a href="<?=$password_reset_page->getURL()?>"><?=Tr::_('I forget my password')?></a>
					<?php endif ?>
				</div>
				<div class="text-right">
					<input type="submit" class="btn btn-primary" value="<?= Tr::_( 'Sign In' ) ?>"/>
				</div>
			</div>
		</div>
		<?= $form->end() ?>
	</div>
</div>
