X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=ea724b33ec2fbbecac995d7d19dbd252ab665d9e;hb=117332fcc34457aadb85db18dbc42f48d32b732e;hp=5424a7c923cbd2e6812b59471d953208c058ddeb;hpb=05e0e8ca1544e1ca706a99e51f9caf9a2f56f6af;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index 5424a7c92..ea724b33e 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -621,7 +621,7 @@ sub parse_html_template { $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 }; @@ -633,32 +633,7 @@ sub parse_html_template { 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(); @@ -685,6 +660,16 @@ sub show_generic_error { $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); @@ -1102,7 +1087,7 @@ sub parse_template { 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"} ) { @@ -1169,55 +1154,43 @@ sub send_email { $mail->{message} .= $_ while ; 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(); @@ -1307,6 +1280,7 @@ sub get_formname_translation { 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();