From 750601ac5b97cdb2d4cf97497b87c61e5083ba33 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. Signed-off-by: Brendan Gallagher Signed-off-by: Tomas Cohen Arazi --- Koha/AdditionalField.pm | 2 +- .../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 2f3f44bc60..aa00bb66d9 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 31eea9afbc..8413a75847 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 @@ -445,7 +445,7 @@ [% ELSE %] - + [% END %] [% END %] diff --git a/serials/serials-search.pl b/serials/serials-search.pl index 1a054d2399..3e73c56b7a 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, } -- 2.39.5