Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 76c486e3

Von Sven Schöling vor etwa 15 Jahren hinzugefügt

  • ID 76c486e3bf157e844b0cf11828d55dae2cb7e439
  • Vorgänger 3d967be3
  • Nachfolger c510d88b

Und wieder ein Schwung strict.

Unterschiede anzeigen:

SL/ReportGenerator.pm
12 12

  
13 13
use SL::Form;
14 14

  
15
use strict;
16

  
15 17
# Cause locales.pl to parse these files:
16 18
# parse_html_template('report_generator/html_report')
17 19

  
......
789 791
     $report->add_data($row1, $row2, @more_rows);
790 792
     $report->generate_with_headers();
791 793

  
792
This creates a report object, sets a few columns, adds some data and generates a standard report. 
794
This creates a report object, sets a few columns, adds some data and generates a standard report.
793 795
Sorting of columns will be alphabetic, and options will be set to their defaults.
794 796
The report will be printed including table headers, html headers and http headers.
795 797

  
......
802 804
Then it lacks usability. You want it to be able to sort the data. You add code for that.
803 805
Then there are too many results, you need pagination, you want to print or export that data..... and so on.
804 806

  
805
The ReportGenerator class was designed because this exact scenario happened about half a dozen times in Lx-Office. 
806
It's purpose is to manage all those formating, culling, sorting, and templating. 
807
The ReportGenerator class was designed because this exact scenario happened about half a dozen times in Lx-Office.
808
It's purpose is to manage all those formating, culling, sorting, and templating.
807 809
Which makes it almost as complicated to use as doing the work for yourself.
808 810

  
809 811
=head1 FUNCTIONS
......
831 833

  
832 834
=item add_data \%data
833 835

  
834
Adds data to the report. A given hash_ref is interpreted as a single line of data, every array_ref as a collection of lines. 
835
Every line will be expected to be in a kay => value format. Note that the rows have to be already sorted. 
836
Adds data to the report. A given hash_ref is interpreted as a single line of data, every array_ref as a collection of lines.
837
Every line will be expected to be in a kay => value format. Note that the rows have to be already sorted.
836 838
ReportGenerator does only colum sorting on its own, and provides links to sorting and visual cue as to which column was sorted by.
837 839

  
838 840
=item add_separator
......
842 844
=item add_control \%data
843 845

  
844 846
Adds a control element to the data. Control elements are an experimental feature to add functionality to a report the regular data cannot.
845
Every control element needs to set IS_CONTROL_DATA, in order to be recongnized by the template. 
847
Every control element needs to set IS_CONTROL_DATA, in order to be recongnized by the template.
846 848
Currently the only control element is a colspan element, which can be used as a mini header further down the report.
847 849

  
848 850
=item clear_data
......
867 869

  
868 870
=item generate_with_headers
869 871

  
870
Parses the report, adds headers and prints it out. Headers depend on the option 'output_format', 
872
Parses the report, adds headers and prints it out. Headers depend on the option 'output_format',
871 873
for example 'HTML' will add proper table headers, html headers and http headers. See configuration for this option.
872 874

  
873 875
=item get_visible_columns $format
......
880 882

  
881 883
=item prepare_html_content $column,$name,@column_headers
882 884

  
883
Parses the data, and sets internal data needed for certain output format. Must be called once before the template is invoked. 
885
Parses the data, and sets internal data needed for certain output format. Must be called once before the template is invoked.
884 886
Should not be called extrenally, since all render and generate functions invoke it anyway.
885
 
887

  
886 888
=item generate_html_content
887 889

  
888 890
The html generation function. Is invoked by generate_with_headers.
......
939 941

  
940 942
Landscape or portrait. Default is landscape.
941 943

  
942
=item font_name 
944
=item font_name
943 945

  
944 946
Default is Verdana. Supported font names are Courier, Georgia, Helvetica, Times and Verdana. This option only affects the rendering with PDF::API2.
945 947

  

Auch abrufbar als: Unified diff