X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttReportHelper.class.php;h=1f797ace4580068bd21bbaede3dd291f12c64650;hb=2ccee198591bc2ad5d80b5e1076246449d9232c1;hp=223d8e4b1bcdd7a163d02bb8b8ffadf003a4bdfc;hpb=2cb68f81bd4dd4f4a83afc87bbc292df6b7d7039;p=timetracker.git diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 223d8e4b..1f797ace 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -291,6 +291,13 @@ class ttReportHelper { // Add paid status. if ($canViewReports && $bean->getAttribute('chpaid')) array_push($fields, 'l.paid as paid'); + // Add IP address. + if ($canViewReports && $bean->getAttribute('chip')) { + array_push($fields, 'l.created as created'); + array_push($fields, 'l.created_ip as created_ip'); + array_push($fields, 'l.modified as modified'); + array_push($fields, 'l.modified_ip as modified_ip'); + } // Add invoice name if it is selected. if (($canViewReports || $isClient) && $bean->getAttribute('chinvoice')) @@ -361,6 +368,14 @@ class ttReportHelper { // Add paid status. if ($canViewReports && $bean->getAttribute('chpaid')) array_push($fields, 'ei.paid as paid'); + // Add IP address. + if ($canViewReports && $bean->getAttribute('chip')) { + array_push($fields, 'ei.created as created'); + array_push($fields, 'ei.created_ip as created_ip'); + array_push($fields, 'ei.modified as modified'); + array_push($fields, 'ei.modified_ip as modified_ip'); + } + // Add invoice name if it is selected. if (($canViewReports || $isClient) && $bean->getAttribute('chinvoice')) array_push($fields, 'i.name as invoice'); @@ -538,6 +553,16 @@ class ttReportHelper { array_push($fields, "cast(l.billable * coalesce(upb.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2)) as cost"); // Use project rate for user. array_push($fields, "null as expense"); } + // Add paid status. + if ($canViewReports && $report['show_paid']) + array_push($fields, 'l.paid as paid'); + // Add IP address. + if ($canViewReports && $report['show_ip']) { + array_push($fields, 'l.created as created'); + array_push($fields, 'l.created_ip as created_ip'); + array_push($fields, 'l.modified as modified'); + array_push($fields, 'l.modified_ip as modified_ip'); + } // Add invoice name if it is selected. if (($canViewReports || $isClient) && $report['show_invoice']) array_push($fields, 'i.name as invoice'); @@ -604,6 +629,16 @@ class ttReportHelper { array_push($fields, 'ei.name as note'); array_push($fields, 'ei.cost as cost'); array_push($fields, 'ei.cost as expense'); + // Add paid status. + if ($canViewReports && $report['show_paid']) + array_push($fields, 'ei.paid as paid'); + // Add IP address. + if ($canViewReports && $report['show_ip']) { + array_push($fields, 'ei.created as created'); + array_push($fields, 'ei.created_ip as created_ip'); + array_push($fields, 'ei.modified as modified'); + array_push($fields, 'ei.modified_ip as modified_ip'); + } // Add invoice name if it is selected. if (($canViewReports || $isClient) && $report['show_invoice']) array_push($fields, 'i.name as invoice'); @@ -1239,6 +1274,8 @@ class ttReportHelper { $body .= ''.$i18n->getKey('label.cost').''; if ($bean->getAttribute('chpaid')) $body .= ''.$i18n->getKey('label.paid').''; + if ($bean->getAttribute('chip')) + $body .= ''.$i18n->getKey('label.ip').''; if ($bean->getAttribute('chinvoice')) $body .= ''.$i18n->getKey('label.invoice').''; $body .= ''; @@ -1281,6 +1318,7 @@ class ttReportHelper { $body .= ''; } if ($bean->getAttribute('chpaid')) $body .= ''; + if ($bean->getAttribute('chip')) $body .= ''; if ($bean->getAttribute('chinvoice')) $body .= ''; $body .= ''; $body .= ' '; @@ -1318,6 +1356,11 @@ class ttReportHelper { $body .= $record['paid'] == 1 ? $i18n->getKey('label.yes') : $i18n->getKey('label.no'); $body .= ''; } + if ($bean->getAttribute('chip')) { + $body .= ''; + $body .= $record['modified'] ? $record['modified_ip'].' '.$record['modified'] : $record['created_ip'].' '.$record['created']; + $body .= ''; + } if ($bean->getAttribute('chinvoice')) $body .= ''.htmlspecialchars($record['invoice']).''; $body .= ''; @@ -1348,6 +1391,7 @@ class ttReportHelper { $body .= ''; } if ($bean->getAttribute('chpaid')) $body .= ''; + if ($bean->getAttribute('chip')) $body .= ''; if ($bean->getAttribute('chinvoice')) $body .= ''; $body .= ''; } @@ -1371,6 +1415,7 @@ class ttReportHelper { $body .= ''; } if ($bean->getAttribute('chpaid')) $body .= ''; + if ($bean->getAttribute('chip')) $body .= ''; if ($bean->getAttribute('chinvoice')) $body .= ''; $body .= ''; @@ -1407,6 +1452,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) @@ -1469,7 +1518,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 .= ''; @@ -1486,7 +1535,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 .= ''; @@ -1499,7 +1548,7 @@ class ttReportHelper { $body .= ''; $body .= ''; $body .= ''; - if ($user->canManageTeam() || $user->isClient()) + if ($canViewReports || $isClient) $body .= ''; if ($report['show_client']) $body .= ''; @@ -1521,6 +1570,8 @@ class ttReportHelper { $body .= ''; if ($report['show_paid']) $body .= ''; + if ($report['show_ip']) + $body .= ''; if ($report['show_invoice']) $body .= ''; $body .= ''; @@ -1548,7 +1599,7 @@ class ttReportHelper { $body .= ''; $body .= ''; $subtotal_name = htmlspecialchars($subtotals[$prev_grouped_by]['name']); - 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 .= ''; @@ -1559,10 +1610,11 @@ class ttReportHelper { if ($report['show_note']) $body .= ''; if ($report['show_cost']) { $body .= ''; } if ($report['show_paid']) $body .= ''; + if ($report['show_ip']) $body .= ''; if ($report['show_invoice']) $body .= ''; $body .= ''; $body .= ''; @@ -1575,7 +1627,7 @@ class ttReportHelper { $row_style = ($row_style == $rowItem) ? $rowItemAlt : $rowItem; $body .= ''; $body .= ''; - if ($user->canManageTeam() || $user->isClient()) + if ($canViewReports || $isClient) $body .= ''; if ($report['show_client']) $body .= ''; @@ -1600,6 +1652,11 @@ class ttReportHelper { $body .= $record['paid'] == 1 ? $i18n->getKey('label.yes') : $i18n->getKey('label.no'); $body .= ''; } + if ($report['show_ip']) { + $body .= ''; + } if ($report['show_invoice']) $body .= ''; $body .= ''; @@ -1615,7 +1672,7 @@ class ttReportHelper { $body .= ''; $body .= ''; $subtotal_name = htmlspecialchars($subtotals[$cur_grouped_by]['name']); - 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 .= ''; @@ -1626,10 +1683,11 @@ class ttReportHelper { if ($report['show_note']) $body .= ''; if ($report['show_cost']) { $body .= ''; } if ($report['show_paid']) $body .= ''; + if ($report['show_ip']) $body .= ''; if ($report['show_invoice']) $body .= ''; $body .= ''; } @@ -1638,7 +1696,7 @@ class ttReportHelper { $body .= ''; $body .= ''; $body .= ''; - 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 .= ''; @@ -1649,10 +1707,11 @@ class ttReportHelper { if ($report['show_note']) $body .= ''; if ($report['show_cost']) { $body .= ''; } if ($report['show_paid']) $body .= ''; + if ($report['show_ip']) $body .= ''; if ($report['show_invoice']) $body .= ''; $body .= '';
'.$i18n->getKey('label.date').''.$i18n->getKey('label.user').''.$i18n->getKey('label.client').''.$i18n->getKey('label.cost').''.$i18n->getKey('label.paid').''.$i18n->getKey('label.ip').''.$i18n->getKey('label.invoice').'
'.$i18n->getKey('label.subtotal').''.($group_by == 'user' ? $subtotal_name : '').''.($group_by == 'user' ? $subtotal_name : '').''.($group_by == 'client' ? $subtotal_name : '').''.($group_by == 'project' ? $subtotal_name : '').''.($group_by == 'task' ? $subtotal_name : '').''; - $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 .= '
 
'.$record['date'].''.htmlspecialchars($record['user']).''.htmlspecialchars($record['client']).''; + $body .= $record['modified'] ? $record['modified_ip'].' '.$record['modified'] : $record['created_ip'].' '.$record['created']; + $body .= ''.htmlspecialchars($record['invoice']).'
'.$i18n->getKey('label.subtotal').''.($group_by == 'user' ? $subtotal_name : '').''.($group_by == 'user' ? $subtotal_name : '').''.($group_by == 'client' ? $subtotal_name : '').''.($group_by == 'project' ? $subtotal_name : '').''.($group_by == 'task' ? $subtotal_name : '').''; - $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 .= '
 
'.$i18n->getKey('label.total').''.htmlspecialchars($user->currency).' '; - $body .= ($user->canManageTeam() || $user->isClient()) ? $totals['cost'] : $totals['expenses']; + $body .= ($canViewReports || $isClient) ? $totals['cost'] : $totals['expenses']; $body .= '