added request button, and check to see if it is requestable.
[koha.git] / charges.pl
1 #!/usr/bin/perl
2
3 #script to display reports
4 #written 8/11/99
5
6 use strict;
7 use CGI;
8 use C4::Output;
9 use C4::Database;
10 use C4::Auth;
11
12 my $input = new CGI;
13
14 my $flagsrequired;
15 $flagsrequired->{circulation}=1;
16 my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired);
17
18
19 print $input->header;
20 my $type=$input->param('type');
21 print startpage();
22 print startmenu('issue');
23 print "Each box needs to be filled in with fine,time to start charging,charging cycle<br>
24 eg 1,7,7 = $1 fine, after 7 days, every 7 days";
25
26 my $dbh=C4Connect;
27 my $query="Select description,categorycode from categories";
28 my $sth=$dbh->prepare($query);
29 $sth->execute;
30 print mktablehdr;
31 my @trow;
32 my @trow3;
33 my $i=0;
34 while (my $data=$sth->fetchrow_hashref){
35   $trow[$i]=$data->{'description'};
36   $trow3[$i]=$data->{'categorycode'};
37   $i++;
38 }
39 $sth->finish;
40 print mktablerow(10,'white','',@trow);
41 print "<form action=/cgi-bin/koha/updatecharges.pl method=post>";
42 $query="Select description,itemtype from itemtypes";
43 $sth=$dbh->prepare($query);
44 $sth->execute;
45 $i=0;
46
47 while (my $data=$sth->fetchrow_hashref){
48   my @trow2;
49   for ($i=0;$i<9;$i++){
50     $query="select * from categoryitem where categorycode='$trow3[$i]' and itemtype='$data->{'itemtype'}'";
51     my $sth2=$dbh->prepare($query);
52     $sth2->execute;
53     my $dat=$sth2->fetchrow_hashref;
54     $sth2->finish;
55     my $fine=$dat->{'fine'}+0;
56     $trow2[$i]="<input type=text name=\"$trow3[$i]$data->{'itemtype'}\" value=\"$fine,$dat->{'startcharge'},$dat->{'chargeperiod'}\" size=6>";
57   }
58   print mktablerow(11,'white',$data->{'description'},@trow2);
59 }
60
61 $sth->finish;
62
63
64 print "</table>";
65 print "<input type=submit></form>";
66 print endmenu('issue');
67 print endpage();