KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

How to retrive data by passing any one of selection in MultipleDataFilters #1225

Closed Sowmya opened this topic on on Dec 23, 2019 - 3 comments

S
Sowmya commented on Dec 23, 2019

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"));
      }

K
KoolReport commented on Dec 24, 2019

One question: Is it required to select multiple countries. It seems to me that you use single selection in the Select

S
Sowmya commented on Dec 26, 2019

Thank you for your reply. Yes Previously I given as single option only. Now I changed my code as same as your example.

But Now I want to display default option as "All",

In your example if all fields are empty then it displays all the data default.

But in my example I want to display data with "ALL" option, My default option should be "All".

How can I done this? Please help me....

Note: In my project I am using SQLServer and PHP Codeigniter3

S
Sowmya commented on Dec 27, 2019

Support is there? Or Not?

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Inputs