From b8bee09147c107822677818930f4396d011901df 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index f38365c..71916f7 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -484,6 +484,22 @@ sub GetPatronInfo { # FIXME We should only retrieve what is needed in the template my $issue = $c->unblessed_all_relateds; delete $issue->{'more_subfields_xml'}; + + # 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