/** * 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')); }
public static function recordLog($invoice, $action, $item_code, $item_desc, $cashier) { $log = new TransactionLog(); $log->invoice_num = $invoice; $log->action = $action; $log->item_code = $item_code; $log->item_desc = $item_desc; $log->cashier = $cashier; $log->save(); }
/** * * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new TransactionLog(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['TransactionLog'])) { $model->attributes = $_POST['TransactionLog']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }