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 #

Nametypedefaultdescription
classstringMust set to '\koolreport\datasources\ReportDataSource'
reportstringThe full class name of source report you want to get data from.
paramsarrayarray()Parameters that will be inserted to source report when initiated
keystringThis 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 #

Namereturndescription
dataStore(string $name)ReportDataSourceThis 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.