X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/0bfbcce6e77e0f9d83e4f54f3fe9da7edcc866f3..38bb9635fde8c2821c23da931bcb6acba8e4b8be:/SL/Helper/File.pm?ds=sidebyside diff --git a/SL/Helper/File.pm b/SL/Helper/File.pm index 7b31ebdd6..96901184b 100644 --- a/SL/Helper/File.pm +++ b/SL/Helper/File.pm @@ -3,19 +3,27 @@ package SL::Helper::File; use strict; use Exporter 'import'; -our @EXPORT_OK = qw(store_pdf append_general_pdf_attachments); +our @EXPORT_OK = qw(store_pdf append_general_pdf_attachments doc_storage_enabled); our %EXPORT_TAGS = (all => \@EXPORT_OK,); use SL::File; +sub doc_storage_enabled { + return 0 unless $::instance_conf->get_doc_storage; + return 1 if $::instance_conf->get_doc_storage_for_documents eq 'Filesystem' && $::instance_conf->get_doc_files; + return 1 if $::instance_conf->get_doc_storage_for_documents eq 'Webdav' && $::instance_conf->get_doc_webdav; + return 0; +} + sub store_pdf { my ($self, $form) = @_; - return unless $::instance_conf->get_doc_storage; + return unless $self->doc_storage_enabled; my $type = $form->{type}; - $type = $form->{formname} if $form->{formname} && !$form->{type}; + $type = $form->{formname} if $form->{formname} && !$form->{type}; + $type = $form->{attachment_type} if $form->{attachment_type}; my $id = $form->{id}; $id = $form->{attachment_id} if $form->{attachment_id} && !$form->{id}; return if !$id || !$type; - my $prefix = $form->get_number_prefix_for_type(); + SL::File->save( object_id => $id, object_type => $type, @@ -24,7 +32,6 @@ sub store_pdf { file_type => 'document', file_name => $form->{attachment_filename}, file_path => $form->{tmpfile}, - file_number => $form->{"${prefix}number"}, ); } @@ -71,7 +78,6 @@ __END__ SL::Helper::File - Helper for $::Form to store generated PDF-Documents - =head1 SYNOPSIS # This Helper is used by SL::Form to store new generated PDF-Files and append general attachments to this documents. @@ -80,7 +86,10 @@ SL::Helper::File - Helper for $::Form to store generated PDF-Documents $self->store_pdf($self); - $self->append_general_pdf_attachments($self) if ( $ext_for_format eq 'pdf' ); + $self->append_general_pdf_attachments(filepath => $pdf_filename, type => $form->{type}) if ( $ext_for_format eq 'pdf' ); + +#It is also used in MassPrint Helper +# =head1 DESCRIPTION @@ -148,4 +157,3 @@ Martin Helmling Emartin.helmling@opendynamic.deE =cut -