예제 #1
0
 /**
  * 
  * @return boolean
  */
 protected function _validateDepartment()
 {
     $user = Zend_Auth::getInstance()->getIdentity();
     $mapperDepartment = new Admin_Model_Mapper_Department();
     $department = $mapperDepartment->getDepartmentByUser($user->id_sysuser);
     // If there is no department
     if (empty($department)) {
         $this->addMessage('Ita la bele rejistu kampanha SMS. Tenki husu uzuariu husi departamentu');
         return false;
     }
     $this->_department = $department;
     return true;
 }
예제 #2
0
 /**
  * 
  */
 public function calcSendingAction()
 {
     $user = Zend_Auth::getInstance()->getIdentity();
     // Get the User department
     $mapperDepartment = new Admin_Model_Mapper_Department();
     $department = $mapperDepartment->getDepartmentByUser($user->id_sysuser);
     // Get the groups with totals
     $mapperGroupsSms = new Sms_Model_Mapper_Group();
     $groups = $mapperGroupsSms->listGroupWithTotals();
     // Get the current sms config
     $mapperConfig = new Admin_Model_Mapper_SmsConfig();
     $config = $mapperConfig->getConfig();
     $groupsSelected = $this->_getParam('groups');
     $total = 0;
     $percent = 100;
     if (!empty($groupsSelected)) {
         foreach ($groups as $group) {
             if (in_array($group['id_sms_group'], $groupsSelected)) {
                 $total += (int) $group['total'];
             }
         }
     }
     $totalCurrency = $total * (double) $config->sms_unit_cost;
     if (!empty($department['balance'])) {
         $percent = $totalCurrency * 100 / $department['balance'];
     }
     $return = array('total' => $total, 'release' => $totalCurrency <= $department['balance'], 'percent' => $percent);
     $this->_helper->json($return);
 }