/** * 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 $id the ID of the model to be loaded * @return Ledger the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Ledger::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
function portfolioUpdate($id, $values) { $user_data = Users::model()->findByPk(Yii::app()->user->id); $client_id = $user_data->client_id; $portfolio_id = 0; $ledger = Ledger::model()->findByPk($id); //if(isset($instrument_id)){$portfolio_id = $values['ledger']['portfolio_id'];} //else{$portfolio_id = $existing_trades->portfolio_id;} $portfolio_id = $ledger->portfolio_id; // $values['ledger']['portfolio_id']; $instrument_id = $ledger->instrument_id; // $values['ledger']['instrument_id']; $trade_currency = $ledger->currency; // $values['ledger']['currency']; $portfolios = Portfolios::model()->findByPk($portfolio_id); $portfolio_currency = $portfolios->currency; //Returns::model()->calculateIinstrumnetReturn($instrument_id, $portfolio_id = 0, $trade_rate, $trade_currency, $client_id, $portfolio_currency); //PortfolioReturns::model()->PortfolioReturnsUpdate($portfolio_id); //$trade_rate, $trade_currency, Returns::model()->calculateIinstrumnetReturn($instrument_id, $portfolio_id, $client_id, $portfolio_currency); $step_completed = $user_data->step_completed; if ($user_data->user_role == 2 && $step_completed < 5) { $user_data->step_completed = 5; $user_data->save(); } }