diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 4aab053af50..d7bd02fa6c2 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -972,175 +972,183 @@ class Form } - /** - * \brief Affiche zone de selection de date - * Liste deroulante pour les jours, mois, annee et eventuellement heurs et minutes - * Les champs sont présélectionnées avec: - * - La date set_time (timestamps ou date au format YYYY-MM-DD ou YYYY-MM-DD HH:MM) - * - La date du jour si set_time vaut '' - * - Aucune date (champs vides) si set_time vaut -1 - */ - function select_date($set_time='', $prefix='re', $h = 0, $m = 0, $empty=0) - { - global $langs; - - if (! $set_time && ! $empty) - { - $set_time = time(); - } - - $strmonth[1] = $langs->trans("January"); - $strmonth[2] = $langs->trans("February"); - $strmonth[3] = $langs->trans("March"); - $strmonth[4] = $langs->trans("April"); - $strmonth[5] = $langs->trans("May"); - $strmonth[6] = $langs->trans("June"); - $strmonth[7] = $langs->trans("July"); - $strmonth[8] = $langs->trans("August"); - $strmonth[9] = $langs->trans("September"); - $strmonth[10] = $langs->trans("October"); - $strmonth[11] = $langs->trans("November"); - $strmonth[12] = $langs->trans("December"); - - // Analyse de la date de préselection - if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?',$set_time,$reg)) { - // Date au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' - $syear = $reg[1]; - $smonth = $reg[2]; - $sday = $reg[3]; - $shour = $reg[4]; - $smin = $reg[5]; - } - else { - // Date est un timestamps - $syear = date("Y", $set_time); - $smonth = date("n", $set_time); - $sday = date("d", $set_time); - $shour = date("H", $set_time); - $smin = date("i", $set_time); - } - - // Jour - print '"; + if (! $set_time && $empty == 0) + { + $set_time = time(); + } - print '"; - - // Année - if ($empty || $set_time == -1) - { - print ''; - } - else - { - print '\n"; - } - - if ($h) - { - print 'H\n"; - - if ($m) - { - print ''; + + if ($empty || $set_time == -1) { - if (strlen($min) < 2) + $sday = 0; + $smonth = 0; + $syear = 0; + $shour = 0; + $smin = 0; + + print ''; + } + + for ($day = 1 ; $day <= 31; $day++) + { + if ($day == $sday) { - $min = "0" . $min; - } - if ($min == $smin) - { - print ""; - } - print "M\n"; - } - - } - } + } + + print ""; + + print '"; + + // Année + if ($empty || $set_time == -1) + { + print ''; + } + else + { + print '\n"; + } + + if ($h) + { + print 'H\n"; + + if ($m) + { + print 'M\n"; + } + + } + } /** * \brief Affiche liste déroulante depuis requete SQL