Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CoaModel::find();
     $query->codeOrdered();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false, 'sort' => false]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('1=0');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'type' => $this->type, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'lower(name)', strtolower($this->name)])->andFilterWhere(['like', 'normal_balance', $this->normal_balance]);
     return $dataProvider;
 }
 public function actionListCoa($term = '')
 {
     $response = Yii::$app->response;
     $response->format = 'json';
     $coaList = \backend\models\accounting\Coa::find()->filterWhere(['like', 'lower([[name]])', strtolower($term)])->orFilterWhere(['like', 'lower([[code]])', strtolower($term)])->codeOrdered()->asArray()->limit(10);
     return $coaList->all();
 }