Auftrags-Controller: Email/DMS falls kein Dokument vorhanden, eines erstellen, …
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 1 Dec 2021 12:42:49 +0000 (13:42 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 20 Dec 2021 10:21:59 +0000 (11:21 +0100)
… wenn die Policy sagt, dass der letzte Ausdruck mitgeschickt werden soll

SL/Controller/Order.pm

index 759de32..5c14971 100644 (file)
@@ -474,9 +474,19 @@ 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},
+    my @errors = $self->generate_pdf(\$doc, {media      => $::form->{media},
                                             format     => $::form->{print_options}->{format},
                                             formname   => $::form->{print_options}->{formname},
                                             language   => $self->order->language,