(bug #4954) allow date expiry modification only on step 0 and 3
[koha.git] / reserve / renewscript.pl
blob09630bdf7af5214f885996ba62a93f20de87d76e
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 C4::Dates qw/format_date_in_iso/;
30 my $input = new CGI;
32 #Set Up User_env
33 # And assures user is loggedin and has correct accreditations.
35 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
37 template_name => "members/moremember.tmpl",
38 query => $input,
39 type => "intranet",
40 authnotrequired => 0,
41 flagsrequired => { circulate => 1 },
42 debug => 0,
47 # find items to renew, all items or a selection of items
50 my @data;
51 if ($input->param('renew_all')) {
52 @data = $input->param('all_items[]');
54 else {
55 @data = $input->param('items[]');
58 my @barcodes;
59 if ($input->param('return_all')) {
60 @barcodes = $input->param('all_barcodes[]');
61 } else {
62 @barcodes = $input->param('barcodes[]');
65 my $branch=$input->param('branch');
66 my $datedue;
67 if ($input->param('newduedate')){
68 $datedue=C4::Dates->new($input->param('newduedate'));
71 # warn "barcodes : @barcodes";
73 # renew items
75 my $cardnumber = $input->param("cardnumber");
76 my $borrowernumber = $input->param("borrowernumber");
77 my $exemptfine = $input->param("exemptfine") || 0;
78 my $override_limit = $input->param("override_limit") || 0;
79 my $failedrenews;
80 foreach my $itemno (@data) {
81 # check status before renewing issue
82 my ($renewokay,$error) = CanBookBeRenewed($borrowernumber,$itemno,$override_limit);
83 if ($renewokay){
84 AddRenewal($borrowernumber,$itemno,$branch,$datedue);
86 else {
87 $failedrenews.="&failedrenew=$itemno";
90 my $failedreturn;
91 foreach my $barcode (@barcodes) {
92 # check status before renewing issue
93 my ( $returned, $messages, $issueinformation, $borrower ) =
94 AddReturn($barcode, $branch, $exemptfine);
95 $failedreturn.="&failedreturn=$barcode" unless ($returned);
99 # redirection to the referrer page
101 if ($input->param('destination') eq "circ"){
102 print $input->redirect(
103 '/cgi-bin/koha/circ/circulation.pl?findborrower='.$cardnumber.$failedrenews.$failedreturn
106 else {
107 print $input->redirect(
108 '/cgi-bin/koha/members/moremember.pl?borrowernumber='.$borrowernumber.$failedrenews.$failedreturn