From bfcebcc56b657dbb85d53e1e6625e64e4aa54160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nyl=C3=A9n?= Date: Thu, 11 Mar 2021 17:24:25 +0100 Subject: [PATCH] Bug 14783: Change pickup location from opac. This patch allows users to change the pickup location for their holds from the opac. A syspref (OPACAllowUserToChangeBranch) controls at what stage a hold can be changed. To test: 1. Set up holds with diffrent statuses for a patron (pending, waiting, in transit, suspended) 2. No pickup locations for any hold should be able to be changed. 3. Turn on and off the different options under OPACAllowUserToChangeBranch. Make sure that only the corresponding holds can be changed from the opac. Check eg in the staff client that pickup location has changed. 4. The available pickup locations should respect any transfer restrictions. (Same as the holds list for a biblio in staff client) 5. For an in-transit hold: Check in the item at the original pickup location. 6. Note that it will be redirected to the new location. Sponsored-by: Lunds Universitetsbibliotek Signed-off-by: Owen Leonard Signed-off-by: Barbara Johnson --- Koha/Hold.pm | 20 +++++++++++++++++++ ...OpacAllowPickupLocationChange_syspref.perl | 8 ++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/circulation.pref | 7 +++++++ .../bootstrap/en/includes/holds-table.inc | 12 ++++++++++- opac/opac-modrequest.pl | 11 ++++++++++ 6 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_14783-add_OpacAllowPickupLocationChange_syspref.perl diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 7840f2d786..9a51298b52 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -678,6 +678,26 @@ sub to_api_mapping { }; } +=head3 can_change_branch_opac + +returns if a hold can change pickup location from opac + +my $can_change_branch_opac = $hold->can_change_branch_opac; + +=cut + +sub can_change_branch_opac { + my ($self) = @_; + + my @statuses = split /,/, C4::Context->preference("OPACAllowUserToChangeBranch"); + foreach my $status ( @statuses ){ + return 1 if ($status eq 'pending' && !$self->is_found && !$self->is_suspended ); + return 1 if ($status eq 'intransit' && $self->is_in_transit); + return 1 if ($status eq 'suspended' && $self->is_suspended); + } + return 0; +} + =head2 Internal methods =head3 _type diff --git a/installer/data/mysql/atomicupdate/bug_14783-add_OpacAllowPickupLocationChange_syspref.perl b/installer/data/mysql/atomicupdate/bug_14783-add_OpacAllowPickupLocationChange_syspref.perl new file mode 100644 index 0000000000..3354581f42 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_14783-add_OpacAllowPickupLocationChange_syspref.perl @@ -0,0 +1,8 @@ + + +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( "INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('OPACAllowUserToChangeBranch','','Pending, In-Transit, Suspended','Allow users to change the library to pick up a hold for these statuses:','multiple');" ); + # Always end with this (adjust the bug info) + NewVersion( $DBversion, 14783, "Allow patrons to change pickup location for non-waiting holds"); +} diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index dd83a00fd8..ede8eb28e8 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -393,6 +393,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OpacAllowPublicListCreation','1',NULL,'If set, allows opac users to create public lists','YesNo'), ('OpacAllowSharingPrivateLists','0',NULL,'If set, allows opac users to share private lists with other patrons','YesNo'), ('OPACAllowUserToChooseBranch','1','1','Allow the user to choose the branch they want to pickup their hold from','YesNo'), +('OPACAllowUserToChangeBranch','','Pending, In-Transit, Suspended','Allow users to change the library to pick up a hold for these statuses:','multiple'), ('OPACAmazonCoverImages','0','','Display cover images on OPAC from Amazon Web Services','YesNo'), ('OpacAuthorities','1',NULL,'If ON, enables the search authorities link on OPAC','YesNo'), ('OPACBaseURL','',NULL,'Specify the Base URL of the OPAC, e.g., http://opac.mylibrary.com, including the protocol (http:// or https://). Otherwise, the http:// will be added automatically by Koha upon saving.','Free'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index ecc49a3a90..41518b0952 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -767,6 +767,13 @@ Circulation: 1: Allow 0: "Don't allow" - a user to choose the library to pick up a hold from. + - + - 'Allow users to change the library to pick up a hold for these statuses:' + - pref: OPACAllowUserToChangeBranch + multiple: + pending: Pending + intransit: In transit + suspended: Suspended - - pref: ReservesNeedReturns choices: diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc index 2263737ec8..4b1badacf6 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc @@ -84,7 +84,17 @@ [% UNLESS( singleBranchMode) %] Pick up location: - [% HOLD.branch.branchname | html %] + [% IF ( HOLD.can_change_branch_opac ) %] +
+ + + +
+ [% ELSE %] + [% HOLD.branch.branchname | html %] + [% END %] [% END %] [% IF ( showpriority ) %] diff --git a/opac/opac-modrequest.pl b/opac/opac-modrequest.pl index 05b01a836a..7bf7d0f0c1 100755 --- a/opac/opac-modrequest.pl +++ b/opac/opac-modrequest.pl @@ -48,4 +48,15 @@ if ($reserve_id && $borrowernumber) { } } +#Change pickup location for hold +my $change_branch = $query->param('change_branch'); +if ($change_branch){ + my $new_branch_reserveid = $query->param('new_branch_reserveid'); + my $new_branch = $query->param('new_branch'); + my $hold = Koha::Holds->find( $new_branch_reserveid ); + if ($hold && $hold->can_change_branch_opac){ + $hold->branchcode($new_branch)->store(); + } +} + print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds"); -- 2.20.1