itemtypes.pl - partial revisions, incl. replacement of invalid META Refresh calls
[koha.git] / reserve / renewscript.pl
blob28e81f270ccea842fac09e2d2e04b7a96fe6ad33
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 with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 USA
25 use CGI;
26 use C4::Circulation;
27 use C4::Auth;
29 my $input = new CGI;
31 #Set Up User_env
32 # And assures user is loggedin and has correct accreditations.
34 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
36 template_name => "members/moremember.tmpl",
37 query => $input,
38 type => "intranet",
39 authnotrequired => 0,
40 flagsrequired => { borrowers => 1 },
41 debug => 1,
46 # find items to renew, all items or a selection of items
49 my @data;
50 if ($input->param('renew_all')) {
51 @data = $input->param('all_items[]');
53 else {
54 @data = $input->param('items[]');
56 my @barcodes = $input->param('barcodes[]');
57 my $branch=$input->param('branch');
59 # warn "barcodes : @barcodes";
61 # renew items
63 my $cardnumber = $input->param("cardnumber");
64 my $borrowernumber = $input->param("borrowernumber");
65 my $failedrenews;
66 foreach my $itemno (@data) {
67 # check status before renewing issue
68 my ($renewokay,$error) = CanBookBeRenewed($borrowernumber,$itemno);
69 if ($renewokay){
70 AddRenewal($borrowernumber,$itemno,$branch);
72 else {
73 $failedrenews.="&failedrenew=$itemno";
76 my $failedreturn;
77 foreach my $barcode (@barcodes) {
78 # check status before renewing issue
79 my ( $returned, $messages, $issueinformation, $borrower ) =
80 AddReturn($barcode,$branch,1);
81 $failedreturn.="&failedreturn=$barcode" unless ($returned);
85 # redirection to the referrer page
87 if ($input->param('destination') eq "circ"){
88 print $input->redirect(
89 '/cgi-bin/koha/circ/circulation.pl?findborrower='.$cardnumber.$failedrenews.$failedreturn
92 else {
93 print $input->redirect(
94 '/cgi-bin/koha/members/moremember.pl?borrowernumber='.$borrowernumber.$failedrenews.$failedreturn