X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=3fe20ffb9aca986e54c75bc317a639e7ad4173e4;hb=abd4a0b007159d46da41dc6ed832acc3e85c9744;hp=f100b8c905053ef81610a8463d0a906bc4a7b096;hpb=b3b1b699c773418dd0e9319220d99d65630f35be;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index f100b8c90..3fe20ffb9 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -56,6 +56,7 @@ use SL::DBUtils; use SL::DO; use SL::IC; use SL::IS; +use SL::Locale; use SL::Mailer; use SL::Menu; use SL::MoreCommon qw(uri_encode uri_decode); @@ -851,6 +852,7 @@ sub format_amount { $main::lxdebug->enter_sub(2); my ($self, $myconfig, $amount, $places, $dash) = @_; + $dash ||= ''; if ($amount eq "") { $amount = 0; @@ -867,9 +869,10 @@ sub format_amount { $amount *= 1; $places *= -1; - my ($actual_places) = ($amount =~ /\.(\d+)/); - $actual_places = length($actual_places); - $places = $actual_places > $places ? $actual_places : $places; + if ($amount =~ /\.(\d+)/) { + my $actual_places = length $1; + $places = $actual_places if $actual_places > $places; + } } } $amount = $self->round_amount($amount, $places); @@ -881,7 +884,7 @@ sub format_amount { $p[0] =~ s/\B(?=(...)*$)/$d[1]/g if $d[1]; # add 1,000 delimiters $amount = $p[0]; - $amount .= $d[0].$p[1].(0 x ($places - length $p[1])) if ($places || $p[1] ne ''); + $amount .= $d[0].($p[1]||'').(0 x ($places - length ($p[1]||''))) if ($places || $p[1] ne ''); $amount = do { ($dash =~ /-/) ? ($neg ? "($amount)" : "$amount" ) : @@ -1106,15 +1109,20 @@ sub parse_template { 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} = '>'; } my $result; + my $command_formatter = sub { + my ($out_mode, $out) = @_; + return $out_mode eq '|-' ? SL::Template::create(type => 'ShellCommand', form => $self)->parse($out) : $out; + }; if ($self->{OUT}) { + $self->{OUT} = $command_formatter->($self->{OUT_MODE}, $self->{OUT}); open(OUT, $self->{OUT_MODE}, $self->{OUT}) or $self->error("error on opening $self->{OUT} with mode $self->{OUT_MODE} : $!"); } else { *OUT = ($::dispatcher->get_standard_filehandles)[1]; @@ -1154,19 +1162,15 @@ sub parse_template { # 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 { @@ -1203,10 +1207,12 @@ 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} : $!"); + $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; + seek IN, 0, 0; } else { $self->{attachment_filename} = ($self->{attachment_filename}) @@ -1241,6 +1247,9 @@ sub get_formname_translation { $formname ||= $self->{formname}; + $self->{recipient_locale} ||= Locale->lang_to_locale($self->{language}); + local $::locale = Locale->new($self->{recipient_locale}); + my %formname_translations = ( bin_list => $main::locale->text('Bin List'), credit_note => $main::locale->text('Credit Note'), @@ -1258,7 +1267,7 @@ sub get_formname_translation { ); $main::lxdebug->leave_sub(); - return $formname_translations{$formname} + return $formname_translations{$formname}; } sub get_number_prefix_for_type { @@ -1294,11 +1303,14 @@ sub generate_attachment_filename { $main::lxdebug->enter_sub(); my ($self) = @_; + $self->{recipient_locale} ||= Locale->lang_to_locale($self->{language}); + my $recipient_locale = Locale->new($self->{recipient_locale}); + my $attachment_filename = $main::locale->unquote_special_chars('HTML', $self->get_formname_translation()); my $prefix = $self->get_number_prefix_for_type(); if ($self->{preview} && (first { $self->{type} eq $_ } qw(invoice credit_note))) { - $attachment_filename .= ' (' . $main::locale->text('Preview') . ')' . $self->get_extension_for_format(); + $attachment_filename .= ' (' . $recipient_locale->text('Preview') . ')' . $self->get_extension_for_format(); } elsif ($attachment_filename && $self->{"${prefix}number"}) { $attachment_filename .= "_" . $self->{"${prefix}number"} . $self->get_extension_for_format(); @@ -2509,7 +2521,7 @@ sub get_name { return scalar(@{ $self->{name_list} }); } -# the selection sub is used in the AR, AP, IS, IR and OE module +# the selection sub is used in the AR, AP, IS, IR, DO and OE module # sub all_vc { $main::lxdebug->enter_sub(); @@ -2521,7 +2533,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 @@ -2857,7 +2869,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 {