Bug 7245 Tables population with mandatory data for italian installation
[koha.git] / reserve / renewscript.pl
blobf4c7fb41252bddae02b34a26dda541c1376a9320
1 #!/usr/bin/perl
4 #written 18/1/2000 by chris@katipo.co.nz
5 #script to renew items from the web
8 # Copyright 2000-2002 Katipo Communications
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along
22 # with Koha; if not, write to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 use strict;
25 use warnings;
26 use CGI;
27 use C4::Circulation;
28 use C4::Auth;
29 use URI::Escape;
30 use C4::Dates qw/format_date_in_iso/;
31 my $input = new CGI;
33 #Set Up User_env
34 # And assures user is loggedin and has correct accreditations.
36 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38 template_name => "members/moremember.tmpl",
39 query => $input,
40 type => "intranet",
41 authnotrequired => 0,
42 flagsrequired => { circulate => 'circulate_remaining_permissions' },
43 debug => 0,
48 # find items to renew, all items or a selection of items
51 my @data;
52 if ($input->param('renew_all')) {
53 @data = $input->param('all_items[]');
55 else {
56 @data = $input->param('items[]');
59 my @barcodes;
60 if ($input->param('return_all')) {
61 @barcodes = $input->param('all_barcodes[]');
62 } else {
63 @barcodes = $input->param('barcodes[]');
66 my $branch=$input->param('branch');
67 my $datedue;
68 if ($input->param('newduedate')){
69 $datedue=C4::Dates->new($input->param('newduedate'));
72 # warn "barcodes : @barcodes";
74 # renew items
76 my $cardnumber = $input->param("cardnumber");
77 my $borrowernumber = $input->param("borrowernumber");
78 my $exemptfine = $input->param("exemptfine") || 0;
79 my $override_limit = $input->param("override_limit") || 0;
80 my $failedrenews = q{};
81 foreach my $itemno (@data) {
82 # check status before renewing issue
83 my ($renewokay,$error) = CanBookBeRenewed($borrowernumber,$itemno,$override_limit);
84 if ($renewokay){
85 AddRenewal($borrowernumber,$itemno,$branch,$datedue);
87 else {
88 $failedrenews.="&failedrenew=$itemno";
91 my $failedreturn = q{};
92 foreach my $barcode (@barcodes) {
93 # check status before renewing issue
94 my ( $returned, $messages, $issueinformation, $borrower ) =
95 AddReturn($barcode, $branch, $exemptfine);
96 $failedreturn.="&failedreturn=$barcode" unless ($returned);
100 # redirection to the referrer page
102 if ($input->param('destination') eq "circ"){
103 $cardnumber = uri_escape($cardnumber);
104 print $input->redirect(
105 '/cgi-bin/koha/circ/circulation.pl?findborrower='.$cardnumber.$failedrenews.$failedreturn
108 else {
109 print $input->redirect(
110 '/cgi-bin/koha/members/moremember.pl?borrowernumber='.$borrowernumber.$failedrenews.$failedreturn