From b4078ad95b5f601f9ec15b478ea6a7cc5705fb26 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 6 May 2009 13:00:42 +0000 Subject: [PATCH] =?utf8?q?Codevereinfachungen.=20Bugfixes=20f=C3=BCr=20die?= =?utf8?q?=20falsche=20Verwendung=20der=20logischen=20SQL-Operatoren=20bez?= =?utf8?q?=C3=BCglich=20ihrer=20Rangfolge.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- bin/mozilla/am.pl | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index f1b339843..fafe65684 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -2837,23 +2837,14 @@ sub show_am_history { "Mahnungsnummer" => "dunning_id" ); - my $restriction; - my $tempNo = 0; - foreach(split(/\,/, $form->{einschraenkungen})) { - if($tempNo == 0) { - $restriction .= " AND addition = '" . $_ . "'"; - $tempNo = 1; - } else { - $restriction .= " OR addition = '" . $_ . "'"; - } - } + my $dbh = $form->dbconnect(\%myconfig); - $restriction .= qq| AND h.itime::date >= | . conv_dateq($form->{fromdate}) if $form->{fromdate}; - $restriction .= qq| AND h.itime::date <= | . conv_dateq($form->{todate}) if $form->{todate}; - $restriction .= qq| AND employee_id = | . $form->{mitarbeiter} if $form->{mitarbeiter} =~ m/^\d+$/; - $restriction .= qq| AND employee_id = | . get_employee_id($form->{mitarbeiter}, $dbh) if $form->{mitarbeiter}; + my $restriction = qq| AND (| . join(' OR ', map { " addition = " . $dbh->quote($_) } split(m/\,/, $form->{einschraenkungen})) . qq|)| if $form->{einschraenkungen}; + $restriction .= qq| AND h.itime::date >= | . conv_dateq($form->{fromdate}) if $form->{fromdate}; + $restriction .= qq| AND h.itime::date <= | . conv_dateq($form->{todate}) if $form->{todate}; + $restriction .= qq| AND employee_id = | . $form->{mitarbeiter} if $form->{mitarbeiter} =~ m/^\d+$/; + $restriction .= qq| AND employee_id = | . get_employee_id($form->{mitarbeiter}, $dbh) if $form->{mitarbeiter}; - my $dbh = $form->dbconnect(\%myconfig); my $query = qq|SELECT trans_id AS id FROM history_erp | . ( $form->{'searchid'} ? qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'| : qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|); -- 2.20.1