$additional_params ||= { };
my $real_file = $self->_prepare_html_template($file, $additional_params);
- my $template = $self->template || $self->init_template;
+ my $template = $self->template;
map { $additional_params->{$_} ||= $self->{$_} } keys %{ $self };
return $output;
}
-sub init_template {
- my $self = shift;
-
- return $self->template if $self->template;
-
- # Force scripts/locales.pl to pick up the exception handling template.
- # parse_html_template('generic/exception')
- return $self->template(Template->new({
- 'INTERPOLATE' => 0,
- 'EVAL_PERL' => 0,
- 'ABSOLUTE' => 1,
- 'CACHE_SIZE' => 0,
- 'PLUGIN_BASE' => 'SL::Template::Plugin',
- 'INCLUDE_PATH' => '.:templates/webpages',
- 'COMPILE_EXT' => '.tcc',
- 'COMPILE_DIR' => $::lx_office_conf{paths}->{userspath} . '/templates-cache',
- 'ERROR' => 'templates/webpages/generic/exception.html',
- 'ENCODING' => 'utf8',
- })) || die;
-}
-
-sub template {
- my $self = shift;
- $self->{template_object} = shift if @_;
- return $self->{template_object};
-}
+sub template { $::request->presenter->get_template }
sub show_generic_error {
$main::lxdebug->enter_sub();
$self->{title} = $params{title} if $params{title};
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Back'),
+ call => [ 'kivi.history_back' ],
+ accesskey => 'enter',
+ ],
+ );
+ }
+
$self->header();
print $self->parse_html_template("generic/error", $add_params);
if ( !$self->{preview} && $ext_for_format eq 'pdf' && $::instance_conf->get_doc_storage) {
$self->{attachment_filename} ||= $self->generate_attachment_filename;
- $self->{print_file_id} = $self->store_pdf($self);
+ $self->{print_file_id} = $self->store_pdf($self)->id;
}
if ($self->{media} eq 'email') {
if ( getcwd() eq $self->{"tmpdir"} ) {
$mail->{message} .= $_ while <IN>;
close(IN);
- } else {
- $main::lxdebug->message(LXDebug->DEBUG2(),"action_oldfile=" . $self->{action_oldfile}." action_nofile=".$self->{action_nofile});
- if (!$self->{"do_not_attach"} && !$self->{action_nofile}) {
- my $attachment_name = $self->{attachment_filename} || $self->{tmpfile};
- $attachment_name =~ s/\.(.+?)$/.${ext_for_format}/ if ($ext_for_format);
- if ( $self->{action_oldfile} ) {
- $main::lxdebug->message(LXDebug->DEBUG2(),"object_id =>". $self->{id}." object_type =>". $self->{formname});
- my ( $attfile ) = SL::File->get_all(object_id => $self->{id},
- object_type => $self->{formname},
- file_type => 'document');
- $main::lxdebug->message(LXDebug->DEBUG2(), "old file obj=".$attfile);
- push @attfiles, $attfile if $attfile;
- } else {
- push @{ $mail->{attachments} }, { path => $self->{tmpfile},
- id => $self->{print_file_id},
- type => "application/pdf",
- name => $attachment_name };
+ } elsif (($self->{attachment_policy} // '') ne 'no_file') {
+ my $attachment_name = $self->{attachment_filename} || $self->{tmpfile};
+ $attachment_name =~ s/\.(.+?)$/.${ext_for_format}/ if ($ext_for_format);
+
+ if (($self->{attachment_policy} // '') eq 'old_file') {
+ my ( $attfile ) = SL::File->get_all(object_id => $self->{id},
+ object_type => $self->{formname},
+ file_type => 'document');
+
+ if ($attfile) {
+ $attfile->{override_file_name} = $attachment_name if $attachment_name;
+ push @attfiles, $attfile;
}
+
+ } else {
+ push @{ $mail->{attachments} }, { path => $self->{tmpfile},
+ id => $self->{print_file_id},
+ type => "application/pdf",
+ name => $attachment_name };
}
}
- if (!$self->{"do_not_attach"}) {
- for my $i (1 .. $self->{attfile_count}) {
- if ( $self->{"attsel_$i"} ) {
- my $attfile = SL::File->get(id => $self->{"attfile_$i"});
- $main::lxdebug->message(LXDebug->DEBUG2(), "att file=".$self->{"attfile_$i"}." obj=".$attfile);
- push @attfiles, $attfile if $attfile;
- }
- }
- for my $i (1 .. $self->{attfile_cv_count}) {
- if ( $self->{"attsel_cv_$i"} ) {
- my $attfile = SL::File->get(id => $self->{"attfile_cv_$i"});
- $main::lxdebug->message(LXDebug->DEBUG2(), "att file=".$self->{"attfile_$i"}." obj=".$attfile);
- push @attfiles, $attfile if $attfile;
- }
- }
- for my $i (1 .. $self->{attfile_part_count}) {
- if ( $self->{"attsel_part_$i"} ) {
- my $attfile = SL::File->get(id => $self->{"attfile_part_$i"});
- $main::lxdebug->message(LXDebug->DEBUG2(), "att file=".$self->{"attfile_$i"}." obj=".$attfile);
- push @attfiles, $attfile if $attfile;
- }
- }
- foreach my $attfile ( @attfiles ) {
- push @{ $mail->{attachments} }, { path => $attfile->get_file,
- id => $attfile->id,
- type => $attfile->mime_type,
- name => $attfile->file_name };
- }
+
+ push @attfiles,
+ grep { $_ }
+ map { SL::File->get(id => $_) }
+ @{ $self->{attach_file_ids} // [] };
+
+ foreach my $attfile ( @attfiles ) {
+ push @{ $mail->{attachments} }, {
+ path => $attfile->get_file,
+ id => $attfile->id,
+ type => $attfile->mime_type,
+ name => $attfile->{override_file_name} // $attfile->file_name,
+ content => $attfile->get_content ? ${ $attfile->get_content } : undef,
+ };
}
+
$mail->{message} =~ s/\r//g;
$mail->{message} .= $full_signature;
$self->{emailerr} = $mail->send();
dunning => $main::locale->text('Dunning'),
letter => $main::locale->text('Letter'),
ic_supply => $main::locale->text('Intra-Community supply'),
+ statement => $main::locale->text('Statement'),
);
$main::lxdebug->leave_sub();