Merged with arensb-context branch: use C4::Context->dbh instead of
[koha.git] / updatecharges.pl
1 #!/usr/bin/perl
2
3 #script to update charges for overdue in database
4 #updates categoryitem
5 # is called by charges.pl
6 # written 1/1/2000 by chris@katipo.co.nz
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 strict;
27 use CGI;
28 use C4::Context;
29 use C4::Output;
30
31 my $input = new CGI;
32 #print $input->header;
33 #print startpage();
34 #print startmenu('issue');
35
36
37 my $dbh = C4::Context->dbh;
38 #print $input->dump;
39 my @names=$input->param();
40
41 foreach my $key (@names){
42   
43   my $bor=substr($key,0,1);
44   my $cat=$key;
45   $cat =~ s/[A-Z]//i;
46   my $data=$input->param($key);
47   my @dat=split(',',$data);
48 #  print "$bor $cat $dat[0] $dat[1] $dat[2] <br> ";
49   my $sth=$dbh->prepare("Update categoryitem set fine=$dat[0],startcharge=$dat[1],chargeperiod=$dat[2] where 
50   categorycode='$bor' and itemtype='$cat'");
51   $sth->execute;
52   $sth->finish;
53 }
54 print $input->redirect("/cgi-bin/koha/charges.pl");
55 #print endmenu('issue');
56 #print endpage();