Hi, once again I am calling for your help ^_^
Please show me how to add date_modified from mantis_bug_history_table into view issue page as a new column.
I am trying to adjust filter_api.php, but I got failed. Could you please help me?
Thank you so much!
I am using Mantis version 1.1.8.
adding mantis_bug_history_table.date_modified into viewIssue
Moderators: Developer, Contributor
-
namhung1986
- Posts: 19
- Joined: 19 Sep 2012, 03:25
-
namhung1986
- Posts: 19
- Joined: 19 Sep 2012, 03:25
Re: adding mantis_bug_history_table.date_modified into viewI
Hi,
Thanks for your reply Atrol!
Indeed, I want to get the most current Status Modified Date by select the max (date_modified) of field_name 'Status 'in mantis_bug_history_table.
I adjusted filter_api.php (change select and join clause)and could get out the result (by var_dump the query result to test out). However, I cannot display Status Modified Date in view_all_bug_page.php correctly.
Here is the error:

Uploaded with ImageShack.us
It just show the defaut date Jan-01-70, not the date in database. In fact, I can get out the right date by my query.
These are what I adjusted in columns_api.php
#print column title for Status Modified Date- Hung Tran
function print_column_title_date_modified( $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
if ( $p_columns_target != COLUMNS_TARGET_CSV_PAGE ) {
echo '<td>';
print_view_bug_sort_link( lang_get( 'status_modified_date' ), 'date_modified', $p_sort, $p_dir, $p_columns_target );
print_sort_icon( $p_dir, $p_sort, 'date_modified' );
echo '</td>';
} else {
echo lang_get( 'status_modified_date' );
}
}
# --------------------
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
//status date modified- Hung Tran
function print_column_date_modified( $p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
$t_date_modified = date( config_get( 'short_date_format' ), $p_row['date_modified'] );
echo '<td class="center">';
echo $t_date_modified;
echo '</td>';
}
Thanks for your reply Atrol!
Indeed, I want to get the most current Status Modified Date by select the max (date_modified) of field_name 'Status 'in mantis_bug_history_table.
I adjusted filter_api.php (change select and join clause)and could get out the result (by var_dump the query result to test out). However, I cannot display Status Modified Date in view_all_bug_page.php correctly.
Here is the error:

Uploaded with ImageShack.us
It just show the defaut date Jan-01-70, not the date in database. In fact, I can get out the right date by my query.
These are what I adjusted in columns_api.php
#print column title for Status Modified Date- Hung Tran
function print_column_title_date_modified( $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
if ( $p_columns_target != COLUMNS_TARGET_CSV_PAGE ) {
echo '<td>';
print_view_bug_sort_link( lang_get( 'status_modified_date' ), 'date_modified', $p_sort, $p_dir, $p_columns_target );
print_sort_icon( $p_dir, $p_sort, 'date_modified' );
echo '</td>';
} else {
echo lang_get( 'status_modified_date' );
}
}
# --------------------
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
//status date modified- Hung Tran
function print_column_date_modified( $p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
$t_date_modified = date( config_get( 'short_date_format' ), $p_row['date_modified'] );
echo '<td class="center">';
echo $t_date_modified;
echo '</td>';
}
-
namhung1986
- Posts: 19
- Joined: 19 Sep 2012, 03:25
Re: adding mantis_bug_history_table.date_modified into viewI
var_dump($p_row['date_modified']) = null
Since it gets null, it displays the default date Jan-01-70, even i can get the data. Here is my screen:

Uploaded with ImageShack.us
This is my revision in filter_api.php. Mantis_group_table and
$t_where_clauses = array( "$t_project_table.enabled = 1", "$t_project_table.id = $t_bug_table.project_id" );
$t_select_clauses = array( "$t_bug_table.*,COALESCE($t_mantis_tag_table_name.[name],N'') AS [Tag],
COALESCE($t_mantis_group_table_name.[groupname],N'') AS [Role],
MAX($t_mantis_bug_history_table_name.date_modified),
$t_custom_field_string_table.value");
$t_join_clauses = array("LEFT JOIN $t_mantis_bug_tag_table $t_mantis_bug_tag_table_name ON $t_mantis_bug_tag_table_name.bug_id = $t_bug_table.id
LEFT JOIN $t_mantis_tag_table $t_mantis_tag_table_name
ON $t_mantis_tag_table_name.id = $t_mantis_bug_tag_table_name.tag_id
LEFT JOIN $t_mantis_project_user_list_table $t_mantis_project_user_list_table_name ON
$t_mantis_project_user_list_table_name.user_id = $t_bug_table.handler_id
AND $t_mantis_project_user_list_table_name.project_id = $t_bug_table.project_id
LEFT JOIN $t_mantis_group_table $t_mantis_group_table_name ON $t_mantis_group_table_name.id = $t_mantis_project_user_list_table_name.group_id
LEFT JOIN $t_mantis_bug_history_table $t_mantis_bug_history_table_name ON $t_mantis_bug_history_table_name.bug_id = $t_bug_table.id
LEFT JOIN $t_custom_field_string_table ON $t_custom_field_string_table.bug_id = $t_bug_table.id
AND $t_custom_field_string_table.field_id = 20
");
$query2 = "SELECT DISTINCT $t_select
$t_from
$t_join
$t_where AND $t_mantis_bug_history_table_name.field_name = 'status'
GROUP BY $t_mantis_bug_table.bug_text_id, $t_mantis_bug_table.build,
$t_mantis_bug_table.category, $t_mantis_bug_table.date_submitted,
$t_mantis_bug_table.duplicate_id,$t_mantis_bug_table.eta,
$t_mantis_bug_table.fixed_in_version, $t_mantis_bug_table.handler_id,
$t_mantis_bug_table.id,$t_mantis_bug_table.last_updated,
$t_mantis_bug_table.os,$t_mantis_bug_table.os_build,
$t_mantis_bug_table.platform,$t_mantis_bug_table.priority,
$t_mantis_bug_table.profile_id, $t_mantis_bug_table.project_id,
$t_mantis_bug_table.projection,$t_mantis_bug_table.reopen_count,
$t_mantis_bug_table.reporter_id,$t_mantis_bug_table.reproducibility,
$t_mantis_bug_table.resolution,$t_mantis_bug_table.severity,
$t_mantis_bug_table.sponsorship_total,$t_mantis_bug_table.status,
$t_mantis_bug_table.sticky,$t_mantis_bug_table.summary,
$t_mantis_bug_table.target_version,$t_mantis_bug_table.version,
$t_mantis_bug_table.view_state, $t_mantis_group_table_name.groupname,
$t_custom_field_string_table.value, $t_mantis_tag_table_name.name
$t_order ";
Since it gets null, it displays the default date Jan-01-70, even i can get the data. Here is my screen:

Uploaded with ImageShack.us
This is my revision in filter_api.php. Mantis_group_table and
$t_where_clauses = array( "$t_project_table.enabled = 1", "$t_project_table.id = $t_bug_table.project_id" );
$t_select_clauses = array( "$t_bug_table.*,COALESCE($t_mantis_tag_table_name.[name],N'') AS [Tag],
COALESCE($t_mantis_group_table_name.[groupname],N'') AS [Role],
MAX($t_mantis_bug_history_table_name.date_modified),
$t_custom_field_string_table.value");
$t_join_clauses = array("LEFT JOIN $t_mantis_bug_tag_table $t_mantis_bug_tag_table_name ON $t_mantis_bug_tag_table_name.bug_id = $t_bug_table.id
LEFT JOIN $t_mantis_tag_table $t_mantis_tag_table_name
ON $t_mantis_tag_table_name.id = $t_mantis_bug_tag_table_name.tag_id
LEFT JOIN $t_mantis_project_user_list_table $t_mantis_project_user_list_table_name ON
$t_mantis_project_user_list_table_name.user_id = $t_bug_table.handler_id
AND $t_mantis_project_user_list_table_name.project_id = $t_bug_table.project_id
LEFT JOIN $t_mantis_group_table $t_mantis_group_table_name ON $t_mantis_group_table_name.id = $t_mantis_project_user_list_table_name.group_id
LEFT JOIN $t_mantis_bug_history_table $t_mantis_bug_history_table_name ON $t_mantis_bug_history_table_name.bug_id = $t_bug_table.id
LEFT JOIN $t_custom_field_string_table ON $t_custom_field_string_table.bug_id = $t_bug_table.id
AND $t_custom_field_string_table.field_id = 20
");
$query2 = "SELECT DISTINCT $t_select
$t_from
$t_join
$t_where AND $t_mantis_bug_history_table_name.field_name = 'status'
GROUP BY $t_mantis_bug_table.bug_text_id, $t_mantis_bug_table.build,
$t_mantis_bug_table.category, $t_mantis_bug_table.date_submitted,
$t_mantis_bug_table.duplicate_id,$t_mantis_bug_table.eta,
$t_mantis_bug_table.fixed_in_version, $t_mantis_bug_table.handler_id,
$t_mantis_bug_table.id,$t_mantis_bug_table.last_updated,
$t_mantis_bug_table.os,$t_mantis_bug_table.os_build,
$t_mantis_bug_table.platform,$t_mantis_bug_table.priority,
$t_mantis_bug_table.profile_id, $t_mantis_bug_table.project_id,
$t_mantis_bug_table.projection,$t_mantis_bug_table.reopen_count,
$t_mantis_bug_table.reporter_id,$t_mantis_bug_table.reproducibility,
$t_mantis_bug_table.resolution,$t_mantis_bug_table.severity,
$t_mantis_bug_table.sponsorship_total,$t_mantis_bug_table.status,
$t_mantis_bug_table.sticky,$t_mantis_bug_table.summary,
$t_mantis_bug_table.target_version,$t_mantis_bug_table.version,
$t_mantis_bug_table.view_state, $t_mantis_group_table_name.groupname,
$t_custom_field_string_table.value, $t_mantis_tag_table_name.name
$t_order ";
Re: adding mantis_bug_history_table.date_modified into viewI
I don't have the time to guide you step by step thru debugging.
If var_dump($p_row['date_modified']) = null you have to ask yourself why it's null.
Where is the place where you think that you set the field, ...
If var_dump($p_row['date_modified']) = null you have to ask yourself why it's null.
Where is the place where you think that you set the field, ...
-
namhung1986
- Posts: 19
- Joined: 19 Sep 2012, 03:25
Re: adding mantis_bug_history_table.date_modified into viewI
var_dump($p_row['date_modified']) = null
because I was using aggregate function MAX($t_mantis_bug_history_table_name.date_modified). This makes the returned column name '' (empty) instead of
'date_modified'. Then I have to use a trick in print function to get data. I made it. Thank you atrol and cas!
because I was using aggregate function MAX($t_mantis_bug_history_table_name.date_modified). This makes the returned column name '' (empty) instead of
'date_modified'. Then I have to use a trick in print function to get data. I made it. Thank you atrol and cas!