View Issue Details

IDProjectCategoryView StatusLast Update
0016869mantisbtbugtrackerpublic2020-03-15 15:23
ReporterHyper Assigned Todregad  
PrioritylowSeverityfeatureReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.2.15 
Target Version2.24.0Fixed in Version2.24.0 
Summary0016869: Change of due date background color
Description

Hello all!

I was wondering if it is possible to add another background color for the ticket's field "DUE DATE". Right now if due date has been reached, the field becomes red. That's fine, but maybe somebody would know how to add another color, let's say orange or yellow, when there are 2 days till due date. It should work as a reminder when I am directly looking on the list of unassigned tickets.

Could please someone help me in this case? Thanks in advance!

TagsNo tags attached.

Relationships

related to 0021642 closedsyncguru mantisbt Highlight due date when the date has passed 
related to 0009155 closeddregad mantisbt Cell coloring for due date indicates "overdue" when not overdue yet. 
child of 0026438 closeddregad mantisbt Allow multiple, customizable due date levels 
child of 0026775 resolveddregad MantisTouch Allow multiple, customizable due date levels 

Activities

dregad

dregad

2014-01-22 12:36

developer   ~0039140

Currently the system does not allow "intermediate" states for due date, it's either OK or past the date (red). Introducing another color like you suggest would also require a parameter to define the thresholds.

As a side note, you can change the color by tweaking the CSS (td.overdue).

Hyper

Hyper

2014-01-23 06:27

reporter   ~0039149

Thank you for the answer. How shall I proceed with creating new parameter to define the new threshold?

MPAA

MPAA

2019-09-19 03:03

reporter   ~0062865

Very much wanted this new potential feature.
Is there anyone who already did some research?

MPAA

MPAA

2019-09-25 14:11

reporter   ~0062908

Last edited: 2019-09-26 07:08

Found a neat solution. Testes in version 2.21.1

*Add 2 lines in your config_inc.php file;

# When do you want to be warned before due_date in seconds
$g_1st_due_date_warning = 432000; # get's color green
$g_2nd_due_date_warning = 172800; # get's color orange and always less seconds then the 1st warning

*Add two lines in file 'default.css' under 'td.overdue ' near line 95;

/* within 1st due_date */
td.near_1st_due_date{ background-color: #a6d147; color: #ffffff; font-weight: bold; }
/* within 2nd due_date */
td.near_2nd_due_date{ background-color: #d19447; color: #ffffff; font-weight: bold; }

*Create two new functions (under function bug_is_overdue) in file /core/bug_api.php;

// Function to determine bug within the 1st_due_date_warning timeframe
function bug_is_1st_due_date( $p_bug_id ) {
    $t_due_date = bug_get_field( $p_bug_id, 'due_date' );
    $t_1st_due_date_warning = config_get( '1st_due_date_warning' );
    if( !date_is_null( $t_due_date ) ) {
        $t_now = db_now() + $t_1st_due_date_warning;
        if( $t_now > $t_due_date ) {
            if( !bug_is_resolved( $p_bug_id ) ) {
                return true;
            }
        }
    }
    return false;
}

// Function to determine bug within the 2nd_due_date_warning timeframe
function bug_is_2nd_due_date( $p_bug_id ) {
    $t_due_date = bug_get_field( $p_bug_id, 'due_date' );
    $t_2nd_due_date_warning = config_get( '2nd_due_date_warning' );
    if( !date_is_null( $t_due_date ) ) {
        $t_now = db_now() + $t_2nd_due_date_warning;
        if( $t_now > $t_due_date ) {
            if( !bug_is_resolved( $p_bug_id ) ) {
                return true;
            }
        }
    }
    return false;
}

*Replace function print_column_due_date (near bottom file) in file /core/columns_api.php with;

function print_column_due_date( BugData $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
    $t_overdue = '';

    if( !access_has_bug_level( config_get( 'due_date_view_threshold' ), $p_bug->id ) ||
        date_is_null( $p_bug->due_date )
    ) {
        $t_value = ' ';
    } else {
        if( bug_is_1st_due_date( $p_bug->id ) ) {
            $t_overdue = ' near_1st_due_date';
        }
        if( bug_is_2nd_due_date( $p_bug->id ) ) {
            $t_overdue = ' near_2nd_due_date';
        }       
        if( bug_is_overdue( $p_bug->id ) ) {
            $t_overdue = ' overdue';
        }

        $t_value = string_display_line( date( config_get( 'short_date_format' ), $p_bug->due_date ) );
    }

    printf( '<td class="column-due-date%s">%s</td>', $t_overdue, $t_value );
}

*Replace function print_column_overdue (bottom file) in file /core/columns_api.php with if you also want to change the 'overdue' column;

function print_column_overdue( BugData $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {

    echo '<td class="column-overdue">';

    if( access_has_bug_level( config_get( 'due_date_view_threshold' ), $p_bug->id ) &&
        !date_is_null( $p_bug->due_date ) &&
        bug_is_overdue( $p_bug->id ) ) {
        $t_overdue_text = lang_get( 'overdue' );
        $t_overdue_text_hover = sprintf( lang_get( 'overdue_since' ), date( config_get( 'short_date_format' ), $p_bug->due_date ) );
        echo '&lt;i class=&quot;fa fa-times-circle-o&quot; title=&quot;' . string_display_line( $t_overdue_text_hover ) . '&quot;></i>';
    } else 
    if( access_has_bug_level( config_get( 'due_date_view_threshold' ), $p_bug->id ) &&
        !date_is_null( $p_bug->due_date ) &&
        bug_is_2nd_due_date( $p_bug->id ) ) {
        $t_overdue_text = lang_get( 'overdue' );
        $t_overdue_text_hover = sprintf( lang_get( 'overdue_since' ), date( config_get( 'short_date_format' ), $p_bug->due_date ) );
        echo '&lt;i class=&quot;fa fa-angle-double-up&quot; title=&quot;' . string_display_line( $t_overdue_text_hover ) . '&quot;></i>';
    } else 
    if( access_has_bug_level( config_get( 'due_date_view_threshold' ), $p_bug->id ) &&
        !date_is_null( $p_bug->due_date ) &&
        bug_is_1st_due_date( $p_bug->id ) ) {
        $t_overdue_text = lang_get( 'overdue' );
        $t_overdue_text_hover = sprintf( lang_get( 'overdue_since' ), date( config_get( 'short_date_format' ), $p_bug->due_date ) );
        echo '&lt;i class=&quot;fa fa-angle-up&quot; title=&quot;' . string_display_line( $t_overdue_text_hover ) . '&quot;></i>';
    } else

    {
        echo ' ';
    }

    echo '&lt;/td>';
}

*Add two lines in bug_view_inc.php under line 184 't_bug_overdue';

$t_bug_near_1st = bug_is_1st_due_date( $f_bug_id );
$t_bug_near_2nd = bug_is_2nd_due_date( $f_bug_id );

*And replace the #Due Date in file bug_view_inc.php;

    # Due Date
    if( $t_show_due_date ) {
        echo '&lt;th class=&quot;bug-due-date category&quot;>', lang_get( 'due_date' ), '&lt;/th>';

        if( $t_bug_overdue ) {
            echo '&lt;td class=&quot;bug-due-date overdue&quot;>', $t_bug_due_date, '&lt;/td>';
        } 
        else if( $t_bug_near_2nd ) {
            echo '&lt;td class=&quot;bug-due-date near_2nd_due_date&quot;>', $t_bug_due_date, '&lt;/td>'; # near_2nd_due_date
        }
        else if( $t_bug_near_1st ) {
            echo '&lt;td class=&quot;bug-due-date near_1st_due_date&quot;>', $t_bug_due_date, '&lt;/td>'; # near_1st_due_date
        }
        else {
            echo '&lt;td class=&quot;bug-due-date&quot;>', $t_bug_due_date, '&lt;/td>';
        }
    } else {
        $t_spacer += 2;
    }

    if( $t_spacer > 0 ) {
        echo '&lt;td colspan=&quot;', $t_spacer, '&quot;> &lt;/td>';
    }

    echo '&lt;/tr>';

*enjoy!

EDIT (dregad) markdown formatting

MPAA

MPAA

2019-09-26 04:02

reporter   ~0062910

dregad

dregad

2019-09-26 05:14

developer   ~0062911

@MPAA to make your changes easier to apply, I would suggest to provide them as a patch, ideally using git format-patch or git diff; if you're not using git, then unified diff (diff -u)

MPAA

MPAA

2019-09-26 06:52

reporter   ~0062912

I've did some magic, at least for me. My first Github project. Hope this helps.
https://github.com/Maximus48p/Mantisbt_due_date

dregad

dregad

2019-09-26 09:20

developer   ~0062915

Thanks. It's better, but still that's not really what I meant... Sorry if I was not clear.

What you should do is

  1. Fork MantisBT repo
  2. Create a feature branch (you should not use master)
  3. Apply your changes
  4. Commit
  5. run git format-patch
  6. upload resulting patch file here
dregad

dregad

2019-12-08 12:05

developer   ~0063198

PR https://github.com/mantisbt/mantisbt/pull/1589

Related Changesets

MantisBT: master 1aa2adf8

2020-02-02 06:28

dregad


Details Diff
Allow multiple, customizable due date levels

New config option defining due date levels allowing administrators to
customize both the number of levels, and the cutover deadlines. CSS can
be used to define the colors.

Fixes 0026438, 0009155, 0016869
PR https://github.com/mantisbt/mantisbt/pull/1589
Affected Issues
0009155, 0016869, 0026438
mod - bug_update_page.php Diff File
mod - bug_view_inc.php Diff File
mod - config_defaults_inc.php Diff File
mod - core/bug_api.php Diff File
mod - core/columns_api.php Diff File
mod - core/commands/IssueViewPageCommand.php Diff File
mod - css/default.css Diff File
mod - docbook/Admin_Guide/en-US/config/duedate.xml Diff File
mod - lang/strings_english.txt Diff File