255], ]; } public function search($params) { $optionsSearch = self::defaultOptionsSearch(); $query = Invoice::find() ->with($optionsSearch['with']) ->joinWith($optionsSearch['join_with']) ->where(['invoice.id_producer' => GlobalParam::getCurrentProducerId()]) ->orderBy('invoice.status ASC, invoice.reference DESC') ->groupBy('invoice.id'); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => ['attributes' => ['name', 'reference', 'date']], 'pagination' => [ 'pageSize' => 20, ], ]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['like', 'invoice.name', $this->name]); $query->andFilterWhere(['like', 'invoice.reference', $this->reference]); $query->andFilterWhere(['like', 'invoice.status', $this->status]); $query->andFilterWhere([ 'or', ['like', 'user_invoice.lastname', $this->username], ['like', 'user_invoice.name', $this->username], ['like', 'user_invoice.name_legal_person', $this->username], ]); return $dataProvider; } }