- Achievement input at user card form.
- Achievement at user view with img
This commit is contained in:
parent
0dbb05ee8e
commit
b7ed0dab99
@ -3,6 +3,7 @@
|
|||||||
namespace backend\modules\card\controllers;
|
namespace backend\modules\card\controllers;
|
||||||
|
|
||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
|
use common\models\AchievementUserCard;
|
||||||
use common\models\AdditionalFields;
|
use common\models\AdditionalFields;
|
||||||
use common\models\CardSkill;
|
use common\models\CardSkill;
|
||||||
use common\Models\ChangeHistory;
|
use common\Models\ChangeHistory;
|
||||||
@ -104,6 +105,12 @@ class UserCardController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all();
|
$skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all();
|
||||||
|
$achievements =
|
||||||
|
AchievementUserCard::find()->where(['user_card_id' => $id])
|
||||||
|
->innerJoinWith(['achievement' => function($query) {
|
||||||
|
$query->andWhere(['status' => \common\models\Achievement::STATUS_ACTIVE]);
|
||||||
|
}])
|
||||||
|
->all();
|
||||||
|
|
||||||
$id_current_user = $this->findModel($id)->id_user;
|
$id_current_user = $this->findModel($id)->id_user;
|
||||||
$changeDataProvider = new ActiveDataProvider([
|
$changeDataProvider = new ActiveDataProvider([
|
||||||
@ -117,6 +124,7 @@ class UserCardController extends Controller
|
|||||||
'model' => $this->findModel($id),
|
'model' => $this->findModel($id),
|
||||||
'modelFieldValue' => $dataProvider,
|
'modelFieldValue' => $dataProvider,
|
||||||
'skills' => $skills,
|
'skills' => $skills,
|
||||||
|
'achievements' => $achievements,
|
||||||
'userData' => User::findOne($id_current_user),
|
'userData' => User::findOne($id_current_user),
|
||||||
'changeDataProvider' => $changeDataProvider,
|
'changeDataProvider' => $changeDataProvider,
|
||||||
]);
|
]);
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace backend\modules\card\models;
|
namespace backend\modules\card\models;
|
||||||
|
|
||||||
|
use backend\modules\achievements\models\Achievement;
|
||||||
use Common\Behaviors\LogBehavior;
|
use Common\Behaviors\LogBehavior;
|
||||||
|
use common\models\AchievementUserCard;
|
||||||
use Yii;
|
use Yii;
|
||||||
use backend\modules\settings\models\Skill;
|
use backend\modules\settings\models\Skill;
|
||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
@ -16,6 +18,7 @@ class UserCard extends \common\models\UserCard
|
|||||||
{
|
{
|
||||||
public $fields;
|
public $fields;
|
||||||
public $skill;
|
public $skill;
|
||||||
|
public $achievements;
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
@ -63,6 +66,19 @@ class UserCard extends \common\models\UserCard
|
|||||||
if (!empty($skill)) {
|
if (!empty($skill)) {
|
||||||
$this->skill = $skill;
|
$this->skill = $skill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$achievements = ArrayHelper::getColumn(AchievementUserCard::find()
|
||||||
|
->where(['user_card_id' => \Yii::$app->request->get('id')])
|
||||||
|
->innerJoinWith(['achievement' => function($query) {
|
||||||
|
$query->andWhere(['status' => \common\models\Achievement::STATUS_ACTIVE]);
|
||||||
|
}])
|
||||||
|
->all(),
|
||||||
|
'achievement_id'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!empty($achievements)) {
|
||||||
|
$this->achievements = $achievements;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function behaviors()
|
public function behaviors()
|
||||||
@ -118,6 +134,19 @@ class UserCard extends \common\models\UserCard
|
|||||||
$skill->save();
|
$skill->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(is_array($post['achievements'])){
|
||||||
|
AchievementUserCard::deleteAll(['user_card_id' => $this->id]);
|
||||||
|
|
||||||
|
foreach ($post['achievements'] as $item) {
|
||||||
|
$achCard = new AchievementUserCard();
|
||||||
|
$achCard->user_card_id = $this->id;
|
||||||
|
$achCard->achievement_id = $item;
|
||||||
|
|
||||||
|
$achCard->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use asmoday74\ckeditor5\EditorClassic;
|
use asmoday74\ckeditor5\EditorClassic;
|
||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
|
use common\models\Achievement;
|
||||||
use kartik\select2\Select2;
|
use kartik\select2\Select2;
|
||||||
use mihaildev\elfinder\InputFile;
|
use mihaildev\elfinder\InputFile;
|
||||||
use unclead\multipleinput\MultipleInput;
|
use unclead\multipleinput\MultipleInput;
|
||||||
@ -175,6 +176,19 @@ use yii\widgets\ActiveForm;
|
|||||||
'language' => 'ru',
|
'language' => 'ru',
|
||||||
]
|
]
|
||||||
]); ?>
|
]); ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<?= $form->field($model, 'achievements')->widget(Select2::class,
|
||||||
|
[
|
||||||
|
'data' => \yii\helpers\ArrayHelper::map(Achievement::find()->where(['status' => Achievement::STATUS_ACTIVE])->all(),'id', 'title'),
|
||||||
|
'options' => ['placeholder' => '...','class' => 'form-control', 'multiple' => true],
|
||||||
|
'pluginOptions' => [
|
||||||
|
'allowClear' => true
|
||||||
|
],
|
||||||
|
]
|
||||||
|
); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
|
@ -8,7 +8,9 @@ use yii\widgets\DetailView;
|
|||||||
/* @var $model backend\modules\card\models\UserCard */
|
/* @var $model backend\modules\card\models\UserCard */
|
||||||
/* @var $userData common\models\User */
|
/* @var $userData common\models\User */
|
||||||
/* @var $skills \common\models\CardSkill */
|
/* @var $skills \common\models\CardSkill */
|
||||||
|
/* @var $achievements \common\models\AchievementUserCard */
|
||||||
/* @var $skill \common\models\Skill */
|
/* @var $skill \common\models\Skill */
|
||||||
|
/* @var $achievement \common\models\Achievement */
|
||||||
/* @var $modelFieldValue yii\data\ActiveDataProvider */
|
/* @var $modelFieldValue yii\data\ActiveDataProvider */
|
||||||
/* @var $changeDataProvider yii\data\ActiveDataProvider */
|
/* @var $changeDataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
@ -91,11 +93,22 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
<h2>Навыки</h2>
|
<h2>Навыки</h2>
|
||||||
|
|
||||||
<?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; ?>
|
||||||
|
|
||||||
|
<h2>Достижения</h2>
|
||||||
|
<?php foreach ($achievements as $achievement) : ?>
|
||||||
|
<a target="_blank"
|
||||||
|
href="<? echo \yii\helpers\Url::to(['/achievements/achievements/view', 'id' => $achievement['achievement']->id]);?>"
|
||||||
|
class="btn btn-default btn-sm">
|
||||||
|
<?= Html::tag('img', null,
|
||||||
|
['src' => $achievement['achievement']->img, 'height' => '50px', 'alt'=> $achievement['achievement']->title]
|
||||||
|
) ?>
|
||||||
|
<?= $achievement['achievement']->title; ?>
|
||||||
|
</a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
<h2>Дополнительные сведения</h2>
|
<h2>Дополнительные сведения</h2>
|
||||||
|
|
||||||
<?= GridView::widget([
|
<?= GridView::widget([
|
||||||
|
@ -9,7 +9,7 @@ use Yii;
|
|||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property int $user_card_id
|
* @property int $user_card_id
|
||||||
* @property int $achievement
|
* @property int $achievement_id
|
||||||
*
|
*
|
||||||
* @property Accesses $accesses
|
* @property Accesses $accesses
|
||||||
* @property UserCard $userCard
|
* @property UserCard $userCard
|
||||||
|
@ -38,6 +38,7 @@ use yii\helpers\ArrayHelper;
|
|||||||
* @property ProjectUser[] $projectUsers
|
* @property ProjectUser[] $projectUsers
|
||||||
* @property Position $position
|
* @property Position $position
|
||||||
* @property Status $status0
|
* @property Status $status0
|
||||||
|
* @property Achievement[] $achievements
|
||||||
*/
|
*/
|
||||||
class UserCard extends \yii\db\ActiveRecord
|
class UserCard extends \yii\db\ActiveRecord
|
||||||
{
|
{
|
||||||
@ -171,6 +172,14 @@ class UserCard extends \yii\db\ActiveRecord
|
|||||||
return $this->hasOne(Status::class, ['id' => 'status']);
|
return $this->hasOne(Status::class, ['id' => 'status']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getAchievements(): \yii\db\ActiveQuery
|
||||||
|
{
|
||||||
|
return $this->hasMany(AchievementUserCard::class, ['user_card_id' => 'id'])->with('achievement');
|
||||||
|
}
|
||||||
|
|
||||||
public function getGenders()
|
public function getGenders()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
Loading…
Reference in New Issue
Block a user