Hello, can you please help me ? I cannot pass datetime pikers parameters to my query ... widely inspired from your examples ... When I add in line 60 of actions_par_pays.php the parameters "startDatePicker", "endDatePicker" it bugs ... As shown in the listing, if I use fixed date parameters in the query, it works, so it is not the query that is wrong, but the part of public fonction setup() : params array ( ) I send you my linstings
index.php
<?php include "../../../helpers/run.example.php";?>
__actions_par_pays.php__
<?php
require_once "../../../load.koolreport.php";
use \koolreport\KoolReport;
use \koolreport\processes\CalculatedColumn;
use \koolreport\processes\ColumnMeta;
class ActionsParPays extends \koolreport\KoolReport
{
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
protected function defaultParamValues()
{
return array(
"sauf"=>"--",
"startDatePicker"=>date("2019-01-01 00:00:00"),
"endDatePicker"=>date("2025-12-31 23:59:59")
);
}
protected function bindParamsToInputs()
{
return array(
"sauf",
"startDatePicker",
"endDatePicker"
);
}
public function settings()
{
$config = include "../../../config.php";
return array(
"dataSources"=>array(
"phamm"=>$config["phamm"]
)
);
}
public function setup()
{
$this->src('phamm')
->query("
select `expeditions`.`pays` , `pays`.`country` , `expeditions`.`date_expedition` as date, count(`expeditions`.`pays`) as nombre
from `expeditions`
inner join `pays` on `expeditions`.`pays`= `pays`.`pays`
where
`expeditions`.`pays` <> :sauf
and
`expeditions`.`date_expedition` < '2021-01-01'
and
`expeditions`.`date_expedition` > '2019-12-31'
group by `expeditions`.`pays`
")
->params(array(
":sauf"=>$this->params["sauf"]
))
->pipe(new CalculatedColumn(array(
"tooltip"=>"'{expeditions.pays} : $'.number_format({nombre}).'{pays.country}'",
)))
->pipe(new ColumnMeta(array(
"tooltip"=>array(
"type"=>"string",
)
)))
->pipe($this->dataStore("expeditions"));
}
}
actions_par_pays.view.php
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\GeoChart;
use \koolreport\inputs\DateTimePicker;
use \koolreport\inputs\Select;
?>
<div class='report-content'>
<div class="text-center">
<h1>Actions Par Pays</h1>
<p class="lead">Le rapport montre le nombre d'expéditions dans chaque pays</p>
</div>
<form method="post">
<div class="col-md-12 form-group">
<html lang="fr">
<div class="row">
<div class="col-md-6">
From Date:
<?php
DateTimePicker::create(array(
"name"=>"startDatePicker",
"maxDate"=>"@endDatePicker",
"format"=>"MM/DD/YYYY HH:mm",
"themeBase"=>"bs4",
));
?>
</div>
<div class="col-md-6">
To Date:
<?php
DateTimePicker::create(array(
"name"=>"endDatePicker",
"minDate"=>"@startDatePicker",
"format"=>"MM/DD/YYYY HH:mm",
"themeBase"=>"bs4",
));
?>
</div>
<strong>Sauf</strong>
<?php
Select::create(array(
"name"=>"sauf",
"dataStore"=>$this->dataStore("expeditions"),
"defaultOption"=>array("--"=>""),
"dataBind"=>"pays",
"attributes"=>array(
"class"=>"form-control",
)
));
?>
</div>
</div>
<div class="col-md-3 " ;">
<button class="btn btn-lg btn-primary">O.K.</button>
</div>
</div>
<p class="form-group">
<i>* Below are values that archived from <code>$params</code>
</i>
</p>
<pre><code><?php echo json_encode($this->params,JSON_PRETTY_PRINT) ?></code></pre>
</form>
<?php
GeoChart::create(array(
"dataStore"=>$this->dataStore("expeditions"),
"columns"=>array(
"country"=>array(
"label"=>"Pays"
),
"nombre"=>array(
"label"=>"Actions",
"type"=>"number",
"prefix"=>""
)
),
"width"=>"100%",
"height"=>"350",
"options"=>array(
"colorAxis" => ["colors"=> ['orange', 'red']],
"backgroundColor"=> '#81d4fa',
"showTooltip"=> true,
"showInfoWindow"=> true
)
));
?>
<?php
Table::create(array(
"dataStore"=>$this->dataStore("expeditions")->sort(array("nombre"=>"desc")),
"columns"=>array(
"pays"=>array(
"label"=>"Pays"
),
"nombre"=>array(
"label"=>"Expeditions",
"type"=>"number",
"prefix"=>"",
)
),
"paging"=>array(
"pageSize"=>10,
),
"cssClass"=>array(
"table"=>"table table-bordered table-striped"
)
));
?>
</div>