/**
  * 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'));
 }
Example #2
0
 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();
 }
Example #3
0
 /**
  * Display a listing of the resource.
  * GET /audits
  *
  * @return Response
  */
 public function index()
 {
     //check the user privliges
     if (Session::has('log_access')) {
         //show the view
         $sys_logs = Audit::all();
         // $trans_logs = Audit::where('module','=','Sales')->get();
         $trans_logs = TransactionLog::all();
         return View::make('system.logs.index')->with('title', 'System Logs')->with('sys_logs', $sys_logs)->with('trans_logs', $trans_logs);
     }
     return View::make('system.errors.unauthorized')->with('title', 'Unauthorized Access');
 }
 /**
  * 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;
 }
Example #5
0
 /**
  * Void the current sale.
  *
  * @return Response
  */
 public function void()
 {
     $trans_id = Input::get('trans_id');
     $items = $this->temp->where('trans_id', '=', $trans_id)->get();
     TransactionLog::recordLog($trans_id, 'Transaction voided.', '', '', $this->cashier);
     $this->sale->saveVoidedItems($items);
     //empty the temp cart
     $this->removeItemsFromTempCart();
     Session::forget('trans_id');
     //return the transaction id
     $trans_id = $this->initTransaction();
     Session::put('trans_id', $trans_id);
     return $trans_id;
 }