Hi,
I want to filter a Table by Date so I use the input package. However something must be wrong because it doesn’t work… Here is my code :
Main file
class Commercial extends \koolreport\KoolReport
{
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
function defaultParamValues()
{
return array(
"thedate"=>0,
);
}
function bindParamsToInputs()
{
return array(
"Date",
);
}
function settings()
{
return array(
"dataSources"=>array(
"sales"=>array(
"class"=>'\koolreport\excel\ExcelDataSource',
"filePath"=>"./databases/commandes.xlsx",
"charset"=>"utf8",
"firstRowData"=>false,
"sheetName"=>"TDV_18",
"sheetIndex"=>0,
),
)
);
}
function setup()
{
$this->src('sales')
->pipe(new Group(array(
"by"=>"Date",
)))
->pipe($this->dataStore('date'));
$this->src('sales')
->pipe(new Filter(array(
array("Ccial","=",$_SESSION['Username']),
array("Ccial","!=",null),
array("Société","!=",null),
)))
->pipe(new Filter(array(
"or",
array("Date","=","JANVIER"),
array("Date","=","FÉVRIER"),
array("Date","=","MARS"),
)))
->pipe($this->dataStore('commandes'));
}
}
And here is my view file code
$customerName = "";
while($row = $this->dataStore("customers")->pop())
{
if($row["thedate"]==$this->params["thedate"])
{
$customerName =$row["Date"];
}
}
?>
<div class="text-center">
<h1>Sales Report</h1>
<h4>This report shows top 10 sales by customer</h4>
<form method="post">
<div class="text-center">
<h1>List order of a customer</h1>
<div class="row form-group">
<div class="col-md-6 col-md-offset-3">
<?php
Select::create(array(
"name"=>"thedate",
"data"=>array(
"JANVIER"=>"1",
"FEVRIER"=>"2",
"MARS"=>"3",
),
"attributes"=>array(
"class"=>"form-control"
)
));
?>
</div>
</div>
<div class="form-group">
<button class="btn btn-primary">Ok</button>
</div>
</div>
</form>
</div>
<hr/>
<?php
Table::create(array(
"dataStore"=>$this->dataStore('commandes'),
"columns"=>array(
"Date"=>array(
"label"=>"Date"
),
"Ccial"=>array(
"label"=>"Customer"
),
"Société"=>array(
"type"=>"string",
"label"=>"Amount",
)
),
"cssClass"=>array(
"table"=>"table table-hover table-bordered"
)
));
Thanks a lot !