Oke,
This is in the Getdata.php file.
<?php
include(FCPATH . 'assets/kool-report/koolreport/core/autoload.php');
use \koolreport\pivot\processes\Pivot;
use \koolreport\pivot\processes\PivotExtract;
use \koolreport\processes\ColumnMeta;
use \koolreport\processes\Filter;
use \koolreport\pivot\PivotExcelExport;
use \koolreport\processes\RemoveColumn;
class Getdata extends koolreport\KoolReport {
private $data;
private $url;
public $kot;
use \koolreport\excel\ExcelExportable;
use \koolreport\export\Exportable;
use \koolreport\inputs\Bindable;
use \koolreport\inputs\POSTBinding;
function __construct($datas = array(), $kot = array()) {
$this->data = $datas;
$this->kot = $kot;
parent::__construct();
}
function settings()
{
return array(
"dataSources" => array(
"apiarray"=>array(
"class"=>'\koolreport\datasources\ArrayDataSource',
"dataFormat"=>"associate",
)
)
);
}
function setup()
{
$node = $this->src('apiarray')->load($this->data);
$node->pipe(new ColumnMeta(array(
'total'=>array(
'type' => 'number'
),
)))
->pipe(new Pivot(array(
'dimensions'=>array(
'column' => 'Kotama_Nama',
'row' => 'Pangkat_Tipe, Golongan_Nama, Pangkat_Nama'
),
'aggregates'=>array(
'sum' => 'DSP_O, Riil_O, Perc_O, DSP_N, Riil_N, Perc_N, DSP_Total, Riil_Total, Perc_Total'
)
)))
->pipe($this->dataStore('Rekap'));
}
}
?>
and this is in the getdata.view.php file.
<?php
use \koolreport\pivot\widgets\PivotTable;
use \koolreport\pivot\widgets\PivotMatrix;
use \koolreport\inputs\DateRangePicker;
use \koolreport\widgets\koolphp\Table;
$url = $_SESSION['BaseUrl'];
?>
<style>
.pivot-data-field-content,
.pivot-data-field-zone,
.pivot-row-header-text,
.pivot-column-header-text,
{
visibility: hidden;
}
.pivot-data-cell-row-total,
.pivot-row-header-grand-total, .pivot-data-cell-row-grand-total {
font-weight: bold;
color: #000;
background-color: #ccc;
}
</style>
<?php
$dataStore = $this->dataStore('Rekap');
PivotTable::create(array(
'dataStore'=>$dataStore,
'rowDimension'=>'row',
'showDataHeaders' => true,
'columnDimension'=>'column',
'measures'=>array(
($orgtipe == "O") ? 'DSP_O - sum' : 'DSP_N - sum',
($orgtipe == "O") ? 'Riil_O - sum' : 'Riil_N - sum',
($orgtipe == "O") ? 'Perc_O - sum' : 'Perc_N - sum',
),
'rowSort' => array(
'Golongan_Nama' => function($a, $b) use($gol) {
return $gol[$a] <= $gol[$b];
},
'Pangkat_Nama' => function($a, $b) use($pang) {
return $pang[$a] <= $pang[$b];
},
),
'rowCollapseLevels' => array(1),
'totalName' => 'TOTAL',
'width' => '100%',
'hideSubtotalColumn' => true,
'hideSubtotalRow' => true,
'map' => array(
'dataCell' => function ($dataField, $fieldInfo) {
if ($fieldInfo['fieldName'] == 'Riil_O - sum') {
$kotamaId = $this->kot;
$Kotama_Nama = $kotamaId[$fieldInfo['column']['Kotama_Nama']['value']];
if ($Pangkat_Nama != "{{all}}") {
if ($dataField > 0) {
$link = '<button type="button" class="btn btn-link-primary" onclick="pangkat_nama(`'.$Kotama_Nama.'`)">'.$dataField.'</button>';
} else {
$link = "0";
}
} else {
if ($dataField > 0) {
$link = "$dataField";
} else {
$link = "0";
}
}
} else {
if ($dataField > 0) {
$link = "$dataField";
} else {
$link = "0";
}
}
return $link;
},
'dataHeader' => function($dataField, $fieldInfo) {
$kotamaId = $this->kot;
$Kotama_Id = $kotamaId[$fieldInfo['column']['Kotama_Nama']['value']];
$v = $dataField;
if($this->orgtipe == "O") {
if ($v == 'DSP_O - sum'){
$v = 'DSP';
}elseif ($v == 'Riil_O - sum') {
$v = '<button type="button" class="btn btn-link-primary" onclick="satuan_kerja(`'.$Kotama_Id.'`)">Riil</buttton>';
}elseif ($v == 'Perc_O - sum') {
$v = '%';
}else{
$v = 'JUMLAH';
}
} else {
if ($v == 'DSP_N - sum'){
$v = 'DSP';
}elseif ($v == 'Riil_N - sum') {
$v = '<button type="button" class="btn btn-link-primary" onclick="satuan_kerja(`'.$Kotama_Id.'`)">Riil</buttton>';
}elseif ($v == 'Perc_N - sum') {
$v = '%';
}else{
$v = 'JUMLAH';
}
}
return $v;
},
),
));
?>
</div>
</div>
In the getdata.view.php file in the map->dataCell section I managed to get data from $fieldInfo['column']['Kotama_Nama']['value'], but why in the map->dataHeader section I not get data from $fieldInfo ['column']['Kotama_Nama']['value']. Do you have a solution? Thank you for your time.