Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Hi Mazmur,
I think your case could make use of the Cube process. Let me present some sample code with a mysql table which you could modify for your case depending your database:
$this->src("mysql")
->query("select employee, day(dateField) as 'day' from myTable where month(dateField) = 1")
->pipe(new \koolreport\cube\processes\Cube([
"row" => "employee",
"column" => "day",
"count" => "employee"
]))
->pipe(new \koolreport\processes\RemoveColumn(["{{all}}"]))
->pipe(new \koolreport\processes\ColumnsSort([
"{name}" => 'asc',
"fixedColumns" => [0]
]))
->pipe(new \koolreport\processes\Map([
"{value}" => function($row, $meta) {
$columns = array_keys($meta["columns"]);
foreach ($columns as $col) {
if ($col !== "employee") {
if ($row[$col] === 0) $row[$col] = "A";
else if ($row[$col] > 0) $row[$col] = "H";
}
}
return $row;
},
"{meta}" => function($meta) {
$columns = array_keys($meta["columns"]);
foreach ($columns as $col) {
$meta["columns"][$col]["type"] = "string";
}
return $meta;
}
]))
->pipe($this->dataStore("attendance"));
The datastore "attendance" will have attendance data for month 1. It's similar for other months. Thanks!
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo