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 <berick@esilibrary.com>
}
);
+
+ # 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;
}