/**
* Returns a pretty formated monetary value using the currency associated with a site.
*
* @param int|string $value The monetary value to format.
* @param int $idSite The ID of the site whose currency will be used.
* @return string
* @api
*/
public function getPrettyMoney($value, $idSite)
{
$space = ' ';
$currencySymbol = Site::getCurrencySymbolFor($idSite);
$currencyBefore = $currencySymbol . $space;
$currencyAfter = '';
// (maybe more currencies prefer this notation?)
$currencySymbolToAppend = array('€', 'kr', 'zł');
// manually put the currency symbol after the amount
if (in_array($currencySymbol, $currencySymbolToAppend)) {
$currencyAfter = $space . $currencySymbol;
$currencyBefore = '';
}
// if the input is a number (it could be a string or INPUT form),
// and if this number is not an int, we round to precision 2
if (is_numeric($value)) {
if ($value == round($value)) {
// 0.0 => 0
$value = round($value);
} else {
$precision = GoalManager::REVENUE_PRECISION;
$value = sprintf("%01." . $precision . "f", $value);
}
}
$prettyMoney = $currencyBefore . $value . $currencyAfter;
return $prettyMoney;
}