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_date', $this->create_date])->andFilterWhere(['like', 'update_date', $this->update_date]); return $dataProvider; }
public static function createGL($hdr, $dtls = []) { $blc = 0.0; foreach ($dtls as $row) { $blc += $row['ammount']; } if ($blc != 0) { throw new UserException('GL Balance Failed'); } $gl = new GlHeader(); $gl->gl_date = $hdr['date']; $gl->id_reff = $hdr['id_reff']; $gl->type_reff = $hdr['type_reff']; $gl->gl_memo = $hdr['memo']; $gl->description = $hdr['description']; $gl->id_branch = $hdr['id_branch']; $active_periode = AccPeriode::getCurrentPeriode(); $gl->id_periode = $active_periode['id_periode']; $gl->status = 0; if (!$gl->save()) { throw new UserException(implode("\n", $gl->getFirstErrors())); } foreach ($dtls as $row) { $glDtl = new GlDetail(); $glDtl->id_gl = $gl->id_gl; $glDtl->id_coa = $row['id_coa']; $glDtl->amount = $row['ammount']; if (!$glDtl->save()) { throw new UserException(implode("\n", $glDtl->getFirstErrors())); } } }
/** * 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']); }