I try this in my code but it show me Class 'App\Reports\FirstTimeFix\PivotSQL' not found
I use Laravel framwork
for referance i post code so you can refer
FirstTimeFixReport.php
$Query = "SELECT * FROM database_table"; // this return more then 40,000 records
$node = $this->src("mysql")->query($Query)
->pipe(new ColumnMeta(array(
"engineer_rating_c"=>array(
"type"=>"number",
"decimals"=>2,
)
)))
->pipe(new PivotSQL(array(
"dimensions"=>array(
"column" => "dateyear",
"row" => "users_zone_c",
),
"aggregates"=>array(
"sum" => "quantity_c",
"count" => "quantity_c",
),
)))
->pipe(new Pivot2D(array(
"dimensions"=>array(
"column" => "dateyear, product_name, cateName, brand, csctype, engname",
"row" => "users_zone_c,address_state,source,CSCName",
),
"aggregates"=>array(
"sum" => "quantity_c,ftmfixed,ClosejsPercent,FirsttimefixPercent",
"count" => "quantity_c",
),
"fieldDelimiter" => $delimiter
)))
->pipe(new Map(array(
'{value}' => function ($row) use ($delimiter) {
foreach ($row as $colName => $colValue) {
$colFields = substr($colName, 0, strrpos($colName, " || "));
$customClosejsColName = $colFields . " || ClosejsPercent - sum";
if($customClosejsColName!==' || ClosejsPercent - sum'){
$row[$customClosejsColName] = $row[$colFields . $delimiter . "quantity_c - sum"] != 0 ? $row[$colFields . $delimiter . "quantity_c - sum"]*100 / $row[$colFields . $delimiter . "quantity_c - sum"] : 0;
}
$customFirstTimeFixColName = $colFields . " || FirsttimefixPercent - sum";
if($customFirstTimeFixColName!==' || FirsttimefixPercent - sum'){
$row[$customFirstTimeFixColName] = $row[$colFields . $delimiter . "ftmfixed - sum"] != 0 ? $row[$colFields . $delimiter . "ftmfixed - sum"]*100 / $row[$colFields . $delimiter . "quantity_c - sum"] : 0;
}
}
return $row;
},
'{meta}' => function($meta) {
$meta['columns']['ClosejsPercent - sum'] = array(
'type' => 'number',
'decimals' => 2,
);
$meta['columns']['FirsttimefixPercent - sum'] = array(
'type' => 'number',
'decimals' => 2,
'suffix' => '%',
);
return $meta;
}
)))
->pipe($this->dataStore('FirstTimeFix'));
}
function getAllIndex($rowLabel)
{
$labelParts = explode(" || ", $rowLabel);
$allIndex = 0;
foreach ($labelParts as $part) {
if ($part === "{{all}}") break; // I made a mistake by using !== here in the previous code
$allIndex++;
}
return $allIndex;
}
function findNextTotalRow($rowLabel, $pivotData)
{
$rowAllIndex = $this->getAllIndex($rowLabel);
$labelParts = explode(" || ", $rowLabel);
foreach ($pivotData as $otherRow) {
$otherRowLabel = $otherRow["label"];
$otherRowAllIndex = $this->getAllIndex($otherRowLabel);
$otheLabelParts = explode(" || ", $otherRowLabel);
$isNextTotalRow = true;
if ($rowAllIndex === 0) {
if ($otherRowAllIndex !== 0) $isNextTotalRow = false;
} else if ($otherRowAllIndex !== $rowAllIndex - 1) {
$isNextTotalRow = false;
} else { // $otherRowAllIndex === $rowAllIndex - 1
for ($i = 0; $i < $rowAllIndex - 1; $i++) {
if ($labelParts[$i] !== $otheLabelParts[$i]) $isNextTotalRow = false;
}
}
if ($isNextTotalRow) return $otherRow;
}
}
This is View file
FirstTimeFixReport.view.php
PivotMatrix::create(array(
"id" => "pivotMatrix1",
'dataSource' => $this->dataStore('FirstTimeFix'),
'showDataHeaders' => true,
"scope" => array(
"reportType" => $this->params["reportType"],
"zone" => $this->params["zone"], // and so on....
),
"measures"=>array(
"quantity_c - sum",
"ftmfixed - sum",
"ClosejsPercent - sum",
"FirsttimefixPercent - sum",
),
'rowSort' => array(
'quantity_c - sum' => 'desc',
'cateName' => 'desc',
),
'columnSort' => array(
'datemonth' => function($a, $b) {
return (int)$a < (int)$b;
},
'quarter_col' => function($a, $b) {
return (int)$a < (int)$b;
},
),
'columnCollapseLevels' => array(0),
'rowCollapseLevels' => array(0),
'width' => '100%',
'height' => '500px',
'headerMap' => function($v, $f) {
switch ($v) {
case 'quantity_c - sum': return 'Closed JS';
case 'ftmfixed - sum' : return 'First Time Fixed';
case 'ClosejsPercent - sum' : return 'Close Js%'; // and so on....
}
$r = $v;
if ($f === 'dateyear')
$r = 'Year ' . $v;
$map = array(
'1' => 'January',
'2' => 'February',
// and so on....
);
$map_quart = array(
'1' => 'First',
'2' => 'Second',
// and so on....
);
if ($f === 'quarter_col')
$r = $map_quart[$v];
if ($f === 'datemonth')
$r = $map[$v];
return $r;
},
'totalName' => 'All',
'waitingFields' => array(
'datemonth' => 'label',
'quarter_col' => 'label',
),
'paging' => array(
'size' => 5,
'maxDisplayedPages' => 5,
'sizeSelect' => array(5, 10, 20, 50, 100)
)
));
this is for excel file
FirstTimeFixReportExcel.view.php
PivotTable::create(array(
"dataSource" => 'FirstTimeFix',
)
);
hope you can help us