ReportDataSource
Introduction #
ReportDataSource
is a special data source which help to get data from another report. Let imagine we create a report that requires data already existed in another report. We want to connect to existed report and get those data rather than spending time to rewrite code. ReportDataSource
will help you to do so.
Settings #
Name | type | default | description |
---|---|---|---|
class | string | Must set to '\koolreport\datasources\ReportDataSource' | |
report | string | The full class name of source report you want to get data from. | |
params | array | array() | Parameters that will be inserted to source report when initiated |
key | string | This is optional parameter. In case that you need to create more than one datasource from single source report (only difference in params) then you specify different key for each datasource. |
Methods #
Name | return | description |
---|---|---|
dataStore(string $name) | ReportDataSource | This function is used in setup() function of report. It specifies the name of data store in the source report we want to get data from. |
Example #
<?php
require "HardwareSaleReport.php";
require "SoftwareSaleReport.php";
class TotalSaleReport extends \koolreport\KoolReport
{
public function settings()
{
return array(
"dataSources"=>array(
"hardwareSaleReport"=>array(
"class"=>"/koolreport/datasources/ReportDataSource",
"report"=>"HardwareSaleReport",
"params"=>array("month"=>1,"year"=>2017)
),
"softwareSaleReport"=>array(
"class"=>"/koolreport/datasources/ReportDataSource",
"report"=>"SoftwareSaleReport",
"params"=>array("month"=>1,"year"=>2017)
),
)
);
}
public function setup()
{
$this->src('hardwareSaleReport')
->dataStore('sale') //We want to get data from "sale" data store of HardwareSaleReport
...
->pipe(this->dataStore('sale_of_hardware'));
}
}
Get started with KoolReport
KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.