Beim Verschicken von Belegen per Email den Betreff analog zum Namen des Anhangs vorbe...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 31 Jan 2008 15:54:04 +0000 (15:54 +0000)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 31 Jan 2008 15:54:04 +0000 (15:54 +0000)
SL/Form.pm
bin/mozilla/io.pl

index 510e305..a6ce5af 100644 (file)
@@ -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();
 
index 5385b17..b48671b 100644 (file)
@@ -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' });