X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttReportHelper.class.php;h=f2ae6202685759b615f4c860e975d1676b56c6d1;hb=7218f84ad58ed22a926b3ffa7a152ca7f93f0204;hp=927892e7963083e4894329ecc4122676a5ac6df3;hpb=5a989e29aed5ad95f7b4a4082a2d88b924523968;p=timetracker.git
diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php
index 927892e7..f2ae6202 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 .= '
';
$body .= '';
$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 .= '
';
$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 .= '
';
$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 .= '
';
$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 .= '
|
';
$body .= '';
$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 .= ' | ';
@@ -1403,6 +1407,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::getFavItems($report);
$group_by = $report['group_by'];
if ($group_by && 'no_grouping' != $group_by)
@@ -1465,7 +1473,7 @@ class ttReportHelper {
}
if ($report['show_cost']) {
$body .= '';
- $body .= ($user->canManageTeam() || $user->isClient()) ? $subtotal['cost'] : $subtotal['expenses'];
+ $body .= ($canViewReports || $isClient) ? $subtotal['cost'] : $subtotal['expenses'];
$body .= ' | ';
}
$body .= '
';
@@ -1482,7 +1490,7 @@ class ttReportHelper {
}
if ($report['show_cost']) {
$body .= ''.htmlspecialchars($user->currency).' ';
- $body .= ($user->canManageTeam() || $user->isClient()) ? $totals['cost'] : $totals['expenses'];
+ $body .= ($canViewReports || $isClient) ? $totals['cost'] : $totals['expenses'];
$body .= ' | ';
}
$body .= '';
@@ -1495,7 +1503,7 @@ class ttReportHelper {
$body .= '';
$body .= '';
$body .= ''.$i18n->getKey('label.date').' | ';
- if ($user->canManageTeam() || $user->isClient())
+ if ($canViewReports || $isClient)
$body .= ''.$i18n->getKey('label.user').' | ';
if ($report['show_client'])
$body .= ''.$i18n->getKey('label.client').' | ';
@@ -1544,7 +1552,7 @@ class ttReportHelper {
$body .= '
';
$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 ($report['show_client']) $body .= ''.($group_by == 'client' ? $subtotal_name : '').' | ';
if ($report['show_project']) $body .= ''.($group_by == 'project' ? $subtotal_name : '').' | ';
if ($report['show_task']) $body .= ''.($group_by == 'task' ? $subtotal_name : '').' | ';
@@ -1555,7 +1563,7 @@ class ttReportHelper {
if ($report['show_note']) $body .= ' | ';
if ($report['show_cost']) {
$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 ($report['show_paid']) $body .= ' | ';
@@ -1571,7 +1579,7 @@ class ttReportHelper {
$row_style = ($row_style == $rowItem) ? $rowItemAlt : $rowItem;
$body .= '
';
$body .= ''.$record['date'].' | ';
- if ($user->canManageTeam() || $user->isClient())
+ if ($canViewReports || $isClient)
$body .= ''.htmlspecialchars($record['user']).' | ';
if ($report['show_client'])
$body .= ''.htmlspecialchars($record['client']).' | ';
@@ -1611,7 +1619,7 @@ class ttReportHelper {
$body .= '
';
$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 ($report['show_client']) $body .= ''.($group_by == 'client' ? $subtotal_name : '').' | ';
if ($report['show_project']) $body .= ''.($group_by == 'project' ? $subtotal_name : '').' | ';
if ($report['show_task']) $body .= ''.($group_by == 'task' ? $subtotal_name : '').' | ';
@@ -1622,7 +1630,7 @@ class ttReportHelper {
if ($report['show_note']) $body .= ' | ';
if ($report['show_cost']) {
$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 ($report['show_paid']) $body .= ' | ';
@@ -1634,7 +1642,7 @@ class ttReportHelper {
$body .= '
|
';
$body .= '';
$body .= ''.$i18n->getKey('label.total').' | ';
- if ($user->canManageTeam() || $user->isClient()) $body .= ' | ';
+ if ($canViewReports || $isClient) $body .= ' | ';
if ($report['show_client']) $body .= ' | ';
if ($report['show_project']) $body .= ' | ';
if ($report['show_task']) $body .= ' | ';
@@ -1645,7 +1653,7 @@ class ttReportHelper {
if ($report['show_note']) $body .= ' | ';
if ($report['show_cost']) {
$body .= ''.htmlspecialchars($user->currency).' ';
- $body .= ($user->canManageTeam() || $user->isClient()) ? $totals['cost'] : $totals['expenses'];
+ $body .= ($canViewReports || $isClient) ? $totals['cost'] : $totals['expenses'];
$body .= ' | ';
}
if ($report['show_paid']) $body .= ' | ';