X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=58b1973aacfc53e5045b70a89052143ab886bd77;hb=c29f804f6abc440789b0c89ff4d7fc171fcf5bda;hp=5393c4719265061215276f668942c0dc450e5d31;hpb=adf1b8cbb7c9b2b49e73256ea66c6fed00e8466e;p=kivitendo-erp.git
diff --git a/SL/Form.pm b/SL/Form.pm
index 5393c4719..58b1973aa 100644
--- a/SL/Form.pm
+++ b/SL/Form.pm
@@ -1094,24 +1094,21 @@ sub parse_template {
# OUT is used for the media, screen, printer, email
# for postscript we store a copy in a temporary file
- my $fileid = time;
- my $prepend_userspath;
-
- if (!$self->{tmpfile}) {
- $self->{tmpfile} = "${fileid}.$self->{IN}";
- $prepend_userspath = 1;
- }
-
- $prepend_userspath = 1 if substr($self->{tmpfile}, 0, length $userspath) eq $userspath;
-
- $self->{tmpfile} =~ s|.*/||;
- $self->{tmpfile} =~ s/[^a-zA-Z0-9\._\ \-]//g;
- $self->{tmpfile} = "$userspath/$self->{tmpfile}" if $prepend_userspath;
+ my ($temp_fh, $suffix);
+ $suffix = $self->{IN};
+ $suffix =~ s/.*\.//;
+ ($temp_fh, $self->{tmpfile}) = File::Temp::tempfile(
+ 'lx-office-printXXXXXX',
+ SUFFIX => '.' . ($suffix || 'tex'),
+ DIR => $userspath,
+ UNLINK => 1,
+ );
+ close $temp_fh;
if ($template->uses_temp_file() || $self->{media} eq 'email') {
- $out = $self->{OUT};
- $out_mode = $self->{OUT_MODE} || '>';
- $self->{OUT} = "$self->{tmpfile}";
+ $out = $self->{OUT};
+ $out_mode = $self->{OUT_MODE} || '>';
+ $self->{OUT} = "$self->{tmpfile}";
$self->{OUT_MODE} = '>';
}
@@ -1152,24 +1149,20 @@ sub parse_template {
$mail->{charset} = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
$mail->{to} = $self->{EMAIL_RECIPIENT} ? $self->{EMAIL_RECIPIENT} : $self->{email};
$mail->{from} = qq|"$myconfig->{name}" <$myconfig->{email}>|;
- $mail->{fileid} = "$fileid.";
+ $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
";
+ $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} : $!");
- while () {
- $mail->{message} .= $_;
- }
-
+ $mail->{message} .= $_ while ;
close(IN);
} else {
@@ -1206,10 +1199,10 @@ sub parse_template {
#print(STDERR "OUT $self->{OUT}\n");
for my $i (1 .. $self->{copies}) {
if ($self->{OUT}) {
- open OUT, $self->{OUT_MODE}, $self->{OUT} or $self->error($self->cleanup . "$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;
+ seek IN, 0, 0;
} else {
$self->{attachment_filename} = ($self->{attachment_filename})
@@ -2524,7 +2517,7 @@ sub all_vc {
$table = $table eq "customer" ? "customer" : "vendor";
- my $query = qq|SELECT count(*) FROM $table|;
+ my $query = qq|SELECT count(*) FROM $table WHERE NOT obsolete|;
my ($count) = selectrow_query($self, $dbh, $query);
# build selection list
@@ -2860,7 +2853,7 @@ sub create_links {
if ($self->{"$self->{vc}_id"}) {
# only setup currency
- ($self->{currency}) = split(/:/, $self->{currencies});
+ ($self->{currency}) = split(/:/, $self->{currencies}) if !$self->{currency};
} else {