KoolReport's Forum

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

KoolReport in CodeIgniter Error: "Unable to locate the specified class: Session.php" #1372

Closed Prescious opened this topic on on Apr 2, 2020 - 3 comments

Prescious commented on Apr 2, 2020

Hello Everyone!

I have started following this link: How to use KoolReport in Codeigniter?. However, when I tried adding a parameter, this error occurs: "Unable to locate the specified class: Session.php"

Here is what I have successfully done:

  1. My Installation included the following versions of files: koolreport_4.5.1 codeigniter_1.8.0
  2. I have created the koolreport_assets folder in the assets folder
  3. I have placed my report and its view in the reports folder located inside the application folder.
  4. This is the code of my controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

require APPPATH."/reports/SecuritySummary.php";

class Welcome extends CI_Controller {

	public function index()
	{
		$report = new SecuritySummary(array("whereCond"=>access::ses('whereCond')));
		$report->run()->render();
	}
}
  1. This is the code of the report:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
require APPPATH."libraries\koolreport\core\autoload.php"; 

use \koolreport\KoolReport;
use \koolreport\processes\Filter;
use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
use \koolreport\processes\Limit;

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

    use \koolreport\clients\Bootstrap;

     public function settings()
      {
            $config = include(PATM_LIBRARIESDIR."koolreport/config.php");

            return array(
            "assets"=>array(
                "path"=>"../../assets/koolreport_assets",
                "url"=>"assets/koolreport_assets",
            ),
            "dataSources"=>array(
                "systems_db"=>$config["systemsdb"]
            )
        );
     } 

    protected function setup(){
        $this->src('systems_db')
        ->query("
            SELECT
                ts.sec_UserNameId AS UserId,
                tul.u_Uname,
                CONCAT_WS(' ',  tul.u_Uname, '~', tul.u_LastName,   tul.u_FirstName,
                    IF (tul.u_SuffixName = 'NONE' OR tul.u_SuffixName LIKE '%n/a%' OR tul.u_SuffixName LIKE '%n\\a%', '', tul.u_SuffixName),
                    IF (tul.u_MiddleName = 'NONE' OR tul.u_MiddleName LIKE '%n/a%' OR tul.u_SuffixName LIKE '%n\\a%', '', tul.u_MiddleName) 
                ) AS `User`,
                Count(tul.u_Uname) AS Ilan,
                ts.sec_In,
                ts.sec_Out
            FROM
              tblsec AS ts
            INNER JOIN
              tbluserlist AS tul ON tul.u_Id = ts.sec_UserNameId
            WHERE
              @whereCond
            GROUP BY
              ts.sec_UserNameId
            ORDER BY
            tul.u_LastName ASC
                      ")
        ->params(array(
            "@whereCond"=>$this->params["whereCond"]
        ))
        ->pipe($this->dataStore('column_chart'));
    } 
}?>
  1. This is the code of the view of the report:
<?php 
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\widgets\google\ColumnChart;
?>
    <?php

        ColumnChart::create(array(
            "dataStore"=>$this->dataStore('column_chart'),  
            "columns"=>array(
                "User"=>array(
                    "type"=>"string",
                ),           
                "Ilan"=>array(
                    "label"=>"Frequency",
                    "type"=>"number",
                )
            ),
            "width"=>"100%",
        ));

        echo '<br>';

        Table::create(array(
            "dataStore"=>$this->dataStore('column_chart'),
            "columns"=>array(
                "User"=>array(
                    "type"=>"string",
                ),           
                "Ilan"=>array(
                    "label"=>"Frequency",
                    "type"=>"number",
                )
            ),
            "cssClass"=>array(
                "table"=>"table table-hover table-bordered"
            )
        ));
    ?>

Thank you in advance for your help and assistance!

KoolReport commented on Apr 3, 2020

This issue is not related to koolreport. This issue is that you are using session in codeigniter but the session library is not registered I guess. I found the solution here, hope that help

Stackoverflow: Unable to locate the specified class: Session.php

Prescious commented on Apr 3, 2020

Hello! Thank you for your help. I have checked the link you gave. My model follows what's in the link and the result is the same. I tried another approach wherein I didn't use any session variable in my array:

class Welcome extends CI_Controller {

public function index()
{
	$report = new SecuritySummary(array("whereCond"=>"MONTH(ts.sec_In) = MONTH('2020/04/01') AND YEAR(ts.sec_In) = YEAR('2020/04/01')"));
	$report->run()->render();
}

}

but the result is the same error. Are there any other alternatives we can do for this? Thank you for your support. :)

Prescious commented on Apr 5, 2020

Hello KoolReport!

I found out that the cause of the error was the inclusion of the configuration file in the setup. I changed this: $config = include(PATM_LIBRARIESDIR."koolreport/config.php"); to: $config = include(APPPATH."libraries/koolreport/config.php"); and the error was gone. It's kinda weird because both of the path provided was the same but the first one triggers the error.

Again thank you for the support. :)

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

None