Revision b0e12c91
Von Andreas Rudin vor etwa 5 Jahren hinzugefügt
templates/webpages/generic/calculate_qty.html | ||
---|---|---|
38 | 38 |
var [% row.name %] = kivi.parse_amount($('#calc_qty_form_id #[% row.name %]').val()); |
39 | 39 |
[%- END %] |
40 | 40 |
var result = [% formel %]; |
41 |
result = number_format(result, 2, "[% MYCONFIG.numberformat %]");
|
|
41 |
result = kivi.format_amount(result, 2);
|
|
42 | 42 |
if (document.CalcQtyForm.input_id.value) { |
43 | 43 |
document.getElementById(document.CalcQtyForm.input_id.value).value = result; |
44 | 44 |
} else { |
... | ... | |
47 | 47 |
$('#calc_qty_dialog').dialog('close'); |
48 | 48 |
} |
49 | 49 |
|
50 |
function number_format(number, precision, numberformat) { |
|
51 |
number = Math.round( number * Math.pow(10, precision) ) / Math.pow(10, precision); |
|
52 |
var nf = numberformat.replace(/\d/g, '').split('').reverse(); |
|
53 |
var sep = nf[0]; |
|
54 |
var th_sep = nf[1]; |
|
55 |
|
|
56 |
str_number = number+""; |
|
57 |
arr_int = str_number.split("."); |
|
58 |
if(!arr_int[0]) arr_int[0] = "0"; |
|
59 |
if(!arr_int[1]) arr_int[1] = ""; |
|
60 |
if(arr_int[1].length < precision) { |
|
61 |
nachkomma = arr_int[1]; |
|
62 |
for(i=arr_int[1].length+1; i <= precision; i++) { |
|
63 |
nachkomma += "0"; |
|
64 |
} |
|
65 |
arr_int[1] = nachkomma; |
|
66 |
} |
|
67 |
if(th_sep != "" && arr_int[0].length > 3) { |
|
68 |
raw_arr_int = arr_int[0]; |
|
69 |
arr_int[0] = ""; |
|
70 |
for(j = 3; j < raw_arr_int.length ; j+=3) { |
|
71 |
arr_int[0] = th_sep + raw_arr_int.slice(raw_arr_int.length - j, raw_arr_int.length - j + 3) + arr_int[0] + ""; |
|
72 |
} |
|
73 |
str_first = raw_arr_int.substr(0, (raw_arr_int.length % 3 == 0) ? 3 : (raw_arr_int.length % 3)); |
|
74 |
arr_int[0] = str_first + arr_int[0]; |
|
75 |
} |
|
76 |
return arr_int[0] + sep + arr_int[1]; |
|
77 |
} |
|
78 | 50 |
</script> |
Auch abrufbar als: Unified diff
In calculate_qty.html number_format() durch kivi.format_amount() ersetzt
function number_format() gelöscht, da nicht mehr nötig