KoolReport's Forum

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

Problem visualQuery symfony #1895

Open Epitello opened this topic on on Feb 4, 2021 - 6 comments

Epitello commented on Feb 4, 2021

Hello, i try to use a visual query in symfony project but i have this error : i have a full licens package, i have installed koolreport/pro and koolreport/inputs. Thanks by advance

Epitello commented on Feb 4, 2021

i send you the code .

//MyReport.php
<?php

namespace App\Reports;

use \koolreport\Koolreport;

class MyReport extends KoolReport
{
    use \koolreport\bootstrap4\Theme;
    use \koolreport\inputs\POSTBinding;
    use \koolreport\visualquery\Bindable;

    protected function settings()
    {
        //Define the "sales" data source which is the orders.csv 
        return array(
            "dataSources"=>array(
                "assurance"=>[
                    "connectionString"=>"mysql:host=localhost;dbname=db_sales",
                    "username"=>"root",
                    "password"=>"",
                    "charset"=>"utf8"
                ]        
            )
        );
    }
  
    protected function setup()
    {
        if (isset($this->queryParams['visualquery1'])) {
            $vqParams =  $this->queryParams['visualquery1'];
            $queryBuilder = $this->paramsToQueryBuilder($vqParams);
            $this->queryStr = $queryStr = $queryBuilder->toMySQL();
        } else {
            $this->queryStr = $queryStr = "SELECT * FROM koolreport_assurance LIMIT 100";
        }
        
        $this->src('assurance')
        ->query($queryStr)
        ->pipe($this->dataStore('assurance'));
    }
    
}

//MyReport.view.php

<?php
use koolreport\datagrid\DataTables;
use koolreport\visualquery\VisualQuery;
use koolreport\widgets\google\BarChart;
use koolreport\widgets\google\PieChart;
//dump($this->dataStore('personnes'));exit;
VisualQuery::create([
    "name" => 'visualquery1',
    "schema" => [
        "tables" => [
            "koolreport_assurance"=>[
                "{meta}" => [
                    "alias" => "Assurance"
                ],
                "departement"=>["alias"=>"Département"],
                "nature"=>["alias"=>"Nature"],
                "compagnie"=>["alias"=>"Compagnie"],
                "type"=>["alias"=>"Type"],
                "date"=>[
                    "alias"=>"Date",
                    "type"=>"datetime",
                    "format"=>"dd-M-YY"
                ],
                "montant"=>[
                    "alias"=>"Montant",
                    "type"=>"number",
                    "decimal"=>2,
                    "decimalPoint" => ".",
                    "thousandSeparator" => " "
                ]
            ],
        ],
        "relations" => [
        ]
    ],
    "defaultValue" => [
        "selectTables" => [
            "koolreport_assurance"
        ],
        "selectFields" => [
            "koolreport_assurance.departement",
            "koolreport_assurance.nature",
            "koolreport_assurance.compagnie",
            "koolreport_assurance.type",
            "koolreport_assurance.date",
            "koolreport_assurance.montant"
        ],
        "filters" => [
        ],
        "groups" => [
        ],
        "sorts" => [
        ],
        "offset" => 0,
        "limit" => 100,
    ],
]);

DataTables::create([
    "dataSource"=>$this->dataStore("assurance")
]);

?>
Epitello commented on Feb 9, 2021

Can someone answer me please

Epitello commented on Feb 10, 2021

The access path is not found,
there is the path in html file href="/koolreport_assets/804364024/../inputs/bower_components/bootstrap-multiselect-0.9/bootstrap-multiselect.css"

Epitello commented on Feb 10, 2021

i using symfony 4

Epitello commented on Feb 10, 2021

i solved my problem by i have created all the folder and file expected by the path. Do you have any solutions to do that properly and do yuo know if you have another missing folder ?

David Winterburn commented on Feb 12, 2021

Hi Epitello,

Sorry for the late reply. To avoid manual copying the resource files yourself, please try to set your report's "assets" setting like this:

class MyReport extends \koolreport\KoolReport
{
    protected function settings()
    {
        return array(
            ...
            "assets"=>array(
                "path"=>"../../public/koolreport_assets", //replace this path with the path to folder koolreport_assets in your Symphony public folder
                "url"=>"/public/koolreport_assets" //replace this url with the url tofolder koolreport_assets in your Symphony public folder 
            )
        );
    }
} 

This would ensure any widget's resource files to be copy to your Symphony public folder an be accessible by client browsers.

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

VisualQuery