ok.. so I got past my first hurdle with creating my first report and at least I'm not getting PHP errors.. but I'm not getting any data either and I'm not sure why.. My code is below -- I'm sure it's something easy but I'm lost.. My code is obviously not final -- I just want to see a little of my data and I can go from there..
<?php
require_once "MyUserReport.php";
$report = new MyUserReport;
$report->run()->render();
?>
<?php
require_once "load.koolreport.php";
use \koolreport\processes\Custom;
function decryptField($stringToDecrypt)
{
<my code to decrypt fields -- removed here>
return($decrypted_string);
}
class MyUserReport extends \koolreport\KoolReport
{
protected function settings()
{
return array(
"dataSources"=>array(
"mydatabase"=>array(
"connectionString"=>"mysql:host=localhost;dbname=mydatabase",
"username"=>"<user>",
"password"=>"<pw>",
"charset"=>"utf8mb4"
)
)
);
}
protected function setup()
{
$this->src('mydatabase')
->query("select marital, name, address from users")
->pipe(new Custom(function($row) {
$row["name"] = decryptField($row["name"]);
$row["address"] = decryptField($row["address"]);
}))
->pipe($this->dataStore("users"));
}
}
<?php
use \koolreport\widgets\koolphp\Table;
?>
<div class='report-content'>
<div class="text-center">
<h1>Users by Country</h1>
<p class="lead">The report show total sales on each countries</p>
</div>
<?php
Table::create(array(
"dataStore"=>$this->dataStore("users"),
"columns"=>array(
"marital"=>array(
"label"=>"marital status",
"type"=>"string"
),
"name"=>array(
"label"=>"Name"
),
"address"=>array(
"label"=>"Address"
)
),
"paging"=>array(
"pageSize"=>50,
),
"cssClass"=>array(
"table"=>"table table-bordered table-striped"
)
));
?>
</div>