From 7cbdae653c6403a99bef7ff29df6307e86109129 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 19 Oct 2021 09:51:07 +1300 Subject: [PATCH] Bug 19532: (follow-up) Fixing tests and can_be_recalled checks --- Koha/Biblio.pm | 10 ++++++++-- koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc | 2 +- opac/opac-recall.pl | 2 +- recalls/request.pl | 4 ++-- t/db_dependent/Holds.t | 2 +- t/db_dependent/Koha/Recall.t | 2 +- t/db_dependent/Koha/Recalls.t | 2 +- t/db_dependent/XSLT.t | 4 ++-- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 30b3652c9b..cbe3c58029 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -951,7 +951,11 @@ Return all active recalls attached to this biblio, sorted by oldest first =cut sub recalls { - my ( $self ) = @_; + my ( $self, $params ) = @_; + if ( $params->{borrowernumber} ) { + my @recalls_rs = Koha::Recalls->search({ biblionumber => $self->biblionumber, old => undef, borrowernumber => $params->{borrowernumber} }, { order_by => { -asc => 'recalldate' } }); + return @recalls_rs; + } my @recalls_rs = Koha::Recalls->search({ biblionumber => $self->biblionumber, old => undef }, { order_by => { -asc => 'recalldate' } }); return @recalls_rs; } @@ -984,7 +988,9 @@ sub can_be_recalled { my @itemtypes; my @itemnumbers; my @items; + my @all_itemnumbers; foreach my $item ( @all_items ) { + push( @all_itemnumbers, $item->itemnumber ); if ( $item->can_be_recalled({ patron => $patron }) ) { push( @itemtypes, $item->effective_itemtype ); push( @itemnumbers, $item->itemnumber ); @@ -1031,7 +1037,7 @@ sub can_be_recalled { return 0 if ( $patron->recalls({ biblionumber => $self->biblionumber })->count >= $recalls_per_record ); # check if any of the items under this biblio are already checked out by this borrower - return 0 if ( Koha::Checkouts->search({ itemnumber => [ @itemnumbers ], borrowernumber => $patron->borrowernumber })->count > 0 ); + return 0 if ( Koha::Checkouts->search({ itemnumber => [ @all_itemnumbers ], borrowernumber => $patron->borrowernumber })->count > 0 ); } # check item availability diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc index 52b67ffbbc..de3036f858 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc @@ -43,7 +43,7 @@ [% UNLESS specific_patron %] - [% recall.patron.firstname | html %] [% recall.patron.surname | html %] ([% recall.patron.cardnumber | html %]) + [% INCLUDE 'patron-title.inc' patron=recall.patron hide_patron_infos_if_needed=1 link_to="circulation_recalls" %] [% END %] diff --git a/opac/opac-recall.pl b/opac/opac-recall.pl index f677832448..9a01607f46 100755 --- a/opac/opac-recall.pl +++ b/opac/opac-recall.pl @@ -46,7 +46,7 @@ if ( C4::Context->preference('UseRecalls') ) { my $items = Koha::Items->search({ biblionumber => $biblionumber }); # check if already recalled - my $recalled = scalar $biblio->recalls; + my $recalled = scalar $biblio->recalls({ borrowernumber => $borrowernumber }); if ( defined $recalled and $recalled > 0 ) { my $recalls_per_record = Koha::CirculationRules->get_effective_rule({ categorycode => $patron->categorycode, diff --git a/recalls/request.pl b/recalls/request.pl index 04e6cd0829..b086616ef8 100755 --- a/recalls/request.pl +++ b/recalls/request.pl @@ -18,8 +18,8 @@ use Modern::Perl; use CGI qw ( -utf8 ); -use C4::Auth; -use C4::Output; +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); use C4::Search; use Koha::Recalls; use Koha::Biblios; diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index 01a983bd22..2610cfa19c 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -7,7 +7,7 @@ use t::lib::TestBuilder; use C4::Context; -use Test::More tests => 72; +use Test::More tests => 73; use MARC::Record; use C4::Biblio; diff --git a/t/db_dependent/Koha/Recall.t b/t/db_dependent/Koha/Recall.t index e89cc88a5a..d6e43f8d2e 100755 --- a/t/db_dependent/Koha/Recall.t +++ b/t/db_dependent/Koha/Recall.t @@ -21,7 +21,7 @@ use Test::More tests => 27; use t::lib::TestBuilder; use t::lib::Mocks; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); BEGIN { require_ok('Koha::Recall'); diff --git a/t/db_dependent/Koha/Recalls.t b/t/db_dependent/Koha/Recalls.t index 32dc9e96ba..02fd40b12f 100755 --- a/t/db_dependent/Koha/Recalls.t +++ b/t/db_dependent/Koha/Recalls.t @@ -21,7 +21,7 @@ use Test::More tests => 19; use t::lib::TestBuilder; use t::lib::Mocks; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); BEGIN { require_ok('Koha::Recall'); diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t index b56ea7971e..c37f95ee57 100755 --- a/t/db_dependent/XSLT.t +++ b/t/db_dependent/XSLT.t @@ -131,7 +131,7 @@ subtest 'buildKohaItemsNamespace status tests' => sub { } }); $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); - like($xml,qr{Waiting},"Waiting status takes precedence over In transit (holds)"); + like($xml,qr{Hold waiting},"Waiting status takes precedence over In transit (holds)"); $hold->cancel; $builder->build({ source => "TmpHoldsqueue", value => { @@ -151,7 +151,7 @@ subtest 'buildKohaItemsNamespace status tests' => sub { }}); $recall->set_waiting; $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); - like($xml,qr{Waiting},"Waiting status takes precedence over In transit (recalls)"); + like($xml,qr{Recall waiting},"Waiting status takes precedence over In transit (recalls)"); }; -- 2.11.0