Skip to content

Commit

Permalink
Fix: Bad value of selected year
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 6, 2011
1 parent 5c25d43 commit cd51211
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
15 changes: 5 additions & 10 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -3098,7 +3098,7 @@ function select_month($selected='',$htmlname='monthid',$useempty=0)

/**
* \brief Return HTML combo list of years
* \param selected Preselected value
* \param selected Preselected value (''=current year, -1=none, year otherwise)
* \param htmlname Name of HTML select object
* \param useempty Affiche valeur vide dans liste
* \param $min_year Valeur minimum de l'annee dans la liste (par defaut annee courante -10)
Expand All @@ -3115,19 +3115,14 @@ function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10,
print '<select class="flat" name="' . $htmlname . '">';
if($useempty)
{
if($selected == '')
$selected_html = 'selected="selected"';
print '<option value="" ' . $selected_html . ' >&nbsp;</option>';
if ($selected == '') $selected_html = ' selected="selected"';
print '<option value=""' . $selected_html . '>&nbsp;</option>';
}
for ($y = $max_year; $y >= $min_year; $y--)
{
$selected_html='';
if ($y == $selected)
{
$selected_html = 'selected="selected"';
}
print "<option value=\"$y\" $selected_html >$y";
print "</option>";
if ($selected > 0 && $y == $selected) $selected_html = ' selected="selected"';
print '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
}
print "</select>\n";
}
Expand Down
3 changes: 1 addition & 2 deletions htdocs/fourn/facture/index.php
Expand Up @@ -204,10 +204,9 @@
print '<td class="liste_titre" colspan="1" align="center">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
//print '&nbsp;'.$langs->trans('Year').': ';
$max_year = date("Y");
$syear = $year;
//if ($syear == '') $syear = date("Y");
$html->select_year($syear,'year',1, '', $max_year);
$html->select_year($syear?$syear:-1,'year',1, 10, 10);
print '</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="left">';
Expand Down

0 comments on commit cd51211

Please sign in to comment.