1 package SL::Template::Plugin::LxERP;
3 use base qw( Template::Plugin );
7 use List::Util qw(min);
21 my ($self, $obj, $wanted_class) = @_;
23 $wanted_class = !$wanted_class ? 'Rose::DB::Object'
24 : $wanted_class =~ m{::} ? $wanted_class
25 : "SL::DB::${wanted_class}";
27 return Scalar::Util::blessed($obj) ? $obj->isa($wanted_class) : 0;
31 my ($self, $var, $places, $skip_zero, $dash) = @_;
33 return $main::form->format_amount(\%main::myconfig, $var * 1, $places, $dash) unless $skip_zero && $var == 0;
38 my ($self, $var, $places, $skip_zero) = @_;
40 return $main::form->round_amount($var * 1, $places) unless $skip_zero && $var == 0;
44 sub format_amount_units {
45 my ($self, $amount, $amount_unit, $part_unit) = @_;
47 return $main::form->format_amount_units('amount' => $amount,
48 'part_unit' => $part_unit,
49 'amount_unit' => $amount_unit,
50 'conv_units' => 'convertible_not_smaller');
54 my ($self, $var, $places, $skip_zero) = @_;
58 return $self->format_amount($var * 100, $places, $skip_zero);
62 my ($self, $var) = @_;
74 return $main::form->format_string($string, @_);
80 return $main::form->numtextrows(@_);
85 my $word = shift || "";
87 return join '<br>', map { $main::locale->quote_special_chars('HTML', $_) } split(m//, $word);
98 $args->{split_by} ||= 'chars';
99 $args->{class} = " class=\"$args->{class}\"" if ($args->{class});
101 if ($args->{split_by} eq 'words') {
102 my @words = split m/\s+/, $word;
104 if (1 >= scalar @words) {
105 return $self->_turn90_word($words[0]);
108 return qq|<table><tr>| . join('', map { '<td valign="bottom"' . $args->{class} . '>' . $self->_turn90_word($_) . '</td>' } @words) . qq|</tr></table>|;
111 return $self->_turn90_word($word);
119 return $var < 0 ? $var * -1 : $var;
123 my ($self, $text, @args) = @_;
124 return $::locale->text($text, @args) || $text;