[patch] Show subtotal of hours, billable and non-billable.

"Jason M. Felice" <[email protected]> Sat, 9 Aug 2003 12:53:31 -0400
Newsgroups gmane.comp.horde.hermes
Message-ID <[email protected]>
This patch shows the total hours, total non-billable hours, total billable
hours, and percents on the time entry screen.

I'm curious if there's maybe a better way to do this, where I can boldface
the font or something?

-- 
 Jason M. Felice
 Cronosys, LLC <http://www.cronosys.com/>
 216.221.4600 x302


-- 
hermes mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]
hermes-subtotals.diff (text/plain, 1.4 KB)
Index: hermes/time.php
===================================================================
RCS file: /repository/hermes/time.php,v
retrieving revision 1.17
diff -u -r1.17 time.php
--- hermes/time.php	11 Jul 2003 20:23:50 -0000	1.17
+++ hermes/time.php	9 Aug 2003 16:50:28 -0000
@@ -56,6 +56,27 @@
                                    'start' => $startofweek,
                                    'end' => $endofweek));
 if (!DB::isError($myhours) && count($myhours) > 0) {
+    $total_hours = 0.0;
+    $total_billable_hours = 0.0;
+    foreach ($myhours as $vals) {
+        $total_hours += (double)$vals['hours'];
+        if ($vals['billable']) {
+            $total_billable_hours += (double)$vals['hours'];
+        }
+    }
+    $billable_pct = round($total_billable_hours / $total_hours * 100.0);
+    $myhours[] = array(
+        'description' => sprintf('Total Billable Hours (%.0f%%)', $billable_pct),
+        'hours' => sprintf('%.02f', $total_billable_hours)
+        );
+    $myhours[] = array(
+        'description' => sprintf('Total Non-Billable Hours (%.0f%%)', 100.0 - $billable_pct),
+        'hours' => sprintf('%.02f', $total_hours - $total_billable_hours)
+        );
+    $myhours[] = array(
+        'description' => 'Total Hours',
+        'hours' => sprintf('%.02f', $total_hours)
+        );
     foreach ($myhours as $idx => $vals) {
         foreach ($vals as $key => $val) {
             $_myhours[$key][$idx] = $val;