KoolReport's Forum

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

Function Redclaration error in latest pro version? #677

Closed gkurl opened this topic on on Feb 14, 2019 - 10 comments

gkurl commented on Feb 14, 2019

Hi Guys,

I am receiving the following error message:

Fatal error: Cannot redeclare koolreport\widgets\koolphp\groupLevel() (previously declared in /var/www/gags/api/scheduledreport/koolreport/src/widgets/koolphp/Table.php:229)

Not sure why or how, please any help?

gkurl commented on Feb 14, 2019

Sorry forgot to add - this is when using the Export package. I have included it in my main report class as stated in the instructions - error occurs when I try and call the toBase64() method. If I take that out, the report generates fine. I have multiple resultsets being processed and this was never a problem before. Any insight please let me know.

KoolReport commented on Feb 14, 2019

Could you please let me know what version of PHP you are using?

gkurl commented on Feb 14, 2019

Yes sure - it is version 7.1.11

KoolReport commented on Feb 14, 2019

It is strange, could you please post your code here. The code that you will get error when added.

KoolReport commented on Feb 15, 2019

We've released new version 3.25.4, please try to upgrade and let me know if it works.

gkurl commented on Feb 15, 2019

Thanks for reply.

I have updated and I am still seeing the same error - I believe I have an idea how. My reports are handled by one class that extends Koolreport - I am calling the report like so.

 $maxkool = new MaxtimeKoolReport($reports[$r['reportid']]['koolreport'], $resultset);

                     $base64report = 0;

                     
                    $reporthtml = $maxkool -> run()->render(null, true);
                    $pdf = $maxkool -> export($reporthtml) -> settings(["useLocalTempFolder" => true]) -> pdf(["format" => "A4", "orientation" => "portrait"])->saveAs("report.pdf");

This is working fine if I run the

$reporthtml = $maxkool -> run()->render(null, true);

by itself

as this gets me my raw html output which is what I require, it's when I call:

 $pdf = $maxkool -> export($reporthtml) -> settings(["useLocalTempFolder" => true]) -> pdf(["format" => "A4", "orientation" => "portrait"])->saveAs("report.pdf");

and pass in the $reporthtml aka the "view" that I still get

Fatal error: Cannot redeclare koolreport\widgets\koolphp\groupLevel() (previously declared in /var/www/gags/api/scheduledreport/koolreport/src/widgets/koolphp/Table.php:229)

So it seems calling methods on the object twice is the cause? I'm assuming somewhere down the line, the export() method must also perform similar functions to the run() or render() method?

Please let me know.

More than happy to share more code if need be.

Thanks.

KoolReport commented on Feb 15, 2019

It seems to me the Table.php has not been updated. Could you please do me a favor, you open the \koolreport\src\widgets\koolphp\Table.php and replace with the code here:

https://github.com/koolphp/koolreport/blob/master/src/widgets/koolphp/Table.php

gkurl commented on Feb 15, 2019

Ah ok thanks! Yes this has solved it - I see you've made the function static - good call! :)

I have another issue related - as I am trying to export a PDF - it goes through the export() function fine but there is no output and keep getting blank PDF files - I have included

    use \koolreport\export\Exportable;

in my report class file and the file that I am creating the Koolreport object from.

I know I am getting data out because when I do a file_put_contents on the $reporthtml and view it I can see my report has successfully generated. But it doesn't seem to translate into the PDF?

Please any help would be appreciated.

gkurl commented on Feb 15, 2019

Ok so I am placing contents of report html in a file called "test.html" and running that through the instant exporter package as another test. The test.html file contains the same information and structure as your SakillaRental.view.php file in PDF export example, except it just has my datasources in.

  1. Sending HTML into export() function as variable i.e. export($html) AFTER running $report -> run() -> render() is this possible? If not, how can it be made possible?

  2. Biggest problem using instant exporter - when the script attempts to execute the "runPhantom()" method for some reason it all just freezes. It does not execute further in the PHP, but just hangs and causes network disconnect eventually. So I can not get it to export at all currently.

  3. I have ran phantomjs -v on the command line in the bin folder of packages/export and I am seeing 2.1.1 return meaning I have installed correctly as PATH variable etc. I am on CentOS 6.9.

Please let me know.

gkurl commented on Feb 18, 2019

Closing this topic and marking as solved as the Table function declaration error was solved - please see my other post regarding PDF export.

Thank you.

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
solved

None