Started to work on ttRegistrator class to encapsulate restration related tasks.
[timetracker.git] / WEB-INF / lib / ttReportHelper.class.php
index 129d975..1f797ac 100644 (file)
@@ -368,7 +368,7 @@ class ttReportHelper {
       // Add paid status.
       if ($canViewReports && $bean->getAttribute('chpaid'))
         array_push($fields, 'ei.paid as paid');
-      // Add IP address. NULL for now for expenses.
+      // Add IP address.
       if ($canViewReports && $bean->getAttribute('chip')) {
         array_push($fields, 'ei.created as created');
         array_push($fields, 'ei.created_ip as created_ip');
@@ -553,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');
@@ -619,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');
@@ -1338,7 +1358,7 @@ class ttReportHelper {
           }
           if ($bean->getAttribute('chip')) {
             $body .= '<td style="'.$cellRightAligned.'">';
-            $body .= $record['modified'] ? $record['modified_ip'].' '.$record['modified'] : $$record['created_ip'].' '.$record['created'];
+            $body .= $record['modified'] ? $record['modified_ip'].' '.$record['modified'] : $record['created_ip'].' '.$record['created'];
             $body .= '</td>';
           }
           if ($bean->getAttribute('chinvoice'))
@@ -1550,6 +1570,8 @@ class ttReportHelper {
         $body .= '<td style="'.$tableHeaderCentered.'" width="5%">'.$i18n->getKey('label.cost').'</td>';
       if ($report['show_paid'])
         $body .= '<td style="'.$tableHeaderCentered.'" width="5%">'.$i18n->getKey('label.paid').'</td>';
+      if ($report['show_ip'])
+        $body .= '<td style="'.$tableHeaderCentered.'" width="5%">'.$i18n->getKey('label.ip').'</td>';
       if ($report['show_invoice'])
         $body .= '<td style="'.$tableHeader.'">'.$i18n->getKey('label.invoice').'</td>';
       $body .= '</tr>';
@@ -1592,6 +1614,7 @@ class ttReportHelper {
                 $body .= '</td>';
               }
               if ($report['show_paid']) $body .= '<td></td>';
+              if ($report['show_ip']) $body .= '<td></td>';
               if ($report['show_invoice']) $body .= '<td></td>';
               $body .= '</tr>';
               $body .= '<tr><td>&nbsp;</td></tr>';
@@ -1629,6 +1652,11 @@ class ttReportHelper {
             $body .= $record['paid'] == 1 ? $i18n->getKey('label.yes') : $i18n->getKey('label.no');
             $body .= '</td>';
           }
+          if ($report['show_ip']) {
+            $body .= '<td style="'.$cellRightAligned.'">';
+            $body .= $record['modified'] ? $record['modified_ip'].' '.$record['modified'] : $record['created_ip'].' '.$record['created'];
+            $body .= '</td>';
+          }
           if ($report['show_invoice'])
             $body .= '<td style="'.$cellRightAligned.'">'.htmlspecialchars($record['invoice']).'</td>';
           $body .= '</tr>';
@@ -1659,6 +1687,7 @@ class ttReportHelper {
           $body .= '</td>';
         }
         if ($report['show_paid']) $body .= '<td></td>';
+        if ($report['show_ip']) $body .= '<td></td>';
         if ($report['show_invoice']) $body .= '<td></td>';
         $body .= '</tr>';
       }
@@ -1682,6 +1711,7 @@ class ttReportHelper {
         $body .= '</td>';
       }
       if ($report['show_paid']) $body .= '<td></td>';
+      if ($report['show_ip']) $body .= '<td></td>';
       if ($report['show_invoice']) $body .= '<td></td>';
       $body .= '</tr>';