I would like to filter the report by Select2. It won't filter but I can't see see error. It would be great it somebody could take a look at it.
If I type in a default paramater in the defaultParamValues() the page blank, so there must be an error somewhere.
MyReport.php
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
protected function defaultParamValues()
{
return array(
"submitdates"=>array(),
"seeds"=>array(),
"lastpages"=>array()
);
}
protected function bindparamsToInputs()
{
return array(
"submitdates",
"seeds",
"lastpages"
);
}
setup()
// Quiry Parameters for Group 3
$query_params = array();
if($this->params["submitdates"]!=array())
{
$query_params[":submitdates"] = $this->params["submitdates"];
}
if($this->params["seeds"]!=array())
{
$query_params[":seeds"] = $this->params["seeds"];
}
if($this->params["lastpages"]!=array())
{
$query_params[":lastpages"] = $this->params["lastpages"];
}
$survey_data_group_3 = $this->src('survey_data')
->query("SELECT submitdate, seed, lastpage from $survey_db_table_name
".(($this->params["submitdates"]!=array())?"and submitdate in (:submitdates)":"")."
".(($this->params["seeds"]!=array())?"and seed in (:seeds)":"")."
".(($this->params["lastpages"]!=array())?"and lastpage in (:lastpages)":"")."
")
;
$survey_data_group_3
->params($query_params)
->pipe($this->dataStore("data_group_3"));
MyReport.view.php
<form method="post">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<b>Select Years -> submitdates</b>
<?php
Select2::create(array(
"multiple"=>true,
"name"=>"submitdates",
"dataSource"=>$this->src("survey_data")->query("
SELECT submitdate from lime_survey_201005
group by submitdate
"),
"attributes"=>array(
"class"=>"form-control"
)
));
?>
</div>
<div class="form-group">
<b>Select Product Lines -> seed</b>
<?php
Select2::create(array(
"multiple"=>true,
"name"=>"seed",
"dataSource"=>$this->src("survey_data")->query("
SELECT seed from lime_survey_201005
".( $this->params["submitdates"]!=array() ?"where submitdate in (:submitdates)":"")."
group by seed
")->params(
$this->params["submitdates"]!=array()?
array(":submitdates"=>$this->params["submitdates"]):
array()
),
"attributes"=>array(
"class"=>"form-control"
)
));
?>
</div>
<div class="form-group">
<b>Select Customers -> lastpage</b>
<?php
Select2::create(array(
"multiple"=>true,
"name"=>"lastpage",
"dataSource"=>$this->src("survey_data")->query("
SELECT lastpage
from lime_survey_201005
".( $this->params["submitdates"]!=array()?"where submitdate in (:submitdates)":"")."
group by lastpage
")->params(
$this->params["submitdates"]!=array()?
array(":submitdates"=>$this->params["submitdates"]):
array()
),
"attributes"=>array(
"class"=>"form-control"
)
));
?>
</div>
<div class="form-group">
<button class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</form>