Skip to content

Create a comparison report

bseddon edited this page Nov 13, 2016 · 2 revisions

The code implements two reporting classes: XBRL_Report and XBRL_Report_Compare. Both are descendants of XBRL_Report_Base. They are simple reports. Not simple in the sense of naive. The reports are complex in the sense that they show examples of how to handle multiple and nested hyper-cubes and tuples within presentation role hierarchies. They are simple in the sense that they produce simple reports with periods as columns.

A comparison report begins by instantiating an instance of XBRL_Report_Compare.

$report = new XBRL_Report_Compare();

Next add the instance documents you want to include in the report. The function will check that the instance documents use the same taxonomy.

$report->addInstanceDocument( 'instance document 1.xml' );
$report->addInstanceDocument( 'instance document 2.xml' );

The main step is to prepare a presentation. When the presentation role hierarchies were create during the compile step hyper-cubes were added to nodes representing primary items. During the preparePresentation step these are expanded to relevant dimensions and members. Dimensions can have default members but can have limited value so there is an option to prevent them being added.

$report->excludeDefaultDimensionMembers();
$report->preparePresentation();

Finally generate the HTML rendering and save to disk.

$html = $report->toHtml();
$date = date( "Y-m-d" );
file_put_contents( "report_{$date}.html", $html );
Clone this wiki locally