From 7b8e90878e88794f36426519d1a68843a7e4a87b Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 14 Oct 2021 16:54:36 +1300 Subject: [PATCH] Bug 19532: (follow-up) Fix calls, tests, syspref settings, checks Signed-off-by: David Nind --- C4/XSLT.pm | 5 +++-- Koha/Biblio.pm | 10 ++++++++-- Koha/Recall.pm | 2 +- Koha/Recalls.pm | 2 +- koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc | 2 +- .../prog/en/modules/admin/preferences/circulation.pref | 4 ++-- .../intranet-tmpl/prog/en/modules/admin/preferences/logs.pref | 4 ++-- misc/cronjobs/recalls/expire_recalls.pl | 2 +- opac/opac-recall.pl | 2 +- recalls/recalls_waiting.pl | 2 +- recalls/request.pl | 4 ++-- t/db_dependent/Koha/Recall.t | 2 +- t/db_dependent/Koha/Recalls.t | 2 +- t/db_dependent/XSLT.t | 4 ++-- 14 files changed, 27 insertions(+), 20 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 6ab047d332f..2bfd88bcbf7 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -357,7 +357,8 @@ sub buildKohaItemsNamespace { if ( $recalls->count ) { # recalls take priority over holds - $status = 'Waiting'; + $status = 'other'; + $substatus = 'Recall waiting'; } elsif ( $item->has_pending_hold ) { $status = 'other'; @@ -365,7 +366,7 @@ sub buildKohaItemsNamespace { } elsif ( $item->holds->waiting->count ) { $status = 'other'; - $substatus = 'Waiting'; + $substatus = 'Hold waiting'; } elsif ($item->get_transfer) { $status = 'other'; diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 2c44a4a0069..c8f31ca740b 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -1171,7 +1171,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; } @@ -1204,7 +1208,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 ); @@ -1251,7 +1257,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/Recall.pm b/Koha/Recall.pm index b74cf6b7f0b..03c61676830 100644 --- a/Koha/Recall.pm +++ b/Koha/Recall.pm @@ -20,7 +20,7 @@ package Koha::Recall; use Modern::Perl; use Koha::Database; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); use Koha::Patron; use Koha::Biblio; use Koha::Item; diff --git a/Koha/Recalls.pm b/Koha/Recalls.pm index 55b6e3656d0..be9f88e11e1 100644 --- a/Koha/Recalls.pm +++ b/Koha/Recalls.pm @@ -21,7 +21,7 @@ use Modern::Perl; use Koha::Database; use Koha::Recall; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); use C4::Stats qw( UpdateStats ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/recalls.inc index 52b67ffbbc8..de3036f858d 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/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index b85664d5e45..3e81898de60 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -1281,6 +1281,6 @@ Circulation: - - pref: UseRecalls choices: - yes: Use - no: "Don't use" + 1: Use + 0: "Don't use" - recalls. Make sure you configure circulation and fines rules for recalls once enabled. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref index cff4d3f6ff4..ba4dcbed7ee 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref @@ -111,8 +111,8 @@ Logging: - - pref: RecallsLog choices: - on: Log - off: "Don't log" + 1: Log + 0: "Don't log" - any actions on recalls (create, cancel, expire, fulfill). Debugging: diff --git a/misc/cronjobs/recalls/expire_recalls.pl b/misc/cronjobs/recalls/expire_recalls.pl index 891911d546b..38408e66dae 100755 --- a/misc/cronjobs/recalls/expire_recalls.pl +++ b/misc/cronjobs/recalls/expire_recalls.pl @@ -31,7 +31,7 @@ BEGIN { # - recalls that have been awaiting pickup for longer than the specified recall_shelf_time circulation rule, or the RecallsMaxPickUpDelay if circ rule is unset use Koha::Script -cron; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); use Koha::Recalls; use C4::Log; diff --git a/opac/opac-recall.pl b/opac/opac-recall.pl index f6778324489..9a01607f465 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/recalls_waiting.pl b/recalls/recalls_waiting.pl index 30511c6e337..874129a4b2f 100755 --- a/recalls/recalls_waiting.pl +++ b/recalls/recalls_waiting.pl @@ -22,7 +22,7 @@ use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use Koha::Recalls; use Koha::BiblioFrameworks; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); use Koha::Patrons; my $query = CGI->new; diff --git a/recalls/request.pl b/recalls/request.pl index 04e6cd0829b..b086616ef86 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/Koha/Recall.t b/t/db_dependent/Koha/Recall.t index e89cc88a5af..d6e43f8d2e0 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 32dc9e96ba0..02fd40b12f9 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 b56ea7971e2..c37f95ee57c 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