Index: units/helpers/currency_rates.php =================================================================== --- units/helpers/currency_rates.php (revision 15331) +++ units/helpers/currency_rates.php (working copy) @@ -81,6 +81,41 @@ return $amount * $this->GetRate($source_cur, $target_cur); } + function AddCurrencySymbol($value, $iso, $decimal_tag = '') + { + static $decimal_separator = false; + + $cache_key = 'iso_masks[%CurrSerial%]'; + $iso_masks = $this->Application->getCache($cache_key); + + if ( $iso_masks === false ) { + $this->Conn->nextQueryCachable = true; + $symbol_sql = 'IF(COALESCE(Symbol, "") = "", CONCAT(ISO, " "), Symbol)'; + + $sql = 'SELECT IF(SymbolPosition = 0, CONCAT(' . $symbol_sql . ', "%s"), CONCAT("%s", ' . $symbol_sql . ')), LOWER(ISO) AS ISO + FROM ' . $this->Application->getUnitOption('curr', 'TableName') . ' + WHERE Status = ' . STATUS_ACTIVE; + $iso_masks = $this->Conn->GetCol($sql, 'ISO'); + $this->Application->setCache($cache_key, $iso_masks); + } + + if ( $decimal_tag ) { + if ( $decimal_separator === false ) { + $language = $this->Application->recallObject('lang.current'); + /* @var $language LanguagesItem */ + + $decimal_separator = $language->GetDBField('DecimalPoint'); + } + + list ($integer_part, $decimal_part) = explode($decimal_separator, $value); + $value = $integer_part . $decimal_separator . '<' . $decimal_tag . '>' . $decimal_part . ''; + } + + $iso = strtolower($iso); + + return array_key_exists($iso, $iso_masks) ? sprintf($iso_masks[$iso], $value) : $value; + } + function SetRate($source_cur, $target_cur, $rate, $units = 1) { $this->ExchangeRates[$target_cur]['TARGET'] = $source_cur;