X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate%2FPlugin%2FLxERP.pm;h=f935a59108d5fabe5cfcaa8faaebf21f8617285f;hb=51d553bdcd32f60634b00c9d4c90f023035e7707;hp=a6bd06a80ab2e5aa326c9e747464b1980f47611c;hpb=8c7e44938a661e035f62840e1e177353240ace5d;p=kivitendo-erp.git diff --git a/SL/Template/Plugin/LxERP.pm b/SL/Template/Plugin/LxERP.pm index a6bd06a80..f935a5910 100644 --- a/SL/Template/Plugin/LxERP.pm +++ b/SL/Template/Plugin/LxERP.pm @@ -1,12 +1,15 @@ package SL::Template::Plugin::LxERP; use base qw( Template::Plugin ); +use Scalar::Util qw(); use Template::Plugin; use List::Util qw(min); use SL::AM; +use strict; + sub new { my $class = shift; my $context = shift; @@ -14,10 +17,27 @@ sub new { bless { }, $class; } +sub is_rdbo { + my ($self, $obj, $wanted_class) = @_; + + $wanted_class = !$wanted_class ? 'Rose::DB::Object' + : $wanted_class =~ m{::} ? $wanted_class + : "SL::DB::${wanted_class}"; + + return Scalar::Util::blessed($obj) ? $obj->isa($wanted_class) : 0; +} + sub format_amount { + my ($self, $var, $places, $skip_zero, $dash) = @_; + + return $main::form->format_amount(\%main::myconfig, $var * 1, $places, $dash) unless $skip_zero && $var == 0; + return ''; +} + +sub round_amount { my ($self, $var, $places, $skip_zero) = @_; - return $main::form->format_amount(\%main::myconfig, $var * 1, $places) unless $skip_zero && $var == 0; + return $main::form->round_amount($var * 1, $places) unless $skip_zero && $var == 0; return ''; } @@ -33,6 +53,8 @@ sub format_amount_units { sub format_percent { my ($self, $var, $places, $skip_zero) = @_; + $places ||= 2; + return $self->format_amount($var * 100, $places, $skip_zero); } @@ -62,7 +84,7 @@ sub _turn90_word { my $self = shift; my $word = shift || ""; - return join '
', map { $main::form->quote_html($_) } split(m//, $word); + return join '
', map { $main::locale->quote_special_chars('HTML', $_) } split(m//, $word); } sub turn90 { @@ -90,4 +112,16 @@ sub turn90 { } } +sub abs { + my $self = shift; + my $var = shift; + + return $var < 0 ? $var * -1 : $var; +} + +sub t8 { + my ($self, $text, @args) = @_; + return $::locale->text($text, @args) || $text; +} + 1;