Fixed a little bug so that flags get recalculated after an item is issued.
[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
8 # Copyright 2000-2002 Katipo Communications
9 #
10 # This file is part of Koha.
11 #
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
16 #
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA  02111-1307 USA
24
25 use C4::Acquisitions;
26 use C4::Biblio;
27 #use CGI;
28 #my $inp=new CGI;
29 #print $inp->header;
30 my ($count,@results)=bookfunds;
31
32
33 print <<printend
34
35 <TABLE  width="40%"  cellspacing=0 cellpadding=5 border=1 >
36 <FORM ACTION="/cgi-bin/koha/search.pl">
37 <TR VALIGN=TOP>
38 <TD  bgcolor="99cc33" background="/images/background-mem.gif" colspan=2><b>BUDGETS AND BOOKFUNDS</b></TD></TR>
39 <TR VALIGN=TOP>
40 <TD colspan=2><table>
41
42
43 <tr><td>
44 <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>
45 printend
46 ;
47 my $total=0;
48 my $totspent=0;
49 my $totcomtd=0;
50 my $totavail=0;
51 for (my $i=0;$i<$count;$i++){
52   my ($spent,$comtd)=bookfundbreakdown($results[$i]->{'bookfundid'});
53   my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
54   print  <<EOP
55 <tr><td>
56 $results[$i]->{'bookfundname'} </TD> 
57 <TD>$results[$i]->{'budgetamount'}</TD> <TD>
58 EOP
59 ;
60 printf  ("%.2f", $spent);
61 print  "</TD><TD>";
62 printf  ("%.2f",$comtd);
63 print  "</TD><TD>";
64 printf  ("%.2f",$avail);
65 print  "</TD></TR>";
66   $total+=$results[$i]->{'budgetamount'};
67   $totspent+=$spent;
68   $totcomtd+=$comtd;
69   $totavail+=$avail;
70 }
71
72 print  <<printend
73 <tr><td colspan=5>
74 <hr size=1 noshade></TD></TR>
75
76 <tr><td>
77 Total </TD> <TD>$total</TD> <TD>
78 printend
79 ;
80 printf  ("%.2f",$totspent);
81 print  "</TD><TD>";
82 printf  ("%.2f",$totcomtd);
83 print  "</TD><TD>";
84 printf  ("%.2f",$totavail);
85 print  "</TD></TR>";
86 print  <<printend
87 </table><br>
88 Use your reload button [ctrl + r] to get the most recent figures.
89 Committed figures are approximate only, as exchange rates will affect the amount actually paid.
90
91 </TD></TR>
92 </form>
93 </table>
94
95 printend
96 ;
97
98 #close ;