Lines 33-72
my ($template, $loggedinuser, $cookie) = get_template_and_user({
Link Here
|
33 |
}); |
33 |
}); |
34 |
my @ordernumbers = $input->multi_param('ordernumber'); |
34 |
my @ordernumbers = $input->multi_param('ordernumber'); |
35 |
|
35 |
|
36 |
my @orders; |
36 |
my $csv_profile_id = $input->param('csv_profile'); |
37 |
for my $ordernumber ( @ordernumbers ) { |
37 |
|
38 |
my $order = GetOrder $ordernumber; |
38 |
unless ( $csv_profile_id ) { |
39 |
my $order_object = Koha::Acquisition::Orders->find($ordernumber); |
39 |
my @orders; |
40 |
my $claims = $order_object->claims; |
40 |
for my $ordernumber ( @ordernumbers ) { |
41 |
push @orders, { |
41 |
my $order = GetOrder $ordernumber; |
42 |
orderdate => $order->{orderdate}, |
42 |
my $order_object = Koha::Acquisition::Orders->find($ordernumber); |
43 |
latesince => $order->{latesince}, |
43 |
my $claims = $order_object->claims; |
44 |
estimateddeliverydate => $order->{estimateddeliverydate}, |
44 |
push @orders, { |
45 |
supplier => $order->{supplier}, |
45 |
orderdate => $order->{orderdate}, |
46 |
supplierid => $order->{supplierid}, |
46 |
latesince => $order->{latesince}, |
47 |
title => $order->{title}, |
47 |
estimateddeliverydate => $order->{estimateddeliverydate}, |
48 |
author => $order->{author}, |
48 |
supplier => $order->{supplier}, |
49 |
publisher => $order->{publisher}, |
49 |
supplierid => $order->{supplierid}, |
50 |
unitpricesupplier => $order->{unitpricesupplier}, |
50 |
title => $order->{title}, |
51 |
quantity_to_receive => $order->{quantity_to_receive}, |
51 |
author => $order->{author}, |
52 |
subtotal => $order->{subtotal}, |
52 |
publisher => $order->{publisher}, |
53 |
budget => $order->{budget}, |
53 |
unitpricesupplier => $order->{unitpricesupplier}, |
54 |
basketname => $order->{basketname}, |
54 |
quantity_to_receive => $order->{quantity_to_receive}, |
55 |
basketno => $order->{basketno}, |
55 |
subtotal => $order->{subtotal}, |
56 |
claims_count => $claims->count, |
56 |
budget => $order->{budget}, |
57 |
claimed_date => $claims->count ? $claims->last->claimed_on : undef, |
57 |
basketname => $order->{basketname}, |
58 |
internalnote => $order->{order_internalnote}, |
58 |
basketno => $order->{basketno}, |
59 |
vendornote => $order->{order_vendornote}, |
59 |
claims_count => $claims->count, |
60 |
isbn => $order->{isbn}, |
60 |
claimed_date => $claims->count ? $claims->last->claimed_on : undef, |
61 |
} |
61 |
internalnote => $order->{order_internalnote}, |
62 |
; |
62 |
vendornote => $order->{order_vendornote}, |
63 |
} |
63 |
isbn => $order->{isbn}, |
|
|
64 |
} |
65 |
; |
66 |
} |
67 |
|
68 |
# We want to export using the default profile, using the template acqui/csv/lateorders.tt |
69 |
print $input->header( |
70 |
-type => 'text/csv', |
71 |
-attachment => 'lateorders.csv', |
72 |
); |
73 |
$template->param( orders => \@orders ); |
74 |
for my $line ( split '\n', $template->output ) { |
75 |
print "$line\n" unless $line =~ m|^\s*$|; |
76 |
} |
77 |
exit; |
78 |
} else { |
79 |
my $csv_profile = Koha::CsvProfiles->find($csv_profile_id); |
80 |
my $content = '[% SET separator = "'.$csv_profile->csv_separator.'" ~%]' . $csv_profile->content; |
81 |
|
82 |
my $csv = C4::Letters::_process_tt({ |
83 |
content => $content, |
84 |
loops => { aqorders => \@ordernumbers }, |
85 |
}); |
64 |
|
86 |
|
65 |
print $input->header( |
87 |
print $input->header( |
66 |
-type => 'text/csv', |
88 |
-type => 'text/csv', |
67 |
-attachment => 'lateorders.csv', |
89 |
-attachment => 'lateorders.csv', |
68 |
); |
90 |
); |
69 |
$template->param( orders => \@orders ); |
91 |
print $csv; |
70 |
for my $line ( split '\n', $template->output ) { |
92 |
exit; |
71 |
print "$line\n" unless $line =~ m|^\s*$|; |
|
|
72 |
} |
93 |
} |