public function search($params) { $query = CoaModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id_coa' => $this->id_coa, 'id_coa_parent' => $this->id_coa_parent, 'coa_type' => $this->coa_type, 'create_by' => $this->create_by, 'update_by' => $this->update_by]); $query->andFilterWhere(['like', 'cd_account', $this->cd_account])->andFilterWhere(['like', 'nm_account', $this->nm_account])->andFilterWhere(['like', 'normal_balance', $this->normal_balance])->andFilterWhere(['like', 'create_date', $this->create_date])->andFilterWhere(['like', 'update_date', $this->update_date]); return $dataProvider; }
public static function getGroupedCoaList($addSelf = false, $tab = 4) { $result = []; $tab = str_pad('', $tab); foreach (Coa::find()->where(['id_coa_parent' => null])->orderBy(['cd_account' => SORT_ASC])->all() as $row) { if ($addSelf) { $result[$row['nm_account']][$row['id_coa']] = "[{$row['cd_account']}] {$row['nm_account']}"; } else { $result[$row['nm_account']] = []; } static::getCoaChild($result[$row['nm_account']], $row['id_coa'], $addSelf ? $tab : '', $tab); } return $result; }
public function actionCoaList($term = '') { $query = Coa::find()->orderBy('cd_account'); if (!empty($term)) { $query->where(['LIKE', 'lower(nm_account)', strtolower($term)]); } $rCoa = []; foreach ($query->all() as $row) { $rCoa[] = ['id' => $row->id_coa, 'label' => $row->cd_account . ': ' . $row->nm_account]; } Yii::$app->response->format = Response::FORMAT_JSON; return $rCoa; }