--- /dev/null
+#
+# Helper for General Ledger Reports
+#
+# 1. Fetch the Count of PDF-Documents of one item of a General Ledger Report
+# 2. Append the contents of all items of a General Ledger Report
+
+package SL::Helper::GlAttachments;
+
+use strict;
+
+use Exporter 'import';
+our @EXPORT_OK = qw(count_gl_attachments append_gl_pdf_attachments);
+our %EXPORT_TAGS = (
+ all => \@EXPORT_OK,
+);
+use SL::File;
+
+my %gl_types = (
+ 'ar' => 'invoice',
+ 'ap' => 'purchase_invoice',
+ 'gl' => 'gl_transaction',
+);
+
+#
+# Fetch the Count of PDF-Documents with are related to the $id parameter
+# The parameter $gltype may be 'ar','ap' or 'gl'.
+#
+sub count_gl_pdf_attachments {
+ my ($self,$id,$gltype) = @_;
+ return SL::File->get_all_count(object_id => $id,
+ object_type => $gl_types{$gltype},
+ mime_type => 'application/pdf',
+ );
+}
+
+# Append the contents of all PDF-Documents to the base $content
+# This Method is only used in SL/Reportgenerator.pm if the $form->{GD} array is set.
+# The elements of the array need the two elements $ref->{type},$ref->{id}
+#
+sub append_gl_pdf_attachments {
+ my ($self,$form,$content) = @_;
+ my @filelist;
+ foreach my $ref (@{ $form->{GL} }) {
+ my @files = SL::File->get_all(object_id => $ref->{id},
+ object_type => $gl_types{$ref->{type}},
+ mime_type => 'application/pdf',
+ );
+ push @filelist, $_->get_file for @files;
+ }
+ return $self->merge_pdfs(file_names => \@filelist , inp_content => $content );
+}
+
+1;
+
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+SL::Helper::GlAttachments - Helper for General Ledger Reports
+
+=head1 SYNOPSIS
+
+ $self->count_gl_pdf_attachments($ref->{id},$ref->{type});
+ $self->append_gl_pdf_attachments($form,$base_content);
+
+
+=head1 DESCRIPTION
+
+Helper for General Ledger Reports
+
+1. Fetch the Count of PDF-Documents of one item of a General Ledger Report
+
+2. Append the contents of all items of a General Ledger Report
+
+
+=head1 METHODS
+
+=head2 C<count_gl_pdf_attachments>
+
+count_gl_pdf_attachments($id,$type);
+
+Fetch the Count of PDF-Documents with are related to the $id parameter
+The parameter $type may be 'ar','ap' or 'gl'.
+
+=head2 C<append_gl_pdf_attachments>
+
+append_gl_pdf_attachments($form,$content);
+
+Append the contents of all PDF-Documents to the base $content
+This Method is only used in SL/Reportgenerator.pm if the $form->{GD} array is set.
+The elements of the array need the two elements $ref->{type},$ref->{id}
+
+=head1 AUTHOR
+
+Martin Helmling E<lt>martin.helmling@opendynamic.deE<gt>
+
+
+=cut
+
#use PDF::Table;
use strict;
+use SL::Helper::GlAttachments qw(append_gl_pdf_attachments);
+use SL::Helper::CreatePDF qw(merge_pdfs);
# Cause locales.pl to parse these files:
# parse_html_template('report_generator/html_report')
my $content = $pdf->stringify();
+ $main::lxdebug->message(LXDebug->DEBUG2(),"addattachments ?? =".$form->{report_generator_addattachments}." GL=".$form->{GL});
+ if ( $form->{report_generator_addattachments} eq 'yes' && $form->{GL}) {
+ $content = $self->append_gl_pdf_attachments($form,$content);
+ }
+
my $printer_command;
if ($pdfopts->{print} && $pdfopts->{printer_id}) {
$form->{printer_id} = $pdfopts->{printer_id};
use SL::DBUtils qw(selectrow_query selectall_hashref_query);
use SL::Webdav;
use SL::Locale::String qw(t8);
+use SL::Helper::GlAttachments qw(count_gl_attachments);
require "bin/mozilla/common.pl";
require "bin/mozilla/reportgenerator.pl";
my @columns = qw(
gldate transdate id reference description
- notes source debit debit_accno
+ notes source doccnt debit debit_accno
credit credit_accno debit_tax debit_tax_accno
credit_tax credit_tax_accno projectnumbers balance employee
);
$form->{l_datesort} = 'Y';
$form->{l_debit_tax_accno} = 'Y';
$form->{l_balance} = $form->{accno} ? 'Y' : '';
+ $form->{l_doccnt} = $form->{l_source} ? 'Y' : '';
my %column_defs = (
'id' => { 'text' => $locale->text('ID'), },
'gldate' => { 'text' => $locale->text('Booking Date'), },
'reference' => { 'text' => $locale->text('Reference'), },
'source' => { 'text' => $locale->text('Source'), },
+ 'doccnt' => { 'text' => $locale->text('Document Count'), },
'description' => { 'text' => $locale->text('Description'), },
'notes' => { 'text' => $locale->text('Notes'), },
'debit' => { 'text' => $locale->text('Debit'), },
$report->set_columns(%column_defs);
$report->set_column_order(@columns);
- $report->set_export_options('generate_report', @hidden_variables, qw(sort sortdir));
+ $form->{l_attachments} = 'Y';
+ $report->set_export_options('generate_report', @hidden_variables, qw(sort sortdir l_attachments));
$report->set_sort_indicator($form->{sort} eq 'accno' ? 'debit_accno' : $form->{sort}, $form->{sortdir});
my $row = { };
map { $row->{$_} = { 'data' => '', 'align' => $column_alignment{$_} } } @columns;
+ if ( $form->{l_doccnt} ) {
+ $row->{doccnt}->{data} = SL::Helper::GlAttachments->count_gl_pdf_attachments($ref->{id},$ref->{type});
+ }
+
my $sh = "";
if ($form->{balance} < 0) {
$sh = " S";
$form->{copies} = max $myconfig{copies} * 1, 1;
my $allow_font_selection = 1;
+ my $allow_attachments = 0;
eval { require PDF::API2; };
$allow_font_selection = 0 if ($@);
+ $allow_attachments = 1 if $form->{report_generator_hidden_l_attachments};
$form->{title} = $locale->text('PDF export -- options');
$form->header();
print $form->parse_html_template('report_generator/pdf_export_options', { 'HIDDEN' => \@form_values,
+ 'ALLOW_ATTACHMENTS' => $allow_attachments,
'ALLOW_FONT_SELECTION' => $allow_font_selection, });
$main::lxdebug->leave_sub();
'Do you want to set the account number "#1" to "#2" and the name "#3" to "#4"?' => 'Soll die Kontonummer "#1" zu "#2" und den Name "#3" zu "#4" geändert werden?',
'Do you want to store the existing onhand values into a new warehouse?' => 'Möchten Sie die vorhandenen Mengendaten in ein Lager übertragen?',
'Document' => 'Dokument',
+ 'Document Count' => 'Anz. PDF Belege',
'Document Project (database ID)' => 'Projektnummer des Belegs (Datenbank-ID)',
'Document Project (description)' => 'Projektnummer des Belegs (Beschreibung)',
'Document Project (number)' => 'Projektnummer des Belegs',
'Export Stammdaten' => 'Export Stammdaten',
'Export as CSV' => 'Als CSV exportieren',
'Export as PDF' => 'Als PDF exportieren',
+ 'Export as PDF with attachments' => 'Als PDF mit Anhängen exportieren',
'Export date' => 'Exportdatum',
'Export date from' => 'Exportdatum von',
'Export date to' => 'Exportdatum bis',
'found' => 'Gefunden',
'found_br' => 'Gef.',
'from (time)' => 'von',
- 'general_ledger_list' => 'buchungsjournal',
+ 'general_ledger_list' => 'Buchungsjournal',
'generate cb/ob transactions for selected charts' => 'Buchungen erstellen',
'gobd-#1-#2.zip' => 'gobd-#1-#2.zip',
'h' => 'h',
<input type="hidden" name="report_generator_pdf_options_set" value="1">
<input type="hidden" name="report_generator_dispatch_to" value="">
+ <input type="hidden" name="report_generator_addattachments" value="">
<table>
<tr>
[%- ELSE %]
<p>
<input type="hidden" name="action" value="report_generator_dispatcher">
- <input type="submit" class="submit" onclick="submit_report_generator_form('report_generator_export_as_pdf')" value="[% 'Export as PDF' | $T8 %]">
+ <input type="submit" class="submit" onclick="submit_report_generator_form('report_generator_export_as_pdf','')" value="[% 'Export as PDF' | $T8 %]">
+[%- IF ALLOW_ATTACHMENTS %]
+ <input type="submit" class="submit"
+ onclick="submit_report_generator_form('report_generator_export_as_pdf','yes')"
+ value="[% 'Export as PDF with attachments' | $T8 %]">
+[%- END %]
<input type="submit" class="submit" onclick="submit_report_generator_form('report_generator_back')" value="[% 'Back' | $T8 %]">
</p>
<script type="text/javascript"><!--
- function submit_report_generator_form(nextsub) {
+ function submit_report_generator_form(nextsub,att) {
document.report_generator_form.report_generator_dispatch_to.value = nextsub;
+ document.report_generator_form.report_generator_addattachments.value = att;
document.report_generator_form.submit();
} // -->
</script>