Merge pull request #6 from apuc/change_status

Change status
This commit is contained in:
kavalar 2019-07-03 10:56:39 +03:00 committed by GitHub
commit e77b7783fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 85 additions and 3 deletions

View File

@ -2,6 +2,7 @@
namespace backend\modules\project\models;
use common\classes\Debug;
use Yii;
use yii\base\Model;
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,
[
'data' => \yii\helpers\ArrayHelper::map(\common\models\Hh::find()->all(),'id', 'title'),

View File

@ -1,6 +1,8 @@
<?php
use common\models\Project;
use common\models\UseStatus;
use kartik\select2\Select2;
use yii\helpers\Html;
use yii\grid\GridView;
@ -46,6 +48,21 @@ $this->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',

View File

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

View File

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

View File

@ -0,0 +1,3 @@
<?php
echo \common\models\UseStatus::getStatusesText($model->use);

View File

@ -1,7 +1,9 @@
<?php
use yii\data\ActiveDataProvider;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\ListView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\status\models\StatusSearch */
@ -24,9 +26,23 @@ $this->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'],
],
]); ?>

View File

@ -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']);
}
}

View File

@ -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];
}
}

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');
}
}