255], ]; } public function search($params) { $optionsSearch = self::defaultOptionsSearch(); $query = DeliveryNote::find() ->with($optionsSearch['with']) ->joinWith($optionsSearch['join_with'], true) ->where(['delivery_note.id_producer' => GlobalParam::getCurrentProducerId()]) ->orderBy('delivery_note.status ASC, delivery_note.reference DESC'); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => ['attributes' => ['name', 'reference', 'date']], 'pagination' => [ 'pageSize' => 30, ], ]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['like', 'delivery_note.name', $this->name]); $query->andFilterWhere(['like', 'delivery_note.reference', $this->reference]); $query->andFilterWhere(['like', 'delivery_note.status', $this->status]); if($this->id_point_sale) { $query->andWhere(['order.id_point_sale' => $this->id_point_sale]); } if($this->date_distribution && strlen($this->date_distribution)) { $query->andFilterWhere(['like', 'distribution.date', date('Y-m-d',strtotime(str_replace('/','-',$this->date_distribution)))]); } return $dataProvider; } }