Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d59ca2b3

Von Wulf Coulmann vor mehr als 13 Jahren hinzugefügt

  • ID d59ca2b3ff5c4772ec86ac14e5867cce3f64326e
  • Vorgänger 915e943a
  • Nachfolger 9c477cc8

add number calculation in number form fields

Unterschiede anzeigen:

SL/Form.pm
1164 1164
  if (   ($myconfig->{numberformat} eq '1.000,00')
1165 1165
      || ($myconfig->{numberformat} eq '1000,00')) {
1166 1166
    $amount =~ s/\.//g;
1167
    $amount =~ s/,/\./;
1167
    $amount =~ s/,/\./g;
1168 1168
  }
1169 1169

  
1170 1170
  if ($myconfig->{numberformat} eq "1'000.00") {
......
1172 1172
  }
1173 1173

  
1174 1174
  $amount =~ s/,//g;
1175
  # make shure no code wich is not a math expression ends in eval()
1176

  
1177
  $amount =~ s/\s//g; 
1178

  
1179
  unless($amount =~ /^[-\+]?\d+\.?\d*([-\+\*\/][-\+]?\d+\.?\d*)*$/){
1180
    return 0;
1181
  }
1175 1182

  
1176 1183
  $main::lxdebug->leave_sub(2);
1177 1184

  
1178
  return ($amount * 1);
1185
  return (eval $amount) * 1 ;
1179 1186
}
1180 1187

  
1181 1188
sub round_amount {
js/common.js
48 48
  if(decpoint == thpoint) {
49 49
    return show_alert_and_focus(input_name, wrongNumberFormat);
50 50
  }
51
  if(decpoint == ',') {
52
    var decnumbers = input_name.value.split(',');
51
  var test_val = input_name.value;
52
  if(thpoint && thpoint == ','){
53
    test_val = test_val.replace(/,/g, '');
53 54
  }
54
  else {
55
    var decnumbers = input_name.value.split('.');
56
  }
57
  if(decnumbers.length == 2) {
58
    if(decnumbers[1].length > 2)  {
59
     /* return show_alert_and_focus(input_name, wrongNumberFormat); */
60
    }
55
  if(thpoint && thpoint == '.'){
56
    test_val = test_val.replace(/\./g, '');
61 57
  }
62
  else {
63
    if(decnumbers.length > 2) {
64
      return show_alert_and_focus(input_name, wrongNumberFormat);
65
    }
66
    if(!thpoint) {
67
      if(decnumbers[0].match(/\D/)) {
68
        return show_alert_and_focus(input_name, wrongNumberFormat);
69
      }
70
    }
58
  if(thpoint && decpoint == ','){
59
    test_val = test_val.replace(/,/g, '.');
71 60
  }
61

  
62
  var forbidden = test_val.match(/[^-\+\/\*\.0-9\ ]/g );
63
  if (forbidden && forbidden.length > 0 ){
64
    return show_alert_and_focus(input_name, wrongNumberFormat);
65
  } 
66

  
67
  try{ 
68
    eval(test_val);
69
  }catch(err){
70
    return show_alert_and_focus(input_name, wrongNumberFormat);
71
  } 
72

  
72 73
}
73 74

  
74 75
function check_right_date_format(input_name) {

Auch abrufbar als: Unified diff