KoolReport's Forum

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

Report with Dashboard #2430

Open Javier Gallardo opened this topic on on Nov 12, 2021 - 13 comments

Javier Gallardo commented on Nov 12, 2021

Example ReportBoard.view.php Report.php ReportBoard.php
I need a example with the tree files

Javier Gallardo commented on Nov 12, 2021

.

daniel commented on Nov 15, 2021

.

daniel commented on Nov 15, 2021

// Report.php <?php

require_once "../../../load.koolreport.php";

use \koolreport\KoolReport; use \koolreport\processes\Group; require_once "Json.php";

class Report extends KoolReport {

public function settings()
{
    return array(
        "dataSources"=>array(
            "data"=>array(
                "class"=>'\koolreport\datasources\ArrayDataSource',
                "data"=>$result,
                "dataFormat"=>"table",
            )
        )
    );
}   
protected function setup()
{
    $this->src('data')
    ->pipe($this->dataStore('data'));
} 

}

daniel commented on Nov 15, 2021

//ReportBoard.View.php <div class="report-content">

<div class="text-center">
    <h1>Reportes</h1>
    <p class="lead">

<?php \koolreport\inputs\Select::create(array(

"name"=>"data",
"dataStore"=>$this->dataStore("NomSSSbre"),
"dataBind"=>"Nombre",
"value"=>"Id",

)); ?>

    </p>
</div>

</div>

daniel commented on Nov 15, 2021

//ReportBoard.php

<?php namespace space\report;

use \koolreport\dashboard\CustomBoard;

use \koolreport\widgets\koolphp\Table;

class ReportBoard extends CustomBoard {

}

daniel commented on Nov 15, 2021

run.php

<?php require_once "Report.php"; $report = new Report; $report->run()->render();

daniel commented on Nov 15, 2021

//JSON API <?php

         $user = $this->board()->app()->user();
         $userInfo = ConnectDB::table("users")->where("id",$user->id())->run()->get(0);
         $tkos = $userInfo["token"];
    // TRAER TODOS LOS PROYECTOS
         $curl = curl_init();

        curl_setopt_array($curl, array(
          CURLOPT_URL => 'url',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'GET',
          CURLOPT_HTTPHEADER => array(
            'Authorization: '.$token
          ),
        ));

        $response = curl_exec($curl);
        curl_close($curl);
        $arr = json_decode($response, true);
        $result = [];
        foreach($arr['projects'] as $project) {
        array_push($result, [
        "Nombre"=>$project["name"],
        "Id"=>$project["id"],
            ]);
        }
daniel commented on Nov 15, 2021

I think I still can't get the data from the JSON API into the dataSource

daniel commented on Nov 15, 2021

shows nothing

Sebastian Morales commented on Nov 16, 2021

What is the value of your $result?

daniel commented on Nov 16, 2021

print_r($result)

Array ( [0] => Array ( [Name] => Project1 [Id] => 8 ) [1] => Array ( [Name] => Project2 [Id] => 12 ) [2] => Array ( [Name] => Project3 [Id] => 7 ) [3] => Array ( [Name] => Project4 [Id] => 13 ) [4] => Array ( [Name] => Project5 [Id] => 9 ) [5] => Array ( [Name] => Project6 [Id] => 11 ) [6] => Array ( [Name] => Project7 [Id] => 15 ) [7] => Array ( [Name] => Project8 [Id] => 1 ) [8] => Array ( [Name] => Project9 [Id] => 10 ) [9] => Array ( [Name] => Project10 [Id] => 14 ) )

daniel commented on Nov 16, 2021

when I put everything in .view it works but at the moment of wanting to use DataSource it does not work

Table::create(array(

            "dataSource"=>$result));

daniel commented on Nov 16, 2021

change the names for security, I hope you understand

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

None