From 41255922aaed8fdb29150471beb0833d45fb2a6d 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 ++-- .../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/Holds.t | 2 +- t/db_dependent/Koha/Recall.t | 2 +- t/db_dependent/Koha/Recalls.t | 2 +- t/db_dependent/XSLT.t | 4 ++-- 15 files changed, 28 insertions(+), 21 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index fb304fe04b..cc37a5db5d 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -352,7 +352,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'; @@ -360,7 +361,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 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/Recall.pm b/Koha/Recall.pm index b74cf6b7f0..03c6167683 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 55b6e3656d..be9f88e11e 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 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/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index da69c92545..6f45c1b8ac 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 cff4d3f6ff..ba4dcbed7e 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 891911d546..38408e66da 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 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/recalls_waiting.pl b/recalls/recalls_waiting.pl index 30511c6e33..874129a4b2 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 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.20.1