add_status_to_project_index

This commit is contained in:
SoHardKI 2019-07-02 17:35:39 +03:00
parent 45dcde26ae
commit 9affc6b402
7 changed files with 62 additions and 1 deletions

View File

@ -2,6 +2,7 @@
namespace backend\modules\project\models; namespace backend\modules\project\models;
use common\classes\Debug;
use Yii; use Yii;
use yii\base\Model; use yii\base\Model;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;

View File

@ -30,6 +30,16 @@ use yii\widgets\ActiveForm;
] ]
); ?> ); ?>
<?= $form->field($model, 'status')
->dropDownList(\yii\helpers\ArrayHelper::map(
\common\models\Status::find()
->joinWith('useStatuses')
->where(['`use_status`.`use`' => \common\models\UseStatus::USE_PROJECT])->all(), 'id', 'name'),
[
'prompt' => 'Выберите'
]
) ?>
<?= $form->field($model, 'hh_id')->widget(Select2::class, <?= $form->field($model, 'hh_id')->widget(Select2::class,
[ [
'data' => \yii\helpers\ArrayHelper::map(\common\models\Hh::find()->all(),'id', 'title'), 'data' => \yii\helpers\ArrayHelper::map(\common\models\Hh::find()->all(),'id', 'title'),

View File

@ -1,6 +1,8 @@
<?php <?php
use common\models\Project; use common\models\Project;
use common\models\UseStatus;
use kartik\select2\Select2;
use yii\helpers\Html; use yii\helpers\Html;
use yii\grid\GridView; use yii\grid\GridView;
@ -46,6 +48,21 @@ $this->params['breadcrumbs'][] = $this->title;
return implode(', ', $model->getUsersNameList()); return implode(', ', $model->getUsersNameList());
} }
], ],
[
'attribute' => 'status',
'value' => function($model){
return $model->status0['name'];
},
'filter' => kartik\select2\Select2::widget([
'model' => $searchModel,
'attribute' => 'status',
'data' => \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROJECT),
'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'],
'pluginOptions' => [
'allowClear' => true
],
]),
],
//'created_at', //'created_at',
//'updated_at', //'updated_at',

View File

@ -35,6 +35,7 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'hh.url' 'attribute' => 'hh.url'
], ],
'description:ntext', 'description:ntext',
'status',
'created_at', 'created_at',
'updated_at', 'updated_at',
], ],

View File

@ -64,7 +64,7 @@ class StatusSearch extends Status
]); ]);
$query->andFilterWhere(['like', 'name', $this->name]); $query->andFilterWhere(['like', 'name', $this->name]);
// Debug::dd($query->all());
return $dataProvider; return $dataProvider;
} }
} }

View File

@ -55,6 +55,7 @@ class Project extends \yii\db\ActiveRecord
[['name'], 'required'], [['name'], 'required'],
[['description'], 'string'], [['description'], 'string'],
[['created_at', 'updated_at'], 'safe'], [['created_at', 'updated_at'], 'safe'],
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
[['name'], 'string', 'max' => 255], [['name'], 'string', 'max' => 255],
[['budget'], 'string', 'max' => 100], [['budget'], 'string', 'max' => 100],
[['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']], [['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']],
@ -72,6 +73,7 @@ class Project extends \yii\db\ActiveRecord
'name' => 'Название', 'name' => 'Название',
'description' => 'Описание', 'description' => 'Описание',
'created_at' => 'Дата создания', 'created_at' => 'Дата создания',
'status' => 'Статус',
'updated_at' => 'Дата редактирования', 'updated_at' => 'Дата редактирования',
'budget' => 'Бюджет', 'budget' => 'Бюджет',
'company_id' => 'Компания', 'company_id' => 'Компания',
@ -129,4 +131,9 @@ class Project extends \yii\db\ActiveRecord
$model = $this->getProjectUsers()->with('card')->all(); $model = $this->getProjectUsers()->with('card')->all();
return ArrayHelper::getColumn($model, 'card.fio'); return ArrayHelper::getColumn($model, 'card.fio');
} }
public function getStatus0()
{
return $this->hasOne(Status::class, ['id' => 'status']);
}
} }

View File

@ -0,0 +1,25 @@
<?php
use yii\db\Migration;
/**
* Class m190702_135529_add_status_column_in_project
*/
class m190702_135529_add_status_column_in_project extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('project', 'status', $this->integer(11)->defaultValue(null));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('project', 'status');
}
}