X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FTemplate%2FPlugin%2FLxERP.pm;h=f935a59108d5fabe5cfcaa8faaebf21f8617285f;hb=833f083eae2a4547c49f8f92a2fdca6ba4dfe5f4;hp=7c5ad94fff86ef389bb3d148e2928c5dd1d5307a;hpb=91ab1ef646193de9359076a876a33a74d7691145;p=kivitendo-erp.git
diff --git a/SL/Template/Plugin/LxERP.pm b/SL/Template/Plugin/LxERP.pm
index 7c5ad94ff..f935a5910 100644
--- a/SL/Template/Plugin/LxERP.pm
+++ b/SL/Template/Plugin/LxERP.pm
@@ -1,8 +1,14 @@
package SL::Template::Plugin::LxERP;
use base qw( Template::Plugin );
+use Scalar::Util qw();
use Template::Plugin;
-use List::Util qw(first);
+
+use List::Util qw(min);
+
+use SL::AM;
+
+use strict;
sub new {
my $class = shift;
@@ -11,16 +17,44 @@ 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 '';
}
+sub format_amount_units {
+ my ($self, $amount, $amount_unit, $part_unit) = @_;
+
+ return $main::form->format_amount_units('amount' => $amount,
+ 'part_unit' => $part_unit,
+ 'amount_unit' => $amount_unit,
+ 'conv_units' => 'convertible_not_smaller');
+}
+
sub format_percent {
my ($self, $var, $places, $skip_zero) = @_;
+ $places ||= 2;
+
return $self->format_amount($var * 100, $places, $skip_zero);
}
@@ -33,5 +67,61 @@ sub escape_br {
return $var;
}
-1;
+sub format_string {
+ my $self = shift;
+ my $string = shift;
+
+ return $main::form->format_string($string, @_);
+}
+
+sub numtextrows {
+ my $self = shift;
+ return $main::form->numtextrows(@_);
+}
+
+sub _turn90_word {
+ my $self = shift;
+ my $word = shift || "";
+
+ return join '
', map { $main::locale->quote_special_chars('HTML', $_) } split(m//, $word);
+}
+
+sub turn90 {
+ my $self = shift;
+ my $word = shift;
+ my $args = shift;
+
+ $args ||= { };
+ $word ||= "";
+
+ $args->{split_by} ||= 'chars';
+ $args->{class} = " class=\"$args->{class}\"" if ($args->{class});
+
+ if ($args->{split_by} eq 'words') {
+ my @words = split m/\s+/, $word;
+
+ if (1 >= scalar @words) {
+ return $self->_turn90_word($words[0]);
+ }
+
+ return qq|
{class} . '>' . $self->_turn90_word($_) . ' | ' } @words) . qq|