-
Notifications
You must be signed in to change notification settings - Fork 54
/
renewscript.pl
executable file
·122 lines (110 loc) · 3.56 KB
/
renewscript.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env perl
#written 18/1/2000 by chris@katipo.co.nz
#script to renew items from the web
# Copyright 2000-2002 Katipo Communications
#
# 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 2 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., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use warnings;
use CGI;
use C4::Circulation;
use C4::Auth;
use URI::Escape;
use C4::Dates qw/format_date_in_iso/;
my $input = new CGI;
#Set Up User_env
# And assures user is loggedin and has correct accreditations.
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "members/moremember.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
flagsrequired => { borrowers => '*' },
debug => 1,
}
);
#
# find items to renew, all items or a selection of items
#
my @data;
if ($input->param('renew_all')) {
@data = $input->param('all_items[]');
}
else {
@data = $input->param('items[]');
}
my @barcodes;
if ($input->param('return_all')) {
@barcodes = $input->param('all_barcodes[]');
} else {
@barcodes = $input->param('barcodes[]');
}
my $branch=$input->param('branch');
my $charges_overridden=$input->param('charges_overridden');
my $override_user=$input->param('override_user');
my $override_pass=$input->param('override_pass');
my $datedue;
if ($input->param('newduedate')){
$datedue=C4::Dates->new($input->param('newduedate'));
}
# warn "barcodes : @barcodes";
#
# renew items
#
my $cardnumber = $input->param("cardnumber");
my $borrowernumber = $input->param("borrowernumber");
my $exemptfine = $input->param("exemptfine") || 0;
my $override_limit = $input->param("override_limit") || 0;
my $failedrenews = '';
foreach my $itemno (@data) {
# check status before renewing issue
my ($renewokay,$error) = CanBookBeRenewed($borrowernumber,$itemno,$override_limit);
if ($renewokay){
AddRenewal(
borrowernumber => $borrowernumber,
itemnumber => $itemno,
branch => $branch,
datedue => $datedue,
exemptfine => $exemptfine,
);
}
else {
$failedrenews.="&failedrenew=$itemno";
}
}
my $failedreturn = '';
foreach my $barcode (@barcodes) {
# check status before renewing issue
my ( $returned, $messages, $issueinformation, $borrower ) =
AddReturn($barcode, $branch, $exemptfine);
$failedreturn.="&failedreturn=$barcode" unless ($returned);
}
#
# redirection to the referrer page
#
if (($input->param('destination') eq "circ")
|| ($ENV{HTTP_REFERER} =~ /circulation\.pl/)) {
$cardnumber = uri_escape($cardnumber);
print $input->redirect(
"/cgi-bin/koha/circ/circulation.pl?override_user=$override_user&override_pass=$override_pass&charges_overridden=$charges_overridden&findborrower=$cardnumber".$failedrenews.$failedreturn
);
}
else {
print $input->redirect(
"/cgi-bin/koha/members/moremember.pl?borrowernumber=".$borrowernumber.$failedrenews.$failedreturn
);
}