KoolReport's Forum

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

HELP with DateRangePicker #920

Open paulo opened this topic on on Jun 11, 2019 - 4 comments

paulo commented on Jun 11, 2019

Hi, I am trying to follow the example https://www.koolreport.com/examples/reports/inputs/order_list/ but I am getting no results. If I remove the databapicker filter, I see the results. I've tried Get and POST. With and without the 'load' button. When I add the load button I and click on it I get "419 Page Expired"

HEre is my info:

 use \koolreport\inputs\POSTBinding;
    protected function defaultParamValues()
    {
        $start_date = date('Y-m-d', strtotime('first day of last month'));
        $end_date = date('Y-m-d', strtotime('last day of last month'));
        return array(
           // "dateRange"=>array(date("Y-m-d 00:00:00"),date("Y-m-d 23:59:59"))
            "dateRange"=>array(
                $start_date,
                $end_date
            ),
        );
    }

    protected function bindParamsToInputs()
    {
        return array(
            "dateRange"=>"dateRange"
        );
    }

 function setup()
    {
...
 WHERE ST.status = \"active\" and T.tour_status !=\"0\" AND T.startDate > :start  AND  T.endDate < :end
                    ORDER BY T.startDate")
               ->params(array(
                   ":start"=>$this->params["dateRange"][0],
                   ":end"=>$this->params["dateRange"][1]
              ))
            ->pipe($this->dataStore('oncalltours'));

Now, in the view:

   <form method="post">
        <div class="row">
            <div class="col-md-8 offset-md-2">

                <strong>Date Range Picker</strong>
                <?php
                DateRangePicker::create(array(
                    "name" => "dateRange",
                ));
                ?>

                <div class="form-group text-center">
                    <button class="btn btn-success"><i class="glyphicon glyphicon-refresh"></i> Load</button>
                </div>
            </div>

        </div>
    </form>
            <?php
            if ($this->dataStore("oncalltours")->countData() > 0) {
                Table::create(array(
                    "dataStore" => $this->dataStore("oncalltours"),
                    "options" => array(
                        //"searching"=>true,
                        "fixedHeader" => true,
                        "ordering" => true,
                    ),
                    "cssClass" => array(
                        "table" => "table table-bordered"
                    ),
                    "columns" => array(
                        "id" => array(
                            "type" => "text",
                            "label" => "id",
                            "formatValue" => "<a href='https://my.ellisontravel.com/tour/tours/@value'>@value</a>"
                        ),
                        "client" => array(
                            "type" => "text",
                            "label" => "Client(s)"
                        ),
                        "tourname" => array(
                            "type" => "text",
                            "label" => "Tours"
                        ),
                        "onCall",
                        "Visitor",
                        "Planner",
                        "Manager",
                        "startDate",
                        "endDate",
                        "country",
                        "psgr",
                        "status"

                    )
                ));
            } else {
                ?>
                <div class="alert alert-warning">
                    <i class="glyphicon glyphicon-info-sign"></i> Sorry, we found no orders found
                </div>
                <?php
            }
            ?>


        </div>

thank you very much for helping Paulo

KoolReport commented on Jun 12, 2019

Do you use in anykinds of framework?

paulo commented on Jun 13, 2019

yes, we are a Laravel shop. I've updated to the latest version of KoolReport. thanks

artemia3 commented on Jun 20, 2019

Solution in laravel, i have the same error think add csrf directive

    <form method="post">
   <?php echo csrf_field() ?>

good job eric

paulo commented on Jun 20, 2019

thank you very much artemia3. It seems to be working now at least locally. I appreciate. @Koolreport, this should be added to your documentation. thank you all

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