/** * @return integer Current accounting periode */ public static function getCurrentIdAccPeriode() { $acc = AccPeriode::findOne(['status' => AccPeriode::STATUS_OPEN]); if ($acc) { return $acc->id_periode; } throw new UserException('Periode tidak ditemukan'); }
public function search($params) { $query = AccPeriodeModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id_periode' => $this->id_periode, 'date_from' => $this->date_from, 'date_to' => $this->date_to, 'status' => $this->status, 'create_by' => $this->create_by, 'update_by' => $this->update_by]); $query->andFilterWhere(['like', 'nm_periode', $this->nm_periode])->andFilterWhere(['like', 'create_at', $this->create_at])->andFilterWhere(['like', 'update_at', $this->update_at]); return $dataProvider; }
/** * Finds the AccPeriode model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return AccPeriode the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = AccPeriode::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getIdPeriode() { return $this->hasOne(AccPeriode::className(), ['id_periode' => 'id_periode']); }