3636// Class ttChartHelper is a helper class for charts.
3737class ttChartHelper {
3838
39- // getTotals - returns total times by project or activity for a given user in a specified period.
39+ // getTotals - returns total times by project or task for a given user in a specified period.
4040 static function getTotals ($ user_id , $ ch_type , $ cl_date , $ cl_period = null ) {
4141
4242 $ period = null ;
@@ -59,7 +59,7 @@ static function getTotals($user_id, $ch_type, $cl_date, $cl_period = null) {
5959 break ;
6060 }
6161 }
62-
62+
6363 $ result = array ();
6464 $ mdb2 = getConnection ();
6565
@@ -81,34 +81,34 @@ static function getTotals($user_id, $ch_type, $cl_date, $cl_period = null) {
8181 // Data for clients.
8282 $ sql = "select coalesce(c.name, 'NULL') as name, sum(time_to_sec(l.duration)) as time from tt_log l
8383 left join tt_clients c on (c.id = l.client_id)
84- where l.status = 1 and l.duration > 0 and l.user_id = $ user_id $ q_period group by l.client_id " ;
84+ where l.status = 1 and l.duration > 0 and l.user_id = $ user_id $ q_period group by l.client_id " ;
8585 }
86-
86+
8787 $ res = $ mdb2 ->query ($ sql );
8888 if (!is_a ($ res , 'PEAR_Error ' )) {
8989 while ($ val = $ res ->fetchRow ()) {
9090 $ result [] = array ('name ' =>$ val ['name ' ],'time ' =>$ val ['time ' ]); // name - project name, time - total for project in seconds.
9191 }
9292 }
93-
94- // Get total time. We'll need it calculate percentages (for labels to the right of diagram).
93+
94+ // Get total time. We'll need it to calculate percentages (for labels to the right of diagram).
9595 $ total = 0 ;
9696 foreach ($ result as $ one_val ) {
9797 $ total += $ one_val ['time ' ];
98- }
99- // Add a string representation of time + percentage to names. Example: "Time Tracker (1:15 - 6%)".
100- foreach ($ result as &$ one_val ) {
101- $ percent = round (100 *$ one_val ['time ' ]/$ total ).'% ' ;
98+ }
99+ // Add a string representation of time + percentage to names. Example: "Time Tracker (1:15 - 6%)".
100+ foreach ($ result as &$ one_val ) {
101+ $ percent = round (100 *$ one_val ['time ' ]/$ total ).'% ' ;
102102 $ one_val ['name ' ] .= ' ( ' .sec_to_time_fmt_hm ($ one_val ['time ' ]).' - ' .$ percent .') ' ;
103- }
104-
105- // Note: the remaining code here is needed to display labels on the side of a diagram.
106- // We print lables ourselves (not using libchart.php) because quality of libchart labels is not good.
107-
108- // Note: Optimize this sorting and reversing.
103+ }
104+
105+ // Note: the remaining code here is needed to display labels on the side of the diagram.
106+ // We print labels ourselves (not using libchart.php) because quality of libchart labels is not good.
107+
108+ // Note: Optimize this sorting and reversing.
109109 $ result = mu_sort ($ result , 'time ' );
110110 $ result = array_reverse ($ result ); // This is to assign correct colors to labels.
111-
111+
112112 // Add color to array items. This is used in labels on the side of a chart.
113113 $ colors = array (
114114 array (2 , 78 , 0 ),
@@ -131,7 +131,7 @@ static function getTotals($user_id, $ch_type, $cl_date, $cl_period = null) {
131131 $ color = $ colors [$ i %count ($ colors )];
132132 $ result [$ i ]['color_html ' ] = sprintf ('#%02x%02x%02x ' , $ color [0 ], $ color [1 ], $ color [2 ]);
133133 }
134-
134+
135135 return $ result ;
136136 }
137137}
0 commit comments