Data-Reporter

 view release on metacpan or  search on metacpan

Reporter.pm  view on Meta::CPAN

SubFinal		function reference, which is called when all data has been processed

=item

SubPrint		function reference, which is called when the report is created

# als, 2001-04-10
=item

User_data		hash reference with data that can be used in each function called during the creation of the report ($hash_ref = $self->[USER_DATA]; $hash_ref->{my_data})

=back

=item

$report->generate()		Generates the report. Returns 0 if OK, 2 if there was no data

=head1 SPECIAL FUNCTIONS

=item

$report->page()		returns the page number

=item

# als, 2001-02-16
$report->date(n)	returns the date in a specific format. n is the format code. Currently, there are only 3 formats 

 1		dd/mm/aaaa
 2		mm/dd/aaaa
 3		aaaa-mm-dd

=item

$report->time(n)	returns the time in a specific format. n is the format code. Currently, there is only 1 format 

 1    hh:mm 

=item

$report->eOR()		indicates the end of report

=item

$report->bOR()		indicates the begining of the report

=item

$report->bOP()		indicates the firts detail in the the page

=item

$report->width()	Report's width

=item

$report->height()	Report's height

=item

$report->islastbreak()	Returns true if it's the last processing break (using the cascade breaks approach)

=item

$report->iPB()	Returns true if the reporter is processing breaks (useful when you want or not to do something while processing breaks)

=item

$report->newpage([TIMES])	indicates that a new page is required. TIMES is the number of form feeds to do. By default is 1

=item

$report->newreport(FILE)		indicates that the data processed up to this point should be stored in file FILE.

=head1 EVENT FUNCTIONS

Each event function (Header, Title, Detail, Break, Foooter, Final), is called automatically when neccesary, passing them the following parameters:

=over 4

=item

report		which can be used to access the special variables

=item

sheet		blank sheet where the output will be defined (see RepFormat pod documentation)

=item

actual_reg	actual processing register

=item

last_reg		last processing register

=back

=over 8

=head2 HEADER FUNCTION

This functions is called each time when a new page is required 

=head2 TITLE FUNCTION

This function is called after the header, and breaks functions.

=head2 DETAIL FUNCTION

This function is called for every data record

=head2 FOOTER FUNCTION

This functions is called at the end of each page

=head2 FINAL FUNCTION

This function is called after the last record has been processed for the detail function

=head2 BREAK FUNTIONS

These functions are called when the break field of the function has changed (see BREAKS section). These functions are called before the detail function for the actual register.

=back

=head1 BREAKS

=item GENERALS

Each break is defined with a break field and a break function. For example:

assume we have the following data:

 1 2
 1 3
 2 4

If we want a break for the first field, that prints the sum of the second field, we have to define the following hash

$breaks{0} = \&sub_break;

where sub_break is the function where the output is defined. We have to define the sum for each record in the 'detail' function

 sub detail ( .....
 ...
 $sum += $field[1];
 ....

so we can do

 sub sub_break ( ....
 ...
 $sheet->Print("the sum is $sum");
 $sum = 0; #reset $sum
 ...


As many breaks as necessary can be defined, but only one break per field is allowed.

=item CASCADE BREAKS

When defining more that one Break, they are handled in cascade. A change in a break field will cause all the break functions defined for fields with a lower value to be called. For example

assume the following data

 1 2 3 1 1
 1 2 3 1 2
 1 2 4 2 3
 1 3 4 2 4

and the following break hash

 $breaks{0} = \&break1;
 $breaks{1} = \&break2;
 $breaks{3} = \&break3;

in the third register, the field #3 changes. This will cause the functions break1, break2 and break3 to be called. The order in which these functions are called are from the left most to the right most one.

In the fourth register the field #2 changes, so functions break1 and break2 will be called, in this order.

=head1 DATASOURCES

This indicates the source for the report data. It can be a Database or a plain ascii file.

Internally, Data::Reporter uses this object to retreive data. This object should have a function 'getdata' defined, which receives a function reference that will be called on each record.

This approach allows to have diferent data sources. At this point the only sources available are a Sybase database and a plain ascii file, but sources for others databases can easily be implemented.

=cut

package Data::Reporter;
use vars qw($myself @ISA $VERSION);
$VERSION = "1.4";
use Exporter();
@ISA = qw(Exporter);
use Data::Reporter::RepFormat;
use Data::Reporter::Datasource;
use Carp;
use English;
use File::Copy;
$|=1;

sub ACTLINE()          {0; }
sub ACTREG()           {1; }
sub BEGINOFPAGE()      {2; }
sub BOR()              {3; }
sub BREAKS()           {4; }
sub DATAFORM()         {5; }
sub EOR()              {6; }
sub FILE_NAME()        {7; }
sub FOOTER_SIZE()      {8; }
sub FORMATFORM()       {9; }
sub HEIGHT()           {10; }
sub LASTBREAK()        {11; }
sub LASTREG()          {12; }
sub LINEAACT()         {13; }
sub NEWPAGE()          {14; }
sub NEWREP()           {15; }
sub NEWREPORT()        {16; }
sub ORIENTATION()      {17; }
sub OS_WIN()           {18; }
sub OUTPUTPATH()       {19; }



( run in 0.809 second using v1.01-cache-2.11-cpan-e1769b4cff6 )