X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=874aacee6f5d723463f988de0d92b2bcd110e8d0;hb=9aaadfdc06efbfb31f70c32cdf6aacf2f8a136f2;hp=7bc62e8864947692560fe0f0dcc7afb6e437aae9;hpb=a36f8ac729bac34b3dbb43cb8e50924afd51d5ff;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index 7bc62e886..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"; @@ -614,14 +614,7 @@ sub _prepare_html_template { map { $additional_params->{"myconfig_${_}"} = $main::myconfig{$_}; } keys %::myconfig; } - $additional_params->{"conf_webdav"} = $::instance_conf->get_webdav; - $additional_params->{"conf_latex_templates"} = $::lx_office_conf{print_templates}->{latex}; - $additional_params->{"conf_opendocument_templates"} = $::lx_office_conf{print_templates}->{opendocument}; - $additional_params->{"conf_vertreter"} = $::instance_conf->get_vertreter; - $additional_params->{"conf_parts_image_css"} = $::instance_conf->get_parts_image_css; - $additional_params->{"conf_parts_listing_image"} = $::instance_conf->get_parts_listing_image; - $additional_params->{"conf_parts_show_image"} = $::instance_conf->get_parts_show_image; - $additional_params->{"INSTANCE_CONF"} = $::instance_conf; + $additional_params->{INSTANCE_CONF} = $::instance_conf; if (my $debug_options = $::lx_office_conf{debug}{options}) { map { $additional_params->{'DEBUG_' . uc($_)} = $debug_options->{$_} } keys %$debug_options; @@ -1051,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 { @@ -1076,12 +1067,14 @@ sub parse_template { $self->cleanup(); $self->error("$self->{IN} : " . $template->get_error()); } - Common::copy_file_to_webdav_folder($self) if ($::instance_conf->get_webdav - and $::instance_conf->get_webdav_documents and not $self->{preview}); + close OUT if $self->{OUT}; + 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}"); @@ -1090,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;