View Issue Details

IDProjectCategoryView StatusLast Update
0010675mantisbttime trackingpublic2016-06-23 22:21
Reporterreinform Assigned To 
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status newResolutionopen 
Product Version1.2.0a2 
Summary0010675: Made enhancement to the billing page
Description

we made some enhancements to the billing page and add the patches for
Mantis BT V 1.1.4 (which we are currently using) and the latest Mantis
BT 1.2.0a2-2009-07-02-master-4eaeb80.

  • added new listbox where you can select ONE reporter for which you want
    the billing; alternatively you can get the report for ALL reporters;
    this is the default and same as the known behaviour

  • the listbox is only visible for users with the appropriate rights
    (configurable in the config file)

  • users which can generate reports (thus visit the reporting page) but
    do not have that right, just get a report for themselves

Tagspatch
Attached Files
mantisbt--1.2.0a2-2009-07-02-master-4eaeb80.diff (8,154 bytes)   
diff -r -u mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/billing_inc.php mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/billing_inc.php
--- mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/billing_inc.php	2009-07-02 17:10:35.000000000 +0200
+++ mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/billing_inc.php	2009-07-02 17:10:21.000000000 +0200
@@ -64,6 +64,14 @@
 	$t_bugnote_stats_to_y = gpc_get_int('end_year', $t_bugnote_stats_to_def_y);
 
 	$f_get_bugnote_stats_button = gpc_get_string('get_bugnote_stats_button', '');
+	if ( access_has_project_level( config_get( 'time_tracking_reporting_select_reporter_threshold' ) ) ) {
+		$t_select_reporter = true;
+		$f_reporter_id = gpc_get_int( 'reporter_id', ALL_USERS );
+	}
+	else {
+		$t_select_reporter = false;
+		$f_reporter_id = auth_get_current_user_id();
+	}
 	$f_bugnote_cost = gpc_get_int( 'bugnote_cost', '' );
 	$f_project_id = helper_get_current_project();
 
@@ -76,17 +84,21 @@
 ?>
 <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
 <input type="hidden" name="id" value="<?php echo isset( $f_bug_id ) ? $f_bug_id : 0 ?>" />
-<table border=0 class="width100" cellspacing="0">
+<table align="center" class="width75" cellspacing="1">
 <tr>
-	<td class="form-title" colspan="4">
+	<td class="form-title" colspan="2">
 <?php
 		collapse_icon( 'bugnotestats' );
 ?>
 		<?php echo lang_get( 'time_tracking' ) ?>
 	</td>
 </tr>
-<tr class="row-2">
-        <td class="category" width="25%">
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category" width="20%">
+		<?php echo lang_get( 'time_tracking_period' ) ?>
+	</td>
+	<td>
+
                 <?php
 		$t_filter = array();
 		$t_filter['do_filter_by_date'] = 'on';
@@ -100,11 +112,26 @@
 		?>
         </td>
 </tr>
+<?php if ( $t_select_reporter ) { ?>
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'username' ) ?>
+	</td>
+	<td>
+		<select <?php echo helper_get_tab_index() ?> name="reporter_id">
+			<option value="0" selected="selected"></option>
+			<?php print_assign_to_option_list( $f_reporter_id ) ?>
+		</select>
+	</td>
+</tr>
+<?php } ?>
 <?php if ( $t_cost_col ) { ?>
-<tr class="row-1">
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'time_tracking_cost' ) ?>
+	</td>
 	<td>
-		<?php echo lang_get( 'time_tracking_cost' ) ?>:
-		<input type="text" name="bugnote_cost" value="<?php echo $f_bugnote_cost ?>" />
+		<input type="text" <?php echo helper_get_tab_index() ?> name="bugnote_cost" value="<?php echo $f_bugnote_cost ?>" />
 	</td>
 </tr>
 <?php } ?>
@@ -120,7 +147,7 @@
 if ( !is_blank( $f_get_bugnote_stats_button ) ) {
 	$t_from = "$t_bugnote_stats_from_y-$t_bugnote_stats_from_m-$t_bugnote_stats_from_d";
 	$t_to = "$t_bugnote_stats_to_y-$t_bugnote_stats_to_m-$t_bugnote_stats_to_d";
-	$t_bugnote_stats = bugnote_stats_get_project_array( $f_project_id, $t_from, $t_to, $f_bugnote_cost );
+	$t_bugnote_stats = bugnote_stats_get_project_array( $f_project_id, $t_from, $t_to, $f_reporter_id, $f_bugnote_cost );
 
 	if ( is_blank( $f_bugnote_cost ) || ( (double)$f_bugnote_cost == 0 ) ) {
 		$t_cost_col = false;
diff -r -u mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/config_defaults_inc.php mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/config_defaults_inc.php
--- mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/config_defaults_inc.php	2009-07-02 17:08:57.000000000 +0200
+++ mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/config_defaults_inc.php	2009-07-02 17:09:08.000000000 +0200
@@ -2012,6 +2012,9 @@
 	# access level required to run reports
 	$g_time_tracking_reporting_threshold = DEVELOPER;
 
+	# access level required to select reporter when running reports
+	$g_time_tracking_reporting_select_reporter_threshold = MANAGER;
+
 	#allow time tracking to be recorded without a bugnote
 	$g_time_tracking_without_note = ON;
 
diff -r -u mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/core/bugnote_api.php mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/core/bugnote_api.php
--- mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/core/bugnote_api.php	2009-06-24 10:04:53.000000000 +0200
+++ mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/core/bugnote_api.php	2009-07-02 16:59:21.000000000 +0200
@@ -599,14 +599,16 @@
  * @param int $p_project_id project id
  * @param string $p_from Starting date (yyyy-mm-dd) inclusive, if blank, then ignored.
  * @param string $p_to Ending date (yyyy-mm-dd) inclusive, if blank, then ignored.
+ * @param int $p_reporter_id
  * @param int $p_cost cost
  * @return array array of bugnote stats
  * @access public
  */
-function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost ) {
+function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_reporter_id, $p_cost ) {
 	$c_project_id = db_prepare_int( $p_project_id );
 	$c_to = db_bind_timestamp( $p_to . ' 23:59:59' );
 	$c_from = db_bind_timestamp( $p_from . ' 00:00:00' );
+	$c_reporter_id = db_prepare_int( $p_reporter_id );
 	$c_cost = db_prepare_double( $p_cost );
 
 	// MySQL
@@ -627,17 +629,23 @@
 	}
 
 	if( ALL_PROJECTS != $c_project_id ) {
-		$t_project_where = " AND b.project_id = '$c_project_id' AND bn.bug_id = b.id ";
+		$t_project_where = " AND b.project_id = '$c_project_id' AND bn.bug_id = b.id";
 	} else {
 		$t_project_where = '';
 	}
 
+	if ( ALL_USERS != $c_reporter_id ) {
+		$t_reporter_where = " AND bn.reporter_id = '$c_reporter_id'";
+	} else {
+		$t_reporter_where = '';
+	}
+
 	$t_results = array();
 
 	$query = "SELECT username, summary, bn.bug_id, SUM(time_tracking) AS sum_time_tracking
 			FROM $t_user_table u, $t_bugnote_table bn, $t_bug_table b
 			WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = b.id
-			$t_project_where $t_from_where $t_to_where
+			$t_project_where $t_from_where $t_to_where $t_reporter_where
 			GROUP BY bn.bug_id, u.id, u.username, b.summary
 			ORDER BY bn.bug_id";
 
diff -r -u mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/lang/strings_german_8859-1.txt mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/lang/strings_german_8859-1.txt
--- mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/lang/strings_german_8859-1.txt	2009-06-23 10:06:29.000000000 +0200
+++ mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/lang/strings_german_8859-1.txt	2009-07-02 16:32:38.000000000 +0200
@@ -1450,6 +1450,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit f�r den Eintrag = %s';
 
 $s_access_denied = $MANTIS_ERROR[ERROR_ACCESS_DENIED];
diff -r -u mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/lang/strings_german_eintrag.txt mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/lang/strings_german_eintrag.txt
--- mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/lang/strings_german_eintrag.txt	2009-06-23 10:06:29.000000000 +0200
+++ mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/lang/strings_german_eintrag.txt	2009-07-02 16:32:38.000000000 +0200
@@ -1449,6 +1449,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit für den Eintrag = %s';
 
 $s_access_denied = $MANTIS_ERROR[ERROR_ACCESS_DENIED];
diff -r -u mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/lang/strings_german.txt mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/lang/strings_german.txt
--- mantisbt-1.2.0a2-2009-07-02-master-4eaeb80.org/lang/strings_german.txt	2009-06-24 10:04:53.000000000 +0200
+++ mantisbt-1.2.0a2-2009-07-02-master-4eaeb80/lang/strings_german.txt	2009-07-02 16:32:38.000000000 +0200
@@ -1147,6 +1147,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit für den Eintrag = %s';
 $s_access_denied = 'Zugriff verweigert.';
 $s_twitter_resolved = '%d: [%s] %s (erledigt von %s in %s)';
mantisbt-1.1.4.diff (7,045 bytes)   
diff -r -u mantis.org/billing_inc.php mantis/billing_inc.php
--- mantis.org/billing_inc.php	2008-05-22 04:50:55.000000000 +0200
+++ mantis/billing_inc.php	2009-07-02 14:43:43.000000000 +0200
@@ -65,6 +65,14 @@
 	$t_bugnote_stats_to_y = gpc_get_int('end_year', $t_bugnote_stats_to_def_y);
 
 	$f_get_bugnote_stats_button = gpc_get_string('get_bugnote_stats_button', '');
+	if ( access_has_project_level( config_get( 'time_tracking_reporting_select_reporter_threshold' ) ) ) {
+		$t_select_reporter = true;
+		$f_reporter_id = gpc_get_int( 'reporter_id', ALL_USERS );
+	}
+	else {
+		$t_select_reporter = false;
+		$f_reporter_id = auth_get_current_user_id();
+	}
 	$f_bugnote_cost = gpc_get_int( 'bugnote_cost', '' );
 	$f_project_id = helper_get_current_project();
 
@@ -77,17 +85,20 @@
 ?>
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 <input type="hidden" name="id" value="<?php echo isset( $f_bug_id ) ? $f_bug_id : 0 ?>" />
-<table border="0" class="width100" cellspacing="0">
+<table align="center" class="width75" cellspacing="1">
 <tr>
-	<td class="form-title" colspan="4">
+	<td class="form-title" colspan="2">
 <?php
 		collapse_icon( 'bugnotestats' );
 ?>
 		<?php echo lang_get( 'time_tracking' ) ?>
 	</td>
 </tr>
-<tr class="row-2">
-        <td class="category" width="25%">
+<tr <?php echo helper_alternate_class() ?>>
+        <td class="category" width="20%">
+		<?php echo lang_get( 'time_tracking_period' ) ?>
+	</td>
+	<td>
                 <?php
 		$t_filter = array();
 		$t_filter['do_filter_by_date'] = 'on';
@@ -101,11 +112,26 @@
 		?>
         </td>
 </tr>
+<?php if ( $t_select_reporter ) { ?>
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'username' ) ?>
+	</td>
+	<td>
+		<select <?php echo helper_get_tab_index() ?> name="reporter_id">
+			<option value="0" selected="selected"></option>
+			<?php print_assign_to_option_list( $f_reporter_id ) ?>
+		</select>
+	</td>
+</tr>
+<?php } ?>
 <?php if ( $t_cost_col ) { ?>
-<tr class="row-1">
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'time_tracking_cost' ) ?>
+	</td>
 	<td>
-		<?php echo lang_get( 'time_tracking_cost' ) ?>:
-		<input type="text" name="bugnote_cost" value="<?php echo $f_bugnote_cost ?>" />
+		<input type="text" <?php echo helper_get_tab_index() ?> name="bugnote_cost" value="<?php echo $f_bugnote_cost ?>" />
 	</td>
 </tr>
 <?php } ?>
@@ -121,7 +147,7 @@
 if ( !is_blank( $f_get_bugnote_stats_button ) ) {
 	$t_from = "$t_bugnote_stats_from_y-$t_bugnote_stats_from_m-$t_bugnote_stats_from_d";
 	$t_to = "$t_bugnote_stats_to_y-$t_bugnote_stats_to_m-$t_bugnote_stats_to_d";
-	$t_bugnote_stats = bugnote_stats_get_project_array( $f_project_id, $t_from, $t_to, $f_bugnote_cost );
+	$t_bugnote_stats = bugnote_stats_get_project_array( $f_project_id, $t_from, $t_to, $f_reporter_id, $f_bugnote_cost );
 
 	if ( is_blank( $f_bugnote_cost ) || ( (double)$f_bugnote_cost == 0 ) ) {
 		$t_cost_col = false;
diff -r -u mantis.org/config_defaults_inc.php mantis/config_defaults_inc.php
--- mantis.org/config_defaults_inc.php	2009-07-02 14:02:27.000000000 +0200
+++ mantis/config_defaults_inc.php	2009-07-02 14:22:17.000000000 +0200
@@ -1914,6 +1914,9 @@
 	# access level required to run reports
 	$g_time_tracking_reporting_threshold = MANAGER;
 
+	# access level required to select reporter when running reports
+	$g_time_tracking_reporting_select_reporter_threshold = MANAGER;
+
 	#allow time tracking to be recorded without a bugnote
 	$g_time_tracking_without_note = ON;
 
diff -r -u mantis.org/core/bugnote_api.php mantis/core/bugnote_api.php
--- mantis.org/core/bugnote_api.php	2008-07-13 00:23:36.000000000 +0200
+++ mantis/core/bugnote_api.php	2009-07-02 13:49:23.000000000 +0200
@@ -525,10 +525,11 @@
 	# Returns an array of bugnote stats
 	# $p_from - Starting date (yyyy-mm-dd) inclusive, if blank, then ignored.
 	# $p_to - Ending date (yyyy-mm-dd) inclusive, if blank, then ignored.
-	function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost ) {
+	function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_reporter_id, $p_cost ) {
 		$c_project_id = db_prepare_int( $p_project_id );
 		$c_to = db_prepare_date( $p_to );
 		$c_from = db_prepare_date( $p_from );
+		$c_reporter_id = db_prepare_int( $p_reporter_id );
 		$c_cost = db_prepare_double( $p_cost );
 
 		// MySQL
@@ -549,17 +550,23 @@
 		}
 
 		if ( ALL_PROJECTS != $c_project_id ) {
-			$t_project_where = " AND b.project_id = '$c_project_id' AND bn.bug_id = b.id ";
+			$t_project_where = " AND b.project_id = '$c_project_id' AND bn.bug_id = b.id";
 		} else {
 			$t_project_where = '';
 		}
 
+		if ( ALL_USERS != $c_reporter_id ) {
+			$t_reporter_where = " AND bn.reporter_id = '$c_reporter_id'";
+		} else {
+			$t_reporter_where = '';
+		}
+
 		$t_results = array();
 
 		$query = "SELECT username, summary, bn.bug_id, SUM(time_tracking) AS sum_time_tracking
 			FROM $t_user_table u, $t_bugnote_table bn, $t_bug_table b
 			WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = b.id
-			$t_project_where $t_from_where $t_to_where
+			$t_project_where $t_from_where $t_to_where $t_reporter_where
 			GROUP BY bn.bug_id, u.id, u.username, b.summary
 			ORDER BY bn.bug_id";
 
diff -r -u mantis.org/lang/strings_german_8859-1.txt mantis/lang/strings_german_8859-1.txt
--- mantis.org/lang/strings_german_8859-1.txt	2007-10-19 09:07:18.000000000 +0200
+++ mantis/lang/strings_german_8859-1.txt	2009-07-02 12:18:21.000000000 +0200
@@ -1412,6 +1412,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit f�r den Eintrag = %s';
 $s_from_date = 'Von';
 $s_to_date = 'Bis';
diff -r -u mantis.org/lang/strings_german_eintrag.txt mantis/lang/strings_german_eintrag.txt
--- mantis.org/lang/strings_german_eintrag.txt	2007-10-19 09:07:18.000000000 +0200
+++ mantis/lang/strings_german_eintrag.txt	2009-07-02 12:19:04.000000000 +0200
@@ -1413,6 +1413,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit für den Eintrag = %s';
 $s_from_date = 'Von';
 $s_to_date = 'Bis';
diff -r -u mantis.org/lang/strings_german.txt mantis/lang/strings_german.txt
--- mantis.org/lang/strings_german.txt	2007-10-19 09:07:18.000000000 +0200
+++ mantis/lang/strings_german.txt	2009-07-02 12:19:47.000000000 +0200
@@ -1412,6 +1412,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit für den Eintrag = %s';
 $s_from_date = 'Von';
 $s_to_date = 'Bis';
mantisbt-1.1.4.diff (7,045 bytes)   
TimeReport1.png (65,747 bytes)   
TimeReport1.png (65,747 bytes)   
TimeReport2.png (71,142 bytes)   
TimeReport2.png (71,142 bytes)   
mantisbt-1.1.4-version2.diff (7,073 bytes)   
diff -r -u mantis.org/billing_inc.php mantis/billing_inc.php
--- mantis.org/billing_inc.php	2008-05-22 04:50:55.000000000 +0200
+++ mantis/billing_inc.php	2009-08-03 14:11:25.000000000 +0200
@@ -65,6 +65,14 @@
 	$t_bugnote_stats_to_y = gpc_get_int('end_year', $t_bugnote_stats_to_def_y);
 
 	$f_get_bugnote_stats_button = gpc_get_string('get_bugnote_stats_button', '');
+	if ( access_has_project_level( config_get( 'time_tracking_reporting_select_reporter_threshold' ) ) ) {
+		$t_select_reporter = true;
+		$f_reporter_id = gpc_get_int( 'reporter_id', ALL_USERS );
+	}
+	else {
+		$t_select_reporter = false;
+		$f_reporter_id = auth_get_current_user_id();
+	}
 	$f_bugnote_cost = gpc_get_int( 'bugnote_cost', '' );
 	$f_project_id = helper_get_current_project();
 
@@ -77,17 +85,20 @@
 ?>
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 <input type="hidden" name="id" value="<?php echo isset( $f_bug_id ) ? $f_bug_id : 0 ?>" />
-<table border="0" class="width100" cellspacing="0">
+<table align="center" class="width75" cellspacing="1">
 <tr>
-	<td class="form-title" colspan="4">
+	<td class="form-title" colspan="2">
 <?php
 		collapse_icon( 'bugnotestats' );
 ?>
 		<?php echo lang_get( 'time_tracking' ) ?>
 	</td>
 </tr>
-<tr class="row-2">
-        <td class="category" width="25%">
+<tr <?php echo helper_alternate_class() ?>>
+        <td class="category" width="20%">
+		<?php echo lang_get( 'time_tracking_period' ) ?>
+	</td>
+	<td>
                 <?php
 		$t_filter = array();
 		$t_filter['do_filter_by_date'] = 'on';
@@ -101,11 +112,26 @@
 		?>
         </td>
 </tr>
+<?php if ( $t_select_reporter ) { ?>
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'username' ) ?>
+	</td>
+	<td>
+		<select <?php echo helper_get_tab_index() ?> name="reporter_id">
+			<option value="0" selected="selected"></option>
+			<?php print_reporter_option_list( $f_reporter_id, $f_project_id ) ?>
+		</select>
+	</td>
+</tr>
+<?php } ?>
 <?php if ( $t_cost_col ) { ?>
-<tr class="row-1">
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'time_tracking_cost' ) ?>
+	</td>
 	<td>
-		<?php echo lang_get( 'time_tracking_cost' ) ?>:
-		<input type="text" name="bugnote_cost" value="<?php echo $f_bugnote_cost ?>" />
+		<input type="text" <?php echo helper_get_tab_index() ?> name="bugnote_cost" value="<?php echo $f_bugnote_cost ?>" />
 	</td>
 </tr>
 <?php } ?>
@@ -121,7 +147,7 @@
 if ( !is_blank( $f_get_bugnote_stats_button ) ) {
 	$t_from = "$t_bugnote_stats_from_y-$t_bugnote_stats_from_m-$t_bugnote_stats_from_d";
 	$t_to = "$t_bugnote_stats_to_y-$t_bugnote_stats_to_m-$t_bugnote_stats_to_d";
-	$t_bugnote_stats = bugnote_stats_get_project_array( $f_project_id, $t_from, $t_to, $f_bugnote_cost );
+	$t_bugnote_stats = bugnote_stats_get_project_array( $f_project_id, $t_from, $t_to, $f_bugnote_cost, $f_reporter_id );
 
 	if ( is_blank( $f_bugnote_cost ) || ( (double)$f_bugnote_cost == 0 ) ) {
 		$t_cost_col = false;
diff -r -u mantis.org/config_defaults_inc.php mantis/config_defaults_inc.php
--- mantis.org/config_defaults_inc.php	2009-07-02 16:50:54.000000000 +0200
+++ mantis/config_defaults_inc.php	2009-08-03 14:11:25.000000000 +0200
@@ -1914,6 +1914,9 @@
 	# access level required to run reports
 	$g_time_tracking_reporting_threshold = DEVELOPER;
 
+	# access level required to select reporter when running reports
+	$g_time_tracking_reporting_select_reporter_threshold = MANAGER;
+
 	#allow time tracking to be recorded without a bugnote
 	$g_time_tracking_without_note = ON;
 
diff -r -u mantis.org/core/bugnote_api.php mantis/core/bugnote_api.php
--- mantis.org/core/bugnote_api.php	2008-07-13 00:23:36.000000000 +0200
+++ mantis/core/bugnote_api.php	2009-08-03 14:11:25.000000000 +0200
@@ -525,10 +525,11 @@
 	# Returns an array of bugnote stats
 	# $p_from - Starting date (yyyy-mm-dd) inclusive, if blank, then ignored.
 	# $p_to - Ending date (yyyy-mm-dd) inclusive, if blank, then ignored.
-	function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost ) {
+	function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost, $p_reporter_id = ALL_USERS ) {
 		$c_project_id = db_prepare_int( $p_project_id );
 		$c_to = db_prepare_date( $p_to );
 		$c_from = db_prepare_date( $p_from );
+		$c_reporter_id = db_prepare_int( $p_reporter_id );
 		$c_cost = db_prepare_double( $p_cost );
 
 		// MySQL
@@ -549,17 +550,23 @@
 		}
 
 		if ( ALL_PROJECTS != $c_project_id ) {
-			$t_project_where = " AND b.project_id = '$c_project_id' AND bn.bug_id = b.id ";
+			$t_project_where = " AND b.project_id = '$c_project_id' AND bn.bug_id = b.id";
 		} else {
 			$t_project_where = '';
 		}
 
+		if ( ALL_USERS != $c_reporter_id ) {
+			$t_reporter_where = " AND bn.reporter_id = '$c_reporter_id'";
+		} else {
+			$t_reporter_where = '';
+		}
+
 		$t_results = array();
 
 		$query = "SELECT username, summary, bn.bug_id, SUM(time_tracking) AS sum_time_tracking
 			FROM $t_user_table u, $t_bugnote_table bn, $t_bug_table b
 			WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = b.id
-			$t_project_where $t_from_where $t_to_where
+			$t_project_where $t_from_where $t_to_where $t_reporter_where
 			GROUP BY bn.bug_id, u.id, u.username, b.summary
 			ORDER BY bn.bug_id";
 
diff -r -u mantis.org/lang/strings_german_8859-1.txt mantis/lang/strings_german_8859-1.txt
--- mantis.org/lang/strings_german_8859-1.txt	2007-10-19 09:07:18.000000000 +0200
+++ mantis/lang/strings_german_8859-1.txt	2009-08-03 14:11:25.000000000 +0200
@@ -1412,6 +1412,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit f�r den Eintrag = %s';
 $s_from_date = 'Von';
 $s_to_date = 'Bis';
diff -r -u mantis.org/lang/strings_german_eintrag.txt mantis/lang/strings_german_eintrag.txt
--- mantis.org/lang/strings_german_eintrag.txt	2007-10-19 09:07:18.000000000 +0200
+++ mantis/lang/strings_german_eintrag.txt	2009-08-03 14:11:25.000000000 +0200
@@ -1413,6 +1413,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit für den Eintrag = %s';
 $s_from_date = 'Von';
 $s_to_date = 'Bis';
diff -r -u mantis.org/lang/strings_german.txt mantis/lang/strings_german.txt
--- mantis.org/lang/strings_german.txt	2007-10-19 09:07:18.000000000 +0200
+++ mantis/lang/strings_german.txt	2009-08-03 14:11:25.000000000 +0200
@@ -1412,6 +1412,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit für den Eintrag = %s';
 $s_from_date = 'Von';
 $s_to_date = 'Bis';
mantisbt-1.1.4-version2.diff (7,073 bytes)   
mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.diff (7,804 bytes)   
diff -r -u mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.org/billing_inc.php mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22/billing_inc.php
--- mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.org/billing_inc.php	2009-07-22 10:04:12.000000000 +0200
+++ mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22/billing_inc.php	2009-08-03 14:47:10.000000000 +0200
@@ -62,6 +62,14 @@
 	$t_bugnote_stats_to_y = gpc_get_int('end_year', $t_bugnote_stats_to_def_y);
 
 	$f_get_bugnote_stats_button = gpc_get_string('get_bugnote_stats_button', '');
+	if ( access_has_project_level( config_get( 'time_tracking_reporting_select_reporter_threshold' ) ) ) {
+		$t_select_reporter = true;
+		$f_reporter_id = gpc_get_int( 'reporter_id', ALL_USERS );
+	}
+	else {
+		$t_select_reporter = false;
+		$f_reporter_id = auth_get_current_user_id();
+	}
 	$f_bugnote_cost = gpc_get_int( 'bugnote_cost', '' );
 	$f_project_id = helper_get_current_project();
 
@@ -75,17 +83,20 @@
 <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
 <?php # CSRF protection not required here - form does not result in modifications ?>
 <input type="hidden" name="id" value="<?php echo isset( $f_bug_id ) ? $f_bug_id : 0 ?>" />
-<table border="0" class="width100" cellspacing="0">
+<table align="center" class="width75" cellspacing="1">
 <tr>
-	<td class="form-title" colspan="4">
+	<td class="form-title" colspan="2">
 <?php
 		collapse_icon( 'bugnotestats' );
 ?>
 		<?php echo lang_get( 'time_tracking' ) ?>
 	</td>
 </tr>
-<tr class="row-2">
-        <td class="category" width="25%">
+<tr <?php echo helper_alternate_class() ?>>
+        <td class="category" width="20%">
+		<?php echo lang_get( 'time_tracking_period' ) ?>
+	</td>
+	<td>
                 <?php
 		$t_filter = array();
 		$t_filter['do_filter_by_date'] = 'on';
@@ -99,11 +110,26 @@
 		?>
         </td>
 </tr>
+<?php if ( $t_select_reporter ) { ?>
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'username' ) ?>
+	</td>
+	<td>
+		<select <?php echo helper_get_tab_index() ?> name="reporter_id">
+			<option value="0" selected="selected"></option>
+			<?php print_reporter_option_list( $f_reporter_id, $f_project_id ) ?>
+		</select>
+	</td>
+</tr>
+<?php } ?>
 <?php if ( $t_cost_col ) { ?>
-<tr class="row-1">
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'time_tracking_cost' ) ?>
+	</td>
 	<td>
-		<?php echo lang_get( 'time_tracking_cost' ) ?>:
-		<input type="text" name="bugnote_cost" value="<?php echo $f_bugnote_cost ?>" />
+		<input type="text" <?php echo helper_get_tab_index() ?> name="bugnote_cost" value="<?php echo $f_bugnote_cost ?>" />
 	</td>
 </tr>
 <?php } ?>
@@ -119,7 +145,7 @@
 if ( !is_blank( $f_get_bugnote_stats_button ) ) {
 	$t_from = "$t_bugnote_stats_from_y-$t_bugnote_stats_from_m-$t_bugnote_stats_from_d";
 	$t_to = "$t_bugnote_stats_to_y-$t_bugnote_stats_to_m-$t_bugnote_stats_to_d";
-	$t_bugnote_stats = bugnote_stats_get_project_array( $f_project_id, $t_from, $t_to, $f_bugnote_cost );
+	$t_bugnote_stats = bugnote_stats_get_project_array( $f_project_id, $t_from, $t_to, $f_bugnote_cost, $f_reporter_id );
 
 	if ( is_blank( $f_bugnote_cost ) || ( (double)$f_bugnote_cost == 0 ) ) {
 		$t_cost_col = false;
diff -r -u mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.org/config_defaults_inc.php mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22/config_defaults_inc.php
--- mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.org/config_defaults_inc.php	2009-08-03 10:03:23.000000000 +0200
+++ mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22/config_defaults_inc.php	2009-08-03 15:08:56.000000000 +0200
@@ -3608,6 +3608,12 @@
 	$g_time_tracking_reporting_threshold = MANAGER;
 
 	/**
+	 * access level required to select reporter when running reports
+	 * @global int $g_time_tracking_reporting_threshold
+	 */
+	$g_time_tracking_reporting_select_reporter_threshold = MANAGER;
+
+	/**
 	 * allow time tracking to be recorded without a bugnote
 	 * @global int $g_time_tracking_without_note
 	 */
diff -r -u mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.org/core/bugnote_api.php mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22/core/bugnote_api.php
--- mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.org/core/bugnote_api.php	2009-07-10 16:04:01.000000000 +0200
+++ mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22/core/bugnote_api.php	2009-08-03 15:21:59.000000000 +0200
@@ -611,10 +611,11 @@
  * @param string $p_from Starting date (yyyy-mm-dd) inclusive, if blank, then ignored.
  * @param string $p_to Ending date (yyyy-mm-dd) inclusive, if blank, then ignored.
  * @param int $p_cost cost
+ * @param int $p_reporter_id Id of reporter, if blank, then ignored.
  * @return array array of bugnote stats
  * @access public
  */
-function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost ) {
+function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost, $p_reporter_id = ALL_USERS ) {
 	$c_project_id = db_prepare_int( $p_project_id );
 
 	$c_to = strtotime( $p_to, SECONDS_PER_DAY - 1); // @23:59:59
@@ -626,6 +627,7 @@
 	}
 
 	$c_cost = db_prepare_double( $p_cost );
+	$c_reporter_id = db_prepare_int( $p_reporter_id );
 
 	$t_bug_table = db_get_table( 'mantis_bug_table' );
 	$t_user_table = db_get_table( 'mantis_user_table' );
@@ -644,17 +646,23 @@
 	}
 
 	if( ALL_PROJECTS != $c_project_id ) {
-		$t_project_where = " AND b.project_id = '$c_project_id' AND bn.bug_id = b.id ";
+		$t_project_where = " AND b.project_id = '$c_project_id' AND bn.bug_id = b.id";
 	} else {
 		$t_project_where = '';
 	}
 
+	if( ALL_USERS != $c_reporter_id ) {
+		$t_reporter_where = " AND bn.reporter_id = '$c_reporter_id'";
+	} else {
+		$t_reporter_where = '';
+	}
+
 	$t_results = array();
 
 	$query = "SELECT username, summary, bn.bug_id, SUM(time_tracking) AS sum_time_tracking
 			FROM $t_user_table u, $t_bugnote_table bn, $t_bug_table b
 			WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = b.id
-			$t_project_where $t_from_where $t_to_where
+			$t_project_where $t_from_where $t_to_where $t_reporter_where
 			GROUP BY bn.bug_id, u.id, u.username, b.summary
 			ORDER BY bn.bug_id";
 
diff -r -u mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.org/lang/strings_german_eintrag.txt mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22/lang/strings_german_eintrag.txt
--- mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.org/lang/strings_german_eintrag.txt	2009-07-16 10:03:34.000000000 +0200
+++ mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22/lang/strings_german_eintrag.txt	2009-08-03 14:49:43.000000000 +0200
@@ -1443,6 +1443,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit für den Eintrag = %s';
 
 $s_access_denied = $MANTIS_ERROR[ERROR_ACCESS_DENIED];
diff -r -u mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.org/lang/strings_german.txt mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22/lang/strings_german.txt
--- mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22.org/lang/strings_german.txt	2009-08-03 10:03:18.000000000 +0200
+++ mantisbt-1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22/lang/strings_german.txt	2009-08-03 15:25:29.000000000 +0200
@@ -1205,6 +1205,7 @@
 $s_time_tracking_get_info_button = 'Zeiterfassungs-Informationen abfragen';
 $s_time_tracking_cost_per_hour = 'Kosten / Stunde';
 $s_time_tracking_cost = 'Kosten';
+$s_time_tracking_period = 'Zeitraum';
 $s_total_time_for_issue = 'Gesamtzeit für den Eintrag = %1$s';
 $s_access_denied = 'Zugriff verweigert.';
 $s_twitter_resolved = '%1$d: [%2$s] %3$s (erledigt von %4$s in %5$s)';

Relationships

related to 0015721 closedgrangeway mantisbt Functionality to consider porting to master-2.0.x 
has duplicate 0008871 closeddregad mantisbt Summary for Developer 
has duplicate 0021151 closedatrol mantisbt Developers not able to see their own Time Tracking report 
related to 0013705 assignedAbsolutelyFreeWeb Plugin - Time Tracking Filtering time tracking report 

Activities

vboctor

vboctor

2009-07-04 00:27

manager   ~0022373

Thanks @reinform for the contribution. Here are some comments:

  1. It would be nice to include a screenshot.
  2. bugnote_stats_get_project_array - move the new parameter to be the last one and default it to the value that provides the previous behavior (ALL_USERS?). We should attempt to avoid breaking the API.
  3. Why do you use the print_assign_to_option_list() to print the list of reporters? This will print the list of developers.
vboctor

vboctor

2009-07-04 00:29

manager   ~0022374

Actually, I'm probably wrong with point 3, since you are referring to the reporter of the note, not the reporter of the issue. In this case, assuming that developers are the only ones who can log time, then you will get the right list. I haven't looked in details, but we should make sure the list is the same as the list of people who are allowed to report time.

reinform

reinform

2009-08-03 09:45

reporter   ~0022649

Hello, sorry for the late reply, i just now could come back here.
Thank you very much for your advice. I followed your suggestions.

Essentially i changed
"print_assign_to_option_list" to "print_reporter_option_list",
moved
"$f_reporter_id" to the end of "bugnote_stats_get_project_array"
with default
"$p_reporter_id = ALL_USERS"
in the proper function.

Two screen shots are included, which show the behaviour for
a) a user that can generate reports, but is not allowed to select a reporter
b) one that can generate reports AND select the reporter of bug notes

Also find enclosed two corresponding patches, one for Mantis BT V 1.1.4 (which we are currently using) and one for V 1.2.0rc2-2009-08-03-master-1.2.x-e4c9e22 (which i downloaded today).

Kind regards

dhx

dhx

2009-10-28 20:24

reporter   ~0023455

Thanks for the patch, this looks quite useful!

My only concern is why there is a need for a new configuration option "time_tracking_reporting_select_reporter_threshold"? This seems fairly useless to me. Why can't we just give everyone (who has access to the billing page) the ability to filter by reporter?

reinform

reinform

2009-10-29 19:13

reporter   ~0023477

Hello dhx,

in our company we use Mantis for several purposes and one of those is to manage ToDo's regarding work for our clients. We track the time the developers need for their ToDo items and use it for accounting. The data is used to invoice clients as well as for the payment of developers. For privacy reasons a developer should just be able to generate reports of his own used time, not reports regarding other reporters. This functionality is limited to the manager and the accounting staff. From this point of view it seemed useful to have the new configuration option "time_tracking_reporting_select_reporter_threshold".

Kind regards

mikrot

mikrot

2010-09-09 05:17

reporter   ~0026640

The billing page shows issues regardlesss of their status (new,assigned, reslolved, closed etc.) I would love to heve another filtering crieria here that would allow filter issues on billing page by their status (either using checkboxes or drop down combo box). As it is quite important to track time / do billing, for closed issuess only.

Mike

AbsolutelyFreeWeb

AbsolutelyFreeWeb

2011-12-23 23:39

reporter   ~0030682

This is partly what we need. How come during more than two years, it hasn't made its way to the core?

grangeway

grangeway

2012-01-22 06:23

reporter   ~0030992

Ability to filter by user added.

Note: Haven't added a configuration variable to control this - ideally i'd probably say that a developer should be able to see his own [he could add it up manually], and the existing manager rights should therefre be able to see 'any'.

dregad

dregad

2012-03-15 07:47

developer   ~0031474

Reopened as the code is not available in the master branch in github

grangeway

grangeway

2012-10-20 19:59

reporter   ~0033291

this is fixed in the mantis-2.x branch

grangeway

grangeway

2013-04-05 17:56

reporter   ~0036220

Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch

akimeu007

akimeu007

2016-06-23 22:21

reporter   ~0053439

Can anyone provide this patch for 1.3 rc2? I tried to apply it to that code base/install, and there are quite a bit of changes which I can't figure out (not a programmer). Especially the changes in core/bugnote_api.php.