3 # script to show a breakdown of committed and spent budgets
5 # Copyright 2002-2009 Katipo Communications Limited
6 # Copyright 2010,2011 Catalyst IT Limited
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 this script is designed to show the spent amount in budgets
39 my $dbh = C4
::Context
->dbh;
41 my $bookfund = $input->param('fund');
42 my $fund_code = $input->param('fund_code');
44 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
46 template_name
=> "acqui/spent.tt",
50 flagsrequired
=> { acquisition
=> '*' },
57 aqorders.basketno, aqorders.ordernumber,
58 quantity-quantityreceived AS tleft,
59 ecost, budgetdate, entrydate,
60 aqbasket.booksellerid,
64 aqinvoices.invoicenumber,
69 FROM (aqorders, aqbasket)
71 items.biblioitemnumber=aqorders.biblioitemnumber
73 biblio.biblionumber=aqorders.biblionumber
74 LEFT JOIN aqorders_items ON
75 aqorders.ordernumber=aqorders_items.ordernumber
76 LEFT JOIN aqinvoices ON
77 aqorders.invoiceid = aqinvoices.invoiceid
79 aqorders.basketno=aqbasket.basketno AND
81 (datecancellationprinted IS NULL OR
82 datecancellationprinted='0000-00-00')
83 GROUP BY aqorders.ordernumber
85 my $sth = $dbh->prepare($query);
86 $sth->execute($bookfund);
88 die "An error occurred fetching records: " . $sth->errstr;
93 while ( my $data = $sth->fetchrow_hashref ) {
94 my $recv = $data->{'quantityreceived'};
96 my $rowtotal = $recv * $data->{'unitprice'};
97 $data->{'rowtotal'} = sprintf( "%.2f", $rowtotal );
98 $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
99 $subtotal += $rowtotal;
105 my $total = $subtotal;
107 SELECT invoicenumber
, shipmentcost
109 WHERE shipmentcost_budgetid
= ?
111 $sth = $dbh->prepare($query);
112 $sth->execute($bookfund);
114 while (my $data = $sth->fetchrow_hashref) {
115 push @shipmentcosts, {
116 shipmentcost
=> sprintf("%.2f", $data->{shipmentcost
}),
117 invoicenumber
=> $data->{invoicenumber
}
119 $total += $data->{shipmentcost
};
123 $total = sprintf( "%.2f", $total );
128 subtotal
=> $subtotal,
129 shipmentcosts
=> \
@shipmentcosts,
131 fund_code
=> $fund_code
134 output_html_with_http_headers
$input, $cookie, $template->output;