From: Bill Erickson Date: Tue, 13 Nov 2012 22:51:37 +0000 (-0500) Subject: ou hiding : filter hold counts pickup lib; part 1 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=988a73f4a0aa9f2d3cd9b0b04628be80ce0949cf;p=evergreen%2Fequinox.git ou hiding : filter hold counts pickup lib; part 1 Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index be54c6821a..187d872330 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -3863,6 +3863,11 @@ __PACKAGE__->register_method( selected bib record or its associated copies and call_numbers/, params => [ { desc => 'Bib ID', type => 'number' }, + { desc => q/Optional arguments. Supported arguments include: + "pickup_lib_descendant" -> limit holds to those whose pickup + library is equal to or is a child of the provided org unit/, + type => 'object' + } ], return => {desc => 'Hold count', type => 'number'} } @@ -3883,8 +3888,8 @@ __PACKAGE__->register_method( # XXX Need to add type I (and, soon, type P) holds to these counts sub rec_hold_count { - my($self, $conn, $target_id) = @_; - + my($self, $conn, $target_id, $args) = @_; + $args ||= {}; my $mmr_join = { mmrsm => { @@ -3978,6 +3983,21 @@ sub rec_hold_count { } + if (my $pld = $args->{pickup_lib_descendant}) { + $query->{where}->{'+ahr'}->{pickup_lib} = { + in => { + select => {aou => [{ + column => 'id', + transform => 'actor.org_unit_descendants', + result_field => 'id' + }]}, + from => 'aou', + where => {id => $pld} + } + }; + } + + return new_editor()->json_query($query)->[0]->{count}; }