From: Moritz Bunkus Date: Thu, 31 Jan 2008 15:54:04 +0000 (+0000) Subject: Beim Verschicken von Belegen per Email den Betreff analog zum Namen des Anhangs vorbe... X-Git-Tag: release-2.6.0beta1~258 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=afe54bed5b9aabdeada2ebcc1c95fc2b8bf1022e;p=kivitendo-erp.git Beim Verschicken von Belegen per Email den Betreff analog zum Namen des Anhangs vorbelegen, sofern der Betreff nicht vom Aufrufer vorgegeben wird. --- diff --git a/SL/Form.pm b/SL/Form.pm index 510e30561..a6ce5afc3 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -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 = $main::locale->quote_special_chars('filenames', $attachment_filename); - $attachment_filename =~ s|[\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(); diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 5385b17ce..b48671bae 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -967,6 +967,7 @@ sub edit_e_mail { $form->{media} = "email"; my $attachment_filename = $form->generate_attachment_filename(); + my $subject = $form->{subject} || $form->generate_email_subject(); $form->{"fokus"} = $form->{"email"} ? "Form.subject" : "Form.email"; $form->header; @@ -979,6 +980,7 @@ sub edit_e_mail { print $form->parse_html_template('generic/edit_email', { title => $title, a_filename => $attachment_filename, + subject => $subject, _print_options_ => print_options('inline' => 1), HIDDEN => [ map +{ name => $_, value => $form->{$_} }, @hidden_keys ], SHOW_BCC => $myconfig{role} eq 'admin' });