From 42f32d16bc459fbcfd11efec0e871aac92466af6 Mon Sep 17 00:00:00 2001 From: danyonsewell Date: Wed, 20 Dec 2023 04:15:06 +0000 Subject: [PATCH] Bug 26567: Allow to limit subscription search to subscriptions with routing lists Have fixed the bug where multiple results were showing for one subscription, have done testing with subscriptions that have differing numbers of patrons added to the routing list. Test plan: 1. Apply this patch 2. Create two subscriptions, one with a routing list and one without 3. Navigate to Serials home and tick the checkbox labeled "Search routing lists only:" 4. Confirm that the only search result to appear is the subscription you added the routing list to Sponsored by: Bibliotheksservice-Zentrum Baden-Wuerttemberg --- C4/Serials.pm | 5 ++++- .../intranet-tmpl/prog/en/includes/serials-advsearch.inc | 5 +++++ serials/serials-search.pl | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index ec88b0f3e63..2924fed711e 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -510,6 +510,7 @@ The valid search fields are: branch expiration_date closed + routinglist The expiration_date search field is special; it specifies the maximum subscription expiration date. @@ -553,6 +554,9 @@ sub SearchSubscriptions { LEFT JOIN biblioitems ON biblioitems.biblionumber = subscription.biblionumber LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id |; + if( $args->{routinglist} ) { + $query .= q| INNER JOIN (SELECT DISTINCT subscriptionid FROM subscriptionroutinglist) srl ON srl.subscriptionid = subscription.subscriptionid|; + } $query .= q| WHERE 1|; my @where_strs; my @where_args; @@ -609,7 +613,6 @@ sub SearchSubscriptions { push @where_strs, "subscription.closed = ?"; push @where_args, "$args->{closed}"; } - if(@where_strs){ $query .= ' AND ' . join(' AND ', @where_strs); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-advsearch.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-advsearch.inc index ec34b6f0732..84b9eed7cb1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-advsearch.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-advsearch.inc @@ -50,6 +50,11 @@ +
  • + + +
  • + [% INCLUDE 'additional-fields-entry.inc' available=additional_fields_for_subscription values=additional_field_filters wrap_fieldset=0 %] diff --git a/serials/serials-search.pl b/serials/serials-search.pl index 80b20038145..1ebe3ccca35 100755 --- a/serials/serials-search.pl +++ b/serials/serials-search.pl @@ -52,6 +52,7 @@ my $location = $query->param('location_filter') || ''; my $expiration_date = $query->param('expiration_date_filter') || ''; my $routing = $query->param('routing') || C4::Context->preference("RoutingSerials"); my $searched = $query->param('searched') || 0; +my $routinglist = $query->param('routinglist'); my $mana = $query->param('mana') || 0; my @subscriptionids = $query->multi_param('subscriptionid'); my $op = $query->param('op'); @@ -116,6 +117,7 @@ if ($searched) { additional_fields => \@additional_field_filters, location => $location, expiration_date => $expiration_date, + routinglist => $routinglist, }, { results_limit => C4::Context->preference('SerialsSearchResultsLimit') } ); -- 2.30.2