Exemplo n.º 1
0
 function getSymbol()
 {
     return TTi18n::getCurrencySymbol($this->getISOCode());
 }
Exemplo n.º 2
0
 function getObjectAsArray($include_columns = NULL, $permission_children_ids = FALSE)
 {
     $variable_function_map = $this->getVariableToFunctionMap();
     if (is_array($variable_function_map)) {
         foreach ($variable_function_map as $variable => $function_stub) {
             if ($include_columns == NULL or isset($include_columns[$variable]) and $include_columns[$variable] == TRUE) {
                 $function = 'get' . $function_stub;
                 switch ($variable) {
                     case 'type':
                         $function = 'get' . $variable;
                         if (method_exists($this, $function)) {
                             $data[$variable] = Option::getByKey($this->{$function}(), $this->getOptions($variable));
                         }
                         break;
                     case 'wage_group':
                     case 'first_name':
                     case 'last_name':
                     case 'title':
                     case 'user_group':
                     case 'currency':
                     case 'default_branch':
                     case 'default_department':
                         $data[$variable] = $this->getColumn($variable);
                         break;
                     case 'currency_symbol':
                         $data[$variable] = TTi18n::getCurrencySymbol($this->getColumn('iso_code'));
                         break;
                     case 'effective_date':
                         if (method_exists($this, $function)) {
                             $data[$variable] = TTDate::getAPIDate('DATE', $this->{$function}());
                         }
                         break;
                     default:
                         if (method_exists($this, $function)) {
                             $data[$variable] = $this->{$function}();
                         }
                         break;
                 }
             }
         }
         $this->getPermissionColumns($data, $this->getID(), $this->getCreatedBy(), $permission_children_ids, $include_columns);
         $this->getCreatedAndUpdatedColumns($data, $include_columns);
     }
     return $data;
 }
Exemplo n.º 3
0
 function getEncoding($company_id = FALSE)
 {
     if ($company_id == '') {
         $company_id = $this->getID();
     }
     $cache_id = 'encoding_' . $company_id;
     $retval = $this->getCache($cache_id);
     if ($retval === FALSE) {
         if ($retval === FALSE) {
             //Get unique currencies, to check if currency symbol requires unicode.
             $clf = TTnew('CurrencyListFactory');
             $iso_codes = $clf->getUniqueISOCodeByCompanyId($company_id);
             //Debug::Arr($iso_codes, 'ISO Codes: ', __FILE__, __LINE__, __METHOD__,9);
             if (is_array($iso_codes)) {
                 foreach ($iso_codes as $iso_code) {
                     $encoding = strtoupper(mb_detect_encoding(TTi18n::getCurrencySymbol($iso_code), 'auto'));
                     if ($encoding == 'UTF-8') {
                         Debug::Text($encoding, 'ISO Code: ' . $iso_code . ' Encoding: ' . $encoding, __FILE__, __LINE__, __METHOD__, 9);
                         $retval = 'UTF-8';
                     }
                 }
             }
         }
         if ($retval === FALSE) {
             //Get unique language codes, if anything other than english is used, assume UTF-8.
             $uplf = TTnew('UserPreferenceListFactory');
             $language_codes = $uplf->getUniqueLanguageByCompanyId($company_id);
             //Debug::Arr($language_codes, 'Language Codes: ', __FILE__, __LINE__, __METHOD__,9);
             if (is_array($language_codes)) {
                 foreach ($language_codes as $language_code) {
                     if ($language_code != 'en') {
                         $retval = 'UTF-8';
                     }
                 }
             }
         }
         if ($retval === FALSE) {
             $retval = 'ISO-8859-1';
         }
         $this->saveCache($retval, $cache_id);
     }
     return $retval;
 }