Bug 26567: Allow to limit subscription search to subscriptions with routing lists
Adds a search option to the advanced search in the serials module that allows to limit search on subscriptions with routing lists. 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 5. Run unit tests: prove t/db_dependent/Serials.t Sponsored by: Bibliotheksservice-Zentrum Baden-Wuerttemberg Signed-off-by: Christian Stelzenmüller <christian.stelzenmueller@bsz-bw.de> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> Perltidied changes to make QA test tools pass. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
b1944c7895
commit
ac5084641e
|
|
@ -511,6 +511,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.
|
||||
|
|
@ -554,6 +555,10 @@ 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;
|
||||
|
|
@ -610,7 +615,6 @@ sub SearchSubscriptions {
|
|||
push @where_strs, "subscription.closed = ?";
|
||||
push @where_args, "$args->{closed}";
|
||||
}
|
||||
|
||||
if(@where_strs){
|
||||
$query .= ' AND ' . join(' AND ', @where_strs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,11 @@
|
|||
<label for="to">Expires before:</label>
|
||||
<input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | html %]" size="10" maxlength="10" class="flatpickr" />
|
||||
</li>
|
||||
<li class="local">
|
||||
<label for="routinglist">Search routing lists only:</label>
|
||||
<input type="checkbox" id="routinglist" name="routinglist" />
|
||||
</li>
|
||||
|
||||
[% INCLUDE 'additional-fields-entry.inc' available=additional_fields_for_subscription values=additional_field_filters wrap_fieldset=0 %]
|
||||
</ol>
|
||||
<input type="hidden" name="searched" value="1" />
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
@ -105,17 +106,18 @@ if ($searched) {
|
|||
else {
|
||||
my $subscriptions = SearchSubscriptions(
|
||||
{
|
||||
biblionumber => $biblionumber,
|
||||
title => $title,
|
||||
issn => $ISSN,
|
||||
ean => $EAN,
|
||||
callnumber => $callnumber,
|
||||
publisher => $publisher,
|
||||
bookseller => $bookseller,
|
||||
branch => $branch,
|
||||
biblionumber => $biblionumber,
|
||||
title => $title,
|
||||
issn => $ISSN,
|
||||
ean => $EAN,
|
||||
callnumber => $callnumber,
|
||||
publisher => $publisher,
|
||||
bookseller => $bookseller,
|
||||
branch => $branch,
|
||||
additional_fields => \@additional_field_filters,
|
||||
location => $location,
|
||||
expiration_date => $expiration_date,
|
||||
location => $location,
|
||||
expiration_date => $expiration_date,
|
||||
routinglist => $routinglist,
|
||||
},
|
||||
{ results_limit => C4::Context->preference('SerialsSearchResultsLimit') }
|
||||
);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use Koha::Acquisition::Booksellers;
|
|||
use t::lib::Mocks;
|
||||
use t::lib::TestBuilder;
|
||||
use Test::MockModule;
|
||||
use Test::More tests => 55;
|
||||
use Test::More tests => 57;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::Serials', qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate ));
|
||||
|
|
@ -199,6 +199,52 @@ is(
|
|||
'SearchSubscriptions returned only one subscription when results_limit is set to "1"'
|
||||
);
|
||||
|
||||
# Set up fake data
|
||||
my $subscriptionwithroutinglistid = NewSubscription(
|
||||
undef, "", undef, undef, $budget_id, $biblionumber,
|
||||
'2013-01-01', $frequency_id, undef, undef, undef,
|
||||
undef, undef, undef, undef, undef, undef,
|
||||
1, $notes, undef, '2013-01-01', undef, $pattern_id,
|
||||
undef, undef, 0, $internalnotes, 0,
|
||||
undef, undef, 0, undef, '2013-12-31', 0
|
||||
);
|
||||
|
||||
#creating fake patrons
|
||||
my $patron = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patrons',
|
||||
}
|
||||
);
|
||||
my $patron2 = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patrons',
|
||||
}
|
||||
);
|
||||
my $patronid1 = $patron->borrowernumber;
|
||||
my $patronid2 = $patron2->borrowernumber;
|
||||
|
||||
# Add a fake routing list with fake patrons
|
||||
addroutingmember( $patronid1, $subscriptionwithroutinglistid );
|
||||
addroutingmember( $patronid2, $subscriptionwithroutinglistid );
|
||||
|
||||
# Perform SearchSubscriptions
|
||||
my $fake_subscription = GetSubscription($subscriptionwithroutinglistid);
|
||||
|
||||
my @subscriptionswithroutinglist = SearchSubscriptions(
|
||||
{
|
||||
issn => $fake_subscription->{issn},
|
||||
orderby => 'title',
|
||||
routinglist => 1
|
||||
}
|
||||
);
|
||||
|
||||
# Check the results
|
||||
is( @subscriptionswithroutinglist, 1, 'SearchSubscriptions returned the expected number of subscriptions' );
|
||||
is(
|
||||
$subscriptionswithroutinglist[0]->{title}, $fake_subscription->{title},
|
||||
'SearchSubscriptions returned the correct subscription'
|
||||
);
|
||||
|
||||
my $frequency = GetSubscriptionFrequency($subscriptioninformation->{periodicity});
|
||||
my $old_frequency;
|
||||
if (not $frequency->{unit}) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue