/** * 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; }
/** * @return \yii\db\ActiveQuery */ public function getCoaPotongan() { return $this->hasOne(\backend\models\accounting\Coa::className(), ['id' => 'coa_id_potongan']); }
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(); }
/** * @return \yii\db\ActiveQuery */ public function getCoas() { return $this->hasMany(Coa::className(), ['parent_id' => 'id']); }
/** * Finds the Coa model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Coa the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Coa::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getCoa() { return $this->hasOne(Coa::className(), ['id' => 'coa_id']); }