Hello KoolReport Team!
I am trying to add a parameter to my report and this is the current setup that I have: I have this controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require APPPATH."\\reports\SecSummaryReport.php";
class Welcome extends CI_Controller {
public function index()
{
$report = new SecSummaryReport(array('camote'=>"YEAR(ts.sec_In) = YEAR('2020/04/03')"));
$report->run()->render();
}
}
and the Report file contains:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once APPPATH."libraries\koolreport\core\autoload.php";
use \koolreport\KoolReport;
use \koolreport\processes\Filter;
use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
use \koolreport\processes\Limit;
class SecSummaryReport extends \koolreport\KoolReport
{
use \koolreport\codeigniter\Friendship;
public function __construct()
{
parent::__construct();
}
public function settings()
{
$config = include(APPPATH."libraries/koolreport/config.php");
return array(
"dataSources"=>array(
"systems_db"=>$config["systemsdb"]
)
);
}
public function getWhereCond()
{
$conn = new mysqli(PATM_HOST, PATM_USER, PATM_PWD, PATM_DB);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT rq_Id, rq_UserId, rq_Query FROM set_reportqueries";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
return 'WHERE '.$row["rq_Query"];
}
} else {
echo "0 results";
}
$conn->close();
}
public function setup()
{
/* $camote = '';
$params = array();
if(array_key_exists('camote',$this->params)){
$camote .= 'and camote = :camote';
$params[':camote'] = $this->params["camote"];
}*/
$this->src('systems_db')
->query("
SELECT
ts.sec_UserNameId AS UserId,
tul.u_Uname,
CONCAT_WS(' ', tul.u_Uname, '~', tul.u_LastName, tul.u_FirstName,
IF (tul.u_SuffixName = 'NONE' OR tul.u_SuffixName LIKE '%n/a%' OR
tul.u_SuffixName LIKE '%n\\a%', '', tul.u_SuffixName),
IF (tul.u_MiddleName = 'NONE' OR tul.u_MiddleName LIKE '%n/a%' OR
tul.u_SuffixName LIKE '%n\\a%', '', tul.u_MiddleName)
) AS `User`,
Count(tul.u_Uname) AS Ilan,
ts.sec_In,
ts.sec_Out
FROM
tblsec AS ts
INNER JOIN
tbluserlist AS tul ON tul.u_Id = ts.sec_UserNameId
:camote
GROUP BY
ts.sec_UserNameId
ORDER BY
tul.u_LastName ASC
")
->params(array(
":camote"=>$this->params["camote"]
))
->pipe($this->dataStore('column_chart'));
}
}?>
However, upon running, I get this error:
Can you help me figure out what is wrong? Thank you very much.