3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
28 my ($template, $loggedinuser, $cookie) = get_template_and_user
({
29 template_name
=> "acqui/csv/lateorders.tt",
33 flagsrequired
=> {acquisition
=> 'order_receive'},
35 my @ordernumbers = $input->multi_param('ordernumber');
37 my $csv_profile_id = $input->param('csv_profile');
39 unless ( $csv_profile_id ) {
41 for my $ordernumber ( @ordernumbers ) {
42 my $order = GetOrder
$ordernumber;
43 my $order_object = Koha
::Acquisition
::Orders
->find($ordernumber);
44 my $claims = $order_object->claims;
46 orderdate
=> $order->{orderdate
},
47 latesince
=> $order->{latesince
},
48 estimateddeliverydate
=> $order->{estimateddeliverydate
},
49 supplier
=> $order->{supplier
},
50 supplierid
=> $order->{supplierid
},
51 title
=> $order->{title
},
52 author
=> $order->{author
},
53 publisher
=> $order->{publisher
},
54 unitpricesupplier
=> $order->{unitpricesupplier
},
55 quantity_to_receive
=> $order->{quantity_to_receive
},
56 subtotal
=> $order->{subtotal
},
57 budget
=> $order->{budget
},
58 basketname
=> $order->{basketname
},
59 basketno
=> $order->{basketno
},
60 claims_count
=> $claims->count,
61 claimed_date
=> $claims->count ?
$claims->last->claimed_on : undef,
62 internalnote
=> $order->{order_internalnote
},
63 vendornote
=> $order->{order_vendornote
},
64 isbn
=> $order->{isbn
},
69 # We want to export using the default profile, using the template acqui/csv/lateorders.tt
72 -attachment
=> 'lateorders.csv',
74 $template->param( orders
=> \
@orders );
75 for my $line ( split '\n', $template->output ) {
76 print "$line\n" unless $line =~ m
|^\s
*$|;
80 my $csv_profile = Koha
::CsvProfiles
->find($csv_profile_id);
81 my $content = '[% SET separator = "'.$csv_profile->csv_separator.'" ~%]' . $csv_profile->content;
83 my $csv = C4
::Letters
::_process_tt
({
85 loops
=> { aqorders
=> \
@ordernumbers },
90 -attachment
=> 'lateorders.csv',
93 print Encode
::encode_utf8
($csv);