Koha/circ/renew.pl
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

127 lines
4.2 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright 2013 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 qw ( -utf8 );
use C4::Context;
use C4::Auth qw/:DEFAULT get_session/;
use C4::Output;
use C4::Circulation;
use C4::Koha;
use Koha::DateUtils;
use Koha::Database;
use Koha::BiblioFrameworks;
my $cgi = new CGI;
my ( $template, $librarian, $cookie, $flags ) = get_template_and_user(
{
template_name => "circ/renew.tt",
query => $cgi,
type => "intranet",
authnotrequired => 0,
flagsrequired => { circulate => "circulate_remaining_permissions" },
}
);
my $schema = Koha::Database->new()->schema();
my $barcode = $cgi->param('barcode');
$barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespae
$barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
my $override_limit = $cgi->param('override_limit');
my $override_holds = $cgi->param('override_holds');
my ( $item, $issue, $borrower );
my $error = q{};
my ( $soonest_renew_date, $latest_auto_renew_date );
if ($barcode) {
$barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
$item = $schema->resultset("Item")->single( { barcode => $barcode } );
if ($item) {
$issue = $item->issue();
if ($issue) {
$borrower = $issue->borrower();
if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) {
my $can_renew;
( $can_renew, $error ) =
CanBookBeRenewed( $borrower->borrowernumber(),
$item->itemnumber(), $override_limit );
if ( $error && ($error eq 'on_reserve') ) {
if ($override_holds) {
$can_renew = 1;
$error = undef;
}
else {
$can_renew = 0;
}
}
if ( $error && ($error eq 'too_soon' or $error eq 'auto_too_soon') ) {
$soonest_renew_date = C4::Circulation::GetSoonestRenewDate(
$borrower->borrowernumber(),
$item->itemnumber(),
);
}
if ( $error && ( $error eq 'auto_too_late' ) ) {
$latest_auto_renew_date = C4::Circulation::GetLatestAutoRenewDate(
$borrower->borrowernumber(),
$item->itemnumber(),
);
}
if ($can_renew) {
my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
my $date_due = AddRenewal( undef, $item->itemnumber(), $branchcode, dt_from_string( scalar $cgi->param('renewonholdduedate')) );
$template->param( date_due => $date_due );
}
}
else {
$error = "patron_restricted";
}
}
else {
$error = "no_checkout";
}
}
else {
$error = "no_item";
}
$template->param(
item => $item,
issue => $issue,
borrower => $borrower,
error => $error,
soonestrenewdate => $soonest_renew_date,
latestautorenewdate => $latest_auto_renew_date,
);
}
# Checking if there is a Fast Cataloging Framework
$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
output_html_with_http_headers( $cgi, $cookie, $template->output );