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 240-290
$cgi parameter is needed for column name translation
Link Here
|
240 |
=cut |
240 |
=cut |
241 |
|
241 |
|
242 |
sub GetBasketAsCSV { |
242 |
sub GetBasketAsCSV { |
243 |
my ($basketno, $cgi) = @_; |
243 |
my ($basketno, $lh) = @_; |
244 |
my $basket = GetBasket($basketno); |
244 |
my $basket = GetBasket($basketno); |
245 |
my @orders = GetOrders($basketno); |
245 |
my @orders = GetOrders($basketno); |
246 |
my $contract = GetContract($basket->{'contractnumber'}); |
246 |
my $contract = GetContract($basket->{'contractnumber'}); |
|
|
247 |
my $csv = Text::CSV::Encoded->new(); |
248 |
my $output; |
249 |
|
250 |
my @headers = ( |
251 |
$lh->maketext('Contract name'), |
252 |
$lh->maketext('Order number'), |
253 |
$lh->maketext('Entry date'), |
254 |
$lh->maketext('ISBN'), |
255 |
$lh->maketext('Author'), |
256 |
$lh->maketext('Title'), |
257 |
$lh->maketext('Publication year'), |
258 |
$lh->maketext('Publisher code'), |
259 |
$lh->maketext('Collection title'), |
260 |
$lh->maketext('Notes'), |
261 |
$lh->maketext('Quantity'), |
262 |
$lh->maketext('RRP'), |
263 |
$lh->maketext('Delivery place'), |
264 |
$lh->maketext('Billing place'), |
265 |
); |
247 |
|
266 |
|
248 |
my $template = C4::Templates::gettemplate("acqui/csv/basket.tmpl", "intranet", $cgi); |
267 |
$csv->combine(@headers); |
|
|
268 |
$output = $csv->string() . "\n"; |
249 |
|
269 |
|
250 |
my @rows; |
270 |
my @rows; |
251 |
foreach my $order (@orders) { |
271 |
foreach my $order (@orders) { |
252 |
my $bd = GetBiblioData( $order->{'biblionumber'} ); |
272 |
my $bd = GetBiblioData( $order->{'biblionumber'} ); |
253 |
my $row = { |
273 |
my @row = ( |
254 |
contractname => $contract->{'contractname'}, |
274 |
$contract->{'contractname'}, |
255 |
ordernumber => $order->{'ordernumber'}, |
275 |
$order->{'ordernumber'}, |
256 |
entrydate => $order->{'entrydate'}, |
276 |
$order->{'entrydate'}, |
257 |
isbn => $order->{'isbn'}, |
277 |
$order->{'isbn'}, |
258 |
author => $bd->{'author'}, |
278 |
$bd->{'author'}, |
259 |
title => $bd->{'title'}, |
279 |
$bd->{'title'}, |
260 |
publicationyear => $bd->{'publicationyear'}, |
280 |
$bd->{'publicationyear'}, |
261 |
publishercode => $bd->{'publishercode'}, |
281 |
$bd->{'publishercode'}, |
262 |
collectiontitle => $bd->{'collectiontitle'}, |
282 |
$bd->{'collectiontitle'}, |
263 |
notes => $order->{'notes'}, |
283 |
$order->{'notes'}, |
264 |
quantity => $order->{'quantity'}, |
284 |
$order->{'quantity'}, |
265 |
rrp => $order->{'rrp'}, |
285 |
$order->{'rrp'}, |
266 |
deliveryplace => C4::Branch::GetBranchName( $basket->{'deliveryplace'} ), |
286 |
C4::Branch::GetBranchName($basket->{'deliveryplace'}), |
267 |
billingplace => C4::Branch::GetBranchName( $basket->{'billingplace'} ), |
287 |
C4::Branch::GetBranchName($basket->{'billingplace'}), |
268 |
}; |
288 |
); |
269 |
foreach(qw( |
289 |
foreach (@row) { |
270 |
contractname author title publishercode collectiontitle notes |
|
|
271 |
deliveryplace billingplace |
272 |
) ) { |
273 |
# Double the quotes to not be interpreted as a field end |
290 |
# Double the quotes to not be interpreted as a field end |
274 |
$row->{$_} =~ s/"/""/g if $row->{$_}; |
291 |
$_ =~ s/"/""/g; |
275 |
} |
292 |
} |
276 |
push @rows, $row; |
293 |
push @rows, \@row; |
277 |
} |
294 |
} |
278 |
|
295 |
|
279 |
@rows = sort { |
296 |
@rows = sort { |
280 |
if(defined $a->{publishercode} and defined $b->{publishercode}) { |
297 |
if(defined $a->[7] and defined $b->[7]) { |
281 |
$a->{publishercode} cmp $b->{publishercode}; |
298 |
$a->[7] cmp $b->[7]; |
282 |
} |
299 |
} |
283 |
} @rows; |
300 |
} @rows; |
|
|
301 |
foreach my $row (@rows) { |
302 |
$csv->combine(@$row); |
303 |
$output .= $csv->string . "\n"; |
304 |
} |
284 |
|
305 |
|
285 |
$template->param(rows => \@rows); |
306 |
return $output; |
286 |
|
|
|
287 |
return $template->output; |
288 |
} |
307 |
} |
289 |
|
308 |
|
290 |
|
309 |
|