@@ -, +, @@ --- 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 --- a/Koha/Hold.pm +++ a/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; + +=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 --- a/installer/data/mysql/atomicupdate/bug_14783-add_OpacAllowPickupLocationChange_syspref.perl +++ a/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"); +} --- a/installer/data/mysql/mandatory/sysprefs.sql +++ a/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'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ a/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: --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc @@ -88,7 +88,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 ) %] --- a/opac/opac-modrequest.pl +++ a/opac/opac-modrequest.pl @@ -49,4 +49,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"); --