From 45026cd585551c90dddeaaa8872d038eea23c445 Mon Sep 17 00:00:00 2001 From: anuko Date: Sat, 4 Nov 2017 17:23:46 +0000 Subject: [PATCH] Cosmetic - white space and comment improvement. --- WEB-INF/lib/ttChartHelper.class.php | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/WEB-INF/lib/ttChartHelper.class.php b/WEB-INF/lib/ttChartHelper.class.php index 7e58ca09..42737c53 100644 --- a/WEB-INF/lib/ttChartHelper.class.php +++ b/WEB-INF/lib/ttChartHelper.class.php @@ -36,7 +36,7 @@ define('CHART_CLIENTS', 3); // Class ttChartHelper is a helper class for charts. class ttChartHelper { - // getTotals - returns total times by project or activity for a given user in a specified period. + // getTotals - returns total times by project or task for a given user in a specified period. static function getTotals($user_id, $ch_type, $cl_date, $cl_period = null) { $period = null; @@ -59,7 +59,7 @@ class ttChartHelper { break; } } - + $result = array(); $mdb2 = getConnection(); @@ -81,34 +81,34 @@ class ttChartHelper { // Data for clients. $sql = "select coalesce(c.name, 'NULL') as name, sum(time_to_sec(l.duration)) as time from tt_log l left join tt_clients c on (c.id = l.client_id) - where l.status = 1 and l.duration > 0 and l.user_id = $user_id $q_period group by l.client_id"; + where l.status = 1 and l.duration > 0 and l.user_id = $user_id $q_period group by l.client_id"; } - + $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { $result[] = array('name'=>$val['name'],'time'=>$val['time']); // name - project name, time - total for project in seconds. } } - - // Get total time. We'll need it calculate percentages (for labels to the right of diagram). + + // Get total time. We'll need it to calculate percentages (for labels to the right of diagram). $total = 0; foreach ($result as $one_val) { $total += $one_val['time']; - } - // Add a string representation of time + percentage to names. Example: "Time Tracker (1:15 - 6%)". - foreach ($result as &$one_val) { - $percent = round(100*$one_val['time']/$total).'%'; + } + // Add a string representation of time + percentage to names. Example: "Time Tracker (1:15 - 6%)". + foreach ($result as &$one_val) { + $percent = round(100*$one_val['time']/$total).'%'; $one_val['name'] .= ' ('.sec_to_time_fmt_hm($one_val['time']).' - '.$percent.')'; - } - - // Note: the remaining code here is needed to display labels on the side of a diagram. - // We print lables ourselves (not using libchart.php) because quality of libchart labels is not good. - - // Note: Optimize this sorting and reversing. + } + + // Note: the remaining code here is needed to display labels on the side of the diagram. + // We print labels ourselves (not using libchart.php) because quality of libchart labels is not good. + + // Note: Optimize this sorting and reversing. $result = mu_sort($result, 'time'); $result = array_reverse($result); // This is to assign correct colors to labels. - + // Add color to array items. This is used in labels on the side of a chart. $colors = array( array(2, 78, 0), @@ -131,7 +131,7 @@ class ttChartHelper { $color = $colors[$i%count($colors)]; $result[$i]['color_html'] = sprintf('#%02x%02x%02x', $color[0], $color[1], $color[2]); } - + return $result; } } -- 2.20.1