3 * FusionForge reporting system
5 * Copyright 2003-2004, Tim Perdue/GForge, LLC
6 * Copyright 2009, Roland Mas
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; either version 2 of the License,
13 * or (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 function report_header($title) {
28 echo $HTML->header(array('title'=>" "._('Reporting').": " . $title));
29 if (isset($GLOBALS['feedback'])) {
30 echo html_feedback_top($GLOBALS['feedback']);
32 echo "<h1>".sprintf(_('%1$s Reporting'), forge_get_config ('forge_name'))."</h1>\n";
35 function report_footer() {
37 echo $HTML->footer(array());
40 function report_span_box($name='SPAN', $selected='1', $suppress_daily=false) {
41 if ($suppress_daily) {
43 $titles=array(_('Weekly'),
47 $titles=array(_('Daily'),
51 return html_build_select_box_from_arrays ($vals,$titles,$name,$selected,false);
54 function report_weeks_box($Report, $name='week', $selected=false) {
55 $arr =& $Report->getWeekStartArr();
58 for ($i=0; $i<count($arr); $i++) {
59 $arr2[$i]=date(_('Y-m-d'), $arr[$i]) .' '._('to').' '. date(_('Y-m-d'), ($arr[$i]+6*24*60*60));
62 return html_build_select_box_from_arrays ($arr,$arr2,$name,$selected,false);
65 function report_day_adjust_box($Report, $name='days_adjust', $selected=false) {
75 $names[]=_('Tuesday');
76 $names[]=_('Wednesday');
77 $names[]=_('Thursday');
79 $names[]=_('Saturday');
80 return html_build_select_box_from_arrays ($days,$names,$name,$selected,false);
82 // return html_build_select_box_from_arrays (array_reverse(array_values($Report->adjust_days)),array_reverse(array_keys($Report->adjust_days)),$name,$selected,false);
85 function report_months_box($Report, $name='month', $selected=false) {
86 $arr =& $Report->getMonthStartArr();
89 for ($i=0; $i<count($arr); $i++) {
90 $arr2[$i]=date(_('Y-m'),$arr[$i]);
93 return html_build_select_box_from_arrays ($arr,$arr2,$name,$selected,false);
96 function report_useract_box($name='dev_id', $selected='1', $start_with='') {
98 $res = db_query_params ('SELECT user_id,realname FROM users WHERE status=$1 AND (exists (SELECT user_id FROM rep_user_act_daily WHERE user_id=users.user_id)) AND (lower(lastname) LIKE $2 OR lower(user_name) LIKE $3) ORDER BY lastname',
100 strtolower("$start_with%"),
101 strtolower("$start_with%"))) ;
103 $res = db_query_params ('SELECT user_id,realname FROM users WHERE status=$1 AND (exists (SELECT user_id FROM rep_user_act_daily WHERE user_id=users.user_id)) ORDER BY lastname',
106 return html_build_select_box($res, $name, $selected, false);
109 function report_usertime_box($name='dev_id', $selected='1', $start_with='') {
111 $res = db_query_params ('SELECT user_id,realname FROM users WHERE status=$1 AND (exists (SELECT user_id FROM rep_time_tracking WHERE user_id=users.user_id)) AND (lower(lastname) LIKE $2 OR lower(user_name) LIKE $3) ORDER BY lastname',
113 strtolower("$start_with%"),
114 strtolower("$start_with%"))) ;
116 $res = db_query_params ('SELECT user_id,realname FROM users WHERE status=$1 AND (exists (SELECT user_id FROM rep_time_tracking WHERE user_id=users.user_id)) ORDER BY lastname',
119 return html_build_select_box($res, $name, $selected, false);
122 function report_group_box($name='g_id', $selected='1') {
124 $res = db_query_params ('SELECT group_id,group_name FROM groups WHERE status=$1 ORDER BY group_name',
126 return html_build_select_box($res, $name, $selected, false);
129 function report_area_box($name='area', $selected='1', $Group=false) {
131 $sys_use_tracker = $Group->usesTracker();
132 $sys_use_forum = $Group->usesForum();
133 $sys_use_docman = $Group->usesDocman();
134 $sys_use_pm = $Group->usesPM();
135 $sys_use_frs = $Group->usesFRS();
137 $sys_use_tracker = forge_get_config('use_tracker');
138 $sys_use_forum = forge_get_config('use_forum');
139 $sys_use_docman = forge_get_config('use_docman');
140 $sys_use_pm = forge_get_config('use_pm');
141 $sys_use_frs = forge_get_config('use_frs');
143 if (forge_get_config('use_tracker')) {
145 $arr2[]=_('Tracker');
147 if (forge_get_config('use_forum')) {
151 if (forge_get_config('use_docman')) {
155 if (forge_get_config('use_pm')) {
159 if (forge_get_config('use_frs')) {
161 $arr2[]=_('Downloads');
164 return html_build_select_box_from_arrays ($arr,$arr2,$name,$selected,false);
167 function report_tracker_box($name='datatype', $selected='1') {
168 if (forge_get_config('use_tracker')) {
172 $arr[]=_('Feature Requests');
173 $arr[]=_('Other Trackers');
180 if (forge_get_config('use_forum')) {
181 $arr[]=_('Forum Messages');
184 if (forge_get_config('use_pm')) {
188 if (forge_get_config('use_frs')) {
189 $arr[]=_('Downloads');
192 return html_build_select_box_from_arrays ($arr2,$arr,$name,$selected,false);
195 function report_time_category_box($name='category',$selected=false) {
196 global $report_time_category_res;
197 if (!$report_time_category_res) {
198 $report_time_category_res = db_query_params ('SELECT * FROM rep_time_category',
201 return html_build_select_box($report_time_category_res,$name,$selected,false);
205 // Takes an array of labels and an array values and removes vals < 2% and sets up an "other"
207 function report_pie_arr($labels, $vals, $format=1) {
208 global $pie_labels,$pie_vals;
209 //first get sum of all values
210 for ($i=0; $i<count($vals); $i++) {
214 //now prune out vals where < 2%
215 for ($i=0; $i<count($vals); $i++) {
216 if (($vals[$i]/$total) < .02) {
219 $pie_labels[]=utf8_decode(util_unconvert_htmlspecialchars($labels[$i]))." (". number_format($vals[$i],$format) .") ";
220 $pie_vals[]=$vals[$i];
224 $pie_labels[]=_('Other')." (". number_format($rem,$format) .") ";
230 function report_package_box($group_id, $name='dev_id', $selected='') {
232 $res = db_query_params ('SELECT package_id, name FROM frs_package WHERE frs_package.group_id = $1',
234 return html_build_select_box($res, $name, $selected, false);
239 // c-file-style: "bsd"