Bugzilla – Attachment 118189 Details for
Bug 14783
Allow patrons to change pickup location for non-waiting holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Allow users to change pickup location for hold from the opac
0001-Bug-14783-Change-pickup-location-from-opac.patch (text/plain), 8.01 KB, created by
Björn Nylén
on 2021-03-12 13:16:13 UTC
(
hide
)
Description:
Allow users to change pickup location for hold from the opac
Filename:
MIME Type:
Creator:
Björn Nylén
Created:
2021-03-12 13:16:13 UTC
Size:
8.01 KB
patch
obsolete
>From 023faeaecb10ada8f678ea5be472927f62e2f594 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Bj=C3=B6rn=20Nyl=C3=A9n?= <bjorn.nylen@ub.lu.se> >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 >--- > 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 | 18 +++++++++++++++++ > 6 files changed, 65 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 892fb20cd5..3da0639f33 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -606,6 +606,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( $use_calendar ); >+ >+=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 3ead03b283..a82fab0276 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -380,6 +380,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 3bb28f5541..d16793c106 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 >@@ -766,6 +766,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 78735ba4a0..f1bb0bbf7e 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc >@@ -88,7 +88,17 @@ > [% UNLESS( singleBranchMode) %] > <td class="branch"> > <span class="tdlabel">Pick up location:</span> >- [% HOLD.branch.branchname | html %] >+ [% IF ( HOLD.can_change_branch_opac ) %] >+ <form class="change_branch" action="/cgi-bin/koha/opac-modrequest.pl" method="post"> >+ <select name="new_branch" > >+ [% PROCESS options_for_libraries libraries = Branches.pickup_locations({ search_params => { biblio => HOLD.biblionumber, patron => HOLD.borrower }, selected => HOLD.branchcode }) %] >+ </select> >+ <input type="hidden" name="new_branch_reserveid" value="[% HOLD.reserve_id | html %]" /> >+ <button class="btn btn-primary" type="submit" name="change_branch" value="1">Change</button> >+ </form> >+ [% ELSE %] >+ [% HOLD.branch.branchname | html %] >+ [% END %] > </td> > [% END %] > [% IF ( showpriority ) %] >diff --git a/opac/opac-modrequest.pl b/opac/opac-modrequest.pl >index d63781b8f9..950690855a 100755 >--- a/opac/opac-modrequest.pl >+++ b/opac/opac-modrequest.pl >@@ -49,4 +49,22 @@ 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(); >+ my $transfer; >+ $transfer = $hold->item->get_transfer if $hold->item; >+ $hold->item->request_transfer( >+ { to => $hold->branch, >+ reason => $transfer->reason, >+ replace => 1, >+ } ) if $transfer; >+ } >+} >+ > print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds"); >-- >2.25.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14783
:
118189
|
118241
|
123199
|
123271
|
123708
|
123709
|
127488
|
127490
|
127492
|
130344
|
130345
|
130346
|
130347
|
141499
|
141500
|
141501
|
141502
|
141727
|
141728
|
141729
|
141730
|
142009
|
142010
|
142011
|
142012
|
142013
|
142014
|
142015
|
143025