From: Bernd Bleßmann Date: Mon, 6 Dec 2021 11:28:33 +0000 (+0100) Subject: Files: Druckvariante beim Drucken speichern und bei E-Mail darauf prüfen, … X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~254 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0631649c2c4115f5820829f866af7e2bc2c6623f;p=kivitendo-erp.git Files: Druckvariante beim Drucken speichern und bei E-Mail darauf prüfen, … … um festzustellen, welcher letzte Belegausdruck für die Variante relrevant ist. --- diff --git a/SL/File.pm b/SL/File.pm index e232908e6..afc0cee1a 100644 --- a/SL/File.pm +++ b/SL/File.pm @@ -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}; diff --git a/SL/Form.pm b/SL/Form.pm index e8a3c0eab..229ad2c4d 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -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; diff --git a/SL/Helper/File.pm b/SL/Helper/File.pm index 96901184b..e658b05e9 100644 --- a/SL/Helper/File.pm +++ b/SL/Helper/File.pm @@ -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}, ); } diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 7fc87e7c4..9628ddffd 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -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)) {