]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/Order.pm
E-Mail-Dialog: Druck-Optionen auch für Policy "letzten Ausdruck mitschicken", …
[mfinanz.git] / SL / Controller / Order.pm
index 81f15e1d0beaf8b73683a3cf3a950f11ba2e9286..1ac21c513a212f35eedfb988ae3a50b536b85c2b 100644 (file)
@@ -474,14 +474,24 @@ sub action_send_email {
   $::form->{$_}     = $::form->{print_options}->{$_} for keys %{ $::form->{print_options} };
   $::form->{media}  = 'email';
 
-  if (($::form->{attachment_policy} // '') !~ m{^(?:old_file|no_file)$}) {
+  $::form->{attachment_policy} //= '';
+
+  # Is an old file version available?
+  my $attfile;
+  if ($::form->{attachment_policy} eq 'old_file') {
+    $attfile = SL::File->get_all(object_id   => $self->order->id,
+                                 object_type => $::form->{formname},
+                                 file_type   => 'document');
+  }
+
+  if ($::form->{attachment_policy} ne 'no_file' && !($::form->{attachment_policy} eq 'old_file' && $attfile)) {
     my $doc;
     my @errors = $self->generate_doc(\$doc, {media      => $::form->{media},
-                                            format     => $::form->{print_options}->{format},
-                                            formname   => $::form->{print_options}->{formname},
-                                            language   => $self->order->language,
-                                            printer_id => $::form->{print_options}->{printer_id},
-                                            groupitems => $::form->{print_options}->{groupitems}});
+                                             format     => $::form->{print_options}->{format},
+                                             formname   => $::form->{print_options}->{formname},
+                                             language   => $self->order->language,
+                                             printer_id => $::form->{print_options}->{printer_id},
+                                             groupitems => $::form->{print_options}->{groupitems}});
     if (scalar @errors) {
       return $self->js->flash('error', t8('Generating the document failed: #1', $errors[0]))->render($self);
     }
@@ -2127,6 +2137,7 @@ sub generate_doc {
           longdescription => 'html',
           partnotes       => 'html',
           notes           => 'html',
+          $::form->get_variable_content_types_for_cvars,
         },
       );
       1;