Ejemplo n.º 1
0
 public function search($params)
 {
     $query = Cashbook::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['date' => SORT_DESC]], 'pagination' => ['pageSize' => 100]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'type_id' => $this->type_id, 'value' => $this->value, 'inc_datetime' => $this->inc_datetime, 'edit_datetime' => $this->edit_datetime, 'user_id' => Yii::$app->user->identity->id]);
     $query->andFilterWhere(['between', 'date', $this->start_date, $this->end_date]);
     $query->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'attachment', $this->attachment]);
     //$query->andFilterWhere(['user_id' => 2]);
     return $dataProvider;
 }