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

@ -13,11 +13,8 @@ return [
'bootstrap' => ['log'],
'modules' => [
'status' => [
'class' => 'backend\modules\status\Status',
],
'fields' => [
'class' => 'backend\modules\fields\Fields',
'settings' => [
'class' => 'backend\modules\settings\Settings',
],
'card' => [
'class' => 'backend\modules\card\Card',

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([

View File

@ -40,7 +40,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_PROJECT])
->all(),

View File

@ -1,16 +1,16 @@
<?php
namespace backend\modules\fields;
namespace backend\modules\settings;
/**
* fields module definition class
* settings module definition class
*/
class Fields extends \yii\base\Module
class Settings extends \yii\base\Module
{
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'backend\modules\fields\controllers';
public $controllerNamespace = 'backend\modules\settings\controllers';
/**
* {@inheritdoc}

View File

@ -1,10 +1,10 @@
<?php
namespace backend\modules\fields\controllers;
namespace backend\modules\settings\controllers;
use Yii;
use backend\modules\fields\models\AdditionalFields;
use backend\modules\fields\models\AdditionalFieldsSearch;
use backend\modules\settings\models\AdditionalFields;
use backend\modules\settings\models\AdditionalFieldsSearch;
use yii\helpers\ArrayHelper;
use yii\web\Controller;
use yii\web\NotFoundHttpException;

View File

@ -0,0 +1,127 @@
<?php
namespace backend\modules\settings\controllers;
use Yii;
use backend\modules\settings\models\Position;
use backend\modules\settings\models\PositionSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* PositionController implements the CRUD actions for Position model.
*/
class PositionController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Position models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new PositionSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Position model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Position model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Position();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['index']);
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Position 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']);
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Position model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Position model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Position the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Position::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

View File

@ -0,0 +1,127 @@
<?php
namespace backend\modules\settings\controllers;
use Yii;
use backend\modules\settings\models\Skill;
use backend\modules\settings\models\SkillSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* SkillController implements the CRUD actions for Skill model.
*/
class SkillController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Skill models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new SkillSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Skill model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Skill model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Skill();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['index']);
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Skill 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']);
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Skill model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Skill model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Skill the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Skill::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

View File

@ -1,10 +1,10 @@
<?php
namespace backend\modules\status\controllers;
namespace backend\modules\settings\controllers;
use Yii;
use backend\modules\status\models\Status;
use backend\modules\status\models\StatusSearch;
use backend\modules\settings\models\Status;
use backend\modules\settings\models\StatusSearch;
use yii\helpers\ArrayHelper;
use yii\web\Controller;
use yii\web\NotFoundHttpException;

View File

@ -1,6 +1,6 @@
<?php
namespace backend\modules\fields\models;
namespace backend\modules\settings\models;
use common\classes\Debug;
use common\models\UseField;

View File

@ -1,6 +1,6 @@
<?php
namespace backend\modules\fields\models;
namespace backend\modules\settings\models;
use Yii;
use yii\base\Model;

View File

@ -0,0 +1,8 @@
<?php
namespace backend\modules\settings\models;
class Position extends \common\models\Position
{
}

View File

@ -0,0 +1,69 @@
<?php
namespace backend\modules\settings\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\settings\models\Position;
/**
* PositionSearch represents the model behind the search form of `backend\modules\settings\models\Position`.
*/
class PositionSearch extends Position
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id'], 'integer'],
[['name'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Position::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace backend\modules\settings\models;
class Skill extends \common\models\Skill
{
}

View File

@ -0,0 +1,69 @@
<?php
namespace backend\modules\settings\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\settings\models\Skill;
/**
* SkillSearch represents the model behind the search form of `backend\modules\settings\models\Skill`.
*/
class SkillSearch extends Skill
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id'], 'integer'],
[['name'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Skill::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace backend\modules\status\models;
namespace backend\modules\settings\models;
use common\models\UseStatus;

View File

@ -1,11 +1,11 @@
<?php
namespace backend\modules\status\models;
namespace backend\modules\settings\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\status\models\Status;
use backend\modules\settings\models\Status;
/**
* StatusSearch represents the model behind the search form of `backend\modules\status\models\Status`.

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\settings\models\Position */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="position-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,29 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\settings\models\PositionSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="position-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'name') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\settings\models\Position */
$this->title = 'Новая должность';
$this->params['breadcrumbs'][] = ['label' => 'Должности', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="position-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,33 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\settings\models\PositionSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Должность';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="position-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\settings\models\Position */
$this->title = 'Редактирование: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Должности', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
?>
<div class="position-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,35 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\settings\models\Position */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Должности', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="position-view">
<p>
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
],
]) ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\settings\models\Skill */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="skill-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,29 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\settings\models\SkillSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="skill-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'name') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\settings\models\Skill */
$this->title = 'Добавить';
$this->params['breadcrumbs'][] = ['label' => 'Навыки', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="skill-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,33 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\settings\models\SkillSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Навыки';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="skill-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\settings\models\Skill */
$this->title = 'Редактирование: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Навыки', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
?>
<div class="skill-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,35 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\settings\models\Skill */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Навыки', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="skill-view">
<p>
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
],
]) ?>
</div>

View File

@ -7,7 +7,7 @@ use yii\grid\GridView;
/* @var $searchModel backend\modules\status\models\StatusSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Statuses';
$this->title = 'Статусы';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="status-index">

View File

@ -3,10 +3,9 @@
/* @var $this yii\web\View */
/* @var $model backend\modules\status\models\Status */
$this->title = 'Update Status: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Statuses', 'url' => ['index']];
$this->title = 'Редактирование: ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Статусы', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="status-update">

View File

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

View File

@ -5,8 +5,16 @@
[
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
'items' => [
['label' => 'Статусы', 'icon' => 'anchor', 'url' => ['/status/status']],
['label' => 'Доп. поля', 'icon' => 'file-text-o', 'url' => ['/fields/additional-fields']],
[
'label' => 'Настройки', 'icon' => 'gears', 'url' => '#',
'items' => [
['label' => 'Статусы', 'icon' => 'anchor', 'url' => ['/settings/status']],
['label' => 'Доп. поля', 'icon' => 'file-text-o', 'url' => ['/settings/additional-fields']],
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position']],
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill']],
]
],
['label' => 'Профили', 'icon' => 'users', 'url' => ['/card/user-card']],
['label' => 'Пректы', 'icon' => 'files-o', 'url' => ['/project/project']],
['label' => 'Компании', 'icon' => 'files-o', 'url' => ['/company/company']],

View File

@ -0,0 +1,67 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "card_skill".
*
* @property int $id
* @property int $card_id
* @property int $skill_id
*
* @property Skill $skill
* @property UserCard $card
*/
class CardSkill extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'card_skill';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['card_id', 'skill_id'], 'required'],
[['card_id', 'skill_id'], 'integer'],
[['skill_id'], 'exist', 'skipOnError' => true, 'targetClass' => Skill::className(), 'targetAttribute' => ['skill_id' => 'id']],
[['card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['card_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'card_id' => 'Card ID',
'skill_id' => 'Skill ID',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getSkill()
{
return $this->hasOne(Skill::className(), ['id' => 'skill_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCard()
{
return $this->hasOne(UserCard::className(), ['id' => 'card_id']);
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "position".
*
* @property int $id
* @property string $name
*/
class Position extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'position';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name'], 'required'],
[['name'], 'string', 'max' => 100],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Название',
];
}
}

54
common/models/Skill.php Normal file
View File

@ -0,0 +1,54 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "skill".
*
* @property int $id
* @property string $name
*
* @property CardSkill[] $cardSkills
*/
class Skill extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'skill';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name'], 'required'],
[['name'], 'string', 'max' => 100],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Name',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCardSkills()
{
return $this->hasMany(CardSkill::className(), ['skill_id' => 'id']);
}
}

View File

@ -21,10 +21,11 @@ use yii\db\Expression;
* @property string $updated_at
* @property string $resume
* @property string $salary
* @property int $position_id
*
* @property array $genders
* @property string $gendersText
*
* @property FieldsValue[] $fieldsValues
* @property ProjectUser[] $projectUsers
* @property Position $position
* @property Status $status0
*/
class UserCard extends \yii\db\ActiveRecord
@ -59,11 +60,11 @@ class UserCard extends \yii\db\ActiveRecord
{
return [
[['fio', 'status'], 'required'],
[['status'], 'integer'],
[['gender'], 'in', 'range' => array_keys($this->genders)],
[['gender', 'status', 'position_id'], 'integer'],
[['dob', 'created_at', 'updated_at'], 'safe'],
[['fio', 'passport', 'photo', 'email', 'resume'], 'string', 'max' => 255],
[['salary'], 'string', 'max' => 100],
[['position_id'], 'exist', 'skipOnError' => true, 'targetClass' => Position::class, 'targetAttribute' => ['position_id' => 'id']],
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
];
}
@ -86,6 +87,7 @@ class UserCard extends \yii\db\ActiveRecord
'updated_at' => 'Дата редактирование',
'resume' => 'Резюме',
'salary' => 'Зарплата',
'position_id' => 'Должность',
];
}
@ -105,6 +107,14 @@ class UserCard extends \yii\db\ActiveRecord
return $this->hasMany(ProjectUser::class, ['card_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getPosition()
{
return $this->hasOne(Position::class, ['id' => 'position_id']);
}
/**
* @return \yii\db\ActiveQuery
*/

View File

@ -0,0 +1,33 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `position`.
*/
class m181012_082916_create_position_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('position', [
'id' => $this->primaryKey(),
'name' => $this->string(100)->notNull(),
], $tableOptions);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('position');
}
}

View File

@ -0,0 +1,36 @@
<?php
use yii\db\Migration;
/**
* Handles adding position_id to table `user_card`.
*/
class m181012_093626_add_position_id_column_to_user_card_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('user_card', 'position_id', $this->integer(11));
$this->addForeignKey(
'user_card_ibfk_position',
'user_card',
'position_id',
'position',
'id',
'RESTRICT',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropForeignKey('user_card_ibfk_position', 'user_card');
$this->dropColumn('project', 'company_id');
}
}

View File

@ -0,0 +1,62 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `skill`.
*/
class m181012_102422_create_skill_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('skill', [
'id' => $this->primaryKey(),
'name' => $this->string(100)->notNull(),
], $tableOptions);
$this->createTable('card_skill', [
'id' => $this->primaryKey(),
'card_id' => $this->integer(11)->notNull(),
'skill_id' => $this->integer(11)->notNull(),
], $tableOptions);
$this->addForeignKey(
'card_skill_ibfk_user_card',
'card_skill',
'card_id',
'user_card',
'id',
'RESTRICT',
'CASCADE'
);
$this->addForeignKey(
'card_skill_ibfk_skill',
'card_skill',
'skill_id',
'skill',
'id',
'RESTRICT',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('card_skill');
$this->dropTable('skill');
}
}