1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 ######################################################################
8 # Stuff that can be used from other modules
10 ######################################################################
12 use List::Util qw(max);
17 use SL::ReportGenerator;
19 sub report_generator_export_as_pdf {
20 $lxdebug->enter_sub();
22 if ($form->{report_generator_pdf_options_set}) {
23 my $saved_form = save_form();
25 report_generator_do('PDF');
27 if ($form->{report_generator_printed}) {
28 restore_form($saved_form);
29 $form->{MESSAGE} = $locale->text('The list has been printed.');
30 report_generator_do('HTML');
33 $lxdebug->leave_sub();
38 map { push @form_values, { 'key' => $_, 'value' => $form->{$_} } } keys %{ $form };
40 $form->get_lists('printers' => 'ALL_PRINTERS');
41 map { $_->{selected} = $myconfig{default_printer_id} == $_->{id} } @{ $form->{ALL_PRINTERS} };
43 $form->{copies} = max $myconfig{copies} * 1, 1;
45 $form->{title} = $locale->text('PDF export -- options');
47 print $form->parse_html_template2('report_generator/pdf_export_options', { 'HIDDEN' => \@form_values });
49 $lxdebug->leave_sub();
52 sub report_generator_export_as_csv {
53 $lxdebug->enter_sub();
55 if ($form->{report_generator_csv_options_set}) {
56 report_generator_do('CSV');
57 $lxdebug->leave_sub();
62 map { push @form_values, { 'key' => $_, 'value' => $form->{$_} } } keys %{ $form };
64 $form->{title} = $locale->text('CSV export -- options');
66 print $form->parse_html_template2('report_generator/csv_export_options', { 'HIDDEN' => \@form_values });
68 $lxdebug->leave_sub();
71 sub report_generator_back {
72 $lxdebug->enter_sub();
74 report_generator_do('HTML');
76 $lxdebug->leave_sub();
79 sub report_generator_do {
80 $lxdebug->enter_sub();
84 my $nextsub = $form->{report_generator_nextsub};
86 $form->error($locale->text('report_generator_nextsub is not defined.'));
89 foreach my $key (split m/ +/, $form->{report_generator_variable_list}) {
90 $form->{$key} = $form->{"report_generator_hidden_${key}"};
93 $form->{report_generator_output_format} = $format;
95 delete @{$form}{map { "report_generator_$_" } qw(nextsub variable_list)};
99 $lxdebug->leave_sub();
102 sub report_generator_dispatcher {
103 $lxdebug->enter_sub();
105 my $nextsub = $form->{report_generator_dispatch_to};
107 $form->error($locale->text('report_generator_dispatch_to is not defined.'));
110 delete $form->{report_generator_dispatch_to};
114 $lxdebug->leave_sub();