1<?php 2# MantisBT - A PHP based bugtracking system 3 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. 8# 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. 13# 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/>. 16 17/** 18 * This include file prints out the bug bugnote_stats 19 * $f_bug_id must already be defined 20 * 21 * @package MantisBT 22 * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 23 * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net 24 * @link http://www.mantisbt.org 25 * 26 * @uses bugnote_api.php 27 * @uses collapse_api.php 28 * @uses config_api.php 29 * @uses constant_inc.php 30 * @uses filter_api.php 31 * @uses gpc_api.php 32 * @uses helper_api.php 33 * @uses lang_api.php 34 * @uses utility_api.php 35 */ 36 37if( !defined( 'BUGNOTE_STATS_INC_ALLOW' ) ) { 38 return; 39} 40 41require_api( 'bugnote_api.php' ); 42require_api( 'collapse_api.php' ); 43require_api( 'config_api.php' ); 44require_api( 'constant_inc.php' ); 45require_api( 'filter_api.php' ); 46require_api( 'gpc_api.php' ); 47require_api( 'helper_api.php' ); 48require_api( 'lang_api.php' ); 49require_api( 'utility_api.php' ); 50 51if( OFF == config_get( 'time_tracking_enabled' ) ) { 52 return; 53} 54?> 55 56<?php 57 58$t_bugnote_stats_from_def = date( 'd:m:Y', $t_bug->date_submitted ); 59$t_bugnote_stats_from_def_ar = explode( ':', $t_bugnote_stats_from_def ); 60$t_bugnote_stats_from_def_d = $t_bugnote_stats_from_def_ar[0]; 61$t_bugnote_stats_from_def_m = $t_bugnote_stats_from_def_ar[1]; 62$t_bugnote_stats_from_def_y = $t_bugnote_stats_from_def_ar[2]; 63 64$t_bugnote_stats_from_d = gpc_get_string( FILTER_PROPERTY_DATE_SUBMITTED_START_DAY, $t_bugnote_stats_from_def_d ); 65$t_bugnote_stats_from_m = gpc_get_string( FILTER_PROPERTY_DATE_SUBMITTED_START_MONTH, $t_bugnote_stats_from_def_m ); 66$t_bugnote_stats_from_y = gpc_get_string( FILTER_PROPERTY_DATE_SUBMITTED_START_YEAR, $t_bugnote_stats_from_def_y ); 67 68$t_bugnote_stats_to_def = date( 'd:m:Y' ); 69$t_bugnote_stats_to_def_ar = explode( ':', $t_bugnote_stats_to_def ); 70$t_bugnote_stats_to_def_d = $t_bugnote_stats_to_def_ar[0]; 71$t_bugnote_stats_to_def_m = $t_bugnote_stats_to_def_ar[1]; 72$t_bugnote_stats_to_def_y = $t_bugnote_stats_to_def_ar[2]; 73 74$t_bugnote_stats_to_d = gpc_get_string( FILTER_PROPERTY_DATE_SUBMITTED_END_DAY, $t_bugnote_stats_to_def_d ); 75$t_bugnote_stats_to_m = gpc_get_string( FILTER_PROPERTY_DATE_SUBMITTED_END_MONTH, $t_bugnote_stats_to_def_m ); 76$t_bugnote_stats_to_y = gpc_get_string( FILTER_PROPERTY_DATE_SUBMITTED_END_YEAR, $t_bugnote_stats_to_def_y ); 77 78$f_get_bugnote_stats_button = gpc_get_string( 'get_bugnote_stats_button', '' ); 79 80$t_collapse_block = is_collapsed( 'bugnotestats' ); 81$t_block_css = $t_collapse_block ? 'collapsed' : ''; 82$t_block_icon = $t_collapse_block ? 'fa-chevron-down' : 'fa-chevron-up'; 83 84# Time tracking date range input form 85# CSRF protection not required here - form does not result in modifications 86?> 87<div class="col-md-12 col-xs-12 noprint"> 88 <a id="bugnotestats"></a> 89 <div class="space-10"></div> 90 <div id="bugnotestats" class="widget-box widget-color-blue2 <?php echo $t_block_css ?>"> 91 92 <div class="widget-header widget-header-small"> 93 <h4 class="widget-title lighter"> 94 <?php print_icon( 'fa-clock-o', 'ace-icon' ); ?> 95 <?php echo lang_get( 'time_tracking' ) ?> 96 </h4> 97 <div class="widget-toolbar"> 98 <a data-action="collapse" href="#"> 99 <?php print_icon( $t_block_icon, '1 ace-icon bigger-125' ); ?> 100 </a> 101 </div> 102 </div> 103 104 <form method="post" action="#bugnotestats"> 105 <div class="widget-body"> 106 <div class="widget-main"> 107 <input type="hidden" name="id" value="<?php echo $f_bug_id ?>" /> 108 <?php 109 $t_filter = array(); 110 $t_filter[FILTER_PROPERTY_FILTER_BY_DATE_SUBMITTED] = 'on'; 111 $t_filter[FILTER_PROPERTY_DATE_SUBMITTED_START_DAY] = $t_bugnote_stats_from_d; 112 $t_filter[FILTER_PROPERTY_DATE_SUBMITTED_START_MONTH] = $t_bugnote_stats_from_m; 113 $t_filter[FILTER_PROPERTY_DATE_SUBMITTED_START_YEAR] = $t_bugnote_stats_from_y; 114 $t_filter[FILTER_PROPERTY_DATE_SUBMITTED_END_DAY] = $t_bugnote_stats_to_d; 115 $t_filter[FILTER_PROPERTY_DATE_SUBMITTED_END_MONTH] = $t_bugnote_stats_to_m; 116 $t_filter[FILTER_PROPERTY_DATE_SUBMITTED_END_YEAR] = $t_bugnote_stats_to_y; 117 filter_init( $t_filter ); 118 print_filter_do_filter_by_date( true ); 119 ?> 120 </div> 121 <div class="widget-toolbox padding-8 clearfix"> 122 <input name="get_bugnote_stats_button" class="btn btn-primary btn-sm btn-white btn-round" 123 value="<?php echo lang_get( 'time_tracking_get_info_button' ) ?>" type="submit"> 124 </div> 125 </div> 126 </form> 127<?php 128 # Print time tracking information if requested 129 if( !is_blank( $f_get_bugnote_stats_button ) ) { 130 # Retrieve time tracking information 131 $t_from = $t_bugnote_stats_from_y . '-' . $t_bugnote_stats_from_m . '-' . $t_bugnote_stats_from_d; 132 $t_to = $t_bugnote_stats_to_y . '-' . $t_bugnote_stats_to_m . '-' . $t_bugnote_stats_to_d; 133 $t_bugnote_stats = bugnote_stats_get_events_array( $f_bug_id, $t_from, $t_to ); 134 135 # Sort the array by user name 136 $t_sort_name = array(); 137 foreach ( $t_bugnote_stats as $t_key => $t_item ) { 138 $t_sort_name[$t_key] = user_get_name_for_sorting_from_row( $t_item ); 139 } 140 141 array_multisort( $t_sort_name, $t_bugnote_stats ); 142 unset( $t_sort_name ); 143?> 144 145 <div class="space-10"></div> 146 <div class="table-responsive"> 147 <table class="table table-bordered table-condensed table-striped"> 148 <tr> 149 <td class="small-caption align-left"> 150 <?php echo lang_get( 'username' ) ?> 151 </td> 152 <td class="small-caption align-left"> 153 <?php echo lang_get( 'time_tracking' ) ?> 154 </td> 155 </tr> 156 <?php 157 # Loop on all time tracking entries 158 $t_sum_in_minutes = 0; 159 foreach ( $t_bugnote_stats as $t_item ) { 160 $t_sum_in_minutes += $t_item['sum_time_tracking']; 161 $t_item['sum_time_tracking'] = db_minutes_to_hhmm( $t_item['sum_time_tracking'] ); 162 ?> 163 <tr> 164 <td class="small-caption"> 165 <?php print_user( $t_item['user_id'] ) ?> 166 </td> 167 <td class="small-caption"> 168 <?php echo $t_item['sum_time_tracking'] ?> 169 </td> 170 </tr> 171 <?php 172 } # end for loop 173 ?> 174 <tr> 175 <td class="small-caption"> 176 <?php echo lang_get( 'total_time' ) ?> 177 </td> 178 <td class="small-caption"> 179 <?php echo db_minutes_to_hhmm( $t_sum_in_minutes ) ?> 180 </td> 181 </tr> 182 </table> 183 </div> 184<?php 185 } # end if 186?> 187 </div> 188</div> 189 190