Lines 17-64
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use CGI; |
19 |
use CGI; |
|
|
20 |
|
20 |
use C4::Auth; |
21 |
use C4::Auth; |
21 |
use C4::Serials; |
|
|
22 |
use C4::Acquisition; |
22 |
use C4::Acquisition; |
23 |
use C4::Output; |
23 |
use C4::Output; |
24 |
use C4::Context; |
24 |
use C4::Context; |
25 |
|
25 |
|
26 |
use Text::CSV::Encoded; |
26 |
my $input = new CGI; |
27 |
use open qw/ :std :utf8 /; |
27 |
my ($template, $loggedinuser, $cookie) = get_template_and_user({ |
28 |
|
28 |
template_name => "acqui/csv/lateorders.tt", |
29 |
my $csv = Text::CSV::Encoded->new ({ |
29 |
query => $input, |
30 |
encoding => undef, |
30 |
type => "intranet", |
31 |
quote_char => '"', |
31 |
authnotrequired => 0, |
32 |
escape_char => '"', |
32 |
flagsrequired => {acquisition => 'order_receive'}, |
33 |
sep_char => ',', |
33 |
}); |
34 |
binary => 1, |
34 |
my @ordernumbers = $input->param('ordernumber'); |
35 |
}); |
|
|
36 |
|
37 |
my $query = new CGI; |
38 |
my @ordernumbers = $query->param('ordernumber'); |
39 |
|
40 |
print $query->header( |
41 |
-type => 'text/csv', |
42 |
-attachment => "lateorders.csv", |
43 |
); |
44 |
|
45 |
print "LATE ORDERS\n\n"; |
46 |
print "ORDER DATE,ESTIMATED DELIVERY DATE,VENDOR,INFORMATION,TOTAL COST,BASKET,CLAIMS COUNT,CLAIMED DATE\n"; |
47 |
|
35 |
|
|
|
36 |
my @orders; |
48 |
for my $ordernumber ( @ordernumbers ) { |
37 |
for my $ordernumber ( @ordernumbers ) { |
49 |
my $order = GetOrder $ordernumber; |
38 |
my $order = GetOrder $ordernumber; |
50 |
$csv->combine( |
39 |
push @orders, { |
51 |
$order->{orderdate} . " (" . $order->{latesince} . " days)", |
40 |
orderdate => $order->{orderdate}, |
52 |
$order->{estimateddeliverydate}, |
41 |
latesince => $order->{latesince}, |
53 |
$order->{supplier} . " (" . $order->{supplierid} . ") ", |
42 |
estimateddeliverydate => $order->{estimateddeliverydate}, |
54 |
$order->{title} . ( $order->{author} ? " Author: $order->{author}" : "" ) . ( $order->{publisher} ? " Published by: $order->{publisher}" : "" ), |
43 |
supplier => $order->{supplier}, |
55 |
$order->{unitpricesupplier} . "x" . $order->{quantity_to_receive} . " = " . $order->{subtotal} . " (" . $order->{budget} . ")", |
44 |
supplierid => $order->{supplierid}, |
56 |
$order->{basketname} . " (" . $order->{basketno} . ")", |
45 |
title => $order->{title}, |
57 |
$order->{claims_count}, |
46 |
author => $order->{author}, |
58 |
$order->{claimed_date} |
47 |
publisher => $order->{publisher}, |
59 |
); |
48 |
unitpricesupplier => $order->{unitpricesupplier}, |
60 |
my $string = $csv->string; |
49 |
quantity_to_receive => $order->{quantity_to_receive}, |
61 |
print $string, "\n"; |
50 |
subtotal => $order->{subtotal}, |
|
|
51 |
budget => $order->{budget}, |
52 |
basketname => $order->{basketname}, |
53 |
basketno => $order->{basketno}, |
54 |
claims_count => $order->{claims_count}, |
55 |
claimed_date => $order->{claimed_date}, |
56 |
} |
57 |
; |
62 |
} |
58 |
} |
63 |
|
59 |
|
64 |
print ",,Total Number Late, " . scalar @ordernumbers . "\n"; |
60 |
print $input->header( |
|
|
61 |
-type => 'text/csv', |
62 |
-attachment => 'lateorders.csv', |
63 |
); |
64 |
$template->param( orders => \@orders ); |
65 |
print $template->output; |