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