3 # Copyright 2008 - 2009 BibLibre SARL
4 # Copyright 2010,2011 Catalyst IT Limited
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
26 this script is to show orders ordered but not yet received
36 my $dbh = C4
::Context
->dbh;
38 my $fund_id = $input->param('fund');
39 my $fund_code = $input->param('fund_code');
41 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
43 template_name
=> "acqui/ordered.tt",
47 flagsrequired
=> { acquisition
=> '*' },
54 aqorders.biblionumber, aqorders.basketno, aqorders.ordernumber,
55 quantity-quantityreceived AS tleft,
56 ecost, budgetdate, entrydate,
57 aqbasket.booksellerid,
60 FROM (aqorders, aqbasket)
62 biblio.biblionumber=aqorders.biblionumber
63 LEFT JOIN aqorders_items ON
64 aqorders.ordernumber=aqorders_items.ordernumber
66 items.itemnumber=aqorders_items.itemnumber
68 aqorders.basketno=aqbasket.basketno AND
70 (datecancellationprinted IS NULL OR
71 datecancellationprinted='0000-00-00') AND
72 (quantity > quantityreceived OR quantityreceived IS NULL)
73 GROUP BY aqorders.ordernumber
76 my $sth = $dbh->prepare($query);
78 $sth->execute($fund_id);
80 die "Error occurred fetching records: " . $sth->errstr;
85 while ( my $data = $sth->fetchrow_hashref ) {
86 my $left = $data->{'tleft'};
87 if ( !$left || $left eq '' ) {
88 $left = $data->{'quantity'};
90 if ( $left && $left > 0 ) {
91 my $subtotal = $left * $data->{'ecost'};
92 $data->{subtotal
} = sprintf( "%.2f", $subtotal );
93 $data->{'left'} = $left;
98 $total = sprintf( "%.2f", $total );
100 $template->{VARS
}->{'fund'} = $fund_id;
101 $template->{VARS
}->{'ordered'} = \
@ordered;
102 $template->{VARS
}->{'total'} = $total;
103 $template->{VARS
}->{'fund_code'} = $fund_code;
107 output_html_with_http_headers
$input, $cookie, $template->output;