From 1f9ddd8c095a253e8286d41a758c5e2cd2dac24a Mon Sep 17 00:00:00 2001 From: Glambertessa Date: Mon, 18 Nov 2019 10:36:13 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=B8=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 --- backend/modules/card/views/user-card/view.php | 1 + frontend/config/main.php | 8 +- frontend/controllers/SiteController.php | 3 + .../access/controllers/AccessController.php | 3 +- .../modules/access/views/access/index.php | 1 - frontend/modules/card/Card.php | 24 ++++++ .../card/controllers/UserCardController.php | 73 +++++++++++++++++ .../modules/card/views/user-card/index.php | 80 +++++++++++++++++++ frontend/views/layouts/main.php | 2 +- frontend/views/site/info.php | 18 +++++ 10 files changed, 208 insertions(+), 5 deletions(-) create mode 100644 frontend/modules/card/Card.php create mode 100644 frontend/modules/card/controllers/UserCardController.php create mode 100644 frontend/modules/card/views/user-card/index.php create mode 100644 frontend/views/site/info.php diff --git a/backend/modules/card/views/user-card/view.php b/backend/modules/card/views/user-card/view.php index be457ab..9cf3277 100755 --- a/backend/modules/card/views/user-card/view.php +++ b/backend/modules/card/views/user-card/view.php @@ -9,6 +9,7 @@ use yii\widgets\DetailView; /* @var $userData common\models\User */ /* @var $skills \common\models\CardSkill */ /* @var $skill \common\models\Skill */ +/* @var $modelFildValue yii\data\ActiveDataProvider */ $this->title = $model->fio; $this->params['breadcrumbs'][] = ['label' => 'User Cards', 'url' => ['index']]; diff --git a/frontend/config/main.php b/frontend/config/main.php index 767b94d..c60d360 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -16,6 +16,9 @@ return [ 'access' => [ 'class' => 'frontend\modules\access\Access', ], + 'card' => [ + 'class' => 'frontend\modules\card\Card', + ], ], 'components' => [ @@ -48,7 +51,10 @@ return [ 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, - 'rules' => [], + 'rules' => [ + '' => 'card1/user-card/index', + 'site/index' => 'card/user-card/index', + ], ], ], diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index d24e107..5adf2f7 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -1,6 +1,8 @@ $dataProvider, diff --git a/frontend/modules/card/Card.php b/frontend/modules/card/Card.php new file mode 100644 index 0000000..f1853b3 --- /dev/null +++ b/frontend/modules/card/Card.php @@ -0,0 +1,24 @@ +user->id; + $id = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); + + return $this->render('index', [ + 'model' => $this->findModel($id[0]['id']), + ]);*/ + + $id_user = Yii::$app->user->id; + $result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); + $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(); + + $id_current_user = $this->findModel($id)->id_user; + + return $this->render('index', [ + 'model' => $this->findModel($id), + 'modelFildValue' => $dataProvider, + 'skills' => $skills, + // 'userData' => $userData, + //userData' => User::findOne($id_current_user), + ]); + + } + + /** + * Finds the Product model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return UserCard the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = UserCard::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} \ 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 new file mode 100644 index 0000000..6c98813 --- /dev/null +++ b/frontend/modules/card/views/user-card/index.php @@ -0,0 +1,80 @@ + +
+ +

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

+ $model, + 'attributes' => [ + ['label' => 'ФИО', 'attribute' => 'fio',], + ['label' => 'Пасспорт', 'attribute' => 'passport',], + ['label' => 'Email', 'attribute' => 'email',], + [ + 'attribute' => 'gender', + 'value' => $model->gendersText, + ], + ['label' => 'Дата рождения', 'attribute' => 'dob',], + [ + 'attribute' => 'status', + 'value' => $model->status0->name, + ], + ['label' => 'Зарплата', 'attribute' => 'salary',], + [ + 'attribute' => 'position_id', + 'value' => (isset($model->position->name)) ? $model->position->name : 'Без должности', + ], + [ + 'attribute' => 'Фото', + 'format' => 'raw', + 'value' => function ($model) { + return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']); + } + ], + [ + 'attribute' => 'Resume', + 'format' => 'raw', + 'value' => function ($model) { + return Html::a('Скачать', $model->resume, ['target' => '_blank']); + } + ], + ['label' => 'Добвлен', 'attribute' => 'created_at',], + ['label' => 'Изменен', 'attribute' => 'updated_at',], + ], + ]) ?> + +

Навыки

+ + + name; ?> + +

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

+ + $modelFildValue, + 'layout' => "{items}", + 'columns' => [ + 'field.name:text:Поле', + [ + 'attribute' => 'value', + 'format' => 'raw', + 'value' => function ($model) { + if ($model->type_file == 'file') { + return $model->value . ' (' . Html::a('Скачать', $model->value, ['target' => '_blank', 'download' => 'download']) . ')'; + } + return $model->value; + } + ], + ], + ]); ?> + +
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 6eb5faf..c32e048 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -46,7 +46,7 @@ AppAsset::register($this); $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']]; $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; } else { - $menuItems[] = ['label' => 'Access', 'url' => ['/access/access/index']]; + $menuItems[] = ['label' => 'Доступы', 'url' => ['/access/access/index']]; $menuItems[] = '
  • ' . Html::beginForm(['/site/logout'], 'post') . Html::submitButton( diff --git a/frontend/views/site/info.php b/frontend/views/site/info.php new file mode 100644 index 0000000..6bda588 --- /dev/null +++ b/frontend/views/site/info.php @@ -0,0 +1,18 @@ + $model, +]); + +// Debug::dd($model); + +// echo DetailView::widget([ +// 'model' => $model, +// 'attributes' => [ +// 'email', +// ], +// ]); From 6640bf5ed92c698dfbdfca87addf2bdca7f197e1 Mon Sep 17 00:00:00 2001 From: Glambertessa Date: Mon, 18 Nov 2019 10:55:53 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=B8=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/config/main.php | 2 +- .../modules/card/controllers/UserCardController.php | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/frontend/config/main.php b/frontend/config/main.php index c60d360..339f96e 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -52,7 +52,7 @@ return [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ - '' => 'card1/user-card/index', + '' => 'card/user-card/index', 'site/index' => 'card/user-card/index', ], ], diff --git a/frontend/modules/card/controllers/UserCardController.php b/frontend/modules/card/controllers/UserCardController.php index 7933d9f..bb0039c 100644 --- a/frontend/modules/card/controllers/UserCardController.php +++ b/frontend/modules/card/controllers/UserCardController.php @@ -5,7 +5,6 @@ namespace frontend\modules\card\controllers; use common\models\CardSkill; use common\models\FieldsValueNew; -use common\models\User; use Yii; use common\models\UserCard; use yii\data\ActiveDataProvider; @@ -21,13 +20,6 @@ class UserCardController extends Controller */ public function actionIndex() { - /* $id_user = Yii::$app->user->id; - $id = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); - - return $this->render('index', [ - 'model' => $this->findModel($id[0]['id']), - ]);*/ - $id_user = Yii::$app->user->id; $result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); $id = $result[0]['id']; @@ -43,14 +35,10 @@ class UserCardController extends Controller $skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all(); - $id_current_user = $this->findModel($id)->id_user; - return $this->render('index', [ 'model' => $this->findModel($id), 'modelFildValue' => $dataProvider, 'skills' => $skills, - // 'userData' => $userData, - //userData' => User::findOne($id_current_user), ]); }