Merged with arensb-context branch: use C4::Context->dbh instead of
[koha.git] / charges.pl
1 #!/usr/bin/perl
2
3 #script to display reports
4 #written 8/11/99
5
6
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 #
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA  02111-1307 USA
23
24 use strict;
25 use CGI;
26 use C4::Context;
27 use C4::Output;
28
29 my $input = new CGI;
30 print $input->header;
31 my $type=$input->param('type');
32 print startpage();
33 print startmenu('issue');
34 print "Each box needs to be filled in with fine,time to start charging,charging cycle<br>
35 eg 1,7,7 = $1 fine, after 7 days, every 7 days";
36
37 my $dbh = C4::Context->dbh;
38 my $query="Select description,categorycode from categories";
39 my $sth=$dbh->prepare($query);
40 $sth->execute;
41 print mktablehdr;
42 my @trow;
43 my @trow3;
44 my $i=0;
45 while (my $data=$sth->fetchrow_hashref){
46   $trow[$i]=$data->{'description'};
47   $trow3[$i]=$data->{'categorycode'};
48   $i++;
49 }
50 $sth->finish;
51 print mktablerow(10,'white','',@trow);
52 print "<form action=/cgi-bin/koha/updatecharges.pl method=post>";
53 $query="Select description,itemtype from itemtypes";
54 $sth=$dbh->prepare($query);
55 $sth->execute;
56 $i=0;
57
58 while (my $data=$sth->fetchrow_hashref){
59   my @trow2;
60   for ($i=0;$i<9;$i++){
61     $query="select * from categoryitem where categorycode='$trow3[$i]' and itemtype='$data->{'itemtype'}'";
62     my $sth2=$dbh->prepare($query);
63     $sth2->execute;
64     my $dat=$sth2->fetchrow_hashref;
65     $sth2->finish;
66     my $fine=$dat->{'fine'}+0;
67     $trow2[$i]="<input type=text name=\"$trow3[$i]$data->{'itemtype'}\" value=\"$fine,$dat->{'startcharge'},$dat->{'chargeperiod'}\" size=6>";
68   }
69   print mktablerow(11,'white',$data->{'description'},@trow2);
70 }
71
72 $sth->finish;
73
74
75 print "</table>";
76 print "<input type=submit></form>";
77 print endmenu('issue');
78 print endpage();