Lines 1-7
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
# Copyright 2008 - 2009 BibLibre SARL |
3 |
# Copyright 2008 - 2009 BibLibre SARL |
4 |
# Copyright 2010 Catalyst IT Limited |
4 |
# Copyright 2010,2011 Catalyst IT Limited |
5 |
# This file is part of Koha. |
5 |
# This file is part of Koha. |
6 |
# |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it under the |
7 |
# Koha is free software; you can redistribute it and/or modify it under the |
Lines 27-45
this script is to show orders ordered but not yet received
Link Here
|
27 |
|
27 |
|
28 |
=cut |
28 |
=cut |
29 |
|
29 |
|
30 |
|
|
|
31 |
use C4::Context; |
30 |
use C4::Context; |
32 |
use strict; |
31 |
use strict; |
33 |
use warnings; |
32 |
use warnings; |
34 |
use CGI; |
33 |
use CGI; |
35 |
use C4::Auth; |
34 |
use C4::Auth; |
36 |
use C4::Output; |
35 |
use C4::Output; |
|
|
36 |
use C4::Dates; |
37 |
|
37 |
|
38 |
my $dbh = C4::Context->dbh; |
38 |
my $dbh = C4::Context->dbh; |
39 |
my $input = new CGI; |
39 |
my $input = new CGI; |
40 |
my $fund_id = $input->param('fund'); |
40 |
my $fund_id = $input->param('fund'); |
41 |
my $start = $input->param('start'); |
41 |
my $start = $input->param('start'); |
42 |
my $end = $input->param('end'); |
42 |
my $end = $input->param('end'); |
43 |
|
43 |
|
44 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
44 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
45 |
{ |
45 |
{ |
Lines 56-62
my $query = <<EOQ;
Link Here
|
56 |
SELECT |
56 |
SELECT |
57 |
aqorders.basketno, aqorders.ordernumber, |
57 |
aqorders.basketno, aqorders.ordernumber, |
58 |
quantity-quantityreceived AS tleft, |
58 |
quantity-quantityreceived AS tleft, |
59 |
ecost, budgetdate, |
59 |
ecost, budgetdate, entrydate, |
60 |
aqbasket.booksellerid, |
60 |
aqbasket.booksellerid, |
61 |
itype, |
61 |
itype, |
62 |
title |
62 |
title |
Lines 73-85
WHERE
Link Here
|
73 |
(datecancellationprinted IS NULL OR |
73 |
(datecancellationprinted IS NULL OR |
74 |
datecancellationprinted='0000-00-00') AND |
74 |
datecancellationprinted='0000-00-00') AND |
75 |
(quantity > quantityreceived OR quantityreceived IS NULL) |
75 |
(quantity > quantityreceived OR quantityreceived IS NULL) |
|
|
76 |
GROUP BY aqorders.ordernumber |
76 |
EOQ |
77 |
EOQ |
77 |
|
78 |
|
78 |
my $sth = $dbh->prepare($query); |
79 |
my $sth = $dbh->prepare($query); |
79 |
|
80 |
|
80 |
$sth->execute( $fund_id); |
81 |
$sth->execute($fund_id); |
81 |
if ($sth->err) { |
82 |
if ( $sth->err ) { |
82 |
die "Error occurred fetching records: ".$sth->errstr; |
83 |
die "Error occurred fetching records: " . $sth->errstr; |
83 |
} |
84 |
} |
84 |
my @ordered; |
85 |
my @ordered; |
85 |
|
86 |
|
Lines 91-108
while ( my $data = $sth->fetchrow_hashref ) {
Link Here
|
91 |
} |
92 |
} |
92 |
if ( $left && $left > 0 ) { |
93 |
if ( $left && $left > 0 ) { |
93 |
my $subtotal = $left * $data->{'ecost'}; |
94 |
my $subtotal = $left * $data->{'ecost'}; |
94 |
$data->{subtotal} = sprintf ("%.2f", $subtotal); |
95 |
$data->{subtotal} = sprintf( "%.2f", $subtotal ); |
95 |
$data->{'left'} = $left; |
96 |
$data->{'left'} = $left; |
96 |
push @ordered, $data; |
97 |
push @ordered, $data; |
97 |
$total += $subtotal; |
98 |
$total += $subtotal; |
98 |
} |
99 |
} |
|
|
100 |
my $entrydate = C4::Dates->new( $data->{'entrydate'}, 'iso' ); |
101 |
$data->{'entrydate'} = $entrydate->output("syspref"); |
99 |
} |
102 |
} |
100 |
$total = sprintf ("%.2f", $total); |
103 |
$total = sprintf( "%.2f", $total ); |
101 |
$template->param( |
104 |
|
102 |
ordered => \@ordered, |
105 |
$template->{VARS}->{'fund'} = $fund_id; |
103 |
total => $total |
106 |
$template->{VARS}->{'ordered'} = \@ordered; |
104 |
); |
107 |
$template->{VARS}->{'total'} = $total; |
|
|
108 |
|
105 |
$sth->finish; |
109 |
$sth->finish; |
106 |
$dbh->disconnect; |
|
|
107 |
|
110 |
|
108 |
output_html_with_http_headers $input, $cookie, $template->output; |
111 |
output_html_with_http_headers $input, $cookie, $template->output; |