View | Details | Raw Unified | Return to bug 7302
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-4 / +64 lines)
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);
(-)a/acqui/basketgroup.pl (-2 / +10 lines)
Lines 53-59 use C4::Output; Link Here
53
use CGI;
53
use CGI;
54
54
55
use C4::Bookseller qw/GetBookSellerFromId/;
55
use C4::Bookseller qw/GetBookSellerFromId/;
56
use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket/;
56
use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/;
57
use C4::Bookseller qw/GetBookSellerFromId/;
57
use C4::Bookseller qw/GetBookSellerFromId/;
58
use C4::Branch qw/GetBranches/;
58
use C4::Branch qw/GetBranches/;
59
use C4::Members qw/GetMember/;
59
use C4::Members qw/GetMember/;
Lines 277-283 sub printbasketgrouppdf{ Link Here
277
277
278
}
278
}
279
279
280
my $op = $input->param('op');
280
my $op = $input->param('op') || 'display';
281
my $booksellerid = $input->param('booksellerid');
281
my $booksellerid = $input->param('booksellerid');
282
$template->param(booksellerid => $booksellerid);
282
$template->param(booksellerid => $booksellerid);
283
283
Lines 417-422 if ( $op eq "add" ) { Link Here
417
    
417
    
418
    printbasketgrouppdf($basketgroupid);
418
    printbasketgrouppdf($basketgroupid);
419
    exit;
419
    exit;
420
}elsif ( $op eq "export" ) {
421
    my $basketgroupid = $input->param('basketgroupid');
422
    print $input->header(
423
        -type       => 'text/csv',
424
        -attachment => 'basketgroup' . $basketgroupid . '.csv',
425
    );
426
    print GetBasketGroupAsCSV( $basketgroupid );
427
    exit;
420
}elsif( $op eq "delete"){
428
}elsif( $op eq "delete"){
421
    my $basketgroupid = $input->param('basketgroupid');
429
    my $basketgroupid = $input->param('basketgroupid');
422
    DelBasketgroup($basketgroupid);
430
    DelBasketgroup($basketgroupid);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketgroup.tt (-3 / +5 lines)
Lines 285-291 function yuiToolbar() { Link Here
285
		<table>
285
		<table>
286
			<thead>
286
			<thead>
287
				<tr>
287
				<tr>
288
					<th>Basket Group</th><th colspan="3">Action</th>
288
					<th>Basket Group</th><th colspan="4">Action</th>
289
				</tr>
289
				</tr>
290
			</thead>
290
			</thead>
291
			<tbody>
291
			<tbody>
Lines 293-299 function yuiToolbar() { Link Here
293
				[% IF ( basketgroup.closed ) %]
293
				[% IF ( basketgroup.closed ) %]
294
				<tr>
294
				<tr>
295
				<td>
295
				<td>
296
					<a href="/cgi-bin/koha/acqui/basketgroup.pl?op=reopen&amp;booksellerid=[% basketgroup.booksellerid %]&amp;basketgroupid[% basketgroup.id %]">[% IF ( basketgroup.name ) %]
296
					<a href="/cgi-bin/koha/acqui/basketgroup.pl?op=reopen&amp;booksellerid=[% basketgroup.booksellerid %]&amp;basketgroupid=[% basketgroup.id %]">[% IF ( basketgroup.name ) %]
297
											[% basketgroup.name %]
297
											[% basketgroup.name %]
298
										[% ELSE %]
298
										[% ELSE %]
299
											Basket group no. [% basketgroup.id %]
299
											Basket group no. [% basketgroup.id %]
Lines 305-310 function yuiToolbar() { Link Here
305
						<td>
305
						<td>
306
							<form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="print" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Print" /></form>
306
							<form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="print" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Print" /></form>
307
						</td>
307
						</td>
308
                    <td>
309
                        <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="get"><input type="hidden" name="op" value="export" /><input type="hidden" name="basketgroupid" value="[% basketgroup.id %]" /><input type="submit" value="Export as CSV" /></form>
310
                    </td>
308
				</tr>
311
				</tr>
309
				[% END %]
312
				[% END %]
310
				[% END %]
313
				[% END %]
311
- 

Return to bug 7302