X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/43c22d1ce7f8553219dc7347117bd9b54361b632..1aa5ac26be6aa48cc482bc35f73f36697f17c52b:/SL/ReportGenerator.pm diff --git a/SL/ReportGenerator.pm b/SL/ReportGenerator.pm index 281000602..b02ab35ef 100644 --- a/SL/ReportGenerator.pm +++ b/SL/ReportGenerator.pm @@ -48,9 +48,11 @@ sub new { $self->{data_present} = 0; + bless $self, $type; + $self->set_options(@_) if (@_); - return bless $self, $type; + return $self; } sub set_columns { @@ -107,7 +109,14 @@ sub add_data { $self->{form}->error('Incorrect usage -- expecting hash or array ref'); } + my @columns_with_default_alignment = grep { defined $self->{columns}->{$_}->{align} } keys %{ $self->{columns} }; + foreach my $row (@{ $row_set }) { + foreach my $column (@columns_with_default_alignment) { + $row->{$column} ||= { }; + $row->{$column}->{align} = $self->{columns}->{$column}->{align} unless (defined $row->{$column}->{align}); + } + foreach my $field (qw(data link)) { map { $row->{$_}->{$field} = [ $row->{$_}->{$field} ] if (ref $row->{$_}->{$field} ne 'ARRAY') } keys %{ $row }; } @@ -222,7 +231,7 @@ sub get_visible_columns { my $self = shift; my $format = shift; - return grep { my $c = $self->{columns}->{$_}; $c && $c->{visible} && (($c->{visible} == 1) || ($c->{visible} =~ /${format}/i)) } @{ $self->{column_order} }; + return grep { my $c = $self->{columns}->{$_}; $c && $c->{visible} && (($c->{visible} == 1) || ($c->{visible} =~ /\Q${format}\E/i)) } @{ $self->{column_order} }; } sub html_format {