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 <oleonard@myacpl.org>

Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Björn Nylén 2022-10-07 11:22:19 +00:00 committed by Tomas Cohen Arazi
parent ace48e8911
commit 4ef87fe837
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
6 changed files with 47 additions and 15 deletions

View file

@ -906,6 +906,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

View file

@ -0,0 +1,10 @@
$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');" );
$dbh->do( "UPDATE systempreferences set value = (SELECT CASE WHEN value = 1 THEN 'intransit' ELSE '' END FROM systempreferences WHERE variable = 'OPACInTransitHoldPickupLocationChange')");
$dbh->do( "DELETE FROM systempreferences WHERE variable = 'OPACInTransitHoldPickupLocationChange' ");
# Always end with this (adjust the bug info)
NewVersion( $DBversion, 14783, "Allow patrons to change pickup location for non-waiting holds");
}

File diff suppressed because one or more lines are too long

View file

@ -695,12 +695,6 @@ Circulation:
1: Allow
0: "Don't allow"
- a patron to renew an item with unfilled holds if other available items can fill that hold.
-
- pref: OPACInTransitHoldPickupLocationChange
choices:
1: Allow
0: "Don't allow"
- patrons to change their in transit holds pickup location.
-
- pref: AllowHoldPolicyOverride
choices:
@ -801,6 +795,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:

View file

@ -82,16 +82,17 @@
[% UNLESS( singleBranchMode) %]
<td class="branch">
<span class="tdlabel">Pick up location:</span>
[% IF Koha.Preference('OPACInTransitHoldPickupLocationChange') && HOLD.is_in_transit %]
<form class="form-inline" action="/cgi-bin/koha/opac-modrequest.pl" method="post">
<input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
<select name="new_pickup_location" class="new_pickup_location" onchange="this.form.submit()">
[% PROCESS options_for_libraries libraries => Branches.pickup_locations({ search_params => { item => HOLD.itemnumber, patron => logged_in_user }, selected => HOLD.branchcode }) %]
</select>
[% 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 %]
[% END %]
</td>
[% END %]
[% IF ( showpriority ) %]

View file

@ -60,7 +60,7 @@ if ( $reserve_id && $borrowernumber ) {
}
elsif ( $new_pickup_location ) {
if ( C4::Context->preference('OPACInTransitHoldPickupLocationChange') ) {
if ($hold->can_change_branch_opac){
$hold->set_pickup_location({ library_id => $new_pickup_location });
}
else {