Continuing work on Z39.50 search tool. Daemon now forks up to 12 processes
[koha.git] / showbudget.pl
blobbe8e250f4170c4061f2cd90e192f6135219de0a3
1 #!/usr/bin/perl
3 #script to show list of budgets and bookfunds
4 #written 4/2/00 by chris@katipo.co.nz
5 #called as an include by the acquisitions index page
7 use C4::Acquisitions;
8 #use CGI;
9 #my $inp=new CGI;
10 #print $inp->header;
11 my ($count,@results)=bookfunds;
13 open (FILE,'>/usr/local/www/hdl/htdocs/includes/budgets.inc') || die "Cant open file";
14 print FILE <<printend
16 <TABLE width="40%" cellspacing=0 cellpadding=5 border=1 >
17 <FORM ACTION="/cgi-bin/koha/search.pl">
18 <TR VALIGN=TOP>
19 <TD bgcolor="99cc33" background="/images/background-mem.gif" colspan=2><b>BUDGETS AND BOOKFUNDS</b></TD></TR>
20 <TR VALIGN=TOP>
21 <TD colspan=2><table>
24 <tr><td>
25 <b>Budgets</B></TD> <TD><b>Total</B></TD> <TD><b>Spent</B></TD><TD><b>Comtd</B></TD><TD><b>Avail</B></TD></TR>
26 printend
28 my $total=0;
29 my $totspent=0;
30 my $totcomtd=0;
31 my $totavail=0;
32 for (my $i=0;$i<$count;$i++){
33 my ($spent,$comtd)=bookfundbreakdown($results[$i]->{'bookfundid'});
34 my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
35 print FILE <<EOP
36 <tr><td>
37 $results[$i]->{'bookfundname'} </TD>
38 <TD>$results[$i]->{'budgetamount'}</TD> <TD>
39 EOP
41 printf FILE ("%.2f", $spent);
42 print FILE "</TD><TD>";
43 printf FILE ("%.2f",$comtd);
44 print FILE "</TD><TD>";
45 printf FILE ("%.2f",$avail);
46 print FILE "</TD></TR>";
47 $total+=$results[$i]->{'budgetamount'};
48 $totspent+=$spent;
49 $totcomtd+=$comtd;
50 $totavail+=$avail;
53 print FILE <<printend
54 <tr><td colspan=5>
55 <hr size=1 noshade></TD></TR>
57 <tr><td>
58 Total </TD> <TD>$total</TD> <TD>
59 printend
61 printf FILE ("%.2f",$totspent);
62 print FILE "</TD><TD>";
63 printf FILE ("%.2f",$totcomtd);
64 print FILE "</TD><TD>";
65 printf FILE ("%.2f",$totavail);
66 print FILE "</TD></TR>";
67 print FILE <<printend
68 </table><br>
69 Use your reload button [ctrl + r] to get the most recent figures.
70 Committed figures are approximate only, as exchange rates will affect the amount actually paid.
72 </TD></TR>
73 </form>
74 </table>
76 printend
79 close FILE;