Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
i send you the code
//index.php
<?php
session_start();
require_once "SalesByCountry.php";
if(!empty($_POST) && isset($_POST['visualQueryDataValue'])){
$_SESSION['visualQueryFilter'] = $_POST['visualQueryDataValue'];
var_dump($_SESSION['visualQueryFilter']);exit;
var_dump($_SESSION, $_POST);exit;
}
var_dump("addColumn",$_SESSION, $_POST);exit;
/* var_dump('tat');exit;*/
//var_dump($_SESSION);exit;
$salesByCountry = new SalesByCountry;
$salesByCountry->run()->render("AddColumn");
?>
//salesByCountry.php
<?php
use \koolreport\KoolReport;
use koolreport\processes\Sort;
use koolreport\processes\Group;
use koolreport\processes\Limit;
require_once "../../koolreport/core/autoload.php";
class SalesByCountry extends Koolreport{
use \koolreport\bootstrap4\Theme;
//use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
use \koolreport\visualquery\Bindable;
/* protected function defaultParamValues()
{
return array(
"matricule"=>array(),
);
}
protected function bindParamsToInputs()
{
return array(
"matricule"
);
} */
public function settings(){
return array(
"dataSources"=>[
/* "personnes"=>[
"connectionString"=>"mysql:host=eptltejprjqtr.mysql.db;dbname=eptltejprjqtr;[port=3306]",
"username"=>"eptltejprjqtr",
"password"=>"9MHzVghf",
"charset"=>"utf8"
] */
"personnes"=>[
"connectionString"=>"mysql:host=localhost;dbname=db_sales",
"username"=>"root",
"password"=>"",
"charset"=>"utf8"
]
]
);
}
public function setup(){
if (isset($this->queryParams['visualquery1'])) {
$vqParams = $this->queryParams['visualquery1'];
$queryBuilder = $this->paramsToQueryBuilder($vqParams);
//var_dump($queryBuilder, $this->queryParams['visualquery1']);exit;
$queryStr = $queryBuilder->toMySQL();
} else {
//var_dump('toto');exit;
$queryStr = "select * from gl_personne LIMIT 100";
}
$this->src('personnes')
->query($queryStr)
->pipe($this->dataStore('personnes'));
}
}
//AddColumn.view.php
<?php
use \koolreport\datagrid\DataTables;
use \koolreport\visualQuery\VisualQuery;
use \koolreport\inputs\Select2;
use koolreport\widgets\koolphp\Table;
use koolreport\widgets\google\PieChart;
?>
<div style="width:100%">
<div class="text-center">
<h1>Camenbert</h1>
</div>
<form method="post">
<input type="submit" name="button1"
value="Button1"/>
<input type="submit" name="button2"
value="Button2"/>
</form>
<form method="post" id="visualForm">
<?php
VisualQuery::create(array(
"name" => "visualquery1",
"schema" => [
"tables" => [
"gl_personne"=>array(
"{meta}" => [
"alias" => "Personnes"
],
"nom"=>array(
"alias"=>"nom",
),
"codeaffniv2"=>array(
"alias"=>"codeaffniv2",
),
"matricule"=>[
"alias"=>"matricule",
]
),
],
"relations" => [
]
]
))
?>
<button type='submit' class='btn btn-primary' value="btnSubmit">Submit</button>
<?php
// print_r($this->dataStore('vqDS')->meta());
DataTables::create(array(
"name" => "globalTable",
"dataSource" => $this->dataStore('personnes'),
// "columns" => ["Quantity", "Product Name"],
"options" => [
"paging" => true,
"select" => true
]
));
?>
</form>
<button id="btn" onclick='saveFilters()'>sauvegarder</button>
<div>
<label for="abscisse">Choisissez un abscisse</label>
<select name="abscisse" id="abscisse">
<!-- <option value="nom">nom</option> -->
<option value="codeaffniv2">codeaffniv2</option>
<option value="matricule">matricule</option>
</select>
<label for="ordonne">Choisissez un ordonne</label>
<select name="ordonne" id="ordonne">
<option value="matricule">matricule</option>
<option value="codeaffniv2">codeaffniv2</option>
</select>
<button id="btn" onclick='createChart()'>Générer un graph</button>
</div>
<div id="filters">
<label for="matriculeNb">Choisissez un matricule</label>
<input name="matriculeNb" type="number" id="matriculeNb">
<label for="operator">Choisissez un opérateur</label>
<select name="operator" id="operator">
<option value=">">Supérieur</option>
<option value="<">Inférieur</option>
<option value="==">Egale</option>
</select>
<button id="btn-filters" onclick="applyFilters()">Appliquer le filtre</button>
<button id="save-filter" onclick="saveFilters()">Sauvegarder le filtre</button>
<button id="save-filter" onclick="loadFilters()">Charger le filtre</button>
</div>
<button id="save-filter" onclick="saveFilters()">Sauvegarder le filtre</button>
<select name="chartType" id="chartType">
<option value="pie">Camembert</option>
<option value="bar">Colonne</option>
</select>
<button id="btn" onclick='createChart()'>Générer un graph</button>
<canvas id="barChart"></canvas>
<script src="../../js/jquery"></script>
<script src="../../koolreport/chartjs/clients/Chart.min.js"></script>
<script src="../../js/saveVisualQuery.js"> </script>
</div>
//saveVisualQuery.js
function saveFilters(){
let vqObject = $(visualquery1)
let vqObject_data = $(visualquery1_data)
let visualQueryDataValue = $(visualquery1_data.value)[0]
visualQueryDataValue = {"hugo" : {"filtre1" : visualQueryDataValue}}
console.log(visualQueryDataValue)
$.ajax({
method: "POST",
url: "http://localhost/koolreport/reports/addColumn/",
data: {visualQueryDataValue},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("some error");
}
})
}
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo