2015-03-16 22:45:25 +01:00
|
|
|
<script type="text/javascript">
|
|
|
|
|
2015-03-30 21:45:10 +02:00
|
|
|
var currencies = {!! \Cache::get('currencies') !!};
|
2015-03-16 22:45:25 +01:00
|
|
|
var currencyMap = {};
|
|
|
|
for (var i=0; i<currencies.length; i++) {
|
|
|
|
var currency = currencies[i];
|
|
|
|
currencyMap[currency.id] = currency;
|
2015-05-22 09:22:24 +02:00
|
|
|
}
|
|
|
|
|
2015-03-16 22:45:25 +01:00
|
|
|
var NINJA = NINJA || {};
|
|
|
|
@if (Auth::check())
|
|
|
|
NINJA.primaryColor = "{{ Auth::user()->account->primary_color }}";
|
|
|
|
NINJA.secondaryColor = "{{ Auth::user()->account->secondary_color }}";
|
2015-05-22 09:22:24 +02:00
|
|
|
NINJA.fontSize = {{ Auth::user()->account->font_size ?: DEFAULT_FONT_SIZE }};
|
2015-10-14 22:56:17 +02:00
|
|
|
@else
|
|
|
|
NINJA.fontSize = {{ DEFAULT_FONT_SIZE }};
|
2015-03-16 22:45:25 +01:00
|
|
|
@endif
|
2015-05-22 09:22:24 +02:00
|
|
|
|
2015-03-16 22:45:25 +01:00
|
|
|
NINJA.parseFloat = function(str) {
|
|
|
|
if (!str) return '';
|
|
|
|
str = (str+'').replace(/[^0-9\.\-]/g, '');
|
|
|
|
return window.parseFloat(str);
|
|
|
|
}
|
2015-05-22 09:22:24 +02:00
|
|
|
|
2015-03-16 22:45:25 +01:00
|
|
|
function formatMoney(value, currency_id, hide_symbol) {
|
|
|
|
value = NINJA.parseFloat(value);
|
2015-03-26 04:48:41 +01:00
|
|
|
if (!currency_id) currency_id = {{ Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY) }};
|
2015-03-16 22:45:25 +01:00
|
|
|
var currency = currencyMap[currency_id];
|
|
|
|
return accounting.formatMoney(value, hide_symbol ? '' : currency.symbol, currency.precision, currency.thousand_separator, currency.decimal_separator);
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|