commit
8515317562
@ -8,6 +8,7 @@ $params = array_merge(
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => 'app-frontend',
|
'id' => 'app-frontend',
|
||||||
|
'name' => 'Guild',
|
||||||
'basePath' => dirname(__DIR__),
|
'basePath' => dirname(__DIR__),
|
||||||
'bootstrap' => ['log'],
|
'bootstrap' => ['log'],
|
||||||
'controllerNamespace' => 'frontend\controllers',
|
'controllerNamespace' => 'frontend\controllers',
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
|
|
||||||
|
$this->title = 'Доступы';
|
||||||
|
|
||||||
echo GridView::widget([
|
echo GridView::widget([
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
'columns' => [
|
'columns' => [
|
||||||
|
@ -3,17 +3,38 @@
|
|||||||
|
|
||||||
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;
|
||||||
use common\models\UserCard;
|
use frontend\modules\card\models\UserCard;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
|
use yii\filters\AccessControl;
|
||||||
|
use yii\filters\VerbFilter;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
class UserCardController extends Controller
|
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.
|
* Displays a single Product model.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@ -21,32 +42,48 @@ class UserCardController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
if(Yii::$app->user->isGuest) return $this->render('index', ['info' => '<h3>Пожалуйста, авторизируйтесь!</h3>']);
|
$id_user = Yii::$app->user->id;
|
||||||
else {
|
$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){
|
if($result) {
|
||||||
$id = $result[0]['id'];
|
$id = $result[0]['id'];
|
||||||
$dataProvider = new ActiveDataProvider([
|
$dataProvider = new ActiveDataProvider([
|
||||||
'query' => FieldsValueNew::find()
|
'query' => FieldsValueNew::find()
|
||||||
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE])
|
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE])
|
||||||
->orderBy('order'),
|
->orderBy('order'),
|
||||||
'pagination' => [
|
'pagination' => [
|
||||||
'pageSize' => 200,
|
'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', [
|
return $this->render('view', [
|
||||||
'model' => $this->findModel($id),
|
'model' => $this->findModel($id),
|
||||||
'modelFildValue' => $dataProvider,
|
'modelFildValue' => $dataProvider,
|
||||||
'skills' => $skills,
|
'skills' => $skills,
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
else return $this->render('index', ['info' => '<h3>Ваши личные данные не заненсены в базу.</h3>']);
|
|
||||||
}
|
}
|
||||||
|
else return $this->render('index', ['info' => '<h3>Ваши личные данные не заненсены в базу.</h3>']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
45
frontend/modules/card/models/UserCard.php
Normal file
45
frontend/modules/card/models/UserCard.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace frontend\modules\card\models;
|
||||||
|
|
||||||
|
use common\models\CardSkill;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
|
class UserCard extends \common\models\UserCard
|
||||||
|
{
|
||||||
|
public $fields;
|
||||||
|
public $skill;
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
parent::init();
|
||||||
|
|
||||||
|
$skill = ArrayHelper::getColumn(
|
||||||
|
CardSkill::find()->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
|
||||||
|
}
|
||||||
|
}
|
39
frontend/modules/card/views/user-card/_form.php
Normal file
39
frontend/modules/card/views/user-card/_form.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use kartik\select2\Select2;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use common\models\Skill;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model frontend\modules\card\models\UserCard */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="user-card-form">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<?= $form->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('Навыки'); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
@ -1 +1,7 @@
|
|||||||
<?= $info ?>
|
<?php
|
||||||
|
|
||||||
|
/* @var $info */
|
||||||
|
|
||||||
|
$this->title = 'Профиль';
|
||||||
|
|
||||||
|
echo $info;
|
||||||
|
14
frontend/modules/card/views/user-card/update.php
Normal file
14
frontend/modules/card/views/user-card/update.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\card\models\UserCard */
|
||||||
|
|
||||||
|
$this->title = "Редактировать профиль";
|
||||||
|
?>
|
||||||
|
<div class="user-card-update">
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
@ -9,7 +9,7 @@ use yii\widgets\DetailView;
|
|||||||
/* @var $skill \common\models\Skill */
|
/* @var $skill \common\models\Skill */
|
||||||
/* @var $modelFildValue yii\data\ActiveDataProvider */
|
/* @var $modelFildValue yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
$this->title = 'Профиль';
|
||||||
?>
|
?>
|
||||||
<div class="user-card-view">
|
<div class="user-card-view">
|
||||||
|
|
||||||
@ -19,7 +19,6 @@ use yii\widgets\DetailView;
|
|||||||
'model' => $model,
|
'model' => $model,
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
['label' => 'ФИО', 'attribute' => 'fio',],
|
['label' => 'ФИО', 'attribute' => 'fio',],
|
||||||
['label' => 'Пасспорт', 'attribute' => 'passport',],
|
|
||||||
['label' => 'Email', 'attribute' => 'email',],
|
['label' => 'Email', 'attribute' => 'email',],
|
||||||
[
|
[
|
||||||
'attribute' => 'gender',
|
'attribute' => 'gender',
|
||||||
@ -30,7 +29,6 @@ use yii\widgets\DetailView;
|
|||||||
'attribute' => 'status',
|
'attribute' => 'status',
|
||||||
'value' => $model->status0->name,
|
'value' => $model->status0->name,
|
||||||
],
|
],
|
||||||
['label' => 'Зарплата', 'attribute' => 'salary',],
|
|
||||||
[
|
[
|
||||||
'attribute' => 'position_id',
|
'attribute' => 'position_id',
|
||||||
'value' => (isset($model->position->name)) ? $model->position->name : 'Без должности',
|
'value' => (isset($model->position->name)) ? $model->position->name : 'Без должности',
|
||||||
@ -43,14 +41,13 @@ use yii\widgets\DetailView;
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'Resume',
|
'attribute' => 'Резюме',
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'value' => function ($model) {
|
'value' => function ($model) {
|
||||||
return Html::a('Скачать', $model->resume, ['target' => '_blank']);
|
return Html::a('Скачать', $model->resume, ['target' => '_blank']);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
['label' => 'Добвлен', 'attribute' => 'created_at',],
|
['label' => 'Добвлен', 'attribute' => 'created_at',],
|
||||||
['label' => 'Изменен', 'attribute' => 'updated_at',],
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
?>
|
?>
|
||||||
@ -60,6 +57,9 @@ use yii\widgets\DetailView;
|
|||||||
<?php foreach ($skills as $skill) : ?>
|
<?php foreach ($skills as $skill) : ?>
|
||||||
<span class="btn btn-default btn-sm"><?= $skill['skill']->name; ?></span>
|
<span class="btn btn-default btn-sm"><?= $skill['skill']->name; ?></span>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
<?= Html::a('Добавить', ['/card/user-card/update', 'id' => $model->id], ['class' => 'btn btn-success']); ?>
|
||||||
|
|
||||||
<h2>Дополнительные сведения</h2>
|
<h2>Дополнительные сведения</h2>
|
||||||
|
|
||||||
<?= GridView::widget([
|
<?= GridView::widget([
|
||||||
|
@ -38,9 +38,7 @@ AppAsset::register($this);
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$menuItems = [
|
$menuItems = [
|
||||||
['label' => 'Home', 'url' => ['/site/index']],
|
['label' => 'Главная', 'url' => ['/site/index']],
|
||||||
['label' => 'About', 'url' => ['/site/about']],
|
|
||||||
['label' => 'Contact', 'url' => ['/site/contact']],
|
|
||||||
];
|
];
|
||||||
if (Yii::$app->user->isGuest) {
|
if (Yii::$app->user->isGuest) {
|
||||||
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
|
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
|
||||||
|
Loading…
Reference in New Issue
Block a user