KoolReport's Forum

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

Getting errors when started #230

Open michele opened this topic on on Mar 14, 2018 - 13 comments

michele commented on Mar 14, 2018

I'm using the basic example in order to test koolreport, but this is the result. What's wrong? Thanks for help!

KoolReport commented on Mar 14, 2018

It seems you have not had the view file yet. If your your report name is MyReport the default report view file is MyReport.view.php located in the same folder.

What shows in your view is the view of debug mode where KoolReport list all of dataStores available.

One question: Do you use any kind of PHP Framework. Laravel? CodeIgnitor?

michele commented on Mar 14, 2018

i'm using a proprietary framework. Controller code:

<?php

use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\Limit;


class SalesByCustomer extends \koolreport\KoolReport
{

    public function settings()
    {
        return array(
            "dataSources"=>array(
                "sales"=>array(
                    "connectionString"=>"mysql:host=XXXXXXX",
                    "username"=>"xxxxxx",
                    "password"=>"xxxxxxxxxx",
                    "charset"=>"utf8"
                )
            )
        );
    }

    public function setup()
    {
        $this->src('sales')
            ->query("SELECT * FROM income_orders")
            ->pipe(new Group(array(
                "by"=>"customer_id",
                "sum"=>"quantity_total_value"
            )))
            ->pipe(new Sort(array(
                "quantity_total_value"=>"desc"
            )))
            ->pipe(new Limit(array(10)))
            ->pipe($this->dataStore('aaaaaaa'));
    }
}

View code:

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


$salesByCustomer = new SalesByCustomer;


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

BarChart::create(array(
    "dataStore"=>$salesByCustomer->dataStore('aaaaaaa'),
    "width"=>"100%",
    "height"=>"500px",
    "columns"=>array(
        "customer_id"=>array(
            "label"=>"Customer"
        ),
        "quantity_total_value"=>array(
            "type"=>"number",
            "label"=>"Amount",
            "prefix"=>"$",
        )
    ),
    "options"=>array(
        "title"=>"Sales By Customer"
    )
));


Table::create(array(
    "dataStore"=>$salesByCustomer->dataStore('aaaaaaa'),
    "columns"=>array(
        "customer_id"=>array(
            "label"=>"Customer"
        ),
        "quantity_total_value"=>array(
            "type"=>"number",
            "label"=>"Amount",
            "prefix"=>"$",
        )
    ),
    "cssClass"=>array(
        "table"=>"table table-hover table-bordered"
    )
));

?>

KoolReport commented on Mar 14, 2018

The initiation is not in the view, but in an index.php file. Could you please follow exactly example here:

First Report Guide

michele commented on Mar 14, 2018

ok, but i need to do this using MVC structure. Is it possible?

KoolReport commented on Mar 14, 2018

Sure, definitely you can use in MVC structure. You can do as follow:

  1. Create a folder MyReport
  2. Insider MyReport folder, create MyReport.php and MyReport.view.php. Those two file are enough for a report.
  3. Now in your controller of your MVC you require the MyReport.php and create report object $report = new MyReport; them transmit that object to your view.
  4. In your view of your MVC, you can do $report->run()->render().

Note: You can create $report object at your view also if you want.

By the way, here in a post of how to use KoolReport in CodeIgniter. May be it can help since CodeIgniter is an MVC framework as well.

michele commented on Mar 15, 2018

Great, now it's working, but i think there are some css and js errors.

KoolReport commented on Mar 15, 2018

Do you have this page online that can be accessed. I want to see what caused errors. You may send your url to support@koolreport.com if you want to keep it private.

By the way, could you please upgrage the jQuery, it seems you are using older jQuery. In your report, you can add jQuery by:

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\clients\jQuery;
}

or if you use Bootstrap, you can do:

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\clients\Bootstrap;
}

Bootstrap has contained jQuery already.

michele commented on Mar 15, 2018

ok, thanks. mail sent.

KoolReport commented on Mar 16, 2018

Hi Michele,

Have seen that you have very nice apps. I have examined the page and it seems to me that there is no particular error related to KoolReport. Table and chartjs loading well. Just only one comment. If you have used jQuery inside your page already. You may not need to use in the report since it will add a duplication of jQuery. Also please choose the latest version of jQuery.

michele commented on Mar 16, 2018

i've integrated latest version of query, but there are that 2 errors. I'm happy you like my app.

KoolReport commented on Mar 16, 2018

Do you mean this error:

Uncaught TypeError: e.widget is not a function
    at ptjs.min.js:1
    at ptjs.min.js:1

and the warning of moment js.

For the first error I have not know the ptjs, it is not from KoolReport library. For the warning of moment js, I will check it but it does not cause any harm, just that it can not parse the date and has fall-back to using Date().

michele commented on Mar 16, 2018

thanks a lot

KoolReport commented on Mar 16, 2018

You are welcome!

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