KoolReport's Forum

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

Inputs get error! #2115

Open ccsmick opened this topic on on Jun 1, 2021 - 11 comments

ccsmick commented on Jun 1, 2021

error messages Notice: Undefined index: dateRange

code:

<?php


namespace App\Reports;

use koolreport\KoolReport;
use koolreport\processes\Group;
use koolreport\processes\TimeBucket;
use koolreport\inputs\Bindable;
use koolreport\inputs\POSTBinding;


class reportdev extends KoolReport
{

    protected function defaultParamValues()
    {
        return array(
            "dateRange"=>array(date("Y-m-01 00:00:00"),date("Y-m-t 23:59:59")),

        );
    }

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

        );
    }

    function settings()
    {
        $config = new conndata();
        return array(
            "dataSources"=>array(
                "ERPdata"=>$config->conndatabase()
            )
        );
    }

    protected function setup()
    {
        $this->src('ERPdata')
            ->query("SELECT OMA00,OMA02,OMA15,OMACONF,
                    (CASE WHEN OMA00 >= 20 THEN -abs(OMA56)ELSE OMA56 END) AS amount
                     FROM OMA_FILE 
                     WHERE  OMACONF='Y' AND orderDate > :start AND orderDate < :end ")
            ->params(array(
                ":start"=>$this->params["dateRange"][0],
                ":end"=>$this->params["dateRange"][1],
            ))
            ->pipe(new TimeBucket(array(
                "OMA02"=>"date"
            )))
            ->pipe(new Group(array(
                "by"=>"OMA02",
                "sum"=>"AMOUNT"
            )))
            ->pipe($this->dataStore('MonthAccountsReceivable'));
Sebastian Morales commented on Jun 1, 2021

Pls show your report view code which should have a DateRangePicker input named "dateRange". Tks,

ccsmick commented on Jun 1, 2021
<?php

use \koolreport\d3\ColumnChart;
use \koolreport\datagrid\DataTables;
use koolreport\inputs\DateRangePicker;
?>
    <form method="post">
<?php
DateRangePicker::create(array(
    "name"=>"dateRange",
));
?>
<button class="btn btn-success"><i class="glyphicon glyphicon-refresh"></i> Load</button>

<?php
ColumnChart::create(array(
    "dataSource" => $this->dataStore("MonthAccountsReceivable"),
    "columns" => array(
        "OMA02",
        "AMOUNT" => array(
            "label" => "Accounts Receivable",
            "type" => "number",
            "prefix" => "฿"
        ),
    )
));

DataTables::create(array(
    "dataSource" => $this->dataStore("MonthAccountsReceivable"),
    "showFooter" => true,
    "columns" => array(
        "OMA02" => array(
            "type" => "date",
            "label" => "Month",
            "footerText" => "<b>Total</b>"
        ),
        "OMA15" => array(
            "type" => "text",
            "label" => "Department",

        ),
        "AMOUNT" => array(
            "label" => "Accounts Receivable amount",
            "type" => "number",
            "prefix" => "฿",
            "footer" => "sum",
//            "footerText"=>"<b>@value</b>"
        ),

    ),

));
Sebastian Morales commented on Jun 1, 2021

Did you have the close form tag </form>? And pls post your code by clicking the editor's Add code block button.

ccsmick commented on Jun 1, 2021

yes, in the report view of code have </form>

<?php

use \koolreport\d3\ColumnChart; use \koolreport\datagrid\DataTables; use koolreport\inputs\DateRangePicker; ?>

<form method="post">

<?php DateRangePicker::create(array(

"name"=>"dateRange",

)); ?> <button class="btn btn-success"><i class="glyphicon glyphicon-refresh"></i> Load</button>

<?php ColumnChart::create(array(

"dataSource" => $this->dataStore("MonthAccountsReceivable"),
"columns" => array(
    "OMA02",
    "AMOUNT" => array(
        "label" => "Accounts Receivable",
        "type" => "number",
        "prefix" => "฿"
    ),
)

));

DataTables::create(array(

"dataSource" => $this->dataStore("MonthAccountsReceivable"),
"showFooter" => true,
"columns" => array(
    "OMA02" => array(
        "type" => "date",
        "label" => "Month",
        "footerText" => "<b>Total</b>"
    ),
    "OMA15" => array(
        "type" => "text",
        "label" => "Department",

    ),
    "AMOUNT" => array(
        "label" => "Accounts Receivable amount",
        "type" => "number",
        "prefix" => "฿",
        "footer" => "sum",

// "footerText"=>"<b>@value</b>"

    ),

),

)); ?> </form>

ccsmick commented on Jun 1, 2021

Sebastian Morales commented on Jun 1, 2021

Pls add the Bindable and POSTBinding traits to your report like this:

class reportdev extends KoolReport
{
    use koolreport\inputs\Bindable;
    use koolreport\inputs\POSTBinding;

You could copy and modify our Inputs examples to avoid such error. Rgds,

ccsmick commented on Jun 1, 2021

<?php

namespace App\Reports;

use koolreport\KoolReport; use koolreport\processes\Group; use koolreport\processes\TimeBucket; //use koolreport\inputs\Bindable; //use koolreport\inputs\POSTBinding;

class reportdev extends KoolReport {

use App\Reports\koolreport\inputs\Bindable;
use App\Reports\koolreport\inputs\POSTBinding;

protected function defaultParamValues()
{
    return array(
        "dateRange"=>array(date("Y-m-01"),date("Y-m-t")),

    );
}

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

    );
}

function settings()
{
    $config = new conndata();
    return array(
        "dataSources"=>array(
            "ERPdata"=>$config->conndatabase()
        )
    );
}

protected function setup()
{
    $this->src('ERPdata')
        ->query("SELECT OMA00,OMA02,OMA15,OMACONF,
                (CASE WHEN OMA00 >= 20 THEN -abs(OMA56)ELSE OMA56 END) AS amount
                 FROM OMA_FILE 
                 WHERE  OMACONF='Y' AND OMA02 > :start AND OMA02 < :end ")
        ->params(array(
            ":start"=>$this->params["dateRange"][0],
            ":end"=>$this->params["dateRange"][1],
        ))
        ->pipe(new TimeBucket(array(
            "OMA02"=>"date"
        )))
        ->pipe(new Group(array(
            "by"=>"OMA02",
            "sum"=>"AMOUNT"
        )))
        ->pipe($this->dataStore('MonthAccountsReceivable'));

get the error

Sebastian Morales commented on Jun 1, 2021

Use this pls:

class reportdev extends KoolReport
{
    use \koolreport\inputs\Bindable;
    use \koolreport\inputs\POSTBinding;
ccsmick commented on Jun 1, 2021

code: class reportdev extends KoolReport {

use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;

get error:

Sebastian Morales commented on Jun 1, 2021

Don't use ":start" and ":end" as sql param name. Some conflicts with Oracle syntax. Use ":startDate" and ":endDate" pls. Rgds,

ccsmick commented on Jun 1, 2021

The problem has been solved, thank you very much.

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
solved

None