*** empty log message ***
[koha.git] / admin / charges.pl
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 use strict;
21 use CGI;
22 use C4::Context;
23 use C4::Output;
24 use C4::Database;
25 use C4::Auth;
26 use C4::Output;
27 use C4::Interface::CGI::Output;
28 use HTML::Template;
29
30 my $input = new CGI;
31
32 my $flagsrequired;
33 $flagsrequired->{circulation}=1;
34 my ($template, $loggedinuser, $cookie)
35     = get_template_and_user({template_name => "parameters/charges.tmpl",
36                              query => $input,
37                              type => "intranet",
38                              authnotrequired => 0,
39                              flagsrequired => {parameters => 1},
40                               debug => 1,
41                              });
42
43 my $type=$input->param('type');
44
45 my $dbh = C4::Context->dbh;
46 my $sth=$dbh->prepare("Select description,categorycode from categories");
47 $sth->execute;
48  my @trow3;
49 my @title_loop;
50 my $i=0;
51 while (my $data=$sth->fetchrow_hashref){
52         my %row = (in_title => $data->{'description'});
53         push @title_loop,\%row;
54         $trow3[$i]=$data->{'categorycode'};
55         $i++;
56 }
57 $sth->finish;
58 $sth=$dbh->prepare("Select description,itemtype from itemtypes");
59 $sth->execute;
60 $i=0;
61 my $toggle="white";
62 my @row_loop;
63 while (my $data=$sth->fetchrow_hashref){
64         my @trow2;
65         my @cell_loop;
66         if ( $toggle eq 'white' ) {
67                 $toggle = '#ffffcc';
68         } else {
69                 $toggle = 'white';
70         }
71         for ($i=0;$i<9;$i++){
72                 my $sth2=$dbh->prepare("select * from categoryitem where categorycode=? and itemtype=?");
73                 $sth2->execute($trow3[$i],$data->{'itemtype'});
74                 my $dat=$sth2->fetchrow_hashref;
75                 $sth2->finish;
76                 my $fine=$dat->{'fine'}+0;
77 #               $trow2[$i]="<input type=text name=\"$trow3[$i].$data->{'itemtype'}\" value=\"$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}\" size=6>";
78                 my %row = (inputname=> "$trow3[$i].$data->{'itemtype'}",
79                                                 inputvalue => "$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}",
80                                                 toggle => $toggle,
81                                                 );
82                 push @cell_loop,\%row;
83         }
84         my %row = (categorycode => $data->{description},
85                                         cell =>\@cell_loop);
86         push @row_loop, \%row;
87 }
88
89 $sth->finish;
90 $template->param(title => \@title_loop,
91                                                 row => \@row_loop);
92 output_html_with_http_headers $input, $cookie, $template->output;