KoolReport's Forum

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

\koolreport\instant\SinglePage koolreport_assets #2969

Closed Ahmed Bucheeri opened this topic on on Feb 1, 2023 - 2 comments

Ahmed Bucheeri commented on Feb 1, 2023

I have used the SinglePage instance in my app. I noticed that a new folder was created called koolreport_assets with many subfolders.

Here is the code

<!DOCTYPE HTML>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="../images/favicon.ico">
  </head>
</html>

<?php
global $CFG;
require_once "../assets/koolreport_pro_6.0.6/core/autoload.php";
use \koolreport\widgets\koolphp\Card;

class StoreReport extends \koolreport\KoolReport {
    use \koolreport\instant\SinglePage;

    public function settings()  {
      require_once "../admin/config.php";
      return $dataSources;
    }

    public function setup()  {
      $this->src('sqlserver')->query("SELECT COUNT (itemId) AS LowStock FROM m_Stores WHERE m_Stores.minQty > 0 AND m_Stores.qty < m_Stores.minQty AND m_Stores.qty <> 0")
          ->pipe($this->dataStore('LowStock'));

      $this->src('sqlserver')->query("SELECT count (itemId) AS NilStock FROM m_Stores WHERE m_Stores.minQty > 0 AND m_Stores.qty = 0")
          ->pipe($this->dataStore('NilStock'));

      $this->src('sqlserver')->query(
                            "SELECT count(m_Order.Id) AS PendOrder FROM m_Order  LEFT JOIN  m_OrderStatus ON m_Order.StatusId = m_OrderStatus.Id
                              WHERE m_OrderStatus.ClosedStatus = 0")
          ->pipe($this->dataStore('pendingOrder'));

      $this->src('sqlserver')->query(
                            "SELECT count(m_Order.Id) AS SnagPendOrder FROM m_Order LEFT JOIN  m_OrderStatus ON m_Order.StatusId = m_OrderStatus.Id
                              WHERE m_Order.SnagRef NOT LIKE '' AND m_OrderStatus.ClosedStatus = 0"
                            )
          ->pipe($this->dataStore('SnagPendOrder'));
    }

}
$report = new StoreReport;
$report->start();
?>
<html>
    <head>
        <title>Stores Summary</title>
        <script src="/admin/maintenance/script.js"></script>
    </head>
    <body>
      <div class="container">
        <h1 class="text-center m-4">Store Summary</h1>
        <form id="summaryform"  method="post">
          <input type="hidden" id="postvalue" name="postvalue">
          <div class="row d-flex justify-content-center m-1">
            <div class="col-md-3 btn">
              <?php
                Card::create(array(
                    "name" => "nilstock",
                    "value"=>$report->dataStore("NilStock"),
                    "title"=>"Nil Stock",
                    "format"=>array(
                        "value"=>array(
                            "suffix"=>" Item(s)"
                        )
                    ),
                    "cssClass"=>array(
                        "card"=>"bg-danger bg-gradient",
                        "title"=>"text-white",
                        "value"=>"text-white"
                    )
                ));
              ?>
            </div>
            <div class="col-md-3 btn">
              <?php
                Card::create(array(
                    "name" => "lowstock",
                    "value"=>$report->dataStore("LowStock"),
                    "title"=>"Low Stock",
                    "format"=>array(
                        "value"=>array(
                            "suffix"=>" Item(s)"
                        )
                    ),
                    "cssClass"=>array(
                        "card"=>"bg-info bg-gradient",
                        "title"=>"text-white",
                        "value"=>"text-white"
                    )
                ));
              ?>
            </div>
          </div>
          <div class="row d-flex justify-content-center m-1">
            <div class="col-md-3 btn">
              <?php
                Card::create(array(
                    "name" => "pendingorder",
                    "value"=>$report->dataStore("pendingOrder"),
                    "title"=>"Total Pending Orders",
                    "cssClass"=>array(
                        "card"=>"bg-info bg-gradient",
                        "title"=>"text-white",
                        "value"=>"text-white"
                    )
                ));
              ?>
            </div>
            <div class="col-md-3 btn">
              <?php
                Card::create(array(
                    "name" => "pendingordersname",
                    "value"=>$report->dataStore("SnagPendOrder"),
                    "title"=>"Snag Related Pending Orders",
                    "cssClass"=>array(
                        "card"=>"bg-warning bg-gradient",
                        "title"=>"text-dark",
                        "value"=>"text-dark"
                    )
                ));
              ?>
            </div>
          </div>
        </form>
      </div>
    </body>
</html>

<?php $report->end(); ?>

Could please advise me how to get rid of that folder

KoolReport commented on Feb 2, 2023

Very simple, in the admin config.php, you add the "assets" property to settings:

$dataSources = [
    "dataSources"=>[
        ...
    ],
    "assets"=>[
        "path"=>"/path/to/where/to/store/koolreport/assets",
        "url"=>"url/to/that/koolreport/assets"
    ]
];

By this way, the report created with SinglePage will store assets into your predefined folder and not create temp folder where the report is created.

Ahmed Bucheeri commented on Feb 3, 2023

Thanks Please close it

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
solved

None