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
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
28 this script is designed to show the spent amount in budgets
38 my $dbh = C4
::Context
->dbh;
40 my $bookfund = $input->param('fund');
41 my $fund_code = $input->param('fund_code');
43 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
45 template_name
=> "acqui/spent.tt",
49 flagsrequired
=> { acquisition
=> '*' },
56 aqorders.biblionumber, aqorders.basketno, aqorders.ordernumber,
57 quantity-quantityreceived AS tleft,
58 ecost, budgetdate, entrydate,
59 aqbasket.booksellerid,
63 aqinvoices.invoicenumber,
67 FROM (aqorders, aqbasket)
69 biblio.biblionumber=aqorders.biblionumber
70 LEFT JOIN aqorders_items ON
71 aqorders.ordernumber = aqorders_items.ordernumber
73 aqorders_items.itemnumber = items.itemnumber
74 LEFT JOIN aqinvoices ON
75 aqorders.invoiceid = aqinvoices.invoiceid
77 aqorders.basketno=aqbasket.basketno AND
79 (datecancellationprinted IS NULL OR
80 datecancellationprinted='0000-00-00') AND
81 datereceived IS NOT NULL
82 GROUP BY aqorders.ordernumber
84 my $sth = $dbh->prepare($query);
85 $sth->execute($bookfund);
87 die "An error occurred fetching records: " . $sth->errstr;
91 while ( my $data = $sth->fetchrow_hashref ) {
92 my $recv = $data->{'quantityreceived'};
94 my $rowtotal = $recv * $data->{'unitprice'};
95 $data->{'rowtotal'} = sprintf( "%.2f", $rowtotal );
96 $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
97 $subtotal += $rowtotal;
103 my $total = $subtotal;
105 SELECT invoicenumber
, shipmentcost
107 WHERE shipmentcost_budgetid
= ?
109 $sth = $dbh->prepare($query);
110 $sth->execute($bookfund);
112 while (my $data = $sth->fetchrow_hashref) {
113 push @shipmentcosts, {
114 shipmentcost
=> sprintf("%.2f", $data->{shipmentcost
}),
115 invoicenumber
=> $data->{invoicenumber
}
117 $total += $data->{shipmentcost
};
121 $total = sprintf( "%.2f", $total );
126 subtotal
=> $subtotal,
127 shipmentcosts
=> \
@shipmentcosts,
129 fund_code
=> $fund_code
132 output_html_with_http_headers
$input, $cookie, $template->output;