X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=3fe20ffb9aca986e54c75bc317a639e7ad4173e4;hb=abd4a0b007159d46da41dc6ed832acc3e85c9744;hp=529426ec2cd9277b322bb01771b2172cc39970f2;hpb=750e2f1a6c01e0502cd6874cbce071c9f4d3456c;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index 529426ec2..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" ) : @@ -1244,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'), @@ -1261,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 { @@ -1297,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(); @@ -2512,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();