Merge branch 'master' into for_managers_show_only_employees

# Conflicts:
#	console/controllers/RbacController.php
This commit is contained in:
iIronside
2023-03-16 17:45:47 +03:00
77 changed files with 5234 additions and 1936 deletions

View 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'=>''];
}
}

View File

@ -166,4 +166,25 @@ class ProjectUserController extends Controller
return $this->redirect(['index']);
}
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 = ProjectUser::getUsersNotOnProject($project_id);
$formattedCatArr = array();
foreach ($categories as $key => $value){
$formattedCatArr[] = array('id' => $key, 'name' => $value);
}
return ['output'=>$formattedCatArr, 'selected'=>''];
}
}
return ['output'=>'', 'selected'=>''];
}
}

View File

@ -2,12 +2,10 @@
namespace backend\modules\project\models;
use common\classes\Debug;
use common\models\FieldsValue;
use common\models\FieldsValueNew;
use common\models\ProjectUser;
use yii\helpers\ArrayHelper;
use Yii;
use yii\helpers\ArrayHelper;
class Project extends \common\models\Project
{
@ -59,13 +57,14 @@ class Project extends \common\models\Project
public function behaviors()
{
return [
'log' => [
'class' => \common\behaviors\LogBehavior::class,
]
$behaviors = parent::behaviors();
$behaviors['log'] = [
'class' => \common\behaviors\LogBehavior::class,
];
return $behaviors;
}
public function afterSave($insert, $changedAttributes)
{
$post = \Yii::$app->request->post('Project');

View File

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

View 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;
}
}

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View File

@ -1,10 +1,9 @@
<?php
use backend\modules\card\models\UserCard;
use backend\modules\project\models\Project;
use common\models\User;
use kartik\select2\Select2;
use kartik\depdrop\DepDrop;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
@ -16,26 +15,40 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'project_id')->widget(Select2::className(),
<?= $form->field($model, 'project_id')->dropDownList(
Project::find()->select(['name', 'id'])->indexBy('id')->column(),
[
'data' => Project::find()->select(['name', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
'id' => 'project-id',
'prompt' => 'Выберите'
]
) ?>
);
?>
<?= $form->field($model, 'card_id')->widget(Select2::className(),
<?= $form->field($model, 'card_id')->widget(DepDrop::className(),
[
'data' => UserCard::find()->select(['fio', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'options' => ['id' => 'card_id'],
'pluginOptions' => [
'allowClear' => true,
'multiple' => true,
'depends' => ['project-id'],
'url' => Url::to(['/project/project-user/users-not-on-project'])
,'initialize' => false,
],
'type' => DepDrop::TYPE_SELECT2,
'select2Options' => [
'pluginOptions' => [
'placeholder' => 'Вводите фио',
'allowClear' => true,
'closeOnSelect' => false,
'multiple' => true,
],
'showToggleAll' => true,
],
]
) ?>
);
echo "<p>
* в списке отображаются только пользователи у которых присудствует запись в таблице user (в user_card есть id_user)
</p>";
?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>

View 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.');
}
}

View File

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

View 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;
}
}

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\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>

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\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>

View 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>

View 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>

View 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>

View 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>

View File

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

View File

@ -3,11 +3,11 @@
namespace backend\modules\task\controllers;
use backend\modules\project\models\ProjectUser;
use backend\modules\task\models\TaskUser;
use backend\modules\task\models\ProjectTaskUser;
use yii\data\ActiveDataProvider;
use yii\web\Response;
use Yii;
use backend\modules\task\models\Task;
use backend\modules\task\models\ProjectTask;
use backend\modules\task\models\TaskSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
@ -80,7 +80,7 @@ class TaskController extends Controller
*/
public function actionCreate()
{
$model = new Task();
$model = new ProjectTask();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
@ -129,12 +129,12 @@ class TaskController extends Controller
* Finds the Task model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Task the loaded model
* @return ProjectTask the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Task::findOne($id)) !== null) {
if (($model = ProjectTask::findOne($id)) !== null) {
return $model;
}

View File

@ -7,7 +7,7 @@ use yii\base\Model;
use yii\helpers\ArrayHelper;
use yii\web\Response;
use Yii;
use backend\modules\task\models\TaskUser;
use backend\modules\task\models\ProjectTaskUser;
use backend\modules\task\models\TaskUserSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
@ -78,7 +78,7 @@ class TaskUserController extends Controller
$project_user_id_arr = ArrayHelper::getValue($post, 'project_user_id');
foreach ($project_user_id_arr as $project_user_id) {
$emtModel = new TaskUser();
$emtModel = new ProjectTaskUser();
$emtModel->task_id = $post['task_id'];
$emtModel->project_user_id = $project_user_id;
@ -99,7 +99,7 @@ class TaskUserController extends Controller
}
$model = new TaskUser();
$model = new ProjectTaskUser();
return $this->render('create', [
'model' => $model,
'task_id' => $task_id,
@ -156,12 +156,12 @@ class TaskUserController extends Controller
* Finds the TaskUser model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return TaskUser the loaded model
* @return ProjectTaskUser the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = TaskUser::findOne($id)) !== null) {
if (($model = ProjectTaskUser::findOne($id)) !== null) {
return $model;
}

View File

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

View File

@ -0,0 +1,9 @@
<?php
namespace backend\modules\task\models;
class ProjectTaskCategory extends \common\models\ProjectTaskCategory
{
}

View File

@ -0,0 +1,69 @@
<?php
namespace backend\modules\task\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\task\models\ProjectTaskCategory;
/**
* ProjectTaskCategorySearch represents the model behind the search form of `backend\modules\task\models\ProjectTaskCategory`.
*/
class ProjectTaskCategorySearch extends ProjectTaskCategory
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'project_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 = ProjectTaskCategory::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,
]);
$query->andFilterWhere(['like', 'title', $this->title]);
return $dataProvider;
}
}

View File

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

View File

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

View File

@ -5,12 +5,12 @@ namespace backend\modules\task\models;
use backend\modules\project\models\ProjectUser;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\task\models\Task;
use backend\modules\task\models\ProjectTask;
/**
* TaskSearch represents the model behind the search form of `backend\modules\task\models\Task`.
*/
class TaskSearch extends Task
class TaskSearch extends ProjectTask
{
/**
* {@inheritdoc}
@ -41,7 +41,7 @@ class TaskSearch extends Task
*/
public function search($params)
{
$query = Task::find();//->joinWith(['user_card', 'project']);
$query = ProjectTask::find();//->joinWith(['user_card', 'project']);
// add conditions that should always apply here

View File

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

View File

@ -4,12 +4,12 @@ namespace backend\modules\task\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\task\models\TaskUser;
use backend\modules\task\models\ProjectTaskUser;
/**
* TaskUserSearch represents the model behind the search form of `backend\modules\task\models\TaskUser`.
*/
class TaskUserSearch extends TaskUser
class TaskUserSearch extends ProjectTaskUser
{
public $projectId;
/**
@ -41,7 +41,7 @@ class TaskUserSearch extends TaskUser
*/
public function search($params)
{
$query = TaskUser::find()->joinWith(['task', 'projectUser', 'projectUser.project', 'projectUser.user']);
$query = ProjectTaskUser::find()->joinWith(['task', 'projectUser', 'projectUser.project', 'projectUser.user']);
// add conditions that should always apply here

View File

@ -0,0 +1,32 @@
<?php
use backend\modules\project\models\Project;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\ProjectTaskCategory */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="project-task-category-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'project_id')->dropDownList(
Project::find()->select(['name', 'id'])->indexBy('id')->column(),
[
'id' => 'project_id',
'prompt' => 'Выберите'
]
); ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,31 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\ProjectTaskCategorySearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="project-task-category-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'title') ?>
<?= $form->field($model, 'project_id') ?>
<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,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\ProjectTaskCategory */
$this->title = 'Создание категории задач';
$this->params['breadcrumbs'][] = ['label' => 'Project Task Categories', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="project-task-category-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,51 @@
<?php
use backend\modules\project\models\Project;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\task\models\ProjectTaskCategorySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Категории задач проекта';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="project-task-category-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'],
'title',
[
'attribute' => 'project_id',
'value' => 'project.name',
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'project_id',
'data' => Project::find()->select(['project.name', 'project.id'])
->indexBy('project.id')->column(),
'pluginOptions' => [
'allowClear' => true,
],
'options' => [
'class' => 'form-control',
'placeholder' => 'Выберите значение'
],
])
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\ProjectTaskCategory */
$this->title = 'Update Project Task Category: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Project Task Categories', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="project-task-category-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,40 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\ProjectTaskCategory */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Project Task Categories', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="project-task-category-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' => [
'title',
[
'attribute' => 'project_id',
'value' => ArrayHelper::getValue($model, 'project.name'),
],
],
]) ?>
</div>

View File

@ -1,6 +1,6 @@
<?php
use backend\modules\task\models\Task;
use backend\modules\task\models\ProjectTask;
use kartik\depdrop\DepDrop;
use kartik\select2\Select2;
use yii\helpers\Html;
@ -8,7 +8,7 @@ use yii\helpers\Url;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */
/* @var $model backend\modules\task\models\ProjectTaskUser */
/* @var $form yii\widgets\ActiveForm */
/* @var $task_id */
?>
@ -18,7 +18,7 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'task_id')->widget(Select2::className(),[
'data' => Task::find()->select(['title', 'id'])->indexBy('id')->column(),
'data' => ProjectTask::find()->select(['title', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите проект', 'value' => $task_id, 'id' => 'task-id',],
'pluginOptions' => [
'allowClear' => false,

View File

@ -1,6 +1,6 @@
<?php
use backend\modules\task\models\Task;
use backend\modules\task\models\ProjectTask;
use kartik\depdrop\DepDrop;
use kartik\select2\Select2;
use yii\helpers\Html;
@ -8,7 +8,7 @@ use yii\helpers\Url;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */
/* @var $model backend\modules\task\models\ProjectTaskUser */
/* @var $form yii\widgets\ActiveForm */
/* @var $task_id */
?>
@ -18,7 +18,7 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'task_id')->widget(Select2::className(),[
'data' => Task::find()->select(['title', 'id'])->indexBy('id')->column(),
'data' => ProjectTask::find()->select(['title', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите проект', 'value' => $task_id, 'id' => 'task-id',],
'pluginOptions' => [
'allowClear' => false,

View File

@ -2,7 +2,7 @@
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */
/* @var $model backend\modules\task\models\ProjectTaskUser */
/* @var $task_id */
$this->title = 'Назначить сотрудника';

View File

@ -1,8 +1,8 @@
<?php
use backend\modules\project\models\ProjectUser;
use backend\modules\task\models\Task;
use backend\modules\task\models\TaskUser;
use backend\modules\task\models\ProjectTask;
use backend\modules\task\models\ProjectTaskUser;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\grid\GridView;
@ -36,8 +36,8 @@ $this->params['breadcrumbs'][] = $this->title;
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'task_id',
'data' => TaskUser::find()->joinWith('task')
->select(['task.title', 'task.id'])->indexBy('task.id')->column(),
'data' => ProjectTaskUser::find()->joinWith('task')
->select(['project_task.title', 'project_task.id'])->indexBy('project_task.id')->column(),
'pluginOptions' => [
'allowClear' => true,
'width' => '250px',
@ -54,8 +54,8 @@ $this->params['breadcrumbs'][] = $this->title;
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'project_user_id',
'data' => TaskUser::find()->joinWith('projectUser.card')
->select(['user_card.fio', 'task_user.id'])->column(),
'data' => ProjectTaskUser::find()->joinWith('projectUser.card')
->select(['user_card.fio', 'project_task_user.id'])->column(),
'pluginOptions' => [
'allowClear' => true,
'width' => '250px',

View File

@ -2,7 +2,7 @@
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */
/* @var $model backend\modules\task\models\ProjectTaskUser */
/* @var $task_id */
$this->title = 'Изменить назначение';

View File

@ -5,7 +5,7 @@ use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */
/* @var $model backend\modules\task\models\ProjectTaskUser */
$this->title = 'Изменить назначение сотрудника';
$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];

View File

@ -8,7 +8,7 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\Task */
/* @var $model backend\modules\task\models\ProjectTask */
/* @var $form yii\widgets\ActiveForm */
?>

View File

@ -1,7 +1,7 @@
<?php
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\Task */
/* @var $model backend\modules\task\models\ProjectTask */
$this->title = 'Создать задачу';
$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']];

View File

@ -3,7 +3,7 @@
use backend\modules\card\models\UserCard;
use backend\modules\project\models\Project;
use backend\modules\project\models\ProjectUser;
use backend\modules\task\models\Task;
use backend\modules\task\models\ProjectTask;
use common\helpers\StatusHelper;
use common\models\User;
use kartik\select2\Select2;
@ -36,7 +36,7 @@ $this->params['breadcrumbs'][] = $this->title;
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'project_id',
'data' => Task::find()->joinWith('project')
'data' => ProjectTask::find()->joinWith('project')
->select(['project.name', 'project.id'])->indexBy('project.id')->column(),
'pluginOptions' => [
'allowClear' => true,
@ -55,7 +55,7 @@ $this->params['breadcrumbs'][] = $this->title;
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'card_id_creator',
'data' => Task::find()->joinWith('userCardCreator')
'data' => ProjectTask::find()->joinWith('userCardCreator')
->select(['user_card.fio', 'user_card.id'])->indexBy('user_card.id')->column(),
'pluginOptions' => [
'allowClear' => true,
@ -73,7 +73,7 @@ $this->params['breadcrumbs'][] = $this->title;
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'card_id',
'data' => Task::find()->joinWith('userCard')
'data' => ProjectTask::find()->joinWith('userCard')
->select(['user_card.fio', 'user_card.id'])->indexBy('user_card.id')->column(),
'pluginOptions' => [
'allowClear' => true,

View File

@ -3,7 +3,7 @@
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\Task */
/* @var $model backend\modules\task\models\ProjectTask */
$this->title = 'Исполнители задачи: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']];

View File

@ -8,7 +8,7 @@ use yii\web\YiiAsset;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\Task */
/* @var $model backend\modules\task\models\ProjectTask */
/* @var $taskDataProvider yii\data\ActiveDataProvider */
$this->title = 'Задача: ' . $model->title;