projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
doc/ Trigram Erweiterung als Musskriterium für das Upgrade genannt
[kivitendo-erp.git]
/
SL
/
CT.pm
diff --git
a/SL/CT.pm
b/SL/CT.pm
index
ded4577
..
57ee031
100644
(file)
--- a/
SL/CT.pm
+++ b/
SL/CT.pm
@@
-25,7
+25,8
@@
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
#======================================================================
#
# backend code for customers and vendors
#======================================================================
#
# backend code for customers and vendors
@@
-40,6
+41,8
@@
package CT;
use SL::Common;
use SL::CVar;
use SL::DBUtils;
use SL::Common;
use SL::CVar;
use SL::DBUtils;
+use SL::DB;
+use Text::ParseWords;
use strict;
use strict;
@@
-103,19
+106,19
@@
sub search {
if ($form->{"${cv}number"}) {
$where .= " AND ct.${cv}number ILIKE ?";
if ($form->{"${cv}number"}) {
$where .= " AND ct.${cv}number ILIKE ?";
- push(@values,
'%' . $form->{"${cv}number"} . '%'
);
+ push(@values,
like($form->{"${cv}number"})
);
}
foreach my $key (qw(name contact email)) {
if ($form->{$key}) {
$where .= " AND ct.$key ILIKE ?";
}
foreach my $key (qw(name contact email)) {
if ($form->{$key}) {
$where .= " AND ct.$key ILIKE ?";
- push(@values,
'%' . $form->{$key} . '%'
);
+ push(@values,
like($form->{$key})
);
}
}
if ($form->{cp_name}) {
$where .= " AND ct.id IN (SELECT cp_cv_id FROM contacts WHERE lower(cp_name) LIKE lower(?))";
}
}
if ($form->{cp_name}) {
$where .= " AND ct.id IN (SELECT cp_cv_id FROM contacts WHERE lower(cp_name) LIKE lower(?))";
- push @values,
'%' . $form->{cp_name} . '%'
;
+ push @values,
like($form->{cp_name})
;
}
if ($form->{addr_street}) {
}
if ($form->{addr_street}) {
@@
-126,7
+129,7
@@
sub search {
qq| WHERE (sc.module = 'CT') | .
qq| AND (sc.shiptostreet ILIKE ?) | .
qq| ))) |;
qq| WHERE (sc.module = 'CT') | .
qq| AND (sc.shiptostreet ILIKE ?) | .
qq| ))) |;
- push @values, (
'%' . $form->{addr_street} . '%'
) x 2;
+ push @values, (
like($form->{addr_street})
) x 2;
}
if ($form->{addr_zipcode}) {
}
if ($form->{addr_zipcode}) {
@@
-137,7
+140,7
@@
sub search {
qq| WHERE (sc.module = 'CT') | .
qq| AND (sc.shiptozipcode ILIKE ?) | .
qq| ))) |;
qq| WHERE (sc.module = 'CT') | .
qq| AND (sc.shiptozipcode ILIKE ?) | .
qq| ))) |;
- push @values, (
'%' . $form->{addr_zipcode} . '%'
) x 2;
+ push @values, (
like($form->{addr_zipcode})
) x 2;
}
if ($form->{addr_city}) {
}
if ($form->{addr_city}) {
@@
-150,7
+153,7
@@
sub search {
AND (lower(sc.shiptocity) LIKE lower(?))
))
)";
AND (lower(sc.shiptocity) LIKE lower(?))
))
)";
- push @values, (
'%' . $form->{addr_city} . '%'
) x 2;
+ push @values, (
like($form->{addr_city})
) x 2;
}
if ($form->{addr_country}) {
}
if ($form->{addr_country}) {
@@
-163,7
+166,7
@@
sub search {
AND (lower(so.shiptocountry) LIKE lower(?))
))
)";
AND (lower(so.shiptocountry) LIKE lower(?))
))
)";
- push @values, (
'%' . $form->{addr_country} . '%'
) x 2;
+ push @values, (
like($form->{addr_country})
) x 2;
}
if ($form->{addr_gln}) {
}
if ($form->{addr_gln}) {
@@
-176,7
+179,7
@@
sub search {
AND (lower(so.shiptogln) LIKE lower(?))
))
)";
AND (lower(so.shiptogln) LIKE lower(?))
))
)";
- push @values, (
'%' . $form->{addr_gln} . '%'
) x 2;
+ push @values, (
like($form->{addr_gln})
) x 2;
}
if ( $form->{status} eq 'orphaned' ) {
}
if ( $form->{status} eq 'orphaned' ) {
@@
-224,6
+227,15
@@
sub search {
push @values, conv_date($form->{insertdateto});
}
push @values, conv_date($form->{insertdateto});
}
+ if ($form->{all}) {
+ my @tokens = parse_line('\s+', 0, $form->{all});
+ $where .= qq| AND (
+ ct.${cv}number ILIKE ? OR
+ ct.name ILIKE ?
+ )| for @tokens;
+ push @values, ("%$_%")x2 for @tokens;
+ }
+
# Nur Kunden finden, bei denen ich selber der Verkäufer bin
# Gilt nicht für Lieferanten
if ($cv eq 'customer' && !$main::auth->assert('customer_vendor_all_edit', 1)) {
# Nur Kunden finden, bei denen ich selber der Verkäufer bin
# Gilt nicht für Lieferanten
if ($cv eq 'customer' && !$main::auth->assert('customer_vendor_all_edit', 1)) {
@@
-241,7
+253,7
@@
sub search {
}
my $pg_select = $form->{l_pricegroup} ? qq|, pg.pricegroup as pricegroup | : '';
}
my $pg_select = $form->{l_pricegroup} ? qq|, pg.pricegroup as pricegroup | : '';
- my $pg_join = $form->{l_pricegroup} ? qq|LEFT JOIN pricegroup pg ON (ct.
klass
= pg.id) | : '';
+ my $pg_join = $form->{l_pricegroup} ? qq|LEFT JOIN pricegroup pg ON (ct.
pricegroup_id
= pg.id) | : '';
my $query =
qq|SELECT ct.*, ct.itime::DATE AS insertdate, b.description AS business, e.name as salesman, | .
qq| pt.description as payment | .
my $query =
qq|SELECT ct.*, ct.itime::DATE AS insertdate, b.description AS business, e.name as salesman, | .
qq| pt.description as payment | .
@@
-331,7
+343,7
@@
sub get_contact {
die 'Missing argument: cp_id' unless $::form->{cp_id};
die 'Missing argument: cp_id' unless $::form->{cp_id};
- my $dbh =
$form->dbconnect($myconfig)
;
+ my $dbh =
SL::DB->client->dbh
;
my $query =
qq|SELECT * FROM contacts c | .
qq|WHERE cp_id = ? ORDER BY cp_id limit 1|;
my $query =
qq|SELECT * FROM contacts c | .
qq|WHERE cp_id = ? ORDER BY cp_id limit 1|;
@@
-349,7
+361,6
@@
sub get_contact {
($form->{cp_used}) = selectfirst_array_query($form, $dbh, $query, ($form->{cp_id})x2);
$sth->finish;
($form->{cp_used}) = selectfirst_array_query($form, $dbh, $query, ($form->{cp_id})x2);
$sth->finish;
- $dbh->disconnect;
$main::lxdebug->leave_sub();
}
$main::lxdebug->leave_sub();
}
@@
-421,7
+432,7
@@
sub search_contacts {
'cp.cp_name ILIKE ?',
'cp.cp_givenname ILIKE ?',
'cp.cp_email ILIKE ?';
'cp.cp_name ILIKE ?',
'cp.cp_givenname ILIKE ?',
'cp.cp_email ILIKE ?';
- push @values, (
'%' . $params{search_term} . '%'
) x 3;
+ push @values, (
like($params{search_term})
) x 3;
if (($params{search_term} =~ m/\d/) && ($params{search_term} !~ m/[^\d \(\)+\-]/)) {
my $number = $params{search_term};
if (($params{search_term} =~ m/\d/) && ($params{search_term} !~ m/[^\d \(\)+\-]/)) {
my $number = $params{search_term};