Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Really sorry for the late reply, could you please provide us more information such as:
Browser does not show any error when clicked.
This is the code I use
DrillDown::create([
"name" => "Time",
"title" => "Time",
"levels" => [
[
"title" => __('By month'),
"widget" => [
ColumnChart::class, [
"dataSource" => function($params, $scope) use ($DB, $query) {
$query['SELECT'][] = new QueryExpression("FROM_UNIXTIME(UNIX_TIMESTAMP(" . $DB->quoteName(PluginActualtimeTask::getTable() . ".actual_begin") . "),'%Y-%m') AS period");
$iterator = new DBmysqlIterator($DB);
$iterator->buildQuery($query);
$sql = $iterator->getSql();
$this->src('glpi')->query($sql)
->pipe(new \koolreport\cube\processes\Cube([
'row' => 'period',
'column' => 'users_id',
'sum' => 'total'
]))
->pipe(new \koolreport\processes\Map([
"{value}" => function($row) {
$aux = $row;
unset($aux['period']);
foreach ($aux as $key => $value) {
$row[$key] = round($value / HOUR_TIMESTAMP, 2);
}
return $row;
},
"{meta}" => function($meta) {
$aux = $meta['columns'];
unset($aux['period']);
unset($aux['{{all}}']);
foreach ($aux as $key => $value) {
$meta['columns'][$key] = [
'label' => getUserName($key)
];
}
$meta['columns']['{{all}}'] = [
'label' => __('Total')
];
return $meta;
}
]))
->pipe($this->dataStore('actualTime'));
return $this->dataStore('actualTime');
}
]
]
],
[
"title" => __('Each week'),
"widget" => [
ColumnChart::class, [
"dataSource" => function($params, $scope) use ($DB, $query) {
$query['SELECT'][] = new QueryExpression("WEEK(" . $DB->quoteName(PluginActualtimeTask::getTable() . ".actual_begin") . ") AS period");
$query['WHERE'][] = [
PluginActualtimeTask::getTable() . ".actual_begin" => ['>=', date("Y-m-01 00:00:00", $params['period'])],
'AND' => [
PluginActualtimeTask::getTable() . ".actual_begin" => ['<=', date("Y-m-t 23:59:59", $params['period'])]
]
];
$iterator = new DBmysqlIterator($DB);
$iterator->buildQuery($query);
$sql = $iterator->getSql();
$this->src('glpi')->query($sql)->pipe(new \koolreport\cube\processes\Cube([
'row' => 'period',
'column' => 'users_id',
'sum' => 'total'
]))
->pipe(new \koolreport\processes\Map([
"{value}" => function($row) {
$aux = $row;
unset($aux['period']);
foreach ($aux as $key => $value) {
$row[$key] = round($value / HOUR_TIMESTAMP, 2);
}
return $row;
},
"{meta}" => function($meta) {
$aux = $meta['columns'];
unset($aux['period']);
unset($aux['{{all}}']);
foreach ($aux as $key => $value) {
$meta['columns'][$key] = [
'label' => getUserName($key)
];
}
$meta['columns']['{{all}}'] = [
'label' => __('Total')
];
return $meta;
}
]))
->pipe($this->dataStore('actualTime'));
return $this->dataStore('actualTime');
}
]
]
],
],
'css' => [
'panel' => 'background-color: #fff; border: 1px solid #ddd; border-radius: 5px; padding: 10px;',
]);
Really sorry for the late reply, despite of looking at the code, I have not been able to spot what may go wrong. There are something that you may try to further debug.
var_dump($params)
to make sure parameter is correct sent from first level. Since this will be ajax request, so you can see the var_dump text from the inspector tool in browser.Please let me know.
Hi. The graph I am trying to generate is the total user hours per month. As the number of users is not fixed I use the Map package.
Anyway for testing purposes I tried to manually indicate the users.
"columns" => [
"period" => [
"type" => "string"
],
"{{all}}" => [
"type" => "number"
],
"2" => [
"type" => "number"
],
"7" => [
"type" => "number"
],
],
I also add var_dump() but it still does not show me anything.
I have the feeling that the drilldown is not adding the 'onclick' in the columns that is why it is not showing me any error.
Is it possible that I need to load some other package besides DrillDown?
That's mystery. So it does not show any single error, even javascript at client-side? Is it possible that you replicate this issue and make it online, send the link over to our support@koolreport.com, I will try to spot out the issue as soon as possible. Let leave the var_dump(params);exit;
inside the "dataSource"
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo