public function filter($value, $context = array())
 {
     $currencyId = $this->getCurrencyId();
     if (!$currencyId) {
         return $value;
         //throw new Zend_Filter_Exception("Missing currency ID in filter");
     }
     $currency = EnumeratedService::getInstance()->findCurrencyById($currencyId);
     if (!$currency) {
         return $value;
         //throw new Zend_Filter_Exception("Missing currency in filter");
     }
     if (!isset($currency['internalNumberOfDecimals']) || !is_numeric($currency['internalNumberOfDecimals'])) {
         return $value;
         //throw new Zend_Filter_Exception("Missing currency decimals in filter");
     }
     $value = (double) $value / (double) pow(10, $currency['internalNumberOfDecimals']);
     $value = number_format($value, $currency['internalNumberOfDecimals'], ',', '');
     $value = (string) $value;
     // Has significative decimals?
     $diff = $currency['internalNumberOfDecimals'] - $currency['numberOfDecimals'];
     $this->_removeNonSignificativeDecimals($value, $diff);
     return $value;
     // . " " . $currency['name'];
 }
 public function filter($value)
 {
     $regionList = \Application\Service\EnumeratedService::getInstance()->getEnum(\Application\Service\EnumeratedService::SERVICE_PROVIDER_REGION_ENUM_NAME);
     foreach ($regionList as $region) {
         if ($region['regionSubId'] == $value) {
             return $region['name'];
         }
     }
     return '';
 }
 public function init()
 {
     $this->_enumSrv = EnumeratedService::getInstance();
 }
 /**
  * Get an specific user by its Id
  */
 public function getAction()
 {
     $enumType = $this->_getParam('id');
     $filters = $this->_getAllParams();
     $this->view->data = $this->_enumSrv->getEnum($enumType, $filters);
 }
 /**
  * @expectedException Application\Exceptions\InvalidArgumentException
  */
 public function testInvalidTypeEnum()
 {
     $this->_enumService->getEnum('invalidEnum');
 }
 protected function _mapEricssonModelToModel(array $data)
 {
     $data = parent::_mapEricssonModelToModel($data);
     // Transformations after "lowercamelcasing" names
     if (isset($data['lifeCycleState'])) {
         $data['lifeCycleStatus'] = $this->_mapEricssonEnumToEnum($data['lifeCycleState'], $this->_lifeCycleStatusMap);
         unset($data['lifeCycleState']);
     }
     if (isset($data['simType'])) {
         $this->_mapEricssonEnumToEnum($data['simType'], $this->_simTypeMap);
     }
     if (isset($data['gprsStatus']) && isset($data['gprsStatus']['status'])) {
         $this->_mapEricssonEnumToEnum($data['gprsStatus']['status'], $this->_connStatusMap);
     }
     if (isset($data['ipStatus']) && isset($data['ipStatus']['status'])) {
         $this->_mapEricssonEnumToEnum($data['ipStatus']['status'], $this->_connStatusMap);
     }
     if (isset($data['billingAccount'])) {
         $this->_mapReference($data, 'billingAccount');
     }
     if (isset($data['servicePack'])) {
         $this->_mapReference($data, 'servicePack');
     }
     if (isset($data['commercialGroup'])) {
         $this->_mapReference($data, 'commercialGroup');
     }
     if (isset($data['supervisionGroup '])) {
         $this->_mapReference($data, 'supervisionGroup');
     }
     // Ericsson issue
     if (!isset($data['apns']) && isset($data['apn'])) {
         $data['apns'] = $data['apn'];
     }
     if (isset($data['apns'])) {
         $data['apns'] = array_values($data['apns']);
     }
     //Invalid 0 as index... strange ericsson behaivor
     if (isset($data['staticIpApnIndex']) && !$data['staticIpApnIndex']) {
         unset($data['staticIpApnIndex']);
     }
     if (isset($data['customerId']) && ($customer = OrgService::getInstance()->load($data['customerId']))) {
         $data['customerCurrency'] = $customer->getCurrency();
         if ($currency = EnumeratedService::getInstance()->findCurrencyById($customer->getCurrency())) {
             $data['customerCurrencyName'] = $currency['name'];
         }
     }
     if (isset($data['restrictions'])) {
         $data['restrictions'] = RestrictionMapper::getInstance()->mapEricssonModelToModel(array('restrictions' => $data['restrictions']));
     }
     if (isset($data['isLegacy'])) {
         $data['legacy'] = $data['isLegacy'];
         unset($data['isLegacy']);
     }
     if (isset($data['logisticsProfile'])) {
         $data['logistics'] = $data['logisticsProfile'];
         unset($data['logisticsProfile']);
     }
     return $data;
 }
Example #7
0
 public function getList()
 {
     $list = EnumeratedService::getInstance()->getEnum($this->_type);
     return $this->_getListIds($list);
 }
 protected function _mapToModel(array $data, $usePreset = true)
 {
     $data = parent::_mapToModel($data, $usePreset);
     $limits = array('limitVoice', 'limitData', 'limitSms', 'limitTotal');
     $currencyId = \App::getOrgUserLogged()->currency;
     $currency = EnumeratedService::getInstance()->findCurrencyById($currencyId);
     $decimals = $currency['internalNumberOfDecimals'];
     foreach ($limits as &$limit) {
         if (isset($data[$limit]['value'])) {
             $data[$limit]['value'] = round($data[$limit]['value'] * pow(10, $decimals));
         }
     }
     return $data;
 }
 protected function _mapToSdp(array $data)
 {
     $data = parent::_mapToSdp($data);
     if ($data['staticApnIndex']) {
         $data['staticApnIndex']--;
     } else {
         $data['staticApnIndex'] = -1;
     }
     if (isset($data['currentApn'])) {
         $data['apn'] = $data['currentApn'];
         unset($data['currentApn']);
     }
     if (isset($data['apns']) && is_array($data['apns'])) {
         foreach ($data['apns'] as $key => $apn) {
             $data['apn' . $key] = $apn;
         }
         unset($data['apns']);
     }
     if (isset($data['gprsStatus']) && is_array($data['gprsStatus'])) {
         $data['gprsStatus'] = $this->_mapConnStatusToSdp($data['gprsStatus']);
     }
     if (isset($data['ipStatus']) && is_array($data['ipStatus'])) {
         $data['ipStatus'] = $this->_mapConnStatusToSdp($data['ipStatus']);
     }
     if (isset($data['provisionDate'])) {
         $data['provisionDate'] = $this->_createAtom($data['provisionDate']);
     }
     if (isset($data['shippingDate'])) {
         $data['shippingDate'] = $this->_createAtom($data['shippingDate']);
     }
     if (isset($data['activationDate'])) {
         $data['activationDate'] = $this->_createAtom($data['activationDate']);
     }
     if (isset($data['IMEILastChange'])) {
         $data['IMEILastChange'] = $this->_createAtom($data['IMEILastChange']);
     }
     /**
      * put Imei dashes
      */
     if (isset($data['imei'])) {
         if (trim($data['imei'])) {
             $imei = trim($data['imei']);
             $nImei = substr_replace($imei, '-', '2', 0);
             $nImei = substr_replace($nImei, '-', '9', 0);
             $nImei = substr_replace($nImei, '-', '16', 0);
             $data['imei'] = $nImei;
         } else {
             unset($data['imei']);
         }
     }
     if (isset($data['restrictions'])) {
         $data['basicServices'] = array('voiceOriginatedHome' => !$data['restrictions']['voice']['mo']['home'], 'voiceOriginatedRoaming' => !$data['restrictions']['voice']['mo']['roaming'], 'voiceOriginatedInternational' => !$data['restrictions']['voice']['mo']['international'], 'voiceTerminatedHome' => !$data['restrictions']['voice']['mt']['home'], 'voiceTerminatedRoaming' => !$data['restrictions']['voice']['mt']['roaming'], 'smsOriginatedHome' => !$data['restrictions']['sms']['mo']['home'], 'smsOriginatedRoaming' => !$data['restrictions']['sms']['mo']['roaming'], 'smsOriginatedInternational' => !$data['restrictions']['sms']['mo']['international'], 'smsTerminatedHome' => !$data['restrictions']['sms']['mt']['home'], 'smsTerminatedRoaming' => !$data['restrictions']['sms']['mt']['roaming'], 'dataHome' => !$data['restrictions']['data']['home'], 'dataRoaming' => !$data['restrictions']['data']['roaming']);
         unset($data['restrictions']);
     }
     if (isset($data['supplServices'])) {
         unset($data['supplServices']['customServices']);
     }
     //NOTE: it's very dangerous making assignations into conditionals
     //sentences.
     //Loaded customer data was being evaluated as boolean by means of the boolean
     //operator && then the result was being asigned to $customer variable in the end
     //we had a boolean instead of a customer instance
     //RESULT: $currencyId was always 0
     if (isset($data['customerID']) && ($customer = OrgService::getInstance()->load($data['customerID'])) && isset($data['expenseMonthly'])) {
         $currencyId = $customer->currency;
         $currency = EnumeratedService::getInstance()->findCurrencyById($currencyId);
         $decimals = $currency['internalNumberOfDecimals'];
         $fields = array('voiceOver', 'smsOver', 'dataOver', 'totalOver');
         foreach ($fields as $field) {
             if (isset($data['expenseMonthly'][$field])) {
                 $data['expenseMonthly'][$field]['limit'] = (double) $data['expenseMonthly'][$field]['limit'] / pow(10, $decimals);
                 $data['expenseMonthly'][$field]['value'] = (double) $data['expenseMonthly'][$field]['value'] / pow(10, $decimals);
                 $data['expenseMonthly'][$field]['thrReached'] = (double) $data['expenseMonthly'][$field]['thrReached'] / pow(10, 2);
             }
         }
         $fields = array('voiceFee', 'smsFee', 'dataFee', 'totalFee', 'other', 'total');
         foreach ($fields as $field) {
             if (isset($data['expenseMonthly'][$field])) {
                 $data['expenseMonthly'][$field] = (double) $data['expenseMonthly'][$field] / pow(10, $decimals);
             }
         }
     }
     if (!empty($data['manualLocation'])) {
         $data['manualLocation'] = $this->_mapLocationToSdp($data['manualLocation']);
     }
     if (!empty($data['automaticLocation'])) {
         $data['automaticLocation'] = $this->_mapLocationToSdp($data['automaticLocation']);
     }
     if (isset($data['simModel']) && empty($data['simModel'])) {
         unset($data['simModel']);
     }
     return $data;
 }