Skip to content

Commit

Permalink
Fixed #8710: display past years in Custom date field
Browse files Browse the repository at this point in the history
git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4872 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
vboctor committed Jan 9, 2008
1 parent 444b5a5 commit 56ffabf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
6 changes: 5 additions & 1 deletion config_defaults_inc.php
Expand Up @@ -1808,9 +1808,13 @@
$g_dot_tool = '/usr/bin/dot';
$g_neato_tool = '/usr/bin/neato';

# Number of years in the past that custom date fields will display in
# drop down boxes.
$g_backward_year_count = 4;

# Number of years in the future that custom date fields will display in
# drop down boxes.
$g_forward_year_count = 4 ;
$g_forward_year_count = 4;

# Custom Group Actions
#
Expand Down
30 changes: 16 additions & 14 deletions core/date_api.php
Expand Up @@ -74,30 +74,32 @@ function print_year_option_list( $p_year = 0 ) {
}
# --------------------
function print_year_range_option_list( $p_year = 0, $p_start = 0, $p_end = 0) {
$t_current = date( "Y" ) ;
$t_forward_years = config_get( 'forward_year_count' ) ;
$t_current = date( 'Y' );
$t_forward_years = config_get( 'forward_year_count' );

$t_start_year = $p_start ;
if ($t_start_year == 0) {
$t_start_year = $t_current ;
$t_start_year = $p_start;
if ( $t_start_year == 0 ) {
$t_backward_years = config_get( 'backward_year_count' );
$t_start_year = $t_current - $t_backward_years;
}

if ( ( $p_year < $t_start_year ) && ( $p_year != 0 ) ) {
$t_start_year = $p_year ;
}

$t_end_year = $p_end ;
if ($t_end_year == 0) {
$t_end_year = $t_current + $t_forward_years ;
$t_end_year = $p_end;
if ( $t_end_year == 0 ) {
$t_end_year = $t_current + $t_forward_years;
}
if ($p_year > $t_end_year) {
$t_end_year = $p_year + $t_forward_years ;
if ( $p_year > $t_end_year ) {
$t_end_year = $p_year + $t_forward_years;
}

for ($i=$t_start_year; $i <= $t_end_year; $i++) {
if ($i == $p_year) {
PRINT "<option value=\"$i\" selected=\"selected\"> $i </option>" ;
for ( $i = $t_start_year; $i <= $t_end_year; $i++ ) {
if ( $i == $p_year ) {
echo "<option value=\"$i\" selected=\"selected\">$i</option>";
} else {
PRINT "<option value=\"$i\"> $i </option>" ;
echo "<option value=\"$i\">$i</option>";
}
}
}
Expand Down

0 comments on commit 56ffabf

Please sign in to comment.