Hi,
I am trying to build a simple PivotMatrix using koolreport pro 3.25.4. However I could not get any data in the DataStore and PivotMatrix. Please help.
in DCSP_TestReport.php
<?php
require_once "./koolreport/autoload.php";
use \koolreport\processes\Filter;
use \koolreport\processes\ColumnMeta;
use \koolreport\pivot\processes\Pivot;
class DCSP_TestReport extends \koolreport\KoolReport
{
use \koolreport\clients\jQuery;
public function settings()
{
$server = "xxxxxx";
$db_username = "xxxxxx";
$db_password = "xxxxxx";
$service_name = "xxxxxx";
$sid = "xxxxxx";
$port = xxxx;
$dbtns = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = $server)(PORT = $port)) (CONNECT_DATA = (SERVICE_NAME = $service_name) (SID = $sid)))";
return array(
"dataSources"=>array(
"dcsp"=>array(
"connectionString"=>"oci:dbname=" . $dbtns . ";charset=utf8",
"username"=>"$db_username",
"password"=>"$db_password",
)
)
);
}
public function setup() {
$sql = "select 'CAR' change_type,'01/01/2019' as export_week, 2 as chg_qty from dual
union all
select 'CAR' change_type,'01/01/2019' as export_week, 3 as chg_qty from dual
union all
select 'CAR' change_type,'08/01/2019' as export_week, 3 as chg_qty from dual
union all
select 'VAN' change_type,'01/01/2019' as export_week, 5 as chg_qty from dual
union all
select 'VAN' change_type,'08/01/2019' as export_week, 4 as chg_qty from dual
union all
select 'BIKE' change_type,'01/01/2019' as export_week, 1 as chg_qty from dual
";
$node = $this->src('dcsp')
->query($sql)
->pipe(new ColumnMeta(array(
"change_type" => array(
'label' => 'Change Type',
'type' => 'string',
),
"export_week" => array(
'label' => 'Export Week',
'type' => 'string',
),
"chg_qty" => array(
'type' => 'number',
),
)))
->pipe( new Pivot (array(
"dimensions" => array(
"column" => "export_week",
"row" => "change_type",
),
"aggregates"=>array(
"sum" => "chg_qty"
)
)))
->pipe($this->dataStore('OMR'));
}
}
?>
in DCSP_TestReport.view.php
<?php
use \koolreport\pivot\widgets\PivotMatrix;
use \koolreport\core\Utility;
use \koolreport\processes\Filter;
use \koolreport\processes\ColumnMeta;
use \koolreport\pivot\processes\Pivot;
use \koolreport\instant\Widget;
?>
<form id='form1' class="form-inline" method="post">
<?php
// if($this->dataStore('OMR')->countData()>0) {
PivotMatrix::create(array(
"id" => "pivotMatrix1",
"dataStore"=>$this->dataStore('OMR'),
'rowDimension'=>'row',
'columnDimension'=>'column',
'measures' => array("chg_qty - sum"),
'paging' => array(),
));
// }
?>
</form>
This is the result that I am getting.