X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate%2FPlugin%2FLxERP.pm;h=f935a59108d5fabe5cfcaa8faaebf21f8617285f;hb=9b039e37be3108c90d20d4db36f0a9a54400c800;hp=df6cb6ad6cb4944131bb4e96f0063a5eceeef60c;hpb=37a84d92f0b0981aa6a8b9ec249baad97f4c0a5f;p=kivitendo-erp.git diff --git a/SL/Template/Plugin/LxERP.pm b/SL/Template/Plugin/LxERP.pm index df6cb6ad6..f935a5910 100644 --- a/SL/Template/Plugin/LxERP.pm +++ b/SL/Template/Plugin/LxERP.pm @@ -1,6 +1,7 @@ package SL::Template::Plugin::LxERP; use base qw( Template::Plugin ); +use Scalar::Util qw(); use Template::Plugin; use List::Util qw(min); @@ -16,6 +17,16 @@ 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) = @_; @@ -42,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); } @@ -107,9 +120,8 @@ sub abs { } sub t8 { - my ($self, $text, $args) = @_; - $self->{locale} ||= Locale->new($::myconfig{countrycode}, 'all'); - return $self->{locale}->text($text, @{ $args || [] }); + my ($self, $text, @args) = @_; + return $::locale->text($text, @args) || $text; } 1;