Информация о пользователе, генерация связей
This commit is contained in:
parent
6640bf5ed9
commit
3d9bbb6744
@ -78,7 +78,6 @@ class UserCardController extends Controller
|
|||||||
'model' => $this->findModel($id),
|
'model' => $this->findModel($id),
|
||||||
'modelFildValue' => $dataProvider,
|
'modelFildValue' => $dataProvider,
|
||||||
'skills' => $skills,
|
'skills' => $skills,
|
||||||
// 'userData' => $userData,
|
|
||||||
'userData' => User::findOne($id_current_user),
|
'userData' => User::findOne($id_current_user),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ class UserCard extends \common\models\UserCard
|
|||||||
$userCardQuery = UserCard::find();
|
$userCardQuery = UserCard::find();
|
||||||
$card_id ? $userCardQuery->where(['id' => $card_id]) : $userCardQuery->where(['id_user' => NULL]);
|
$card_id ? $userCardQuery->where(['id' => $card_id]) : $userCardQuery->where(['id_user' => NULL]);
|
||||||
$user_card_array = $userCardQuery->all();
|
$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) {
|
foreach ($user_card_array as $user_card_value) {
|
||||||
|
|
||||||
@ -147,7 +147,6 @@ class UserCard extends \common\models\UserCard
|
|||||||
if ($user_id) {
|
if ($user_id) {
|
||||||
UserCard::genereateLinlkOnUser($user_card_value, $user_id);
|
UserCard::genereateLinlkOnUser($user_card_value, $user_id);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$user_id = UserCard::generateUser($user_card_value->email, $user_card_value->status);
|
$user_id = UserCard::generateUser($user_card_value->email, $user_card_value->status);
|
||||||
UserCard::genereateLinlkOnUser($user_card_value, $user_id);
|
UserCard::genereateLinlkOnUser($user_card_value, $user_id);
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ return [
|
|||||||
'enablePrettyUrl' => true,
|
'enablePrettyUrl' => true,
|
||||||
'showScriptName' => false,
|
'showScriptName' => false,
|
||||||
'rules' => [
|
'rules' => [
|
||||||
'' => 'card/user-card/index',
|
|
||||||
'site/index' => 'card/user-card/index',
|
'site/index' => 'card/user-card/index',
|
||||||
|
'' => 'card/user-card/index',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
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 Yii;
|
use Yii;
|
||||||
@ -24,23 +25,26 @@ class UserCardController extends Controller
|
|||||||
$result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all();
|
$result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all();
|
||||||
$id = $result[0]['id'];
|
$id = $result[0]['id'];
|
||||||
|
|
||||||
$dataProvider = new ActiveDataProvider([
|
if(Yii::$app->user->isGuest) return $this->render('index', ['info' => '<h3>Пожалуйста, авторизируйтесь!</h3>']);
|
||||||
'query' => FieldsValueNew::find()
|
else if($id) {
|
||||||
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE])
|
$dataProvider = new ActiveDataProvider([
|
||||||
->orderBy('order'),
|
'query' => FieldsValueNew::find()
|
||||||
'pagination' => [
|
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE])
|
||||||
'pageSize' => 200,
|
->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('index', [
|
|
||||||
'model' => $this->findModel($id),
|
|
||||||
'modelFildValue' => $dataProvider,
|
|
||||||
'skills' => $skills,
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
return $this->render('view', [
|
||||||
|
'model' => $this->findModel($id),
|
||||||
|
'modelFildValue' => $dataProvider,
|
||||||
|
'skills' => $skills,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else return $this->render('index', ['info' => '<h3>Ваши личные данные не заненсены в базу.</h3>']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,80 +1 @@
|
|||||||
<?php
|
<?= $info ?>
|
||||||
|
|
||||||
use yii\grid\GridView;
|
|
||||||
use yii\helpers\Html;
|
|
||||||
use yii\widgets\DetailView;
|
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
|
||||||
/* @var $skills \common\models\CardSkill */
|
|
||||||
/* @var $skill \common\models\Skill */
|
|
||||||
/* @var $modelFildValue yii\data\ActiveDataProvider */
|
|
||||||
|
|
||||||
?>
|
|
||||||
<div class="user-card-view">
|
|
||||||
|
|
||||||
<h3>Личная информация</h3>
|
|
||||||
<?= DetailView::widget([
|
|
||||||
'model' => $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',],
|
|
||||||
],
|
|
||||||
]) ?>
|
|
||||||
|
|
||||||
<h2>Навыки</h2>
|
|
||||||
|
|
||||||
<?php foreach ($skills as $skill) : ?>
|
|
||||||
<span class="btn btn-default btn-sm"><?= $skill['skill']->name; ?></span>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<h2>Дополнительные сведения</h2>
|
|
||||||
|
|
||||||
<?= GridView::widget([
|
|
||||||
'dataProvider' => $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;
|
|
||||||
}
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]); ?>
|
|
||||||
|
|
||||||
</div>
|
|
83
frontend/modules/card/views/user-card/view.php
Normal file
83
frontend/modules/card/views/user-card/view.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\grid\GridView;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $skills \common\models\CardSkill */
|
||||||
|
/* @var $skill \common\models\Skill */
|
||||||
|
/* @var $modelFildValue yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="user-card-view">
|
||||||
|
|
||||||
|
<h3>Личная информация</h3>
|
||||||
|
<?php
|
||||||
|
echo DetailView::widget([
|
||||||
|
'model' => $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',],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h2>Навыки</h2>
|
||||||
|
|
||||||
|
<?php foreach ($skills as $skill) : ?>
|
||||||
|
<span class="btn btn-default btn-sm"><?= $skill['skill']->name; ?></span>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<h2>Дополнительные сведения</h2>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $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;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user