Page 1 of 1
Add "Total time for issue" to Available Columns
Posted: 17 Jan 2012, 15:28
by ShawnPaul
I would like to add the result for "Total time for issue" from Bug Notes to all available columns under Manage Columns. Our users need to plug in this information in various Views and Reports. Could someone point out where this may be documented or post a link to a plugin that provides this customization? Any help would be greatly appreciated. Thank you

Re: Add "Total time for issue" to Available Columns
Posted: 23 Jan 2012, 09:02
by ShawnPaul
What makes this problem complicated is that the columns are limited to those in the mantis_bug_table in the database, but I need the time_tracking column from the mantis_bugnote_table. This appears not to be possible.
Re: Add "Total time for issue" to Available Columns
Posted: 23 Jan 2012, 09:19
by ShawnPaul
Apparently there's a function that allows columns to be "extended"
"Extended columns are native columns that are associated with the issue but are saved in mantis_bug_text_table"
Could I somehow "extend" extended columns to include native columns saved in mantis_bugnote_table? Thereby including the time_tracking column?
Re: Add "Total time for issue" to Available Columns
Posted: 27 Jan 2012, 18:01
by rajeshkanattu
Hello Shawn,
Did you get it sorted out? I am also looking for the same functionality...
Re: Add "Total time for issue" to Available Columns
Posted: 24 Apr 2012, 15:41
by federbear
I've hacked the code:
1. Create view in mantis database:
SELECT b.id, b.project_id, b.reporter_id, b.handler_id, b.duplicate_id, b.priority, b.severity, b.reproducibility, b.status, b.resolution, b.projection, b.eta, b.bug_text_id, b.os, b.os_build, b.platform, b.version, b.fixed_in_version, b.build, b.profile_id, b.view_state, b.summary, b.sponsorship_total, b.sticky, b.target_version, b.category_id, b.date_submitted, b.last_updated, b.due_date, ( SELECT sum(n.time_tracking) AS sum
FROM mantis_bugnote_table n
WHERE n.bug_id = b.id) AS total_time
FROM mantis_bug_table b;
2. Add parameter after mantis_bug_table: config_defaults_inc.php
$g_db_table['mantis_bug_table'] = '%db_table_prefix%_bug%db_table_suffix%';
$g_db_table['mantis_bug_table_view'] = '%db_table_prefix%_bug%db_table_suffix%_view';
3. Add column after due_date to $g_bug_view_page_fields array: config_defaults_inc.php
'due_date',
'total_time',
);
4. Changed the table parameter to view (3x): core/filter_api.php
$t_bug_table = db_get_table( 'mantis_bug_table_view' );
5. Add attribute to Class BugData after "$due_date = 0": core/bug_api.php
protected $due_date = 0;
protected $total_time = 0;
6. Add code to case in public function __set (after due_date): core/bug_api.php
case 'due_date':
if ( !is_numeric( $value ) ) {
$value = strtotime($value);
}
break;
case 'total_time':
$value = number_format( $value / 60, 1 );
break;
Re: Add "Total time for issue" to Available Columns
Posted: 25 Apr 2012, 08:44
by federbear
Additional code for excel export:
function excel_format_due_date( $p_due_date ) {
return excel_prepare_string( date( config_get( 'short_date_format' ), $p_due_date ) );
}
Add this code after due_date:
function excel_format_total_time( $p_total_time ) {
return excel_prepare_string( number_format( $p_total_time, 1 ));
}
Re: Add "Total time for issue" to Available Columns
Posted: 27 Mar 2017, 16:47
by savo
Hi, I'm trying to make your suggestions, but I have a problem about your point 4:
4. Changed the table parameter to view (3x): core/filter_api.php
$t_bug_table = db_get_table( 'mantis_bug_table_view' );
I didn't understand where I have to insert and use the variable $t_bug_table on file core/filter_api.php
Can you give me some more details ?
Thanks in advance
PS. My Mantis version is 2.2.1