From a09710703090df303790653f20b65d2e99500f77 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 23 Dec 2013 10:43:52 +0100 Subject: [PATCH] Bug 10855: search with exact match if linked to an AV If a field is linked to an AV, the search should be an exact match. --- Koha/AdditionalField.pm | 2 +- .../intranet-tmpl/prog/en/modules/serials/serials-search.tt | 4 ++-- serials/serials-search.pl | 9 ++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Koha/AdditionalField.pm b/Koha/AdditionalField.pm index 2f3f44b..55f041b 100644 --- a/Koha/AdditionalField.pm +++ b/Koha/AdditionalField.pm @@ -230,7 +230,7 @@ sub get_matching_record_ids { ) AS values$i |; $subquery .= ' USING (record_id)' if $i > 1; push @subqueries, $subquery; - push @args, $field->{name}, $tablename, ( $exact_match ? $field->{value} : "%$field->{value}%" ); + push @args, $field->{name}, $tablename, ( $exact_match or $field->{authorised_value_category} ? $field->{value} : "%$field->{value}%" ); } $query .= join( ' LEFT JOIN ', @subqueries ) . ' WHERE 1'; for my $j ( 1 .. $i ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt index 61c031e..b581466 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt @@ -425,7 +425,7 @@ [% ELSE %] - + [% END %] [% END %] diff --git a/serials/serials-search.pl b/serials/serials-search.pl index b612c70..eb3b74e 100755 --- a/serials/serials-search.pl +++ b/serials/serials-search.pl @@ -82,8 +82,11 @@ my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription my $additional_field_filters; for my $field ( @$additional_fields ) { my $filter_value = $query->param('additional_field_' . $field->{id} . '_filter'); - if ( defined ( $filter_value ) ) { - $additional_field_filters->{ $field->{name} } = $filter_value; + if ( defined $filter_value and $filter_value ne q|| ) { + $additional_field_filters->{ $field->{name} } = { + value => $filter_value, + authorised_value_category => $field->{authorised_value_category}, + }; } if ( $field->{authorised_value_category} ) { $field->{authorised_value_choices} = GetAuthorisedValues( $field->{authorised_value_category} ); @@ -103,7 +106,7 @@ if ($searched){ publisher => $publisher, bookseller => $bookseller, branch => $branch, - additional_fields => [ map{ { name => $_, value => $additional_field_filters->{$_}} } keys %$additional_field_filters ], + additional_fields => [ map{ { name => $_, value => $additional_field_filters->{$_}{value}, authorised_value_category => $additional_field_filters->{$_}{authorised_value_category} } } keys %$additional_field_filters ], location => $location, expiration_date => $expiration_date_dt, } -- 1.7.10.4