Page 1 of 1

Need help to copy functionality of due_date

Posted: 02 Apr 2014, 09:02
by mworks
Hello everybody,

I need help to implement a custom date field with the behaviour of the due_date field, changing color from a given date on.
We have to fields in our forms, one is a given by customer and called 'Target Date' (based on due_date) another is the intended finishing date ( by developper).
This one should change color like due_date. On one hand I'm a developper and have done little patches directly in the sourcecode of mantis, on the other side I'm not a specialist for php and the architecture of mantis. So here comes my question: Has anyone realised that yet ? Are there some hints or workarrounds to generate this funcionality quick and clean :-)), something like due_date_2 ?

Thanks for any help,
Stephan

Re: Need help to copy functionality of due_date

Posted: 02 Apr 2014, 11:20
by atrol
mworks wrote:quick and clean
You certainly mean quick or clean ;-)

I don't have enough time to tell how a clean solution would work as this requires an extension to the custom field concept.

A quick and dirty solution is to change function print_custom_field_value in core/custom_field_api.php
Check for the name of your custom field.
If it's your special field, use the custom field value to determine if you have reached the due date.
If so, change the background color.

Some hints how to implement it:

function bug_is_overdue in core/bug_api.php

This piece of code from bug_view_inc.php

Code: Select all

			if ( $tpl_bug_overdue ) {
				echo '<td class="overdue">', $tpl_bug_due_date, '</td>';
			} else {
				echo '<td>', $tpl_bug_due_date, '</td>';
			}

Re: Need help to copy functionality of due_date

Posted: 02 Apr 2014, 12:56
by mworks
Thank You so far. I'll try to understand the hints...
Regards,
Stephan