Beispiel #1
0
 function addBalanceByUser($user_id, $data)
 {
     $db = $this->getAdapter();
     $db_loan = new Application_Model_DbTable_DbLoanAgent();
     $db->beginTransaction();
     try {
         foreach ($data as $k => $val) {
             if ($k != "dollar" && $k != "bath" && $k != "rail") {
                 continue;
             }
             $currency_type = 0;
             if ($k == "dollar") {
                 $currency_type = 1;
             } elseif ($k == "bath") {
                 $currency_type = 2;
             } elseif ($k == "rail") {
                 $currency_type = 3;
             }
             $amount = floatval($this->getCurrentBalanceByUser($user_id, $currency_type)) + floatval($val);
             $this->updateBalanceByUserId($user_id, $currency_type, $amount);
             $db_loan->saveLoanByUserId($user_id, $currency_type, $val);
         }
         return $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         //     		echo $e->getMessage(); exit;
     }
 }
Beispiel #2
0
 public function rptbalanceAgentAction()
 {
     // Get Session User
     $session_user = new Zend_Session_Namespace('auth');
     $b = new Application_Model_DbTable_DbCapitalAgent();
     $usr_mod = new Application_Model_DbTable_DbAgents();
     $agents_list = $usr_mod->getAgentListSelect();
     $user_id = $agents_list[0]['id'];
     $month = date("n");
     if ($this->getRequest()->isPost()) {
         $formdata = $this->getRequest()->getPost();
         $user_id = $formdata['user_id'];
         if ($formdata['actions'] == "add_capital") {
             $b->addBalanceByUser($user_id, $formdata);
         } else {
             $month = $formdata['month'];
         }
     }
     $this->view->users = $agents_list;
     $this->view->balance = $b->getCurrentBallancesByCurrentUser($user_id);
     $this->view->user_id = $user_id;
     $this->view->month = $month;
     // For view
     $db_loan = new Application_Model_DbTable_DbLoanAgent();
     $trans = $db_loan->getLoanDataByUserId($user_id, $month);
     if (empty($trans)) {
         $trans = array('err' => 1, 'msg' => 'មិន​ទាន់​មាន​ទន្និន័យ​នូវ​ឡើយ​ទេ!');
     }
     $this->view->tranlist = $trans;
 }