Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6ed4a18f

Von Cem Aydin vor 3 Monaten hinzugefügt

  • ID 6ed4a18f9f7e211112a7ddd27fb865eb24f15fde
  • Vorgänger 64ed077b

Berichte Buchungsliste Export aller Konten als PDF (ZIP) ermöglichen

Analog zum CSV export.

Changelog aktualisiert.

Unterschiede anzeigen:

SL/Controller/ListTransactions.pm
71 71
  $self->report->generate_with_headers;
72 72
}
73 73

  
74
sub action_csv_options_export_all_charts {
74
sub action_export_options_all_charts {
75 75
  my ($self) = @_;
76 76

  
77 77
  $self->set_dates;
......
97 97
    { key => $_, value => $self->defaults->{$_} }
98 98
  } keys %{ $self->defaults };
99 99

  
100
  $self->setup_csv_options_action_bar;
101
  $self->render('report_generator/csv_export_options',
102
    title => t8('CSV export -- options'),
103
    HIDDEN => \@hidden,
104
  );
100
  if ($::form->{output_format} eq 'PDF') {
101
    $self->setup_export_options_action_bar(output_format => 'PDF');
102
    $self->render('report_generator/pdf_export_options',
103
      title => t8('PDF export -- options'),
104
      HIDDEN => \@hidden,
105
    );
106
  } else {
107
    $self->setup_export_options_action_bar(output_format => 'CSV');
108
    $self->render('report_generator/csv_export_options',
109
      title => t8('CSV export -- options'),
110
      HIDDEN => \@hidden,
111
    );
112
  }
105 113
}
106 114

  
107 115
sub action_export_all_charts {
108 116
  my ($self) = @_;
109 117

  
118
  my $output_format = $::form->{output_format} // 'CSV';
119

  
110 120
  my $zip = Archive::Zip->new();
111 121

  
112 122
  for my $account (@{ $self->accounts_list }) {
......
117 127
    my $sfile = SL::SessionFile::Random->new(mode => "w");
118 128

  
119 129
    $self->set_title;
120
    $self->report_type('CSV');
130
    $self->report_type($output_format);
121 131

  
122 132
    $self->prepare_report;
123 133
    $self->set_report_data;
124
    $self->report->_generate_csv_content($sfile->fh);
134
    if  ($output_format eq 'PDF') {
135
      my $output = $self->report->generate_pdf_content(want_binary_pdf => 1);
136
      $sfile->fh->print($output);
137
    } else {
138
      $self->report->_generate_csv_content($sfile->fh);
139
    }
125 140
    $sfile->fh->close;
126 141

  
127 142
    $zip->addFile(
128 143
      $sfile->{file_name},
129
      t8('list_of_transactions') . "_" . t8('account') . "_" . $account->{accno} . ".csv"
144
      t8('list_of_transactions') . "_" . t8('account') . "_" . $account->{accno} . ($output_format eq 'PDF' ? '.pdf' : '.csv')
130 145
    );
131 146
  }
132 147

  
......
411 426
        ],
412 427
        action => [
413 428
          t8('Export all accounts to CSV (ZIP file)'),
414
          submit => [ '#report_settings', { action => 'ListTransactions/csv_options_export_all_charts' } ],
429
          submit => [ '#report_settings', {
430
            action => 'ListTransactions/export_options_all_charts',
431
            output_format => 'CSV',
432
          } ],
433
        ],
434
        action => [
435
          t8('Export all accounts to PDF (ZIP file)'),
436
          submit => [ '#report_settings', {
437
            action => 'ListTransactions/export_options_all_charts',
438
            output_format => 'PDF',
439
          } ],
415 440
        ],
416 441
      ], # end of combobox "Export"
417 442
    );
418 443
  }
419 444
}
420 445

  
421
sub setup_csv_options_action_bar {
446
sub setup_export_options_action_bar {
422 447
  my ($self, %params) = @_;
423 448
  for my $bar ($::request->layout->get('actionbar')) {
424 449
    $bar->add(
425 450
      action => [
426 451
        t8('Export'),
427
        submit    => [ '#report_generator_form', { action => 'ListTransactions/export_all_charts' } ],
452
        submit    => [ '#report_generator_form', {
453
          action => 'ListTransactions/export_all_charts',
454
          output_format => $params{output_format},
455
        } ],
428 456
        accesskey => 'enter',
429 457
      ],
430 458
      action => [
......
459 487
  if ($::form->{projectnumber}) {
460 488
    push @text, $::locale->text('Project Number') . " : $::form->{projectnumber}<br>";
461 489
  }
462
  push @text, join " ", t8('Period:'), $self->from_date, "-", $self->to_date;
490
  push @text, join " ", t8('Period:'), $::form->{fromdate}, t8('to'), $::form->{todate};
463 491
  push @text, join " ", t8('Report date:'), $::locale->format_date_object(DateTime->now_local);
464 492
  push @text, join " ", t8('Company:'), $::instance_conf->get_company;
465 493
  join "\n", @text;
......
509 537
options and the sorting of the report.
510 538

  
511 539
At this point, exporting all accounts is possible via Export -> Export all
512
accounts to CSV (ZIP file).
540
accounts to CSV / PDF (ZIP file).
513 541

  
514 542
This will export all accounts for the selected time period and options,
515 543
and offer the resulting file for download.
......
528 556
The database queries in SL::CA are quite sophisticated, therefore i'm still using
529 557
these for now.
530 558

  
531
TODO: Exporting all accounts to PDF (ZIP file) should be added.
532

  
533 559
=head1 BUGS
534 560

  
535 561
None yet.

Auch abrufbar als: Unified diff