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
|
define("ADAY", (60*60*24));
$thisYear = date('Y');
if ((!isset($_POST['month'])) || (!isset($_POST['year']))) {
$nowArray = getdate();
$month = $nowArray['mon'];
$year = $nowArray['year'];
} else {
$month = $_POST['month'];
$year = $_POST['year'];
}
$start = mktime(12,0,0,$month,1,$year);
$firstDayArray = getdate($start);
?>
<html>
<head>
<title><?php echo "Calendar: ".$firstDayArray['month']."" . $firstDayArray['year']; ?></title>
<script language="JavaScript">
function add_it(){
document.cal.jour.value = document.getElementById("day").innerText;
}
</script>
</head>
<script type="text/javascript">
function eventWindow(url){
event_popupWin = window.open(url, 'event', 'resizable=yes, scrollbars=yes, toolbar=no,width=400,height=400');
event_popupWin.opener = self;
}
</script>
<body>
<h1>Choix de la Date</h1>
<form name="cal" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="month">
<?php
$months = Array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
for ($x=1; $x<=count($months); $x++){
echo "<option value=\"$x\"";
if ($x == $month){
echo " selected";
}
echo ">".$months[$x-1]."</option>";
}
?>
</select>
<select name="year">
<?php
for ($x=$thisYear; $x<=$thisYear + 1; $x++){
echo "<option";
if ($x == $year){
echo " selected";
}
echo ">$x</option>";
}
?>
</select>
<input type="submit" name="submit" value="Afficher le mois choisi">
<br />
<?php
$days = Array("Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam");
echo "<table border=\"1\" cellpadding=\"3\"><tr>\n";
foreach ($days as $day){
echo "<td style=\"background-color: #aeaeae; text-align: center; width: 14% \"><strong>$day</strong></td>\n";
}
for ($count=0; $count < (6*7); $count++){
$dayArray = getdate($start);
if (($count % 7) == 0){
if ($dayArray['mon'] != $month){
break;
} else {
echo "</tr><tr bgcolor=#cccccc>\n";
}
}
if ($count < $firstDayArray['wday'] || $dayArray['mon'] != $month){
echo "<td> </td>\n";
} else {
echo "<td valign=top width=50 height=50 id=day bgcolor=#cccccc onClick=\"javascript: style.backgroundColor='#cc0000'; style.Color='#ffffff'; add_it();\" onBlur=\"style.backgroundColor='#cccccc'; style.Color='#000000';\">".$dayArray['mday']."</td>\n";
$start += ADAY;
}
}
echo "</tr></table>";
?>
<input type="text" name="jour" readonly>
</form>
</body>
</html> |
Partager