KoolReport's Forum

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

MultFilter Error #702

Closed Daniel Amamoo-Otchere opened this topic on on Feb 22, 2019 - 2 comments

Daniel Amamoo-Otchere commented on Feb 22, 2019

Hello Kool Team, I tried your multi filter example with my code but getting the following error on top of the parameters.

These are the various code blocks

 $query_params = array();
        if($this->params["form_id"]!=array())
        {
            $query_params[":form_id"] = $this->params["form_id"];
        }
        if($this->params["user_id"]!=array())
        {
            $query_params[":user_id"] = $this->params["user_id"];
        }
         $query_params[":start"] = $this->params["startDatePicker"];
          $query_params[":end"] = $this->params["endDatePicker"];
  
       $this->src('pace')
         ->query("
                SELECT
                a,
                b,
                c,
                d
                WHERE 1=1
                ".(($this->params["form_id"]!=array())?" and a in (:form_id)":"")."
               ".(($this->params["user_id"]!=array())?" and b in (:user_id)":"")."
               AND c>=:start 
                AND c<=:end
                ORDER BY casc
                ")
            ->params( $query_params) 
            ->pipe($this->dataStore("result"));

Parameter 1

      <div class="col-md-6">
               <b>Module</b>
            <?php
              
                    Select2::create(array(
                        "multiple"=>true,
                        "name"=>"form_id",
                        "dataSource"=>$this->src("pace")->query("
                            SELECT 
                                b.sys_form_id,
                                form_label
                             FROM controller.sys_form b
                             INNER JOIN  task.tasklist a on a.sys_form_id=b.sys_form_id
                        "),
                          "dataBind"=>array(
                             "text"=>"form_label",
                             "value"=>"sys_form_id"								   
                            ),
                        "attributes"=>array(
                            "class"=>"form-control"
                        )
                    ));
            
                    ?>  
          </div>  

Parameter 2

  <div class="col-md-6">
             <b>Users</b>
                <?php 
                   Select2::create(array(
                        "multiple"=>true,
                        "name"=>"user_id",
                        "dataSource"=>$this->
                        src("pace")->query("
                            SELECT distinct
                            sys_users_id,  concat(b.firstname,' ',b.lastname)  as user
                            FROM task.tasklist a 
                            INNER JOIN controller.sys_users b on b.sys_users_id=a.assigned_user_id"
                            .(($this->params["form_id"]!=array())? "" : " 
                            WHERE a.sys_form_id in (:form_id)")."
                            ")
                       ->params($this->params["form_id"]!=array() ?
                                array(":form_id"=>$this->params["form_id"]): array()
                            ),
                            "dataBind"=>array(
                             "text"=>"user",
                             "value"=>"sys_users_id"								   
                            ),
                        "attributes"=>array(
                            "class"=>"form-control"
                            )
                    ));
                    
                ?>  
          </div>

Paramter 4 and 5

    <div class="col-md-6">
            <b>From Date:</b>
            <?php
            DateTimePicker::create(array(
                "name"=>"startDatePicker",
                "maxDate"=>"@endDatePicker",
                "format"=>"MM/DD/YYYY HH:mm",
                "themeBase"=>"bs3",
            ));
            ?>
        </div>
        <div class="col-md-6">
           <b>To Date:</b>
            <?php
            DateTimePicker::create(array(
                "name"=>"endDatePicker",
                "minDate"=>"@startDatePicker",
                "format"=>"MM/DD/YYYY HH:mm",
                "themeBase"=>"bs3",
            ));
            ?>
        </div>
KoolReport commented on Feb 23, 2019

In your Select2 for with name "user_id", you have a wrong condition. This is wrong:

(($this->params["form_id"]!=array())? "" : " WHERE a.sys_form_id in (:form_id)")

it should be:

(($this->params["form_id"]!=array())?" WHERE a.sys_form_id in (:form_id)" : "")
Daniel Amamoo-Otchere commented on Feb 23, 2019

Hello KoolReport, I fixed it but the 2nd Parameter does not refresh on selection of the 1st parameter. Can one achieve a cascade filter ?.

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
None yet

Inputs