commit
56a22f6f1c
@ -15,6 +15,7 @@ class AppAsset extends AssetBundle
|
|||||||
'css/site.css',
|
'css/site.css',
|
||||||
];
|
];
|
||||||
public $js = [
|
public $js = [
|
||||||
|
'js/site.js'
|
||||||
];
|
];
|
||||||
public $depends = [
|
public $depends = [
|
||||||
'yii\web\YiiAsset',
|
'yii\web\YiiAsset',
|
||||||
|
@ -16,7 +16,7 @@ use yii\widgets\ActiveForm;
|
|||||||
|
|
||||||
<?= $form->field($model, 'login')->textInput(['maxlength' => true]) ?>
|
<?= $form->field($model, 'login')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'password')->passwordInput(['maxlength' => true]) ?>
|
<?= $form->field($model, 'password')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'link')->textInput(['maxlength' => true]) ?>
|
<?= $form->field($model, 'link')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
namespace frontend\modules\card\controllers;
|
namespace frontend\modules\card\controllers;
|
||||||
|
|
||||||
|
use common\classes\Debug;
|
||||||
use common\models\CardSkill;
|
use common\models\CardSkill;
|
||||||
use common\models\FieldsValueNew;
|
use common\models\FieldsValueNew;
|
||||||
|
use common\models\User;
|
||||||
use Yii;
|
use Yii;
|
||||||
use frontend\modules\card\models\UserCard;
|
use frontend\modules\card\models\UserCard;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
@ -57,7 +59,6 @@ class UserCardController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all();
|
$skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all();
|
||||||
|
|
||||||
return $this->render('view', [
|
return $this->render('view', [
|
||||||
'model' => $this->findModel($id),
|
'model' => $this->findModel($id),
|
||||||
'modelFildValue' => $dataProvider,
|
'modelFildValue' => $dataProvider,
|
||||||
@ -86,6 +87,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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the Product model based on its primary key value.
|
* Finds the Product model based on its primary key value.
|
||||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
@ -17,10 +17,6 @@ use yii\helpers\ArrayHelper;
|
|||||||
|
|
||||||
<?= $form->field($model, 'fio')->textInput(['maxlength' => true]) ?>
|
<?= $form->field($model, 'fio')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
|
|
||||||
|
|
||||||
<?= $form->field($model, 'gender')->dropDownList($model->genders, ['prompt' => 'Выберите']) ?>
|
|
||||||
|
|
||||||
<?= $form->field($model, 'dob')->input(
|
<?= $form->field($model, 'dob')->input(
|
||||||
'date',
|
'date',
|
||||||
[
|
[
|
||||||
@ -30,7 +26,6 @@ use yii\helpers\ArrayHelper;
|
|||||||
|
|
||||||
]
|
]
|
||||||
) ?>
|
) ?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<?= $form->field($model, 'skill')->widget(
|
<?= $form->field($model, 'skill')->widget(
|
||||||
|
21
frontend/modules/card/views/user-card/password.php
Normal file
21
frontend/modules/card/views/user-card/password.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'id' => 'password-form',
|
||||||
|
'enableClientValidation' => true,
|
||||||
|
'enableAjaxValidation' => false,
|
||||||
|
'method' => 'post',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
<h4>Введите новый пароль</h4>
|
||||||
|
|
||||||
|
<?= Html::input('text', 'password', '', ['class' => 'form-control custom-input']) ?>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
@ -12,9 +12,10 @@ use yii\widgets\DetailView;
|
|||||||
$this->title = 'Профиль';
|
$this->title = 'Профиль';
|
||||||
?>
|
?>
|
||||||
<div class="user-card-view">
|
<div class="user-card-view">
|
||||||
|
|
||||||
<h3>Личная информация</h3>
|
<h3>Личная информация</h3>
|
||||||
<?php
|
<?php
|
||||||
|
echo Html::a('Изменить профиль', ['/card/user-card/update', 'id' => $model->id], ['class' => 'btn btn-success'])
|
||||||
|
. ' ' . Html::a('Изменить пароль', ['/card/user-card/password', 'id' => $model->id], ['class' => 'btn btn-success']);
|
||||||
echo DetailView::widget([
|
echo DetailView::widget([
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
@ -77,7 +78,4 @@ $this->title = 'Профиль';
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
<?= Html::a('Изменить', ['/card/user-card/update', 'id' => $model->id], ['class' => 'btn btn-success']); ?>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -118,3 +118,7 @@ a.desc:after {
|
|||||||
.nav > li > form > button.logout:focus {
|
.nav > li > form > button.logout:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.custom-input {
|
||||||
|
width: 50%;
|
||||||
|
}
|
24
frontend/web/js/site.js
Normal file
24
frontend/web/js/site.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
$(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 () {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user