);
%db_encoding_to_charset = map { $_->{dbencoding}, $_->{charset} } @db_encodings;
+%charset_to_db_encoding = map { $_->{charset}, $_->{dbencoding} } @db_encodings;
use constant DEFAULT_CHARSET => 'ISO-8859-15';
my $dbh = $form->dbconnect($myconfig);
my (@filter_values, $filter);
- if ($form->{"partnumber"}) {
- $filter .= qq| AND (partnumber ILIKE ?)|;
- push(@filter_values, '%' . $form->{"partnumber"} . '%');
+
+ foreach (qw(partnumber description)) {
+ next unless $form->{$_};
+
+ $filter .= qq| AND ($_ ILIKE ?)|;
+ push @filter_values, '%' . $form->{$_} . '%';
}
- if ($form->{"description"}) {
- $filter .= qq| AND (description ILIKE ?)|;
- push(@filter_values, '%' . $form->{"description"} . '%');
+
+ if ($form->{no_assemblies}) {
+ $filter .= qq| AND (NOT COALESCE(assembly, 'f'))|;
+ }
+
+ if ($form->{no_services}) {
+ $filter .= qq| AND (COALESCE(inventory_accno_id, 0) > 0)|;
}
+
substr($filter, 1, 3) = "WHERE" if ($filter);
$order_by =~ s/[^a-zA-Z_]//g;
my $params = shift;
foreach my $key (@_) {
- if (!defined $params->{$key}) {
+ if ((ref $key eq '') && !defined $params->{$key}) {
my $subroutine = (caller(1))[3];
$main::form->error($main::locale->text("Missing parameter #1 in call to sub #2.", $key, $subroutine));
+
+ } elsif (ref $key eq 'ARRAY') {
+ my $found = 0;
+ foreach $subkey (@{ $key }) {
+ if (defined $params->{$subkey}) {
+ $found = 1;
+ last;
+ }
+ }
+
+ if (!$found) {
+ my $subroutine = (caller(1))[3];
+ $main::form->error($main::locale->text("Missing parameter (at least one of #1) in call to sub #2.", join(', ', @{ $key }), $subroutine));
+ }
}
}
}
my $params = shift;
foreach my $key (@_) {
- if (!exists $params->{$key}) {
+ if ((ref $key eq '') && !exists $params->{$key}) {
my $subroutine = (caller(1))[3];
$main::form->error($main::locale->text("Missing parameter #1 in call to sub #2.", $key, $subroutine));
+
+ } elsif (ref $key eq 'ARRAY') {
+ my $found = 0;
+ foreach $subkey (@{ $key }) {
+ if (exists $params->{$subkey}) {
+ $found = 1;
+ last;
+ }
+ }
+
+ if (!$found) {
+ my $subroutine = (caller(1))[3];
+ $main::form->error($main::locale->text("Missing parameter (at least one of #1) in call to sub #2.", join(', ', @{ $key }), $subroutine));
+ }
}
}
}