From 3cd198c12cb6b6a48be9d0ca18fcbc5c8576dbdb Mon Sep 17 00:00:00 2001 From: root Date: Thu, 18 Jun 2026 23:08:43 +0000 Subject: [PATCH] Fix billable mapping (0=billable, 1=non-billable, 2=unproductive) - Swapped billable/non-billable SQL values to match migrated data - All 3 pivot tables always render (empty ones show 'No data') - Added grand total row to pivot tables - Initialize unprodRows/userColumnsUP to prevent undefined var error --- .../Reporting/TeamSummaryController.php | 10 ++++++---- templates/reporting/team_summary.html.twig | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Controller/Reporting/TeamSummaryController.php b/src/Controller/Reporting/TeamSummaryController.php index 6f3efc82..b78adc07 100644 --- a/src/Controller/Reporting/TeamSummaryController.php +++ b/src/Controller/Reporting/TeamSummaryController.php @@ -35,13 +35,15 @@ final class TeamSummaryController extends AbstractController $userColumns = []; $nonbillRows = []; $userColumnsNB = []; + $unprodRows = []; + $userColumnsUP = []; if ($selectedTeamId > 0) { $team = $this->teamRepository->find($selectedTeamId); if ($team) { $rows = $this->getUserTimeAnalysis($selectedTeamId, $from, $to); - [$projectRows, $userColumns] = $this->getProjectPivot($selectedTeamId, $from, $to, '= 1'); - [$nonbillRows, $userColumnsNB] = $this->getProjectPivot($selectedTeamId, $from, $to, '= 0'); + [$projectRows, $userColumns] = $this->getProjectPivot($selectedTeamId, $from, $to, '= 0'); + [$nonbillRows, $userColumnsNB] = $this->getProjectPivot($selectedTeamId, $from, $to, '= 1'); [$unprodRows, $userColumnsUP] = $this->getProjectPivot($selectedTeamId, $from, $to, '= 2'); } } @@ -68,8 +70,8 @@ final class TeamSummaryController extends AbstractController $sql = "SELECT u.username, u.alias, - COALESCE(SUM(CASE WHEN p.billable = 1 THEN ts.duration END), 0) / 3600 AS billable_hours, - COALESCE(SUM(CASE WHEN p.billable = 0 THEN ts.duration END), 0) / 3600 AS nonbillable_hours, + COALESCE(SUM(CASE WHEN p.billable = 0 THEN ts.duration END), 0) / 3600 AS billable_hours, + COALESCE(SUM(CASE WHEN p.billable = 1 THEN ts.duration END), 0) / 3600 AS nonbillable_hours, COALESCE(SUM(CASE WHEN p.billable IS NULL OR p.billable NOT IN (0,1) THEN ts.duration END), 0) / 3600 AS unproductive_hours, COALESCE(SUM(ts.duration), 0) / 3600 AS total_hours FROM kimai2_users u diff --git a/templates/reporting/team_summary.html.twig b/templates/reporting/team_summary.html.twig index d3f832ed..903e05f1 100644 --- a/templates/reporting/team_summary.html.twig +++ b/templates/reporting/team_summary.html.twig @@ -65,7 +65,6 @@ {% macro pivot(rows, cols, title) %} - {% if rows is not empty %}

{{ title }}

@@ -75,6 +74,9 @@ + {% if rows is empty %} + + {% else %} {% for pr in rows %} @@ -85,9 +87,19 @@ {% endfor %} + + + {% set gt = 0 %} + {% for uc in cols %} + {% set ct = 0 %}{% for pr in rows %}{% set ct = ct + pr.users[uc]|default(0) %}{% endfor %} + + {% set gt = gt + ct %} + {% endfor %} + + + {% endif %}
TOTAL
No data for this period
{{ pr.company }}{{ pr.total|number_format(1) }}
TOTAL{{ ct > 0 ? ct|number_format(1) }}{{ gt|number_format(1) }}
- {% endif %} {% endmacro %} {% import _self as self %}