Dear KoolReport Team,
I have a requirement from my client. By using Multiple Data Filters, I generate a Grid.
In that Multiple Data Filters, if I pass any control data, the grid has to be show data based on that particular filter only. Remaining filters has to be Empty only.
For Ex I have 4 filters like SalesManager, City, State, Country, DateRange.
If I select DateRange as "LastMonth", it has to be display all the records within that DateRange only and ignore remaing all filters.
If I select City and SalesManager I want to display data that depend on these 2 filters only.
How can I achieve this?
public function setup()
{
$query_params = array();
if($this->params["salesManger"]!=array())
{
$query_params[":salesManger"] = $this->params["salesManger"];
}
if($this->params["country"]!=array())
{
$query_params[":country"] = $this->params["country"];
}
if($this->params["state"]!=array())
{
$query_params[":state"] = $this->params["state"];
}
if($this->params["city"]!=array())
{
$query_params[":city"] = $this->params["city"];
}
if($this->params["dateRange"]!=array())
{
$query_params[":start_date"] = $this->params["dateRange"][0];
$query_params[":end_date"] = $this->params["dateRange"][1];
}
$this->src('enquiry')
->query("SELECT EnqRefNo,CustomerName,city,state,country,Email,ContactNumber,salesManger,EnquiryDate from EnquiryDataView
WHERE 1=1
".(($this->params["salesManger"]!=array())?"and salesManger in (:salesManger)":"")."
".(($this->params["country"]!=array())?"and country in (:country)":"")."
".(($this->params["state"]!=array())?"and state in (:state)":"")."
".(($this->params["city"]!=array())?"and city in (:city)":"")."
".(($this->params["dateRange"]!=array())?"and EnquiryDate BETWEEN :start_date AND :end_date":"")."
GROUP BY
salesManger,country,state,city,EnquiryDate,EnqRefNo,CustomerName,ContactNumber,Email
")
->params($query_params)
->pipe($this->dataStore("enquiryGrid"));
}