public function rules()
{
return [
- [['id', 'type_id'], 'integer'],
- [['name', 'model', 'os', 'mac', 'serial', 'product', 'modelnumber', 'invent', 'date', 'comment', 'statusName', 'typeName', 'locationName', 'regionName'], 'safe'],
+ [['id', 'model_id'], 'integer'],
+ [['name', 'modelName', 'os', 'mac', 'serial', 'invent', 'date', 'comment', 'statusName', 'typeName', 'locationName', 'regionName'], 'safe'],
];
}
$query = Items::find()
->select(Items::tableName() . '.*, ' .
Locations::tableName() . '.name AS locationName, ' .
+ Models::tableName() . '.name AS modelName, ' .
Types::tableName() . '.name AS typeName, ' .
Regions::tableName() . '.name AS regionName, ' .
Status::tableName() . '.name AS statusName ')
- ->joinWith([ 'types', 'moving', 'status', 'locations', 'regions' ])
+ ->joinWith([ 'types', 'moving', 'status', 'locations', 'regions', 'models', ])
->where([ 'in', Moving::tableName() . '.id', $query ])
- ->andWhere([ 'checked' => false ]);
+ ->andWhere([ 'checked' => 0 ]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'id' => SORT_ASC,
],
]);
+
+ $this->load($params);
+ if (!$this->validate())
+ {
+ return $dataProvider;
+ }
+
+ // grid filtering conditions
+ $query->andFilterWhere([
+ 'id' => $this->id,
+ ])->andFilterWhere([
+ 'ilike', Status::tableName() . '.name', $this->statusName
+ ])->andFilterWhere([
+ 'ilike', Models::tableName() . '.name', $this->modelName
+ ])->andFilterWhere([
+ 'ilike', Types::tableName() . '.name', $this->typeName
+ ])->andFilterWhere([ 'OR', [
+ 'ilike', Locations::tableName() . '.name', $this->regionName
+ ], [
+ 'ilike', Regions::tableName() . '.name', $this->regionName
+ ]])->andFilterWhere([ 'OR', [
+ 'ilike', Locations::tableName() . '.name', $this->locationName
+ ], [
+ 'ilike', Regions::tableName() . '.name', $this->locationName
+ ]]);
+
+ $query->andFilterWhere(['ilike', 'name', $this->name])
+ ->andFilterWhere( ['ilike', 'os', $this->os])
+ ->andFilterWhere( ['ilike', 'mac', $this->mac])
+ ->andFilterWhere( ['ilike', 'serial', $this->serial])
+ ->andFilterWhere( ['ilike', 'invent', $this->invent])
+ ->andFilterWhere( ['ilike', 'comment', $this->comment]);
+
+
+ $dataProvider->sort->attributes['modelName'] = [
+ 'asc' => [ Models::tableName() . '.name' => SORT_ASC ],
+ 'desc' => [ Models::tableName() . '.name' => SORT_DESC ],
+ ];
$dataProvider->sort->attributes['statusName'] = [
'asc' => [ Status::tableName() . '.name' => SORT_ASC ],
'desc' => [ Status::tableName() . '.name' => SORT_DESC ],
$query = Items::find()
->select(Items::tableName() . '.*, ' .
Locations::tableName() . '.name AS locationName, ' .
-// Models::tableName() . '.name AS modelName' .
+ Models::tableName() . '.name AS modelName, ' .
Types::tableName() . '.name AS typeName, ' .
Regions::tableName() . '.name AS regionName, ' .
Status::tableName() . '.name AS statusName ')
- ->joinWith([ 'types', 'moving', 'status', 'locations', 'regions', /* 'models', */ ])
+ ->joinWith([ 'types', 'moving', 'status', 'locations', 'regions', 'models', ])
->where([ 'in', Moving::tableName() . '.id', $subQuery ]);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
+ 'pagination' => [
+ 'pageSize' => \Yii::$app->session['pageSize'] ?? 20,
+ ],
]);
$dataProvider->setSort([
'id' => $this->id,
])->andFilterWhere([
'ilike', Status::tableName() . '.name', $this->statusName
-// ])->andFilterWhere([
-// 'ilike', Models::tableName() . '.name', $this->modelName
- ])->andFilterWhere([
+ ])->andFilterWhere([ 'OR', [
+ 'ilike', Models::tableName() . '.name', $this->modelName
+ ], [
+ 'ilike', Items::tableName() . '.name', $this->modelName
+ ]])->andFilterWhere([
'ilike', Types::tableName() . '.name', $this->typeName
])->andFilterWhere([ 'OR', [
'ilike', Locations::tableName() . '.name', $this->regionName
]]);
$query->andFilterWhere(['ilike', 'name', $this->name])
- ->andFilterWhere( ['ilike', 'model', $this->model])
->andFilterWhere( ['ilike', 'os', $this->os])
->andFilterWhere( ['ilike', 'mac', $this->mac])
->andFilterWhere( ['ilike', 'serial', $this->serial])
- ->andFilterWhere( ['ilike', 'product', $this->product])
- ->andFilterWhere( ['ilike', 'modelnumber', $this->modelnumber])
->andFilterWhere( ['ilike', 'invent', $this->invent])
->andFilterWhere( ['ilike', 'comment', $this->comment]);
-// $dataProvider->sort->attributes['modelName'] = [
-// 'asc' => [Models::tableName() . '.name' => SORT_ASC],
-// 'desc' => [Models::tableName() . '.name' => SORT_DESC],
-// ];
+ $dataProvider->sort->attributes['modelName'] = [
+ 'asc' => [Models::tableName() . '.name' => SORT_ASC],
+ 'desc' => [Models::tableName() . '.name' => SORT_DESC],
+ ];
$dataProvider->sort->attributes['statusName'] = [
'asc' => [Status::tableName() . '.name' => SORT_ASC],
'desc' => [Status::tableName() . '.name' => SORT_DESC],