diff --git a/backend/modules/card/controllers/UserCardController.php b/backend/modules/card/controllers/UserCardController.php
index 6c4f95f..1d28e09 100755
--- a/backend/modules/card/controllers/UserCardController.php
+++ b/backend/modules/card/controllers/UserCardController.php
@@ -65,6 +65,28 @@ class UserCardController extends Controller
]);
}
+ public function actionPassword($id)
+ {
+ $user_card = UserCard::findOne($id);
+ $model = User::findOne(['id' => $user_card->id_user]);
+
+ return $this->render('password', [
+ 'model' => $model,
+ ]);
+ }
+
+ public function actionAjax() {
+ if(Yii::$app->request->isAjax) {
+ $id = $_POST['id'];
+ $password = $_POST['password'];
+
+ $user_card = UserCard::findOne($id);
+ $user = User::findOne(['id' => $user_card->id_user]);
+ $user->password = $password;
+ $user->save();
+ }
+ }
+
/**
* Displays a single UserCard model.
* @param integer $id
diff --git a/backend/modules/card/views/user-card/password.php b/backend/modules/card/views/user-card/password.php
new file mode 100644
index 0000000..5b98274
--- /dev/null
+++ b/backend/modules/card/views/user-card/password.php
@@ -0,0 +1,22 @@
+
+
+ 'password-form',
+ 'enableClientValidation' => true,
+ 'enableAjaxValidation' => false,
+ 'method' => 'post',
+]); ?>
+
+
Введите новый пароль
+
+= Html::input('text', 'password', '', ['class' => 'form-control custom-input']) ?>
+
+
+
+= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
+ 'btn btn-success generate']); ?>
+
+
diff --git a/backend/modules/card/views/user-card/update.php b/backend/modules/card/views/user-card/update.php
index b448634..3dddd5e 100755
--- a/backend/modules/card/views/user-card/update.php
+++ b/backend/modules/card/views/user-card/update.php
@@ -12,6 +12,9 @@ $this->params['breadcrumbs'][] = 'Редактировать';
?>
+ $model->id], ['class' => 'btn btn-success']);
+ ?>
+
= $this->render('_form', [
'model' => $model,
]) ?>
diff --git a/backend/web/js/site.js b/backend/web/js/site.js
index 510e486..e920667 100644
--- a/backend/web/js/site.js
+++ b/backend/web/js/site.js
@@ -4,4 +4,44 @@ $(function(){
history.pushState({}, '', month);
$.pjax.reload({container:"#reload"});
})
-});
\ No newline at end of file
+});
+
+$(document).on("beforeSubmit", "#password-form", function (e) {
+ let form = $(this);
+ let formData = form.serialize();
+ let location = document.location.href;
+ location = location.split('=');
+ formData = formData.split('=');
+ console.log(formData[2]);
+
+ $.ajax({
+ url: 'ajax',
+ type: 'POST',
+ data: {
+ id: location[1],
+ password: formData[2],
+ },
+ password: formData[2],
+ success: function (response) {
+ window.location.replace('index');
+ },
+ error: function () {
+ }
+ });
+
+});
+
+$(document).ready(function () {
+ $('.generate').on('click', function () {
+ $(".custom-input").val(gen_password(8));
+ });
+});
+
+function gen_password(len){
+ var password = "";
+ var symbols = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ for (var i = 0; i < len; i++){
+ password += symbols.charAt(Math.floor(Math.random() * symbols.length));
+ }
+ return password;
+}
\ No newline at end of file