972 |
} |
} |
973 |
|
|
974 |
|
|
975 |
/** |
/** |
976 |
* \brief Affiche zone de selection de date |
* \brief Affiche zone de selection de date |
977 |
* Liste deroulante pour les jours, mois, annee et eventuellement heurs et minutes |
* Liste deroulante pour les jours, mois, annee et eventuellement heurs et minutes |
978 |
* Les champs sont présélectionnées avec: |
* Les champs sont présélectionnées avec: |
979 |
* - La date set_time (timestamps ou date au format YYYY-MM-DD ou YYYY-MM-DD HH:MM) |
* - La date set_time (timestamps ou date au format YYYY-MM-DD ou YYYY-MM-DD HH:MM) |
980 |
* - La date du jour si set_time vaut '' |
* - La date du jour si set_time vaut '' |
981 |
* - Aucune date (champs vides) si set_time vaut -1 |
* - Aucune date (champs vides) si set_time vaut -1 |
982 |
*/ |
*/ |
983 |
function select_date($set_time='', $prefix='re', $h = 0, $m = 0, $empty=0) |
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 '<select class="flat" name="'.$prefix.'day">'; |
|
|
|
|
|
if ($empty || $set_time == -1) |
|
|
{ |
|
|
$sday = 0; |
|
|
$smonth = 0; |
|
|
$syear = 0; |
|
|
$shour = 0; |
|
|
$smin = 0; |
|
|
|
|
|
print '<option value="0" selected="true"></option>'; |
|
|
} |
|
|
|
|
|
for ($day = 1 ; $day <= 31; $day++) |
|
984 |
{ |
{ |
985 |
if ($day == $sday) |
global $langs; |
986 |
{ |
|
987 |
print "<option value=\"$day\" selected=\"true\">$day"; |
if (! $set_time && $empty == 0) |
|
} |
|
|
else |
|
988 |
{ |
{ |
989 |
print "<option value=\"$day\">$day"; |
$set_time = time(); |
990 |
} |
} |
|
print "</option>"; |
|
|
} |
|
991 |
|
|
992 |
print "</select>"; |
$strmonth[1] = $langs->trans("January"); |
993 |
|
$strmonth[2] = $langs->trans("February"); |
994 |
|
$strmonth[3] = $langs->trans("March"); |
995 |
|
$strmonth[4] = $langs->trans("April"); |
996 |
|
$strmonth[5] = $langs->trans("May"); |
997 |
|
$strmonth[6] = $langs->trans("June"); |
998 |
|
$strmonth[7] = $langs->trans("July"); |
999 |
|
$strmonth[8] = $langs->trans("August"); |
1000 |
|
$strmonth[9] = $langs->trans("September"); |
1001 |
|
$strmonth[10] = $langs->trans("October"); |
1002 |
|
$strmonth[11] = $langs->trans("November"); |
1003 |
|
$strmonth[12] = $langs->trans("December"); |
1004 |
|
|
1005 |
|
// Analyse de la date de préselection |
1006 |
|
if (eregi('^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?',$set_time,$reg)) { |
1007 |
|
// Date au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' |
1008 |
|
$syear = $reg[1]; |
1009 |
|
$smonth = $reg[2]; |
1010 |
|
$sday = $reg[3]; |
1011 |
|
$shour = $reg[4]; |
1012 |
|
$smin = $reg[5]; |
1013 |
|
} |
1014 |
|
elseif ($set_time) { |
1015 |
|
// Date est un timestamps |
1016 |
|
$syear = date("Y", $set_time); |
1017 |
|
$smonth = date("n", $set_time); |
1018 |
|
$sday = date("d", $set_time); |
1019 |
|
$shour = date("H", $set_time); |
1020 |
|
$smin = date("i", $set_time); |
1021 |
|
} |
1022 |
|
else { |
1023 |
|
// Date est vide |
1024 |
|
$syear = ''; |
1025 |
|
$smonth = ''; |
1026 |
|
$sday = ''; |
1027 |
|
$shour = ''; |
1028 |
|
$smin = ''; |
1029 |
|
} |
1030 |
|
|
1031 |
|
// Jour |
1032 |
|
print '<select class="flat" name="'.$prefix.'day">'; |
1033 |
|
|
1034 |
|
if ($empty || $set_time == -1) |
1035 |
|
{ |
1036 |
|
$sday = 0; |
1037 |
|
$smonth = 0; |
1038 |
|
$syear = 0; |
1039 |
|
$shour = 0; |
1040 |
|
$smin = 0; |
1041 |
|
|
1042 |
print '<select class="flat" name="'.$prefix.'month">'; |
print '<option value="0" selected="true"></option>'; |
|
if ($empty || $set_time == -1) |
|
|
{ |
|
|
print '<option value="0" selected="true"></option>'; |
|
|
} |
|
|
|
|
|
// Mois |
|
|
for ($month = 1 ; $month <= 12 ; $month++) |
|
|
{ |
|
|
if ($month == $smonth) |
|
|
{ |
|
|
print "<option value=\"$month\" selected=\"true\">" . $strmonth[$month]; |
|
1043 |
} |
} |
1044 |
else |
|
1045 |
{ |
for ($day = 1 ; $day <= 31; $day++) |
|
print "<option value=\"$month\">" . $strmonth[$month]; |
|
|
} |
|
|
print "</option>"; |
|
|
} |
|
|
print "</select>"; |
|
|
|
|
|
// Année |
|
|
if ($empty || $set_time == -1) |
|
|
{ |
|
|
print '<input class="flat" type="text" size="3" maxlength="4" name="'.$prefix.'year">'; |
|
|
} |
|
|
else |
|
|
{ |
|
|
print '<select class="flat" name="'.$prefix.'year">'; |
|
|
|
|
|
for ($year = $syear - 3; $year < $syear + 5 ; $year++) |
|
|
{ |
|
|
if ($year == $syear) |
|
1046 |
{ |
{ |
1047 |
print "<option value=\"$year\" selected=\"true\">$year"; |
if ($day == $sday) |
1048 |
|
{ |
1049 |
|
print "<option value=\"$day\" selected=\"true\">$day"; |
1050 |
|
} |
1051 |
|
else |
1052 |
|
{ |
1053 |
|
print "<option value=\"$day\">$day"; |
1054 |
|
} |
1055 |
|
print "</option>"; |
1056 |
} |
} |
1057 |
else |
|
1058 |
|
print "</select>"; |
1059 |
|
|
1060 |
|
print '<select class="flat" name="'.$prefix.'month">'; |
1061 |
|
if ($empty || $set_time == -1) |
1062 |
{ |
{ |
1063 |
print "<option value=\"$year\">$year"; |
print '<option value="0" selected="true"></option>'; |
1064 |
} |
} |
|
print "</option>"; |
|
|
} |
|
|
print "</select>\n"; |
|
|
} |
|
|
|
|
|
if ($h) |
|
|
{ |
|
|
print '<select class="flat" name="'.$prefix.'hour">'; |
|
1065 |
|
|
1066 |
for ($hour = 0; $hour < 24 ; $hour++) |
// Mois |
1067 |
{ |
for ($month = 1 ; $month <= 12 ; $month++) |
|
if (strlen($hour) < 2) |
|
1068 |
{ |
{ |
1069 |
$hour = "0" . $hour; |
if ($month == $smonth) |
1070 |
|
{ |
1071 |
|
print "<option value=\"$month\" selected=\"true\">" . $strmonth[$month]; |
1072 |
|
} |
1073 |
|
else |
1074 |
|
{ |
1075 |
|
print "<option value=\"$month\">" . $strmonth[$month]; |
1076 |
|
} |
1077 |
|
print "</option>"; |
1078 |
} |
} |
1079 |
if ($hour == $shour) |
print "</select>"; |
1080 |
|
|
1081 |
|
// Année |
1082 |
|
if ($empty || $set_time == -1) |
1083 |
{ |
{ |
1084 |
print "<option value=\"$hour\" selected=\"true\">$hour"; |
print '<input class="flat" type="text" size="3" maxlength="4" name="'.$prefix.'year">'; |
1085 |
} |
} |
1086 |
else |
else |
1087 |
{ |
{ |
1088 |
print "<option value=\"$hour\">$hour"; |
print '<select class="flat" name="'.$prefix.'year">'; |
1089 |
} |
|
1090 |
print "</option>"; |
for ($year = $syear - 3; $year < $syear + 5 ; $year++) |
|
} |
|
|
print "</select>H\n"; |
|
|
|
|
|
if ($m) |
|
|
{ |
|
|
print '<select class="flat" name="'.$prefix.'min">'; |
|
|
|
|
|
for ($min = 0; $min < 60 ; $min++) |
|
|
{ |
|
|
if (strlen($min) < 2) |
|
1091 |
{ |
{ |
1092 |
$min = "0" . $min; |
if ($year == $syear) |
1093 |
|
{ |
1094 |
|
print "<option value=\"$year\" selected=\"true\">$year"; |
1095 |
|
} |
1096 |
|
else |
1097 |
|
{ |
1098 |
|
print "<option value=\"$year\">$year"; |
1099 |
|
} |
1100 |
|
print "</option>"; |
1101 |
} |
} |
1102 |
if ($min == $smin) |
print "</select>\n"; |
1103 |
|
} |
1104 |
|
|
1105 |
|
if ($h) |
1106 |
|
{ |
1107 |
|
print '<select class="flat" name="'.$prefix.'hour">'; |
1108 |
|
|
1109 |
|
for ($hour = 0; $hour < 24 ; $hour++) |
1110 |
{ |
{ |
1111 |
print "<option value=\"$min\" selected=\"true\">$min"; |
if (strlen($hour) < 2) |
1112 |
|
{ |
1113 |
|
$hour = "0" . $hour; |
1114 |
|
} |
1115 |
|
if ($hour == $shour) |
1116 |
|
{ |
1117 |
|
print "<option value=\"$hour\" selected=\"true\">$hour"; |
1118 |
|
} |
1119 |
|
else |
1120 |
|
{ |
1121 |
|
print "<option value=\"$hour\">$hour"; |
1122 |
|
} |
1123 |
|
print "</option>"; |
1124 |
} |
} |
1125 |
else |
print "</select>H\n"; |
1126 |
|
|
1127 |
|
if ($m) |
1128 |
{ |
{ |
1129 |
print "<option value=\"$min\">$min"; |
print '<select class="flat" name="'.$prefix.'min">'; |
1130 |
|
|
1131 |
|
for ($min = 0; $min < 60 ; $min++) |
1132 |
|
{ |
1133 |
|
if (strlen($min) < 2) |
1134 |
|
{ |
1135 |
|
$min = "0" . $min; |
1136 |
|
} |
1137 |
|
if ($min == $smin) |
1138 |
|
{ |
1139 |
|
print "<option value=\"$min\" selected=\"true\">$min"; |
1140 |
|
} |
1141 |
|
else |
1142 |
|
{ |
1143 |
|
print "<option value=\"$min\">$min"; |
1144 |
|
} |
1145 |
|
print "</option>"; |
1146 |
|
} |
1147 |
|
print "</select>M\n"; |
1148 |
} |
} |
1149 |
print "</option>"; |
|
1150 |
} |
} |
1151 |
print "</select>M\n"; |
} |
|
} |
|
|
|
|
|
} |
|
|
} |
|
1152 |
|
|
1153 |
/** |
/** |
1154 |
* \brief Affiche liste déroulante depuis requete SQL |
* \brief Affiche liste déroulante depuis requete SQL |