my $copy_limit = shift;
my $copy_offset = shift;
- # XXX In the future, $sort_org should be understood to be an abstration
- # that refers to something configurable, not necessariyl orig_loc.
-
- my $sort_org = $self->ctx->{orig_loc} || $org ||
- $self->ctx->{aou_tree}->()->id;
-
my $query = {
select => {
acp => ['id', 'barcode', 'circ_lib', 'create_date', 'age_protect', 'holdable'],
# Order is: copies with circ_lib=org, followed by circ_lib name, followed by call_number label
order_by => [
- {class => 'acp', field => 'circ_lib', transform => 'numeric_eq',
- params => [$sort_org], direction => 'desc'},
{class => 'aou', field => 'name'},
{class => 'acn', field => 'label'}
],
offset => $copy_offset
};
+ # XXX In the future, $sort_org should be understood to be an abstration
+ # that refers to something configurable, not necessariyl orig_loc.
+
+ if (my $sort_org = $self->ctx->{orig_loc}) {
+ unshift @{$query->{order_by}}, {
+ class => 'acp', field => 'circ_lib', transform => 'numeric_eq',
+ params => [$sort_org], direction => 'desc'
+ };
+ }
+
# Filter hidden items if this is the public catalog
unless($self->ctx->{is_staff}) {
$query->{where}->{'+acp'}->{opac_visible} = 't';