Merge pull request #70 from apuc/add_task

Add task
This commit is contained in:
2021-11-25 13:02:08 +03:00
committed by GitHub
76 changed files with 10938 additions and 48 deletions

View File

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

View File

@ -0,0 +1,20 @@
<?php
namespace backend\modules\employee\controllers;
use yii\web\Controller;
/**
* Default controller for the `employee` module
*/
class DefaultController extends Controller
{
/**
* Renders the index view for the module
* @return string
*/
public function actionIndex()
{
return $this->render('index');
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,67 @@
<?php
namespace backend\modules\employee\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\employee\models\ManagerEmployee;
/**
* ManagerEmployeeSearch represents the model behind the search form of `backend\modules\employee\models\ManagerEmployee`.
*/
class ManagerEmployeeSearch extends ManagerEmployee
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'manager_id', 'employee_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 = ManagerEmployee::find()->joinWith(['user', 'manager']);
// 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,
'manager_id' => $this->manager_id,
'employee_id' => $this->employee_id,
]);
return $dataProvider;
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace backend\modules\employee\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\employee\models\Manager;
/**
* ManagerSearch represents the model behind the search form of `backend\modules\employee\models\Manager`.
*/
class ManagerSearch extends Manager
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'user_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 = Manager::find()->with('user');
// 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,
'user_id' => $this->user_id,
]);
return $dataProvider;
}
}

View File

@ -0,0 +1,12 @@
<div class="employee-default-index">
<h1><?= $this->context->action->uniqueId ?></h1>
<p>
This is the view content for action "<?= $this->context->action->id ?>".
The action belongs to the controller "<?= get_class($this->context) ?>"
in the "<?= $this->context->module->id ?>" module.
</p>
<p>
You may customize this page by editing the following file:<br>
<code><?= __FILE__ ?></code>
</p>
</div>

View File

@ -0,0 +1,44 @@
<?php
use backend\modules\employee\models\Manager;
use common\models\User;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\employee\models\ManagerEmployee */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="manager-employee-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'manager_id')->widget(Select2::className(),
[
'data' => Manager::find()->select(['username', 'manager.id'])
->joinWith('user')->indexBy('manager.id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]) ?>
<?= $form->field($model, 'employee_id')->widget(Select2::className(),
[
'data' => User::find()->select(['username', 'user.id'])
->joinWith('manager')->where(['manager.user_id' => null])->indexBy('user.id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]) ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

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

View File

@ -0,0 +1,18 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\employee\models\ManagerEmployee */
$this->title = 'Назначить работника';
$this->params['breadcrumbs'][] = ['label' => 'Manager Employees', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="manager-employee-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,40 @@
<?php
use common\models\User;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\employee\models\ManagerEmployeeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Сотрудники';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="manager-employee-index">
<p>
<?= Html::a('Назначить менеджеру работника', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'manager_id',
'filter' => User::find()->select(['username', 'user.id'])
->joinWith('manager')->where(['not',['manager.user_id' => null]])->indexBy('user.id')->column(),
'value' => 'manager.user.username',
],
[
'attribute' => 'employee_id',
'filter' => User::find()->select(['username', 'user.id'])
->joinWith('manager')->where(['manager.user_id' => null])->indexBy('user.id')->column(),
'value' => 'user.username',
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\employee\models\ManagerEmployee */
$this->title = 'Изменить сотрудника у менеджера:';
$this->params['breadcrumbs'][] = ['label' => 'Manager Employees', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="manager-employee-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,48 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\web\YiiAsset;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\employee\models\ManagerEmployee */
$manager = ArrayHelper::getValue($model,'manager.user.username');
$employee = ArrayHelper::getValue($model,'user.username');
$this->title = 'Менеджер: ' . $manager . ', ' . 'сотрудник: ' . $employee;
$this->params['breadcrumbs'][] = ['label' => 'Manager Employees', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
YiiAsset::register($this);
?>
<div class="manager-employee-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' => 'manager_id',
'value' => ArrayHelper::getValue($model,'manager.user.username'),
],
[
'attribute' => 'employee_id',
'value' => ArrayHelper::getValue($model,'user.username'),
],
],
]) ?>
</div>

View File

@ -0,0 +1,33 @@
<?php
use common\models\User;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;
/* @var $this yii\web\View */
/* @var $model backend\modules\employee\models\Manager */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="manager-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'user_id')->widget(Select2::className(),
[
'data' => User::find()->select(['username', 'user.id'])
->joinWith('manager')->where(['manager.user_id' => null])->indexBy('user.id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

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

View File

@ -0,0 +1,16 @@
<?php
/* @var $this yii\web\View */
/* @var $model backend\modules\employee\models\Manager */
$this->title = 'Назначить менеджера';
$this->params['breadcrumbs'][] = ['label' => 'Managers', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="manager-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,35 @@
<?php
use common\models\User;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\employee\models\ManagerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Менеджеры';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="manager-index">
<p>
<?= Html::a('Назначить менеджера', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'user_id',
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
'value' => 'user.username',
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,20 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\employee\models\Manager */
$this->title = 'Изменить менеджера: ' . ArrayHelper::getValue($model,'user.username');
$this->params['breadcrumbs'][] = ['label' => 'Managers', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="manager-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,81 @@
<?php
use common\models\User;
use kartik\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\web\YiiAsset;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\employee\models\Manager */
/* @var $managerEmployeeSearchModel backend\modules\employee\models\ManagerEmployeeSearch */
/* @var $managerEmployeeDataProvider yii\data\ActiveDataProvider */
$this->title = 'Менеджер: ' . ArrayHelper::getValue($model,'user.username');
$this->params['breadcrumbs'][] = ['label' => 'Managers', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
YiiAsset::register($this);
?>
<div class="manager-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' => 'Вы уверены, что хотите удалить менеджера?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
[
'attribute' => 'user_id',
'value' => ArrayHelper::getValue($model,'user.username'),
],
],
]) ?>
<?= GridView::widget([
'dataProvider' => $managerEmployeeDataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'user_id',
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
'value' => 'user.username',
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {delete}',
'controller' => 'manager-employee',
'buttons' => [
'update' => function ($url,$model) {
return Html::a(
'<span class="glyphicon glyphicon-pencil"></span>',
['manager-employee/update', 'id' => $model['id'], 'manager_id' => $model['manager_id']]);
},
'delete' => function ($url,$model) {
return Html::a(
'<span class="glyphicon glyphicon-trash"></span>',
[
'manager-employee/delete', 'id' => $model['id'], 'manager_id' => $model['manager_id']
],
[
'data' => ['confirm' => 'Вы уверены, что хотите удалить этого сотрудника?', 'method' => 'post']
]
);
},
],
],
],
]); ?>
</div>

View File

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

View File

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

View File

@ -0,0 +1,67 @@
<?php
namespace backend\modules\project\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\project\models\ProjectUser;
/**
* ProjectUserSearch represents the model behind the search form of `backend\modules\project\models\ProjectUser`.
*/
class ProjectUserSearch extends ProjectUser
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'project_id', 'user_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 = ProjectUser::find()->joinWith(['project', 'user']);
// 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,
'user_id' => $this->user_id,
]);
return $dataProvider;
}
}

View File

@ -0,0 +1,44 @@
<?php
use backend\modules\project\models\Project;
use common\models\User;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectUser */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="project-user-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'project_id')->widget(Select2::className(),
[
'data' => Project::find()->select(['name', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
) ?>
<?= $form->field($model, 'user_id')->widget(Select2::className(),
[
'data' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => '...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

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

View File

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

View File

@ -0,0 +1,41 @@
<?php
use backend\modules\project\models\Project;
use common\models\User;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\project\models\ProjectUserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Сотрудники на проектах';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="project-user-index">
<p>
<?= Html::a('Назначить сотрудника на проект', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'project_id',
'filter' => Project::find()->select(['name', 'id'])->indexBy('id')->column(),
'value' => 'project.name'
],
[
'attribute' => 'user_id',
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
'value' => 'user.username'
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,19 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectUser */
$this->title = 'Изменить сотрудника на проекте';
$this->params['breadcrumbs'][] = ['label' => 'Project Users', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="project-user-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,44 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectUser */
$this->title = 'Сотрудник проекта: ' . $model->project->name;
$this->params['breadcrumbs'][] = ['label' => 'Project Users', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="project-user-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' => 'user_id',
'value' => ArrayHelper::getValue($model, 'user.username' ),
],
],
]) ?>
</div>

View File

@ -6,7 +6,7 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\AnswerSearch */
/* @var $modelSearch backend\modules\questionnaire\models\AnswerSearch */
/* @var $form yii\widgets\ActiveForm */
?>
@ -17,7 +17,7 @@ use yii\widgets\ActiveForm;
'method' => 'get',
]); ?>
<?= $form->field($model, 'questionnaire')->widget(Select2::className(),[
<?= $form->field($modelSearch, 'questionnaire')->widget(Select2::className(),[
'data' => Questionnaire::find()->select(['title', 'id'])->indexBy('id')->column(),
'options' => ['placeholder' => 'Выберите анкету'],
'pluginOptions' => [

View File

@ -21,7 +21,7 @@ $this->params['breadcrumbs'][] = $this->title;
</p>
<?= $this->render('_search_by_questionnaire', [
'model' => $searchModel,
'modelSearch' => $searchModel,
]) ?>
<?= GridView::widget([

View File

@ -32,7 +32,7 @@ $this->params['breadcrumbs'][] = $this->title;
],
[
'attribute' => 'user_id',
'filter' => ArrayHelper::map(User::find()->all(), 'id', 'username'),
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
'value' => 'user.username'
],
'score',

View File

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

View File

@ -1,7 +1,6 @@
<?php
use backend\modules\questionnaire\models\Questionnaire;
use backend\modules\questionnaire\models\UserQuestionnaire;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

View File

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

View File

@ -0,0 +1,20 @@
<?php
namespace backend\modules\task\controllers;
use yii\web\Controller;
/**
* Default controller for the `task` module
*/
class DefaultController extends Controller
{
/**
* Renders the index view for the module
* @return string
*/
public function actionIndex()
{
return $this->render('index');
}
}

View File

@ -0,0 +1,161 @@
<?php
namespace backend\modules\task\controllers;
use backend\modules\project\models\ProjectUser;
use backend\modules\task\models\TaskUser;
use yii\data\ActiveDataProvider;
use yii\web\Response;
use Yii;
use backend\modules\task\models\Task;
use backend\modules\task\models\TaskSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* TaskController implements the CRUD actions for Task model.
*/
class TaskController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Task models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new TaskSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Task model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
$model = $this->findModel($id);
$taskDataProvider = new ActiveDataProvider([
'query' => $model->getTaskUsers()->with(['task', 'projectUser']),
'pagination' => [
'pageSize' => 20,
],
]);
return $this->render('view', [
'model' => $model,
'taskDataProvider' => $taskDataProvider,
]);
}
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Task();
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 Task 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 Task 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 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
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Task::findOne($id)) !== null) {
return $model;
}
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

@ -0,0 +1,150 @@
<?php
namespace backend\modules\task\controllers;
use backend\modules\project\models\ProjectUser;
use yii\web\Response;
use Yii;
use backend\modules\task\models\TaskUser;
use backend\modules\task\models\TaskUserSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* TaskUserController implements the CRUD actions for TaskUser model.
*/
class TaskUserController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all TaskUser models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new TaskUserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single TaskUser 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 TaskUser model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new TaskUser();
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 TaskUser 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 TaskUser 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 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
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = TaskUser::findOne($id)) !== null) {
return $model;
}
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

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

View File

@ -0,0 +1,75 @@
<?php
namespace backend\modules\task\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\task\models\Task;
/**
* TaskSearch represents the model behind the search form of `backend\modules\task\models\Task`.
*/
class TaskSearch extends Task
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'project_id', 'status', 'project_user_id', 'user_id'], 'integer'],
[['title', 'created_at', 'updated_at', 'description'], '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 = Task::find()->joinWith(['user', 'project', 'projectUser.user']);
// 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,
'status' => $this->status,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'project_user_id' => $this->project_user_id,
'user_id' => $this->user_id,
]);
$query->andFilterWhere(['like', 'title', $this->title])
->andFilterWhere(['like', 'description', $this->description]);
return $dataProvider;
}
}

View File

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

View File

@ -0,0 +1,67 @@
<?php
namespace backend\modules\task\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\task\models\TaskUser;
/**
* TaskUserSearch represents the model behind the search form of `backend\modules\task\models\TaskUser`.
*/
class TaskUserSearch extends TaskUser
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'task_id', 'project_user_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 = TaskUser::find()->joinWith(['task', 'projectUser']);
// 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,
'task_id' => $this->task_id,
'project_user_id' => $this->project_user_id,
]);
return $dataProvider;
}
}

View File

@ -0,0 +1,12 @@
<div class="task-default-index">
<h1><?= $this->context->action->uniqueId ?></h1>
<p>
This is the view content for action "<?= $this->context->action->id ?>".
The action belongs to the controller "<?= get_class($this->context) ?>"
in the "<?= $this->context->module->id ?>" module.
</p>
<p>
You may customize this page by editing the following file:<br>
<code><?= __FILE__ ?></code>
</p>
</div>

View File

@ -0,0 +1,44 @@
<?php
use backend\modules\task\models\Task;
use kartik\depdrop\DepDrop;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="task-user-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'task_id')->dropDownList(Task::find()
->select(['title', 'id'])->indexBy('id')->column(),
[
'id' => 'task-id',
'prompt' => 'Выберите'
]
);
?>
<?= $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">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

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

View File

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

View File

@ -0,0 +1,43 @@
<?php
use backend\modules\project\models\ProjectUser;
use backend\modules\task\models\Task;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\task\models\TaskUserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Исполнители задачи';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="task-user-index">
<p>
<?= Html::a('Назначить сотрудника', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'task_id',
'filter' => Task::find()->select(['title', 'id'])->indexBy('id')->column(),
'value' => 'task.title'
],
[
'attribute' => 'project_user_id',
'filter' => ProjectUser::find()->select(['user.username', 'project_user.id'])
->joinWith('user')->indexBy('project_user.id')->column(),
'value' => 'projectUser.user.username'
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

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

View File

@ -0,0 +1,44 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskUser */
$this->title = 'Изменить назначение сотрудника';
$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="task-user-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' => 'task_id',
'value' => ArrayHelper::getValue($model, 'task.title'),
],
[
'attribute' => 'project_user_id',
'value' => ArrayHelper::getValue($model, 'projectUser.user.username'),
],
],
]) ?>
</div>

View File

@ -0,0 +1,60 @@
<?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\Url;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\Task */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="task-form">
<?php $form = ActiveForm::begin(); ?>
<?= $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, 'status')->dropDownList(
StatusHelper::statusList(),
[
'prompt' => 'Выберите'
]
) ?>
<?= $form->field($model, 'user_id')->textInput() ?>
<?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,43 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\TaskSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="task-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'project_id') ?>
<?= $form->field($model, 'title') ?>
<?= $form->field($model, 'status') ?>
<?= $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<?php // echo $form->field($model, 'project_user_id') ?>
<?php // echo $form->field($model, 'user_id') ?>
<?php // echo $form->field($model, 'description') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

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

View File

@ -0,0 +1,61 @@
<?php
use backend\modules\project\models\Project;
use backend\modules\project\models\ProjectUser;
use common\helpers\StatusHelper;
use common\models\User;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\task\models\TaskSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Задачи';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="task-index">
<p>
<?= Html::a('Создать задачу', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'project_id',
'filter' => ArrayHelper::map(Project::find()->all(), 'id', 'name'),
'value' => 'project.name'
],
'title',
[
'attribute' => 'project_user_id',
'filter' => ProjectUser::find()->select(['username', 'project_user.id'])->joinWith('user')->indexBy('id')->column(),
'value' => 'projectUser.user.username'
],
[
'attribute' => 'user_id',
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
'value' => 'user.username'
],
'description',
[
'attribute' => 'status',
'format' => 'raw',
'filter' => StatusHelper::statusList(),
'value' => function ($model) {
return StatusHelper::statusLabel($model->status);
},
],
'created_at',
'updated_at',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

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

View File

@ -0,0 +1,85 @@
<?php
use common\helpers\StatusHelper;
use kartik\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\web\YiiAsset;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\task\models\Task */
/* @var $taskDataProvider yii\data\ActiveDataProvider */
$this->title = 'Задача: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
YiiAsset::register($this);
?>
<div class="task-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')
],
'title',
[
'attribute' => 'status',
'format' => 'raw',
'value' => StatusHelper::statusLabel($model->status),
],
'created_at',
'updated_at',
[
'attribute' => 'project_user_id',
'value' => ArrayHelper::getValue($model, 'projectUser.user.username'),
],
[
'attribute' => 'user_id',
'value' => ArrayHelper::getValue($model, 'user.username'),
],
'description',
],
]) ?>
<div>
<h2>
<?= 'Исполнители' ?>
</h2>
</div>
<?= GridView::widget([
'dataProvider' => $taskDataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'task_id', // ArrayHelper::map(Task::find()->all(), 'id', 'title'),
'value' => 'task.title'
],
[
'attribute' => 'project_user_id',
'value' => 'projectUser.user.username'
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>