From: Bernd Bleßmann Date: Fri, 22 Nov 2019 15:14:23 +0000 (+0100) Subject: Massendruck: Kopieren ins Webdav in den Helper verschoben. X-Git-Tag: release-3.5.6.1~429 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a5d4818cb7437683707f042b99cbecff27ce6799;p=kivitendo-erp.git Massendruck: Kopieren ins Webdav in den Helper verschoben. Damit erzeugen alle Druckvorgänge hierüber Kopien im Webdav --- diff --git a/SL/BackgroundJob/MassRecordCreationAndPrinting.pm b/SL/BackgroundJob/MassRecordCreationAndPrinting.pm index e799c2447..756867a8c 100644 --- a/SL/BackgroundJob/MassRecordCreationAndPrinting.pm +++ b/SL/BackgroundJob/MassRecordCreationAndPrinting.pm @@ -15,7 +15,6 @@ use SL::Locale::String qw(t8); use SL::Helper::MassPrintCreatePDF qw(:all); use SL::Helper::CreatePDF qw(:all); use SL::Helper::File qw(store_pdf append_general_pdf_attachments doc_storage_enabled); -use SL::Webdav; use constant WAITING_FOR_EXECUTION => 0; use constant CONVERTING_DELIVERY_ORDERS => 1; @@ -104,32 +103,18 @@ sub convert_invoices_to_pdf { foreach my $invoice (@{ $self->{invoices} }) { eval { + my @errors = (); my %params = ( variables => \%variables, return => 'file_name', document => $invoice, + errors => \@errors, ); push @pdf_file_names, $self->create_massprint_pdf(%params); - $data->{num_printed}++; - # OLD WebDAV Code, may be deleted: - # copy file to webdav folder - if ($::instance_conf->get_webdav_documents) { - my $webdav = SL::Webdav->new( - type => 'invoice', - number => $invoice->invnumber, - ); - my $webdav_file = SL::Webdav::File->new( - webdav => $webdav, - filename => t8('Invoice') . '_' . $invoice->invnumber . '.pdf', - ); - eval { - $webdav_file->store(file => $pdf_file_names[-1]); - 1; - } or do { - push @{ $data->{print_errors} }, { id => $invoice->id, number => $invoice->invnumber, message => $@ }; - } + if (scalar @errors) { + push @{ $data->{print_errors} }, { id => $invoice->id, number => $invoice->invnumber, message => join(', ', @errors) }; } 1; diff --git a/SL/Helper/MassPrintCreatePDF.pm b/SL/Helper/MassPrintCreatePDF.pm index 66fbaf2b9..1117c4fe5 100644 --- a/SL/Helper/MassPrintCreatePDF.pm +++ b/SL/Helper/MassPrintCreatePDF.pm @@ -2,6 +2,8 @@ package SL::Helper::MassPrintCreatePDF; use strict; +use SL::Webdav; + use Exporter 'import'; our @EXPORT_OK = qw(create_massprint_pdf merge_massprint_pdf create_pdfs print_pdfs); our %EXPORT_TAGS = ( @@ -46,6 +48,23 @@ sub create_massprint_pdf { my $pdf_filename = $self->create_pdf(%create_params); + if ($::instance_conf->get_webdav_documents && !$form->{preview}) { + my $webdav = SL::Webdav->new( + type => $params{document}->type, + number => $params{document}->record_number, + ); + my $webdav_file = SL::Webdav::File->new( + webdav => $webdav, + filename => $form->{attachment_filename}, + ); + eval { + $webdav_file->store(file => $pdf_filename); + 1; + } or do { + push @{ $params{errors} }, $@ if exists $params{errors}; + } + } + if ( $::instance_conf->get_doc_storage && ! $form->{preview}) { $self->append_general_pdf_attachments(filepath => $pdf_filename, type => $form->{type} ); $form->{tmpfile} = $pdf_filename; @@ -160,6 +179,15 @@ a tempory $form is used to set before printing is done +Recognized parameters are (not a complete list): + +=over 2 + +=item * C – optional. If given, it must be an array ref. This will be +filled with potential errors. + +=back + =head1 AUTHOR