Bug 16816: Do not copy parameters used when duplicating a report
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / includes / format_price.inc
1 [% USE Koha %]
2 <script type="text/javascript">
3     [%# This should use the Format template plugin, but not pushed yet %]
4     [% IF Koha.Preference("CurrencyFormat") == 'FR' %]
5         var default_value = {
6             thousands_sep: ' ',
7             decimal_point: ',',
8             decimal_digits: 2
9         };
10     [% ELSIF Koha.Preference("CurrencyFormat") == 'CH' %]
11         var default_value = {
12             thousands_sep: '\'',
13             decimal_point: '.',
14             decimal_digits: 2
15         };
16     [% ELSE %]
17         var default_value = {
18             thousands_sep: ',',
19             decimal_point: '.',
20             decimal_digits: 2
21         };
22
23     [% END %]
24     Number.prototype.format_price = function( value, params ) {
25         params = params == undefined ? {} : params;
26         var thousands_sep = params.thousands_sep == undefined ? default_value.thousands_sep : params.thousands_sep,
27             decimal_point = params.decimal_point == undefined ? default_value.decimal_point : params.decimal_point,
28             //symbol = params.symbol == undefined ? '$' : params.symbol, // Not implemented yet
29             decimal_digits = params.decimal_digits == undefined ? default_value.decimal_digits : params.decimal_digits;
30
31             var re = '\\d(?=(\\d{' + 3 + '})+' + '\\D' + ')', value = this.toFixed(decimal_digits);
32             return value.replace('.', decimal_point).replace(new RegExp(re, 'g'), '$&' + thousands_sep);
33     }
34 </script>