From 63c24217938073d1a20a05659c1b455cc0223f49 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 21 Aug 2012 17:19:54 -0400 Subject: [PATCH] Option to include Wrong-Shelf holds in clear-shelf results Adds a new org unit setting "circ.holds.clear_shelf.include_pl_changed". When enabled, we 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. Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/Application/Circ/Holds.pm | 47 +++++++++++++++++++++- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 20 +++++++++ .../upgrade/XXXX.data.clear_shelf_pl_changed.sql | 25 ++++++++++++ .../server/locale/en-US/circ.properties | 1 + 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.clear_shelf_pl_changed.sql diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index b72db96635..f58dabc042 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -3452,9 +3452,18 @@ sub clear_shelf_process { my %cache_data = ( hold => [], transit => [], - shelf => [] + shelf => [], + pl_changed => [] ); + # if requested, find any holds on our shelf whose pickup lib + # has been changed to some other branch and include those in + # the clear-shelf cache. But, only add them to the pl_changed + # list if they are not otherwise getting canceled by this process. + $cache_data{pl_changed} = + pickup_lib_changed_on_shelf_holds($e, $org_id, \@hold_ids) + if $U->ou_ancestor_setting_value($org_id, 'circ.holds.clear_shelf.include_pl_changed'); + for my $hold (@holds) { my $copy = $hold->current_copy; @@ -3501,6 +3510,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', diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 41eb5fecce..4d2bf3929f 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -11836,3 +11836,23 @@ INSERT into config.org_unit_setting_type 'bool' ); +INSERT into config.org_unit_setting_type + (name, grp, label, description, datatype) + VALUES ( + 'circ.holds.clear_shelf.include_pl_changed', + 'holds', + oils_i18n_gettext( + 'circ.holds.clear_shelf.include_pl_changed', + 'Clear shelf process includes Wrong-Shelf holds', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.holds.clear_shelf.include_pl_changed', + 'If enabled, we include Wrong-Shelf holds in the results list of the holds clear shelf process. Wrong-Shelf holds are those whose pickup lib was changed while the hold was on the holds shelf', + 'coust', + 'description' + ), + 'bool' + ); + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.clear_shelf_pl_changed.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.clear_shelf_pl_changed.sql new file mode 100644 index 0000000000..19216c8e67 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.clear_shelf_pl_changed.sql @@ -0,0 +1,25 @@ +BEGIN; + +-- SELECT evergreen.upgrade_deps_block_check('0730', :eg_version); + +INSERT into config.org_unit_setting_type + (name, grp, label, description, datatype) + VALUES ( + 'circ.holds.clear_shelf.include_pl_changed', + 'holds', + oils_i18n_gettext( + 'circ.holds.clear_shelf.include_pl_changed', + 'Clear shelf process includes Wrong-Shelf holds', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.holds.clear_shelf.include_pl_changed', + 'If enabled, we include Wrong-Shelf holds in the results list of the holds clear shelf process. Wrong-Shelf holds are those whose pickup lib was changed while the hold was on the holds shelf', + 'coust', + 'description' + ), + 'bool' + ); + +COMMIT; diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties index 3f34a0f796..774d128976 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties @@ -328,6 +328,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 -- 2.11.0