Revision 7fa2595e
Von Jan Büren vor etwa 1 Jahr hinzugefügt
bin/mozilla/sepa.pl | ||
---|---|---|
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
sub bank_transfer_download_sepa_docs {
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my $form = $main::form;
|
||
my $defaults = SL::DB::Default->get;
|
||
my $locale = $main::locale;
|
||
my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor';
|
||
|
||
if (!$defaults->doc_storage) {
|
||
$form->show_generic_error($locale->text('Doc Storage is not enabled'));
|
||
}
|
||
|
||
my @ids;
|
||
if ($form->{mode} && ($form->{mode} eq 'multi')) {
|
||
@ids = @{ $form->{ids} || [] };
|
||
} else {
|
||
@ids = ($form->{id});
|
||
}
|
||
|
||
if (!@ids) {
|
||
$form->show_generic_error($locale->text('You have not selected any export.'));
|
||
}
|
||
|
||
my @items = ();
|
||
|
||
foreach my $id (@ids) {
|
||
my $export = SL::SEPA->retrieve_export('id' => $id, 'details' => 1, vc => $vc);
|
||
push @items, @{ $export->{items} } if ($export);
|
||
}
|
||
my @files;
|
||
foreach my $item (@items) {
|
||
|
||
# check if there is already a file for the invoice
|
||
# File::get_all and converting to scalar is a tiny bit stupid, see Form.pm,
|
||
# but there is no get_latest_version (but sorts objects by itime!)
|
||
# check if already resynced
|
||
my ( $file_object ) = SL::File->get_all(object_id => $item->{ap_id} ? $item->{ap_id} : $item->{ar_id},
|
||
object_type => $item->{ap_id} ? 'purchase_invoice' : 'invoice',
|
||
file_type => 'document',
|
||
);
|
||
next if (ref $file_object ne 'SL::File::Object');
|
||
next unless $file_object->mime_type eq 'application/pdf';
|
||
|
||
my $file = $file_object->get_file;
|
||
die "No file" unless -e $file;
|
||
push @files, $file;
|
||
}
|
||
my $inputfiles = join " ", @files;
|
||
my $downloadname = $locale->text('SEPA XML Docs for Exports ') . (join " ", @ids) . ".pdf";
|
||
my $in = IO::File->new($::lx_office_conf{applications}->{ghostscript} . " -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=- $inputfiles |");
|
||
|
||
$form->error($main::locale->text('Could not spawn ghostscript.')) unless $in;
|
||
|
||
print $::form->create_http_response(content_type => 'Application/PDF',
|
||
content_disposition => 'attachment; filename="'. $downloadname . '"');
|
||
|
||
$::locale->with_raw_io(\*STDOUT, sub { print while <$in> });
|
||
$in->close;
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
|
||
sub bank_transfer_mark_as_closed {
|
||
$main::lxdebug->enter_sub();
|
||
... | ... | |
foreach my $action (qw(bank_transfer_create bank_transfer_edit bank_transfer_list
|
||
bank_transfer_post_payments bank_transfer_download_sepa_xml
|
||
bank_transfer_mark_as_closed_step1 bank_transfer_mark_as_closed_step2
|
||
bank_transfer_payment_list_as_pdf bank_transfer_undo_sepa_xml)) {
|
||
bank_transfer_payment_list_as_pdf bank_transfer_undo_sepa_xml
|
||
bank_transfer_download_sepa_docs)) {
|
||
if ($form->{"action_${action}"}) {
|
||
call_sub($action);
|
||
return;
|
Auch abrufbar als: Unified diff
Beim SEPA-Lauf für Überweisungen auch eine Liste der hinterlegten PDFs anbieten