124 lines
5.3 KiB
PHP
124 lines
5.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use yii\helpers\Html;
|
|
use yii\bootstrap\ActiveForm;
|
|
use yii\widgets\Pjax;
|
|
|
|
use app\models\AccountForm;
|
|
|
|
/**
|
|
* @todo Восстановить сохранение сессии
|
|
*/
|
|
?>
|
|
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="mx-auto">
|
|
<?php
|
|
|
|
// Инициализация идентификатора формы
|
|
if ($panel ?? false) {
|
|
// Генерация документа во всплывающем меню
|
|
|
|
// Инициализация параметров
|
|
$form_id = 'form_account_panel';
|
|
$target = 'panel';
|
|
} else {
|
|
// Генерация документа в основном блоке страницы
|
|
|
|
// Инициализация параметров
|
|
$form_id = 'form_account';
|
|
$target = 'main';
|
|
}
|
|
|
|
$form = ActiveForm::begin([
|
|
'id' => $form_id,
|
|
'action' => false,
|
|
'fieldConfig' => [
|
|
'template' => '{label}{input}{error}',
|
|
'options' => [
|
|
'class' => ''
|
|
]
|
|
],
|
|
'options' => [
|
|
'class' => 'form_account',
|
|
'onsubmit' => 'return false;'
|
|
],
|
|
'enableClientValidation' => false,
|
|
'enableAjaxValidation' => true
|
|
]);
|
|
|
|
$model = $model ?? new AccountForm;
|
|
?>
|
|
|
|
<?php if ($registration ?? false) : ?>
|
|
<?php if ($panel ?? false) : ?>
|
|
<h5 class="mb-4 text-center">Регистрация</h5>
|
|
<?php else : ?>
|
|
<h3 class="mb-4 text-center">Регистрация</h3>
|
|
<?php endif ?>
|
|
<?php else : ?>
|
|
<?php if ($panel ?? false) : ?>
|
|
<h5 class="mb-4 text-center">Аутентификация</h5>
|
|
<?php else : ?>
|
|
<h3 class="mb-4 text-center">Аутентификация</h3>
|
|
<?php endif ?>
|
|
<?php endif ?>
|
|
|
|
<?= $form->field($model, 'mail', ['enableLabel' => false, 'options' => ['class' => 'mb-2'], 'inputOptions' => ['class' => 'form-control button_clean'], 'errorOptions' => ['class' => 'help-block help-block-error px-2 small']])->textInput(['autofocus' => true, 'placeholder' => $model->getAttributeLabel('mail')]) ?>
|
|
<?= $form->field($model, 'pswd', ['enableLabel' => false, 'inputOptions' => ['class' => 'form-control button_clean'], 'errorOptions' => ['class' => 'help-block help-block-error px-2 small']])->passwordInput(['placeholder' => $model->getAttributeLabel('pswd')]) ?>
|
|
|
|
<div class="d-flex mb-2 mt-3">
|
|
<?= Html::submitButton('Войти', ['name' => 'submitAuthentication', 'onclick' => 'authentication(this.parentElement.parentElement, \'' . $target . '\');', 'class' => 'flex-grow-1 mr-2 btn btn-primary button_clean']) ?>
|
|
<?= $form->field($model, 'auto', ['checkboxTemplate' => '<div class="checkbox button_clean">{beginLabel}' .
|
|
Html::submitButton('{labelTitle}', ['name' => 'submit', 'data-toggle' => 'button', 'class' => 'w-100 btn btn-primary button_clean', 'aria-pressed' => 'false', 'onclick' => 'return authentication_auto_button_status_switch(this);']) .
|
|
'{endLabel}</div>'])->checkbox()->label($model->getAttributeLabel('auto'), ['class' => 'w-100 m-0']) ?>
|
|
</div>
|
|
|
|
<?= Html::submitButton('Регистрация', ['name' => 'submitRegistration', 'onclick' => 'return registration_start(this.parentElement, \'' . $target . '\');', 'class' => 'col-12 ml-auto btn btn-success btn-sm button_clean']) ?>
|
|
<small class="d-flex mt-2"><a class="mx-auto text-dark" type="button" onclick="restore(this.parentElement.parentElement)">Восстановить пароль</a></small>
|
|
|
|
<?php
|
|
|
|
ActiveForm::end();
|
|
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ($registration ?? false) : ?>
|
|
<script async="false">
|
|
// Инициализация формы
|
|
let form = document.getElementById('<?= $form_id ?>');
|
|
|
|
// Запуск программы регистрации
|
|
registration_start(form, 'panel');
|
|
|
|
if (document.readyState === "complete") {
|
|
// Документ загружен
|
|
|
|
// Обработчик события инициализации
|
|
$(form).on('afterInit', function(e) {
|
|
|
|
// Запуск программы регистрации
|
|
registration_start(form, 'panel');
|
|
});
|
|
} else {
|
|
// Документ не загружен
|
|
|
|
// Обработчик события загрузки документа
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Обработчик события инициализации
|
|
$(form).on('afterInit', function(e) {
|
|
|
|
// Запуск программы регистрации
|
|
registration_start(form, 'panel');
|
|
});
|
|
}, false);
|
|
}
|
|
</script>
|
|
<?php endif ?>
|