From: Bill Erickson Date: Mon, 18 Jun 2012 14:16:39 +0000 (-0400) Subject: tpac: sort copies by physical loc when searching parent X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e9aaad28bcd44d51f70882239bcbb6233f07db98;p=working%2FEvergreen.git tpac: sort copies by physical loc when searching parent If a physical location is set and it is a child of the current search location, sort copies living at the physical location to the top of the copy grid in the record detail page. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index a4af2c657f..7cef318229 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -225,6 +225,26 @@ sub mk_copy_query { } ); + + # If a physical location is set and is a child of the search location, + # sort copies living at the physical location to the front. + if (my $phys_loc = $self->ctx->{physical_loc}) { + + my $ou = $self->ctx->{get_aou}->($phys_loc); + $ou = $ou->parent_ou; + + while ($ou) { + if ($org == $ou) { + unshift @{$query->{order_by}}, { + class => 'acp', field => 'circ_lib', transform => 'numeric_eq', + params => [$phys_loc], direction => 'desc' + }; + last; + } + $ou = $self->ctx->{get_aou}->($ou)->parent_ou; + } + } + return $query; }