|
Lines 35-40
use C4::Biblio;
Link Here
|
| 35 |
use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket |
35 |
use C4::Members qw/GetMember/; #needed for permissions checking for changing basketgroup of a basket |
| 36 |
use C4::Items; |
36 |
use C4::Items; |
| 37 |
use C4::Suggestions; |
37 |
use C4::Suggestions; |
|
|
38 |
use C4::Csv; |
| 38 |
use Date::Calc qw/Add_Delta_Days/; |
39 |
use Date::Calc qw/Add_Delta_Days/; |
| 39 |
|
40 |
|
| 40 |
=head1 NAME |
41 |
=head1 NAME |
|
Lines 156-162
if ( $op eq 'delete_confirm' ) {
Link Here
|
| 156 |
-type => 'text/csv', |
157 |
-type => 'text/csv', |
| 157 |
-attachment => 'basket' . $basket->{'basketno'} . '.csv', |
158 |
-attachment => 'basket' . $basket->{'basketno'} . '.csv', |
| 158 |
); |
159 |
); |
| 159 |
print GetBasketAsCSV($query->param('basketno'), $query); |
160 |
if ( $query->param('csv_profile') eq 'default'){ |
|
|
161 |
print GetBasketAsCSV($query->param('basketno'), $query); |
| 162 |
} else { |
| 163 |
my $csv_profile_id = $query->param('csv_profile'); |
| 164 |
my $csv_profile = C4::Csv::GetCsvProfile( $csv_profile_id ); |
| 165 |
die "There is no valid csv profile given" unless $csv_profile; |
| 166 |
|
| 167 |
my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$csv_profile->{csv_separator},'binary'=>1}); |
| 168 |
my $csv_profile_content = $csv_profile->{content}; |
| 169 |
|
| 170 |
my $basket_info = get_basket_csv_profile_info($csv_profile_content, $query->param('basketno')); |
| 171 |
|
| 172 |
print join( $csv_profile->{csv_separator}, @{$basket_info->{headers}} ) . "\n"; |
| 173 |
|
| 174 |
for my $row ( @{$basket_info->{rows}} ) { |
| 175 |
$csv->combine(@$row); |
| 176 |
my $string = $csv->string; |
| 177 |
print $string, "\n"; |
| 178 |
} |
| 179 |
} |
| 160 |
exit; |
180 |
exit; |
| 161 |
} elsif ($op eq 'close') { |
181 |
} elsif ($op eq 'close') { |
| 162 |
my $confirm = $query->param('confirm') || $confirm_pref eq '2'; |
182 |
my $confirm = $query->param('confirm') || $confirm_pref eq '2'; |
|
Lines 392-397
if ( $op eq 'delete_confirm' ) {
Link Here
|
| 392 |
unclosable => @orders ? 0 : 1, |
412 |
unclosable => @orders ? 0 : 1, |
| 393 |
has_budgets => $has_budgets, |
413 |
has_budgets => $has_budgets, |
| 394 |
duplinbatch => $duplinbatch, |
414 |
duplinbatch => $duplinbatch, |
|
|
415 |
csv_profiles => C4::Csv::GetCsvProfiles( "sql" ), |
| 395 |
); |
416 |
); |
| 396 |
} |
417 |
} |
| 397 |
|
418 |
|
|
Lines 471-474
sub get_order_infos {
Link Here
|
| 471 |
return \%line; |
492 |
return \%line; |
| 472 |
} |
493 |
} |
| 473 |
|
494 |
|
|
|
495 |
sub get_basket_DB_info{ |
| 496 |
my ( $basketno ) = @_; |
| 497 |
return () unless $basketno; |
| 498 |
my $dbh = C4::Context->dbh; |
| 499 |
my $query =" |
| 500 |
SELECT biblio.*,biblioitems.*, aqbasket.*,aqcontract.*, |
| 501 |
aqorders.*, |
| 502 |
aqbudgets.* |
| 503 |
FROM aqorders |
| 504 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
| 505 |
LEFT JOIN aqcontract ON aqbasket.contractnumber = aqcontract.contractnumber |
| 506 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
| 507 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
| 508 |
LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber |
| 509 |
WHERE aqorders.basketno=? |
| 510 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
| 511 |
ORDER BY biblioitems.publishercode,biblio.title |
| 512 |
"; |
| 513 |
my $result_set = |
| 514 |
$dbh->selectall_arrayref( $query, { Slice => {} }, $basketno ); |
| 515 |
return @{$result_set}; |
| 516 |
} |
| 517 |
|
| 518 |
sub get_basket_csv_profile_info{ |
| 519 |
my ($csv_profile_content,$basketno) = @_; |
| 520 |
|
| 521 |
my ( @headers, @fields ); |
| 522 |
while ( $csv_profile_content =~ / |
| 523 |
([^=]+) # header |
| 524 |
= |
| 525 |
([^\|]+) # fieldname (table.row or row) |
| 526 |
\|? /gxms |
| 527 |
) { |
| 528 |
push @headers, $1; |
| 529 |
my $field = $2; |
| 530 |
$field =~ s/[^\.]*\.?//; # Remove the table name if exists. |
| 531 |
push @fields, $field; |
| 532 |
} |
| 533 |
|
| 534 |
my @rows; |
| 535 |
my @basket_info = get_basket_DB_info($basketno); |
| 536 |
|
| 537 |
for my $basket_info ( @basket_info ) { |
| 538 |
my @row; |
| 539 |
for my $field ( @fields ) { |
| 540 |
push @row, $basket_info->{$field}; |
| 541 |
} |
| 542 |
push @rows, \@row; |
| 543 |
} |
| 544 |
my $hash_ref; |
| 545 |
$hash_ref->{ 'headers' } = \@headers; |
| 546 |
$hash_ref->{ 'rows' } = \@rows; |
| 547 |
|
| 548 |
return $hash_ref; |
| 549 |
} |
| 550 |
|
| 474 |
output_html_with_http_headers $query, $cookie, $template->output; |
551 |
output_html_with_http_headers $query, $cookie, $template->output; |