Lines 29-37
use C4::Suggestions;
Link Here
|
29 |
use C4::Biblio; |
29 |
use C4::Biblio; |
30 |
use C4::Debug; |
30 |
use C4::Debug; |
31 |
use C4::SQLHelper qw(InsertInTable); |
31 |
use C4::SQLHelper qw(InsertInTable); |
|
|
32 |
use C4::Bookseller qw(GetBookSellerFromId); |
32 |
|
33 |
|
33 |
use Time::localtime; |
34 |
use Time::localtime; |
34 |
use HTML::Entities; |
35 |
use HTML::Entities; |
|
|
36 |
use Text::CSV::Encoded; |
37 |
use utf8; |
35 |
|
38 |
|
36 |
use vars qw($VERSION @ISA @EXPORT); |
39 |
use vars qw($VERSION @ISA @EXPORT); |
37 |
|
40 |
|
Lines 42-48
BEGIN {
Link Here
|
42 |
@ISA = qw(Exporter); |
45 |
@ISA = qw(Exporter); |
43 |
@EXPORT = qw( |
46 |
@EXPORT = qw( |
44 |
&GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket |
47 |
&GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket |
45 |
&GetBasketAsCSV |
48 |
&GetBasketAsCSV &GetBasketGroupAsCSV |
46 |
&GetBasketsByBookseller &GetBasketsByBasketgroup |
49 |
&GetBasketsByBookseller &GetBasketsByBasketgroup |
47 |
|
50 |
|
48 |
&ModBasketHeader |
51 |
&ModBasketHeader |
Lines 233-239
sub GetBasketAsCSV {
Link Here
|
233 |
my $basket = GetBasket($basketno); |
236 |
my $basket = GetBasket($basketno); |
234 |
my @orders = GetOrders($basketno); |
237 |
my @orders = GetOrders($basketno); |
235 |
my $contract = GetContract($basket->{'contractnumber'}); |
238 |
my $contract = GetContract($basket->{'contractnumber'}); |
236 |
my $csv = Text::CSV->new(); |
239 |
my $csv = Text::CSV::Encoded->new ({ encoding => "utf8" }); |
237 |
my $output; |
240 |
my $output; |
238 |
|
241 |
|
239 |
# TODO: Translate headers |
242 |
# TODO: Translate headers |
Lines 274-279
sub GetBasketAsCSV {
Link Here
|
274 |
} |
277 |
} |
275 |
|
278 |
|
276 |
|
279 |
|
|
|
280 |
=head3 GetBasketGroupAsCSV |
281 |
|
282 |
=over 4 |
283 |
|
284 |
&GetBasketGroupAsCSV($basketgroupid); |
285 |
|
286 |
Export a basket group as CSV |
287 |
|
288 |
=back |
289 |
|
290 |
=cut |
291 |
|
292 |
sub GetBasketGroupAsCSV { |
293 |
my ($basketgroupid) = @_; |
294 |
my $baskets = GetBasketsByBasketgroup($basketgroupid); |
295 |
|
296 |
# TODO: Translate headers |
297 |
my @headers = qw(booksellername bookselleraddress booksellerpostal accountnumber contractnumber contractname ordernumber entrydate isbn author title publishercode collectiontitle notes quantity rrp); |
298 |
|
299 |
my $csv = Text::CSV::Encoded->new ({ encoding => "utf8" }); |
300 |
|
301 |
my $output; |
302 |
$csv->combine(@headers); |
303 |
$output = $csv->string() . "\n"; |
304 |
|
305 |
for my $basket (@$baskets) { |
306 |
my @orders = GetOrders( $$basket{basketno} ); |
307 |
my $contract = GetContract( $$basket{contractnumber} ); |
308 |
my $bookseller = GetBookSellerFromId( $$basket{booksellerid} ); |
309 |
|
310 |
my @rows; |
311 |
foreach my $order (@orders) { |
312 |
my @cols; |
313 |
my $bd = GetBiblioData( $order->{'biblionumber'} ); |
314 |
push( @cols, |
315 |
$bookseller->{name}, $bookseller->{address1}, $bookseller->{postal}, $bookseller->{accountnumber}, |
316 |
$contract->{contractnumber}, $contract->{contractname}, |
317 |
$order->{ordernumber}, $order->{entrydate}, $order->{isbn}, |
318 |
$bd->{author}, $bd->{title}, $bd->{publishercode}, $bd->{collectiontitle}, |
319 |
$order->{notes}, $order->{quantity}, $order->{rrp}, ); |
320 |
push( @rows, \@cols ); |
321 |
} |
322 |
|
323 |
foreach my $row (@rows) { |
324 |
$csv->combine(@$row); |
325 |
$output .= $csv->string() . "\n"; |
326 |
|
327 |
} |
328 |
} |
329 |
|
330 |
return $output; |
331 |
|
332 |
} |
333 |
|
277 |
=head3 CloseBasketgroup |
334 |
=head3 CloseBasketgroup |
278 |
|
335 |
|
279 |
&CloseBasketgroup($basketgroupno); |
336 |
&CloseBasketgroup($basketgroupno); |
Lines 476-483
Returns a reference to all baskets that belong to basketgroup $basketgroupid.
Link Here
|
476 |
|
533 |
|
477 |
sub GetBasketsByBasketgroup { |
534 |
sub GetBasketsByBasketgroup { |
478 |
my $basketgroupid = shift; |
535 |
my $basketgroupid = shift; |
479 |
my $query = "SELECT * FROM aqbasket |
536 |
my $query = qq{ |
480 |
LEFT JOIN aqcontract USING(contractnumber) WHERE basketgroupid=?"; |
537 |
SELECT *, aqbasket.booksellerid as booksellerid |
|
|
538 |
FROM aqbasket |
539 |
LEFT JOIN aqcontract USING(contractnumber) WHERE basketgroupid=? |
540 |
}; |
481 |
my $dbh = C4::Context->dbh; |
541 |
my $dbh = C4::Context->dbh; |
482 |
my $sth = $dbh->prepare($query); |
542 |
my $sth = $dbh->prepare($query); |
483 |
$sth->execute($basketgroupid); |
543 |
$sth->execute($basketgroupid); |