X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=a6ce5afc38c30dc120b8e0c33c9937164927e6d4;hb=0a4891e33e1ee05dd0363d985fb1a2205e25c63c;hp=4caa9b943943b8f04aa47e931049c5f0e69d1654;hpb=0c75bd00cf14a04c9e750c58f289d8688cb579cc;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index 4caa9b943..a6ce5afc3 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -511,7 +511,7 @@ sub create_http_response { '-path' => $base_path); } - my %cgi_params = ('-type' => $params{type}); + my %cgi_params = ('-type' => $params{content_type}); $cgi_params{'-charset'} = $params{charset} if ($parmas{charset}); my $output = $cgi->header('-cookie' => $session_cookie, @@ -594,8 +594,8 @@ sub header { $ajax .= $item->show_javascript(); } - print $self->create_http_response('type' => 'text/html', - 'charset' => $db_charset,); + print $self->create_http_response('content_type' => 'text/html', + 'charset' => $db_charset,); print qq|${doctype} $self->{titlebar} @@ -1246,25 +1246,40 @@ sub get_formname_translation { return $formname_translations{$formname} } -sub generate_attachment_filename { +sub get_number_prefix_for_type { my ($self) = @_; - my $attachment_filename = $main::locale->unquote_special_chars('HTML', $self->get_formname_translation()); my $prefix = (first { $self->{type} eq $_ } qw(invoice credit_note)) ? 'inv' : ($self->{type} =~ /_quotation$/) ? 'quo' : ($self->{type} =~ /_delivery_order$/) ? 'do' : 'ord'; + return $prefix; +} + +sub get_extension_for_format { + my ($self) = @_; + + my $extension = $self->{format} =~ /pdf/i ? ".pdf" + : $self->{format} =~ /postscript/i ? ".ps" + : $self->{format} =~ /opendocument/i ? ".odt" + : $self->{format} =~ /html/i ? ".html" + : ""; + + return $extension; +} + +sub generate_attachment_filename { + my ($self) = @_; + + my $attachment_filename = $main::locale->unquote_special_chars('HTML', $self->get_formname_translation()); + my $prefix = $self->get_number_prefix_for_type(); + if ($attachment_filename && $self->{"${prefix}number"}) { - $attachment_filename .= "_" . $self->{"${prefix}number"} - . ( $self->{format} =~ /pdf/i ? ".pdf" - : $self->{format} =~ /postscript/i ? ".ps" - : $self->{format} =~ /opendocument/i ? ".odt" - : $self->{format} =~ /html/i ? ".html" - : ""); - $attachment_filename = lc $main::locale->quote_special_chars('filenames', $attachment_filename); - $attachment_filename =~ s/ /_/g; + $attachment_filename .= "_" . $self->{"${prefix}number"} . $self->get_extension_for_format(); + $attachment_filename = $main::locale->quote_special_chars('filenames', $attachment_filename); + $attachment_filename =~ s|[\s/\\]+|_|g; } else { $attachment_filename = ""; } @@ -1272,6 +1287,19 @@ sub generate_attachment_filename { return $attachment_filename; } +sub generate_email_subject { + my ($self) = @_; + + my $subject = $main::locale->unquote_special_chars('HTML', $self->get_formname_translation()); + my $prefix = $self->get_number_prefix_for_type(); + + if ($subject && $self->{"${prefix}number"}) { + $subject .= " " . $self->{"${prefix}number"} + } + + return $subject; +} + sub cleanup { $main::lxdebug->enter_sub();