KoolReport's Forum

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

Assets path and url NULL in ResourceManager with CodeIgniter #2095

Closed Sebastien opened this topic on on May 19, 2021 - 3 comments

Sebastien commented on May 19, 2021

Hi,

I have a SalesByCustomer class in which I set the assets folder which is at same level as codeigniter application folder.

Also using a codeigniter controller to load the koolreport report.

It seems despite setting the assets path and url, the default route (libraries/koolreport/src/clients...) is maintained by the publishAssetFolder from the RessourceManager. As such I'm unable to render the charts.

Could someone help in understanding why this behavior is happening and what options to solve it?

Thanks

//SalesByCustomer class
<?php

require APPPATH."libraries/koolreport/core/autoload.php";

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

class SalesByCustomer extends \koolreport\KoolReport
{
  
  use \koolreport\codeigniter\Friendship;

  
    public function settings()
    {
          return array(
            "assets"=>array(
                "path"=>"../../assets",
                "url"=>"/assets"
            )
        );
    }

//Reports codeigniter class
<?php

defined('BASEPATH') OR exit('No direct script access allowed');
require APPPATH."reports/SalesByCustomer.php";

class Reports extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper('url');
    }

    public function index($page = 'reportHome') 
    {

        if ( ! file_exists(APPPATH.'views/reports/'.$page.'.php'))
        {
           // Whoops, we don't have a page for that!
            show_404();
        }
        $data['title'] = ucfirst($page); // Capitalize the first letter

        $report['report'] = new SalesByCustomer;
        //$this->load->view('templates/header', $data);
        $this->load->view('reports/'.$page, $report);
        //$this->load->view('templates/footer');    
       
    } 
}
//Reportview codeigniter
<?php 
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\widgets\google\BarChart;
?>
<style>
.customers {
  font-family: Arial, Helvetica, sans-serif;
  border-collapse: collapse;
  width: 100%;
}
</style>

<div class="text-center">
    <h1>Sales Report</h1>
    <h4>This report shows top 10 sales by customer</h4>
</div>
<hr/>
<?php
    BarChart::create(array(
        "dataStore"=>$report->dataStore('sales_by_customer'),
        "width"=>"100%",
        "height"=>"500px",
        "columns"=>array(
            "cod"=>array(
                "label"=>"Customer"
            ),
            "importe"=>array(
                "type"=>"number",
                "label"=>"Amount",
                "prefix"=>"€",
            )
        ),
        "options"=>array(
            "title"=>"Sales By Customer"
        )
    ));
?>
KoolReport commented on May 20, 2021

Do you run the report before render:

$report->run()->render();
Sebastien commented on May 20, 2021

Thanks so much! Adding the above to the codeigniter view and loading the charts in the koolreport view solved it.

KoolReport commented on May 20, 2021

That's great :)

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
help needed

CodeIgniter