Sales SuperCube

Supporing multiple rows, columns and aggregates

Multi row fields (productLine, productName) SuperCube

productLineproductName{{all}} - {{all}} | dollar_sales - sum
Classic Cars 1992 Ferrari 360 Spider red $276,840
Classic Cars 2001 Ferrari Enzo $190,756
Classic Cars 1952 Alpine Renault 1300 $190,018
Motorcycles 2003 Harley-Davidson Eagle Drag Bike $170,686
Classic Cars 1968 Ford Mustang $161,531

Multi column fields (Year, Quarter) SuperCube

{{label}}Year - {{all}} | dollar_sales - sumYear - 2003 | dollar_sales - sumYear - 2004 | dollar_sales - sumYear - 2005 | dollar_sales - sumQuarter - {{all}} | dollar_sales - sumQuarter - 1 | dollar_sales - sumQuarter - 2 | dollar_sales - sumQuarter - 3 | dollar_sales - sumQuarter - 4 | dollar_sales - sum
Total $9,583,418 $3,296,576 $4,515,906 $1,770,937 $9,583,418 $2,169,061 $2,081,322 $1,645,586 $3,687,449

Multi aggregated fields (dollar_sales sum, count, average and sum percent) SuperCube

customerName{{all}} - {{all}} | dollar_sales - sum{{all}} - {{all}} | dollar_sales - count{{all}} - {{all}} | dollar_sales - avg{{all}} - {{all}} | dollar_sales - sum percent
Euro+ Shopping Channel $820,690 259 $3,169 8.56%
Mini Gifts Distributors Ltd. $591,827 180 $3,288 6.18%
Australian Collectors, Co. $180,585 55 $3,283 1.88%
Muscle Machine Inc $177,914 48 $3,707 1.86%
La Rochelle Gifts $158,573 53 $2,992 1.65%

SuperCube process extends the power of Cube process. It allows users to create aggregated reports in one step that could take a lot of Cube's and other processes' steps to achieve.

<?php
require_once "MyReport.php";

$report = new MyReport;
$report->run()->render();
<?php
//Step 1: Load KoolReport
require_once "../../../../koolreport/autoload.php";
use \koolreport\processes\Limit;
use \koolreport\processes\Sort;
use \koolreport\processes\Map;
use \koolreport\cube\processes\Cube;
use \koolreport\cube\processes\SuperCube;
use \koolreport\core\Utility as Util;

//Step 2: Creating Report class
class MyReport extends \koolreport\KoolReport
{
    function settings()
    {
        return array(
            "dataSources" => array(
                "dollarsales"=>array(
                    'filePath' => '../../../databases/customer_product_dollarsales2.csv',
                    'fieldSeparator' => ';',
                    'class' => "\koolreport\datasources\CSVDataSource"      
                ), 
            )
        );
    }
    function setup()
    {
        $node = $this->src('dollarsales')
        ->pipe(new Map(array(
            '{value}' => function($row, $metaData) {
                $row['Year'] = $row['orderYear'];
                $row['Quarter'] = $row['orderQuarter'];
                return array($row);
            },
            '{meta}' => function($metaData) {
                $metaData['columns']['dollar_sales'] = array(
                    'type' => 'number',
                    "prefix" => "$",
                );
                $metaData['columns']['orderQuarter'] = array(
                    'type' => 'string',
                );
                return $metaData;
            },
        )));
        
        //multi row fields
        $node->pipe(new SuperCube(array(
            "rows" => "productLine, productName",
            "sum" => "dollar_sales",
        )))
        ->pipe(new Sort(array(
            '{{all}} - {{all}} | dollar_sales - sum' => 'desc',
        )))
        ->pipe(new Limit(array(
            5, 0
        )))
        ->pipe($this->dataStore('salesCategoryProduct'));

        //multi column fields
        $node->pipe(new SuperCube(array(
            "columns" => "Year, Quarter",
            "sum" => "dollar_sales",
        )))
        ->pipe(new Sort(array(
            'orderYear - {{all}} | dollar_sales - sum' => 'desc',
        )))
        ->pipe(new Limit(array(
            5, 0
        )))
        ->pipe($this->dataStore('salesYearQuarter'));

        //multi aggregated fields
        $node->pipe(new SuperCube(array(
            "rows" => "customerName",
            // "columns" => "Year",
            "sum" => "dollar_sales",
            "count" => "dollar_sales",
            "avg" => "dollar_sales",
            'sum percent' => 'dollar_sales',
        )))
        ->pipe(new Sort(array(
            '{{all}} - {{all}} | dollar_sales - sum' => 'desc',
        )))
        ->pipe(new Limit(array(
            5, 0
        )))
        ->pipe($this->dataStore('salesCustomerYear'));
    }
}
<?php
    use \koolreport\datagrid\DataTables;
    use \koolreport\morris_chart;
    use \koolreport\sparklines;
    use \koolreport\widgets\google;
    use \koolreport\widgets\koolphp\Table;
?>
<div class="report-content">

    <div class="text-center">
        <h1>Sales SuperCube</h1>
        <p class="lead">
            Supporing multiple rows, columns and aggregates
        </p>
    </div>

    <p class="lead text-center">Multi row fields (productLine, productName) SuperCube</p>
    <?php
        Table::create(array(
            "dataSource" => $this->dataStore('salesCategoryProduct'),
            "options" => array(
                "searching" => true,
                "paging" => true,
                "colReorder" => true,
                "order" => [],
                "pageLength" => 5,
                "lengthMenu" => [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]]
            ),
            "showFooter" => true,
        ));
    ?>

    <p class="lead text-center">Multi column fields (Year, Quarter) SuperCube</p>

    <?php
        Table::create(array(
            "dataSource" => $this->dataStore('salesYearQuarter'),
            "options" => array(
                "searching" => true,
                "paging" => true,
                "colReorder" => true,
                "order" => [],
                "pageLength" => 5,
                "lengthMenu" => [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]]
            ),
            "showFooter" => true,
        ));
    ?>

    <p class="lead text-center">Multi aggregated fields (dollar_sales sum, count, average and sum percent) SuperCube</p>
    
    <?php
        Table::create(array(
            "dataSource" => $this->dataStore('salesCustomerYear'),
            "options" => array(
                "searching" => true,
                "paging" => true,
                "colReorder" => true,
                "order" => [],
                "pageLength" => 5,
                "lengthMenu" => [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]]
            ),
            "showFooter" => true,
        ));
    ?>

</div>
customerNameproductNameproductLineorderDateorderDayorderMonthorderYearorderQuarterdollar_sales
Vitachrome Inc. 1937 Lincoln Berline Vintage Cars 2003-01-10 00:00:00 10 1 2003 1 3726.45
Vitachrome Inc. 1936 Mercedes-Benz 500K Special Roadster Vintage Cars 2003-01-10 00:00:00 10 1 2003 1 1768.3300000000002
Baane Mini Imports 1952 Alpine Renault 1300 Classic Cars 2003-01-29 00:00:00 29 1 2003 1 5571.8
Baane Mini Imports 1962 LanciaA Delta 16V Classic Cars 2003-01-29 00:00:00 29 1 2003 1 5026.14
Baane Mini Imports 1958 Setra Bus Trucks and Buses 2003-01-29 00:00:00 29 1 2003 1 3284.28
Baane Mini Imports 1940 Ford Pickup Truck Trucks and Buses 2003-01-29 00:00:00 29 1 2003 1 3307.5
Baane Mini Imports 1926 Ford Fire Engine Trucks and Buses 2003-01-29 00:00:00 29 1 2003 1 1283.48
Baane Mini Imports 1913 Ford Model T Speedster Vintage Cars 2003-01-29 00:00:00 29 1 2003 1 2489.13
Baane Mini Imports 1934 Ford V8 Coupe Vintage Cars 2003-01-29 00:00:00 29 1 2003 1 2164.4
Baane Mini Imports 18th Century Vintage Horse Carriage Vintage Cars 2003-01-29 00:00:00 29 1 2003 1 2173

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport