Improved week view slightly.
authoranuko <support@anuko.com>
Mon, 25 Dec 2017 00:37:11 +0000 (00:37 +0000)
committeranuko <support@anuko.com>
Mon, 25 Dec 2017 00:37:11 +0000 (00:37 +0000)
WEB-INF/lib/ttTimeHelper.class.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/week.tpl
week.php

index 5090488..48ebdc9 100644 (file)
@@ -795,4 +795,23 @@ class ttTimeHelper {
 
     return $record_identifier;
   }
+
+  // getGroupedRecordsTotals - returns day totals for grouped records.
+  static function getGroupedRecordsTotals($groupedRecords) {
+    $groupedRecordsTotals = array();
+    foreach ($groupedRecords as $groupedRecord) {
+      foreach($groupedRecord as $key => $dayEntry) {
+        if ($dayEntry['duration']) {
+          $minutes = ttTimeHelper::toMinutes($dayEntry['duration']);
+          $groupedRecordsTotals[$key] += $minutes;
+        }
+      }
+    }
+    // Convert minutes to hh:mm for display.
+    foreach ($groupedRecordsTotals as $key => $single_total) {
+      $groupedRecordsTotals[$key] = ttTimeHelper::toAbsDuration($single_total);
+    }
+
+    return $groupedRecordsTotals;
+  }
 }
index be7b43f..04af17e 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.12.3.3687 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.12.3.3688 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index d919fd1..b120c49 100644 (file)
     {if ($user->isPluginEnabled('cf') || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
         <td valign="top">{$record.task|escape}<p>{$record.cf_1_value|escape}</td>
     {/if}
-        <td valign="top">{$record.$day_header_0.duration}</td>
-        <td valign="top">{$record.$day_header_1.duration}</td>
-        <td valign="top">{$record.$day_header_2.duration}</td>
-        <td valign="top">{$record.$day_header_3.duration}</td>
-        <td valign="top">{$record.$day_header_4.duration}</td>
-        <td valign="top">{$record.$day_header_5.duration}</td>
-        <td valign="top">{$record.$day_header_6.duration}</td>
+        <td valign="top">{$record.$date_0.duration}</td>
+        <td valign="top">{$record.$date_1.duration}</td>
+        <td valign="top">{$record.$date_2.duration}</td>
+        <td valign="top">{$record.$date_3.duration}</td>
+        <td valign="top">{$record.$date_4.duration}</td>
+        <td valign="top">{$record.$date_5.duration}</td>
+        <td valign="top">{$record.$date_6.duration}</td>
       </tr>
   {/foreach}
+      <tr>
+  {if ($user->isPluginEnabled('cl') || ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode))}
+        <td class="tableHeader"></td>
+  {/if}
+  {if ($user->isPluginEnabled('cf') || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+        <td class="tableHeader"></td>
+  {/if}
+        <td class="tableHeader">{$grouped_records_totals.$date_0}</td>
+        <td class="tableHeader">{$grouped_records_totals.$date_1}</td>
+        <td class="tableHeader">{$grouped_records_totals.$date_2}</td>
+        <td class="tableHeader">{$grouped_records_totals.$date_3}</td>
+        <td class="tableHeader">{$grouped_records_totals.$date_4}</td>
+        <td class="tableHeader">{$grouped_records_totals.$date_5}</td>
+        <td class="tableHeader">{$grouped_records_totals.$date_6}</td>
+      </tr>
     </table>
 {/if}
   </td>
index dea27e3..fd7af52 100644 (file)
--- a/week.php
+++ b/week.php
@@ -369,7 +369,10 @@ $endDate->setTimestamp(mktime(0,0,0,$t_arr[4]+1,$t_arr[3]-$t_arr[6]+6+$startWeek
 $smarty->assign('selected_date', $selected_date);
 $smarty->assign('week_total', $week_total);
 $smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getActiveUser(), $cl_date));
-$smarty->assign('grouped_records', ttTimeHelper::getGroupedRecordsForInterval($user->getActiveUser(), $startDate->toString(DB_DATEFORMAT), $endDate->toString(DB_DATEFORMAT)));
+$groupedRecords = ttTimeHelper::getGroupedRecordsForInterval($user->getActiveUser(), $startDate->toString(DB_DATEFORMAT), $endDate->toString(DB_DATEFORMAT));
+$smarty->assign('grouped_records', $groupedRecords);
+$smarty->assign('grouped_records_totals', ttTimeHelper::getGroupedRecordsTotals($groupedRecords));
+
 $smarty->assign('client_list', $client_list);
 $smarty->assign('project_list', $project_list);
 $smarty->assign('task_list', $task_list);
@@ -378,19 +381,26 @@ $smarty->assign('onload', 'onLoad="fillDropdowns()"');
 $smarty->assign('timestring', $startDate->toString($user->date_format).' - '.$endDate->toString($user->date_format));
 
 // Prepare and assign date headers. Note how startDate moves to the end of the week, so it no longer holds correct start week value.
-$smarty->assign('day_header_0', $startDate->toString($user->date_format));
+$smarty->assign('date_0', $startDate->toString(DB_DATEFORMAT));
+$smarty->assign('day_header_0', $startDate->getDate());
 $startDate->incDay();
-$smarty->assign('day_header_1', $startDate->toString($user->date_format));
+$smarty->assign('date_1', $startDate->toString(DB_DATEFORMAT));
+$smarty->assign('day_header_1', $startDate->getDate());
 $startDate->incDay();
-$smarty->assign('day_header_2', $startDate->toString($user->date_format));
+$smarty->assign('date_2', $startDate->toString(DB_DATEFORMAT));
+$smarty->assign('day_header_2', $startDate->getDate());
 $startDate->incDay();
-$smarty->assign('day_header_3', $startDate->toString($user->date_format));
+$smarty->assign('date_3', $startDate->toString(DB_DATEFORMAT));
+$smarty->assign('day_header_3', $startDate->getDate());
 $startDate->incDay();
-$smarty->assign('day_header_4', $startDate->toString($user->date_format));
+$smarty->assign('date_4', $startDate->toString(DB_DATEFORMAT));
+$smarty->assign('day_header_4', $startDate->getDate());
 $startDate->incDay();
-$smarty->assign('day_header_5', $startDate->toString($user->date_format));
+$smarty->assign('date_5', $startDate->toString(DB_DATEFORMAT));
+$smarty->assign('day_header_5', $startDate->getDate());
 $startDate->incDay();
-$smarty->assign('day_header_6', $startDate->toString($user->date_format));
+$smarty->assign('date_6', $startDate->toString(DB_DATEFORMAT));
+$smarty->assign('day_header_6', $startDate->getDate());
 
 $smarty->assign('title', $i18n->getKey('title.time'));
 $smarty->assign('content_page_name', 'week.tpl');