|
Lines 34-39
use C4::Biblio;
Link Here
|
| 34 |
use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket |
34 |
use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket |
| 35 |
use C4::Items; |
35 |
use C4::Items; |
| 36 |
use C4::Suggestions; |
36 |
use C4::Suggestions; |
|
|
37 |
use C4::Csv; |
| 37 |
use Koha::Libraries; |
38 |
use Koha::Libraries; |
| 38 |
use Date::Calc qw/Add_Delta_Days/; |
39 |
use Date::Calc qw/Add_Delta_Days/; |
| 39 |
use Koha::Database; |
40 |
use Koha::Database; |
|
Lines 163-169
if ( $op eq 'delete_confirm' ) {
Link Here
|
| 163 |
-type => 'text/csv', |
164 |
-type => 'text/csv', |
| 164 |
-attachment => 'basket' . $basket->{'basketno'} . '.csv', |
165 |
-attachment => 'basket' . $basket->{'basketno'} . '.csv', |
| 165 |
); |
166 |
); |
| 166 |
print GetBasketAsCSV($query->param('basketno'), $query); |
167 |
if ( $query->param('csv_profile') eq 'default'){ |
|
|
168 |
print GetBasketAsCSV($query->param('basketno'), $query); |
| 169 |
} else { |
| 170 |
my $csv_profile_id = $query->param('csv_profile'); |
| 171 |
my $csv_profile = C4::Csv::GetCsvProfile( $csv_profile_id ); |
| 172 |
die "There is no valid csv profile given" unless $csv_profile; |
| 173 |
|
| 174 |
my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$csv_profile->{csv_separator},'binary'=>1}); |
| 175 |
my $csv_profile_content = $csv_profile->{content}; |
| 176 |
|
| 177 |
my $basket_info = get_basket_csv_profile_info($csv_profile_content, $query->param('basketno')); |
| 178 |
|
| 179 |
print join( $csv_profile->{csv_separator}, @{$basket_info->{headers}} ) . "\n"; |
| 180 |
|
| 181 |
for my $row ( @{$basket_info->{rows}} ) { |
| 182 |
$csv->combine(@$row); |
| 183 |
my $string = $csv->string; |
| 184 |
print $string, "\n"; |
| 185 |
} |
| 186 |
} |
| 167 |
exit; |
187 |
exit; |
| 168 |
} elsif ($op eq 'close') { |
188 |
} elsif ($op eq 'close') { |
| 169 |
my $confirm = $query->param('confirm') || $confirm_pref eq '2'; |
189 |
my $confirm = $query->param('confirm') || $confirm_pref eq '2'; |
|
Lines 403-408
elsif ( $op eq 'ediorder' ) {
Link Here
|
| 403 |
unclosable => @orders ? $basket->{is_standing} : 1, |
423 |
unclosable => @orders ? $basket->{is_standing} : 1, |
| 404 |
has_budgets => $has_budgets, |
424 |
has_budgets => $has_budgets, |
| 405 |
duplinbatch => $duplinbatch, |
425 |
duplinbatch => $duplinbatch, |
|
|
426 |
csv_profiles => C4::Csv::GetCsvProfiles( "sql" ), |
| 406 |
); |
427 |
); |
| 407 |
} |
428 |
} |
| 408 |
|
429 |
|
|
Lines 481-486
sub get_order_infos {
Link Here
|
| 481 |
return \%line; |
502 |
return \%line; |
| 482 |
} |
503 |
} |
| 483 |
|
504 |
|
|
|
505 |
sub get_basket_DB_info{ |
| 506 |
my ( $basketno ) = @_; |
| 507 |
return () unless $basketno; |
| 508 |
my $dbh = C4::Context->dbh; |
| 509 |
my $query =" |
| 510 |
SELECT biblio.*,biblioitems.*, aqbasket.*,aqcontract.*, |
| 511 |
aqorders.*, |
| 512 |
aqbudgets.* |
| 513 |
FROM aqorders |
| 514 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
| 515 |
LEFT JOIN aqcontract ON aqbasket.contractnumber = aqcontract.contractnumber |
| 516 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
| 517 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
| 518 |
LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber |
| 519 |
WHERE aqorders.basketno=? |
| 520 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
| 521 |
ORDER BY biblioitems.publishercode,biblio.title |
| 522 |
"; |
| 523 |
my $result_set = |
| 524 |
$dbh->selectall_arrayref( $query, { Slice => {} }, $basketno ); |
| 525 |
return @{$result_set}; |
| 526 |
} |
| 527 |
|
| 528 |
sub get_basket_csv_profile_info{ |
| 529 |
my ($csv_profile_content,$basketno) = @_; |
| 530 |
|
| 531 |
my ( @headers, @fields ); |
| 532 |
while ( $csv_profile_content =~ / |
| 533 |
([^=]+) # header |
| 534 |
= |
| 535 |
([^\|]+) # fieldname (table.row or row) |
| 536 |
\|? /gxms |
| 537 |
) { |
| 538 |
push @headers, $1; |
| 539 |
my $field = $2; |
| 540 |
$field =~ s/[^\.]*\.?//; # Remove the table name if exists. |
| 541 |
push @fields, $field; |
| 542 |
} |
| 543 |
|
| 544 |
my @rows; |
| 545 |
my @basket_info = get_basket_DB_info($basketno); |
| 546 |
|
| 547 |
for my $basket_info ( @basket_info ) { |
| 548 |
my @row; |
| 549 |
for my $field ( @fields ) { |
| 550 |
push @row, $basket_info->{$field}; |
| 551 |
} |
| 552 |
push @rows, \@row; |
| 553 |
} |
| 554 |
my $hash_ref; |
| 555 |
$hash_ref->{ 'headers' } = \@headers; |
| 556 |
$hash_ref->{ 'rows' } = \@rows; |
| 557 |
|
| 558 |
return $hash_ref; |
| 559 |
} |
| 560 |
|
| 484 |
output_html_with_http_headers $query, $cookie, $template->output; |
561 |
output_html_with_http_headers $query, $cookie, $template->output; |
| 485 |
|
562 |
|
| 486 |
|
563 |
|