2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # MantisBT is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
18 * This include file prints out the bug bugnote_stats
19 * $f_bug_id must already be defined
22 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
23 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
24 * @link http://www.mantisbt.org
26 * @uses bugnote_api.php
27 * @uses collapse_api.php
28 * @uses config_api.php
29 * @uses database_api.php
30 * @uses filter_api.php
32 * @uses helper_api.php
34 * @uses string_api.php
35 * @uses utility_api.php
38 if ( !defined( 'BILLING_INC_ALLOW' ) ) {
42 require_api( 'bugnote_api.php' );
43 require_api( 'collapse_api.php' );
44 require_api( 'config_api.php' );
45 require_api( 'database_api.php' );
46 require_api( 'filter_api.php' );
47 require_api( 'gpc_api.php' );
48 require_api( 'helper_api.php' );
49 require_api( 'lang_api.php' );
50 require_api( 'string_api.php' );
51 require_api( 'utility_api.php' );
54 <a id
="bugnotestats"></a
><br
/>
56 collapse_open( 'bugnotestats' );
58 $t_today = date( "d:m:Y" );
59 $t_date_submitted = isset( $t_bug ) ?
date( "d:m:Y", $t_bug->date_submitted
) : $t_today;
61 $t_bugnote_stats_from_def = $t_date_submitted;
62 $t_bugnote_stats_from_def_ar = explode ( ":", $t_bugnote_stats_from_def );
63 $t_bugnote_stats_from_def_d = $t_bugnote_stats_from_def_ar[0];
64 $t_bugnote_stats_from_def_m = $t_bugnote_stats_from_def_ar[1];
65 $t_bugnote_stats_from_def_y = $t_bugnote_stats_from_def_ar[2];
67 $t_bugnote_stats_from_d = gpc_get_int('start_day', $t_bugnote_stats_from_def_d);
68 $t_bugnote_stats_from_m = gpc_get_int('start_month', $t_bugnote_stats_from_def_m);
69 $t_bugnote_stats_from_y = gpc_get_int('start_year', $t_bugnote_stats_from_def_y);
71 $t_bugnote_stats_to_def = $t_today;
72 $t_bugnote_stats_to_def_ar = explode ( ":", $t_bugnote_stats_to_def );
73 $t_bugnote_stats_to_def_d = $t_bugnote_stats_to_def_ar[0];
74 $t_bugnote_stats_to_def_m = $t_bugnote_stats_to_def_ar[1];
75 $t_bugnote_stats_to_def_y = $t_bugnote_stats_to_def_ar[2];
77 $t_bugnote_stats_to_d = gpc_get_int('end_day', $t_bugnote_stats_to_def_d);
78 $t_bugnote_stats_to_m = gpc_get_int('end_month', $t_bugnote_stats_to_def_m);
79 $t_bugnote_stats_to_y = gpc_get_int('end_year', $t_bugnote_stats_to_def_y);
81 $f_get_bugnote_stats_button = gpc_get_string('get_bugnote_stats_button', '');
82 $f_bugnote_cost = gpc_get_int( 'bugnote_cost', '' );
83 $f_project_id = helper_get_current_project();
85 if ( ON
== config_get( 'time_tracking_with_billing' ) ) {
92 <form method
="post" action
="">
93 <?php
# CSRF protection not required here - form does not result in modifications ?>
94 <input type
="hidden" name
="id" value
="<?php echo isset( $f_bug_id ) ? $f_bug_id : 0 ?>" />
95 <table
class="width100" cellspacing
="0">
97 <td
class="form-title" colspan
="4">
99 collapse_icon( 'bugnotestats' );
101 <?php
echo lang_get( 'time_tracking' ) ?
>
105 <td
class="category" width
="25%">
108 $t_filter[FILTER_PROPERTY_FILTER_BY_DATE
] = 'on';
109 $t_filter[FILTER_PROPERTY_START_DAY
] = $t_bugnote_stats_from_d;
110 $t_filter[FILTER_PROPERTY_START_MONTH
] = $t_bugnote_stats_from_m;
111 $t_filter[FILTER_PROPERTY_START_YEAR
] = $t_bugnote_stats_from_y;
112 $t_filter[FILTER_PROPERTY_END_DAY
] = $t_bugnote_stats_to_d;
113 $t_filter[FILTER_PROPERTY_END_MONTH
] = $t_bugnote_stats_to_m;
114 $t_filter[FILTER_PROPERTY_END_YEAR
] = $t_bugnote_stats_to_y;
115 print_filter_do_filter_by_date(true);
119 <?php
if ( $t_cost_col ) { ?
>
122 <?php
echo lang_get( 'time_tracking_cost_label' ) ?
>
123 <input type
="text" name
="bugnote_cost" value
="<?php echo $f_bugnote_cost ?>" />
128 <td
class="center" colspan
="2">
129 <input type
="submit" class="button" name
="get_bugnote_stats_button" value
="<?php echo lang_get( 'time_tracking_get_info_button' ) ?>" />
136 if ( !is_blank( $f_get_bugnote_stats_button ) ) {
137 $t_from = "$t_bugnote_stats_from_y-$t_bugnote_stats_from_m-$t_bugnote_stats_from_d";
138 $t_to = "$t_bugnote_stats_to_y-$t_bugnote_stats_to_m-$t_bugnote_stats_to_d";
139 $t_bugnote_stats = bugnote_stats_get_project_array( $f_project_id, $t_from, $t_to, $f_bugnote_cost );
141 if ( is_blank( $f_bugnote_cost ) ||
( (double)$f_bugnote_cost == 0 ) ) {
148 <table
class="width100" cellspacing
="0">
149 <tr
class="row-category-history">
150 <td
class="small-caption">
151 <?php
echo lang_get( 'username' ) ?
>
153 <td
class="small-caption">
154 <?php
echo lang_get( 'time_tracking' ) ?
>
156 <?php
if ( $t_cost_col) { ?
>
157 <td
class="small-caption">
158 <?php
echo lang_get( 'time_tracking_cost' ) ?
>
164 $t_sum_in_minutes = 0;
165 $t_user_summary = array();
167 foreach ( $t_bugnote_stats as $t_item ) {
168 $t_sum_in_minutes +
= $t_item['sum_time_tracking'];
169 $t_user_summary[$t_item['username']] +
= $t_item['sum_time_tracking'];
171 $t_item['sum_time_tracking'] = db_minutes_to_hhmm( $t_item['sum_time_tracking'] );
172 if ( $t_item['bug_id'] != $t_prev_id) {
173 $t_link = sprintf( lang_get( 'label' ), string_get_bug_view_link( $t_item['bug_id'] ) ) . lang_get( 'word_separator' ) . string_display( $t_item['summary'] );
174 echo '<tr class="row-category-history"><td colspan="4">' . $t_link . "</td></tr>";
175 $t_prev_id = $t_item['bug_id'];
178 <tr
<?php
echo helper_alternate_class() ?
>>
179 <td
class="small-caption">
180 <?php
echo $t_item['username'] ?
>
182 <td
class="small-caption">
183 <?php
echo $t_item['sum_time_tracking'] ?
>
185 <?php
if ($t_cost_col) { ?
>
187 <?php
echo string_attribute( number_format( $t_item['cost'], 2 ) ); ?
>
191 <?php
} # end for loop
193 <tr
<?php
echo helper_alternate_class() ?
>>
194 <td
class="small-caption">
195 <?php
echo lang_get( 'total_time' ); ?
>
197 <td
class="small-caption">
198 <?php
echo db_minutes_to_hhmm( $t_sum_in_minutes ); ?
>
200 <?php
if ($t_cost_col) { ?
>
202 <?php
echo string_attribute( number_format( $t_sum_in_minutes * $f_bugnote_cost / 60, 2 ) ); ?
>
211 <table
class="width100" cellspacing
="0">
212 <tr
class="row-category-history">
213 <td
class="small-caption">
214 <?php
echo lang_get( 'username' ) ?
>
216 <td
class="small-caption">
217 <?php
echo lang_get( 'time_tracking' ) ?
>
219 <?php
if ( $t_cost_col) { ?
>
220 <td
class="small-caption">
221 <?php
echo lang_get( 'time_tracking_cost' ) ?
>
226 foreach ( $t_user_summary as $t_username => $t_total_time ) {
228 <tr
<?php
echo helper_alternate_class() ?
>>
229 <td
class="small-caption">
230 <?php
echo $t_username; ?
>
232 <td
class="small-caption">
233 <?php
echo db_minutes_to_hhmm($t_total_time); ?
>
235 <?php
if ($t_cost_col) { ?
>
237 <?php
echo string_attribute( number_format( $t_total_time * $f_bugnote_cost / 60, 2 ) ); ?
>
242 <tr
<?php
echo helper_alternate_class() ?
>>
243 <td
class="small-caption">
244 <?php
echo lang_get( 'total_time' ); ?
>
246 <td
class="small-caption">
247 <?php
echo db_minutes_to_hhmm( $t_sum_in_minutes ); ?
>
249 <?php
if ($t_cost_col) { ?
>
251 <?php
echo string_attribute( number_format( $t_sum_in_minutes * $f_bugnote_cost / 60, 2 ) ); ?
>
257 collapse_closed( 'bugnotestats' );
259 <table
class="width100" cellspacing
="0">
261 <td
class="form-title" colspan
="4">
262 <?php
collapse_icon( 'bugnotestats' );
263 echo lang_get( 'time_tracking' ) ?
>
268 collapse_end( 'bugnotestats' );