add task, fixed executors in all projects

This commit is contained in:
iIronside 2021-11-24 13:05:12 +03:00
parent a058b1baa1
commit 7d886ff7c3
19 changed files with 1444 additions and 85 deletions

View File

@ -86,7 +86,6 @@ YiiAsset::register($this);
'class' => 'btn btn-primary', 'class' => 'btn btn-primary',
'data' => [ 'data' => [
'confirm' => 'Проверка ответов пользователя: ' . $user . ". Категория: " . $questionnaire_title, 'confirm' => 'Проверка ответов пользователя: ' . $user . ". Категория: " . $questionnaire_title,
// 'method' => 'post',
], ],
]) ?> ]) ?>
<?php <?php

View File

@ -2,6 +2,8 @@
namespace backend\modules\task\controllers; namespace backend\modules\task\controllers;
use backend\modules\project\models\ProjectUser;
use yii\web\Response;
use Yii; use Yii;
use backend\modules\task\models\Task; use backend\modules\task\models\Task;
use backend\modules\task\models\TaskSearch; use backend\modules\task\models\TaskSearch;
@ -124,4 +126,25 @@ class TaskController extends Controller
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
public function actionCreator()
{
Yii::$app->response->format = Response::FORMAT_JSON;
if (isset($_POST['depdrop_parents'])) {
$parents = $_POST['depdrop_parents'];
if ($parents != null) {
$project_id = $parents[0];
$users = ProjectUser::usersByProjectArr($project_id);
$formattedUsersArr = array();
foreach ($users as $key => $value){
$formattedUsersArr[] = array('id' => $key, 'name' => $value);
}
return ['output'=>$formattedUsersArr, 'selected'=>''];
}
}
return ['output'=>'', 'selected'=>''];
}
} }

View File

@ -2,6 +2,8 @@
namespace backend\modules\task\controllers; namespace backend\modules\task\controllers;
use backend\modules\project\models\ProjectUser;
use yii\web\Response;
use Yii; use Yii;
use backend\modules\task\models\TaskUser; use backend\modules\task\models\TaskUser;
use backend\modules\task\models\TaskUserSearch; use backend\modules\task\models\TaskUserSearch;
@ -124,4 +126,25 @@ class TaskUserController extends Controller
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
public function actionExecutor()
{
Yii::$app->response->format = Response::FORMAT_JSON;
if (isset($_POST['depdrop_parents'])) {
$parents = $_POST['depdrop_parents'];
if ($parents != null) {
$task_id = $parents[0];
$users = ProjectUser::usersByTaskArr($task_id);
$formattedUsersArr = array();
foreach ($users as $key => $value){
$formattedUsersArr[] = array('id' => $key, 'name' => $value);
}
return ['output'=>$formattedUsersArr, 'selected'=>''];
}
}
return ['output'=>'', 'selected'=>''];
}
} }

View File

@ -1,6 +1,9 @@
<?php <?php
use backend\modules\task\models\Task;
use kartik\depdrop\DepDrop;
use yii\helpers\Html; use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
@ -12,9 +15,25 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'task_id')->textInput() ?> <?= $form->field($model, 'task_id')->dropDownList(Task::find()
->select(['title', 'id'])->indexBy('id')->column(),
[
'id' => 'task-id',
'prompt' => 'Выберите'
]
);
?>
<?= $form->field($model, 'project_user_id')->textInput() ?> <?= $form->field($model, 'project_user_id')->widget(DepDrop::className(),
[
'options' => ['id' => 'project-user-id'],
'pluginOptions' => [
'depends' => ['task-id'],
'placeholder' => 'Выберите',
'url' => Url::to(['/task/task-user/executor'])
]
]
); ?>
<div class="form-group"> <div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?> <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>

View File

@ -1,18 +1,15 @@
<?php <?php
use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */ /* @var $model backend\modules\task\models\TaskUser */
$this->title = 'Create Task User'; $this->title = 'Назначить сотрудника';
$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="task-user-create"> <div class="task-user-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [ <?= $this->render('_form', [
'model' => $model, 'model' => $model,
]) ?> ]) ?>

View File

@ -1,5 +1,8 @@
<?php <?php
use backend\modules\project\models\ProjectUser;
use backend\modules\task\models\Task;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
@ -7,16 +10,13 @@ use yii\grid\GridView;
/* @var $searchModel backend\modules\task\models\TaskUserSearch */ /* @var $searchModel backend\modules\task\models\TaskUserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Task Users'; $this->title = 'Исполнители задачи';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="task-user-index"> <div class="task-user-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p> <p>
<?= Html::a('Create Task User', ['create'], ['class' => 'btn btn-success']) ?> <?= Html::a('Назначить сотрудника', ['create'], ['class' => 'btn btn-success']) ?>
</p> </p>
<?= GridView::widget([ <?= GridView::widget([
@ -25,9 +25,17 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [ 'columns' => [
['class' => 'yii\grid\SerialColumn'], ['class' => 'yii\grid\SerialColumn'],
'id', [
'task_id', 'attribute' => 'task_id',
'project_user_id', 'filter' => ArrayHelper::map(Task::find()->all(), 'id', 'title'),
'value' => 'task.title'
],
[
'attribute' => 'project_user_id',
'filter' => ArrayHelper::map(ProjectUser::find()->joinWith('user')
->all(), 'id', 'user.username'),
'value' => 'projectUser.user.username'
],
['class' => 'yii\grid\ActionColumn'], ['class' => 'yii\grid\ActionColumn'],
], ],

View File

@ -5,15 +5,13 @@ use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */ /* @var $model backend\modules\task\models\TaskUser */
$this->title = 'Update Task User: ' . $model->id; $this->title = 'Изменить назначение';
$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update'; $this->params['breadcrumbs'][] = 'Update';
?> ?>
<div class="task-user-update"> <div class="task-user-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [ <?= $this->render('_form', [
'model' => $model, 'model' => $model,
]) ?> ]) ?>

View File

@ -1,23 +1,23 @@
<?php <?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */ /* @var $model backend\modules\task\models\TaskUser */
$this->title = $model->id; $this->title = 'Изменить назначение сотрудника';
$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this); \yii\web\YiiAsset::register($this);
?> ?>
<div class="task-user-view"> <div class="task-user-view">
<h1><?= Html::encode($this->title) ?></h1>
<p> <p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> <?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [ <?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger', 'class' => 'btn btn-danger',
'data' => [ 'data' => [
'confirm' => 'Are you sure you want to delete this item?', 'confirm' => 'Are you sure you want to delete this item?',
@ -30,8 +30,14 @@ $this->params['breadcrumbs'][] = $this->title;
'model' => $model, 'model' => $model,
'attributes' => [ 'attributes' => [
'id', 'id',
'task_id', [
'project_user_id', 'attribute' => 'task_id',
'value' => ArrayHelper::getValue($model, 'task.title'),
],
[
'attribute' => 'project_user_id',
'value' => ArrayHelper::getValue($model, 'projectUser.user.username'),
],
], ],
]) ?> ]) ?>

View File

@ -1,6 +1,12 @@
<?php <?php
use backend\modules\project\models\Project;
use backend\modules\project\models\ProjectUser;
use common\helpers\StatusHelper;
use kartik\depdrop\DepDrop;
use kartik\select2\Select2;
use yii\helpers\Html; use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
@ -12,17 +18,34 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'project_id')->textInput() ?> <?= $form->field($model, 'project_id')->dropDownList(Project::find()
->select(['name', 'id'])->indexBy('id')->column(),
[
'id' => 'project-id',
'prompt' => 'Выберите'
]
);
?>
<?= $form->field($model, 'project_user_id')->widget(DepDrop::className(),
[
'options' => ['id' => 'project-user-id'],
'pluginOptions' => [
'depends' => ['project-id'],
'placeholder' => 'Выберите',
'url' => Url::to(['/task/task/creator'])
]
]
); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->textInput() ?> <?= $form->field($model, 'status')->dropDownList(
StatusHelper::statusList(),
<?= $form->field($model, 'created_at')->textInput() ?> [
'prompt' => 'Выберите'
<?= $form->field($model, 'updated_at')->textInput() ?> ]
) ?>
<?= $form->field($model, 'project_user_id')->textInput() ?>
<?= $form->field($model, 'user_id')->textInput() ?> <?= $form->field($model, 'user_id')->textInput() ?>

View File

@ -1,18 +1,14 @@
<?php <?php
use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model backend\modules\task\models\Task */ /* @var $model backend\modules\task\models\Task */
$this->title = 'Create Task'; $this->title = 'Создать задачу';
$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="task-create"> <div class="task-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [ <?= $this->render('_form', [
'model' => $model, 'model' => $model,
]) ?> ]) ?>

View File

@ -1,5 +1,8 @@
<?php <?php
use backend\modules\project\models\Project;
use common\helpers\StatusHelper;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
@ -7,16 +10,13 @@ use yii\grid\GridView;
/* @var $searchModel backend\modules\task\models\TaskSearch */ /* @var $searchModel backend\modules\task\models\TaskSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Tasks'; $this->title = 'Задачи';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="task-index"> <div class="task-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p> <p>
<?= Html::a('Create Task', ['create'], ['class' => 'btn btn-success']) ?> <?= Html::a('Создать задачу', ['create'], ['class' => 'btn btn-success']) ?>
</p> </p>
<?= GridView::widget([ <?= GridView::widget([
@ -25,15 +25,21 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [ 'columns' => [
['class' => 'yii\grid\SerialColumn'], ['class' => 'yii\grid\SerialColumn'],
'id', [
'project_id', 'attribute' => 'project_id',
'filter' => ArrayHelper::map(Project::find()->all(), 'id', 'name'),
'value' => 'project.name'
],
'title', 'title',
'status', [
'attribute' => 'status',
'format' => 'raw',
'filter' => StatusHelper::statusList(),
'value' => function ($model) {
return StatusHelper::statusLabel($model->status);
},
],
'created_at', 'created_at',
//'updated_at',
//'project_user_id',
//'user_id',
//'description',
['class' => 'yii\grid\ActionColumn'], ['class' => 'yii\grid\ActionColumn'],
], ],

View File

@ -5,15 +5,13 @@ use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model backend\modules\task\models\Task */ /* @var $model backend\modules\task\models\Task */
$this->title = 'Update Task: ' . $model->title; $this->title = 'Исполнители задачи: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update'; $this->params['breadcrumbs'][] = 'Update';
?> ?>
<div class="task-update"> <div class="task-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [ <?= $this->render('_form', [
'model' => $model, 'model' => $model,
]) ?> ]) ?>

View File

@ -1,23 +1,24 @@
<?php <?php
use common\helpers\StatusHelper;
use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model backend\modules\task\models\Task */ /* @var $model backend\modules\task\models\Task */
$this->title = $model->title; $this->title = 'Задача: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this); \yii\web\YiiAsset::register($this);
?> ?>
<div class="task-view"> <div class="task-view">
<h1><?= Html::encode($this->title) ?></h1>
<p> <p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> <?= Html::a('Список', ['index', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [ <?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger', 'class' => 'btn btn-danger',
'data' => [ 'data' => [
'confirm' => 'Are you sure you want to delete this item?', 'confirm' => 'Are you sure you want to delete this item?',
@ -30,13 +31,26 @@ $this->params['breadcrumbs'][] = $this->title;
'model' => $model, 'model' => $model,
'attributes' => [ 'attributes' => [
'id', 'id',
'project_id', [
'attribute' => 'project_id',
'value' => ArrayHelper::getValue($model, 'project.name')
],
'title', 'title',
'status', [
'attribute' => 'status',
'format' => 'raw',
'value' => StatusHelper::statusLabel($model->status),
],
'created_at', 'created_at',
'updated_at', 'updated_at',
'project_user_id', [
'user_id', 'attribute' => 'project_user_id',
'value' => ArrayHelper::getValue($model, 'projectUser.user.username'),
],
[
'attribute' => 'user_id',
'value' => ArrayHelper::getValue($model, 'user.username'),
],
'description', 'description',
], ],
]) ?> ]) ?>

View File

@ -8,11 +8,11 @@
$menuItems[] = ['label' => $status, 'icon' => 'id-card', 'url' => ['/card/user-card?UserCardSearch[status]=' . $key]]; $menuItems[] = ['label' => $status, 'icon' => 'id-card', 'url' => ['/card/user-card?UserCardSearch[status]=' . $key]];
} }
$projectStatuses = \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROJECT); $projectStatuses = \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROJECT);
$projectItems = [['label' => 'Все', 'icon' => 'cubes', 'url' => ['/project/project']]]; $projectItems = [['label' => 'Все', 'icon' => 'cubes', 'url' => ['/project/project'], 'active' => \Yii::$app->controller->id == 'project']];
foreach ($projectStatuses as $key => $status) { foreach ($projectStatuses as $key => $status) {
$projectItems[] = ['label' => $status, 'icon' => 'user', 'url' => ['/project/project?ProjectSearch[status]=' . $key]]; $projectItems[] = ['label' => $status, 'icon' => 'user', 'url' => ['/project/project?ProjectSearch[status]=' . $key, 'active' => \Yii::$app->controller->id == 'project']];
} }
$projectItems[] = ['label' => 'Сотрудники на проектах', 'icon' => 'cubes', 'url' => ['/project/project-user']]; $projectItems[] = ['label' => 'Сотрудники на проектах', 'icon' => 'users', 'url' => ['/project/project-user'], 'active' => \Yii::$app->controller->id == 'project-user'];
?> ?>
<?= dmstr\widgets\Menu::widget( <?= dmstr\widgets\Menu::widget(
@ -42,7 +42,7 @@
// TODO visible 'visible' => Yii::$app->user->can('confidential_information') // TODO visible 'visible' => Yii::$app->user->can('confidential_information')
], ],
[ [
'label' => 'Проекты', 'icon' => 'cubes', 'url' => ['#'], 'active' => \Yii::$app->controller->id == 'project', 'label' => 'Проекты', 'icon' => 'cubes', 'url' => ['#'], //'active' => \Yii::$app->controller->id == 'project',
'items' => $projectItems, 'items' => $projectItems,
// TODO visible 'visible' => Yii::$app->user->can('confidential_information') // TODO visible 'visible' => Yii::$app->user->can('confidential_information')
], ],
@ -50,7 +50,7 @@
'label' => 'Задачи', 'icon' => '', 'url' => '#', 'label' => 'Задачи', 'icon' => '', 'url' => '#',
'items' => [ 'items' => [
['label' => 'Задачи', 'icon' => '', 'url' => ['/task/task'], 'active' => \Yii::$app->controller->id == 'task'], ['label' => 'Задачи', 'icon' => '', 'url' => ['/task/task'], 'active' => \Yii::$app->controller->id == 'task'],
['label' => 'Сотруднике на задаче', 'icon' => '', 'url' => ['/task/task-user'], 'active' => \Yii::$app->controller->id == 'task-user'], ['label' => 'Исполнители задачи', 'icon' => '', 'url' => ['/task/task-user'], 'active' => \Yii::$app->controller->id == 'task-user'],
], ],
// TODO visible 'visible' => Yii::$app->user->can('confidential_information') // TODO visible 'visible' => Yii::$app->user->can('confidential_information')
@ -92,7 +92,7 @@
['label' => 'Ответы пользователей', 'icon' => 'comments', 'url' => ['/questionnaire/user-response'], 'active' => \Yii::$app->controller->id == 'user-response'], ['label' => 'Ответы пользователей', 'icon' => 'comments', 'url' => ['/questionnaire/user-response'], 'active' => \Yii::$app->controller->id == 'user-response'],
], ],
'visible' => Yii::$app->user->can('confidential_information') // TODO visible 'visible' => Yii::$app->user->can('confidential_information')
], ],
/*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']], /*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']],

View File

@ -2,7 +2,8 @@
namespace common\models; namespace common\models;
use Yii; use yii\db\ActiveQuery;
use yii\helpers\ArrayHelper;
/** /**
* This is the model class for table "project_user". * This is the model class for table "project_user".
@ -52,7 +53,7 @@ class ProjectUser extends \yii\db\ActiveRecord
} }
/** /**
* @return \yii\db\ActiveQuery * @return ActiveQuery
*/ */
public function getProject() public function getProject()
{ {
@ -60,7 +61,7 @@ class ProjectUser extends \yii\db\ActiveRecord
} }
/** /**
* @return \yii\db\ActiveQuery * @return ActiveQuery
*/ */
public function getUser() public function getUser()
{ {
@ -70,16 +71,44 @@ class ProjectUser extends \yii\db\ActiveRecord
/** /**
* @return \yii\db\ActiveQuery * @return \yii\db\ActiveQuery
*/ */
public function getCard()
{
return $this->hasOne(UserCard::className(), ['id_user' => 'user_id']);
}
/**
* @return ActiveQuery
*/
public function getTasks() public function getTasks()
{ {
return $this->hasMany(Task::className(), ['project_user_id' => 'id']); return $this->hasMany(Task::className(), ['project_user_id' => 'id']);
} }
/** /**
* @return \yii\db\ActiveQuery * @return ActiveQuery
*/
public function getTasksByProject()
{
return $this->hasMany(Task::className(), ['project_id' => 'project_id']);
}
/**
* @return ActiveQuery
*/ */
public function getTaskUsers() public function getTaskUsers()
{ {
return $this->hasMany(TaskUser::className(), ['project_user_id' => 'id']); return $this->hasMany(TaskUser::className(), ['project_user_id' => 'id']);
} }
public static function usersByProjectArr($project_id): array
{
return ArrayHelper::map(
self::find()->joinWith('user')->where(['project_id' => $project_id])->all(), 'id', 'user.username');
}
public static function usersByTaskArr($task_id): array
{
return ArrayHelper::map(
self::find()->joinWith(['tasksByProject', 'user'])->where(['task.id' => $task_id])->all(), 'id', 'user.username');
}
} }

View File

@ -2,7 +2,11 @@
namespace common\models; namespace common\models;
use phpDocumentor\Reflection\Types\This;
use Yii; use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use yii\helpers\ArrayHelper;
/** /**
* This is the model class for table "task". * This is the model class for table "task".
@ -32,13 +36,25 @@ class Task extends \yii\db\ActiveRecord
return 'task'; return 'task';
} }
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
];
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function rules() public function rules()
{ {
return [ return [
[['project_id'], 'required'], [['project_id', 'status', 'title', 'description', 'project_user_id'], 'required'],
[['project_id', 'status', 'project_user_id', 'user_id'], 'integer'], [['project_id', 'status', 'project_user_id', 'user_id'], 'integer'],
[['created_at', 'updated_at'], 'safe'], [['created_at', 'updated_at'], 'safe'],
[['title'], 'string', 'max' => 255], [['title'], 'string', 'max' => 255],
@ -56,17 +72,25 @@ class Task extends \yii\db\ActiveRecord
{ {
return [ return [
'id' => 'ID', 'id' => 'ID',
'project_id' => 'Project ID', 'project_id' => 'Проект',
'title' => 'Title', 'title' => 'Название задачи',
'status' => 'Status', 'status' => 'Статус',
'created_at' => 'Created At', 'created_at' => 'Дата создания',
'updated_at' => 'Updated At', 'updated_at' => 'Дата обновления',
'project_user_id' => 'Project User ID', 'project_user_id' => 'Создатель',
'user_id' => 'User ID', 'user_id' => 'Наблюдатель',
'description' => 'Description', 'description' => 'Описание',
]; ];
} }
public function beforeDelete()
{
foreach ($this->taskUsers as $taskUser){
$taskUser->delete();
}
return parent::beforeDelete();
}
/** /**
* @return \yii\db\ActiveQuery * @return \yii\db\ActiveQuery
*/ */
@ -98,4 +122,10 @@ class Task extends \yii\db\ActiveRecord
{ {
return $this->hasMany(TaskUser::className(), ['task_id' => 'id']); return $this->hasMany(TaskUser::className(), ['task_id' => 'id']);
} }
public static function usersByTaskArr($task_id): array
{
return ArrayHelper::map(
self::find()->joinWith(['user', 'project'])->where(['project_id' => $task_id])->all(), 'id', 'user.username');
}
} }

View File

@ -3,6 +3,7 @@
namespace common\models; namespace common\models;
use Yii; use Yii;
use yii\db\ActiveQuery;
/** /**
* This is the model class for table "task_user". * This is the model class for table "task_user".
@ -43,13 +44,13 @@ class TaskUser extends \yii\db\ActiveRecord
{ {
return [ return [
'id' => 'ID', 'id' => 'ID',
'task_id' => 'Task ID', 'task_id' => 'Задача',
'project_user_id' => 'Project User ID', 'project_user_id' => 'Сотрудник',
]; ];
} }
/** /**
* @return \yii\db\ActiveQuery * @return ActiveQuery
*/ */
public function getProjectUser() public function getProjectUser()
{ {
@ -57,7 +58,7 @@ class TaskUser extends \yii\db\ActiveRecord
} }
/** /**
* @return \yii\db\ActiveQuery * @return ActiveQuery
*/ */
public function getTask() public function getTask()
{ {

File diff suppressed because it is too large Load Diff

View File

@ -1186,3 +1186,6 @@ Stack trace:
2021/11/17 12:16:05 [error] 711#711: *331 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/manager/get-manager?manager_id=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" 2021/11/17 12:16:05 [error] 711#711: *331 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/manager/get-manager?manager_id=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
2021/11/17 12:18:40 [error] 711#711: *334 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/manager/get-manager?manager_id=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" 2021/11/17 12:18:40 [error] 711#711: *334 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/manager/get-manager?manager_id=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
2021/11/17 12:20:52 [error] 711#711: *336 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/manager/get-employees-manager?manager_id=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" 2021/11/17 12:20:52 [error] 711#711: *336 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/manager/get-employees-manager?manager_id=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
2021/11/24 12:06:47 [error] 706#706: *349 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/answer/get-answers?question_id=7 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
2021/11/24 12:07:00 [error] 706#706: *349 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user/login?login=testUser HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
2021/11/24 12:07:17 [error] 706#706: *349 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/answer/get-answers?question_id=7 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"