Пример #1
0
 protected 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 = Helper::getCurrentIdAccPeriode();
     $gl->id_periode = $active_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()));
         }
     }
 }
Пример #2
0
 public function search($params)
 {
     $query = GlHeaderModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id_gl' => $this->id_gl, 'id_branch' => $this->id_branch, 'id_periode' => $this->id_periode, 'type_reff' => $this->type_reff, 'id_reff' => $this->id_reff, 'status' => $this->status, 'create_by' => $this->create_by, 'update_by' => $this->update_by]);
     $query->andFilterWhere(['like', 'gl_date', $this->gl_date])->andFilterWhere(['like', 'gl_num', $this->gl_num])->andFilterWhere(['like', 'gl_memo', $this->gl_memo])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'create_date', $this->create_date])->andFilterWhere(['like', 'update_date', $this->update_date]);
     return $dataProvider;
 }
 /**
  * Finds the GlHeader model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return GlHeader the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = GlHeader::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdGl()
 {
     return $this->hasOne(GlHeader::className(), ['id_gl' => 'id_gl']);
 }
Пример #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGlHeaders()
 {
     return $this->hasMany(GlHeader::className(), ['id_branch' => 'id_branch']);
 }
Пример #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGlHeaders()
 {
     return $this->hasMany(GlHeader::className(), ['id_periode' => 'id_periode']);
 }