KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

The same reports multiple times on the same page #2976

Open Luca opened this topic on on Feb 8, 2023 - 1 comments

Luca commented on Feb 8, 2023

Hey guys,

I want to create a report for each worker with their working time each month.

I now created the following code, to open the report multiple times (different data is given)

$planCaseReport = new planCaseReport();
$planCaseReport->setup($this, $this->src("mysql_datasource"), $selectedWorkerArray[$x], $dateStart, $dateEnd, $projektNamen, $projektIds);

But unfortunately this doesn´t open the reports multiple times, its just mixes the data from all the times it got created and makes one report out of it. The reason is, that the "report.view.php" just gets called one time and not multiple times.

Is there any solution to solve this problem, that I will have the same report with different data multiple times on one page?

Than you

Sebastian Morales commented on Feb 9, 2023

Don't pass parameters to report in setup() method, pass them when you create the report and run it like normal:

$parameters = array(
    "dataSourceName" => "mysql_datasource",
    "selectedWorkerArrayElement" => $selectedWorkerArray[$x],
    ...
);
$planCaseReport = new planCaseReport($parameters);
$planCaseReport->run()->render();

In your report file, you can use $this->params to access the passed parameters:

//planCaseReport.php
function setup() {
    $dataSourceName = $this->params["dataSourceName"];
    $selectedWorkerArrayElement = $this->params["selectedWorkerArrayElement"];
    $this->src($dataSourceName)
    ...
}

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None