]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttReportHelper.class.php
Fixed reports for renamed timesheet field.
[timetracker.git] / WEB-INF / lib / ttReportHelper.class.php
index 80ead68ed083ab70c423d41b200e0ffa7f3b21f6..7d2e40c5678e9b3f05d1fe4cb9bf4a541595b2c7 100644 (file)
@@ -285,11 +285,11 @@ class ttReportHelper {
     if ($user->isPluginEnabled('ts')) {
       $timesheet_option = $options['timesheet'];
       if ($timesheet_option == TIMESHEET_PENDING)
-        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.submit_status = 1 and ts.approval_status is null)";
+        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.submit_status = 1 and ts.approve_status is null)";
       else if ($timesheet_option == TIMESHEET_APPROVED)
-        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approval_status = 1)";
+        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approve_status = 1)";
       else if ($timesheet_option == TIMESHEET_NOT_APPROVED)
-        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approval_status = 0)";
+        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approve_status = 0)";
       else if ($options['show_timesheet'])
         $inner_joins .= " left join tt_timesheets ts on (l.timesheet_id = ts.id)"; // Left join for timesheet nme.
     }
@@ -371,11 +371,11 @@ class ttReportHelper {
       if ($user->isPluginEnabled('ts')) {
         $timesheet_option = $options['timesheet'];
         if ($timesheet_option == TIMESHEET_PENDING)
-          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.submit_status = 1 and ts.approval_status is null)";
+          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.submit_status = 1 and ts.approve_status is null)";
         else if ($timesheet_option == TIMESHEET_APPROVED)
-          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approval_status = 1)";
+          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approve_status = 1)";
         else if ($timesheet_option == TIMESHEET_NOT_APPROVED)
-          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approval_status = 0)";
+          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approve_status = 0)";
         else if ($options['show_timesheet'])
           $inner_joins .= " left join tt_timesheets ts on (ei.timesheet_id = ts.id)"; // Left join for timesheet name.
       }
@@ -566,11 +566,11 @@ class ttReportHelper {
     if ($user->isPluginEnabled('ts') && $options['timesheet']) {
       $timesheet_option = $options['timesheet'];
       if ($timesheet_option == TIMESHEET_PENDING)
-        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.submit_status = 1 and ts.approval_status is null)";
+        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.submit_status = 1 and ts.approve_status is null)";
       else if ($timesheet_option == TIMESHEET_APPROVED)
-        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approval_status = 1)";
+        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approve_status = 1)";
       else if ($timesheet_option == TIMESHEET_NOT_APPROVED)
-        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approval_status = 0)";
+        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approve_status = 0)";
     }
     // Prepare a query for time items.
     $sql = "select $time_part $units_part $cost_part from tt_log l $left_joins $inner_joins $where";
@@ -582,11 +582,11 @@ class ttReportHelper {
       if ($user->isPluginEnabled('ts') && $options['timesheet']) {
         $timesheet_option = $options['timesheet'];
         if ($timesheet_option == TIMESHEET_PENDING)
-          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.submit_status = 1 and ts.approval_status is null)";
+          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.submit_status = 1 and ts.approve_status is null)";
         else if ($timesheet_option == TIMESHEET_APPROVED)
-          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approval_status = 1)";
+          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approve_status = 1)";
         else if ($timesheet_option == TIMESHEET_NOT_APPROVED)
-          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approval_status = 0)";
+          $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approve_status = 0)";
       }
       $where = ttReportHelper::getExpenseWhere($options);
       $sql_for_expenses = "select null as time";
@@ -834,12 +834,16 @@ class ttReportHelper {
         $body .= '<td style="'.$tableHeader.'">'.$i18n->get('label.note').'</td>';
       if ($options['show_cost'])
         $body .= '<td style="'.$tableHeaderCentered.'" width="5%">'.$i18n->get('label.cost').'</td>';
+      if ($options['show_approved'])
+        $body .= '<td style="'.$tableHeaderCentered.'" width="5%">'.$i18n->get('label.approved').'</td>';
       if ($options['show_paid'])
         $body .= '<td style="'.$tableHeaderCentered.'" width="5%">'.$i18n->get('label.paid').'</td>';
       if ($options['show_ip'])
         $body .= '<td style="'.$tableHeaderCentered.'" width="5%">'.$i18n->get('label.ip').'</td>';
       if ($options['show_invoice'])
         $body .= '<td style="'.$tableHeader.'">'.$i18n->get('label.invoice').'</td>';
+      if ($options['show_timesheet'])
+        $body .= '<td style="'.$tableHeader.'">'.$i18n->get('label.timesheet').'</td>';
       $body .= '</tr>';
 
       // Initialize variables to print subtotals.
@@ -880,9 +884,11 @@ class ttReportHelper {
                 $body .= ($canViewReports || $isClient) ? $subtotals[$prev_grouped_by]['cost'] : $subtotals[$prev_grouped_by]['expenses'];
                 $body .= '</td>';
               }
+              if ($options['show_approved']) $body .= '<td></td>';
               if ($options['show_paid']) $body .= '<td></td>';
               if ($options['show_ip']) $body .= '<td></td>';
               if ($options['show_invoice']) $body .= '<td></td>';
+              if ($options['show_timesheet']) $body .= '<td></td>';
               $body .= '</tr>';
               $body .= '<tr><td>&nbsp;</td></tr>';
             }
@@ -916,6 +922,11 @@ class ttReportHelper {
             $body .= '<td style="'.$cellLeftAligned.'">'.htmlspecialchars($record['note']).'</td>';
           if ($options['show_cost'])
             $body .= '<td style="'.$cellRightAligned.'">'.$record['cost'].'</td>';
+          if ($options['show_approved']) {
+            $body .= '<td style="'.$cellRightAligned.'">';
+            $body .= $record['approved'] == 1 ? $i18n->get('label.yes') : $i18n->get('label.no');
+            $body .= '</td>';
+          }
           if ($options['show_paid']) {
             $body .= '<td style="'.$cellRightAligned.'">';
             $body .= $record['paid'] == 1 ? $i18n->get('label.yes') : $i18n->get('label.no');
@@ -928,6 +939,8 @@ class ttReportHelper {
           }
           if ($options['show_invoice'])
             $body .= '<td style="'.$cellRightAligned.'">'.htmlspecialchars($record['invoice']).'</td>';
+          if ($options['show_timesheet'])
+            $body .= '<td style="'.$cellRightAligned.'">'.htmlspecialchars($record['timesheet']).'</td>';
           $body .= '</tr>';
 
           $prev_date = $record['date'];
@@ -956,9 +969,11 @@ class ttReportHelper {
           $body .= ($canViewReports || $isClient) ? $subtotals[$cur_grouped_by]['cost'] : $subtotals[$cur_grouped_by]['expenses'];
           $body .= '</td>';
         }
+        if ($options['show_approved']) $body .= '<td></td>';
         if ($options['show_paid']) $body .= '<td></td>';
         if ($options['show_ip']) $body .= '<td></td>';
         if ($options['show_invoice']) $body .= '<td></td>';
+        if ($options['show_timesheet']) $body .= '<td></td>';
         $body .= '</tr>';
       }
 
@@ -981,9 +996,11 @@ class ttReportHelper {
         $body .= ($canViewReports || $isClient) ? $totals['cost'] : $totals['expenses'];
         $body .= '</td>';
       }
+      if ($options['show_approved']) $body .= '<td></td>';
       if ($options['show_paid']) $body .= '<td></td>';
       if ($options['show_ip']) $body .= '<td></td>';
       if ($options['show_invoice']) $body .= '<td></td>';
+      if ($options['show_timesheet']) $body .= '<td></td>';
       $body .= '</tr>';
 
       $body .= '</table>';
@@ -1588,11 +1605,11 @@ class ttReportHelper {
     if ($user->isPluginEnabled('ts') && $options['timesheet']) {
       $timesheet_option = $options['timesheet'];
       if ($timesheet_option == TIMESHEET_PENDING)
-        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.submit_status = 1 and ts.approval_status is null)";
+        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.submit_status = 1 and ts.approve_status is null)";
       else if ($timesheet_option == TIMESHEET_APPROVED)
-        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approval_status = 1)";
+        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approve_status = 1)";
       else if ($timesheet_option == TIMESHEET_NOT_APPROVED)
-        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approval_status = 0)";
+        $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approve_status = 0)";
     }
     $join .= $inner_joins;
     return $join;
@@ -1646,11 +1663,11 @@ class ttReportHelper {
     if ($user->isPluginEnabled('ts') && $options['timesheet']) {
       $timesheet_option = $options['timesheet'];
       if ($timesheet_option == TIMESHEET_PENDING)
-        $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.submit_status = 1 and ts.approval_status is null)";
+        $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.submit_status = 1 and ts.approve_status is null)";
       else if ($timesheet_option == TIMESHEET_APPROVED)
-        $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approval_status = 1)";
+        $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approve_status = 1)";
       else if ($timesheet_option == TIMESHEET_NOT_APPROVED)
-        $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approval_status = 0)";
+        $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approve_status = 0)";
     }
     $join .= $inner_joins;
     return $join;