Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ff65252d

Von Andreas Rudin vor mehr als 4 Jahren hinzugefügt

parse_amount ersetzt durch kivi.parse_amount, " statt ' bei Zahlenformat

1) Unnoetig doppelte Funktion gelöscht
2) [% MYCONFIG.numberformat %] darf nicht in einfache Hochkommas gesetzt
werden, da dies beim Zahlenformat 1'000.00 zu Fehlern führt.

Unterschiede anzeigen:

templates/webpages/generic/calculate_qty.html
35 35
 <script type="text/javascript">
36 36
   function calculate_qty() {
37 37
[%- FOREACH row = VARIABLES %]
38
     var [% row.name %] = parse_amount('[% MYCONFIG.numberformat %]', $('#calc_qty_form_id #[% row.name %]').val());
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 = number_format(result, 2, "[% MYCONFIG.numberformat %]");
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 parse_amount(numberformat, amount) {
51
     if (numberformat == '1.000,00' || numberformat == '1000,00')
52
       amount = amount.replace(/\./g, "").replace(/,/, ".");
53
     if (numberformat == "1'000.00")
54
       amount = amount.replace(/\'/g, '');
55
     return amount.replace(/,/g, '');
56
   }
57

  
58 50
   function number_format(number, precision, numberformat) {
59 51
     number = Math.round( number * Math.pow(10, precision) ) / Math.pow(10, precision);
60 52
     var nf     = numberformat.replace(/\d/g, '').split('').reverse();

Auch abrufbar als: Unified diff