fix crud
This commit is contained in:
parent
c730e2547e
commit
45173d3b66
@ -34,7 +34,8 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
},
|
||||
],
|
||||
'fio',
|
||||
'passport',
|
||||
//'passport',
|
||||
'salary',
|
||||
'email:email',
|
||||
//'gender',
|
||||
//'dob',
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace backend\modules\company\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
@ -18,7 +19,7 @@ class CompanySearch extends Company
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'status_id'], 'integer'],
|
||||
[['id', 'status_id', 'projectId'], 'integer'],
|
||||
[['name', 'description', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
@ -41,7 +42,7 @@ class CompanySearch extends Company
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Company::find();
|
||||
$query = Company::find()->joinWith('project');
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
@ -63,6 +64,7 @@ class CompanySearch extends Company
|
||||
'status_id' => $this->status_id,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'project.id' => $this->projectId
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name])
|
||||
|
@ -26,8 +26,36 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
//'id',
|
||||
'name',
|
||||
'description:ntext',
|
||||
'status_id',
|
||||
[
|
||||
'attribute' => 'project.name',
|
||||
'label' => 'Проект',
|
||||
'filter' => kartik\select2\Select2::widget([
|
||||
'model' => $searchModel,
|
||||
'name' => 'CompanySearch[projectId]',
|
||||
'data' => \common\models\Project::getList(),
|
||||
'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]),
|
||||
],
|
||||
//'description:ntext',
|
||||
//'status_id',
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'value' => function($model){
|
||||
return isset($model->status0->name) ? $model->status0->name : 'Не задано';
|
||||
},
|
||||
'filter' => kartik\select2\Select2::widget([
|
||||
'model' => $searchModel,
|
||||
'attribute' => 'status',
|
||||
'data' => \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_COMPANY),
|
||||
'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]),
|
||||
],
|
||||
//'created_at',
|
||||
//'updated_at',
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use common\models\Project;
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
@ -13,7 +14,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
<div class="project-index">
|
||||
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<?php ?>
|
||||
<p>
|
||||
<?= Html::a('Создать', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
@ -24,11 +25,29 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
'id',
|
||||
'name',
|
||||
//'id',
|
||||
[
|
||||
'attribute' => 'name',
|
||||
'filter' => kartik\select2\Select2::widget([
|
||||
'model' => $searchModel,
|
||||
'attribute' => 'name',
|
||||
'data' => \common\models\Project::getListName(),
|
||||
'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]),
|
||||
],
|
||||
'budget',
|
||||
'description:ntext',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
[
|
||||
'label' => 'Исполнители',
|
||||
'value' => function($model){
|
||||
return implode(', ', $model->getUsersNameList());
|
||||
}
|
||||
],
|
||||
//'created_at',
|
||||
//'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
|
@ -1,5 +1,12 @@
|
||||
<aside class="main-sidebar">
|
||||
<section class="sidebar">
|
||||
<?php
|
||||
$userStatuses = \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROFILE);
|
||||
$menuItems = [['label' => 'Все', 'icon' => 'user', 'url' => ['/card/user-card']]];
|
||||
foreach($userStatuses as $key => $status){
|
||||
$menuItems[] = ['label' => $status, 'icon' => 'user', 'url' => ['/card/user-card?UserCardSearch[status]=' . $key]];
|
||||
}
|
||||
?>
|
||||
|
||||
<?= dmstr\widgets\Menu::widget(
|
||||
[
|
||||
@ -14,8 +21,10 @@
|
||||
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill']],
|
||||
]
|
||||
],
|
||||
|
||||
['label' => 'Профили', 'icon' => 'users', 'url' => ['/card/user-card']],
|
||||
[
|
||||
'label' => 'Профили', 'icon' => 'users', 'url' => '#',
|
||||
'items' => $menuItems,
|
||||
],
|
||||
['label' => 'Пректы', 'icon' => 'files-o', 'url' => ['/project/project']],
|
||||
['label' => 'Компании', 'icon' => 'files-o', 'url' => ['/company/company']],
|
||||
[
|
||||
|
@ -13,6 +13,7 @@ use yii\db\Expression;
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property int $status_id
|
||||
* @property int $projectId
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*
|
||||
@ -21,6 +22,7 @@ use yii\db\Expression;
|
||||
*/
|
||||
class Company extends \yii\db\ActiveRecord
|
||||
{
|
||||
public $projectId;
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -49,7 +51,7 @@ class Company extends \yii\db\ActiveRecord
|
||||
return [
|
||||
[['name'], 'required'],
|
||||
[['description'], 'string'],
|
||||
[['status_id'], 'integer'],
|
||||
[['status_id', 'projectId'], 'integer'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['name'], 'string', 'max' => 255],
|
||||
[['status_id'], 'exist', 'skipOnError' => true, 'targetClass' => Status::className(), 'targetAttribute' => ['status_id' => 'id']],
|
||||
@ -86,4 +88,20 @@ class Company extends \yii\db\ActiveRecord
|
||||
{
|
||||
return $this->hasMany(FieldsValue::className(), ['company_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getStatus0()
|
||||
{
|
||||
return $this->hasOne(Status::class, ['id' => 'status']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getProject()
|
||||
{
|
||||
return $this->hasOne(Project::class, ['company_id' => 'id']);
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
* This is the model class for table "project".
|
||||
@ -108,4 +110,23 @@ class Project extends \yii\db\ActiveRecord
|
||||
{
|
||||
return $this->hasMany(ProjectUser::class, ['project_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getList()
|
||||
{
|
||||
return ArrayHelper::map(self::find()->all(), 'id', 'name');
|
||||
}
|
||||
|
||||
public static function getListName()
|
||||
{
|
||||
return ArrayHelper::map(self::find()->all(), 'name', 'name');
|
||||
}
|
||||
|
||||
public function getUsersNameList()
|
||||
{
|
||||
$model = $this->getProjectUsers()->with('card')->all();
|
||||
return ArrayHelper::getColumn($model, 'card.fio');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user