Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 88dea78e

Von Moritz Bunkus vor mehr als 8 Jahren hinzugefügt

  • ID 88dea78ecdb77761f71c5016ca97e53b2d55d9d3
  • Vorgänger abc7a54c
  • Nachfolger 061f4d6d

Einkaufs-/Verkaufssuchen: bei Textfeldern führende/anhängende Whitespaces entfernen

Unterschiede anzeigen:

SL/AP.pm
39 39
use SL::IO;
40 40
use SL::MoreCommon;
41 41
use SL::DB::Default;
42
use SL::Util qw(trim);
42 43
use Data::Dumper;
43 44

  
44 45
use strict;
......
457 458
  }
458 459
  if ($form->{"cp_name"}) {
459 460
    $where .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
460
    push(@values, ('%' . $form->{"cp_name"} . '%')x2);
461
    push(@values, ('%' . trim($form->{"cp_name"}) . '%')x2);
461 462
  }
462 463
  if ($form->{department}) {
463 464
    # ähnlich wie commit 0bbfb33b6aa8e38bb6c81d1684ab7d08e5b5c5af abteilung
......
493 494

  
494 495
  if ($form->{transdatefrom}) {
495 496
    $where .= " AND a.transdate >= ?";
496
    push(@values, $form->{transdatefrom});
497
    push(@values, trim($form->{transdatefrom}));
497 498
  }
498 499
  if ($form->{transdateto}) {
499 500
    $where .= " AND a.transdate <= ?";
500
    push(@values, $form->{transdateto});
501
    push(@values, trim($form->{transdateto}));
501 502
  }
502 503
  if ($form->{open} || $form->{closed}) {
503 504
    unless ($form->{open} && $form->{closed}) {
SL/AR.pm
41 41
use SL::MoreCommon;
42 42
use SL::DB::Default;
43 43
use SL::TransNumber;
44
use SL::Util qw(trim);
44 45

  
45 46
use strict;
46 47

  
......
499 500

  
500 501
  if ($form->{customernumber}) {
501 502
    $where .= " AND c.customernumber = ?";
502
    push(@values, $form->{customernumber});
503
    push(@values, trim($form->{customernumber}));
503 504
  }
504 505
  if ($form->{customer_id}) {
505 506
    $where .= " AND a.customer_id = ?";
......
510 511
  }
511 512
  if ($form->{"cp_name"}) {
512 513
    $where .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
513
    push(@values, ('%' . $form->{"cp_name"} . '%')x2);
514
    push(@values, ('%' . trim($form->{"cp_name"}) . '%')x2);
514 515
  }
515 516
  if ($form->{business_id}) {
516 517
    my $business_id = $form->{business_id};
......
523 524
    push(@values, $department_id);
524 525
  }
525 526
  if ($form->{department}) {
526
    my $department = "%" . $form->{department} . "%";
527
    my $department = "%" . trim($form->{department}) . "%";
527 528
    $where .= " AND d.description ILIKE ?";
528 529
    push(@values, $department);
529 530
  }
......
547 548

  
548 549
  if ($form->{transdatefrom}) {
549 550
    $where .= " AND a.transdate >= ?";
550
    push(@values, $form->{transdatefrom});
551
    push(@values, trim($form->{transdatefrom}));
551 552
  }
552 553
  if ($form->{transdateto}) {
553 554
    $where .= " AND a.transdate <= ?";
554
    push(@values, $form->{transdateto});
555
    push(@values, trim($form->{transdateto}));
555 556
  }
556 557
  if ($form->{duedatefrom}) {
557 558
    $where .= " AND a.duedate >= ?";
558
    push(@values, $form->{duedatefrom});
559
    push(@values, trim($form->{duedatefrom}));
559 560
  }
560 561
  if ($form->{duedateto}) {
561 562
    $where .= " AND a.duedate <= ?";
562
    push(@values, $form->{duedateto});
563
    push(@values, trim($form->{duedateto}));
563 564
  }
564 565
  if ($form->{open} || $form->{closed}) {
565 566
    unless ($form->{open} && $form->{closed}) {
SL/CVar.pm
9 9

  
10 10
use SL::DBUtils;
11 11
use SL::MoreCommon qw(listify);
12
use SL::Util qw(trim);
12 13

  
13 14
sub get_configs {
14 15
  $main::lxdebug->enter_sub();
......
355 356
      next unless ($params{filter}->{$name});
356 357

  
357 358
      push @sub_where,  qq|cvar.text_value ILIKE ?|;
358
      push @sub_values, '%' . $params{filter}->{$name} . '%'
359
      push @sub_values, '%' . trim($params{filter}->{$name}) . '%'
359 360

  
360 361
    } elsif ($config->{type} eq 'select') {
361 362
      next unless ($params{filter}->{$name});
......
406 407
      }
407 408

  
408 409
      push @sub_where,  qq|cvar.number_value $op ?|;
409
      push @sub_values, $form->parse_amount($myconfig, $params{filter}->{$name});
410
      push @sub_values, $form->parse_amount($myconfig, trim($params{filter}->{$name}));
410 411

  
411 412
    } elsif ($config->{type} eq 'bool') {
412 413
      next unless ($params{filter}->{$name});
......
418 419

  
419 420
      my $table = $config->{type};
420 421
      push @sub_where, qq|cvar.number_value * 1 IN (SELECT id FROM $table WHERE name ILIKE ?)|;
421
      push @sub_values, "%$params{filter}->{$name}%";
422
      push @sub_values, "%" . trim($params{filter}->{$name}) . "%";
422 423
    } elsif ($config->{type} eq 'part') {
423 424
      next unless $params{filter}->{$name};
424 425

  
425 426
      push @sub_where, qq|cvar.number_value * 1 IN (SELECT id FROM parts WHERE partnumber ILIKE ?)|;
426
      push @sub_values, "%$params{filter}->{$name}%";
427
      push @sub_values, "%" . trim($params{filter}->{$name}) . "%";
427 428
    }
428 429

  
429 430
    if (@sub_where) {
SL/DBUtils.pm
1 1
package SL::DBUtils;
2 2

  
3
use SL::Util qw(trim);
4

  
3 5
require Exporter;
4 6
our @ISA = qw(Exporter);
5 7

  
......
30 32

  
31 33
sub conv_date {
32 34
  my ($value) = @_;
33
  return (defined($value) && "$value" ne "") ? $value : undef;
35
  return undef if !defined $value;
36
  $value = trim($value);
37
  return $value eq "" ? undef : $value;
34 38
}
35 39

  
36 40
sub conv_dateq {
SL/DN.pm
45 45
use SL::DB::Printer;
46 46
use SL::DB::Language;
47 47
use SL::TransNumber;
48
use SL::Util qw(trim);
48 49

  
49 50
use strict;
50 51

  
......
491 492

  
492 493
  } elsif ($form->{customer}) {
493 494
    $where .= qq| AND (ct.name ILIKE ?)|;
494
    push(@values, '%' . $form->{customer} . '%');
495
    push(@values, '%' . trim($form->{customer}) . '%');
495 496
  }
496 497

  
497 498
  my %columns = (
......
503 504
  foreach my $key (keys(%columns)) {
504 505
    next unless ($form->{$key});
505 506
    $where .= qq| AND $columns{$key} ILIKE ?|;
506
    push(@values, '%' . $form->{$key} . '%');
507
    push(@values, '%' . trim($form->{$key}) . '%');
507 508
  }
508 509

  
509 510
  if ($form->{dunning_level}) {
......
514 515
  $form->{minamount} = $form->parse_amount($myconfig,$form->{minamount});
515 516
  if ($form->{minamount}) {
516 517
    $where .= qq| AND ((a.amount - a.paid) > ?) |;
517
    push(@values, $form->{minamount});
518
    push(@values, trim($form->{minamount}));
518 519
  }
519 520

  
520 521
  my $query =
SL/DO.pm
46 46
use SL::RecordLinks;
47 47
use SL::IC;
48 48
use SL::TransNumber;
49
use SL::Util qw(trim);
49 50

  
50 51
use strict;
51 52

  
......
110 111

  
111 112
  } elsif ($form->{$vc}) {
112 113
    push @where,  qq|ct.name ILIKE ?|;
113
    push @values, '%' . $form->{$vc} . '%';
114
    push @values, '%' . trim($form->{$vc}) . '%';
114 115
  }
115 116

  
116 117
  if ($form->{"cp_name"}) {
117 118
    push @where, "(cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
118
    push @values, ('%' . $form->{"cp_name"} . '%')x2;
119
    push @values, ('%' . trim($form->{"cp_name"}) . '%')x2;
119 120
  }
120 121

  
121 122
  foreach my $item (qw(employee_id salesman_id)) {
......
131 132
  foreach my $item (qw(donumber ordnumber cusordnumber transaction_description)) {
132 133
    next unless ($form->{$item});
133 134
    push @where,  qq|dord.$item ILIKE ?|;
134
    push @values, '%' . $form->{$item} . '%';
135
    push @values, '%' . trim($form->{$item}) . '%';
135 136
  }
136 137

  
137 138
  if (($form->{open} || $form->{closed}) &&
......
146 147

  
147 148
  if ($form->{serialnumber}) {
148 149
    push @where, 'dord.id IN (SELECT doi.delivery_order_id FROM delivery_order_items doi WHERE doi.serialnumber LIKE ?)';
149
    push @values, '%' . $form->{serialnumber} . '%';
150
    push @values, '%' . trim($form->{serialnumber}) . '%';
150 151
  }
151 152

  
152 153
  if($form->{transdatefrom}) {
SL/Form.pm
75 75
use SL::Request;
76 76
use SL::Template;
77 77
use SL::User;
78
use SL::Util;
78 79
use SL::X;
79 80
use Template;
80 81
use URI;
......
3001 3002
}
3002 3003

  
3003 3004
sub like {
3004
  $main::lxdebug->enter_sub();
3005

  
3006 3005
  my ($self, $string) = @_;
3007 3006

  
3008
  if ($string !~ /%/) {
3009
    $string = "%$string%";
3010
  }
3011

  
3012
  $string =~ s/\'/\'\'/g;
3013

  
3014
  $main::lxdebug->leave_sub();
3015

  
3016
  return $string;
3007
  return "%" . SL::Util::trim($string // '') . "%";
3017 3008
}
3018 3009

  
3019 3010
sub redo_rows {
SL/OE.pm
50 50
use SL::HTML::Restrict;
51 51
use SL::IC;
52 52
use SL::TransNumber;
53
use SL::Util qw(trim);
53 54
use Text::ParseWords;
54 55

  
55 56
use strict;
......
172 173

  
173 174
  } elsif ($form->{$vc}) {
174 175
    $query .= " AND ct.name ILIKE ?";
175
    push(@values, '%' . $form->{$vc} . '%');
176
    push(@values, '%' . trim($form->{$vc}) . '%');
176 177
  }
177 178

  
178 179
  if ($form->{"cp_name"}) {
179 180
    $query .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
180
    push(@values, ('%' . $form->{"cp_name"} . '%')x2);
181
    push(@values, ('%' . trim($form->{"cp_name"}) . '%')x2);
181 182
  }
182 183

  
183 184
  if (!$main::auth->assert('sales_all_edit', 1)) {
......
208 209

  
209 210
  if ($form->{$ordnumber}) {
210 211
    $query .= qq| AND o.$ordnumber ILIKE ?|;
211
    push(@values, '%' . $form->{$ordnumber} . '%');
212
    push(@values, '%' . trim($form->{$ordnumber}) . '%');
212 213
  }
213 214

  
214 215
  if ($form->{cusordnumber}) {
215 216
    $query .= qq| AND o.cusordnumber ILIKE ?|;
216
    push(@values, '%' . $form->{cusordnumber} . '%');
217
    push(@values, '%' . trim($form->{cusordnumber}) . '%');
217 218
  }
218 219

  
219 220
  if($form->{transdatefrom}) {
......
248 249

  
249 250
  if ($form->{shippingpoint}) {
250 251
    $query .= qq| AND o.shippingpoint ILIKE ?|;
251
    push(@values, '%' . $form->{shippingpoint} . '%');
252
    push(@values, '%' . trim($form->{shippingpoint}) . '%');
252 253
  }
253 254

  
254 255
  if ($form->{taxzone_id} ne '') { # taxzone_id could be 0
......
258 259

  
259 260
  if ($form->{transaction_description}) {
260 261
    $query .= qq| AND o.transaction_description ILIKE ?|;
261
    push(@values, '%' . $form->{transaction_description} . '%');
262
    push(@values, '%' . trim($form->{transaction_description}) . '%');
262 263
  }
263 264

  
264 265
  if ($form->{periodic_invoices_active} ne $form->{periodic_invoices_inactive}) {
......
273 274
  if (($form->{order_probability_value} || '') ne '') {
274 275
    my $op  = $form->{order_probability_value} eq 'le' ? '<=' : '>=';
275 276
    $query .= qq| AND (o.order_probability ${op} ?)|;
276
    push @values, $form->{order_probability_value};
277
    push @values, trim($form->{order_probability_value});
277 278
  }
278 279

  
279 280
  if ($form->{expected_billing_date_from}) {

Auch abrufbar als: Unified diff