From 7530666995e85d59f310a4f41a63191a96a49c6f Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Fri, 27 Apr 2018 16:22:28 +0200 Subject: [PATCH] Bug 21284: ILS-DI: Allow GetPatronInfo to tell if a loaned item is on hold by someone else. This patch adds two entries in the loans section of GetPatronInfo's response: - itemonhold: number of holds on this specific item. - recordonhold: number of holds on the record. Test plan: - Call GetPatronInfo on a user with a loan that has no holds - Check that itemonhold and recordonhold entries are equal to zero - Add holds on biblio and/or item level - Check that itemonhold and recordonhold are incremented accordingly Please note that a hold on item level counts as a hold on record level, but not vice-versa. --- C4/ILSDI/Services.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 158ff8e..191fee5 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -28,6 +28,7 @@ use C4::Biblio; use C4::Reserves qw(AddReserve CanBookBeReserved CanItemBeReserved IsAvailableForItemLevelRequest); use C4::Context; use C4::AuthoritiesMarc; +use C4::Reserves; use XML::Simple; use HTML::Entities; use CGI qw ( -utf8 ); @@ -470,6 +471,22 @@ sub GetPatronInfo { while ( my $c = $pending_checkouts->next ) { # FIXME We should only retrieve what is needed in the template my $issue = $c->unblessed_all_relateds; + + # Is the item already on hold by another user? + my $rs = Koha::Database->new()->schema()->resultset('Reserve'); + $issue->{'itemonhold'} = $rs->count( + { + itemnumber => $issue->{'itemnumber'} + } + ); + + # Is the record (next available item) on hold by another user? + $issue->{'recordonhold'} = $rs->count( + { + biblionumber => $issue->{'biblionumber'} + } + ); + push @checkouts, $issue } $borrower->{'loans'}->{'loan'} = \@checkouts; -- 2.7.4