Are we getting sick of merging yet? Not me!
[koha.git] / showbudget.pl
1 #!/usr/bin/perl
2
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
6
7 use C4::Acquisitions;
8 use C4::Biblio;
9 #use CGI;
10 #my $inp=new CGI;
11 #print $inp->header;
12 my ($count,@results)=bookfunds;
13
14
15 print <<printend
16
17 <TABLE  width="40%"  cellspacing=0 cellpadding=5 border=1 >
18 <FORM ACTION="/cgi-bin/koha/search.pl">
19 <TR VALIGN=TOP>
20 <TD  bgcolor="99cc33" background="/images/background-mem.gif" colspan=2><b>BUDGETS AND BOOKFUNDS</b></TD></TR>
21 <TR VALIGN=TOP>
22 <TD colspan=2><table>
23
24
25 <tr><td>
26 <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>
27 printend
28 ;
29 my $total=0;
30 my $totspent=0;
31 my $totcomtd=0;
32 my $totavail=0;
33 for (my $i=0;$i<$count;$i++){
34   my ($spent,$comtd)=bookfundbreakdown($results[$i]->{'bookfundid'});
35   my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
36   print  <<EOP
37 <tr><td>
38 $results[$i]->{'bookfundname'} </TD> 
39 <TD>$results[$i]->{'budgetamount'}</TD> <TD>
40 EOP
41 ;
42 printf  ("%.2f", $spent);
43 print  "</TD><TD>";
44 printf  ("%.2f",$comtd);
45 print  "</TD><TD>";
46 printf  ("%.2f",$avail);
47 print  "</TD></TR>";
48   $total+=$results[$i]->{'budgetamount'};
49   $totspent+=$spent;
50   $totcomtd+=$comtd;
51   $totavail+=$avail;
52 }
53
54 print  <<printend
55 <tr><td colspan=5>
56 <hr size=1 noshade></TD></TR>
57
58 <tr><td>
59 Total </TD> <TD>$total</TD> <TD>
60 printend
61 ;
62 printf  ("%.2f",$totspent);
63 print  "</TD><TD>";
64 printf  ("%.2f",$totcomtd);
65 print  "</TD><TD>";
66 printf  ("%.2f",$totavail);
67 print  "</TD></TR>";
68 print  <<printend
69 </table><br>
70 Use your reload button [ctrl + r] to get the most recent figures.
71 Committed figures are approximate only, as exchange rates will affect the amount actually paid.
72
73 </TD></TR>
74 </form>
75 </table>
76
77 printend
78 ;
79
80 #close ;