From 3f7507918f6a1724abd9c5655b0294fa8b5c4877 Mon Sep 17 00:00:00 2001 From: Glambertessa Date: Mon, 18 Nov 2019 13:33:08 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D0=98=D0=BD=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=BE=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/modules/card/views/user-card/view.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/modules/card/views/user-card/view.php b/frontend/modules/card/views/user-card/view.php index dc45d67..81b1fe6 100644 --- a/frontend/modules/card/views/user-card/view.php +++ b/frontend/modules/card/views/user-card/view.php @@ -19,7 +19,6 @@ use yii\widgets\DetailView; 'model' => $model, 'attributes' => [ ['label' => 'ФИО', 'attribute' => 'fio',], - ['label' => 'Пасспорт', 'attribute' => 'passport',], ['label' => 'Email', 'attribute' => 'email',], [ 'attribute' => 'gender', @@ -30,7 +29,6 @@ use yii\widgets\DetailView; 'attribute' => 'status', 'value' => $model->status0->name, ], - ['label' => 'Зарплата', 'attribute' => 'salary',], [ 'attribute' => 'position_id', 'value' => (isset($model->position->name)) ? $model->position->name : 'Без должности', @@ -43,7 +41,7 @@ use yii\widgets\DetailView; } ], [ - 'attribute' => 'Resume', + 'attribute' => 'Резюме', 'format' => 'raw', 'value' => function ($model) { return Html::a('Скачать', $model->resume, ['target' => '_blank']); From 6037c69b85445bfb67001119f3dc5cdc3c576e03 Mon Sep 17 00:00:00 2001 From: Glambertessa Date: Mon, 18 Nov 2019 13:39:26 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8E=20=D1=84=D1=80?= =?UTF-8?q?=D0=BE=D0=BD=D1=82=D0=B5=D0=BD=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/config/main.php | 1 + frontend/views/layouts/main.php | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/config/main.php b/frontend/config/main.php index ecc3e60..81d2b38 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -8,6 +8,7 @@ $params = array_merge( return [ 'id' => 'app-frontend', + 'name' => 'Guild', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'frontend\controllers', diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index c32e048..666098a 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -38,9 +38,7 @@ AppAsset::register($this); ], ]); $menuItems = [ - ['label' => 'Home', 'url' => ['/site/index']], - ['label' => 'About', 'url' => ['/site/about']], - ['label' => 'Contact', 'url' => ['/site/contact']], + ['label' => 'Главная', 'url' => ['/site/index']], ]; if (Yii::$app->user->isGuest) { $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']]; From 028cce3bef3182c8b7e75b78e045cba4d47e3f70 Mon Sep 17 00:00:00 2001 From: Glambertessa Date: Mon, 18 Nov 2019 16:14:06 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=A0=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20skills?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/config/main.php | 2 +- .../modules/access/views/access/index.php | 2 + .../card/controllers/UserCardController.php | 24 ++++++++-- frontend/modules/card/models/UserCard.php | 45 +++++++++++++++++++ .../modules/card/views/user-card/_form.php | 39 ++++++++++++++++ .../modules/card/views/user-card/index.php | 8 +++- .../modules/card/views/user-card/update.php | 14 ++++++ .../modules/card/views/user-card/view.php | 6 ++- frontend/views/layouts/main.php | 2 +- 9 files changed, 134 insertions(+), 8 deletions(-) create mode 100644 frontend/modules/card/models/UserCard.php create mode 100644 frontend/modules/card/views/user-card/_form.php create mode 100644 frontend/modules/card/views/user-card/update.php diff --git a/frontend/config/main.php b/frontend/config/main.php index 81d2b38..9fbadf2 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -60,4 +60,4 @@ return [ ], 'params' => $params, -]; +]; \ No newline at end of file diff --git a/frontend/modules/access/views/access/index.php b/frontend/modules/access/views/access/index.php index 326a232..4340a7c 100644 --- a/frontend/modules/access/views/access/index.php +++ b/frontend/modules/access/views/access/index.php @@ -2,6 +2,8 @@ use yii\grid\GridView; +$this->title = 'Доступы'; + echo GridView::widget([ 'dataProvider' => $dataProvider, 'columns' => [ diff --git a/frontend/modules/card/controllers/UserCardController.php b/frontend/modules/card/controllers/UserCardController.php index 271ece2..02e3d8b 100644 --- a/frontend/modules/card/controllers/UserCardController.php +++ b/frontend/modules/card/controllers/UserCardController.php @@ -3,11 +3,10 @@ namespace frontend\modules\card\controllers; -use common\classes\Debug; use common\models\CardSkill; use common\models\FieldsValueNew; use Yii; -use common\models\UserCard; +use frontend\modules\card\models\UserCard; use yii\data\ActiveDataProvider; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -26,7 +25,7 @@ class UserCardController extends Controller $id_user = Yii::$app->user->id; $result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); - if($result){ + if($result) { $id = $result[0]['id']; $dataProvider = new ActiveDataProvider([ 'query' => FieldsValueNew::find() @@ -49,6 +48,25 @@ class UserCardController extends Controller } } + /** + * Updates an existing UserCard model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['index', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + /** * 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/models/UserCard.php b/frontend/modules/card/models/UserCard.php new file mode 100644 index 0000000..8f736f0 --- /dev/null +++ b/frontend/modules/card/models/UserCard.php @@ -0,0 +1,45 @@ +where(['card_id' => \Yii::$app->request->get('id')])->all(), + 'skill_id' + ); + + if (!empty($skill)) { + $this->skill = $skill; + } + } + + public function afterSave($insert, $changedAttributes) + { + $post = \Yii::$app->request->post('UserCard'); + + if ($post['skill']) { + CardSkill::deleteAll(['card_id' => $this->id]); + + foreach ($post['skill'] as $item) { + $skill = new CardSkill(); + $skill->skill_id = $item; + $skill->card_id = $this->id; + + $skill->save(); + } + } + + parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub + } +} diff --git a/frontend/modules/card/views/user-card/_form.php b/frontend/modules/card/views/user-card/_form.php new file mode 100644 index 0000000..aaf3967 --- /dev/null +++ b/frontend/modules/card/views/user-card/_form.php @@ -0,0 +1,39 @@ + + +
+ + + +
+
+ field($model, 'skill')->widget( + Select2::class, + [ + 'data' => ArrayHelper::map(Skill::find()->all(), 'id', 'name'), + 'options' => ['placeholder' => '...', 'class' => 'form-control', 'multiple' => true], + 'pluginOptions' => [ + 'allowClear' => true + ], + ] + )->label('Навыки'); ?> +
+
+ +
+ 'btn btn-success']) ?> +
+ + + +
\ No newline at end of file diff --git a/frontend/modules/card/views/user-card/index.php b/frontend/modules/card/views/user-card/index.php index 9b3a781..75951e9 100644 --- a/frontend/modules/card/views/user-card/index.php +++ b/frontend/modules/card/views/user-card/index.php @@ -1 +1,7 @@ - \ No newline at end of file +title = 'Профиль'; + + echo $info; diff --git a/frontend/modules/card/views/user-card/update.php b/frontend/modules/card/views/user-card/update.php new file mode 100644 index 0000000..f674155 --- /dev/null +++ b/frontend/modules/card/views/user-card/update.php @@ -0,0 +1,14 @@ +title = "Редактировать профиль"; +?> +
+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/modules/card/views/user-card/view.php b/frontend/modules/card/views/user-card/view.php index 81b1fe6..4a7d7b8 100644 --- a/frontend/modules/card/views/user-card/view.php +++ b/frontend/modules/card/views/user-card/view.php @@ -9,7 +9,7 @@ use yii\widgets\DetailView; /* @var $skill \common\models\Skill */ /* @var $modelFildValue yii\data\ActiveDataProvider */ - +$this->title = 'Профиль'; ?>
@@ -48,7 +48,6 @@ use yii\widgets\DetailView; } ], ['label' => 'Добвлен', 'attribute' => 'created_at',], - ['label' => 'Изменен', 'attribute' => 'updated_at',], ], ]); ?> @@ -58,6 +57,9 @@ use yii\widgets\DetailView; name; ?> + + $model->id], ['class' => 'btn btn-success']); ?> +

Дополнительные сведения

-endPage() ?> \ No newline at end of file +endPage() ?> From 1ee8f198acc7d8265376f053bd245c2d70511f52 Mon Sep 17 00:00:00 2001 From: Glambertessa Date: Mon, 18 Nov 2019 17:04:32 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B5?= =?UTF-8?q?=D0=BD=20behaviors=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=84=D0=B8=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../card/controllers/UserCardController.php | 63 ++++++++++++------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/frontend/modules/card/controllers/UserCardController.php b/frontend/modules/card/controllers/UserCardController.php index 02e3d8b..86bf120 100644 --- a/frontend/modules/card/controllers/UserCardController.php +++ b/frontend/modules/card/controllers/UserCardController.php @@ -8,11 +8,33 @@ use common\models\FieldsValueNew; use Yii; use frontend\modules\card\models\UserCard; use yii\data\ActiveDataProvider; +use yii\filters\AccessControl; +use yii\filters\VerbFilter; use yii\web\Controller; use yii\web\NotFoundHttpException; class UserCardController extends Controller { + + /** + * {@inheritdoc} + */ + public function behaviors() + { + return [ + 'access' => [ + 'class' => AccessControl::className(), + 'only' => ['index', 'update'], + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['@'], + ], + ], + ], + ]; + } + /** * Displays a single Product model. * @return mixed @@ -20,32 +42,29 @@ class UserCardController extends Controller */ public function actionIndex() { - if(Yii::$app->user->isGuest) return $this->render('index', ['info' => '

Пожалуйста, авторизируйтесь!

']); - else { - $id_user = Yii::$app->user->id; - $result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); + $id_user = Yii::$app->user->id; + $result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); - if($result) { - $id = $result[0]['id']; - $dataProvider = new ActiveDataProvider([ - 'query' => FieldsValueNew::find() - ->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE]) - ->orderBy('order'), - 'pagination' => [ - 'pageSize' => 200, - ], - ]); + if($result) { + $id = $result[0]['id']; + $dataProvider = new ActiveDataProvider([ + 'query' => FieldsValueNew::find() + ->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE]) + ->orderBy('order'), + 'pagination' => [ + 'pageSize' => 200, + ], + ]); - $skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all(); + $skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all(); - return $this->render('view', [ - 'model' => $this->findModel($id), - 'modelFildValue' => $dataProvider, - 'skills' => $skills, - ]); - } - else return $this->render('index', ['info' => '

Ваши личные данные не заненсены в базу.

']); + return $this->render('view', [ + 'model' => $this->findModel($id), + 'modelFildValue' => $dataProvider, + 'skills' => $skills, + ]); } + else return $this->render('index', ['info' => '

Ваши личные данные не заненсены в базу.

']); } /**