3 # Copyright 2006 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
24 use C4::Interface::CGI::Output;
26 my $dbh = C4::Context->dbh;
28 my $bookfund = $input->param('bookfund');
29 my $start = $input->param('start');
30 my $end = $input->param('end');
32 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
34 template_name => "acqui/bookfund.tmpl",
38 flagsrequired => { acquisition => 1 },
44 "Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived
45 as qrev,subscription,title,itemtype,aqorders.biblionumber,aqorders.booksellerinvoicenumber,
46 quantity-quantityreceived as tleft,aqorders.ordernumber
47 as ordnum,entrydate,budgetdate,booksellerid,aqbasket.basketno
48 from aqorders,aqorderbreakdown,aqbasket
49 left join biblioitems on biblioitems.biblioitemnumber=aqorders.biblioitemnumber
50 where bookfundid=? and aqorders.ordernumber=aqorderbreakdown.ordernumber and
51 aqorders.basketno=aqbasket.basketno and (budgetdate >= ? and budgetdate < ?)
52 and (datecancellationprinted is NULL or datecancellationprinted='0000-00-00')
55 my $sth = $dbh->prepare($query);
56 $sth->execute( $bookfund, $start, $end );
60 while ( my $data = $sth->fetchrow_hashref ) {
61 my $left = $data->{'tleft'};
62 if ( !$left || $left eq '' ) {
63 $left = $data->{'quantity'};
65 if ( $left && $left > 0 ) {
66 my $subtotal = $left * $data->{'ecost'};
67 $data->{subtotal} = $subtotal;
68 $data->{'left'} = $left;
69 push @commited_loop, $data;
75 COMMITEDLOOP => \@commited_loop,
81 output_html_with_http_headers $input, $cookie, $template->output;