예제 #1
0
파일: Sms.php 프로젝트: fredcido/simuweb
 /**
  * 
  * @return array
  */
 public function balanceReport()
 {
     $total = 0;
     $mapperSmsCredit = new Admin_Model_Mapper_SmsCredit();
     $balanceRows = $mapperSmsCredit->getBalance();
     foreach ($balanceRows as $row) {
         $total += $row->balance;
     }
     return array('rows' => $balanceRows, 'total' => $total);
 }
예제 #2
0
 /**
  * 
  * @param int $id
  * @return array
  */
 public function detailDepartment($id)
 {
     $dbDepartment = App_Model_DbTable_Factory::get('Department');
     $row = $dbDepartment->fetchRow(array('id_department = ?' => $id));
     if (empty($row)) {
         return array();
     } else {
         $data = $row->toArray();
         $mapperCredit = new Admin_Model_Mapper_SmsCredit();
         $totalBalance = $mapperCredit->getBalanceDepartment($row->id_department);
         $balance = (double) (empty($totalBalance) ? 0 : $totalBalance->balance);
         $mapperConfig = new Admin_Model_Mapper_SmsConfig();
         $config = $mapperConfig->getConfig();
         $sending = 0;
         if (!empty($balance)) {
             $sending = floor($balance / $config->sms_unit_cost);
         }
         $data['balance'] = $balance;
         $data['sending'] = $sending;
         return $data;
     }
 }
예제 #3
0
 /**
  * 
  */
 public function balanceAction()
 {
     $this->_helper->viewRenderer->setRender('balance-rows');
     $this->_helper->layout()->disableLayout();
     $this->view->rows = $this->_mapper->getBalance();
 }