Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Methods to grab the requested currency symbol. #37
James Colec2dd61e96bc7
diff --git a/app/lib/FireflyIII/Form/Form.php b/app/lib/FireflyIII/Form/Form.phpindex 0435415cd0..13bf163944 100644--- a/app/lib/FireflyIII/Form/Form.php+++ b/app/lib/FireflyIII/Form/Form.php@@ -123,7 +123,7 @@ class Form$html .= \Form::input('text', $name, $value, $options);break;case 'amount':- $html .= '<div class="input-group"><div class="input-group-addon">€</div>';+ $html .= '<div class="input-group"><div class="input-group-addon">'.getCurrencySymbol().'</div>';$html .= \Form::input('number', $name, $value, $options);$html .= '</div>';break;diff --git a/app/views/budgets/index.blade.php b/app/views/budgets/index.blade.phpindex 06edd95808..60aa1d4d03 100644--- a/app/views/budgets/index.blade.php+++ b/app/views/budgets/index.blade.php@@ -100,15 +100,15 @@<!-- budget-info-X holds the input and the euro-sign: --><span id="budget-info-{{$budget->id}}">@if($budget->currentRep->amount > $budget->spent)- <span class="text-success">€</span> <input type="number" min="0" max="{{$budgetMaximum}}" data-id="{{$budget->id}}" step="1" value="{{$budget->currentRep->amount}}" style="width:90px;color:#3c763d;" />+ <span class="text-success">{{getCurrencySymbol()}}</span> <input type="number" min="0" max="{{$budgetMaximum}}" data-id="{{$budget->id}}" step="1" value="{{$budget->currentRep->amount}}" style="width:90px;color:#3c763d;" />@else- <span class="text-danger">€</span> <input type="number" min="0" max="{{$budgetMaximum}}" data-id="{{$budget->id}}" step="1" value="{{$budget->currentRep->amount}}" style="width:90px;color:#a94442;" />+ <span class="text-danger">{{getCurrencySymbol()}}</span> <input type="number" min="0" max="{{$budgetMaximum}}" data-id="{{$budget->id}}" step="1" value="{{$budget->currentRep->amount}}" style="width:90px;color:#a94442;" />@endif</span>@else<span id="budget-description-{{$budget->id}}"><em>No budget</em></span><span id="budget-info-{{$budget->id}}">- <span class="text-success" style="display:none;">€</span> <input data-id="{{$budget->id}}" type="number" min="0" max="{{$budgetMaximum}}" step="1" value="0" style="width:50px;color:#3c763d;display:none;" />+ <span class="text-success" style="display:none;">{{getCurrencySymbol()}}</span> <input data-id="{{$budget->id}}" type="number" min="0" max="{{$budgetMaximum}}" step="1" value="0" style="width:50px;color:#3c763d;display:none;" /></span>@endif</span>diff --git a/bootstrap/start.php b/bootstrap/start.phpindex 35cc8fa52e..259599da65 100644--- a/bootstrap/start.php+++ b/bootstrap/start.php@@ -9,6 +9,7 @@ if (!function_exists('mf')) {*/function mf($amount, $coloured = true){+ $currencySymbol = getCurrencySymbol();$amount = floatval($amount);$amount = round($amount, 2);@@ -16,18 +17,51 @@ if (!function_exists('mf')) {if ($coloured === true) {if ($amount === 0.0) {- return '<span style="color:#999">€ ' . $string . '</span>';+ return '<span style="color:#999">'.$currencySymbol.' ' . $string . '</span>';}if ($amount > 0) {- return '<span class="text-success">€ ' . $string . '</span>';+ return '<span class="text-success">'.$currencySymbol.' ' . $string . '</span>';}- return '<span class="text-danger">€ ' . $string . '</span>';+ return '<span class="text-danger">'.$currencySymbol.' ' . $string . '</span>';}+ // €+ return $currencySymbol.' ' . $string;+ }+}++if (!function_exists('getCurrencySymbol')) {+ /**+ * @return string+ */+ function getCurrencySymbol()+ {+ if (defined('FFCURRENCYSYMBOL')) {+ return FFCURRENCYSYMBOL;+ }+ if (Cache::has('FFCURRENCYSYMBOL')) {+ define('FFCURRENCYSYMBOL', Cache::get('FFCURRENCYSYMBOL'));- return '€ ' . $string;+ return FFCURRENCYSYMBOL;+ }++ /** @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('FFCURRENCYSYMBOL', $currency->symbol);++ define('FFCURRENCYSYMBOL', $currency->symbol);++ return $currency->symbol;}}+if (!function_exists('boolstr')) {/*** @param $boolean