diff --git a/backend/modules/project/models/ProjectSearch.php b/backend/modules/project/models/ProjectSearch.php index 9d80e61..8fe9ab2 100755 --- a/backend/modules/project/models/ProjectSearch.php +++ b/backend/modules/project/models/ProjectSearch.php @@ -2,6 +2,7 @@ namespace backend\modules\project\models; +use common\classes\Debug; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; diff --git a/backend/modules/project/views/project/_form.php b/backend/modules/project/views/project/_form.php index 149f9c0..4ed2289 100755 --- a/backend/modules/project/views/project/_form.php +++ b/backend/modules/project/views/project/_form.php @@ -30,6 +30,16 @@ use yii\widgets\ActiveForm; ] ); ?> + 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' => 'Выберите' + ] + ) ?> + field($model, 'hh_id')->widget(Select2::class, [ 'data' => \yii\helpers\ArrayHelper::map(\common\models\Hh::find()->all(),'id', 'title'), diff --git a/backend/modules/project/views/project/index.php b/backend/modules/project/views/project/index.php index 3692f5b..6e3d020 100755 --- a/backend/modules/project/views/project/index.php +++ b/backend/modules/project/views/project/index.php @@ -1,6 +1,8 @@ params['breadcrumbs'][] = $this->title; 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', //'updated_at', diff --git a/backend/modules/project/views/project/view.php b/backend/modules/project/views/project/view.php index 64e6ba8..fbaabb4 100755 --- a/backend/modules/project/views/project/view.php +++ b/backend/modules/project/views/project/view.php @@ -35,6 +35,7 @@ $this->params['breadcrumbs'][] = $this->title; 'attribute' => 'hh.url' ], 'description:ntext', + 'status', 'created_at', 'updated_at', ], diff --git a/backend/modules/settings/models/StatusSearch.php b/backend/modules/settings/models/StatusSearch.php index 403a327..ab54df0 100755 --- a/backend/modules/settings/models/StatusSearch.php +++ b/backend/modules/settings/models/StatusSearch.php @@ -2,6 +2,7 @@ namespace backend\modules\settings\models; +use common\classes\Debug; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; diff --git a/backend/modules/settings/views/status/_additional.php b/backend/modules/settings/views/status/_additional.php new file mode 100644 index 0000000..fe811c4 --- /dev/null +++ b/backend/modules/settings/views/status/_additional.php @@ -0,0 +1,3 @@ +use); diff --git a/backend/modules/settings/views/status/index.php b/backend/modules/settings/views/status/index.php index 1628e22..7637a77 100755 --- a/backend/modules/settings/views/status/index.php +++ b/backend/modules/settings/views/status/index.php @@ -1,7 +1,9 @@ params['breadcrumbs'][] = $this->title; 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - 'id', 'name', + [ + 'label' => 'Доп. информация', + 'format' => 'raw', + 'value' => function ($model) { + $dataProvider = new ActiveDataProvider([ + 'query' => $model->getUseStatuses(), + ]); + return ListView::widget([ + 'dataProvider' => $dataProvider, + 'itemView' => '_additional', + 'layout' => "{items}", + ]); + }, + 'headerOptions' => ['width' => '300'], + ], ['class' => 'yii\grid\ActionColumn'], ], ]); ?> diff --git a/common/models/Project.php b/common/models/Project.php index c83910d..1f471de 100755 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -55,6 +55,7 @@ class Project extends \yii\db\ActiveRecord [['name'], 'required'], [['description'], 'string'], [['created_at', 'updated_at'], 'safe'], + [['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']], [['name'], 'string', 'max' => 255], [['budget'], 'string', 'max' => 100], [['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']], @@ -72,6 +73,7 @@ class Project extends \yii\db\ActiveRecord 'name' => 'Название', 'description' => 'Описание', 'created_at' => 'Дата создания', + 'status' => 'Статус', 'updated_at' => 'Дата редактирования', 'budget' => 'Бюджет', 'company_id' => 'Компания', @@ -129,4 +131,9 @@ class Project extends \yii\db\ActiveRecord $model = $this->getProjectUsers()->with('card')->all(); return ArrayHelper::getColumn($model, 'card.fio'); } + + public function getStatus0() + { + return $this->hasOne(Status::class, ['id' => 'status']); + } } diff --git a/common/models/UseStatus.php b/common/models/UseStatus.php index 0e9b151..a7facca 100755 --- a/common/models/UseStatus.php +++ b/common/models/UseStatus.php @@ -76,8 +76,9 @@ class UseStatus extends \yii\db\ActiveRecord /** * @return string status text label */ - public function getStatusesText() + public static function getStatusesText($id) { - return $this->statuses[$this->status_id]; + $model = new self(); + return $model->statuses[$id]; } } diff --git a/console/migrations/m190702_135529_add_status_column_in_project.php b/console/migrations/m190702_135529_add_status_column_in_project.php new file mode 100644 index 0000000..4bbacdc --- /dev/null +++ b/console/migrations/m190702_135529_add_status_column_in_project.php @@ -0,0 +1,25 @@ +addColumn('project', 'status', $this->integer(11)->defaultValue(null)); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropColumn('project', 'status'); + } +}