Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TblAssetLoan::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['entry_id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('externalUser');
     $query->joinWith('statuS');
     $query->andFilterWhere(['entry_id' => $this->entry_id, 'form_id' => $this->form_id, 'user_id' => $this->user_id, 'form_type' => $this->form_type, 'closed_by' => $this->closed_by, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'update_date' => $this->update_date, 'assigned_to' => $this->assigned_to, 'expected_return' => $this->expected_return, 'loan_date' => $this->loan_date]);
     $query->andFilterWhere(['like', 'inventory', $this->inventory])->andFilterWhere(['like', 'purpose', $this->purpose])->andFilterWhere(['like', 'purpose_other', $this->purpose_other])->andFilterWhere(['like', 'comments', $this->comments])->andFilterWhere(['or', ['like', 'tbl_external_user.first_name', $this->external_user], ['like', 'tbl_external_user.last_name', $this->external_user]])->andFilterWhere(['like', 'tbl_statuses.status_name', $this->status]);
     return $dataProvider;
 }