Use hold current shelf lib to determine availability : opac sorting
authorBill Erickson <berick@esilibrary.com>
Wed, 28 Dec 2011 20:44:36 +0000 (15:44 -0500)
committerBill Erickson <berick@esilibrary.com>
Wed, 4 Jan 2012 21:01:08 +0000 (16:01 -0500)
The availability of a hold can now be determined by
hold.current_shelf_lib == hold.pickup_lib.

This change uses the new hold availability test to sort available
holds to front/top of a patron's holds list (for the OPAC).

Affects open-ils.circ.holds[.canceled|id_list].retrieve

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm

index a5b76f9..38f269f 100644 (file)
@@ -530,7 +530,17 @@ sub retrieve_holds {
     } else {
 
         # order non-cancelled holds by ready-for-pickup, then active, followed by suspended
-        $holds_query->{order_by} = {ahr => ['shelf_time', 'frozen', 'request_time']};
+        # "compare" sorts false values to the front.  testing pickup_lib != current_shelf_lib
+        # will sort by pl = csl > pl != csl > followed by csl is null;
+        $holds_query->{order_by} = [
+            {   class => 'ahr', 
+                field => 'pickup_lib', 
+                compare => {'!='  => {'+ahr' => 'current_shelf_lib'}}},
+            {class => 'ahr', field => 'shelf_time'},
+            {class => 'ahr', field => 'frozen'},
+            {class => 'ahr', field => 'request_time'}
+
+        ];
         $holds_query->{where}->{cancel_time} = undef;
     }