Koha/svc/renew
Andrew Isherwood c48af49ded Bug 7088: Allow renew on hold items with due date
This patch adds the ability for items that are on hold to be renewed with a due date specfied by the user. It is enabled by the new "AllowRenewalOnHoldOverride" syspref. It is manifested in two locations:

1. In the "Checkouts" table on the Patron Details screen. It is now possible to select on loan items that would otherwise fulfil a hold request to be renewed. When such an item is selected, an additional date selection box is displayed to allow the user to specify the due date for all on hold items that are to be renewed.

2. In the Circulation > Renew alert screen. When a barcode of an on loan item that would ordinarily fulfil a hold request is entered, the usual alert is displayed indicating that the item is on hold, it is still possible to override this, and renew, however it is now also possible to specify a due date.

Test plan:

- Go to the Patron Details page for a patron who has an item on loan that would fulfil an outstanding loan request.
- TEST: Observe that it is NOT possible to select this item
- Enable the "AllowRenewalOnHoldOverride" syspref
- Return to the Patron Details page for a patron who has an item on loan that would fulfil an outstanding loan request.
- TEST: Observe that it IS possible to select this item
- Select the item
- TEST: Observe that an additional "On hold due date" input box is displayed
- De-select the item
- TEST: Observe that an additional "On hold due date" input box is hidden
- Select the item
- In the "On hold due date" input box, select a due date for the item
- Click "Renew or check in selected items"
- TEST: Observe that the item is renewed as usual
- In the "Renewal due date" input box, select a due date
- Remove the contents of the "On hold due date" input box
- Click "Renew or check in selected items"
- TEST: Observe that the item is renewed by falling back to the "Renewal due date" value if a value is not specified in the "On hold due date" input box
- Remove the contents of the "Renewal due date" input box
- Click "Renew or check in selected items"
- TEST: Observe that the standard loan period is used for the renewal period if no due date is specified in either box
- In the "On hold due date" input box, select a due date for the item
- In the "Renewal due date" input box, select a different due date
- Click "Renew all"
- TEST: Observe that all non on hold items are renewed using the value in "Renewal due date" and on hold items are renewed using the value in "On hold due date"
- From the main staff client from page, choose "Circulation", then choose "Renew"
- Enter the barcode of an item that you know to be on hold and submit
- TEST: In the alert box that appears, observe that a date picker is
displayed
- Choose a due date for this item, then click "Override and renew"
- TEST: In the "Item renewed" box, observe that the item has been
renewed to the date specified

Sponsored-by: Cheshire Libraries Shared Services
Sponsored-by: Halton Borough Council
Sponsored-by: Sefton Council

Signed-off-by: Andrew Farthing <Andrew.Farthing@sefton.gov.uk>

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2019-05-09 14:40:49 +00:00

73 lines
2.2 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright 2014 ByWater Solutions
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use CGI;
use JSON qw(to_json);
use C4::Circulation;
use C4::Context;
use C4::Auth qw(check_cookie_auth);
use Koha::DateUtils qw(output_pref dt_from_string);
my $input = new CGI;
my ( $auth_status, $sessionID ) =
check_cookie_auth( $input->cookie('CGISESSID'),
{ circulate => 'circulate_remaining_permissions' } );
if ( $auth_status ne "ok" ) {
exit 0;
}
binmode STDOUT, ":encoding(UTF-8)";
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
my $itemnumber = $input->param('itemnumber');
my $borrowernumber = $input->param('borrowernumber');
my $override_limit = $input->param('override_limit');
my $branchcode = $input->param('branchcode')
|| C4::Context->userenv->{'branch'};
my $date_due;
if ( $input->param('date_due') ) {
$date_due = dt_from_string( scalar $input->param('date_due') );
}
my $data;
$data->{itemnumber} = $itemnumber;
$data->{borrowernumber} = $borrowernumber;
$data->{branchcode} = $branchcode;
( $data->{renew_okay}, $data->{error} ) =
CanBookBeRenewed( $borrowernumber, $itemnumber, $override_limit );
# If we're allowing reserved items to be renewed...
if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference('AllowRenewalOnHoldOverride')) {
$data->{renew_okay} = 1;
$data->{error} = undef;
}
if ( $data->{renew_okay} ) {
$date_due = AddRenewal( $borrowernumber, $itemnumber, $branchcode, $date_due );
$data->{date_due} = output_pref( { dt => $date_due, as_due_date => 1 } );
}
print to_json($data);