X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FHelper%2FReportGenerator.pm;h=41f0c6c36824e49092c7d735dd952a5503140290;hb=d51b3011755b4a7e006f433d9fe5836a22a69638;hp=13f47983fcb7eff95fd4451cc91253859e284a74;hpb=9365876836531e9e12297483cf75b7868d338116;p=kivitendo-erp.git diff --git a/SL/Controller/Helper/ReportGenerator.pm b/SL/Controller/Helper/ReportGenerator.pm index 13f47983f..41f0c6c36 100644 --- a/SL/Controller/Helper/ReportGenerator.pm +++ b/SL/Controller/Helper/ReportGenerator.pm @@ -5,7 +5,6 @@ use strict; use Carp; use List::Util qw(max); -use SL::Form; use SL::Common; use SL::MoreCommon; use SL::ReportGenerator; @@ -17,6 +16,26 @@ our @EXPORT = qw( report_generator_list_objects ); +sub _setup_action_bar { + my ($self, $type) = @_; + + my $key = $::form->{CONTROLLER_DISPATCH} ? 'action' : 'report_generator_form.report_generator_dispatch_to'; + my $value = $::form->{CONTROLLER_DISPATCH} ? $::form->{CONTROLLER_DISPATCH} . "/" : ''; + + 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 { my ($self) = @_; @@ -43,6 +62,9 @@ sub action_report_generator_export_as_pdf { $::form->{copies} = max $::myconfig{copies} * 1, 1; $::form->{title} = $::locale->text('PDF export -- options'); + + _setup_action_bar($self, 'pdf'); # Sub not exported, therefore don't call via object. + $::form->header; print $::form->parse_html_template('report_generator/pdf_export_options', { 'HIDDEN' => \@form_values, @@ -62,6 +84,9 @@ sub action_report_generator_export_as_csv { my @form_values = $::form->flatten_variables(grep { ($_ ne 'login') && ($_ ne 'password') } keys %{ $::form }); $::form->{title} = $::locale->text('CSV export -- options'); + + _setup_action_bar($self, 'csv'); # Sub not exported, therefore don't call via object. + $::form->header; print $::form->parse_html_template('report_generator/csv_export_options', { 'HIDDEN' => \@form_values }); } @@ -117,10 +142,13 @@ sub report_generator_list_objects { $params{report}->add_data(\%data); } + my %options = %{ $params{options} || {} }; + $options{action_bar} //= $params{action_bar} // 1; + if ($params{layout}) { - return $params{report}->generate_with_headers(%{ $params{options} || {}}); + return $params{report}->generate_with_headers(%options); } else { - my $html = $params{report}->generate_html_content(%{ $params{options} || {}}); + my $html = $params{report}->generate_html_content(action_bar => 0, %options); $self->render(\$html , { layout => 0, process => 0 }); } } @@ -236,6 +264,15 @@ L. An optional hash reference that's passed verbatim to the function L. +=item C + +If the buttons for exporting PDF and/or CSV variants are included in +the action bar. Otherwise they're rendered at the bottom of the page. + +The value can be either a specific action bar instance or simply 1 in +which case the default action bar is used: +C<$::request-Elayout-Eget('actionbar')>. + =back =back