Lines 17-23
package C4::Acquisition;
Link Here
|
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
19 |
|
20 |
|
|
|
21 |
use strict; |
20 |
use strict; |
22 |
use warnings; |
21 |
use warnings; |
23 |
use Carp; |
22 |
use Carp; |
Lines 34-39
use C4::Templates qw(gettemplate);
Link Here
|
34 |
|
33 |
|
35 |
use Time::localtime; |
34 |
use Time::localtime; |
36 |
use HTML::Entities; |
35 |
use HTML::Entities; |
|
|
36 |
use Text::CSV::Encoded; |
37 |
|
37 |
|
38 |
use vars qw($VERSION @ISA @EXPORT); |
38 |
use vars qw($VERSION @ISA @EXPORT); |
39 |
|
39 |
|
Lines 234-284
$cgi parameter is needed for column name translation
Link Here
|
234 |
=cut |
234 |
=cut |
235 |
|
235 |
|
236 |
sub GetBasketAsCSV { |
236 |
sub GetBasketAsCSV { |
237 |
my ($basketno, $cgi) = @_; |
237 |
my ($basketno, $lh) = @_; |
238 |
my $basket = GetBasket($basketno); |
238 |
my $basket = GetBasket($basketno); |
239 |
my @orders = GetOrders($basketno); |
239 |
my @orders = GetOrders($basketno); |
240 |
my $contract = GetContract($basket->{'contractnumber'}); |
240 |
my $contract = GetContract($basket->{'contractnumber'}); |
|
|
241 |
my $csv = Text::CSV::Encoded->new(); |
242 |
my $output; |
243 |
|
244 |
my @headers = ( |
245 |
$lh->maketext('Contract name'), |
246 |
$lh->maketext('Order number'), |
247 |
$lh->maketext('Entry date'), |
248 |
$lh->maketext('ISBN'), |
249 |
$lh->maketext('Author'), |
250 |
$lh->maketext('Title'), |
251 |
$lh->maketext('Publication year'), |
252 |
$lh->maketext('Publisher code'), |
253 |
$lh->maketext('Collection title'), |
254 |
$lh->maketext('Notes'), |
255 |
$lh->maketext('Quantity'), |
256 |
$lh->maketext('RRP'), |
257 |
$lh->maketext('Delivery place'), |
258 |
$lh->maketext('Billing place'), |
259 |
); |
241 |
|
260 |
|
242 |
my $template = C4::Templates::gettemplate("acqui/csv/basket.tmpl", "intranet", $cgi); |
261 |
$csv->combine(@headers); |
|
|
262 |
$output = $csv->string() . "\n"; |
243 |
|
263 |
|
244 |
my @rows; |
264 |
my @rows; |
245 |
foreach my $order (@orders) { |
265 |
foreach my $order (@orders) { |
246 |
my $bd = GetBiblioData( $order->{'biblionumber'} ); |
266 |
my $bd = GetBiblioData( $order->{'biblionumber'} ); |
247 |
my $row = { |
267 |
my @row = ( |
248 |
contractname => $contract->{'contractname'}, |
268 |
$contract->{'contractname'}, |
249 |
ordernumber => $order->{'ordernumber'}, |
269 |
$order->{'ordernumber'}, |
250 |
entrydate => $order->{'entrydate'}, |
270 |
$order->{'entrydate'}, |
251 |
isbn => $order->{'isbn'}, |
271 |
$order->{'isbn'}, |
252 |
author => $bd->{'author'}, |
272 |
$bd->{'author'}, |
253 |
title => $bd->{'title'}, |
273 |
$bd->{'title'}, |
254 |
publicationyear => $bd->{'publicationyear'}, |
274 |
$bd->{'publicationyear'}, |
255 |
publishercode => $bd->{'publishercode'}, |
275 |
$bd->{'publishercode'}, |
256 |
collectiontitle => $bd->{'collectiontitle'}, |
276 |
$bd->{'collectiontitle'}, |
257 |
notes => $order->{'notes'}, |
277 |
$order->{'notes'}, |
258 |
quantity => $order->{'quantity'}, |
278 |
$order->{'quantity'}, |
259 |
rrp => $order->{'rrp'}, |
279 |
$order->{'rrp'}, |
260 |
deliveryplace => $basket->{'deliveryplace'}, |
280 |
$basket->{'deliveryplace'}, |
261 |
billingplace => $basket->{'billingplace'} |
281 |
$basket->{'billingplace'} |
262 |
}; |
282 |
); |
263 |
foreach(qw( |
283 |
foreach (@row) { |
264 |
contractname author title publishercode collectiontitle notes |
|
|
265 |
deliveryplace billingplace |
266 |
) ) { |
267 |
# Double the quotes to not be interpreted as a field end |
284 |
# Double the quotes to not be interpreted as a field end |
268 |
$row->{$_} =~ s/"/""/g if $row->{$_}; |
285 |
$_ =~ s/"/""/g; |
269 |
} |
286 |
} |
270 |
push @rows, $row; |
287 |
push @rows, \@row; |
271 |
} |
288 |
} |
272 |
|
289 |
|
273 |
@rows = sort { |
290 |
@rows = sort { |
274 |
if(defined $a->{publishercode} and defined $b->{publishercode}) { |
291 |
if(defined $a->[7] and defined $b->[7]) { |
275 |
$a->{publishercode} cmp $b->{publishercode}; |
292 |
$a->[7] cmp $b->[7]; |
276 |
} |
293 |
} |
277 |
} @rows; |
294 |
} @rows; |
|
|
295 |
foreach my $row (@rows) { |
296 |
$csv->combine(@$row); |
297 |
$output .= $csv->string . "\n"; |
298 |
} |
278 |
|
299 |
|
279 |
$template->param(rows => \@rows); |
300 |
return $output; |
280 |
|
|
|
281 |
return $template->output; |
282 |
} |
301 |
} |
283 |
|
302 |
|
284 |
|
303 |
|