X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=874aacee6f5d723463f988de0d92b2bcd110e8d0;hb=9aaadfdc06efbfb31f70c32cdf6aacf2f8a136f2;hp=fc900c108e64ff918d020088bf3997da0c7d20ac;hpb=53c26ac20286b4f80238778ef6d649ea1c77e077;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index fc900c108..874aacee6 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -468,7 +468,7 @@ sub header { $layout->use_javascript("$_.js") for (qw( jquery jquery-ui jquery.cookie jqModal jquery.checkall jquery.download - common part_selection switchmenuframe + common part_selection switchmenuframe autocomplete_part ), "jquery/ui/i18n/jquery.ui.datepicker-$::myconfig{countrycode}"); $self->{favicon} ||= "favicon.ico"; @@ -1044,12 +1044,10 @@ sub parse_template { close $temp_fh; (undef, undef, $self->{template_meta}{tmpfile}) = File::Spec->splitpath( $self->{tmpfile} ); - if ($template->uses_temp_file() || $self->{media} eq 'email') { - $out = $self->{OUT}; - $out_mode = $self->{OUT_MODE} || '>'; - $self->{OUT} = "$self->{tmpfile}"; - $self->{OUT_MODE} = '>'; - } + $out = $self->{OUT}; + $out_mode = $self->{OUT_MODE} || '>'; + $self->{OUT} = "$self->{tmpfile}"; + $self->{OUT_MODE} = '>'; my $result; my $command_formatter = sub { @@ -1072,11 +1070,11 @@ sub parse_template { close OUT if $self->{OUT}; - Common::copy_file_to_webdav_folder($self) if ($::instance_conf->get_webdav - and $::instance_conf->get_webdav_documents and not $self->{preview}); + my $copy_to_webdav = $::instance_conf->get_webdav && $::instance_conf->get_webdav_documents && !$self->{preview}; if ($self->{media} eq 'file') { copy(join('/', $self->{cwd}, $userspath, $self->{tmpfile}), $out =~ m|^/| ? $out : join('/', $self->{cwd}, $out)) if $template->uses_temp_file; + Common::copy_file_to_webdav_folder($self) if $copy_to_webdav; $self->cleanup; chdir("$self->{cwd}"); @@ -1085,92 +1083,90 @@ sub parse_template { return; } - if ($template->uses_temp_file() || $self->{media} eq 'email') { + Common::copy_file_to_webdav_folder($self) if $copy_to_webdav; - if ($self->{media} eq 'email') { + if ($self->{media} eq 'email') { - my $mail = new Mailer; + my $mail = new Mailer; - map { $mail->{$_} = $self->{$_} } - qw(cc bcc subject message version format); - $mail->{to} = $self->{EMAIL_RECIPIENT} ? $self->{EMAIL_RECIPIENT} : $self->{email}; - $mail->{from} = qq|"$myconfig->{name}" <$myconfig->{email}>|; - $mail->{fileid} = time() . '.' . $$ . '.'; - $myconfig->{signature} =~ s/\r//g; + map { $mail->{$_} = $self->{$_} } + qw(cc bcc subject message version format); + $mail->{to} = $self->{EMAIL_RECIPIENT} ? $self->{EMAIL_RECIPIENT} : $self->{email}; + $mail->{from} = qq|"$myconfig->{name}" <$myconfig->{email}>|; + $mail->{fileid} = time() . '.' . $$ . '.'; + $myconfig->{signature} =~ s/\r//g; - # if we send html or plain text inline - if (($self->{format} eq 'html') && ($self->{sendmode} eq 'inline')) { - $mail->{contenttype} = "text/html"; - $mail->{message} =~ s/\r//g; - $mail->{message} =~ s/\n/
\n/g; - $myconfig->{signature} =~ s/\n/
\n/g; - $mail->{message} .= "
\n--
\n$myconfig->{signature}\n
"; + # if we send html or plain text inline + if (($self->{format} eq 'html') && ($self->{sendmode} eq 'inline')) { + $mail->{contenttype} = "text/html"; + $mail->{message} =~ s/\r//g; + $mail->{message} =~ s/\n/
\n/g; + $myconfig->{signature} =~ s/\n/
\n/g; + $mail->{message} .= "
\n--
\n$myconfig->{signature}\n
"; - open(IN, "<", $self->{tmpfile}) - or $self->error($self->cleanup . "$self->{tmpfile} : $!"); - $mail->{message} .= $_ while ; - close(IN); + open(IN, "<", $self->{tmpfile}) + or $self->error($self->cleanup . "$self->{tmpfile} : $!"); + $mail->{message} .= $_ while ; + close(IN); - } else { + } else { - if (!$self->{"do_not_attach"}) { - my $attachment_name = $self->{attachment_filename} || $self->{tmpfile}; - $attachment_name =~ s/\.(.+?)$/.${ext_for_format}/ if ($ext_for_format); - $mail->{attachments} = [{ "filename" => $self->{tmpfile}, - "name" => $attachment_name }]; - } + if (!$self->{"do_not_attach"}) { + my $attachment_name = $self->{attachment_filename} || $self->{tmpfile}; + $attachment_name =~ s/\.(.+?)$/.${ext_for_format}/ if ($ext_for_format); + $mail->{attachments} = [{ "filename" => $self->{tmpfile}, + "name" => $attachment_name }]; + } - $mail->{message} =~ s/\r//g; - $mail->{message} .= "\n-- \n$myconfig->{signature}"; + $mail->{message} =~ s/\r//g; + $mail->{message} .= "\n-- \n$myconfig->{signature}"; - } + } - my $err = $mail->send(); - $self->error($self->cleanup . "$err") if ($err); + my $err = $mail->send(); + $self->error($self->cleanup . "$err") if ($err); - } else { + } else { - $self->{OUT} = $out; - $self->{OUT_MODE} = $out_mode; + $self->{OUT} = $out; + $self->{OUT_MODE} = $out_mode; - my $numbytes = (-s $self->{tmpfile}); - open(IN, "<", $self->{tmpfile}) - or $self->error($self->cleanup . "$self->{tmpfile} : $!"); - binmode IN; + my $numbytes = (-s $self->{tmpfile}); + open(IN, "<", $self->{tmpfile}) + or $self->error($self->cleanup . "$self->{tmpfile} : $!"); + binmode IN; - $self->{copies} = 1 unless $self->{media} eq 'printer'; + $self->{copies} = 1 unless $self->{media} eq 'printer'; - chdir("$self->{cwd}"); - #print(STDERR "Kopien $self->{copies}\n"); - #print(STDERR "OUT $self->{OUT}\n"); - for my $i (1 .. $self->{copies}) { - if ($self->{OUT}) { - $self->{OUT} = $command_formatter->($self->{OUT_MODE}, $self->{OUT}); + chdir("$self->{cwd}"); + #print(STDERR "Kopien $self->{copies}\n"); + #print(STDERR "OUT $self->{OUT}\n"); + for my $i (1 .. $self->{copies}) { + if ($self->{OUT}) { + $self->{OUT} = $command_formatter->($self->{OUT_MODE}, $self->{OUT}); - open OUT, $self->{OUT_MODE}, $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!"); - print OUT $_ while ; - close OUT; - seek IN, 0, 0; + open OUT, $self->{OUT_MODE}, $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!"); + print OUT $_ while ; + close OUT; + seek IN, 0, 0; - } else { - $self->{attachment_filename} = ($self->{attachment_filename}) - ? $self->{attachment_filename} - : $self->generate_attachment_filename(); + } else { + $self->{attachment_filename} = ($self->{attachment_filename}) + ? $self->{attachment_filename} + : $self->generate_attachment_filename(); - # launch application - print qq|Content-Type: | . $template->get_mime_type() . qq| + # launch application + print qq|Content-Type: | . $template->get_mime_type() . qq| Content-Disposition: attachment; filename="$self->{attachment_filename}" Content-Length: $numbytes |; - $::locale->with_raw_io(\*STDOUT, sub { print while }); - } + $::locale->with_raw_io(\*STDOUT, sub { print while }); } - - close(IN); } + close(IN); } $self->cleanup;