Merge remote branch 'kc/new/bug_6162' into kcmaster
[koha.git] / opac / opac-renew.pl
blob68abed04a82c493ed73f804cf24a2b06b36fd232
1 #!/usr/bin/perl
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 Catalyst IT
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 use strict;
25 use warnings;
27 use CGI;
28 use C4::Circulation;
29 use C4::Auth;
31 my $query = new CGI;
33 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
35 template_name => "opac-user.tmpl",
36 query => $query,
37 type => "opac",
38 authnotrequired => 0,
39 flagsrequired => { borrow => 1 },
40 debug => 1,
42 );
43 my @items = $query->param('item');
44 $borrowernumber = $query->param('borrowernumber') || $query->param('bornum');
45 my $opacrenew = C4::Context->preference("OpacRenewalAllowed");
47 my $errorstring='';
48 for my $itemnumber ( @items ) {
49 my ($status,$error) = CanBookBeRenewed( $borrowernumber, $itemnumber );
50 if ( $status == 1 && $opacrenew == 1 ) {
51 AddRenewal( $borrowernumber, $itemnumber );
53 else {
54 $errorstring .= $error ."|";
58 print $query->redirect("/cgi-bin/koha/opac-user.pl?renew_error=$errorstring");