информация о пользователе

This commit is contained in:
Glambertessa 2019-11-18 10:36:13 +03:00
parent c9baee8d5a
commit 1f9ddd8c09
10 changed files with 208 additions and 5 deletions

View File

@ -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']];

View File

@ -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',
],
],
],

View File

@ -1,6 +1,8 @@
<?php
namespace frontend\controllers;
use common\classes\Debug;
use Yii;
use yii\base\InvalidParamException;
use yii\web\BadRequestHttpException;
@ -13,6 +15,7 @@ use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm;
use frontend\models\ContactForm;
/**
* Site controller
*/

View File

@ -2,11 +2,10 @@
namespace frontend\modules\access\controllers;
use common\classes\Debug;
use common\models\Accesses;
use Yii;
use yii\web\Controller;
use yii\data\ActiveDataProvider;
use common\models\Accesses;
class AccessController extends Controller
{

View File

@ -1,7 +1,6 @@
<?php
use yii\grid\GridView;
use yii\widgets\DetailView;
echo GridView::widget([
'dataProvider' => $dataProvider,

View File

@ -0,0 +1,24 @@
<?php
namespace frontend\modules\card;
/**
* card module definition class
*/
class Card extends \yii\base\Module
{
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'frontend\modules\card\controllers';
/**
* {@inheritdoc}
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
}

View File

@ -0,0 +1,73 @@
<?php
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;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
class UserCardController extends Controller
{
/**
* Displays a single Product model.
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
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'];
$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.');
}
}

View File

@ -0,0 +1,80 @@
<?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>
<?= 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>

View File

@ -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[] = '<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(

View File

@ -0,0 +1,18 @@
<?php
use common\classes\Debug;
use yii\widgets\DetailView;
use yii\grid\GridView;
echo GridView::widget([
'dataProvider' => $model,
]);
// Debug::dd($model);
// echo DetailView::widget([
// 'model' => $model,
// 'attributes' => [
// 'email',
// ],
// ]);