2 # Helper for General Ledger Reports
 
   4 # 1. Fetch the Count of PDF-Documents of one item of a General Ledger Report
 
   5 # 2. Append the contents of all items of a General Ledger Report
 
   7 package SL::Helper::GlAttachments;
 
  11 use Exporter 'import';
 
  12 our @EXPORT_OK = qw(count_gl_attachments append_gl_pdf_attachments);
 
  20   'ap' => 'purchase_invoice',
 
  21   'gl' => 'gl_transaction',
 
  25 # Fetch the Count of PDF-Documents with are related to the $id parameter
 
  26 # The parameter $gltype may be 'ar','ap' or 'gl'.
 
  28 sub count_gl_pdf_attachments {
 
  29   my ($self,$id,$gltype) = @_;
 
  30   return SL::File->get_all_count(object_id   => $id,
 
  31                                  object_type => $gl_types{$gltype},
 
  32                                  mime_type   => 'application/pdf',
 
  36 # Append the contents of all PDF-Documents to the base $content
 
  37 # This Method is only used in SL/Reportgenerator.pm if the $form->{GD} array is set.
 
  38 # The elements of the array need the two elements $ref->{type},$ref->{id}
 
  40 sub append_gl_pdf_attachments {
 
  41   my ($self,$form,$content) = @_;
 
  43   foreach my $ref (@{ $form->{GL} }) {
 
  44     my @files = SL::File->get_all(object_id   => $ref->{id},
 
  45                                   object_type => $gl_types{$ref->{type}},
 
  46                                   mime_type   => 'application/pdf',
 
  48     push @filelist, $_->get_file for @files;
 
  50   return $self->merge_pdfs(file_names => \@filelist , inp_content => $content );
 
  61 SL::Helper::GlAttachments - Helper for General Ledger Reports
 
  65    $self->count_gl_pdf_attachments($ref->{id},$ref->{type});
 
  66    $self->append_gl_pdf_attachments($form,$base_content);
 
  71 Helper for General Ledger Reports
 
  73 1. Fetch the Count of PDF-Documents of one item of a General Ledger Report
 
  75 2. Append the contents of all items of a General Ledger Report
 
  80 =head2 C<count_gl_pdf_attachments>
 
  82 count_gl_pdf_attachments($id,$type);
 
  84 Fetch the Count of PDF-Documents with are related to the $id parameter
 
  85 The parameter $type may be 'ar','ap' or 'gl'.
 
  87 =head2 C<append_gl_pdf_attachments>
 
  89 append_gl_pdf_attachments($form,$content);
 
  91 Append the contents of all PDF-Documents to the base $content
 
  92 This Method is only used in SL/Reportgenerator.pm if the $form->{GD} array is set.
 
  93 The elements of the array need the two elements $ref->{type},$ref->{id}
 
  97 Martin Helmling E<lt>martin.helmling@opendynamic.deE<gt>