Beim Dialogbuchen die Kontensalden zu den jeweils ausgewählten Konten anzeigen. Fix...
[kivitendo-erp.git] / SL / Template / Plugin / LxERP.pm
1 package SL::Template::Plugin::LxERP;
2
3 use base qw( Template::Plugin );
4 use Template::Plugin;
5
6 use List::Util qw(min);
7
8 use SL::AM;
9
10 sub new {
11   my $class   = shift;
12   my $context = shift;
13
14   bless { }, $class;
15 }
16
17 sub format_amount {
18   my ($self, $var, $places, $skip_zero, $dash) = @_;
19
20   return $main::form->format_amount(\%main::myconfig, $var * 1, $places, $dash) unless $skip_zero && $var == 0;
21   return '';
22 }
23
24 sub format_amount_units {
25   my ($self, $amount, $amount_unit, $part_unit) = @_;
26
27   return $main::form->format_amount_units('amount'      => $amount,
28                                           'part_unit'   => $part_unit,
29                                           'amount_unit' => $amount_unit,
30                                           'conv_units'  => 'convertible_not_smaller');
31 }
32
33 sub format_percent {
34   my ($self, $var, $places, $skip_zero) = @_;
35
36   return $self->format_amount($var * 100, $places, $skip_zero);
37 }
38
39 sub escape_br {
40   my ($self, $var) = @_;
41
42   $var =~ s/\r//g;
43   $var =~ s/\n/<br>/g;
44
45   return $var;
46 }
47
48 sub format_string {
49   my $self   = shift;
50   my $string = shift;
51
52   return $main::form->format_string($string, @_);
53 }
54
55 sub numtextrows {
56   my $self = shift;
57
58   return $main::form->numtextrows(@_);
59 }
60
61 sub _turn90_word {
62   my $self = shift;
63   my $word = shift || "";
64
65   return join '<br>', map { $main::locale->quote_special_chars('HTML', $_) } split(m//, $word);
66 }
67
68 sub turn90 {
69   my $self            = shift;
70   my $word            = shift;
71   my $args            = shift;
72
73   $args             ||= { };
74   $word             ||= "";
75
76   $args->{split_by} ||= 'chars';
77   $args->{class}      = " class=\"$args->{class}\"" if ($args->{class});
78
79   if ($args->{split_by} eq 'words') {
80     my @words = split m/\s+/, $word;
81
82     if (1 >= scalar @words) {
83       return $self->_turn90_word($words[0]);
84     }
85
86     return qq|<table><tr>| . join('', map { '<td valign="bottom"' . $args->{class} . '>' . $self->_turn90_word($_) . '</td>' } @words) . qq|</tr></table>|;
87
88   } else {
89     return $self->_turn90_word($word);
90   }
91 }
92
93 1;