add task module
This commit is contained in:
parent
12648f16f8
commit
ae99b9c4df
@ -68,11 +68,14 @@ return [
|
|||||||
'employee' => [
|
'employee' => [
|
||||||
'class' => 'backend\modules\employee\Employee',
|
'class' => 'backend\modules\employee\Employee',
|
||||||
],
|
],
|
||||||
|
'task' => [
|
||||||
|
'class' => 'backend\modules\task\Task',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'components' => [
|
'components' => [
|
||||||
'request' => [
|
'request' => [
|
||||||
'csrfParam' => '_csrf-backend',
|
'csrfParam' => '_csrf-backend',
|
||||||
'baseUrl' => '/secure',
|
'baseUrl' => '', //TODO /secure
|
||||||
'parsers' => [
|
'parsers' => [
|
||||||
'application/json' => 'yii\web\JsonParser',
|
'application/json' => 'yii\web\JsonParser',
|
||||||
'text/xml' => 'yii/web/XmlParser',
|
'text/xml' => 'yii/web/XmlParser',
|
||||||
|
24
backend/modules/task/Task.php
Normal file
24
backend/modules/task/Task.php
Normal 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
|
||||||
|
}
|
||||||
|
}
|
20
backend/modules/task/controllers/DefaultController.php
Normal file
20
backend/modules/task/controllers/DefaultController.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
127
backend/modules/task/controllers/TaskController.php
Normal file
127
backend/modules/task/controllers/TaskController.php
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\task\controllers;
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
return $this->render('view', [
|
||||||
|
'model' => $this->findModel($id),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.');
|
||||||
|
}
|
||||||
|
}
|
127
backend/modules/task/controllers/TaskUserController.php
Normal file
127
backend/modules/task/controllers/TaskUserController.php
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\task\controllers;
|
||||||
|
|
||||||
|
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.');
|
||||||
|
}
|
||||||
|
}
|
8
backend/modules/task/models/Task.php
Normal file
8
backend/modules/task/models/Task.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\task\models;
|
||||||
|
|
||||||
|
class Task extends \common\models\Task
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
75
backend/modules/task/models/TaskSearch.php
Normal file
75
backend/modules/task/models/TaskSearch.php
Normal 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();
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
8
backend/modules/task/models/TaskUser.php
Normal file
8
backend/modules/task/models/TaskUser.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\modules\task\models;
|
||||||
|
|
||||||
|
class TaskUser extends \common\models\TaskUser
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
67
backend/modules/task/models/TaskUserSearch.php
Normal file
67
backend/modules/task/models/TaskUserSearch.php
Normal 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();
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
12
backend/modules/task/views/default/index.php
Normal file
12
backend/modules/task/views/default/index.php
Normal 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>
|
25
backend/modules/task/views/task-user/_form.php
Normal file
25
backend/modules/task/views/task-user/_form.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
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')->textInput() ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'project_user_id')->textInput() ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
31
backend/modules/task/views/task-user/_search.php
Normal file
31
backend/modules/task/views/task-user/_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\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>
|
20
backend/modules/task/views/task-user/create.php
Normal file
20
backend/modules/task/views/task-user/create.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\task\models\TaskUser */
|
||||||
|
|
||||||
|
$this->title = 'Create Task User';
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="task-user-create">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
35
backend/modules/task/views/task-user/index.php
Normal file
35
backend/modules/task/views/task-user/index.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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 = 'Task Users';
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="task-user-index">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a('Create Task User', ['create'], ['class' => 'btn btn-success']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'filterModel' => $searchModel,
|
||||||
|
'columns' => [
|
||||||
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
|
||||||
|
'id',
|
||||||
|
'task_id',
|
||||||
|
'project_user_id',
|
||||||
|
|
||||||
|
['class' => 'yii\grid\ActionColumn'],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
</div>
|
21
backend/modules/task/views/task-user/update.php
Normal file
21
backend/modules/task/views/task-user/update.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\task\models\TaskUser */
|
||||||
|
|
||||||
|
$this->title = 'Update Task User: ' . $model->id;
|
||||||
|
$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">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
38
backend/modules/task/views/task-user/view.php
Normal file
38
backend/modules/task/views/task-user/view.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\task\models\TaskUser */
|
||||||
|
|
||||||
|
$this->title = $model->id;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => 'Task Users', 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
\yii\web\YiiAsset::register($this);
|
||||||
|
?>
|
||||||
|
<div class="task-user-view">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= Html::a('Delete', ['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',
|
||||||
|
'task_id',
|
||||||
|
'project_user_id',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
37
backend/modules/task/views/task/_form.php
Normal file
37
backend/modules/task/views/task/_form.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
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')->textInput() ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'status')->textInput() ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'created_at')->textInput() ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'updated_at')->textInput() ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'project_user_id')->textInput() ?>
|
||||||
|
|
||||||
|
<?= $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>
|
43
backend/modules/task/views/task/_search.php
Normal file
43
backend/modules/task/views/task/_search.php
Normal 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>
|
20
backend/modules/task/views/task/create.php
Normal file
20
backend/modules/task/views/task/create.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\task\models\Task */
|
||||||
|
|
||||||
|
$this->title = 'Create Task';
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="task-create">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
41
backend/modules/task/views/task/index.php
Normal file
41
backend/modules/task/views/task/index.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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 = 'Tasks';
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="task-index">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a('Create Task', ['create'], ['class' => 'btn btn-success']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'filterModel' => $searchModel,
|
||||||
|
'columns' => [
|
||||||
|
['class' => 'yii\grid\SerialColumn'],
|
||||||
|
|
||||||
|
'id',
|
||||||
|
'project_id',
|
||||||
|
'title',
|
||||||
|
'status',
|
||||||
|
'created_at',
|
||||||
|
//'updated_at',
|
||||||
|
//'project_user_id',
|
||||||
|
//'user_id',
|
||||||
|
//'description',
|
||||||
|
|
||||||
|
['class' => 'yii\grid\ActionColumn'],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
</div>
|
21
backend/modules/task/views/task/update.php
Normal file
21
backend/modules/task/views/task/update.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\modules\task\models\Task */
|
||||||
|
|
||||||
|
$this->title = 'Update Task: ' . $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">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
44
backend/modules/task/views/task/view.php
Normal file
44
backend/modules/task/views/task/view.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
|
/* @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'][] = $this->title;
|
||||||
|
\yii\web\YiiAsset::register($this);
|
||||||
|
?>
|
||||||
|
<div class="task-view">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= Html::a('Delete', ['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',
|
||||||
|
'project_id',
|
||||||
|
'title',
|
||||||
|
'status',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'project_user_id',
|
||||||
|
'user_id',
|
||||||
|
'description',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
@ -26,7 +26,7 @@
|
|||||||
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position'], 'active' => \Yii::$app->controller->id == 'position'],
|
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position'], 'active' => \Yii::$app->controller->id == 'position'],
|
||||||
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill'], 'active' => \Yii::$app->controller->id == 'skill'],
|
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill'], 'active' => \Yii::$app->controller->id == 'skill'],
|
||||||
],
|
],
|
||||||
'visible' => Yii::$app->user->can('confidential_information')
|
// TODO visible 'visible' => Yii::$app->user->can('confidential_information')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => 'Профили', 'icon' => 'address-book-o', 'url' => '#', 'active' => \Yii::$app->controller->id == 'user-card',
|
'label' => 'Профили', 'icon' => 'address-book-o', 'url' => '#', 'active' => \Yii::$app->controller->id == 'user-card',
|
||||||
@ -38,12 +38,21 @@
|
|||||||
['label' => 'Менеджеры', 'icon' => 'user-circle-o', 'url' => ['/employee/manager'], 'active' => \Yii::$app->controller->id == 'manager'],
|
['label' => 'Менеджеры', 'icon' => 'user-circle-o', 'url' => ['/employee/manager'], 'active' => \Yii::$app->controller->id == 'manager'],
|
||||||
['label' => 'Работники', 'icon' => 'user', 'url' => ['/employee/manager-employee'], 'active' => \Yii::$app->controller->id == 'manager-employee'],
|
['label' => 'Работники', 'icon' => 'user', 'url' => ['/employee/manager-employee'], 'active' => \Yii::$app->controller->id == 'manager-employee'],
|
||||||
],
|
],
|
||||||
'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,
|
||||||
'visible' => Yii::$app->user->can('confidential_information')
|
// TODO visible 'visible' => Yii::$app->user->can('confidential_information')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => 'Задачи', 'icon' => '', 'url' => '#',
|
||||||
|
'items' => [
|
||||||
|
['label' => 'Задачи', 'icon' => '', 'url' => ['/task/task'], 'active' => \Yii::$app->controller->id == 'task'],
|
||||||
|
['label' => 'Сотруднике на задаче', 'icon' => '', 'url' => ['/task/task-user'], 'active' => \Yii::$app->controller->id == 'task-user'],
|
||||||
|
],
|
||||||
|
|
||||||
|
// TODO visible 'visible' => Yii::$app->user->can('confidential_information')
|
||||||
],
|
],
|
||||||
['label' => 'Компании', 'icon' => 'building', 'url' => ['/company/company'], 'active' => \Yii::$app->controller->id == 'company', 'visible' => Yii::$app->user->can('confidential_information')],
|
['label' => 'Компании', 'icon' => 'building', 'url' => ['/company/company'], 'active' => \Yii::$app->controller->id == 'company', 'visible' => Yii::$app->user->can('confidential_information')],
|
||||||
[
|
[
|
||||||
@ -52,7 +61,7 @@
|
|||||||
['label' => 'Компании', 'icon' => 'building', 'url' => ['/hh/hh'], 'active' => \Yii::$app->controller->id == 'hh'],
|
['label' => 'Компании', 'icon' => 'building', 'url' => ['/hh/hh'], 'active' => \Yii::$app->controller->id == 'hh'],
|
||||||
['label' => 'Вакансии', 'icon' => 'user-md', 'url' => ['/hh/hh-job'], 'active' => \Yii::$app->controller->id == 'hh-job'],
|
['label' => 'Вакансии', 'icon' => 'user-md', 'url' => ['/hh/hh-job'], 'active' => \Yii::$app->controller->id == 'hh-job'],
|
||||||
],
|
],
|
||||||
'visible' => Yii::$app->user->can('confidential_information')
|
// TODO visible 'visible' => Yii::$app->user->can('confidential_information')
|
||||||
],
|
],
|
||||||
['label' => 'Баланс', 'icon' => 'dollar', 'url' => ['/balance/balance'], 'active' => \Yii::$app->controller->id == 'balance', 'visible' => Yii::$app->user->can('confidential_information')],
|
['label' => 'Баланс', 'icon' => 'dollar', 'url' => ['/balance/balance'], 'active' => \Yii::$app->controller->id == 'balance', 'visible' => Yii::$app->user->can('confidential_information')],
|
||||||
['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday', 'visible' => Yii::$app->user->can('confidential_information')],
|
['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday', 'visible' => Yii::$app->user->can('confidential_information')],
|
||||||
|
101
common/models/Task.php
Normal file
101
common/models/Task.php
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "task".
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property int $project_id
|
||||||
|
* @property string $title
|
||||||
|
* @property int $status
|
||||||
|
* @property string $created_at
|
||||||
|
* @property string $updated_at
|
||||||
|
* @property int $project_user_id
|
||||||
|
* @property int $user_id
|
||||||
|
* @property string $description
|
||||||
|
*
|
||||||
|
* @property Project $project
|
||||||
|
* @property ProjectUser $projectUser
|
||||||
|
* @property User $user
|
||||||
|
* @property TaskUser[] $taskUsers
|
||||||
|
*/
|
||||||
|
class Task extends \yii\db\ActiveRecord
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function tableName()
|
||||||
|
{
|
||||||
|
return 'task';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['project_id'], 'required'],
|
||||||
|
[['project_id', 'status', 'project_user_id', 'user_id'], 'integer'],
|
||||||
|
[['created_at', 'updated_at'], 'safe'],
|
||||||
|
[['title'], 'string', 'max' => 255],
|
||||||
|
[['description'], 'string', 'max' => 500],
|
||||||
|
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||||
|
[['project_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectUser::className(), 'targetAttribute' => ['project_user_id' => 'id']],
|
||||||
|
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => 'ID',
|
||||||
|
'project_id' => 'Project ID',
|
||||||
|
'title' => 'Title',
|
||||||
|
'status' => 'Status',
|
||||||
|
'created_at' => 'Created At',
|
||||||
|
'updated_at' => 'Updated At',
|
||||||
|
'project_user_id' => 'Project User ID',
|
||||||
|
'user_id' => 'User ID',
|
||||||
|
'description' => 'Description',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getProject()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Project::className(), ['id' => 'project_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getProjectUser()
|
||||||
|
{
|
||||||
|
return $this->hasOne(ProjectUser::className(), ['id' => 'project_user_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getUser()
|
||||||
|
{
|
||||||
|
return $this->hasOne(User::className(), ['id' => 'user_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getTaskUsers()
|
||||||
|
{
|
||||||
|
return $this->hasMany(TaskUser::className(), ['task_id' => 'id']);
|
||||||
|
}
|
||||||
|
}
|
66
common/models/TaskUser.php
Normal file
66
common/models/TaskUser.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "task_user".
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property int $task_id
|
||||||
|
* @property int $project_user_id
|
||||||
|
*
|
||||||
|
* @property ProjectUser $projectUser
|
||||||
|
* @property Task $task
|
||||||
|
*/
|
||||||
|
class TaskUser extends \yii\db\ActiveRecord
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function tableName()
|
||||||
|
{
|
||||||
|
return 'task_user';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['task_id', 'project_user_id'], 'integer'],
|
||||||
|
[['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']],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => 'ID',
|
||||||
|
'task_id' => 'Task ID',
|
||||||
|
'project_user_id' => 'Project User ID',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getProjectUser()
|
||||||
|
{
|
||||||
|
return $this->hasOne(ProjectUser::className(), ['id' => 'project_user_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \yii\db\ActiveQuery
|
||||||
|
*/
|
||||||
|
public function getTask()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Task::className(), ['id' => 'task_id']);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class m211123_082634_change_foreign_key_in_project_user_from_user_card_table_to_user_table
|
||||||
|
*/
|
||||||
|
class m211123_082634_change_foreign_key_in_project_user_from_user_card_table_to_user_table extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->dropForeignKey('project_user_ibfk_user_card', 'project_user');
|
||||||
|
$this->dropColumn('project_user', 'card_id');
|
||||||
|
$this->addColumn('project_user', 'user_id', $this->integer(11)->notNull());
|
||||||
|
$this->addForeignKey('user_project_user', 'project_user', 'user_id', 'user', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropForeignKey('user_project_user', 'project_user');
|
||||||
|
$this->dropColumn('project_user', 'user_id');
|
||||||
|
$this->addColumn('project_user', 'card_id', $this->integer(11)->notNull());
|
||||||
|
$this->addForeignKey(
|
||||||
|
'project_user_ibfk_user_card',
|
||||||
|
'project_user',
|
||||||
|
'card_id',
|
||||||
|
'user_card',
|
||||||
|
'id',
|
||||||
|
'RESTRICT',
|
||||||
|
'CASCADE'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use up()/down() to run migration code without a transaction.
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m211123_082634_change_foreign_key_in_project_user_from_user_card_table_to_user_table cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
43
console/migrations/m211123_083938_create_task_table.php
Normal file
43
console/migrations/m211123_083938_create_task_table.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the creation of table `{{%task}}`.
|
||||||
|
*/
|
||||||
|
class m211123_083938_create_task_table extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->createTable('{{%task}}', [
|
||||||
|
'id' => $this->primaryKey(),
|
||||||
|
'project_id' => $this->integer(11)->notNull(),
|
||||||
|
'title' => $this->string(),
|
||||||
|
'status' => $this->integer(),
|
||||||
|
'created_at' => $this->dateTime(),
|
||||||
|
'updated_at' => $this->dateTime(),
|
||||||
|
'project_user_id' => $this->integer(),
|
||||||
|
'user_id' => $this->integer(),
|
||||||
|
'description' => $this->string(500),
|
||||||
|
]);
|
||||||
|
$this->addForeignKey('task_project', 'task',
|
||||||
|
'project_id', 'project', 'id');
|
||||||
|
$this->addForeignKey('task_project_user', 'task',
|
||||||
|
'project_user_id', 'project_user', 'id');
|
||||||
|
$this->addForeignKey('task_user', 'task', 'user_id', 'user', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropForeignKey('task_project', 'task');
|
||||||
|
$this->dropForeignKey('task_project_user', 'task');
|
||||||
|
$this->dropForeignKey('task_user', 'task');
|
||||||
|
$this->dropTable('{{%task}}');
|
||||||
|
}
|
||||||
|
}
|
35
console/migrations/m211123_085751_create_task_user_table.php
Normal file
35
console/migrations/m211123_085751_create_task_user_table.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the creation of table `{{%task_user}}`.
|
||||||
|
*/
|
||||||
|
class m211123_085751_create_task_user_table extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$this->createTable('{{%task_user}}', [
|
||||||
|
'id' => $this->primaryKey(),
|
||||||
|
'task_id' => $this->integer(),
|
||||||
|
'project_user_id' => $this->integer(),
|
||||||
|
]);
|
||||||
|
$this->addForeignKey('task_task_user', 'task_user',
|
||||||
|
'task_id', 'task', 'id');
|
||||||
|
$this->addForeignKey('project_user_task_user', 'task_user',
|
||||||
|
'project_user_id', 'project_user', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
$this->dropForeignKey('task_task_user', 'task_user');
|
||||||
|
$this->dropForeignKey('project_user_task_user', 'task_user');
|
||||||
|
$this->dropTable('{{%task_user}}');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user