mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Extend JS to include currency code #37
This commit is contained in:
@@ -17,16 +17,17 @@ if (!function_exists('mf')) {
|
||||
|
||||
if ($coloured === true) {
|
||||
if ($amount === 0.0) {
|
||||
return '<span style="color:#999">'.$currencySymbol.' ' . $string . '</span>';
|
||||
return '<span style="color:#999">' . $currencySymbol . ' ' . $string . '</span>';
|
||||
}
|
||||
if ($amount > 0) {
|
||||
return '<span class="text-success">'.$currencySymbol.' ' . $string . '</span>';
|
||||
return '<span class="text-success">' . $currencySymbol . ' ' . $string . '</span>';
|
||||
}
|
||||
|
||||
return '<span class="text-danger">'.$currencySymbol.' ' . $string . '</span>';
|
||||
return '<span class="text-danger">' . $currencySymbol . ' ' . $string . '</span>';
|
||||
}
|
||||
|
||||
// €
|
||||
return $currencySymbol.' ' . $string;
|
||||
return $currencySymbol . ' ' . $string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +63,38 @@ if (!function_exists('getCurrencySymbol')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('getCurrencyCode')) {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function getCurrencyCode()
|
||||
{
|
||||
if (defined('FFCURRENCYCODE')) {
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
if (Cache::has('FFCURRENCYCODE')) {
|
||||
define('FFCURRENCYCODE', Cache::get('FFCURRENCYCODE'));
|
||||
|
||||
return FFCURRENCYCODE;
|
||||
}
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencies */
|
||||
$currencies = App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
|
||||
|
||||
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
|
||||
$preferences = App::make('FireflyIII\Shared\Preferences\Preferences');
|
||||
|
||||
$currencyPreference = $preferences->get('currencyPreference', 'EUR');
|
||||
$currency = $currencies->findByCode($currencyPreference->data);
|
||||
|
||||
Cache::forever('FFCURRENCYCODE', $currency->code);
|
||||
|
||||
define('FFCURRENCYCODE', $currency->code);
|
||||
|
||||
return $currency->code;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('boolstr')) {
|
||||
/**
|
||||
* @param $boolean
|
||||
|
Reference in New Issue
Block a user