diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index 8b5f017..c00f7e4 100755 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -15,6 +15,7 @@ class AppAsset extends AssetBundle 'css/site.css', ]; public $js = [ + 'js/site.js' ]; public $depends = [ 'yii\web\YiiAsset', diff --git a/frontend/modules/access/views/access/_form.php b/frontend/modules/access/views/access/_form.php index 4b979f7..75c1128 100644 --- a/frontend/modules/access/views/access/_form.php +++ b/frontend/modules/access/views/access/_form.php @@ -16,7 +16,7 @@ use yii\widgets\ActiveForm; field($model, 'login')->textInput(['maxlength' => true]) ?> - field($model, 'password')->passwordInput(['maxlength' => true]) ?> + field($model, 'password')->textInput(['maxlength' => true]) ?> field($model, 'link')->textInput(['maxlength' => true]) ?> diff --git a/frontend/modules/card/controllers/UserCardController.php b/frontend/modules/card/controllers/UserCardController.php index 86bf120..3a81c7e 100755 --- a/frontend/modules/card/controllers/UserCardController.php +++ b/frontend/modules/card/controllers/UserCardController.php @@ -3,8 +3,10 @@ namespace frontend\modules\card\controllers; +use common\classes\Debug; use common\models\CardSkill; use common\models\FieldsValueNew; +use common\models\User; use Yii; use frontend\modules\card\models\UserCard; use yii\data\ActiveDataProvider; @@ -57,7 +59,6 @@ class UserCardController extends Controller ]); $skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all(); - return $this->render('view', [ 'model' => $this->findModel($id), '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. * If the model is not found, a 404 HTTP exception will be thrown. diff --git a/frontend/modules/card/views/user-card/_form.php b/frontend/modules/card/views/user-card/_form.php index eeefc53..e510d86 100755 --- a/frontend/modules/card/views/user-card/_form.php +++ b/frontend/modules/card/views/user-card/_form.php @@ -17,10 +17,6 @@ use yii\helpers\ArrayHelper; field($model, 'fio')->textInput(['maxlength' => true]) ?> - field($model, 'email')->textInput(['maxlength' => true]) ?> - - field($model, 'gender')->dropDownList($model->genders, ['prompt' => 'Выберите']) ?> - field($model, 'dob')->input( 'date', [ @@ -30,7 +26,6 @@ use yii\helpers\ArrayHelper; ] ) ?> -
field($model, 'skill')->widget( diff --git a/frontend/modules/card/views/user-card/password.php b/frontend/modules/card/views/user-card/password.php new file mode 100644 index 0000000..7ba02c2 --- /dev/null +++ b/frontend/modules/card/views/user-card/password.php @@ -0,0 +1,21 @@ + + + 'password-form', + 'enableClientValidation' => true, + 'enableAjaxValidation' => false, + 'method' => 'post', +]); ?> + +

Введите новый пароль

+ + 'form-control custom-input']) ?> + +
+ + 'btn btn-success']) ?> + + diff --git a/frontend/modules/card/views/user-card/view.php b/frontend/modules/card/views/user-card/view.php index 972feb4..ee26b36 100755 --- a/frontend/modules/card/views/user-card/view.php +++ b/frontend/modules/card/views/user-card/view.php @@ -12,10 +12,11 @@ use yii\widgets\DetailView; $this->title = 'Профиль'; ?>
-

Личная информация

$model->id], ['class' => 'btn btn-success']) + . ' ' . Html::a('Изменить пароль', ['/card/user-card/password', 'id' => $model->id], ['class' => 'btn btn-success']); + echo DetailView::widget([ 'model' => $model, 'attributes' => [ ['label' => 'ФИО', 'attribute' => 'fio',], @@ -77,7 +78,4 @@ $this->title = 'Профиль'; ], ], ]); ?> - - $model->id], ['class' => 'btn btn-success']); ?> -
diff --git a/frontend/web/css/site.css b/frontend/web/css/site.css index 5f1e6b9..a3b38da 100755 --- a/frontend/web/css/site.css +++ b/frontend/web/css/site.css @@ -118,3 +118,7 @@ a.desc:after { .nav > li > form > button.logout:focus { outline: none; } + +.custom-input { + width: 50%; +} \ No newline at end of file diff --git a/frontend/web/js/site.js b/frontend/web/js/site.js new file mode 100644 index 0000000..5200e11 --- /dev/null +++ b/frontend/web/js/site.js @@ -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 () { + } + }); + +}); \ No newline at end of file