KoolReport's Forum

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

Card into Dashboard #1958

Closed Andre Van Der Walt opened this topic on on Mar 10, 2021 - 4 comments

Andre Van Der Walt commented on Mar 10, 2021

Hi,

Please advice how to use Card indicator within Dashboard using KWidget. In function onCreated() how to get the value and baseValue from function dataSource()?

protected function onCreated()
    {
        $this
            ->use(\koolreport\widgets\koolphp\Card::class)
            ->settings([
                "title"=>"Month Sale",
                "value"=>11249,
                "baseValue"=>9230,
                "format"=>array(
                    "value"=>array(
                        "prefix"=>"$"
                    )
                )
            ]);
    }

Thanks for your help.

KoolReport commented on Mar 11, 2021

You may try

"value"=>AutoMaker::table("payments")->sum("amount")->run()->getScalar()

The most important is run() the query and then use getScalar() to get the value to input to value

Andre Van Der Walt commented on Mar 11, 2021

Thank you!

Andre Van Der Walt commented on Apr 20, 2021

Hi,

Can we use Card with procedure as below actually giving an error:

$this
            ->use(\koolreport\widgets\koolphp\Card::class)
            ->settings([
                "title"=>("TOTAL"),
                "value"=>DB::select("
                    CALL `get_results`
                        (1, '2021-01-05 00:00:00', '2021-01-05 23:59:59', 'abc', 'edf')
                ")->sum("Total")->run()->getScalar(),
            ]);

Thank you,

KoolReport commented on Apr 22, 2021

DB::select() belongs to Laravel and does not have those above function, please try to use our rawSQL():

AutoMaker::rawSQL("procedure")->run()->sum("Total")->getScalar();

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

Dashboard