add mark to project
This commit is contained in:
parent
9eba04cae2
commit
8a1f99c707
165
backend/modules/project/controllers/ProjectMarkController.php
Normal file
165
backend/modules/project/controllers/ProjectMarkController.php
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\project\controllers;
|
||||||
|
|
||||||
|
use backend\modules\project\models\ProjectMark;
|
||||||
|
use backend\modules\project\models\ProjectMarkSearch;
|
||||||
|
use Yii;
|
||||||
|
use yii\filters\VerbFilter;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
use yii\web\Controller;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
use yii\web\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProjectMarkController implements the CRUD actions for ProjectMark model.
|
||||||
|
*/
|
||||||
|
class ProjectMarkController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function behaviors()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'verbs' => [
|
||||||
|
'class' => VerbFilter::className(),
|
||||||
|
'actions' => [
|
||||||
|
'delete' => ['POST'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all ProjectMark models.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionIndex()
|
||||||
|
{
|
||||||
|
$searchModel = new ProjectMarkSearch();
|
||||||
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
return $this->render('index', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a single ProjectMark 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 ProjectMark model.
|
||||||
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionCreate()
|
||||||
|
{
|
||||||
|
$marks = \Yii::$app->request->post('ProjectMark');
|
||||||
|
|
||||||
|
if (!empty($marks)) {
|
||||||
|
$mark_id_arr = ArrayHelper::getValue($marks, 'mark_id');
|
||||||
|
$project_id = $marks['project_id'];
|
||||||
|
|
||||||
|
foreach ($mark_id_arr as $mark_id) {
|
||||||
|
$emtModel = new ProjectMark();
|
||||||
|
$emtModel->project_id = $project_id;
|
||||||
|
$emtModel->mark_id = $mark_id;
|
||||||
|
|
||||||
|
if (!$emtModel->save()) {
|
||||||
|
return $this->render('create', [
|
||||||
|
'model' => $emtModel,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->redirect(['index']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$model = new ProjectMark();
|
||||||
|
return $this->render('create', [
|
||||||
|
'model' => $model,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an existing ProjectMark 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(['view', 'id' => $model->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('update', [
|
||||||
|
'model' => $model,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes an existing ProjectMark 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 ProjectMark model based on its primary key value.
|
||||||
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
* @param integer $id
|
||||||
|
* @return ProjectMark the loaded model
|
||||||
|
* @throws NotFoundHttpException if the model cannot be found
|
||||||
|
*/
|
||||||
|
protected function findModel($id)
|
||||||
|
{
|
||||||
|
if (($model = ProjectMark::findOne($id)) !== null) {
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotFoundHttpException('The requested page does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionUsersNotOnProject(): array
|
||||||
|
{
|
||||||
|
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
|
if (isset($_POST['depdrop_parents'])) {
|
||||||
|
$parents = $_POST['depdrop_parents'];
|
||||||
|
if ($parents != null) {
|
||||||
|
$project_id = $parents[0];
|
||||||
|
$categories = ProjectMark::getMarkNotAtProject($project_id);
|
||||||
|
|
||||||
|
$formattedCatArr = array();
|
||||||
|
foreach ($categories as $key => $value){
|
||||||
|
$formattedCatArr[] = array('id' => $key, 'name' => $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['output'=>$formattedCatArr, 'selected'=>''];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ['output'=>'', 'selected'=>''];
|
||||||
|
}
|
||||||
|
}
|
8
backend/modules/project/models/ProjectMark.php
Normal file
8
backend/modules/project/models/ProjectMark.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\project\models;
|
||||||
|
|
||||||
|
class ProjectMark extends \common\models\ProjectMark
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
67
backend/modules/project/models/ProjectMarkSearch.php
Normal file
67
backend/modules/project/models/ProjectMarkSearch.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\project\models;
|
||||||
|
|
||||||
|
use yii\base\Model;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
|
use backend\modules\project\models\ProjectMark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProjectMarkSearch represents the model behind the search form of `backend\modules\project\models\ProjectMark`.
|
||||||
|
*/
|
||||||
|
class ProjectMarkSearch extends ProjectMark
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['id', 'project_id', 'mark_id'], 'integer'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@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 = ProjectMark::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,
|
||||||
|
'project_id' => $this->project_id,
|
||||||
|
'mark_id' => $this->mark_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $dataProvider;
|
||||||
|
}
|
||||||
|
}
|
58
backend/modules/project/views/project-mark/_form.php
Normal file
58
backend/modules/project/views/project-mark/_form.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use backend\modules\project\models\Project;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
use kartik\depdrop\DepDrop;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\project\models\ProjectMark */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="project-mark-form">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'project_id')->dropDownList(
|
||||||
|
Project::find()->select(['name', 'id'])->indexBy('id')->column(),
|
||||||
|
[
|
||||||
|
'id' => 'project-id',
|
||||||
|
'placeholder' => 'Выберите',
|
||||||
|
'prompt' => 'Выберите'
|
||||||
|
]
|
||||||
|
) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'mark_id')->widget(DepDrop::className(),
|
||||||
|
[
|
||||||
|
'options' => ['id' => 'mark_id'],
|
||||||
|
'pluginOptions' => [
|
||||||
|
'depends' => ['project-id'],
|
||||||
|
'url' => Url::to(['/project/project-mark/users-not-on-project'])
|
||||||
|
,'initialize' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'type' => DepDrop::TYPE_SELECT2,
|
||||||
|
'select2Options' => [
|
||||||
|
'hideSearch' => false,
|
||||||
|
'pluginOptions' => [
|
||||||
|
'placeholder' => 'Вводите название метки',
|
||||||
|
'allowClear' => true,
|
||||||
|
'closeOnSelect' => false,
|
||||||
|
'multiple' => true,
|
||||||
|
'hideSearch' => false
|
||||||
|
],
|
||||||
|
'showToggleAll' => true,
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
41
backend/modules/project/views/project-mark/_form_update.php
Normal file
41
backend/modules/project/views/project-mark/_form_update.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use backend\modules\project\models\Project;
|
||||||
|
use backend\modules\settings\models\Mark;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\project\models\ProjectMark */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="project-mark-form">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'project_id')->dropDownList(
|
||||||
|
Project::find()->select(['name', 'id'])->indexBy('id')->column(),
|
||||||
|
[
|
||||||
|
'id' => 'project-id',
|
||||||
|
'placeholder' => 'Выберите',
|
||||||
|
'prompt' => 'Выберите'
|
||||||
|
]
|
||||||
|
) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'mark_id')->dropDownList(
|
||||||
|
Mark::find()->select(['title', 'id'])
|
||||||
|
->indexBy('id')
|
||||||
|
->column(),
|
||||||
|
[
|
||||||
|
'placeholder' => 'Выберите',
|
||||||
|
]
|
||||||
|
) ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
31
backend/modules/project/views/project-mark/_search.php
Normal file
31
backend/modules/project/views/project-mark/_search.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\project\models\ProjectMarkSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="project-mark-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['index'],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'id') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'project_id') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'mark_id') ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
18
backend/modules/project/views/project-mark/create.php
Normal file
18
backend/modules/project/views/project-mark/create.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\project\models\ProjectMark */
|
||||||
|
|
||||||
|
$this->title = 'Добавление проекту метки';
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => 'Project Marks', 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="project-mark-create">
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
61
backend/modules/project/views/project-mark/index.php
Normal file
61
backend/modules/project/views/project-mark/index.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use backend\modules\project\models\Project;
|
||||||
|
use backend\modules\settings\models\Mark;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $searchModel backend\modules\project\models\ProjectMarkSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
$this->title = 'Метки проектов';
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="project-mark-index">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a('Добавить проекту метку', ['create'], ['class' => 'btn btn-success']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'filterModel' => $searchModel,
|
||||||
|
'columns' => [
|
||||||
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
|
||||||
|
[
|
||||||
|
'attribute' => 'project_id',
|
||||||
|
'value' => function($model){
|
||||||
|
return $model->project->name;
|
||||||
|
},
|
||||||
|
'filter' => kartik\select2\Select2::widget([
|
||||||
|
'model' => $searchModel,
|
||||||
|
'attribute' => 'project_id',
|
||||||
|
'data' => Project::find()->select(['name', 'id'])->indexBy('id')->column(),
|
||||||
|
'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'],
|
||||||
|
'pluginOptions' => [
|
||||||
|
'allowClear' => true
|
||||||
|
],
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'mark_id',
|
||||||
|
'value' => function($model){
|
||||||
|
return $model->mark->title;
|
||||||
|
},
|
||||||
|
'filter' => kartik\select2\Select2::widget([
|
||||||
|
'model' => $searchModel,
|
||||||
|
'attribute' => 'mark_id',
|
||||||
|
'data' => Mark::find()->select(['title', 'id'])->indexBy('id')->column(),
|
||||||
|
'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'],
|
||||||
|
'pluginOptions' => [
|
||||||
|
'allowClear' => true
|
||||||
|
],
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
|
||||||
|
['class' => 'yii\grid\ActionColumn'],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
</div>
|
19
backend/modules/project/views/project-mark/update.php
Normal file
19
backend/modules/project/views/project-mark/update.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\project\models\ProjectMark */
|
||||||
|
|
||||||
|
$this->title = 'Изменение метки для проекта: ' . $model->project->name;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => 'Project Marks', 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
|
||||||
|
$this->params['breadcrumbs'][] = 'Update';
|
||||||
|
?>
|
||||||
|
<div class="project-mark-update">
|
||||||
|
|
||||||
|
<?= $this->render('_form_update', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
44
backend/modules/project/views/project-mark/view.php
Normal file
44
backend/modules/project/views/project-mark/view.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\project\models\ProjectMark */
|
||||||
|
|
||||||
|
$this->title = 'Проект: ' . $model->project->name . '; Метка: ' . $model->mark->title;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => 'Project Marks', 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
\yii\web\YiiAsset::register($this);
|
||||||
|
?>
|
||||||
|
<div class="project-mark-view">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= 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',
|
||||||
|
[
|
||||||
|
'attribute' => 'project_id',
|
||||||
|
'value' => ArrayHelper::getValue($model, 'project.name' ),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'mark_id',
|
||||||
|
'value' => ArrayHelper::getValue($model, 'mark.title' ),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
@ -29,21 +29,19 @@ use yii\widgets\ActiveForm;
|
|||||||
'options' => ['id' => 'card_id'],
|
'options' => ['id' => 'card_id'],
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
'depends' => ['project-id'],
|
'depends' => ['project-id'],
|
||||||
'placeholder' => 'Выберите',
|
|
||||||
'url' => Url::to(['/project/project-user/users-not-on-project'])
|
'url' => Url::to(['/project/project-user/users-not-on-project'])
|
||||||
,'initialize' => false,
|
,'initialize' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
'type' => DepDrop::TYPE_SELECT2,
|
'type' => DepDrop::TYPE_SELECT2,
|
||||||
'select2Options' => [
|
'select2Options' => [
|
||||||
'hideSearch' => false,
|
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
|
'placeholder' => 'Вводите фио',
|
||||||
'allowClear' => true,
|
'allowClear' => true,
|
||||||
'closeOnSelect' => false,
|
'closeOnSelect' => false,
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'hideSearch' => false
|
|
||||||
],
|
],
|
||||||
'showToggleAll' => false,
|
'showToggleAll' => true,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
127
backend/modules/settings/controllers/MarkController.php
Normal file
127
backend/modules/settings/controllers/MarkController.php
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\settings\controllers;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use backend\modules\settings\models\Mark;
|
||||||
|
use backend\modules\settings\models\MarkSearch;
|
||||||
|
use yii\web\Controller;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
use yii\filters\VerbFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MarkController implements the CRUD actions for Mark model.
|
||||||
|
*/
|
||||||
|
class MarkController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function behaviors()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'verbs' => [
|
||||||
|
'class' => VerbFilter::className(),
|
||||||
|
'actions' => [
|
||||||
|
'delete' => ['POST'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all Mark models.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionIndex()
|
||||||
|
{
|
||||||
|
$searchModel = new MarkSearch();
|
||||||
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
return $this->render('index', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a single Mark 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 Mark model.
|
||||||
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionCreate()
|
||||||
|
{
|
||||||
|
$model = new Mark();
|
||||||
|
|
||||||
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
|
return $this->redirect(['view', 'id' => $model->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('create', [
|
||||||
|
'model' => $model,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an existing Mark 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(['view', 'id' => $model->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('update', [
|
||||||
|
'model' => $model,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes an existing Mark 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 Mark model based on its primary key value.
|
||||||
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
* @param integer $id
|
||||||
|
* @return Mark the loaded model
|
||||||
|
* @throws NotFoundHttpException if the model cannot be found
|
||||||
|
*/
|
||||||
|
protected function findModel($id)
|
||||||
|
{
|
||||||
|
if (($model = Mark::findOne($id)) !== null) {
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotFoundHttpException('The requested page does not exist.');
|
||||||
|
}
|
||||||
|
}
|
8
backend/modules/settings/models/Mark.php
Normal file
8
backend/modules/settings/models/Mark.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\settings\models;
|
||||||
|
|
||||||
|
class Mark extends \common\models\Mark
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
68
backend/modules/settings/models/MarkSearch.php
Normal file
68
backend/modules/settings/models/MarkSearch.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\settings\models;
|
||||||
|
|
||||||
|
use yii\base\Model;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
|
use backend\modules\settings\models\Mark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MarkSearch represents the model behind the search form of `backend\modules\settings\models\Mark`.
|
||||||
|
*/
|
||||||
|
class MarkSearch extends Mark
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['id'], 'integer'],
|
||||||
|
[['title'], '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 = Mark::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', 'title', $this->title]);
|
||||||
|
|
||||||
|
return $dataProvider;
|
||||||
|
}
|
||||||
|
}
|
23
backend/modules/settings/views/mark/_form.php
Normal file
23
backend/modules/settings/views/mark/_form.php
Normal 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\Mark */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="mark-form">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
29
backend/modules/settings/views/mark/_search.php
Normal file
29
backend/modules/settings/views/mark/_search.php
Normal 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\MarkSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="mark-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['index'],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'id') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'title') ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
18
backend/modules/settings/views/mark/create.php
Normal file
18
backend/modules/settings/views/mark/create.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\settings\models\Mark */
|
||||||
|
|
||||||
|
$this->title = 'Создание метки';
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => 'Marks', 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="mark-create">
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
30
backend/modules/settings/views/mark/index.php
Normal file
30
backend/modules/settings/views/mark/index.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $searchModel backend\modules\settings\models\MarkSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
$this->title = 'Метки';
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="mark-index">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a('Создать метку', ['create'], ['class' => 'btn btn-success']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'filterModel' => $searchModel,
|
||||||
|
'columns' => [
|
||||||
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
|
||||||
|
'title',
|
||||||
|
|
||||||
|
['class' => 'yii\grid\ActionColumn'],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
</div>
|
19
backend/modules/settings/views/mark/update.php
Normal file
19
backend/modules/settings/views/mark/update.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\settings\models\Mark */
|
||||||
|
|
||||||
|
$this->title = 'Изменение метки: ' . $model->title;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => 'Marks', 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
|
||||||
|
$this->params['breadcrumbs'][] = 'Update';
|
||||||
|
?>
|
||||||
|
<div class="mark-update">
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
36
backend/modules/settings/views/mark/view.php
Normal file
36
backend/modules/settings/views/mark/view.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\settings\models\Mark */
|
||||||
|
|
||||||
|
$this->title = $model->title;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => 'Marks', 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
\yii\web\YiiAsset::register($this);
|
||||||
|
?>
|
||||||
|
<div class="mark-view">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= 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',
|
||||||
|
'title',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
@ -18,6 +18,7 @@
|
|||||||
$projectItems[] = ['label' => $status, 'icon' => 'user', 'url' => ['/project/project?ProjectSearch[status]=' . $key, 'active' => \Yii::$app->controller->id == 'project']];
|
$projectItems[] = ['label' => $status, 'icon' => 'user', 'url' => ['/project/project?ProjectSearch[status]=' . $key, 'active' => \Yii::$app->controller->id == 'project']];
|
||||||
}
|
}
|
||||||
$projectItems[] = ['label' => 'Сотрудники на проектах', 'icon' => 'users', 'url' => ['/project/project-user'], 'active' => \Yii::$app->controller->id == 'project-user'];
|
$projectItems[] = ['label' => 'Сотрудники на проектах', 'icon' => 'users', 'url' => ['/project/project-user'], 'active' => \Yii::$app->controller->id == 'project-user'];
|
||||||
|
$projectItems[] = ['label' => 'метки проектов', 'icon' => 'tags', 'url' => ['/project/project-mark'], 'active' => \Yii::$app->controller->id == 'project-mark'];
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?= dmstr\widgets\Menu::widget(
|
<?= dmstr\widgets\Menu::widget(
|
||||||
@ -31,6 +32,7 @@
|
|||||||
['label' => 'Доп. поля', 'icon' => 'file-text-o', 'url' => ['/settings/additional-fields'], 'active' => \Yii::$app->controller->id == 'additional-fields', 'visible' => Yii::$app->user->can('settings')],
|
['label' => 'Доп. поля', 'icon' => 'file-text-o', 'url' => ['/settings/additional-fields'], 'active' => \Yii::$app->controller->id == 'additional-fields', 'visible' => Yii::$app->user->can('settings')],
|
||||||
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position'], 'active' => \Yii::$app->controller->id == 'position', 'visible' => Yii::$app->user->can('settings')],
|
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position'], 'active' => \Yii::$app->controller->id == 'position', 'visible' => Yii::$app->user->can('settings')],
|
||||||
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill'], 'active' => \Yii::$app->controller->id == 'skill', 'visible' => Yii::$app->user->can('settings/skill')],
|
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill'], 'active' => \Yii::$app->controller->id == 'skill', 'visible' => Yii::$app->user->can('settings/skill')],
|
||||||
|
['label' => 'Метки', 'icon' => 'tag', 'url' => ['/settings/mark'], 'active' => \Yii::$app->controller->id == 'mark', 'visible' => Yii::$app->user->can('settings/mark')],
|
||||||
['label' => 'Шаблоны резюме', 'icon' => 'address-card ', 'url' => ['/card/resume-template'], 'active' => \Yii::$app->controller->id == 'resume-template', 'visible' => Yii::$app->user->can('card')],
|
['label' => 'Шаблоны резюме', 'icon' => 'address-card ', 'url' => ['/card/resume-template'], 'active' => \Yii::$app->controller->id == 'resume-template', 'visible' => Yii::$app->user->can('card')],
|
||||||
['label' => 'Шаблоны документов', 'icon' => 'file', 'url' => ['/document/document-template'], 'active' => \Yii::$app->controller->id == 'document-template', 'visible' => Yii::$app->user->can('document')],
|
['label' => 'Шаблоны документов', 'icon' => 'file', 'url' => ['/document/document-template'], 'active' => \Yii::$app->controller->id == 'document-template', 'visible' => Yii::$app->user->can('document')],
|
||||||
['label' => 'Поля документов', 'icon' => 'file-text', 'url' => ['/document/document-field'], 'active' => \Yii::$app->controller->id == 'document-field', 'visible' => Yii::$app->user->can('document')],
|
['label' => 'Поля документов', 'icon' => 'file-text', 'url' => ['/document/document-field'], 'active' => \Yii::$app->controller->id == 'document-field', 'visible' => Yii::$app->user->can('document')],
|
||||||
|
53
common/models/Mark.php
Normal file
53
common/models/Mark.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "mark".
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property string $title
|
||||||
|
*
|
||||||
|
* @property ProjectMark[] $projectMarks
|
||||||
|
*/
|
||||||
|
class Mark extends \yii\db\ActiveRecord
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function tableName()
|
||||||
|
{
|
||||||
|
return 'mark';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['title'], 'string', 'max' => 255],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => 'ID',
|
||||||
|
'title' => 'Название',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getProjectMarks()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProjectMark::className(), ['mark_id' => 'id']);
|
||||||
|
}
|
||||||
|
}
|
80
common/models/ProjectMark.php
Normal file
80
common/models/ProjectMark.php
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "project_mark".
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property int $project_id
|
||||||
|
* @property int $mark_id
|
||||||
|
*
|
||||||
|
* @property Mark $mark
|
||||||
|
* @property Project $project
|
||||||
|
*/
|
||||||
|
class ProjectMark extends \yii\db\ActiveRecord
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function tableName()
|
||||||
|
{
|
||||||
|
return 'project_mark';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['project_id', 'mark_id'], 'integer'],
|
||||||
|
[['project_id', 'mark_id'], 'required'],
|
||||||
|
[['project_id', 'mark_id'], 'unique', 'targetAttribute' => ['project_id', 'mark_id']],
|
||||||
|
[['mark_id'], 'exist', 'skipOnError' => true, 'targetClass' => Mark::className(), 'targetAttribute' => ['mark_id' => 'id']],
|
||||||
|
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => 'ID',
|
||||||
|
'project_id' => 'Проект',
|
||||||
|
'mark_id' => 'Метка',
|
||||||
|
'title' => 'Название',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getMark()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Mark::className(), ['id' => 'mark_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getProject()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Project::className(), ['id' => 'project_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getMarkNotAtProject($project_id): array
|
||||||
|
{
|
||||||
|
$markIdList = ProjectMark::find()->where(['project_id' => $project_id])->select('mark_id')->column();
|
||||||
|
|
||||||
|
$marks = Mark::find()
|
||||||
|
->where(['not in', 'id', $markIdList])
|
||||||
|
->all();
|
||||||
|
return ArrayHelper::map($marks, 'id', 'title');
|
||||||
|
}
|
||||||
|
}
|
@ -92,106 +92,154 @@ class RbacController extends Controller
|
|||||||
$admin = $auth->getRole('admin');
|
$admin = $auth->getRole('admin');
|
||||||
$profileEditor = $auth->getRole('profileEditor');
|
$profileEditor = $auth->getRole('profileEditor');
|
||||||
|
|
||||||
|
if(!$auth->getPermission('test')) {
|
||||||
$test = $auth->createPermission('test');
|
$test = $auth->createPermission('test');
|
||||||
$test->description = 'Модуль "Тестовые задания"';
|
$test->description = 'Модуль "Тестовые задания"';
|
||||||
$auth->add($test);
|
$auth->add($test);
|
||||||
$auth->addChild($admin, $test);
|
$auth->addChild($admin, $test);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('questionnaire')) {
|
||||||
$questionnaire = $auth->createPermission('questionnaire');
|
$questionnaire = $auth->createPermission('questionnaire');
|
||||||
$questionnaire->description = 'Модуль "Анкеты": Создание, редактирование анкет, категорий анкет, вопросов, проверка ответов пользователей';
|
$questionnaire->description = 'Модуль "Анкеты": Создание, редактирование анкет, категорий анкет, вопросов, проверка ответов пользователей';
|
||||||
$auth->add($questionnaire);
|
$auth->add($questionnaire);
|
||||||
$auth->addChild($admin, $questionnaire);
|
$auth->addChild($admin, $questionnaire);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('interview')) {
|
||||||
$interview = $auth->createPermission('interview');
|
$interview = $auth->createPermission('interview');
|
||||||
$interview->description = 'Модуль "Запрос интервью"';
|
$interview->description = 'Модуль "Запрос интервью"';
|
||||||
$auth->add($interview);
|
$auth->add($interview);
|
||||||
$auth->addChild($admin, $interview);
|
$auth->addChild($admin, $interview);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('options')) {
|
||||||
$options = $auth->createPermission('options');
|
$options = $auth->createPermission('options');
|
||||||
$options->description = 'Модуль "Опции"';
|
$options->description = 'Модуль "Опции"';
|
||||||
$auth->add($options);
|
$auth->add($options);
|
||||||
$auth->addChild($admin, $options);
|
$auth->addChild($admin, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('reports')) {
|
||||||
$reports = $auth->createPermission('reports');
|
$reports = $auth->createPermission('reports');
|
||||||
$reports->description = 'Модуль "Отчёты"';
|
$reports->description = 'Модуль "Отчёты"';
|
||||||
$auth->add($reports);
|
$auth->add($reports);
|
||||||
$auth->addChild($admin, $reports);
|
$auth->addChild($admin, $reports);
|
||||||
|
}
|
||||||
|
if(!$auth->getPermission('calendar')) {
|
||||||
$calendar = $auth->createPermission('calendar');
|
$calendar = $auth->createPermission('calendar');
|
||||||
$calendar->description = 'Модуль "Календарь ДР"';
|
$calendar->description = 'Модуль "Календарь ДР"';
|
||||||
$auth->add($calendar);
|
$auth->add($calendar);
|
||||||
$auth->addChild($admin, $calendar);
|
$auth->addChild($admin, $calendar);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('notes')) {
|
||||||
$notes = $auth->createPermission('notes');
|
$notes = $auth->createPermission('notes');
|
||||||
$notes->description = 'Модуль "Заметки"';
|
$notes->description = 'Модуль "Заметки"';
|
||||||
$auth->add($notes);
|
$auth->add($notes);
|
||||||
$auth->addChild($admin, $notes);
|
$auth->addChild($admin, $notes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('accesses')) {
|
||||||
$accesses = $auth->createPermission('accesses');
|
$accesses = $auth->createPermission('accesses');
|
||||||
$accesses->description = 'Модуль "Доступы"';
|
$accesses->description = 'Модуль "Доступы"';
|
||||||
$auth->add($accesses);
|
$auth->add($accesses);
|
||||||
$auth->addChild($admin, $accesses);
|
$auth->addChild($admin, $accesses);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('achievements')) {
|
||||||
$achievements = $auth->createPermission('achievements');
|
$achievements = $auth->createPermission('achievements');
|
||||||
$achievements->description = 'Модуль "Достижения"';
|
$achievements->description = 'Модуль "Достижения"';
|
||||||
$auth->add($achievements);
|
$auth->add($achievements);
|
||||||
$auth->addChild($admin, $achievements);
|
$auth->addChild($admin, $achievements);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('holiday')) {
|
||||||
$holiday = $auth->createPermission('holiday');
|
$holiday = $auth->createPermission('holiday');
|
||||||
$holiday->description = 'Модуль "Отпуска"';
|
$holiday->description = 'Модуль "Отпуска"';
|
||||||
$auth->add($holiday);
|
$auth->add($holiday);
|
||||||
$auth->addChild($admin, $holiday);
|
$auth->addChild($admin, $holiday);
|
||||||
|
}
|
||||||
|
if(!$auth->getPermission('balance')) {
|
||||||
$balance = $auth->createPermission('balance');
|
$balance = $auth->createPermission('balance');
|
||||||
$balance->description = 'Модуль "Баланс"';
|
$balance->description = 'Модуль "Баланс"';
|
||||||
$auth->add($balance);
|
$auth->add($balance);
|
||||||
$auth->addChild($admin, $balance);
|
$auth->addChild($admin, $balance);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('hh')) {
|
||||||
$hh = $auth->createPermission('hh');
|
$hh = $auth->createPermission('hh');
|
||||||
$hh->description = 'Модуль "Hh.ru"';
|
$hh->description = 'Модуль "Hh.ru"';
|
||||||
$auth->add($hh);
|
$auth->add($hh);
|
||||||
$auth->addChild($admin, $hh);
|
$auth->addChild($admin, $hh);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('company')) {
|
||||||
$company = $auth->createPermission('company');
|
$company = $auth->createPermission('company');
|
||||||
$company->description = 'Модуль "Компании"';
|
$company->description = 'Модуль "Компании"';
|
||||||
$auth->add($company);
|
$auth->add($company);
|
||||||
$auth->addChild($admin, $company);
|
$auth->addChild($admin, $company);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('task')) {
|
||||||
$task = $auth->createPermission('task');
|
$task = $auth->createPermission('task');
|
||||||
$task->description = 'Модуль "Задачи"';
|
$task->description = 'Модуль "Задачи"';
|
||||||
$auth->add($task);
|
$auth->add($task);
|
||||||
$auth->addChild($admin, $task);
|
$auth->addChild($admin, $task);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('project')) {
|
||||||
$project = $auth->createPermission('project');
|
$project = $auth->createPermission('project');
|
||||||
$project->description = 'Модуль "Проекты"';
|
$project->description = 'Модуль "Проекты"';
|
||||||
$auth->add($project);
|
$auth->add($project);
|
||||||
$auth->addChild($admin, $project);
|
$auth->addChild($admin, $project);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('document')) {
|
||||||
$documents = $auth->createPermission('document');
|
$documents = $auth->createPermission('document');
|
||||||
$documents->description = 'Модуль "Документы": Создание, редактирование документов, их полей и шаблонов';
|
$documents->description = 'Модуль "Документы": Создание, редактирование документов, их полей и шаблонов';
|
||||||
$auth->add($documents);
|
$auth->add($documents);
|
||||||
$auth->addChild($admin, $documents);
|
$auth->addChild($admin, $documents);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('employee')) {
|
||||||
$employee = $auth->createPermission('employee');
|
$employee = $auth->createPermission('employee');
|
||||||
$employee->description = 'Модуль "Сотрудники"';
|
$employee->description = 'Модуль "Сотрудники"';
|
||||||
$auth->add($employee);
|
$auth->add($employee);
|
||||||
$auth->addChild($admin, $employee);
|
$auth->addChild($admin, $employee);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('card')) {
|
||||||
$card = $auth->createPermission('card');
|
$card = $auth->createPermission('card');
|
||||||
$card->description = 'Модуль "Профили"';
|
$card->description = 'Модуль "Профили"';
|
||||||
$auth->add($card);
|
$auth->add($card);
|
||||||
$auth->addChild($admin, $card);
|
$auth->addChild($admin, $card);
|
||||||
$auth->addChild($profileEditor, $card);
|
$auth->addChild($profileEditor, $card);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('settings')) {
|
||||||
$settings = $auth->createPermission('settings');
|
$settings = $auth->createPermission('settings');
|
||||||
$settings->description = 'Модуль "Настройки"';
|
$settings->description = 'Модуль "Настройки"';
|
||||||
$auth->add($settings);
|
$auth->add($settings);
|
||||||
$auth->addChild($admin, $settings);
|
$auth->addChild($admin, $settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('settings/skill')) {
|
||||||
$skills = $auth->createPermission('settings/skill');
|
$skills = $auth->createPermission('settings/skill');
|
||||||
$skills->description = 'Навыки';
|
$skills->description = 'Навыки';
|
||||||
$auth->add($skills);
|
$auth->add($skills);
|
||||||
$auth->addChild($admin, $skills);
|
$auth->addChild($admin, $skills);
|
||||||
$auth->addChild($profileEditor, $skills);
|
$auth->addChild($profileEditor, $skills);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$auth->getPermission('settings/mark')) {
|
||||||
|
$mark = $auth->createPermission('settings/mark');
|
||||||
|
$mark->description = 'Метки';
|
||||||
|
$auth->add($mark);
|
||||||
|
$auth->addChild($admin, $mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
var_dump($auth->getPermission('settings/mark'));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
28
console/migrations/m230123_084421_create_mark_table.php
Normal file
28
console/migrations/m230123_084421_create_mark_table.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the creation of table `{{%mark}}`.
|
||||||
|
*/
|
||||||
|
class m230123_084421_create_mark_table extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->createTable('{{%mark}}', [
|
||||||
|
'id' => $this->primaryKey(),
|
||||||
|
'title' => $this->string()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropTable('{{%mark}}');
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the creation of table `{{%project_mark}}`.
|
||||||
|
*/
|
||||||
|
class m230123_084629_create_project_mark_table extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->createTable('{{%project_mark}}', [
|
||||||
|
'id' => $this->primaryKey(),
|
||||||
|
'project_id' => $this->integer(),
|
||||||
|
'mark_id' => $this->integer(),
|
||||||
|
]);
|
||||||
|
$this->addForeignKey('project_mark_project', 'project_mark', 'project_id', 'project', 'id');
|
||||||
|
$this->addForeignKey('project_mark_mark', 'project_mark', 'mark_id', 'mark', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropForeignKey('project_mark_project', 'project_mark');
|
||||||
|
$this->dropForeignKey('project_mark_mark', 'project_mark');
|
||||||
|
$this->dropTable('{{%project_mark}}');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user