X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/5a989e29aed5ad95f7b4a4082a2d88b924523968..2cb68f81bd4dd4f4a83afc87bbc292df6b7d7039:/WEB-INF/lib/ttReportHelper.class.php diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 927892e7..223d8e4b 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -1121,6 +1121,10 @@ class ttReportHelper { global $user; global $i18n; + // Determine these once as they are used in multiple places in this function. + $canViewReports = $user->can('view_reports'); + $isClient = $user->isClient(); + $items = ttReportHelper::getItems($bean); $group_by = $bean->getAttribute('group_by'); if ($group_by && 'no_grouping' != $group_by) @@ -1183,7 +1187,7 @@ class ttReportHelper { } if ($bean->getAttribute('chcost')) { $body .= '
| '.$i18n->getKey('label.date').' | '; - if ($user->canManageTeam() || $user->isClient()) + if ($canViewReports || $isClient) $body .= ''.$i18n->getKey('label.user').' | '; if ($bean->getAttribute('chclient')) $body .= ''.$i18n->getKey('label.client').' | '; @@ -1262,7 +1266,7 @@ class ttReportHelper { $body .= '||||||
| '.$i18n->getKey('label.subtotal').' | '; $subtotal_name = htmlspecialchars($subtotals[$prev_grouped_by]['name']); - if ($user->canManageTeam() || $user->isClient()) $body .= ''.($group_by == 'user' ? $subtotal_name : '').' | '; + if ($canViewReports || $isClient) $body .= ''.($group_by == 'user' ? $subtotal_name : '').' | '; if ($bean->getAttribute('chclient')) $body .= ''.($group_by == 'client' ? $subtotal_name : '').' | '; if ($bean->getAttribute('chproject')) $body .= ''.($group_by == 'project' ? $subtotal_name : '').' | '; if ($bean->getAttribute('chtask')) $body .= ''.($group_by == 'task' ? $subtotal_name : '').' | '; @@ -1273,7 +1277,7 @@ class ttReportHelper { if ($bean->getAttribute('chnote')) $body .= ''; if ($bean->getAttribute('chcost')) { $body .= ' | '; - $body .= ($user->canManageTeam() || $user->isClient()) ? $subtotals[$prev_grouped_by]['cost'] : $subtotals[$prev_grouped_by]['expenses']; + $body .= ($canViewReports || $isClient) ? $subtotals[$prev_grouped_by]['cost'] : $subtotals[$prev_grouped_by]['expenses']; $body .= ' | '; } if ($bean->getAttribute('chpaid')) $body .= ''; @@ -1289,7 +1293,7 @@ class ttReportHelper { $row_style = ($row_style == $rowItem) ? $rowItemAlt : $rowItem; $body .= ' |
| '.$record['date'].' | '; - if ($user->canManageTeam() || $user->isClient()) + if ($canViewReports || $isClient) $body .= ''.htmlspecialchars($record['user']).' | '; if ($bean->getAttribute('chclient')) $body .= ''.htmlspecialchars($record['client']).' | '; @@ -1329,7 +1333,7 @@ class ttReportHelper { $body .= '||||||
| '.$i18n->getKey('label.subtotal').' | '; $subtotal_name = htmlspecialchars($subtotals[$cur_grouped_by]['name']); - if ($user->canManageTeam() || $user->isClient()) $body .= ''.($group_by == 'user' ? $subtotal_name : '').' | '; + if ($canViewReports || $isClient) $body .= ''.($group_by == 'user' ? $subtotal_name : '').' | '; if ($bean->getAttribute('chclient')) $body .= ''.($group_by == 'client' ? $subtotal_name : '').' | '; if ($bean->getAttribute('chproject')) $body .= ''.($group_by == 'project' ? $subtotal_name : '').' | '; if ($bean->getAttribute('chtask')) $body .= ''.($group_by == 'task' ? $subtotal_name : '').' | '; @@ -1340,7 +1344,7 @@ class ttReportHelper { if ($bean->getAttribute('chnote')) $body .= ''; if ($bean->getAttribute('chcost')) { $body .= ' | '; - $body .= ($user->canManageTeam() || $user->isClient()) ? $subtotals[$cur_grouped_by]['cost'] : $subtotals[$cur_grouped_by]['expenses']; + $body .= ($canViewReports || $isClient) ? $subtotals[$cur_grouped_by]['cost'] : $subtotals[$cur_grouped_by]['expenses']; $body .= ' | '; } if ($bean->getAttribute('chpaid')) $body .= ''; @@ -1352,7 +1356,7 @@ class ttReportHelper { $body .= ' |
| '.$i18n->getKey('label.total').' | '; - if ($user->canManageTeam() || $user->isClient()) $body .= ''; + if ($canViewReports || $isClient) $body .= ' | '; if ($bean->getAttribute('chclient')) $body .= ' | '; if ($bean->getAttribute('chproject')) $body .= ' | '; if ($bean->getAttribute('chtask')) $body .= ' | '; @@ -1363,7 +1367,7 @@ class ttReportHelper { if ($bean->getAttribute('chnote')) $body .= ' | '; if ($bean->getAttribute('chcost')) { $body .= ' | '.htmlspecialchars($user->currency).' '; - $body .= ($user->canManageTeam() || $user->isClient()) ? $totals['cost'] : $totals['expenses']; + $body .= ($canViewReports || $isClient) ? $totals['cost'] : $totals['expenses']; $body .= ' | '; } if ($bean->getAttribute('chpaid')) $body .= ''; |