/** * Smarty {localize} function plugin * * Type: function<br> * Name: localize<br> * * Examples: * <pre> * {ratio p1='25' p2='35'} * </pre> * @author Andrej Harsani, Michal Bebjak * @param array * @param Smarty * @return string */ function smarty_function_ratio($params, &$smarty) { if ($params['p2']!=0) { return round($params['p1']/$params['p2'],Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision()); } else { echo ''; } }
/** * Smarty {localize} function plugin * * Type: function<br> * Name: localize<br> * * Examples: * <pre> * {ratioPercentage p1='25' p2='35'} * </pre> * @author Andrej Harsani, Michal Bebjak * @param array * @param Smarty * @return string */ function smarty_function_ratioPercentage($params, &$smarty) { if ($params['p2']!=0) { $number = round($params['p1']/$params['p2']*100,Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision()); return Gpf_Common_NumberUtils::toStandardNumberFormat($number, Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision()) . ' %'; } else { return '0'; } }
/** * Smarty |currency_span modifier * * Type: function<br> * Name: localize<br> * * Examples: * <pre> * {$allCommission|currency_span} * </pre> * @author Michal Bebjak * @param string * @return string */ function smarty_modifier_currency_span($number) { $cssClass = 'CurrencyData'; if ($number < 0) { $cssClass .= ' CurrencyData-negative'; } $number = number_format($number, Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision(), Gpf_Settings_Regional::getInstance()->getDecimalSeparator(), Gpf_Settings_Regional::getInstance()->getThousandsSeparator()); return '<span class="'.$cssClass.'">'.Pap_Common_Utils_CurrencyUtils::stringToCurrencyFormat($number).'</span>'; }
public function getAmountAsText() { return round($this->getAmount(), Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision()); }
private function round($value) { return round($value, Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision()); }
/** * Smarty |currency modifier * * Type: function<br> * Name: localize<br> * * Examples: * <pre> * {$allCommission|currency} * </pre> * @author Michal Bebjak * @param string * @return string */ function smarty_modifier_currency($number) { $number = number_format($number, Pap_Common_Utils_CurrencyUtils::getDefaultCurrencyPrecision(), Gpf_Settings_Regional::getInstance()->getDecimalSeparator(), Gpf_Settings_Regional::getInstance()->getThousandsSeparator()); return Pap_Common_Utils_CurrencyUtils::stringToCurrencyFormat($number); }