KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Create Attendance Sheet Report ? #940

Open Mazmur opened this topic on on Jun 22, 2019 - 9 comments

Mazmur commented on Jun 22, 2019

Dear Koolreport,

How can I create a Attendance Report (Daily, Weekly & monthly) using koolreport ?

Regards,

Mazmur

KoolReport commented on Jun 23, 2019

How does your attendance report look like?

Mazmur commented on Jun 24, 2019

like this...

David Winterburn commented on Jun 24, 2019

Hi Mazmur,

What is the rule of deciding "H" or "A" from your attendance data?

Mazmur commented on Jun 26, 2019

Dear,

Yes, the rule of deciding "H" or "A" from my attendance data.

Regards

David Winterburn commented on Jun 26, 2019

Hi Mazmur,

It's not a yes or no question. I'm asking you what the rule is, how do you decide "H" or "A"?

Mazmur commented on Jun 26, 2019

Dear,

"H" for attend in data "A" for not present in data

Regards

David Winterburn commented on Jun 26, 2019

Another question, what is the type of your attendance data source, is it CSV, Excel file or database table/view? In the case of database table/view what is the type of column "Date"? Thanks!

Mazmur commented on Jun 26, 2019

Datasource from database with Datetime for data type.

David Winterburn commented on Jun 28, 2019

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!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None