3 * FusionForge reporting system
5 * Copyright 2003-2004, Tim Perdue/GForge, LLC
6 * Copyright 2009, Roland Mas
7 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
8 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 function report_header($title) {
27 $t = sprintf(_('%1$s Reporting'), forge_get_config ('forge_name')) . ": " . $title;
28 site_header(array('title'=>$t));
31 function report_footer() {
33 echo $HTML->footer(array());
36 function report_span_box($name='SPAN', $selected='1', $suppress_daily=false) {
37 if ($suppress_daily) {
39 $titles=array(_('Weekly'),
43 $titles=array(_('Daily'),
47 return html_build_select_box_from_arrays ($vals,$titles,$name,$selected,false);
50 function report_weeks_box($Report, $name='week', $selected=false) {
51 $arr =& $Report->getWeekStartArr();
54 for ($i=0; $i<count($arr); $i++) {
55 $arr2[$i]=date(_('Y-m-d'), $arr[$i]) .' '._('to').' '. date(_('Y-m-d'), ($arr[$i]+6*24*60*60));
58 return html_build_select_box_from_arrays ($arr,$arr2,$name,$selected,false);
61 function report_day_adjust_box($Report, $name='days_adjust', $selected=false) {
71 $names[]=_('Tuesday');
72 $names[]=_('Wednesday');
73 $names[]=_('Thursday');
75 $names[]=_('Saturday');
76 return html_build_select_box_from_arrays ($days,$names,$name,$selected,false);
78 // return html_build_select_box_from_arrays (array_reverse(array_values($Report->adjust_days)),array_reverse(array_keys($Report->adjust_days)),$name,$selected,false);
81 function report_months_box($Report, $name='month', $selected=false) {
82 $arr =& $Report->getMonthStartArr();
85 for ($i=0; $i<count($arr); $i++) {
86 $arr2[$i]=date(_('Y-m'),$arr[$i]);
89 return html_build_select_box_from_arrays ($arr,$arr2,$name,$selected,false);
92 function report_useract_box($name='dev_id', $selected='1', $start_with='') {
94 $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',
96 strtolower("$start_with%"),
97 strtolower("$start_with%"))) ;
99 $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',
102 return html_build_select_box($res, $name, $selected, false);
105 function report_usertime_box($name='dev_id', $selected='1', $start_with='') {
107 $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',
109 strtolower("$start_with%"),
110 strtolower("$start_with%"))) ;
112 $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',
115 return html_build_select_box($res, $name, $selected, false);
118 function report_group_box($name='g_id', $selected='1') {
120 $res = db_query_params ('SELECT group_id,group_name FROM groups WHERE status=$1 ORDER BY group_name',
122 return html_build_select_box($res, $name, $selected, false);
125 function report_area_box($name='area', $selected='1', $Group=false) {
129 $use_tracker = $Group->usesTracker();
130 $use_forum = $Group->usesForum();
131 $use_docman = $Group->usesDocman();
132 $use_pm = $Group->usesPM();
133 $use_frs = $Group->usesFRS();
135 $use_tracker = forge_get_config('use_tracker');
136 $use_forum = forge_get_config('use_forum');
137 $use_docman = forge_get_config('use_docman');
138 $use_pm = forge_get_config('use_pm');
139 $use_frs = forge_get_config('use_frs');
143 $arr2[]=_('Tracker');
159 $arr2[]=_('Downloads');
162 $arr2[]=_('Page views');
164 if (is_object($Group) && $Group->getID()) {
165 $hookParams['group'] = $Group->getID();
166 $hookParams['show'] = array('none'); // No display => No compute this time.
167 $hookParams['ids'] = &$arr;
168 $hookParams['texts'] = &$arr2;
169 plugin_hook ("activity", $hookParams) ;
172 return html_build_select_box_from_arrays ($arr,$arr2,$name,$selected,false);
175 function report_tracker_box($name='datatype', $selected='1') {
176 if (forge_get_config('use_tracker')) {
180 $arr[]=_('Feature Requests');
181 $arr[]=_('Other Trackers');
188 if (forge_get_config('use_forum')) {
189 $arr[]=_('Forum Messages');
192 if (forge_get_config('use_pm')) {
196 if (forge_get_config('use_frs')) {
197 $arr[]=_('Downloads');
200 return html_build_select_box_from_arrays ($arr2,$arr,$name,$selected,false);
203 function report_time_category_box($name='category',$selected=false) {
204 global $report_time_category_res;
205 if (!$report_time_category_res) {
206 $report_time_category_res = db_query_params ('SELECT * FROM rep_time_category',
209 return html_build_select_box($report_time_category_res,$name,$selected,false);
213 // Takes an array of labels and an array values and removes vals < 2% and sets up an "other"
215 function report_pie_arr($labels, $vals, $format=1) {
216 global $pie_labels,$pie_vals;
217 //first get sum of all values
218 for ($i=0; $i<count($vals); $i++) {
222 //now prune out vals where < 2%
224 for ($i=0; $i<count($vals); $i++) {
225 if (($vals[$i]/$total) < .02) {
228 $pie_labels[]=utf8_decode(util_unconvert_htmlspecialchars($labels[$i]))." (". number_format($vals[$i],$format) .") ";
229 $pie_vals[]=$vals[$i];
233 $pie_labels[]=_('Other')." (". number_format($rem,$format) .") ";
239 function report_package_box($group_id, $name='dev_id', $selected='') {
241 $res = db_query_params ('SELECT package_id, name FROM frs_package WHERE frs_package.group_id = $1',
243 return html_build_select_box($res, $name, $selected, false);
248 // c-file-style: "bsd"