project column

This commit is contained in:
2023-04-20 02:07:19 +03:00
parent edea2cc3e7
commit 2482ae89f6
24 changed files with 737 additions and 18 deletions

View File

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

View File

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

View File

@ -18,7 +18,7 @@ class ProjectSearch extends Project
public function rules()
{
return [
[['id','status'], 'integer'],
[['id','status', 'owner_id'], 'integer'],
[['name', 'description', 'created_at', 'updated_at'], 'safe'],
];
}
@ -61,6 +61,7 @@ class ProjectSearch extends Project
$query->andFilterWhere([
'id' => $this->id,
'status' => $this->status,
'owner_id' => $this->owner_id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);

View File

@ -0,0 +1,35 @@
<?php
use common\models\Project;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectColumn */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="project-column-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'project_id')->dropDownList(
Project::find()->select(['name', 'id'])->indexBy('id')->column(),
[
'id' => 'project-id',
'placeholder' => 'Выберите',
'prompt' => 'Выберите'
]
) ?>
<?= $form->field($model, 'status')->dropDownList(\common\models\ProjectColumn::getStatus(), ['prompt' => 'Выберите статус']) ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectColumnSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="project-column-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'title') ?>
<?= $form->field($model, 'project_id') ?>
<?= $form->field($model, 'created_at') ?>
<?= $form->field($model, 'updated_at') ?>
<?php // echo $form->field($model, 'status') ?>
<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\ProjectColumn */
$this->title = 'Создать колонку';
$this->params['breadcrumbs'][] = ['label' => 'Колонки проектов', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="project-column-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,47 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\project\models\ProjectColumnSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Колонки проектов';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="project-column-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Создать', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'id',
'title',
[
'attribute' => 'project_id',
'value' => function(\common\models\ProjectColumn $model){
return $model->project->name ?? 'Не задано';
}
],
'created_at',
'updated_at',
[
'attribute' => 'status',
'value' => function (\common\models\ProjectColumn $model) {
return \common\models\ProjectColumn::getStatus()[$model->status] ?? 'Не задано';
}
],
['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\ProjectColumn */
$this->title = 'Редактировать колонку: ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Колонки проектов', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Редактировать';
?>
<div class="project-column-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,49 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\project\models\ProjectColumn */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Колонки проектов', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="project-column-view">
<p>
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'title',
[
'attribute' => 'project_id',
'value' => ArrayHelper::getValue($model, 'project.name' ),
],
'created_at',
'updated_at',
[
'attribute' => 'status',
'value' => function (\common\models\ProjectColumn $model) {
return \common\models\ProjectColumn::getStatus()[$model->status] ?? 'Не задано';
}
],
],
]) ?>
</div>

View File

@ -21,6 +21,17 @@ use mihaildev\elfinder\InputFile;
<?= $form->field($model, 'budget')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'owner_id')->widget(
Select2::class,
[
'data' => \common\models\UserCard::getListUserWithUserId(),
'options' => ['placeholder' => '...', 'class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]
); ?>
<?= $form->field($model, 'company_id')->widget(Select2::class,
[
'data' => \yii\helpers\ArrayHelper::map(\common\models\Company::find()->all(),'id', 'name'),

View File

@ -41,6 +41,21 @@ $this->params['breadcrumbs'][] = $this->title;
]),
],
'budget',
[
'attribute' => 'owner_id',
'value' => function (\common\models\Project $model) {
return $model->owner->userCard->fio ?? 'Не задано';
},
'filter' => kartik\select2\Select2::widget([
'model' => $searchModel,
'attribute' => 'owner_id',
'data' => \common\models\UserCard::getListUserWithUserId(),
'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]),
],
//'description:ntext',
[
'label' => 'Исполнители',

View File

@ -34,6 +34,12 @@ $this->params['breadcrumbs'][] = $this->title;
'label' => 'Сраница на hh.ru',
'attribute' => 'hh.url'
],
[
'attribute' => 'owner_id',
'value' => function (\common\models\Project $model) {
return $model->owner->userCard->fio ?? 'Не задано ФИО';
}
],
'description:ntext',
'status',
'created_at',