koolreport
koolreport copied to clipboard
How to insert parameters to KoolReport?
KoolReport is able to create dynamic report which received parameters from outside. Let say we want to create a SaleReport which summarize sales for each months of a given year.
We can do this:
<?php
$saleReport = new SaleReport(array(
"year"=>2005
));
$saleReport->run()->render();
Here is our SaleReport.php setup:
<?php
class SaleReport extends from \koolreport\KoolReport
{
...
function setup()
{
//In here you can get the year from $this->params["year']
$year = $this->params["year"];
$this->src("sales")->query("
SELECT month,sum(sale)
FROM tbl_sales
WHERE year=$year
GROUP BY month
")->pipe($this->dataStore('month-of-year'));
}
}
The example show how KoolReport can get parameters and access it in setup()
or setting()
function.