Bug 18552: Borrower debarments not showing on member detail page
[koha.git] / opac / opac-renew.pl
blob03c4a714a4a411bd2cf18a2e922a0a795fb4956c
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,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>.
24 use strict;
25 use warnings;
27 use CGI qw ( -utf8 );
28 use C4::Circulation;
29 use C4::Auth;
30 use C4::Context;
31 use C4::Items;
32 use C4::Members;
33 use Koha::Patrons;
34 use Date::Calc qw( Today Date_to_Days );
35 my $query = new CGI;
37 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
39 template_name => "opac-user.tt",
40 query => $query,
41 type => "opac",
42 authnotrequired => 0,
43 debug => 1,
45 );
46 my @items = $query->multi_param('item');
48 my $opacrenew = C4::Context->preference("OpacRenewalAllowed");
50 my $errorstring = q{};
51 my $renewed = q{};
53 my $patron = Koha::Patrons->find( $borrowernumber );
55 if ( $patron->category->effective_BlockExpiredPatronOpacActions
56 && $patron->is_expired )
58 $errorstring = 'card_expired';
60 else {
61 my @renewed;
62 for my $itemnumber (@items) {
63 my ( $status, $error ) =
64 CanBookBeRenewed( $borrowernumber, $itemnumber );
65 if ( $status == 1 && $opacrenew == 1 ) {
66 my $renewalbranch = C4::Context->preference('OpacRenewalBranch');
67 my $branchcode;
68 if ( $renewalbranch eq 'itemhomebranch' ) {
69 my $item = GetItem($itemnumber);
70 $branchcode = $item->{'homebranch'};
72 elsif ( $renewalbranch eq 'patronhomebranch' ) {
73 my $borrower = GetMember( borrowernumber => $borrowernumber );
74 $branchcode = $borrower->{'branchcode'};
76 elsif ( $renewalbranch eq 'checkoutbranch' ) {
77 my $issue = GetOpenIssue($itemnumber);
78 $branchcode = $issue->{'branchcode'};
80 elsif ( $renewalbranch eq 'NULL' ) {
81 $branchcode = '';
83 else {
84 $branchcode = 'OPACRenew';
86 AddRenewal( $borrowernumber, $itemnumber, $branchcode );
87 push( @renewed, $itemnumber );
89 else {
90 $errorstring .= $error . "|";
93 $renewed = join( ':', @renewed );
96 print $query->redirect("/cgi-bin/koha/opac-user.pl?renew_error=$errorstring&renewed=$renewed");