/** * 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 ForceAgentTable the loaded model * @throws CHttpException */ public function loadModel($id) { $model = ForceAgentTable::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionTopUpSelected() { $formModel = new TopupForm(); $numberOfAccounts = RemoteDataCache::model()->count(); $topupLogsTotalToday = 0; $datasources = $this->loadDataSources(); $chartInitialData = $datasources['iniChartData']; $sipAccountTempContainer = $datasources['sipAccountStr']; //append the current campaign foreach ($sipAccountTempContainer as $key => $currentAccount) { $campaignInformationRetriever = Yii::app()->campaignInformationRetriever; $sipAccountTempContainer[$key] = $key + 1 . " - " . $campaignInformationRetriever->getInformation($currentAccount) . " - " . $sipAccountTempContainer[$key]; } $sipAccountsStr = json_encode($datasources['sipAccountStr']); $chartLabels = json_encode($sipAccountTempContainer); $seriesDataStr = json_encode($datasources['chartSeriesData']); $allSipAccounts = array(); /*retrieve all accounts to be topped up*/ /*get all subsip logs from Vicilogs*/ $criteria = new CDbCriteria(); $criteria->compare("date(logDate)", date("Y-m-d")); $criteria->compare("action_type", 'SUB_ACCOUNT_TOPUP'); $criteria->order = "logDate DESC"; $logRecsTodayDataProvider = new CActiveDataProvider('ViciLogAction', array('criteria' => $criteria, 'pagination' => array('pageSize' => 20))); /** * Topup implementation */ if (isset($_POST['TopupForm'])) { $formModel->attributes = $_POST['TopupForm']; if ($formModel->validate()) { $numberOfAffectedAccounts = $formModel->topupAccounts(); Yii::app()->user->setFlash("success", "Success! All {$numberOfAffectedAccounts} account(s) are topped up."); $this->redirect(array('/subSipAccount/topUpSelected')); } } foreach ($logRecsTodayDataProvider->data as $key => $value) { $topupLogsTotalToday += $value->topUpValue; } $allSipAccounts = $this->getRemoteDataCacheAccounts(); //append current campaign //List of force agent options $forceAgentModelAll = ForceAgentTable::model()->findAll(); $listForceAgentCollection = CHtml::listData($forceAgentModelAll, 'force_agent_value', 'force_agent_lbl'); $this->render('topUpSelected', compact('chartLabels', 'formModel', 'allSipAccounts', 'topupLogsTotalToday', 'logRecsTodayDataProvider', 'numberOfAccounts', 'sipAccountsStr', 'sipAccountsStr', 'seriesDataStr', 'listForceAgentCollection')); }