DMS attachment_policy, falls kein Dokument vorhanden, erste Version erstellen
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 6 Dec 2021 13:55:21 +0000 (14:55 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 20 Dec 2021 10:21:59 +0000 (11:21 +0100)
angepasster commit von Jan

bin/mozilla/io.pl

index eedde3f..7fc87e7 100644 (file)
@@ -2156,7 +2156,17 @@ sub send_sales_purchase_email {
 
   $::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   => $id,
+                                 object_type => $::form->{formname},
+                                 file_type   => 'document');
+  }
+
+  if ($::form->{attachment_policy} eq 'no_file' || ($::form->{attachment_policy} eq 'old_file' && $attfile)) {
     $::form->send_email(\%::myconfig, 'pdf');
 
   } else {