The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

SAL::WebDDR - Web-based reporting abstraction for SAL::DBI database objects

Synopsis

 use CGI;
 use CGI::Carp qw(fatalsToBrowser);
 use SAL::DBI;
 use SAL::WebDDR;

 my $dbo_factory = new SAL::DBI;
 my $dbo_data = $dbo_factory->spawn_odbc('REPORTING_DSN',$report_user, $report_pass);
    $dbo_data->execute("sp_FinancialResults 'Q3'");

 my $report = new SAL::WebDDR;
    $report->{datasource} = $dbo_data;
    $report->{dfm_column} = '0';                        # Data Formatting Markup is in column 0
    $report->{skip_fields} = 's 0 1 12 14 15 16 s';     # Do not display columns specified between the s's

 print "Content-type: text/html\n\n";
 my $canvas = $report->build_report();

 print qq[
 <html>
 <head>
 <title>SampleCorp: Financial Results for Q3 2005</title>
 </head>
 <body>
 $canvas
 </body>
 </html>
 ];

Eponymous Hash

This section describes some useful items in the SAL::WebDDR eponymous hash. Arrow syntax is used here for readability, but is not strictly required.

Note: Replace $SAL::WebDDR with the name of your database object... eg. $report->{datasource} = $dbo_data

Datasource
 $SAL::WebDDR->{datasource} is a reference to a SAL::DBI object
Formatting Control
 $SAL::WebDDR->{dfm_column} tells SAL::WebDDR where to look for DFM (Data Formatting Markup) tags
 $SAL::WebDDR->{skip_fields} specifies columns you want to skip in the reports output.

Constructors

new()

Builds a data-driven reporting object.

Methods

$canvas = build_window($titlebar, $canvas, $statusbar, $width)

Builds a window-like html table using 3 scalars: $titelbar, $canvas, $statusbar. $width is optional.

$canvas = build_scroll_window($titlebar, $canvas, $statusbar, $width)

Same as build_window() but uses an iframe for the main window content ($canvas). JScript is used to copy the contents of $canvas into the iframe.

$canvas = build_iframe_window($titlebar, $url, $statusbar, $width)

Same as build_scroll_window() but the embedded iframe retrieves it's content from $url.

$canvas = build_data_table($datasource, $commify, $highlight_negatives, $width)

Build's a simple spreadsheet-like table using $datasource (a SAL::DBI object).

NOTE: This method does not use it's internal datasource connection. (~fixme)

If you want your numbers with commas, set $commify to a non-zero value.

If you'd like negative numbers highlighted, set $highlight_negatives to a non-zero value.

$width is optional, defaulting to 100%

$canvas = build_report()

Build's a data driven report. Please see the file 'salreport.cgi' in the samples directory.

Author

Scott Elcomb <psema4@gmail.com>

See Also

SAL, SAL::DBI, SAL::Graph, SAL::WebApplication