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
| $tabmonth = Array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin","Juillet",
"Août", "Septembre", "Octobre", "Novembre","Décembre");
$tabday = Array("Lun", "Mar", "Mer", "Jeu", "Ven", "Sam","Dim");
// selectionne la date d aujourd hui si aucune saisie
if (!$dt)
{
$year = date("Y");
$now = date("Y/m/d");
$month = date("n");
$day = date("d");
}
else
{
$data=explode(" ",$dt);
$year=$data[0];
$month=$data[1];
$day=$data[2];
$now=date("Y/m/d", mktime(0,0,0,$month,$day,$year));
echo "now = $now";
}
$moyear=$tabmonth[$month-1]." ".$year;
?>
<table WIDTH="160" BORDER="0" CELLSPACING="0" CELLPADDING="2">
<tr>
<td CLASS='titremois' colspan="8" ALIGN="center">
<?
$lien=date("Y+m+d", mktime(0,0,0,$month,$day-1,$year));
echo "<A CLASS='titremois' href=\"testcalendrier5.php?dt=$lien\">< </a>";
$lien=date("Y+m+d", mktime(0,0,0,$month-1,$day,$year));
echo "<A CLASS='titremois' href=\"testcalendrier5.php?dt=$lien\"><<</a>";
echo "<A CLASS='titremois'> $moyear </a>";
$lien=date("Y+m+d", mktime(0,0,0,$month+1,$day,$year));
echo "<A CLASS='titremois' href=\"testcalendrier5.php?dt=$lien\">>> </a>";
$lien=date("Y+m+d", mktime(0,0,0,$month,$day+1,$year));
echo "<A CLASS='titremois' href=\"testcalendrier5.php?dt=$lien\">></a>";
?>
</td>
</tr>
<tr>
<?
echo"<td WIDTH=20 class='titreweek' ALIGN='center'>Sem</td>\n";
for ($i=0;$i<7;$i++)
{
echo"<td WIDTH=20 class='titrejours' ALIGN='center'>$tabday[$i]</td>\n";
}
?>
</tr>
<?
//Me permet de connaitre le numero du jour de la semaine
//Mais comme cela commence a 0 pour le dimanche si j'ai 0 je mets 7
$num_day=date("w", mktime(0 ,0 ,0 ,$month,01,$year ));
echo "num_day = $num_day";
if($num_day==0)
{
$num_day=7;
}//Me permet de connaitre exactement le nombre de jour dans le mois
$max_day=date("t", mktime(0,0,0,$month,01,$year)); $cpt_day=2;
while ($cpt_day<=$max_day+$num_day)
{
echo "<tr>";
// calcul le numero de semaine
$nb_day=date("z", mktime(0,0,0,$month,$cpt_day-$num_day+3,$year));
$val=intval($nb_day/7)+1;
echo "<td WIDTH=20 class='titreweek2' ALIGN='center'>".(($val < 10) ? "0".$val : $val)."</td>\n";
// affiche les jours du mois
for ($i=0;$i<7;$i++) {
$theday=date("D", mktime(0,0,0,$month,$cpt_day-$num_day,$year));
$val=date("d", mktime(0,0,0,$month,$cpt_day-$num_day,$year));
// $jourferie=calcul_joursferies($month,$cpt_day-$num_day,$year);
$class="titrenum";
if (($theday=="Sun") or ($theday=="Sat")){ $class="titrewend";}
if ($now==date("Y/m/d",mktime(0,0,0,$month,$cpt_day-$num_day,$year))){ $class="titrenow";}
if ((($cpt_day-$num_day)<1) or (($cpt_day-$num_day)>$max_day)){
$class="titrenum2";
if (($theday=="Sun") or ($theday=="Sat")){ $class="titrewend2";}
}
$cpt_day++;
echo "<td WIDTH=20 class='$class'ALIGN='center'>".$val."</td>\n";
}
echo "</tr>";
}
?>
</table> |
Partager