Files: Druckvariante beim Drucken speichern und bei E-Mail darauf prüfen, …
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 6 Dec 2021 11:28:33 +0000 (12:28 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 20 Dec 2021 10:21:59 +0000 (11:21 +0100)
… um festzustellen, welcher letzte Belegausdruck für die Variante relrevant
ist.

SL/File.pm
SL/Form.pm
SL/Helper/File.pm
bin/mozilla/io.pl

index e232908..afc0cee 100644 (file)
@@ -48,10 +48,11 @@ sub get_all {
     object_id   => $params{object_id},
     object_type => $params{object_type}
   );
-  push @query, (file_name => $params{file_name}) if $params{file_name};
-  push @query, (file_type => $params{file_type}) if $params{file_type};
-  push @query, (mime_type => $params{mime_type}) if $params{mime_type};
-  push @query, (source    => $params{source})    if $params{source};
+  push @query, (file_name     => $params{file_name})     if $params{file_name};
+  push @query, (file_type     => $params{file_type})     if $params{file_type};
+  push @query, (mime_type     => $params{mime_type})     if $params{mime_type};
+  push @query, (source        => $params{source})        if $params{source};
+  push @query, (print_variant => $params{print_variant}) if $params{print_variant};
 
   my $sortby = $params{sort_by} || 'itime DESC,file_name ASC';
 
@@ -218,6 +219,7 @@ sub _save {
         mime_type      => $params{mime_type},
         title          => $params{title},
         description    => $params{description},
+        print_variant  => $params{print_variant},
       );
       $file->itime($params{mtime})    if $params{mtime};
       $params{itime} = $params{mtime} if $params{mtime};
index e8a3c0e..229ad2c 100644 (file)
@@ -975,9 +975,10 @@ sub send_email {
     $attachment_name     =~ s{\.(.+?)$}{.${ext_for_format}} if ($ext_for_format);
 
     if (($self->{attachment_policy} // '') eq 'old_file') {
-      my ( $attfile ) = SL::File->get_all(object_id   => $self->{id},
-                                          object_type => $self->{formname},
-                                          file_type   => 'document');
+      my ( $attfile ) = SL::File->get_all(object_id     => $self->{id},
+                                          object_type   => $self->{type},
+                                          file_type     => 'document',
+                                          print_variant => $self->{formname},);
 
       if ($attfile) {
         $attfile->{override_file_name} = $attachment_name if $attachment_name;
index 9690118..e658b05 100644 (file)
@@ -25,13 +25,14 @@ sub store_pdf {
   return if !$id || !$type;
 
   SL::File->save(
-    object_id   => $id,
-    object_type => $type,
-    mime_type   => 'application/pdf',
-    source      => 'created',
-    file_type   => 'document',
-    file_name   => $form->{attachment_filename},
-    file_path   => $form->{tmpfile},
+    object_id     => $id,
+    object_type   => $type,
+    mime_type     => 'application/pdf',
+    source        => 'created',
+    file_type     => 'document',
+    file_name     => $form->{attachment_filename},
+    file_path     => $form->{tmpfile},
+    print_variant => $form->{formname},
   );
 }
 
index 7fc87e7..9628ddf 100644 (file)
@@ -2161,9 +2161,10 @@ sub send_sales_purchase_email {
   # 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');
+    $attfile = SL::File->get_all(object_id     => $id,
+                                 object_type   => $type,
+                                 file_type     => 'document',
+                                 print_variant => $::form->{formname},);
   }
 
   if ($::form->{attachment_policy} eq 'no_file' || ($::form->{attachment_policy} eq 'old_file' && $attfile)) {