Sammelrechnung / Kundenkonto / Fälligkeitsabrechnung / Statement
[kivitendo-erp.git] / SL / Template / Simple.pm
index d7a7c35..9960908 100644 (file)
@@ -10,6 +10,8 @@ package SL::Template::Simple;
 
 use strict;
 
+use Scalar::Util qw(blessed);
+
 # Parameters:
 #   1. The template's file name
 #   2. A reference to the Form object
@@ -83,13 +85,13 @@ sub uses_temp_file {
 }
 
 sub _get_loop_variable {
-  my $self      = shift;
-  my $var       = shift;
-  my $get_array = shift;
-  my @indices   = @_;
-
+  my ($self, $var, $get_array, @indices) = @_;
   my $form      = $self->{form};
-  my $value;
+  my ($value, @methods);
+
+  if ($var =~ m/\./) {
+    ($var, @methods) = split m/\./, $var;
+  }
 
   if (($get_array || @indices) && (ref $form->{TEMPLATE_ARRAYS} eq 'HASH') && (ref $form->{TEMPLATE_ARRAYS}->{$var} eq 'ARRAY')) {
     $value = $form->{TEMPLATE_ARRAYS}->{$var};
@@ -102,6 +104,17 @@ sub _get_loop_variable {
     $value = $value->[$indices[$i]];
   }
 
+  for my $part (@methods) {
+    if (ref($value) =~ m/^(?:Form|HASH)$/) {
+      $value = $value->{$part};
+    } elsif (blessed($value) && $value->can($part)) {
+      $value = $value->$part;
+    } else {
+      $value = '';
+      last;
+    }
+  }
+
   return $value;
 }