KoolReport's Forum

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

Location of koolreport files #925

Closed Matthew Bates opened this topic on on Jun 14, 2019 - 4 comments

Matthew Bates commented on Jun 14, 2019

I have been able to create a basic table for testing purposes, however it just shows the data without any of the graphical customization (borders around cells, shading, page number graphics). I believe this is because the script is not finding the required files. In particular, the view.php file has the following line: use \koolreport\widgets\koolphp\Table; - I am thinking that this is where the script is getting the customization info.

The php scripts I created live in one particular directory - /var/www and the koolreport files live in another directory - /var/lib/koolreport. Specifically, the Table.php is at the path - /var/lib/koolreport/core/src/widgets/koolphp. Should I be adjusting the use line so that it finds that file? If so, what should I enter? Also, in trying out the DataGrid format, the use line was use \koolreport\datagrid\DataTables. The only datagrid directories I could find were /var/lib/koolreport/core/tests/acceptance/koolreport/datagrid and /var/lib/koolreport/core/tests/unit/koolreport/datagrid and both of those directories have DataTablesTest and not DataTables. Am I missing some files in my structure?

Thanks.

KoolReport commented on Jun 15, 2019

In the report, please use the Bootstrap like following:

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\clients\Bootstrap;
    ...
}
Matthew Bates commented on Jun 17, 2019

Looks like I am still missing something. Here is my code:

ServerReport.php

<?php
require_once "ServerReportBuild.php";
$report = new ServerReport;
$report->run()->render();

ServerReportBuild.php

<?php
require_once "/var/lib/koolreport/core/autoload.php";
class ServerReport extends \koolreport\KoolReport
{
   use \koolreport\clients\Bootstrap;
   public function settings()
   {
     return array(
       "dataSources"=>array(
         "servers"=>array(
            "connectionString"=>"mysql:host=localhost;dbname=Decom",
            "username"=>"REDACTED",
            "password"=>"REDACTED",
            "charset"=>"utf8"
          )
       )
     );
   }
   public function setup()
   {
      $this->src('servers')
      ->query("SELECT * FROM Decom where equiptype=\"Server\"")
      ->pipe($this->dataStore('server_data'));
   }
}

ServerReport.view.php

<?php
   require_once "/var/lib/koolreport/core/autoload.php";
   use \koolreport\widgets\koolphp\Table;
?>
<div class="report-content">
   <div class="text-center">
   <h1>Disposed Servers</h1>
</div>
<?php
Table::create(array(
  "dataSource"=>$this->dataStore('server_data'),
   "columns"=>array(
    "date"=>array(
       "label"=>"Date"
    ),
    "time"=>array(
       "label"=>"Time"
    ),
    "brand"=>array(
        "label"=>"Manufacturer"
    ),
    "model"=>array(
       "label"=>"Model"
    ),
    "serialno"=>array(
       "label"=>"Serial Number"
    ),
    "drives"=>array(
    "label"=>"Drives"
    ),
    "comment"=>array(
       "label"=>"Comments"
    ),
    "certloc"=>array(
       "label"=>"Certificate of Disposal",
       "formatValue"=>function($value,$row){
        return "<a href=$value target=\"_blank\">Click to view</a>";
       }
    ),
   "tech"=>array(
       "label"=>"Disposed By"
    )
  ),
  "cssClass"=>array(
      "table"=>"table-bordered table-striped table-hover"
  ),
));
?>
</div>

The data is retrieved correctly, but displays like the below:

Matthew Bates commented on Jun 17, 2019

As additional information, looking at the console shows that the bootstrap files are not being loaded. The files are being looked for in a directory under koolreport_assests that doesn't seem to exist. There are other numbered directores in the koolreport_assests directory and none of them contain the bootstrap files being requested.

Matthew Bates commented on Jun 17, 2019

Got it working. I changed the owner of the koolreport_assets directory to www-data and now the requested directory exists.

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