|
Lines 33-38
use C4::Biblio;
Link Here
|
| 33 |
use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket |
33 |
use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket |
| 34 |
use C4::Items; |
34 |
use C4::Items; |
| 35 |
use C4::Suggestions; |
35 |
use C4::Suggestions; |
|
|
36 |
use C4::Csv; |
| 36 |
use Koha::Biblios; |
37 |
use Koha::Biblios; |
| 37 |
use Koha::Acquisition::Booksellers; |
38 |
use Koha::Acquisition::Booksellers; |
| 38 |
use Koha::Libraries; |
39 |
use Koha::Libraries; |
|
Lines 164-170
if ( $op eq 'delete_confirm' ) {
Link Here
|
| 164 |
-type => 'text/csv', |
165 |
-type => 'text/csv', |
| 165 |
-attachment => 'basket' . $basket->{'basketno'} . '.csv', |
166 |
-attachment => 'basket' . $basket->{'basketno'} . '.csv', |
| 166 |
); |
167 |
); |
| 167 |
print GetBasketAsCSV($query->param('basketno'), $query); |
168 |
if ( $query->param('csv_profile') eq 'default'){ |
|
|
169 |
print GetBasketAsCSV($query->param('basketno'), $query); |
| 170 |
} else { |
| 171 |
my $csv_profile_id = $query->param('csv_profile'); |
| 172 |
my $csv_profile = C4::Csv::GetCsvProfile( $csv_profile_id ); |
| 173 |
die "There is no valid csv profile given" unless $csv_profile; |
| 174 |
|
| 175 |
my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$csv_profile->{csv_separator},'binary'=>1}); |
| 176 |
my $csv_profile_content = $csv_profile->{content}; |
| 177 |
|
| 178 |
my $basket_info = get_basket_csv_profile_info($csv_profile_content, $query->param('basketno')); |
| 179 |
|
| 180 |
print join( $csv_profile->{csv_separator}, @{$basket_info->{headers}} ) . "\n"; |
| 181 |
|
| 182 |
for my $row ( @{$basket_info->{rows}} ) { |
| 183 |
$csv->combine(@$row); |
| 184 |
my $string = $csv->string; |
| 185 |
print $string, "\n"; |
| 186 |
} |
| 187 |
} |
| 168 |
exit; |
188 |
exit; |
| 169 |
} elsif ($op eq 'email') { |
189 |
} elsif ($op eq 'email') { |
| 170 |
my $err = eval { |
190 |
my $err = eval { |
|
Lines 420-425
if ( $op eq 'list' ) {
Link Here
|
| 420 |
unclosable => @orders ? $basket->{is_standing} : 1, |
440 |
unclosable => @orders ? $basket->{is_standing} : 1, |
| 421 |
has_budgets => $has_budgets, |
441 |
has_budgets => $has_budgets, |
| 422 |
duplinbatch => $duplinbatch, |
442 |
duplinbatch => $duplinbatch, |
|
|
443 |
csv_profiles => C4::Csv::GetCsvProfiles( "sql" ), |
| 423 |
); |
444 |
); |
| 424 |
} |
445 |
} |
| 425 |
|
446 |
|
|
Lines 507-512
sub get_order_infos {
Link Here
|
| 507 |
return \%line; |
528 |
return \%line; |
| 508 |
} |
529 |
} |
| 509 |
|
530 |
|
|
|
531 |
sub get_basket_DB_info{ |
| 532 |
my ( $basketno ) = @_; |
| 533 |
return () unless $basketno; |
| 534 |
my $dbh = C4::Context->dbh; |
| 535 |
my $query =" |
| 536 |
SELECT biblio.*,biblioitems.*, aqbasket.*,aqcontract.*, |
| 537 |
aqorders.*, |
| 538 |
aqbudgets.* |
| 539 |
FROM aqorders |
| 540 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
| 541 |
LEFT JOIN aqcontract ON aqbasket.contractnumber = aqcontract.contractnumber |
| 542 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
| 543 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
| 544 |
LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber |
| 545 |
WHERE aqorders.basketno=? |
| 546 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
| 547 |
ORDER BY biblioitems.publishercode,biblio.title |
| 548 |
"; |
| 549 |
my $result_set = |
| 550 |
$dbh->selectall_arrayref( $query, { Slice => {} }, $basketno ); |
| 551 |
return @{$result_set}; |
| 552 |
} |
| 553 |
|
| 554 |
sub get_basket_csv_profile_info{ |
| 555 |
my ($csv_profile_content,$basketno) = @_; |
| 556 |
|
| 557 |
my ( @headers, @fields ); |
| 558 |
while ( $csv_profile_content =~ / |
| 559 |
([^=]+) # header |
| 560 |
= |
| 561 |
([^\|]+) # fieldname (table.row or row) |
| 562 |
\|? /gxms |
| 563 |
) { |
| 564 |
push @headers, $1; |
| 565 |
my $field = $2; |
| 566 |
$field =~ s/[^\.]*\.?//; # Remove the table name if exists. |
| 567 |
push @fields, $field; |
| 568 |
} |
| 569 |
|
| 570 |
my @rows; |
| 571 |
my @basket_info = get_basket_DB_info($basketno); |
| 572 |
|
| 573 |
for my $basket_info ( @basket_info ) { |
| 574 |
my @row; |
| 575 |
for my $field ( @fields ) { |
| 576 |
push @row, $basket_info->{$field}; |
| 577 |
} |
| 578 |
push @rows, \@row; |
| 579 |
} |
| 580 |
my $hash_ref; |
| 581 |
$hash_ref->{ 'headers' } = \@headers; |
| 582 |
$hash_ref->{ 'rows' } = \@rows; |
| 583 |
|
| 584 |
return $hash_ref; |
| 585 |
} |
| 586 |
|
| 510 |
sub edi_close_and_order { |
587 |
sub edi_close_and_order { |
| 511 |
my $confirm = $query->param('confirm') || $confirm_pref eq '2'; |
588 |
my $confirm = $query->param('confirm') || $confirm_pref eq '2'; |
| 512 |
if ($confirm) { |
589 |
if ($confirm) { |