3 #written 18/1/2000 by chris@katipo.co.nz
4 # adapted for use in the hlt opac by finlay@katipo.co.nz 29/11/2002
5 # script to renew items from the web
6 # Parts Copyright 2010,2011 Catalyst IT
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
27 use C4::Circulation qw( CanBookBeRenewed AddRenewal );
28 use C4::Auth qw( get_template_and_user );
34 my $op = $query->param('op') || q{};
36 die "op must be set" unless $op eq 'cud-renew';
38 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
40 template_name => "opac-user.tt",
45 my @issues = $query->multi_param('issue');
47 my $opacrenew = C4::Context->preference("OpacRenewalAllowed");
49 my $errorstring = q{};
52 my $patron = Koha::Patrons->find( $borrowernumber );
54 if ( $patron->category->effective_BlockExpiredPatronOpacActions_contains('renew')
55 && $patron->is_expired )
57 $errorstring = 'card_expired';
61 my $issues = Koha::Checkouts->search(
63 issue_id => { -in => \@issues }
68 while( my $issue = $issues->next) {
69 my ( $status, $error ) =
70 CanBookBeRenewed( $patron, $issue );
71 if ( $status == 1 && $opacrenew == 1 ) {
74 borrowernumber => $borrowernumber,
75 itemnumber => $issue->itemnumber,
79 push( @renewed, $issue->itemnumber );
82 $errorstring .= $error . "|";
85 $renewed = join( ':', @renewed );
88 print $query->redirect("/cgi-bin/koha/opac-user.pl?renew_error=$errorstring&renewed=$renewed");