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 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
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.
34 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
36 template_name
=> "opac-user.tmpl",
40 flagsrequired
=> { borrow
=> 1 },
44 my @items = $query->param('item');
45 $borrowernumber = $query->param('borrowernumber') || $query->param('bornum');
46 my $opacrenew = C4
::Context
->preference("OpacRenewalAllowed");
49 for my $itemnumber ( @items ) {
50 my ($status,$error) = CanBookBeRenewed
( $borrowernumber, $itemnumber );
51 if ( $status == 1 && $opacrenew == 1 ) {
52 my $renewalbranch = C4
::Context
->preference('OpacRenewalBranch');
54 if ($renewalbranch eq 'itemhomebranch'){
55 my $item = GetItem
($itemnumber);
56 $branchcode=$item->{'homebranch'};
58 elsif ($renewalbranch eq 'patronhomebranch'){
59 my $borrower = GetMemberDetails
($borrowernumber);
60 $branchcode = $borrower->{'branchcode'};
62 elsif ($renewalbranch eq 'checkoutbranch'){
63 my $issue = GetOpenIssue
($itemnumber);
64 $branchcode = $issue->{'branchcode'};
66 elsif ($renewalbranch eq 'NULL'){
70 $branchcode='OPACRenew'
72 AddRenewal
( $borrowernumber, $itemnumber, $branchcode);
75 $errorstring .= $error ."|";
79 print $query->redirect("/cgi-bin/koha/opac-user.pl?renew_error=$errorstring");