KoolReport's Forum

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

PivotTable doesn't show some values #1697

Closed Samuel Alderete opened this topic on on Nov 4, 2020 - 1 comments

Samuel Alderete commented on Nov 4, 2020

I want to use PivotTable to organize information, but PivotTable doesn't display an specific field:

ITIL FOUNDATION and ITIL Service Operation belong to the same category, and it should display ITIL.

Here's my query:

It's very strange because if I use another field it works, field fabricante's type is VARCHAR 100 in my database.

Here's my code:


<?php

// Require autoload.php from koolreport library
require_once "koolreport/core/autoload.php";
use \koolreport\processes\Filter;
use \koolreport\pivot\processes\Pivot;

//Specify some data processes that will be used to process

//Define the class
class Certificaciones extends \koolreport\KoolReport
{
    use \koolreport\amazing\Theme;
    use \koolreport\inputs\Bindable;
    use \koolreport\inputs\POSTBinding;

    // Datos del servidor de desarrollo
    
    private $db_host = 'localhost';
    private $db_name = 'crm_db';
    private $db_user = 'root';
    private $db_password = '';
    private $db_charset = 'utf8';
    
    protected function settings()
    {
        
        return array(
            "dataSources"=>array(
                "mysql_datasource"=>array(
                    "connectionString"=>"mysql:host=".$this->db_host.";dbname=".$this->db_name,
                    "username"=>$this->db_user,
                    "password"=>$this->db_password,
                    "charset"=>$this->db_charset
                ),
            )
        );
    }
  
    protected function setup()
    {
        $this->src('mysql_datasource')
        ->query("SELECT CONCAT(users.first_name,' ', users.last_name) AS Empleado 
                    FROM
                        users 
                    WHERE
                        users.deleted = 0")
        ->pipe($this->dataStore('empleados'));

        //Procesamiento de datos
        $this->src('mysql_datasource')
        ->query("SELECT
                    CONCAT( users.first_name, ' ', users.last_name ) AS 'empleado',
                    rcco2_certificaciones.id AS id,
                    rcco2_certificaciones.document_name AS 'certificacion',
                    rcco2_certificaciones.status_id AS 'estado',
                    CAST(UPPER(rcco2_certificaciones.category_id) AS CHAR) AS 'fabricante'
                FROM
                    rcco2_certificaciones
                INNER JOIN users_rcco2_certificaciones_1_c ON users_rcco2_certificaciones_1_c.users_rcco2_certificaciones_1rcco2_certificaciones_idb = rcco2_certificaciones.id
                INNER JOIN users ON users.id = users_rcco2_certificaciones_1_c.users_rcco2_certificaciones_1users_ida
                WHERE users_rcco2_certificaciones_1_c.deleted = 0 AND rcco2_certificaciones.deleted = 0
        ")/*
        ->pipeIf(
            isset($_POST['Empleado']),
            function($node){
                //Filtra por empleado
                return $node->pipe(new Filter(array(
                    array("usuario","=",$_POST['Empleado'])
                )));
            },
            function($node)
            {
                // No aplica filtro
                return $node;
            }
        )*/
        ->pipe(
            new Pivot(
                array(
                    "dimensions" => array(
                        "row" => "empleado,fabricante,certificacion",
                        "column" => ""
                    )
                )
            )
        )
        ->pipe($this->dataStore('certificaciones'));
    }
}

?>

Thanks for your support.

Samuel Alderete commented on Nov 4, 2020

Forget this, sorry. I was wrong.

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

Pivot