__PACKAGE__->columns( Essential => qw/name owning_lib holdable hold_verify opac_visible circulate/ );
#-------------------------------------------------------------------------------
+package asset::copy_location_order;
+use base qw/asset/;
+
+__PACKAGE__->table( 'asset_copy_location_order' );
+__PACKAGE__->columns( Primary => qw/id/ );
+__PACKAGE__->columns( Essential => qw/location org position/ );
+
+#-------------------------------------------------------------------------------
package asset::call_number;
use base qw/asset/;
asset::call_number->sequence( 'asset.call_number_id_seq' );
#---------------------------------------------------------------------
+ package asset::copy_location_order;
+
+ asset::copy_location_order->table( 'asset.copy_location_order' );
+ asset::copy_location_order->sequence( 'asset.copy_location_order_id_seq' );
+
+ #---------------------------------------------------------------------
package asset::copy_location;
asset::copy_location->table( 'asset.copy_location' );
return undef unless ($ou);
my $h_table = action::hold_request->table;
my $a_table = asset::copy->table;
+ my $ord_table = asset::copy_location_order->table;
my $idlist = 1 if ($self->api_name =~/id_list/o);
SELECT h.*
FROM $h_table h
JOIN $a_table a ON (h.current_copy = a.id)
+ LEFT JOIN $ord_table ord (a.location = ord.location AND a.circ_lib = ord.org)
WHERE a.circ_lib = ?
AND h.capture_time IS NULL
AND h.cancel_time IS NULL
AND (h.expire_time IS NULL OR h.expire_time > NOW())
$status_filter
- ORDER BY h.request_time ASC
+ ORDER BY CASE WHEN ord.position IS NOT NULL THEN ord.position ELSE 999 END, h.request_time
LIMIT $limit
OFFSET $offset
SQL