modification: deep circulation template rewrite to make it easier to
[koha.git] / reserve / renewscript.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #written 18/1/2000 by chris@katipo.co.nz
6 #script to renew items from the web
7
8
9 # Copyright 2000-2002 Katipo Communications
10 #
11 # This file is part of Koha.
12 #
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
16 # version.
17 #
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA  02111-1307 USA
25
26 use CGI;
27 use C4::Circulation::Circ2;
28
29 my $input = new CGI;
30 my @names = $input->param();
31
32 #
33 # find items to renew, all items or a selection of items
34 #
35
36 # create a look-up table to check efficiently parameter availability
37 my %is_param = map {$_ => 1} @names;
38
39 my @data;
40 if ($is_param{renew_all}) {
41     @data = $input->param('all_items[]');
42 }
43 else {
44     @data = $input->param('items[]');
45 }
46
47 #
48 # renew items
49 #
50 my %env;
51 my $cardnumber = $input->param("cardnumber");
52 my $bornum = $input->param("bornum");
53
54 foreach my $itemno (@data) {
55     #check status before renewing issue
56     if (renewstatus(\%env,$bornum,$itemno)){
57         renewbook(\%env,$bornum,$itemno);
58     }
59 }
60
61 #
62 # redirection to the referrer page
63 #
64 if ($input->param('destination') eq "circ"){
65     print $input->redirect(
66         '/cgi-bin/koha/circ/circulation.pl?findborrower='.$cardnumber
67     );
68 }
69 else {
70     print $input->redirect(
71         '/cgi-bin/koha/members/moremember.pl?bornum='.$bornum
72     );
73 }