From 54bc2edb1e4bfceaba08e9526389aebd60dbf830 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 21 May 2013 11:59:36 -0400 Subject: [PATCH] LP1182519 Per-Hold Behind Desk Value The true/false value for behind_desk is now stored directly on the hold object for more accurate tracking of the location of captured holds. If configured, patrons can now set their preferred value for behind the desk holds. * DB/IDL changes to support the new column * API support for loading the setting from the patron for cases when no value is provided by the caller. * Staff client grid column definition for the Behind Desk field * Hold counts in the staff client now show total, available, and behind-desk (at the workstation). * Printed hold receipt now uses the behind_desk value on the hold to decide if a hold is behind the desk. * Release notes Signed-off-by: Bill Erickson Conflicts: Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm Resolved 2 conflicts in Actor.pm sub hold_request_count Retained the parameters as: my( $self, $client, $authtoken, $user_id, $ctx_org) = @; And retained: my @ready = grep { .... } @$holds code. Signed-off-by: Garry Collum --- Open-ILS/examples/fm_IDL.xml | 3 ++ .../lib/OpenILS/Application/Acq/Order.pm | 16 ++++++ .../perlmods/lib/OpenILS/Application/Actor.pm | 38 ++++++++++---- .../lib/OpenILS/Application/Circ/Holds.pm | 26 ++++++++++ .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 22 +++++++++ Open-ILS/src/sql/Pg/090.schema.action.sql | 3 +- .../XXXX.schema.per-hold-behind-desk.sql | 31 ++++++++++++ .../templates/opac/myopac/prefs_settings.tt2 | 10 ++++ Open-ILS/web/opac/locale/en-US/lang.dtd | 1 + Open-ILS/xul/staff_client/server/circ/util.js | 49 ++++++++++++------- .../server/locale/en-US/circ.properties | 1 + .../server/locale/en-US/patron.properties | 4 ++ .../xul/staff_client/server/patron/summary.js | 35 +++++++++++-- .../server/patron/summary_overlay.xul | 5 ++ .../Circulation/per-hold-behind-desk.txt | 32 ++++++++++++ 15 files changed, 241 insertions(+), 35 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.schema.per-hold-behind-desk.sql create mode 100644 docs/RELEASE_NOTES_NEXT/Circulation/per-hold-behind-desk.txt diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 0064b76d48..d2703414eb 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -5179,6 +5179,7 @@ SELECT usr, + @@ -5339,6 +5340,7 @@ SELECT usr, + @@ -5407,6 +5409,7 @@ SELECT usr, + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index 1a774d8bb5..c8ca798f9e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -274,6 +274,22 @@ sub promote_lineitem_holds { $hold->target( $li->eg_bib_id ); } + # if behind-the-desk holds are supported at the + # pickup library, apply the patron default + my $bdous = $U->ou_ancestor_setting_value( + $hold->pickup_lib, + 'circ.holds.behind_desk_pickup_supported', + $mgr->editor + ); + + if ($bdous) { + my $set = $mgr->editor->search_actor_user_setting( + {usr => $hold->usr, name => 'circ.holds_behind_desk'})->[0]; + + $hold->behind_desk('t') if $set and + OpenSRF::Utils::JSON->JSON2perl($set->value); + } + $mgr->editor->create_action_hold_request( $hold ) or return 0; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index 37ad23b4da..9c9efc490d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -1929,11 +1929,17 @@ __PACKAGE__->register_method( api_name => "open-ils.actor.user.hold_requests.count", authoritative => 1, argc => 1, - notes => 'Returns hold ready/total counts' + notes => q/ + Returns hold ready vs. total counts. + If a context org unit is provided, a third value + is returned with key 'behind_desk', which reports + how many holds are ready at the pickup library + with the behind_desk flag set to true. + / ); sub hold_request_count { - my( $self, $client, $authtoken, $user_id ) = @_; + my( $self, $client, $authtoken, $user_id, $ctx_org ) = @_; my $e = new_editor(authtoken => $authtoken); return $e->event unless $e->checkauth; @@ -1945,7 +1951,7 @@ sub hold_request_count { } my $holds = $e->json_query({ - select => {ahr => ['pickup_lib', 'current_shelf_lib']}, + select => {ahr => ['pickup_lib', 'current_shelf_lib', 'behind_desk']}, from => 'ahr', where => { usr => $user_id, @@ -1954,15 +1960,27 @@ sub hold_request_count { } }); - return { + my @ready = grep { + $_->{current_shelf_lib} and # avoid undef warnings + $_->{pickup_lib} eq $_->{current_shelf_lib} + } @$holds; + + my $resp = { total => scalar(@$holds), - ready => scalar( - grep { - $_->{current_shelf_lib} and # avoid undef warnings - $_->{pickup_lib} eq $_->{current_shelf_lib} - } @$holds - ) + ready => scalar(@ready) }; + + if ($ctx_org) { + # count of holds ready at pickup lib with behind_desk true. + $resp->{behind_desk} = scalar( + grep { + $_->{pickup_lib} == $ctx_org and + $U->is_true($_->{behind_desk}) + } @ready + ); + } + + return $resp; } __PACKAGE__->register_method( 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 cb99b3d3ff..9de0fca24e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -36,6 +36,7 @@ use DateTime::Format::ISO8601; use OpenSRF::Utils qw/:datetime/; use Digest::MD5 qw(md5_hex); use OpenSRF::Utils::Cache; +use OpenSRF::Utils::JSON; my $apputils = "OpenILS::Application::AppUtils"; my $U = $apputils; @@ -338,6 +339,31 @@ sub create_hold { $hold->expire_time(calculate_expire_time($recipient->home_ou)); } + + # if behind-the-desk pickup is supported at the hold pickup lib, + # set the value to the patron default, unless a value has already + # been applied. If it's not supported, force the value to false. + + my $bdous = $U->ou_ancestor_setting_value( + $hold->pickup_lib, + 'circ.holds.behind_desk_pickup_supported', $e); + + if ($bdous) { + if (!defined $hold->behind_desk) { + + my $set = $e->search_actor_user_setting({ + usr => $hold->usr, + name => 'circ.holds_behind_desk' + })->[0]; + + $hold->behind_desk('t') if $set and + OpenSRF::Utils::JSON->JSON2perl($set->value); + } + } else { + # behind the desk not supported, force it to false + $hold->behind_desk('f'); + } + $hold->requestor($e->requestor->id); $hold->request_lib($e->requestor->ws_ou); $hold->selection_ou($hold->pickup_lib) unless $hold->selection_ou; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 381028d3ea..a7f60a405c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -406,6 +406,28 @@ sub load_myopac_prefs_settings { my $stat = $self->_load_user_with_prefs; return $stat if $stat; + # if behind-desk holds are supported and the user + # setting which controls the value is opac-visible, + # add the setting to the list of settings to manage. + # note: this logic may need to be changed later to + # check whether behind-the-desk holds are supported + # anywhere the patron may select as a pickup lib. + my $e = $self->editor; + my $bdous = $self->ctx->{get_org_setting}->( + $e->requestor->home_ou, + 'circ.holds.behind_desk_pickup_supported'); + + if ($bdous) { + my $setting = + $e->retrieve_config_usr_setting_type( + 'circ.holds_behind_desk'); + + if ($U->is_true($setting->opac_visible)) { + push(@user_prefs, 'circ.holds_behind_desk'); + $self->ctx->{behind_desk_supported} = 1; + } + } + return Apache2::Const::OK unless $self->cgi->request_method eq 'POST'; diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql index 351d9ca3b8..e8aa81e33b 100644 --- a/Open-ILS/src/sql/Pg/090.schema.action.sql +++ b/Open-ILS/src/sql/Pg/090.schema.action.sql @@ -395,7 +395,8 @@ CREATE TABLE action.hold_request ( cut_in_line BOOL, mint_condition BOOL NOT NULL DEFAULT TRUE, shelf_expire_time TIMESTAMPTZ, - current_shelf_lib INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED + current_shelf_lib INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED, + behind_desk BOOLEAN NOT NULL DEFAULT FALSE ); ALTER TABLE action.hold_request ADD CONSTRAINT sms_check CHECK ( sms_notify IS NULL diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.per-hold-behind-desk.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.per-hold-behind-desk.sql new file mode 100644 index 0000000000..4f0458cb0a --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.per-hold-behind-desk.sql @@ -0,0 +1,31 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +ALTER TABLE action.hold_request + ADD COLUMN behind_desk BOOLEAN NOT NULL DEFAULT FALSE; + +-- The value on the hold is the new arbiter of whether a +-- hold should be held behind the desk and reported as such +-- Update existing holds that would in the current regime +-- be considered behind-the-desk holds to use the new column + +UPDATE action.hold_request ahr + SET behind_desk = TRUE + FROM actor.usr_setting aus + WHERE + ahr.cancel_time IS NULL AND + ahr.fulfillment_time IS NULL AND + aus.usr = ahr.usr AND + aus.name = 'circ.holds_behind_desk' AND + aus.value = 'true' AND + EXISTS ( + SELECT 1 + FROM actor.org_unit_ancestor_setting( + 'circ.holds.behind_desk_pickup_supported', + ahr.pickup_lib + ) + WHERE value = 'true' + ); + +COMMIT; diff --git a/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 b/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 index 7b27be7fe9..4896a7b66e 100644 --- a/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 +++ b/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 @@ -87,6 +87,16 @@ [% IF ctx.user_setting_map.$setting %] checked='checked' [% END %]/> + [%- setting = 'circ.holds_behind_desk'; IF ctx.behind_desk_supported -%] + + + + + + + [% END %] +