KoolReport's Forum

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

Fatal error: in SalesByProduct.view.php #795

Open henry opened this topic on on Apr 11, 2019 - 25 comments

henry commented on Apr 11, 2019

Fatal error: Class 'koolreport\widgets\google\BarChart' not found could anyone help to solve this error?

KoolReport commented on Apr 11, 2019

In the view you need to use:

use \koolreport\widgets\google\BarChart;

Please have a look at our example.

henry commented on Apr 11, 2019

hi I have ady use this two line at the top of the code

use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\BarChart;

But why still get this problem?

KoolReport commented on Apr 11, 2019

Did you require_once the autoload file somewhere? Like in the index.php or in the controller class.

henry commented on Apr 11, 2019

yes, i do this coding follow the SalesByCustomer.php as example. i put require_once autoload file in SalesByProduct.php

KoolReport commented on Apr 11, 2019

I thought you have successfully render the chart as I see in your another topics about table css.

KoolReport commented on Apr 11, 2019

Please check if you are working in correct view, it seems to me you have SalesByProduct and SalesByCustomer report.

henry commented on Apr 11, 2019

yes , but now the problem is i want it to export as PDF using cloudexport package, but i only can view the chart in index file. so when i export will have problem....could you guide me on that?

henry commented on Apr 11, 2019

yes and sorry i didn infrom that i ady change the name, and now i can view the report in index.php........but how do i do to export to PDF using cloudexport package

KoolReport commented on Apr 11, 2019

To export, you need to include

use \koolreport\cloudexport\Exportable;

in your SalesByProduct.php

And then in the index.php, instead of render by

$report->run()->render();

you do:

$report->run()->cloudExport()
->chromeHeadlessio("key")
->pdf()
->toBrowser("sales_by_product.pdf");
henry commented on Apr 11, 2019

Call to undefined method SalesByProduct::export()...... its show this error

KoolReport commented on Apr 11, 2019

It is cloudExport()

henry commented on Apr 11, 2019

im sorry for my mistake, now ady change it and another error happen

Warning: file_get_contents(http://localhost/jinxiPhp/final project/koolreport/src/clients/core/KoolReport.js): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\xampp\htdocs\jinxiPhp\final project\koolreport\packages\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 163

Warning: file_get_contents(http://localhost/jinxiPhp/final project/koolreport/src/clients/bootstrap/css/bootstrap-theme.min.css): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\xampp\htdocs\jinxiPhp\final project\koolreport\packages\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 163

Warning: file_get_contents(http://localhost/jinxiPhp/final project/koolreport/src/clients/bootstrap/css/bootstrap.min.css): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\xampp\htdocs\jinxiPhp\final project\koolreport\packages\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 163

Warning: file_get_contents(http://localhost/jinxiPhp/final%20project/index.php/css): failed to open stream: HTTP request failed! in C:\xampp\htdocs\jinxiPhp\final project\koolreport\packages\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 163

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\jinxiPhp\final project\koolreport\packages\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 163

KoolReport commented on Apr 11, 2019

If you paste this link to browser, does it show content:

http://localhost/jinxiPhp/final project/koolreport/src/clients/core/KoolReport.js
henry commented on Apr 11, 2019

yes its show some coding

henry commented on Apr 11, 2019

do i need to copy it to you?

KoolReport commented on Apr 11, 2019

May I know what webserver do you use? It seems that there is security that prevent PHP itself to call the webserver? the function file-get_contents() work like you put the file to browser but seems failed here.

henry commented on Apr 11, 2019

i use MYSQL in xampp

henry commented on Apr 11, 2019

but how come it work when i try the example in cloudexport for the file MyReport.php

KoolReport commented on Apr 11, 2019

I see, please try to remove the " " space in the "final product". The space there could cause this problem

henry commented on Apr 11, 2019

do you mean my file name "final project" to become "finalproject" ?

KoolReport commented on Apr 11, 2019

yes

henry commented on Apr 11, 2019

hi i try to remove the space, but now get the same error, but seem like shorter a bit

Warning: file_get_contents(http://localhost/jinxiPhp/finalproject/index3.php/css): failed to open stream: HTTP request failed! in C:\xampp\htdocs\jinxiPhp\finalproject\koolreport\packages\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 163

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\jinxiPhp\finalproject\koolreport\packages\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 163

henry commented on Apr 11, 2019

hi sorry, could you do a checking for me? this is my index3.php

<?php
require_once "SalesByProduct.php";

$salesByProduct = new SalesByProduct;
$salesByProduct->run()
->cloudExport("SalesByProduct")
->chromeHeadlessio("my key")
->pdf()
->toBrowser("sales_by_product.pdf");
?>

SalesByProduct.php

<?php
require_once "koolreport/autoload.php";
use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\Limit;
class SalesByProduct extends \koolreport\KoolReport
{
    use \koolreport\cloudexport\Exportable;
    use \koolreport\clients\Bootstrap;

    public function settings()
    {
        return array(
            "dataSources"=>array(
                "sales"=>array(
                    "connectionString"=>"mysql:host=localhost;dbname=finalproject",
                    "username"=>"root",
                    "password"=>"",
                    "charset"=>"utf8"
                )
            )
        );
    }

    public function setup()
    {
        $this->src('sales')
        ->query("SELECT product_name,total_sales FROM dbproduct")
        ->pipe(new Group(array(
            "by"=>"product_name",
            "sum"=>"total_sales"
        )))
        ->pipe(new Sort(array(
            "total_sales"=>"desc"
        )))
        ->pipe(new Limit(array(10)))
        ->pipe($this->dataStore('Top_Selling_Product'));
    }
}


this is SalesByProduct.view.php

<?php 
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\widgets\google\BarChart;
?>

<div class="text-center">
    <h1>Sales Report</h1>
    <h4>This report shows top 10 sales product</h4>
</div>
<hr/>

<?php
    BarChart::create(array(
        "dataStore"=>$this->dataStore('Top_Selling_Product'),
        "width"=>"100%",
        "height"=>"500px",
        "columns"=>array(
            "product_name"=>array(
                "label"=>"Product Name"
            ),
            "total_sales"=>array(
                "type"=>"number",
                "label"=>"Sales Amount",
                "prefix"=>"$",
            )
        ),
        "options"=>array(
            "title"=>"Top 10 Selling Product"
        )
    ));
?>
<?php
Table::create(array(
    "dataStore"=>$this->dataStore('Top_Selling_Product'),
        "columns"=>array(
            "product_name"=>array(
                "label"=>"Product Name"
            ),
            "total_sales"=>array(
                "type"=>"number",
                "label"=>"Sales Amount",
                "prefix"=>"$",
            )
        ),
    "cssClass"=>array(
        "table"=>"table table-hover table-bordered"
    )
));
?>

Big thanks for your time!

David Winterburn commented on Apr 12, 2019

Hi Henry,

Again, please try to paste the link http://localhost/jinxiPhp/finalproject/index3.php/css to your browser and let us know the result. Thanks!

henry commented on Apr 12, 2019

hi the result is as below

Warning: file_get_contents(http://localhost/jinxiPhp/finalproject/index3.php/css/css): failed to open stream: HTTP request failed! in C:\xampp\htdocs\jinxiPhp\finalproject\koolreport\packages\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 163

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\jinxiPhp\finalproject\koolreport\packages\cloudexport\vendor\chromeheadlessio\php-client\src\Exporter.php on line 163

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

CloudExport