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 = "";
}
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();
$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;
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' });