1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
<?php
if (isset($_GET["form"])) { $form=$_GET["form"]; }
if (isset($_GET["elem"])) { $elem=$_GET["elem"]; }
if (isset($_GET["jour"])) { $jour=$_GET["jour"]; }
if (isset($_GET["mois"])) { $mois=$_GET["mois"]; }
if (isset($_GET["annee"])) { $annee=$_GET["annee"]; }
// Section de configuration
$bgcolor="dddddd" ; // Couleur de fond
$daybgcolor="aaaaaa" ; // Couleur des jours de la semaine
$dombgcolor="eeeeee" ; // Couleur du jour sélectionné
$dayholcolor="cccccc" ; // Couleur des WE
// Mois
$month[0] = "Janvier" ;
$month[1] = "Février" ;
$month[2] = "Mars" ;
$month[3] = "Avril" ;
$month[4] = "Mai" ;
$month[5] = "Juin" ;
$month[6] = "Juillet" ;
$month[7] = "Août" ;
$month[8] = "Septembre" ;
$month[9] = "Octobre" ;
$month[10] = "Novembre" ;
$month[11] = "Décembre" ;
// Première lettre des jours de la semaine
$day[0] = "D" ;
$day[1] = "L" ;
$day[2] = "M" ;
$day[3] = "M" ;
$day[4] = "J" ;
$day[5] = "V" ;
$day[6] = "S" ;
$error01 = "Erreur : date invalide"
?>
<html>
<head>
<style>
#general
{
font-family: Arial;
font-size: 10pt;
}
a:link,a:active,a:visited
{
text-decoration:none;
color:#000000;
}
a:hover
{
text-decoration:underline;
color:#000000;
}
</style>
<script language='JavaScript'>
window.resizeTo(200,320) ;
function modifier (jour)
{
window.location.href = "mycalendar.php?form=<?php echo $form;?>&elem=<?php echo $elem;?>&mois=" + document.forms["MyCalendar"].elements['month'].options[document.forms["MyCalendar"].elements['month'].selectedIndex].value + "&jour=" + jour +"&annee=" + document.forms["MyCalendar"].elements['year'].options[document.forms["MyCalendar"].elements['year'].selectedIndex].value
}
<?php
if (!isset($jour))
$jour = date("j") ;
if (!isset($mois))
$mois = date("m") ;
if (!isset($annee))
$annee = date("Y") ;
// nombre de jours par mois
$nbjmonth[0] = 31 ;
$nbjmonth[1] = ($annee%4==0?($annee%100==0?($annee%400?29:28):29):28) ;
$nbjmonth[2] = 31 ;
$nbjmonth[3] = 30 ;
$nbjmonth[4] = 31 ;
$nbjmonth[5] = 30 ;
$nbjmonth[6] = 31;
$nbjmonth[7] = 31 ;
$nbjmonth[8] = 30 ;
$nbjmonth[9] = 31 ;
$nbjmonth[10] = 30 ;
$nbjmonth[11] = 31 ;
if(!checkdate($mois,$jour,$annee))
{
echo "alert('$error01')\n" ;
$jour = date("j") ;
$mois = date("m") ;
$annee = date("Y") ;
}
// Calcul du jour julien et du numéro du jour
$HR = 0;
$GGG = 1;
if( $annee < 1582 ) $GGG = 0;
if( $annee <= 1582 && $mois < 10 ) $GGG = 0;
if( $annee <= 1582 && $mois == 10 && 1 < 5 ) $GGG = 0;
$JD = -1 * floor(7 * (floor(($mois + 9) / 12) + $annee) / 4);
$S = 1;
if (($mois - 9)<0) $S=-1;
$A = abs($mois - 9);
$J1 = floor($mois + $S * floor($A / 7));
$J1 = -1 * floor((floor($J1 / 100) + 1) * 3 / 4);
$JD = $JD + floor(275 * $mois / 9) + 1 + ($GGG * $J1);
$JD = $JD + 1721027 + 2 * $GGG + 367 * $annee - 0.5;
/*$tmp = ((int)(($mois>2?$annee:$annee-1)/100)) ;
$jj = (int)((((int)(365.25*($mois>2?$annee:$annee-1))) + ((int)(30.6001*($mois>2?$mois+1:$mois+13))) + $jour + 1720994.5 + ($annee > 1582 && $mois > 10 && $jour > 15?2-$tmp+((int)($tmp/4)):0))) ;
$jj = (int)(($jj) % 7)*/
$jj = (($JD+.5)%7) ;
?>
</script>
</head>
<?php
echo "<body bgcolor='#$bgcolor' onUnLoad=''>\n" ;
echo "<center><form name='MyCalendar'>\n" ;
echo "<table width='170' cellspacing='0' cellspading='0' border='0'><tr>\n" ;
// Affichage de la sélection du mois et de l'année
echo "<td><select name='month' onChange=\"modifier($jour)\">\n" ;
for ($i=0;$i<12;$i++)
{
echo "<option value='".($i+1)."'".($mois==($i+1)?" selected":"").">".$month[$i]."</option>\n" ;
}
echo "</select></td>\n" ;
echo "<td align='right'><select name='year' onChange=\"modifier($jour)\">\n" ;
$y = date("Y") ;
for ($i=$y-10;$i<$y+10;$i++)
{
echo "<option value='$i'".($annee==($i)?" selected":"").">$i</option>\n" ;
}
echo "</select></td></tr><tr><td colspan='2'> </td></tr>\n" ;
echo "<tr><td colspan='2'><table width='100%' cellspacing='0' cellspading='0' border='0'>\n" ;
echo "<tr>\n" ;
// Affichage des jours
for($i=0;$i<7;$i++)
{
echo "<td width='14%' bgcolor='#$daybgcolor'><font id='general'>".$day[$i]."</font></td>" ;
}
echo "</tr>\n<tr><td colspan='7'> </td></tr>\n<tr>\n" ;
// Première ligne des jours
$j = $jj ;//date ("w", mktime (0,0,0,$mois,1,$annee)) ;
$dom = 1 ;
for ($i=0;$i<7;$i++)
{
if ($j<=$i)
{
echo "<td".($dom==$jour?" bgcolor='#$dombgcolor'":"")."><a href='javascript:modifier($dom)'><font id='general'>".$dom++."</font></a></td>\n" ;
}
else
echo "<td> </td>\n" ;
}
echo "</tr>\n" ;
// Le reste
for ($i=0;$i<5;$i++)
{
echo "<tr>\n" ;
for ($j=0;$j<7;$j++)
{
$j_inac = ($j==0 || $j==6) ;
if($dom < $nbjmonth[($mois-1)])
echo "<td".($dom==$jour?" bgcolor='#$dombgcolor'":($j_inac ?" bgcolor='#$dayholcolor'":""))."><a href='javascript:modifier($dom)'><font id='general'>".$dom++."</font></a></td>\n" ;
else if (checkdate($mois,$dom,$annee))
echo "<td".($dom==$jour?" bgcolor='#$dombgcolor'":($j_inac ?" bgcolor='#$dayholcolor'":""))."><a href='javascript:modifier($dom)'><font id='general'>".$dom++."</font></a></td>\n" ;
else
echo "<td> </td>\n" ;
}
echo "</tr>\n" ;
}
echo "\n<tr><td colspan='10' align='center'><input type='button' onclick='window.opener.document.forms[\"$form\"].elements[\"$elem\"].value=\"$annee-$mois-$jour\";window.close()' value='Valider'> <input onclick='window.close()' type='button' value='Annuler'></td></tr></table>\n" ;
echo "\n</tr></table>\n" ;
echo "</td></tr></table>" ;
echo "</form></center>" ;
echo "</body>\n" ;
?>
</html> |
Partager