From 3d9bbb6744fb7fb8b5148089fd25af96ab8338c7 Mon Sep 17 00:00:00 2001 From: Glambertessa Date: Mon, 18 Nov 2019 13:06:54 +0300 Subject: [PATCH] =?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,=20=D0=B3=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D1=8F=20=D1=81=D0=B2=D1=8F?= =?UTF-8?q?=D0=B7=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../card/controllers/UserCardController.php | 1 - backend/modules/card/models/UserCard.php | 3 +- frontend/config/main.php | 2 +- .../card/controllers/UserCardController.php | 34 ++++---- .../modules/card/views/user-card/index.php | 81 +----------------- .../modules/card/views/user-card/view.php | 83 +++++++++++++++++++ 6 files changed, 105 insertions(+), 99 deletions(-) create mode 100644 frontend/modules/card/views/user-card/view.php diff --git a/backend/modules/card/controllers/UserCardController.php b/backend/modules/card/controllers/UserCardController.php index 039f933..094d4d8 100755 --- a/backend/modules/card/controllers/UserCardController.php +++ b/backend/modules/card/controllers/UserCardController.php @@ -78,7 +78,6 @@ class UserCardController extends Controller 'model' => $this->findModel($id), 'modelFildValue' => $dataProvider, 'skills' => $skills, - // 'userData' => $userData, 'userData' => User::findOne($id_current_user), ]); } diff --git a/backend/modules/card/models/UserCard.php b/backend/modules/card/models/UserCard.php index 5b7654e..56b6ea9 100755 --- a/backend/modules/card/models/UserCard.php +++ b/backend/modules/card/models/UserCard.php @@ -134,7 +134,7 @@ class UserCard extends \common\models\UserCard $userCardQuery = UserCard::find(); $card_id ? $userCardQuery->where(['id' => $card_id]) : $userCardQuery->where(['id_user' => NULL]); $user_card_array = $userCardQuery->all(); - $user_array = User::find()->select(['id', 'email'])->all(); + $user_array = User::find()->all(); foreach ($user_card_array as $user_card_value) { @@ -147,7 +147,6 @@ class UserCard extends \common\models\UserCard if ($user_id) { UserCard::genereateLinlkOnUser($user_card_value, $user_id); } else { - $user_id = UserCard::generateUser($user_card_value->email, $user_card_value->status); UserCard::genereateLinlkOnUser($user_card_value, $user_id); } diff --git a/frontend/config/main.php b/frontend/config/main.php index 339f96e..ecc3e60 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -52,8 +52,8 @@ return [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ - '' => 'card/user-card/index', 'site/index' => 'card/user-card/index', + '' => 'card/user-card/index', ], ], diff --git a/frontend/modules/card/controllers/UserCardController.php b/frontend/modules/card/controllers/UserCardController.php index bb0039c..9dfc394 100644 --- a/frontend/modules/card/controllers/UserCardController.php +++ b/frontend/modules/card/controllers/UserCardController.php @@ -3,6 +3,7 @@ namespace frontend\modules\card\controllers; +use common\classes\Debug; use common\models\CardSkill; use common\models\FieldsValueNew; use Yii; @@ -24,23 +25,26 @@ class UserCardController extends Controller $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, - ], - ]); + if(Yii::$app->user->isGuest) return $this->render('index', ['info' => '

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

']); + else if($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(); - - return $this->render('index', [ - 'model' => $this->findModel($id), - 'modelFildValue' => $dataProvider, - 'skills' => $skills, - ]); + $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' => '

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

']); } /** diff --git a/frontend/modules/card/views/user-card/index.php b/frontend/modules/card/views/user-card/index.php index 6c98813..9b3a781 100644 --- a/frontend/modules/card/views/user-card/index.php +++ b/frontend/modules/card/views/user-card/index.php @@ -1,80 +1 @@ - -
- -

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

- $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; - } - ], - ], - ]); ?> - -
+ \ No newline at end of file diff --git a/frontend/modules/card/views/user-card/view.php b/frontend/modules/card/views/user-card/view.php new file mode 100644 index 0000000..dc45d67 --- /dev/null +++ b/frontend/modules/card/views/user-card/view.php @@ -0,0 +1,83 @@ + +
+ +

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

+ $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; + } + ], + ], + ]); ?> + +