Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7fa2595e

Von Jan Büren vor etwa 1 Monat hinzugefügt

  • ID 7fa2595e8cbbb4d3ac3309aad47c897c44682c49
  • Vorgänger 203f9e93
  • Nachfolger 43e54a65

Beim SEPA-Lauf für Überweisungen auch eine Liste der hinterlegten PDFs anbieten

Unterschiede anzeigen:

bin/mozilla/sepa.pl
606 606

  
607 607
  $main::lxdebug->leave_sub();
608 608
}
609
sub bank_transfer_download_sepa_docs {
610
  $main::lxdebug->enter_sub();
611

  
612
  my $form     =  $main::form;
613
  my $defaults = SL::DB::Default->get;
614
  my $locale   =  $main::locale;
615
  my $vc       = $form->{vc} eq 'customer' ? 'customer' : 'vendor';
616

  
617
  if (!$defaults->doc_storage) {
618
    $form->show_generic_error($locale->text('Doc Storage is not enabled'));
619
  }
620

  
621
  my @ids;
622
  if ($form->{mode} && ($form->{mode} eq 'multi')) {
623
     @ids = @{ $form->{ids} || [] };
624
  } else {
625
    @ids = ($form->{id});
626
  }
627

  
628
  if (!@ids) {
629
    $form->show_generic_error($locale->text('You have not selected any export.'));
630
  }
631

  
632
  my @items = ();
633

  
634
  foreach my $id (@ids) {
635
    my $export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1, vc => $vc);
636
    push @items, @{ $export->{items} } if ($export);
637
  }
638
  my @files;
639
  foreach my $item (@items) {
640

  
641
    # check if there is already a file for the invoice
642
    # File::get_all and converting to scalar is a tiny bit stupid, see Form.pm,
643
    # but there is no get_latest_version (but sorts objects by itime!)
644
    # check if already resynced
645
    my ( $file_object ) = SL::File->get_all(object_id   => $item->{ap_id} ? $item->{ap_id} : $item->{ar_id},
646
                                            object_type => $item->{ap_id} ? 'purchase_invoice' : 'invoice',
647
                                            file_type   => 'document',
648
                                           );
649
    next if     (ref $file_object ne 'SL::File::Object');
650
    next unless $file_object->mime_type eq 'application/pdf';
651

  
652
    my $file = $file_object->get_file;
653
    die "No file" unless -e $file;
654
    push @files, $file;
655
  }
656
  my $inputfiles  = join " ", @files;
657
  my $downloadname = $locale->text('SEPA XML Docs for Exports ') . (join " ", @ids) . ".pdf";
658
  my $in = IO::File->new($::lx_office_conf{applications}->{ghostscript} . " -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=- $inputfiles |");
659

  
660
  $form->error($main::locale->text('Could not spawn ghostscript.')) unless $in;
661

  
662
  print $::form->create_http_response(content_type        => 'Application/PDF',
663
                                      content_disposition => 'attachment; filename="'. $downloadname . '"');
664

  
665
  $::locale->with_raw_io(\*STDOUT, sub { print while <$in> });
666
  $in->close;
667

  
668
  $main::lxdebug->leave_sub();
669
}
670

  
609 671

  
610 672
sub bank_transfer_mark_as_closed {
611 673
  $main::lxdebug->enter_sub();
......
643 705
  foreach my $action (qw(bank_transfer_create bank_transfer_edit bank_transfer_list
644 706
                         bank_transfer_post_payments bank_transfer_download_sepa_xml
645 707
                         bank_transfer_mark_as_closed_step1 bank_transfer_mark_as_closed_step2
646
                         bank_transfer_payment_list_as_pdf bank_transfer_undo_sepa_xml)) {
708
                         bank_transfer_payment_list_as_pdf bank_transfer_undo_sepa_xml
709
                         bank_transfer_download_sepa_docs)) {
647 710
    if ($form->{"action_${action}"}) {
648 711
      call_sub($action);
649 712
      return;

Auch abrufbar als: Unified diff