Running Reportico - Options
Running Reportico reports
As you can see, once you have created some reports you can access them from the Administration page by pointing your browser at the index.php file in the Reportico directory. However you can also access reports more directly by specifying the relevant information as part of the URL. For example you can :-
Directly access a report project menu
Run a report specifying all report criteria and the output format in the URL
With JSON and XML output format you can effectively turn your report suite into a web API
Guide users directly to specified report without going through the menu, allowing you to build your own menu front end to reports
Embed reportico and report output within your web pages
Run Reportico from a Linux command line, allowing you to save reports and email them to recipients
In order to achieve the above, you need to point your browser at the run.php in your Reportico area
and provide various parameters
to identify which project you want to run
and what mode - menu mode (the default), report preparation/criteria entry mode or design
mode. To generate report output you need to specify the report xml file name, the report output format ( HTML, PDF, CSV, JSON, XML ) and also the criteria.
criteria and output format (HTML, PDF, CSV) within the URL.
Exampes follow below but a list of available parameters is provided in Appendix 2 - Reportico URL request parameters.
Below find examples of simple
common options for running Reportico from the browser :-
To run
a report menu for a project which is restricted by a password,
enter:
http://{HOST}/{REPORTICO_DIR}/run.php?execute_mode=MENU&project={PROJECTCODE}&project_password={PASSWORD}
To
run a specific report in criteria entry
mode:
http://{HOST}/{REPORTICO_DIR}/run.php?execute_mode=PREPARE&
project={PROJECTCODE}&xmlin={REPORT}.xml
To generate HTML output for a report.
:
http://{HOST}/{REPORTICO_DIR}/run.php?execute_mode=EXECUTE&
project={PROJECTCODE}&xmlin={REPORT}.xml&
target_format=HTML
To generate XML output for a report - just change the XML to PDF, CSV or JSON for those formats
:
http://{HOST}/{REPORTICO_DIR}/run.php?execute_mode=EXECUTE&
project={PROJECTCODE}&xmlin={REPORT}.xml&
target_format=XML
To generate HTML output for, for example, all invoices from 1st August 2011 to Today for raised for customers living in London or Paris you might do:-
:
http://{HOST}/{REPORTICO_DIR}/run.php?execute_mode=EXECUTE&
project={PROJECTCODE}&xmlin={REPORT}.xml&
target_format=HTML&MANUAL_daterange_FROM=2011-08-01&MANUAL_daterange_TO=TODAY%MANUAL_city=London,Paris
To
Run a specific report in design
mode in a password unprotected project:
http://{HOST}/{REPORTICO_DIR}/run.php?execute_mode=MAINTAIN&
project={PROJECTCODE}&xmlin={REPORT}.xml
Execution Modes
Reportico may be run in one
of 4 modes
:-
MENU
Presents the
report menu for the desired project. Uses the menu.php file found within
the project area for the menu definitions and menu
title.
PREPARE
Runs a report
in preparation/criteria entry mode. It is in this mode that the user selects report
criteria and can then generate the report output in the desired format.
Also, if enabled, the user can enter report design mode from the prepare
screen. Running an existing report requires that the project name and the
report XML definition file is passed. If no report name is passed then the
new report definition will be used.
It is this mode that is entered when you select one of the rpeorts from a menu.
MAINTAIN
Runs the report in
design mode. It is in this mode that all the report configuration can be
maintained. Reports can be created, modified and stored. Here reports are configured by entry of SQL data access queries,
formatting, criteria, groups, graphs etc. Again the project and report
definition must be
provided to enter this mode directly.
EXECUTE
This is
report output generation mode. The report switches to this mode when the
user presses the Execute button in Prepare mode. To run a report directly
in this mode, the project and report definition file must be provided
as well as the output method (HTML,PDF etc) as well as any other output options. See the example above
and Appendix 2 - Reportico URL request parameters.
Reportico runner scripts
The supplied
Reportico runner script run.php which allows to run the reports in the above modes
may be customized as you see fit.
This is the contents of the run.php script.
:-
error_reporting(E_ALL);
if (!date_default_timezone_get())
date_default_timezone_set("Europe/London");
ini_set("memory_limit","100M");
//ob_start();
require_once('reportico.php');
$q = new reportico();
$q->allow_debug = true;
$q->forward_url_get_parameters = "";
$q->execute($q->get_execute_mode(), true);
//ob_end_flush();
Taking each line at a time
:-
error_reporting(E_ALL);
Sets full error reporting, which is useful when debugging reports - this can be turned off or commented out as required.
if (!date_default_timezone_get()) date_default_timezone_set("Europe/London");
The reporting engine works with dates and needs a system timezone to be set. If not it is forced to a UK timezone.
ini_set("memory_limit","100M");
For more complex reports, more memory may be required than allowed by the existing PHP config. This allocates 100 Mb but can be changed or commented out as required.
require_once('reportico.php');
Includes
the reporting class that is responsible for all the capabilities of
Reportico such as menus, report design, report criteria entry and output
generation.
$q = new reportico();
Creates an instance of the
reporting tool in variable $q.
$q->allow_debug = true;
Enables debug mode. When running a
report, a debug list box will appear. The user can then get information
about the database calls made while the report is being
generated.
$q->forward_url_get_parameters = "";
Specifies a list of URL GET parameters which are included in all invocations of this calling script and all links presented while running Reportico.
This is useful when embedding Reportico within web frameworks that rely on parameters being used to control navigation around the site.
Specify in the form <param1=value1¶m2=value2>
$q->execute($a->get_execute_mode(),true);
Enters the reporting tool in the
current mode whether MENU, PREPARE, MAINTAIN or EXECUTE. This is the mode
that is provided on the URL command line. The default is PREPARE.
Embedding a report within a web
page
In order to place a fully functional report within your
own web pages it is necessary to include php code that will include the
Reportico reporting engine, set various parameters and then execute it. The
code you embed is not much different from the code in a runner script
except that the embedded_report option is set and the full path to Reportico must be included within
the INCLUDE PATH. You should also include within you HTML a reference to the desired
stylesheet within the Reportico stylesheet directory in order to set the look and feel. An example web page may
look as follows :
<HTML>
<BODY>
...... Your web content ......
<!-- Start of Reportico Report -->
<?php
set_include_path('{PATH TO REPORTICO DIRECTORY}');
require_once('reportico.php');
$a = new reportico();
$a->embedded_report = true;
$a->forward_url_get_parameters = "x1=y1&x2=y2";
$a->execute();
?>
< !-- End of Reportico Report -->
...... More web content ......
</BODY>
</HTML>