/** * get or create record for table * @param int $fret_id - ref type (first dimension level) * @param int $ref_id - refernce table record id * @param string $code * @param string $name * @return type */ public static function getDim3Id($fret_id, $fdm2_id, $ref_id, $code, $name = false) { if (!$name) { $name = $code; } //search existing record $criteria = new CDbCriteria(); $criteria->compare('fdm3_sys_ccmp_id', Yii::app()->sysCompany->getActiveCompany()); $criteria->compare('fdm3_fret_id', $fret_id); $criteria->compare('fdm3_fdm2_id', $fdm2_id); $criteria->compare('fdm3_ref_id', $ref_id); if ($fdm3 = Fdm3Dimension3::model()->find($criteria)) { return $fdm3->fdm3_id; } $fret = FretRefType::model()->findByPk($fret_id); //add record $fdm3 = new Fdm3Dimension3(); $fdm3->fdm3_fret_id = $fret_id; $fdm3->fdm3_ref_id = $ref_id; $fdm3->fdm3_fdm1_id = $fret->fret_fdm1_id; $fdm3->fdm3_fdm2_id = $fdm2_id; $fdm3->fdm3_code = substr($code, 0, 10); $fdm3->fdm3_name = $name; $fdm3->save(); return $fdm3->primaryKey; }
public function loadModel($id) { $m = Fdm3Dimension3::model(); // apply scope, if available $scopes = $m->scopes(); if (isset($scopes[$this->scope])) { $m->{$this->scope}(); } $model = $m->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('D2fixrModule.crud', 'The requested page does not exist.')); } return $model; }
/** * level 1 month transactions * @param type $fdm1_id * @param type $year * @param type $month */ public function actionLevel3transactions($fdm3_id, $year, $month) { $fdpe_id = FdpeDimPeriod::getIdByYearMonth($year, $month); $data = FdpeDimPeriod::getDimMonthPositions($fdpe_id, false, false, $fdm3_id); $fdm3 = Fdm3Dimension3::model()->findByPk($fdm3_id); $this->renderPartial('transactions', array('year' => $year, 'month' => $month, 'label' => $fdm3->fdm3_name, 'data' => $data)); }