Hi all ,
I hope I'm explaining this correctly , I use codeigniter + grocecycrud. I'm want to create a report which consists from around 10 sql queries that include calculations and joins in my database . When I create a view in grocery crud I have a view button lets say that calls a function in my controller and presents the detail of record with id 1 as in : http://localhost/index.php/controller/function/1 . I want to create a report that takes this id from the controller and pass it to the sql query in koolreport :
eg controller function :
function analysis()
{
$this->load->view('analysis.php');
}
My analysis.php is :
<?php
require APPPATH."reports/Analysis.php";
$report = new Analysis;
$report->run()->render();
and one of my query in Analysis.php :
<?php
require APPPATH . "/libraries/koolreport/autoload.php";
class Analysis extends \koolreport\KoolReport
{
public function settings()
{
return array(
"dataSources" => array(
"data" => array(
"connectionString" => "mysql:host=localhost;dbname=database",
"username" => "",
"password" => "",
"charset" => "utf8",
),
),
);
}
public function setup()
{
//1st Row
$this->src('data')
->query("-- SELECT from table for Calculations ;
SELECT
-- Calculate Max Tolerable Loss (0.2%) ;
ROUND(Own*(-0.2/100), 2) AS MxTol02P,
-- Calulate Scenario fig /0.2% ;
ROUND((Discharge.Actual - Load.Own)-(Own*(-0.2/100)), 3) AS Scenario
FROM Loading
INNER JOIN Discharge
ON Load.idNo = Discharge.idNo
WHERE Load.idNo = 1")
->pipe($this->dataStore('analysis_figures'));
Is there a way instead of putting WHERE Load.idNo = 1 have something like WHERE Load.idNo = '$idNo' and get this idNo from the calling controller ? (all the queries will use this idNo).
I've looked into a couple of similar questions in the forum but I haven't got a clear direction from the answers as in https://www.koolreport.com/forum/topics/1023 where the question describes something similar I guess but I somehow can't really follow the answer and I'm guessing he speaks about variables between koolreports controller and view file whereas I want to pass this variable from my CI controller to koolreport controller .
Sorry for the long post ,I hope I explained this clearly and thanks anyway for any hint.
George