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;
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;
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 = (
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;
before printing is done
+Recognized parameters are (not a complete list):
+
+=over 2
+
+=item * C<errors> – optional. If given, it must be an array ref. This will be
+filled with potential errors.
+
+=back
+
=head1 AUTHOR