File Manager
<?php
namespace CGExtensions\reports;
// this generator runs the report and returns a data array.
class data_report_generator extends tabular_report_generator
{
private $_data = array('structure'=>array());
private $_rec;
protected function start()
{
$this->_data['title'] = $this->report()->get_title();
$this->_data['description'] = $this->report()->get_description();
$this->_data['generated'] = time();
}
protected function before_group_headers()
{
$this->_rec = array('headers'=>array(),'footers'=>array(),'body'=>array());
}
protected function do_group_header(tabular_report_defn_group $grp)
{
// this method does not call the parent method
$lines = $grp->get_header_lines();
if( count($lines) ) {
foreach( $lines as $line ) {
$rec = array();
foreach( $this->report()->get_columns() as $key => $col ) {
$val = $line->get_column_value($key);
$rec[$key] = $this->get_group_column_display_value($key,$grp->get_column(),$val);
}
$this->_rec['headers'][] = $rec;
}
}
}
function do_group_footer(tabular_report_defn_group $grp)
{
// this method does not call the parent method
$lines = $grp->get_footer_lines();
if( count($lines) ) {
foreach( $lines as $line ) {
$rec = array();
foreach( $this->report()->get_columns() as $key => $col ) {
$val = $line->get_column_value($key);
$rec[$key] = $this->get_group_column_display_value($key,$grp->get_column(),$val);
}
$this->_rec['footers'][] = $rec;
}
}
// this group has changed, go through all columns and reset this group
foreach( $this->report()->get_columns() as $key => $col ) {
$col->reset_group($grp->get_column());
}
}
function after_group_footers()
{
$this->_data['structure'][] = $this->_rec;
$this->_rec = null;
}
protected function set_row($row)
{
parent::set_row($row);
$this->_rec['body'][] = $row;
}
protected function draw_cell(tabular_report_cellfmt $col,$val)
{
// nothing to do here.
}
public function get_output()
{
return $this->_data;
}
} // end of class
?>
File Manager Version 1.0, Coded By Lucas
Email: hehe@yahoo.com