From 2685aede35f50e29a0919f320e489100f979a806 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 5ebba3435d..5156cd7356 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -497,6 +497,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.27.0