X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FHelper%2FReportGenerator.pm;h=be9b8306de097a622294824a60b6cdbe8c4dcf1c;hb=7890a0001aa7cc60002f7dc9d654762a3febc064;hp=20ab8c3b4a9f6204660c0b0ab66f0d13abe6385d;hpb=40e0911a4ec0bbae2036839e0d9a954ea5c76d07;p=kivitendo-erp.git diff --git a/SL/Controller/Helper/ReportGenerator.pm b/SL/Controller/Helper/ReportGenerator.pm index 20ab8c3b4..be9b8306d 100644 --- a/SL/Controller/Helper/ReportGenerator.pm +++ b/SL/Controller/Helper/ReportGenerator.pm @@ -4,6 +4,7 @@ use strict; use Carp; use List::Util qw(max); +use Scalar::Util qw(blessed); use SL::Common; use SL::MoreCommon; @@ -22,16 +23,18 @@ sub _setup_action_bar { my $key = $::form->{CONTROLLER_DISPATCH} ? 'action' : 'report_generator_form.report_generator_dispatch_to'; my $value = $::form->{CONTROLLER_DISPATCH} ? $::form->{CONTROLLER_DISPATCH} . "/" : ''; - $::request->layout->get('actionbar')->add( - action => [ - $type eq 'pdf' ? $::locale->text('PDF export') : $::locale->text('CSV export'), - submit => [ '#report_generator_form', { $key => "${value}report_generator_export_as_${type}" } ], - ], - action => [ - $::locale->text('Back'), - submit => [ '#report_generator_form', { $key => "${value}report_generator_back" } ], - ], - ); + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + $type eq 'pdf' ? $::locale->text('PDF export') : $::locale->text('CSV export'), + submit => [ '#report_generator_form', { $key => "${value}report_generator_export_as_${type}" } ], + ], + action => [ + $::locale->text('Back'), + submit => [ '#report_generator_form', { $key => "${value}report_generator_back" } ], + ], + ); + } } sub action_report_generator_export_as_pdf { @@ -124,16 +127,24 @@ sub report_generator_list_objects { my @columns = $params{report}->get_visible_columns('HTML'); for my $obj (@{ $params{objects} || [] }) { - my %data = map { - my $def = $column_defs->{$_}; - $_ => { - raw_data => $def->{raw_data} ? $def->{raw_data}->($obj) : '', - data => $def->{sub} ? $def->{sub}->($obj) - : $obj->can($_) ? $obj->$_ - : $obj->{$_}, - link => $def->{obj_link} ? $def->{obj_link}->($obj) : '', - }, - } @columns; + my %data; + + if (blessed($obj) && $obj->isa('SL::Controller::Helper::ReportGenerator::ControlRow::Base')) { + $obj->set_data($params{report}); + next; + + } else { + %data = map { + my $def = $column_defs->{$_}; + my $tmp; + $tmp->{raw_data} = $def->{raw_data} ? $def->{raw_data}->($obj) : ''; + $tmp->{data} = $def->{sub} ? $def->{sub}->($obj) + : $obj->can($_) ? $obj->$_ + : $obj->{$_}; + $tmp->{link} = $def->{obj_link} ? $def->{obj_link}->($obj) : ''; + $_ => $tmp; + } @columns; + } $params{data_callback}->(\%data) if $params{data_callback}; @@ -141,12 +152,12 @@ sub report_generator_list_objects { } my %options = %{ $params{options} || {} }; - $options{action_bar} //= $params{action_bar}; + $options{action_bar} //= $params{action_bar} // 1; if ($params{layout}) { return $params{report}->generate_with_headers(%options); } else { - my $html = $params{report}->generate_html_content(%options); + my $html = $params{report}->generate_html_content(action_bar => 0, %options); $self->render(\$html , { layout => 0, process => 0 }); } } @@ -249,6 +260,14 @@ already (column definitions, title, sort handling etc). Mandatory. An array reference of RDBO models to output. +An element of the array can also be an instance of a control row, i.e. +an instance of a class derived from +C. +See also: + +L +L + =item C Optional. A callback handler (code reference) that gets called for