Lines 157-173
if (@patron_attr_filter_loop) {
Link Here
|
157 |
# too resource intensive, MySQL can be used to do the filtering, i.e. rewire the |
157 |
# too resource intensive, MySQL can be used to do the filtering, i.e. rewire the |
158 |
# SQL below to select only those attribute values that match the filters. |
158 |
# SQL below to select only those attribute values that match the filters. |
159 |
|
159 |
|
160 |
my $sql = q(SELECT borrowernumber AS bn, b.code, attribute AS val, category AS avcategory, lib AS avdescription |
160 |
my $sql = q{ |
|
|
161 |
SELECT b.borrowernumber AS bn, b.code AS attrcode, b.attribute AS attrval, a.lib AS avdescription |
161 |
FROM borrower_attributes b |
162 |
FROM borrower_attributes b |
162 |
JOIN borrower_attribute_types bt ON (b.code = bt.code) |
163 |
JOIN borrower_attribute_types bt ON (b.code = bt.code) |
163 |
LEFT JOIN authorised_values a ON (a.category = bt.authorised_value_category AND a.authorised_value = b.attribute)); |
164 |
LEFT JOIN authorised_values a ON (a.category = bt.authorised_value_category AND a.authorised_value = b.attribute) |
|
|
165 |
}; |
164 |
my $sth = $dbh->prepare($sql); |
166 |
my $sth = $dbh->prepare($sql); |
165 |
$sth->execute(); |
167 |
$sth->execute(); |
166 |
while (my $row = $sth->fetchrow_hashref) { |
168 |
while (my $row = $sth->fetchrow_hashref) { |
167 |
my $pattrs = $borrowernumber_to_attributes{$row->{bn}} ||= { }; |
169 |
my $pattrs = $borrowernumber_to_attributes{$row->{bn}} ||= { }; |
168 |
push @{ $pattrs->{$row->{code}} }, [ |
170 |
push @{ $pattrs->{$row->{attrcode}} }, [ |
169 |
$row->{val}, |
171 |
$row->{attrval}, |
170 |
defined $row->{avdescription} ? $row->{avdescription} : $row->{val}, |
172 |
defined $row->{avdescription} ? $row->{avdescription} : $row->{attrval}, |
171 |
]; |
173 |
]; |
172 |
} |
174 |
} |
173 |
|
175 |
|
Lines 178-185
if (@patron_attr_filter_loop) {
Link Here
|
178 |
# discard patrons that do not match (case insensitive) at least one of each attribute filter value |
180 |
# discard patrons that do not match (case insensitive) at least one of each attribute filter value |
179 |
my $discard = 1; |
181 |
my $discard = 1; |
180 |
for my $attrval (map { lc $_ } @{ $cgi_attrcode_to_attrvalues{$code} }) { |
182 |
for my $attrval (map { lc $_ } @{ $cgi_attrcode_to_attrvalues{$code} }) { |
181 |
## if (grep { $attrval eq lc($_->[0]) } @{ $pattrs->{$code} }) |
183 |
if (grep { $attrval eq lc($_->[0]) } @{ $pattrs->{$code} }) { |
182 |
if (grep { $attrval eq lc($_->[1]) } @{ $pattrs->{$code} }) { |
|
|
183 |
$discard = 0; |
184 |
$discard = 0; |
184 |
last; |
185 |
last; |
185 |
} |
186 |
} |
186 |
- |
|
|