Merge branch 'master' into for_managers_show_only_employees
# Conflicts: # console/controllers/RbacController.php
This commit is contained in:
commit
1f375a52d8
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'=>''];
|
||||
}
|
||||
}
|
@ -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'=>''];
|
||||
}
|
||||
}
|
||||
|
@ -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' => [
|
||||
$behaviors = parent::behaviors();
|
||||
$behaviors['log'] = [
|
||||
'class' => \common\behaviors\LogBehavior::class,
|
||||
]
|
||||
];
|
||||
return $behaviors;
|
||||
}
|
||||
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
$post = \Yii::$app->request->post('Project');
|
||||
|
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>
|
@ -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' => [
|
||||
'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']) ?>
|
||||
|
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>
|
@ -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.');
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
8
backend/modules/task/models/ProjectTask.php
Normal file
8
backend/modules/task/models/ProjectTask.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\task\models;
|
||||
|
||||
class ProjectTask extends \common\models\ProjectTask
|
||||
{
|
||||
|
||||
}
|
9
backend/modules/task/models/ProjectTaskCategory.php
Normal file
9
backend/modules/task/models/ProjectTaskCategory.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\task\models;
|
||||
|
||||
|
||||
class ProjectTaskCategory extends \common\models\ProjectTaskCategory
|
||||
{
|
||||
|
||||
}
|
69
backend/modules/task/models/ProjectTaskCategorySearch.php
Normal file
69
backend/modules/task/models/ProjectTaskCategorySearch.php
Normal 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;
|
||||
}
|
||||
}
|
8
backend/modules/task/models/ProjectTaskUser.php
Normal file
8
backend/modules/task/models/ProjectTaskUser.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\task\models;
|
||||
|
||||
class ProjectTaskUser extends \common\models\ProjectTaskUser
|
||||
{
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\task\models;
|
||||
|
||||
class Task extends \common\models\Task
|
||||
{
|
||||
|
||||
}
|
@ -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
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\task\models;
|
||||
|
||||
class TaskUser extends \common\models\TaskUser
|
||||
{
|
||||
|
||||
}
|
@ -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
|
||||
|
||||
|
32
backend/modules/task/views/project-task-category/_form.php
Normal file
32
backend/modules/task/views/project-task-category/_form.php
Normal 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>
|
31
backend/modules/task/views/project-task-category/_search.php
Normal file
31
backend/modules/task/views/project-task-category/_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\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>
|
18
backend/modules/task/views/project-task-category/create.php
Normal file
18
backend/modules/task/views/project-task-category/create.php
Normal 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>
|
51
backend/modules/task/views/project-task-category/index.php
Normal file
51
backend/modules/task/views/project-task-category/index.php
Normal 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>
|
21
backend/modules/task/views/project-task-category/update.php
Normal file
21
backend/modules/task/views/project-task-category/update.php
Normal 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>
|
40
backend/modules/task/views/project-task-category/view.php
Normal file
40
backend/modules/task/views/project-task-category/view.php
Normal 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>
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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 = 'Назначить сотрудника';
|
||||
|
@ -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',
|
||||
|
@ -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 = 'Изменить назначение';
|
||||
|
@ -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']];
|
||||
|
@ -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 */
|
||||
?>
|
||||
|
||||
|
@ -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']];
|
||||
|
@ -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,
|
||||
|
@ -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']];
|
||||
|
@ -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;
|
||||
|
@ -18,6 +18,7 @@
|
||||
$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' => 'tags', 'url' => ['/project/project-mark'], 'active' => \Yii::$app->controller->id == 'project-mark'];
|
||||
?>
|
||||
|
||||
<?= 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' => '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' => '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' => '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')],
|
||||
@ -68,6 +70,7 @@
|
||||
'items' => [
|
||||
['label' => 'Задачи', 'icon' => 'minus', 'url' => ['/task/task'], 'active' => \Yii::$app->controller->id == 'task'],
|
||||
['label' => 'Исполнители задачи', 'icon' => 'users', 'url' => ['/task/task-user'], 'active' => \Yii::$app->controller->id == 'task-user'],
|
||||
['label' => 'Категории задач', 'icon' => 'users', 'url' => ['/task/project-task-category'], 'active' => \Yii::$app->controller->id == 'project-task-category'],
|
||||
],
|
||||
'visible' => Yii::$app->user->can('task')
|
||||
],
|
||||
|
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']);
|
||||
}
|
||||
}
|
@ -52,6 +52,7 @@ class Project extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
['name', 'unique'],
|
||||
[['name', 'status'], 'required'],
|
||||
[['description'], 'string'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
|
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');
|
||||
}
|
||||
}
|
@ -24,16 +24,16 @@ use yii\helpers\ArrayHelper;
|
||||
* @property Project $project
|
||||
* @property UserCard $card
|
||||
* @property UserCard $cardIdCreator
|
||||
* @property TaskUser[] $taskUsers
|
||||
* @property ProjectTaskUser[] $taskUsers
|
||||
*/
|
||||
class Task extends ActiveRecord
|
||||
class ProjectTask extends ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'task';
|
||||
return 'project_task';
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
@ -123,7 +123,7 @@ class Task extends ActiveRecord
|
||||
*/
|
||||
public function getTaskUsers()
|
||||
{
|
||||
return $this->hasMany(TaskUser::className(), ['task_id' => 'id']);
|
||||
return $this->hasMany(ProjectTaskUser::className(), ['task_id' => 'id']);
|
||||
}
|
||||
|
||||
public static function usersByTaskArr($task_id): array
|
59
common/models/ProjectTaskCategory.php
Normal file
59
common/models/ProjectTaskCategory.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "project_task_category".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
* @property int $project_id
|
||||
*
|
||||
* @property Project $project
|
||||
*/
|
||||
class ProjectTaskCategory extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'project_task_category';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['project_id', 'title'], 'required'],
|
||||
[['project_id', 'title'], 'unique', 'targetAttribute' => ['project_id', 'title']],
|
||||
[['project_id'], 'integer'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'title' => 'Название',
|
||||
'project_id' => 'Проект',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getProject()
|
||||
{
|
||||
return $this->hasOne(Project::className(), ['id' => 'project_id']);
|
||||
}
|
||||
}
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\InvalidConfigException;
|
||||
use yii\db\ActiveQuery;
|
||||
|
||||
/**
|
||||
@ -14,16 +12,16 @@ use yii\db\ActiveQuery;
|
||||
* @property int $project_user_id
|
||||
*
|
||||
* @property ProjectUser $projectUser
|
||||
* @property Task $task
|
||||
* @property ProjectTask $task
|
||||
*/
|
||||
class TaskUser extends \yii\db\ActiveRecord
|
||||
class ProjectTaskUser extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'task_user';
|
||||
return 'project_task_user';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,7 +33,7 @@ class TaskUser extends \yii\db\ActiveRecord
|
||||
[['task_id', 'project_user_id'], 'required'],
|
||||
['project_user_id', 'unique', 'targetAttribute' => ['task_id', 'project_user_id'], 'message'=>'Уже закреплён(ы) за задачей'],
|
||||
[['project_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectUser::className(), 'targetAttribute' => ['project_user_id' => 'id']],
|
||||
[['task_id'], 'exist', 'skipOnError' => true, 'targetClass' => Task::className(), 'targetAttribute' => ['task_id' => 'id']],
|
||||
[['task_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectTask::className(), 'targetAttribute' => ['task_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
@ -64,6 +62,6 @@ class TaskUser extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getTask()
|
||||
{
|
||||
return $this->hasOne(Task::className(), ['id' => 'task_id']);
|
||||
return $this->hasOne(ProjectTask::className(), ['id' => 'task_id']);
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ use yii\helpers\ArrayHelper;
|
||||
* @property Project $project
|
||||
* @property UserCard $card
|
||||
* @property User $user
|
||||
* @property TaskUser[] $taskUsers
|
||||
* @property ProjectTaskUser[] $taskUsers
|
||||
*/
|
||||
class ProjectUser extends \yii\db\ActiveRecord
|
||||
{
|
||||
@ -88,7 +88,7 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getTasks()
|
||||
{
|
||||
return $this->hasMany(Task::className(), ['project_user_id' => 'id']);
|
||||
return $this->hasMany(ProjectTask::className(), ['project_user_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,7 +96,7 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getTasksByProject()
|
||||
{
|
||||
return $this->hasMany(Task::className(), ['project_id' => 'project_id']);
|
||||
return $this->hasMany(ProjectTask::className(), ['project_id' => 'project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,7 +104,7 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getTaskUsers()
|
||||
{
|
||||
return $this->hasMany(TaskUser::className(), ['project_user_id' => 'id']);
|
||||
return $this->hasMany(ProjectTaskUser::className(), ['project_user_id' => 'id']);
|
||||
}
|
||||
|
||||
public static function usersByProjectArr($project_id): array
|
||||
@ -150,4 +150,15 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getUsersNotOnProject($project_id): array
|
||||
{
|
||||
$usersIdList = ProjectUser::find()->where(['project_id' => $project_id])->select('card_id')->column();
|
||||
|
||||
$userCards = UserCard::find()
|
||||
->where(['not in', 'id', $usersIdList])
|
||||
->andWhere(['not', ['id_user' => null]])
|
||||
->all();
|
||||
return ArrayHelper::map($userCards, 'id', 'fio');
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ use yii\web\UnauthorizedHttpException;
|
||||
* @property integer $updated_at
|
||||
* @property $access_token_expired_at
|
||||
* @property string $password write-only password
|
||||
*
|
||||
* @property UserCard $userCard
|
||||
*/
|
||||
class User extends ActiveRecord implements IdentityInterface, UserRbacInterface
|
||||
{
|
||||
|
@ -2,36 +2,36 @@
|
||||
|
||||
namespace common\services;
|
||||
|
||||
use common\models\Task;
|
||||
use common\models\ProjectTask;
|
||||
|
||||
class TaskService
|
||||
{
|
||||
public static function createTask($taskParams)
|
||||
{
|
||||
$task = new Task();
|
||||
$task = new ProjectTask();
|
||||
$task->load($taskParams, '');
|
||||
$task->save();
|
||||
return $task;
|
||||
}
|
||||
|
||||
public static function getTask($task_id): ?Task
|
||||
public static function getTask($task_id): ?ProjectTask
|
||||
{
|
||||
return Task::findOne($task_id);
|
||||
return ProjectTask::findOne($task_id);
|
||||
}
|
||||
|
||||
public static function getTaskList($task_id): array
|
||||
{
|
||||
return Task::find()->asArray()->all();
|
||||
return ProjectTask::find()->asArray()->all();
|
||||
}
|
||||
|
||||
public static function getTaskListByProject($project_id): array
|
||||
{
|
||||
return Task::find()->where(['project_id' => $project_id])->asArray()->all();
|
||||
return ProjectTask::find()->where(['project_id' => $project_id])->asArray()->all();
|
||||
}
|
||||
|
||||
public static function updateTask($task_params): ?Task
|
||||
public static function updateTask($task_params): ?ProjectTask
|
||||
{
|
||||
$modelTask = Task::findOne($task_params['task_id']);
|
||||
$modelTask = ProjectTask::findOne($task_params['task_id']);
|
||||
|
||||
$modelTask->load($task_params, '');
|
||||
$modelTask->save();
|
||||
@ -41,6 +41,6 @@ class TaskService
|
||||
|
||||
public static function taskExists($task_id): bool
|
||||
{
|
||||
return Task::find()->where(['id' => $task_id])->exists();
|
||||
return ProjectTask::find()->where(['id' => $task_id])->exists();
|
||||
}
|
||||
}
|
@ -29,7 +29,6 @@
|
||||
"edofre/yii2-fullcalendar-scheduler": "V1.1.12",
|
||||
"asmoday74/yii2-ckeditor5": "*",
|
||||
"kavalar/telegram_bot": "^0.2.0",
|
||||
"kavalar/yii2-telegram-bot": "^0.1.0",
|
||||
"2amigos/yii2-transliterator-helper": "*",
|
||||
"ext-json": "*",
|
||||
"kartik-v/yii2-widget-depdrop": "dev-master",
|
||||
@ -43,8 +42,8 @@
|
||||
"yiisoft/yii2-debug": "~2.0.0",
|
||||
"yiisoft/yii2-gii": "~2.0.0",
|
||||
"yiisoft/yii2-faker": "~2.0.0",
|
||||
"codeception/base": "^2.2.3",
|
||||
"codeception/verify": "~0.3.1"
|
||||
"codeception/verify": "~0.3.1",
|
||||
"codeception/module-yii2": "^1.1"
|
||||
},
|
||||
"config": {
|
||||
"process-timeout": 1800,
|
||||
|
3359
composer.lock
generated
3359
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m230118_120338_rename_task_table_to_project_task
|
||||
*/
|
||||
class m230118_120338_rename_task_table_to_project_task extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->renameTable('task', 'project_task');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->renameTable('project_task', 'task');
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m230118_120338_rename_task_table_to_project_task cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m230118_120405_rename_task_user_table_to_project_task_user
|
||||
*/
|
||||
class m230118_120405_rename_task_user_table_to_project_task_user extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->renameTable('task_user', 'project_task_user');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->renameTable('project_task_user', 'task_user');
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m230118_120405_rename_task_user_table_to_project_task_user cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
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}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m230221_181446_add_partner_to_status_table
|
||||
*/
|
||||
class m230221_181446_add_partner_to_status_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->insert('status',
|
||||
[
|
||||
'name' => 'Партнер',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->delete('status', ['name' => 'Партнер']);
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m230221_181446_add_partner_to_status_table cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
1189
docs/api/projects_and_tasks.md
Normal file
1189
docs/api/projects_and_tasks.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,200 +0,0 @@
|
||||
## Исполнители задачи
|
||||
## Методы
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Метод
|
||||
</th>
|
||||
<th>
|
||||
Описание
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
get-task-users
|
||||
</td>
|
||||
<td>
|
||||
Список исплнителей задачи
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
set-task-users
|
||||
</td>
|
||||
<td>
|
||||
Назначить исполнителя на задачу
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### Список исполнителей задачи
|
||||
`https://guild.craft-group.xyz/api/task-user/get-task-users`
|
||||
<p>
|
||||
Для получения списка исполнителей необходимо отправить <b>GET</b> запрос на URL https://guild.craft-group.xyz/api/task-user/get-task-users
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Требуемые параметры:
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Параметры
|
||||
</th>
|
||||
<th>
|
||||
Значение
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
task_id
|
||||
</td>
|
||||
<td>
|
||||
ID задачи
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
Пример запроса:
|
||||
</p>
|
||||
|
||||
`https://guild.craft-group.xyz/api/task-user/get-task-users?task_id=10`
|
||||
|
||||
<p>
|
||||
Возвращает массив сотрудников проекта закреплённых за задачей. <br>
|
||||
Каждый ответ имеет такой вид:
|
||||
</p>
|
||||
|
||||
```json5
|
||||
[
|
||||
{
|
||||
"id": 5,
|
||||
"task_id": 10,
|
||||
"project_user_id": 1
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"task_id": 10,
|
||||
"project_user_id": 5
|
||||
}
|
||||
]
|
||||
```
|
||||
<p>
|
||||
Параметры объекта <b>Исполнитель</b>:
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Параметры
|
||||
</th>
|
||||
<th>
|
||||
Значение
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
id
|
||||
</td>
|
||||
<td>
|
||||
ID исполнителя задачи(int)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
task_id
|
||||
</td>
|
||||
<td>
|
||||
ID задачи(int)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
project_user_id
|
||||
</td>
|
||||
<td>
|
||||
ID сотрудника на проекте(int)
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
Если задача не найдена будет отправлено следующее сообщение:
|
||||
</p>
|
||||
|
||||
```json5
|
||||
{
|
||||
"name": "Not Found",
|
||||
"message": "The task does not exist or there are no employees for it",
|
||||
"code": 0,
|
||||
"status": 404,
|
||||
"type": "yii\\web\\NotFoundHttpException"
|
||||
}
|
||||
```
|
||||
### Назначить сотрудника на задачу
|
||||
`https://guild.craft-group.xyz/api/task-user/set-task-users`
|
||||
<p>
|
||||
Для назначения исполнителя необходимо отправить <b>POST</b> запрос на URL https://guild.craft-group.xyz/api/task-user/set-task-user
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Требуемые параметры:
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Параметры
|
||||
</th>
|
||||
<th>
|
||||
Значение
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
task_id
|
||||
</td>
|
||||
<td>
|
||||
ID задачи
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
project_user_id
|
||||
</td>
|
||||
<td>
|
||||
ID сотрудника на проекте
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
Пример запроса:
|
||||
</p>
|
||||
|
||||
`https://guild.craft-group.xyz/api/task-user/set-task-user`
|
||||
|
||||
<p>
|
||||
Возвращает объект <b>Исполнителя задачи</b>.<br>
|
||||
Каждый ответ имеет такой вид:
|
||||
</p>
|
||||
|
||||
```json5
|
||||
{
|
||||
"task_id": "10",
|
||||
"project_user_id": "5",
|
||||
"id": 8
|
||||
}
|
||||
```
|
||||
|
||||
<p>
|
||||
Если задача не найдена будет отправлено следующее сообщение:
|
||||
</p>
|
||||
|
||||
```json5
|
||||
{
|
||||
"name": "Bad Request",
|
||||
"message": "{\"task_id\":[\"\З\а\д\а\ч\а is invalid.\"]}",
|
||||
"code": 0,
|
||||
"status": 400,
|
||||
"type": "yii\\web\\BadRequestHttpException"
|
||||
}
|
||||
```
|
321
docs/api/task.md
321
docs/api/task.md
@ -1,321 +0,0 @@
|
||||
# Задачи
|
||||
|
||||
## Методы
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Метод
|
||||
</th>
|
||||
<th>
|
||||
Описание
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
get-task-list
|
||||
</td>
|
||||
<td>
|
||||
Возвращает список задач
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
get-task
|
||||
</td>
|
||||
<td>
|
||||
Возвращает задачу
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
create-task
|
||||
</td>
|
||||
<td>
|
||||
Создаёт задачу
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
update
|
||||
</td>
|
||||
<td>
|
||||
Обновить задачу
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Список задач
|
||||
|
||||
`https://guild.craft-group.xyz/api/task/get-task-list?project_id=1`
|
||||
<p>
|
||||
Параметры:
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Параметры
|
||||
</th>
|
||||
<th>
|
||||
Значение
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
project_id
|
||||
</td>
|
||||
<td>
|
||||
Id проекта
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
Без передачи параметра возвращает массив объектов <b>Задача</b> . С параметром <b>project_id</b>,
|
||||
метод возвращает объекты <b>Задача</b> определённого проекта.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Возвращает <b>массив</b> объектов <b>Задача</b>. <br>
|
||||
Каждый объект <b>Задача</b> имеет такой вид:
|
||||
</p>
|
||||
|
||||
```json5
|
||||
[
|
||||
{
|
||||
"id": "6",
|
||||
"project_id": "74",
|
||||
"title": "Название задачи",
|
||||
"status": "1",
|
||||
"created_at": "2021-12-20 16:29:39",
|
||||
"updated_at": "2021-12-20 17:35:04",
|
||||
"description": "Описание задачи",
|
||||
"card_id_creator": "1",
|
||||
"card_id": "3"
|
||||
},
|
||||
'...'
|
||||
]
|
||||
```
|
||||
|
||||
## Получить документ
|
||||
|
||||
`https://guild.craft-group.xyz/api/task/get-task?task_id=15`
|
||||
<p>
|
||||
Параметры:
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Параметры
|
||||
</th>
|
||||
<th>
|
||||
Значение
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
task_id
|
||||
</td>
|
||||
<td>
|
||||
Id задачи
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
Возвращает объект <b>Задача</b>. <br>
|
||||
Каждый объект <b>Задача</b> имеет такой вид:
|
||||
</p>
|
||||
|
||||
```json5
|
||||
{
|
||||
"id": 15,
|
||||
"project_id": 74,
|
||||
"title": "4324238888",
|
||||
"status": 1,
|
||||
"created_at": "2022-01-05 17:37:37",
|
||||
"updated_at": "2022-01-05 17:46:10",
|
||||
"description": "888",
|
||||
"card_id_creator": 1,
|
||||
"card_id": null
|
||||
}
|
||||
```
|
||||
<p>
|
||||
Пример ошибки:
|
||||
</p>
|
||||
|
||||
```json5
|
||||
{
|
||||
"name": "Not Found",
|
||||
"message": "The task does not exist",
|
||||
"code": 0,
|
||||
"status": 404,
|
||||
"type": "yii\\web\\NotFoundHttpException"
|
||||
}
|
||||
```
|
||||
|
||||
## Создать документ
|
||||
|
||||
`https://guild.craft-group.xyz/api/document/create-document`
|
||||
<p>
|
||||
Параметры:
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Параметры
|
||||
</th>
|
||||
<th>
|
||||
Значение
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
title
|
||||
</td>
|
||||
<td>
|
||||
Название задачи
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
project_id
|
||||
</td>
|
||||
<td>
|
||||
Id проекта
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
status
|
||||
</td>
|
||||
<td>
|
||||
статус задачи
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
card_id_creator
|
||||
</td>
|
||||
<td>
|
||||
Id профиля создателя
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
card_id
|
||||
</td>
|
||||
<td>
|
||||
Id профиля наблюдателя(не обязательный параметр)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
description
|
||||
</td>
|
||||
<td>
|
||||
Описание
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
Создаёт <b>Задача</b>. Требует передачи <b>POST</b> запроса с соответствующими
|
||||
параметрами
|
||||
</p>
|
||||
|
||||
<p>
|
||||
В случае указания не верных параметров буде возвращена соответствующая ошибка. Пример ошибки:
|
||||
</p>
|
||||
|
||||
```json5
|
||||
{
|
||||
"name": "Internal Server Error",
|
||||
"message": "{\"project_id\":[\"\П\р\о\е\к\т is invalid.\"]}",
|
||||
"code": 0,
|
||||
"status": 500,
|
||||
"type": "yii\\web\\ServerErrorHttpException"
|
||||
}
|
||||
```
|
||||
|
||||
## Обновить задачу
|
||||
|
||||
`https://guild.craft-group.xyz/api/task/update`
|
||||
<p>
|
||||
Параметры:
|
||||
</p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Параметры
|
||||
</th>
|
||||
<th>
|
||||
Значение
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
title
|
||||
</td>
|
||||
<td>
|
||||
Название задачи
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
project_id
|
||||
</td>
|
||||
<td>
|
||||
Id проекта
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
status
|
||||
</td>
|
||||
<td>
|
||||
статус задачи
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
card_id_creator
|
||||
</td>
|
||||
<td>
|
||||
Id профиля создателя
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
card_id
|
||||
</td>
|
||||
<td>
|
||||
Id профиля наблюдателя(не обязательный параметр)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
description
|
||||
</td>
|
||||
<td>
|
||||
Описание
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
Обновляет объект <b>Задача</b>. Требует передачи <b>POST</b> запроса с соответствующими
|
||||
параметрами
|
||||
</p>
|
||||
|
||||
<p>
|
||||
В случае указания не верных параметров буде возвращена соответствующая ошибка. Пример ошибки:
|
||||
</p>
|
||||
|
||||
```json5
|
||||
{
|
||||
"name": "Not Found",
|
||||
"message": "The task does not exist",
|
||||
"code": 0,
|
||||
"status": 404,
|
||||
"type": "yii\\web\\NotFoundHttpException"
|
||||
}
|
||||
```
|
@ -18,7 +18,5 @@ class Api extends \yii\base\Module
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
}
|
||||
|
133
frontend/modules/api/controllers/ProjectController.php
Normal file
133
frontend/modules/api/controllers/ProjectController.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\modules\api\controllers;
|
||||
|
||||
use common\models\ProjectTaskCategory;
|
||||
use common\models\ProjectUser;
|
||||
use common\models\Status;
|
||||
use common\models\UseStatus;
|
||||
use frontend\modules\api\models\Project;
|
||||
use Yii;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class ProjectController extends ApiController
|
||||
{
|
||||
public $modelClass = 'frontend\modules\api\models\Project';
|
||||
public $serializer = [
|
||||
'class' => 'yii\rest\Serializer',
|
||||
'collectionEnvelope' => 'projects',
|
||||
];
|
||||
|
||||
public function behaviors(): array
|
||||
{
|
||||
return ArrayHelper::merge(parent::behaviors(), [
|
||||
|
||||
'verbs' => [
|
||||
'class' => \yii\filters\VerbFilter::class,
|
||||
'actions' => [
|
||||
'get-project' => ['GET', 'OPTIONS'],
|
||||
'project-list' => ['GET', 'OPTIONS'],
|
||||
'status-list' => ['GET', 'OPTIONS'],
|
||||
'project-task-category-list' => ['GET', 'OPTIONS'],
|
||||
'create' => ['POST', 'OPTIONS'],
|
||||
'update' => ['POST', 'OPTIONS']
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionGetProject($project_id): ?Project
|
||||
{
|
||||
return Project::findOne($project_id);
|
||||
}
|
||||
|
||||
public function actionProjectList($card_id = null): ActiveDataProvider
|
||||
{
|
||||
if (!empty($card_id)) {
|
||||
$projectIdList = ProjectUser::find()->where(['card_id' => $card_id])->select('project_id')->column();
|
||||
$query = Project::find()->where([ 'IN', 'id', $projectIdList]);
|
||||
} else {
|
||||
$query = Project::find();
|
||||
}
|
||||
|
||||
return new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionStatusList(): array
|
||||
{
|
||||
return Status::find()
|
||||
->joinWith('useStatuses')
|
||||
->where(['`use_status`.`use`' => UseStatus::USE_PROJECT])->all();
|
||||
}
|
||||
|
||||
public function actionProjectTaskCategoryList($project_id): array
|
||||
{
|
||||
return ProjectTaskCategory::find()->where(['project_id' => $project_id])->all();
|
||||
}
|
||||
|
||||
public function actionCreateProjectTaskCategory()
|
||||
{
|
||||
$projectTaskCategory = new ProjectTaskCategory();
|
||||
$projectTaskCategory->attributes = \yii::$app->request->post();
|
||||
|
||||
if($projectTaskCategory->validate()) {
|
||||
$projectTaskCategory->save(false);
|
||||
return $projectTaskCategory;
|
||||
}
|
||||
return $projectTaskCategory->errors;
|
||||
}
|
||||
|
||||
public function actionUpdateProjectTaskCategory()
|
||||
{
|
||||
$projectTaskCategory = ProjectTaskCategory::find()
|
||||
->where(['project_id' => Yii::$app->request->post('project_id')])
|
||||
->andWhere(['title' => Yii::$app->request->post('title')])
|
||||
->one();
|
||||
|
||||
if(empty($projectTaskCategory)) {
|
||||
throw new NotFoundHttpException('The project not found');
|
||||
}
|
||||
|
||||
$projectTaskCategory->title = Yii::$app->request->post('new_title');
|
||||
if (!$projectTaskCategory->update() && $projectTaskCategory->hasErrors()) {
|
||||
return $projectTaskCategory->errors;
|
||||
}
|
||||
return $projectTaskCategory;
|
||||
}
|
||||
|
||||
public function actionCreate()
|
||||
{
|
||||
$project = new Project();
|
||||
$project->attributes = \yii::$app->request->post();
|
||||
|
||||
if($project->validate()) {
|
||||
$project->save(false);
|
||||
return $project;
|
||||
}
|
||||
return $project->errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Throwable
|
||||
* @throws \yii\base\InvalidConfigException
|
||||
* @throws \yii\db\StaleObjectException
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionUpdate()
|
||||
{
|
||||
$project = Project::findOne(Yii::$app->request->post('project_id'));
|
||||
if(empty($project)) {
|
||||
throw new NotFoundHttpException('The project not found');
|
||||
}
|
||||
|
||||
$project->load(Yii::$app->request->getBodyParams(), '');
|
||||
if (!$project->update()) {
|
||||
return $project->errors;
|
||||
}
|
||||
return $project;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace frontend\modules\api\controllers;
|
||||
|
||||
use common\models\Task;
|
||||
use common\models\ProjectTask;
|
||||
use common\services\TaskService;
|
||||
use Yii;
|
||||
use yii\base\InvalidConfigException;
|
||||
@ -25,7 +25,7 @@ class TaskController extends ApiController
|
||||
* @throws InvalidConfigException
|
||||
* @throws ServerErrorHttpException
|
||||
*/
|
||||
public function actionCreateTask(): Task
|
||||
public function actionCreateTask(): ProjectTask
|
||||
{
|
||||
$taskModel = TaskService::createTask(Yii::$app->getRequest()->getBodyParams());
|
||||
if ($taskModel->errors) {
|
||||
@ -59,7 +59,7 @@ class TaskController extends ApiController
|
||||
/**
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionGetTask($task_id): Task
|
||||
public function actionGetTask($task_id): ProjectTask
|
||||
{
|
||||
if (empty($task_id) or !is_numeric($task_id)) {
|
||||
throw new NotFoundHttpException('Incorrect task ID');
|
||||
@ -78,7 +78,7 @@ class TaskController extends ApiController
|
||||
* @throws ServerErrorHttpException
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionUpdate(): ?Task
|
||||
public function actionUpdate(): ?ProjectTask
|
||||
{
|
||||
$params = Yii::$app->request->getBodyParams();
|
||||
if (empty ($params['task_id']) or !TaskService::taskExists($params['task_id'])) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace frontend\modules\api\controllers;
|
||||
|
||||
use common\models\TaskUser;
|
||||
use common\models\ProjectTaskUser;
|
||||
use Yii;
|
||||
use yii\filters\auth\HttpBearerAuth;
|
||||
use yii\rest\Controller;
|
||||
@ -21,7 +21,7 @@ class TaskUserController extends ApiController
|
||||
|
||||
public function actionSetTaskUser()
|
||||
{
|
||||
$taskUserModel = new TaskUser();
|
||||
$taskUserModel = new ProjectTaskUser();
|
||||
|
||||
$params = Yii::$app->request->post();
|
||||
$taskUserModel->attributes = $params;
|
||||
@ -57,6 +57,6 @@ class TaskUserController extends ApiController
|
||||
|
||||
private function findUsers($project_id): array
|
||||
{
|
||||
return TaskUser::find()->where(['task_id' => $project_id])->all();
|
||||
return ProjectTaskUser::find()->where(['task_id' => $project_id])->all();
|
||||
}
|
||||
}
|
@ -62,11 +62,14 @@ class UserController extends ActiveController
|
||||
{
|
||||
$model = new LoginForm();
|
||||
if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->login()) {
|
||||
/** @var User $user */
|
||||
$user = $model->getUser();
|
||||
return [
|
||||
'access_token' => $model->login(),
|
||||
'access_token_expired_at' => $model->getUser()->getTokenExpiredAt(),
|
||||
'id' => $model->getUser()->id,
|
||||
'card_id' => $model->getUser()->userCard->id ?? null,
|
||||
'id' => $user->id,
|
||||
'status' => $user->userCard->status,
|
||||
'card_id' => $user->userCard->id ?? null,
|
||||
];
|
||||
} else {
|
||||
throw new BadRequestHttpException(json_encode($model->errors));
|
||||
|
20
frontend/modules/api/models/Company.php
Normal file
20
frontend/modules/api/models/Company.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\modules\api\models;
|
||||
|
||||
class Company extends \common\models\Company
|
||||
{
|
||||
public function fields()
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'name',
|
||||
'description',
|
||||
];
|
||||
}
|
||||
|
||||
public function extraFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
44
frontend/modules/api/models/Project.php
Normal file
44
frontend/modules/api/models/Project.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\modules\api\models;
|
||||
|
||||
use yii\db\ActiveQuery;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\Link;
|
||||
use yii\web\Linkable;
|
||||
|
||||
class Project extends \common\models\Project implements Linkable
|
||||
{
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'name',
|
||||
'budget',
|
||||
'status',
|
||||
'hh_id' => function() {
|
||||
return $this->hh;
|
||||
},
|
||||
'company' => function() {
|
||||
return $this->company;
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function extraFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLinks(): array
|
||||
{
|
||||
return [
|
||||
Link::REL_SELF => Url::to(['index', 'project_id' => $this->id], true),
|
||||
];
|
||||
}
|
||||
|
||||
public function getCompany(): ActiveQuery
|
||||
{
|
||||
return $this->hasOne(Company::className(), ['id' => 'company_id']);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user