/** * Set price onlinepayment amount for this reservation * (non-PHPdoc) * @see CActiveRecord::beforesave() */ public function beforeSave() { //Make sure we have a date to. if (empty($this->dateto)) { $this->updateDateTo(); } if (empty($this->onlinepayment)) { $criteria = new CDbCriteria(); $criteria->select = 'price'; $criteria->condition = 'roomid=:roomid'; $criteria->params = array(':roomid' => $this->roomid); $model = RoomCharge::model()->find($criteria); $this->setAttribute('onlinepayment', $model->price); } return parent::beforeSave(); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = RoomCharge::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }