Include Wrong-Shelf holds in clear-shelf results
authorBill Erickson <berick@esilibrary.com>
Tue, 21 Aug 2012 21:19:54 +0000 (17:19 -0400)
committerJason Etheridge <jason@esilibrary.com>
Fri, 7 Jun 2013 16:24:34 +0000 (12:24 -0400)
Include non-expired, Wrong-Shelf holds in the results list of the "Clear
Shelf-Expired Holds" process.  ("Wrong-Shelf" holds are those whose
pickup lib was changed while the hold was on the holds shelf).  The idea
behind this option is that branches may use the clear-shelf process as a
general shelf management report beyond just holds that have expired.
I.e. tell me everything I need to remove from the shelf.

This change includes a label change for the clear-shelf menu options:

"Clear Shelf-Expired Holds" -> "Clear Holds Shelf"

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/server/locale/en-US/circ.properties

index cde9619..7e06492 100644 (file)
@@ -3541,7 +3541,8 @@ sub clear_shelf_process {
         my %cache_data = (
             hold => [],
             transit => [],
-            shelf => []
+            shelf => [],
+            pl_changed => pickup_lib_changed_on_shelf_holds($e, $org_id, \@hold_ids)
         );
 
         for my $hold (@holds) {
@@ -3590,6 +3591,42 @@ sub clear_shelf_process {
     }
 }
 
+# returns IDs for holds that are on the holds shelf but 
+# have had their pickup_libs change while on the shelf.
+sub pickup_lib_changed_on_shelf_holds {
+    my $e = shift;
+    my $org_id = shift;
+    my $ignore_holds = shift;
+    $ignore_holds = [$ignore_holds] if !ref($ignore_holds);
+
+    my $query = {
+        select => { alhr => ['id'] },
+        from   => {
+            alhr => {
+                acp => {
+                    field => 'id',
+                    fkey  => 'current_copy'
+                },
+            }
+        },
+        where => {
+            '+acp' => { status => OILS_COPY_STATUS_ON_HOLDS_SHELF },
+            '+alhr' => {
+                capture_time     => { "!=" => undef },
+                fulfillment_time => undef,
+                current_shelf_lib => $org_id,
+                pickup_lib => {'!='  => {'+alhr' => 'current_shelf_lib'}}
+            }
+        }
+    };
+
+    $query->{where}->{'+alhr'}->{id} =
+        {'not in' => $ignore_holds} if @$ignore_holds;
+
+    my $hold_ids = $e->json_query($query);
+    return [ map { $_->{id} } @$hold_ids ];
+}
+
 __PACKAGE__->register_method(
     method    => 'usr_hold_summary',
     api_name  => 'open-ils.circ.holds.user_summary',
index b7a2f4d..7084976 100644 (file)
 <!ENTITY staff.main.menu.circ.hold_browse.accesskey "B">
 <!ENTITY staff.main.menu.circ.hold_browse.label "Browse Holds Shelf">
 <!ENTITY staff.main.menu.circ.hold_clear.accesskey "">
-<!ENTITY staff.main.menu.circ.hold_clear.label "Clear Shelf-Expired Holds">
+<!ENTITY staff.main.menu.circ.hold_clear.label "Clear Holds Shelf">
 <!ENTITY staff.main.menu.circ.hold_capture.accesskey "H">
 <!ENTITY staff.main.menu.circ.hold_capture.label "Capture Holds">
 <!ENTITY staff.main.menu.circ.hold_pull.accesskey "S">
 <!ENTITY staff.circ.checkin_overlay.checkin_auto_print_slips.accesskey "P">
 <!ENTITY staff.circ.checkin_overlay.checkin_modifiers_btn.label "Checkin Modifiers">
 <!ENTITY staff.circ.checkin_overlay.checkin_modifiers_btn.accesskey "M">
-<!ENTITY staff.circ.checkin_overlay.checkin_clear_shelf_expired.label "Clear Shelf-Expired Holds">
+<!ENTITY staff.circ.checkin_overlay.checkin_clear_shelf_expired.label "Clear Holds Shelf">
 <!ENTITY staff.circ.checkin_overlay.checkin_clear_shelf_expired.accesskey "C">
 <!ENTITY staff.circ.checkin_overlay.checkin_auto_retarget.label "Retarget Local Holds">
 <!ENTITY staff.circ.checkin_overlay.checkin_auto_retarget.accesskey "R">
index 2f058ae..c77579a 100644 (file)
@@ -332,6 +332,7 @@ staff.circ.utils.hold_post_clear_shelf_action.label=Post-Clear
 staff.circ.utils.hold_post_clear_shelf_action.hold=Need for Hold
 staff.circ.utils.hold_post_clear_shelf_action.transit=Need for Transit
 staff.circ.utils.hold_post_clear_shelf_action.shelf=Reshelve
+staff.circ.utils.hold_post_clear_shelf_action.pl_changed=Wrong Shelf
 staff.circ.utils.frozen=Frozen?
 staff.circ.utils.active=Active?
 staff.circ.utils.thaw_date=Activation Date