コード例 #1
0
 /**
  * This is the default 'index' action that is invOked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $this->redirect(array('/sipAccount/index'));
     $transactionLogMdl = new TransactionLog();
     if (isset($_POST['TransactionLog'])) {
         $transactionLogMdl->attributes = $_POST['TransactionLog'];
         if ($transactionLogMdl->save()) {
             /*send to remote*/
             $rmt = new RemoteTransferFund();
             $remoteResult = $rmt->commitTransaction($transactionLogMdl->freevoipAccount->username, $transactionLogMdl->freevoipAccount->password, $transactionLogMdl->to_username, $transactionLogMdl->amount, $transactionLogMdl->pincode);
             $newTransactionlink = CHtml::link('Transaction Log', array('transactionLog/view', 'id' => $transactionLogMdl->id));
             $transactionLogMdl->result_string = $remoteResult->resultstring;
             $transactionLogMdl->result_description = $remoteResult->description;
             $transactionLogMdl->save();
             if ($remoteResult->resultstring == 'success') {
                 Yii::app()->user->setFlash('success', '<strong>Success!</strong> Credit transfered . ' . $newTransactionlink);
             } else {
                 if ($remoteResult->resultstring == 'failure') {
                     $reasonOfFailure = "unknown";
                     if (isset($remoteResult->description)) {
                         $reasonOfFailure = $remoteResult->description;
                     }
                     Yii::app()->user->setFlash('error', '<strong>Transaction Failed!</strong> We met some error while transferring the amount . <br>But here is your transaction log ' . $newTransactionlink . ' , you can resend it later. <br>Reason of failure : ' . $reasonOfFailure);
                 }
             }
             $this->redirect("/site/index");
         }
     }
     $voipAccountsCount = FreeVoipAccounts::model()->count();
     $transactionCount = TransactionLog::model()->count();
     $sipAccountCount = SipAccount::model()->count();
     $this->render('dashboard', compact('voipAccountsCount', 'transactionCount', 'transactionLogMdl', 'sipAccountCount'));
 }
コード例 #2
0
 /**
  * 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 TransactionLog the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = TransactionLog::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }