ReportDataSource

The report shows how to build report from another report data

MonthAmount
May, 2005 $4,824
June, 2005 $9,632
July, 2005 $28,374
August, 2005 $24,072
February, 2006 $514

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.

    public function settings()
    {
        require "HardwareSaleReport.php";
        return array(
            "dataSources"=>array(
                "hardwareSaleReport"=>array(
                    "class"=>"/koolreport/datasources/ReportDataSource",
                    "report"=>"HardwareSaleReport",
                    "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'));
    }
<?php
require_once "SakilaRental2.php";

$report = new SakilaRental2;
$report->run()->render();
<?php

require_once "../../../load.koolreport.php";

class SakilaRental2 extends \koolreport\KoolReport
{
    public function settings()
    {
        require_once "../csv_report/SakilaRental.php";
        return array(
            "dataSources"=>array(
                "sakila_rental"=>array(
                    "class"=>"/koolreport/datasources/ReportDataSource",
                    "report"=>"SakilaRental",
                )
            )
        );
    }   
    protected function setup()
    {
        $this->src('sakila_rental')
        ->dataStore('sale_by_month') //We want to get data from "sale" data store of HardwareSaleReport
        ->pipe($this->dataStore('sale_by_month_2'));
    } 
}
<?php 
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\widgets\google\ColumnChart;
?>

<div class="report-content">

    <div class="text-center">
        <h1>ReportDataSource</h1>
        <p class="lead">The report shows how to build report from another report data</p>
    </div>

    <?php
    ColumnChart::create(array(
        "dataStore"=>$this->dataStore('sale_by_month_2'),  
        "columns"=>array(
            "payment_date"=>array(
                "label"=>"Month",
                "type"=>"datetime",
                "format"=>"Y-n",
                "displayFormat"=>"F, Y",
            ),
            "amount"=>array(
                "label"=>"Amount",
                "type"=>"number",
                "prefix"=>"$",
            )
        ),
        "width"=>"100%",
    ));
    ?>

    <?php
    Table::create(array(
        "dataStore"=>$this->dataStore('sale_by_month_2'),
        "columns"=>array(
            "payment_date"=>array(
                "label"=>"Month",
                "type"=>"datetime",
                "format"=>"Y-n",
                "displayFormat"=>"F, Y",
            ),
            "amount"=>array(
                "label"=>"Amount",
                "type"=>"number",
                "prefix"=>"$",
                        )
        ),
        "cssClass"=>array(
            "table"=>"table table-hover table-bordered"
        )
    ));
    ?>

</div>

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport Get KoolReport Pro