PHP Report class

What I can do with it?

Every time you need to process data before show it to the end user you have to do some work on it. Usually that means field formating (date, floats), math operations, page formating, etc. That is what this classes can do for you in a organized way.

Think of a shop cart or a report being generated from SQL data. You have to list products, add columns, multiply one column with another, etc. You may also have to organize the result within groups (headers, subtitles), having a header for each group. You may also need to show some totals from numeric columns or format fields from dates and floats coming from the database so they dont show up as ugly 8 or 12 decimal digits and strange date patterns to the user.

Sure, uou can deal with those problems directly each time you need, going each field one by one, or you could use the Report class. Just feed in your data, a HTML template and some definitions and you'll get a very nice html page to show to the user.

Currently you can parse the data and:

  • have sums of columns,
  • apply math operations on columns generating new columns and
  • apply math operations and functions (yours or system ones) on columns generating new columns and
  • apply functions (yours or system ones) directly to columns altering their values.
  • The Report class in the package use several HTML templates classes to parse the result. To understand what a template is and how it works please reffer to the documentation of each supported class. Working suported template classes are PEAR::HTML_Template_IT and PEAR::HTML_Template_PHPLIB, from PEAR or phplib directly, this last template is kept for compatibility with some old work. PEAR::HTML_Template_Sigma is in the package but isnt working yet, i will fix that soon. The classes you will use besides having PEAR installed in you server are:

  • Report.php THE class.
  • Report_template.php 'Interface' to the 'raw' PHPLib template not the PEAR one.
  • Report_PHPLIB.php 'Interface' to the PEAR::HTML_Template_PHPLIB.
  • Report_IT.php 'Interface' to PEAR::HTML_Template_IT ( fixed!).
  • Report_Sigma.php 'Interface' to the PEAR::HTML_Template_Sigma ( but... not working, block parsing is broken).
  • To choose the template classe you want to use, edit the Report.php and include, or require once, the one you want.
    That in the future should change to use a factory pattern.

    This is not Alpha code as far as it is being used for at least 2-3 years in prodution e-commerce sites I am developing and maintaining.

    Your contribution will help me buy pizzas and caffeinate drinks, and that can really speed up the development :) or
    My amazon wish list


    Author: Sebastião Rocha Aladim Neto (a.k.a Neto, a.k.a toomuchcoffeman)

    Contact me: rocha at i-node dot com dot br, if you have any questions


    Google
    Copyright © 2002-2004 Sebastião Rocha A. Neto