add skill and position

This commit is contained in:
king199025
2018-10-12 14:52:08 +03:00
parent c9db4cd49b
commit 369cf94f23
52 changed files with 1129 additions and 62 deletions

View File

@ -3,6 +3,7 @@
namespace backend\modules\card\controllers;
use common\classes\Debug;
use common\models\CardSkill;
use common\models\FieldsValue;
use Yii;
use backend\modules\card\models\UserCard;
@ -62,9 +63,12 @@ class UserCardController extends Controller
],
]);
$skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all();
return $this->render('view', [
'model' => $this->findModel($id),
'modelFildValue' => $dataProvider,
'skills' => $skills,
]);
}

View File

@ -2,11 +2,15 @@
namespace backend\modules\card\models;
use backend\modules\settings\models\Skill;
use common\models\CardSkill;
use common\models\FieldsValue;
use yii\helpers\ArrayHelper;
class UserCard extends \common\models\UserCard
{
public $fields;
public $skill;
public function init()
{
@ -35,6 +39,15 @@ class UserCard extends \common\models\UserCard
],
];
}
$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)
@ -53,6 +66,16 @@ class UserCard extends \common\models\UserCard
$fildsValue->save();
}
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
}
}

View File

@ -1,5 +1,6 @@
<?php
use kartik\select2\Select2;
use mihaildev\elfinder\InputFile;
use unclead\multipleinput\MultipleInput;
use unclead\multipleinput\examples\models\ExampleModel;
@ -103,12 +104,32 @@ use yii\widgets\ActiveForm;
<div class="row">
<div class="col-xs-6">
<?= $form->field($model, 'salary')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'salary')->textInput(['maxlength' => true]) ?>
</div>
<div class="col-xs-6">
<?= $form->field($model, 'position_id')->dropDownList(
\yii\helpers\ArrayHelper::map(\backend\modules\settings\models\Position::find()->all(), 'id', 'name'),
['prompt' => '...']
) ?>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<?= $form->field($model, 'skill')->widget(Select2::class,
[
'data' => \yii\helpers\ArrayHelper::map(\common\models\Skill::find()->all(),'id', 'name'),
'options' => ['placeholder' => '...','class' => 'form-control', 'multiple' => true],
'pluginOptions' => [
'allowClear' => true
],
]
)->label('Навыки'); ?>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<?= $form->field($model, 'fields')->widget(MultipleInput::class, [
@ -119,7 +140,7 @@ use yii\widgets\ActiveForm;
'type' => 'dropDownList',
'title' => 'Поле',
'defaultValue' => null,
'items' => \yii\helpers\ArrayHelper::map(\backend\modules\fields\models\AdditionalFields::find()
'items' => \yii\helpers\ArrayHelper::map(\backend\modules\settings\models\AdditionalFields::find()
->joinWith('useFields')
->where(['`use_field`.`use`' => \common\models\UseStatus::USE_PROFILE])
->all(),

View File

@ -6,6 +6,8 @@ use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\card\models\UserCard */
/* @var $skills \common\models\CardSkill */
/* @var $skill \common\models\Skill */
$this->title = $model->fio;
$this->params['breadcrumbs'][] = ['label' => 'User Cards', 'url' => ['index']];
@ -23,21 +25,21 @@ $this->params['breadcrumbs'][] = $this->title;
'fio',
'passport',
[
'label' => 'Photo',
'attribute' => 'Photo',
'format' => 'raw',
'value' => function($model){
return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']);
}
],
[
'label' => 'Resume',
'attribute' => 'Resume',
'format' => 'raw',
'value' => function($model){
return Html::a('Скачать', $model->resume, ['target' => '_blank']);
}
],
[
'label' => 'gender',
'attribute' => 'gender',
'value' => $model->gendersText,
],
@ -45,15 +47,24 @@ $this->params['breadcrumbs'][] = $this->title;
'dob',
[
'label' => 'status',
'attribute' => 'status',
'value' => $model->status0->name,
],
'salary',
[
'attribute' => 'position_id',
'value' => $model->position->name,
],
'created_at',
'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([