From f0afa4084e94c05fd0aae73338628f89990b8225 Mon Sep 17 00:00:00 2001 From: Dan Pearl Date: Wed, 1 Mar 2017 14:43:58 -0500 Subject: [PATCH] LP##1661688 - Want easy way to clear a hold when picked up by other patron. This common action was handled previously as 1) item it scanned 2) force override was selected 3) librarian cancels original hold This feature provides the option to cancel the hold in step #2. --- .../lib/OpenILS/Application/Circ/Circulate.pm | 31 ++++++++-------- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 23 ++++++++++++ .../sql/Pg/upgrade/XXXX.schema.hold_checkout.sql | 29 +++++++++++++++ .../staff/circ/share/t_event_override_dialog.tt2 | 8 ++++ .../web/js/ui/default/staff/circ/services/circ.js | 43 +++++++++++++++++++++- .../Circulation/alternate_patron_hold_pickup.adoc | 20 ++++++++++ 6 files changed, 137 insertions(+), 17 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold_checkout.sql create mode 100644 docs/RELEASE_NOTES_NEXT/Circulation/alternate_patron_hold_pickup.adoc diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index 0dcc78294a..4c50778326 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -855,7 +855,12 @@ sub check_captured_holds { cancel_time => undef, fulfillment_time => undef }, - { limit => 1 } + { limit => 1, + flesh => 2, + flesh_fields => { ahr => ['usr'], + au => ['family_name', 'first_given_name'] + } + } ] )->[0]; @@ -864,25 +869,19 @@ sub check_captured_holds { return undef; } - /* Get fleshed version of hold so we can grab name of requestor */ - $hold = $self->editor->retrieve_action_hold_request( - [ - $hold->id, - { - flesh => 1, - flesh_fields => { ahr => [ 'usr' ] } - } - ] - $logger->info("circulator: this copy is needed by a different patron to fulfill a hold"); - my $user = $hold->usr; + my $payload; + my $holdau = $hold->usr; + if ($holdau) { + $payload->{patron_name} = $holdau->first_given_name . ' ' . $holdau->family_name; + } else { + $payload->{patron_name} = "???"; + } + $payload->{hold_id} = $hold->id; $self->push_events(OpenILS::Event->new('ITEM_ON_HOLDS_SHELF', - { payload => { hold => $hold->id, - patron_name = $user->first_given_name. ' '. - $user->family_name - )); + payload => $payload)); } 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 ce5e03f1ef..e0b6754ca9 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -16503,6 +16503,29 @@ INSERT INTO config.org_unit_setting_type INSERT INTO config.org_unit_setting_type ( name, grp, label, description, datatype ) VALUES + ('circ.clear_hold_on_checkout', + 'circ', + oils_i18n_gettext('circ.clear_hold_on_checkout', + 'Clear hold when other patron checks out item', + 'coust', 'label'), + oils_i18n_gettext('circ.clear_hold_on_checkout', + 'When patron A checks out item on hold for patron B, ' || + 'automatically clear the hold for patron B. This is ' || + 'desirable when checking out item for family members', + 'coust', 'description'), + 'bool'); + +INSERT INTO actor.org_unit_setting ( + org_unit, name, value +) VALUES ( + (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL), + 'circ.clear_hold_on_checkout', + 'true' +); + +INSERT INTO config.org_unit_setting_type +( name, grp, label, description, datatype ) +VALUES ('circ.patron_search.diacritic_insensitive', 'circ', oils_i18n_gettext('circ.patron_search.diacritic_insensitive', diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold_checkout.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold_checkout.sql new file mode 100644 index 0000000000..a425ef350e --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold_checkout.sql @@ -0,0 +1,29 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +INSERT INTO config.org_unit_setting_type +( name, grp, label, description, datatype ) +VALUES + ('circ.hold.clear_hold_on_checkout', + 'circ', + oils_i18n_gettext('circ.hold.clear_hold_on_checkout', + 'Clear hold when other patron checks out item', + 'coust', 'label'), + oils_i18n_gettext('circ.hold.clear_hold_on_checkout', + 'When patron A checks out item on hold for patron B, ' || + 'automatically clear the hold for patron B. This is ' || + 'desirable when checking out item for family members', + 'coust', 'description'), + 'bool'); + +INSERT INTO actor.org_unit_setting ( + org_unit, name, value +) VALUES ( + (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL), + 'circ.hold.clear_hold_on_checkout', + 'true' +); + +COMMIT; + diff --git a/Open-ILS/src/templates/staff/circ/share/t_event_override_dialog.tt2 b/Open-ILS/src/templates/staff/circ/share/t_event_override_dialog.tt2 index 730814548a..0adeb115cc 100644 --- a/Open-ILS/src/templates/staff/circ/share/t_event_override_dialog.tt2 +++ b/Open-ILS/src/templates/staff/circ/share/t_event_override_dialog.tt2 @@ -13,6 +13,14 @@
{{copy_barcode}}
{{evt.desc}} +
+ [% l('for ') %] {{patronName}}. +
+ +
+ +
diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js index c32cf6f300..d5513b6533 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js +++ b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js @@ -653,12 +653,53 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog, ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) { $scope.events = evt; + + // Find the event, if any, that is for ITEM_ON_HOLDS_SHELF + // and grab the patron name of the owner. + $scope.holdEvent = evt.filter( + function(e) { + return e.textcode === 'ITEM_ON_HOLDS_SHELF' + } + ); + + if ($scope.holdEvent) { + // Ensure we have a scalar here + if (angular.isArray($scope.holdEvent)) { + $scope.holdEvent = $scope.holdEvent[0]; + } + + $scope.patronName = $scope.holdEvent.payload.patron_name; + $scope.holdID = $scope.holdEvent.payload.hold_id; + } + $scope.auto_override = evt.filter(function(e){ return service.checkout_auto_override_after_first.indexOf(evt.textcode) > -1; }).length > 0; $scope.copy_barcode = params.copy_barcode; // may be null - $scope.ok = function() { $uibModalInstance.close() } + + // Implementation note: Why not use a primitive here? It + // doesn't work. See: + // http://stackoverflow.com/questions/18642371/checkbox-not-binding-to-scope-in-angularjs + $scope.formdata = {clearHold : service.clearHold}; + + $scope.ok = function() { + $uibModalInstance.close(); + + // Handle the cancellation of the assciated hold here + if ($scope.formdata.clearHold && $scope.holdID) { + $scope.args = { + cancel_reason : 5, + note: 'Item checked out by other patron' + }; + egCore.net.request( + 'open-ils.circ', 'open-ils.circ.hold.cancel', + egCore.auth.token(), $scope.holdID, + $scope.args.cancel_reason, + $scope.args.note); + } + } + $scope.cancel = function ($event) { $uibModalInstance.dismiss(); $event.preventDefault(); diff --git a/docs/RELEASE_NOTES_NEXT/Circulation/alternate_patron_hold_pickup.adoc b/docs/RELEASE_NOTES_NEXT/Circulation/alternate_patron_hold_pickup.adoc new file mode 100644 index 0000000000..d3ef60edfb --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/Circulation/alternate_patron_hold_pickup.adoc @@ -0,0 +1,20 @@ +Alternate Patron Hold Pickup +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +This feature adds a bit of convenience to a common task: checking out +an item on hold to another patron (typically a family member or helper). + +When you checkout the item, you will get a pop-up window with warnings associated +with this item. The "ITEM_ON_HOLDS_SHELF" message is now expanded to + + * Let you know the name of the person who had placed the hold. + * Give you the option (in the form of a checkbox) of cancelling the + hold placed by the above-named patron. (Checked = Cancel the hold; + Uncheked = Leave the hold in place) + +The initial value of the checkbox is derived from the circ.clear_hold_on_checkout +organizational setting. This is found under Administration -- Server Administration -- Org Unit Setting Types + +If the operator has CANCEL_HOLD privilege, then if the checkbox is checked and the checkout is allowed to proceed, +the hold will be cancelled with a note that the item was checked out to another patrron. + +This feature is available in the browser-based staff client. -- 2.11.0