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 196-202
if ( $op eq 'delete_confirm' ) {
Link Here
|
196 |
-type => 'text/csv', |
197 |
-type => 'text/csv', |
197 |
-attachment => 'basket' . $basket->{'basketno'} . '.csv', |
198 |
-attachment => 'basket' . $basket->{'basketno'} . '.csv', |
198 |
); |
199 |
); |
199 |
print GetBasketAsCSV($query->param('basketno'), $query); |
200 |
if ( $query->param('csv_profile') eq 'default'){ |
|
|
201 |
print GetBasketAsCSV($query->param('basketno'), $query); |
202 |
} else { |
203 |
my $csv_profile_id = $query->param('csv_profile'); |
204 |
my $csv_profile = C4::Csv::GetCsvProfile( $csv_profile_id ); |
205 |
die "There is no valid csv profile given" unless $csv_profile; |
206 |
|
207 |
my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$csv_profile->{csv_separator},'binary'=>1}); |
208 |
my $csv_profile_content = $csv_profile->{content}; |
209 |
|
210 |
my $basket_info = get_basket_csv_profile_info($csv_profile_content, $query->param('basketno')); |
211 |
|
212 |
print join( $csv_profile->{csv_separator}, @{$basket_info->{headers}} ) . "\n"; |
213 |
|
214 |
for my $row ( @{$basket_info->{rows}} ) { |
215 |
$csv->combine(@$row); |
216 |
my $string = $csv->string; |
217 |
print $string, "\n"; |
218 |
} |
219 |
} |
200 |
exit; |
220 |
exit; |
201 |
} elsif ($op eq 'close') { |
221 |
} elsif ($op eq 'close') { |
202 |
my $confirm = $query->param('confirm') || $confirm_pref eq '2'; |
222 |
my $confirm = $query->param('confirm') || $confirm_pref eq '2'; |
Lines 431-436
if ( $op eq 'delete_confirm' ) {
Link Here
|
431 |
grouped => $basket->{basketgroupid}, |
451 |
grouped => $basket->{basketgroupid}, |
432 |
unclosable => @orders ? 0 : 1, |
452 |
unclosable => @orders ? 0 : 1, |
433 |
has_budgets => $has_budgets, |
453 |
has_budgets => $has_budgets, |
|
|
454 |
csv_profiles => C4::Csv::GetCsvProfiles( "sql" ), |
434 |
); |
455 |
); |
435 |
} |
456 |
} |
436 |
|
457 |
|
Lines 510-513
sub get_order_infos {
Link Here
|
510 |
return \%line; |
531 |
return \%line; |
511 |
} |
532 |
} |
512 |
|
533 |
|
|
|
534 |
sub get_basket_DB_info{ |
535 |
my ( $basketno ) = @_; |
536 |
return () unless $basketno; |
537 |
my $dbh = C4::Context->dbh; |
538 |
my $query =" |
539 |
SELECT biblio.*,biblioitems.*, aqbasket.*,aqcontract.*, |
540 |
aqorders.*, |
541 |
aqbudgets.* |
542 |
FROM aqorders |
543 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
544 |
LEFT JOIN aqcontract ON aqbasket.contractnumber = aqcontract.contractnumber |
545 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
546 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
547 |
LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber |
548 |
WHERE aqorders.basketno=? |
549 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
550 |
ORDER BY biblioitems.publishercode,biblio.title |
551 |
"; |
552 |
my $result_set = |
553 |
$dbh->selectall_arrayref( $query, { Slice => {} }, $basketno ); |
554 |
return @{$result_set}; |
555 |
} |
556 |
|
557 |
sub get_basket_csv_profile_info{ |
558 |
my ($csv_profile_content,$basketno) = @_; |
559 |
|
560 |
my ( @headers, @fields ); |
561 |
while ( $csv_profile_content =~ / |
562 |
([^=]+) # header |
563 |
= |
564 |
([^\|]+) # fieldname (table.row or row) |
565 |
\|? /gxms |
566 |
) { |
567 |
push @headers, $1; |
568 |
my $field = $2; |
569 |
$field =~ s/[^\.]*\.?//; # Remove the table name if exists. |
570 |
push @fields, $field; |
571 |
} |
572 |
|
573 |
my @rows; |
574 |
my @basket_info = get_basket_DB_info($basketno); |
575 |
|
576 |
for my $basket_info ( @basket_info ) { |
577 |
my @row; |
578 |
for my $field ( @fields ) { |
579 |
push @row, $basket_info->{$field}; |
580 |
} |
581 |
push @rows, \@row; |
582 |
} |
583 |
my $hash_ref; |
584 |
$hash_ref->{ 'headers' } = \@headers; |
585 |
$hash_ref->{ 'rows' } = \@rows; |
586 |
|
587 |
return $hash_ref; |
588 |
} |
589 |
|
513 |
output_html_with_http_headers $query, $cookie, $template->output; |
590 |
output_html_with_http_headers $query, $cookie, $template->output; |