<?= $this->extend('backend/layout/login_layout'); ?>
<?= $this->section('title') ?>Set Password<?= $this->endSection() ?>
<?= $this->section('content') ?>
<div class="card">
    <div class="card-header text-center">
        <?= view_cell('LogoCell') ?>
        <span class="splash-description">Please enter your new password.</span>
    </div>
    <div class="card-body">
        <?= view_cell('AlertCell') ?>
        <?php $validation = service('validation'); ?>
        <?= form_open(route_to('set_password', $token), [
            'csrf_id' => 'csrf_id',
            'novalidate' => '',
            'id' => 'setPasswordForm'
        ]) ?>
        <div class="form-group">
            <?= form_password(
                [
                    'name' => 'password',
                    'id' => 'password',
                    'required' => true,
                    'placeholder' => 'Enter your password',
                    'class' => 'form-control form-control-lg',
                ],
                set_value('password', ''),
            ) ?>
        </div>
        <p class="text-danger small ps-2"><?= $validation->getError('password') ?></p>
        <div class="form-group">
            <?= form_password(
                [
                    'name' => 'password2',
                    'id' => 'password2',
                    'required' => true,
                    'placeholder' => 'Confirm your password',
                    'class' => 'form-control form-control-lg',
                ],
                set_value('password2', ''),
            ) ?>
        </div>
        <p class="text-danger small ps-2"><?= $validation->getError('password2') ?></p>
        <div class="form-group pt-1">
            <?= form_button(
                [
                    'type' => 'submit',
                    'class' => 'btn btn-block btn-primary btn-xl',
                ],
                'Submit',
            ) ?>
            <?= form_close() ?>
        </div>
        <div class="card-footer text-center">
            <span><a href="<?= url_to('login') ?>">Sign In</a></span>
        </div>
    </div>
    <?= $this->endSection() ?>

    <?= $this->section('js') ?>
    <script src="<?= base_url() ?>assets/common/js/jquery.validate.min.js"></script>
    <?= $this->endSection() ?>

    <?= $this->section('scripts'); ?>
    <script>
        $("#setPasswordForm").submit(function(event) {
            var vForm = $(this);
            if (vForm[0].checkValidity() === false) {
                event.preventDefault()
                event.stopPropagation()
            }
            vForm.addClass('was-validated');
        });

        //signature pad
    </script>
    <?= $this->endSection() ?>