]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Helper/MassPrintCreatePDF.pm
Massendruck: Attachment-/Archiv-Dateiname in Zielsprache
[mfinanz.git] / SL / Helper / MassPrintCreatePDF.pm
index 454088e6dc274c537ec7181c9e193ac40112f85b..b00950c6c89a0200684b9666cf36dc4469aa105f 100644 (file)
@@ -2,13 +2,13 @@ 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 = (
   all => \@EXPORT_OK,
 );
-use SL::Helper::CreatePDF qw(:all);
-use SL::Helper::File qw(store_pdf append_general_pdf_attachments);
 
 sub create_pdfs {
   my ($self, %params) = @_;
@@ -39,12 +39,34 @@ sub create_massprint_pdf {
   # flatten_to_form sets payment_terms from customer/vendor - we do not want that here
   # really ??
   delete $form->{payment_terms} if !$form->{payment_id};
+  for my $i (1 .. $form->{rowcount}) {
+    $form->{"sellprice_$i"} = $form->{"fxsellprice_$i"};
+  }
 
   $form->prepare_for_printing;
+
+  $form->{language}            = '_' . $form->{language};
   $form->{attachment_filename} = $form->generate_attachment_filename;
 
   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;
@@ -159,6 +181,15 @@ a tempory $form is used to set
 
 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
 
@@ -166,4 +197,3 @@ Martin Helmling E<lt>martin.helmling@opendynamic.deE<gt>
 
 
 =cut
-