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
| <?php
function calculDateDebut($dateDeb, $jourChoisiFR)
{
$choixPossible = array('monday' => 'lundi', 'sunday' => 'dimanche');
$jourChoisiEN = array_search($jourChoisiFR, $choixPossible);
$dateDeb -> modify('+1 month');
$libelleJour = strftime('%A', $dateDeb -> format('U'));
if ($libelleJour != $jourChoisiFR)
{
$dateDeb -> modify('next ' . $jourChoisiEN);
}
return $dateDeb;
}
function calculSemaine($nbSemaine, $dateDeb)
{
$semaine = '';
$i = 0;
while ($i < $nbSemaine)
{
$debut = $dateDeb -> format('d/m/Y');
$dateDeb -> modify('+6 days');
$fin = $dateDeb -> format('d/m/Y');
$semaine .= '<tr><td>du ' . $debut . '</td><td>au ' . $fin . '</td><td><input type="radio" name="radiobutton'.$i.'" vvalue="libre-'.$i.'-'.$debut.'-'.$fin.'">Libre</td><td><input type="radio" name="radiobutton'.$i.'" value="occupe-'.$i.'-'.$debut.'-'.$fin.'">Occupé</td><td><input name="prix'.$i.'" type="text" size="10" id="prix'.$i.'"></td></tr>' . "\n";
$dateDeb -> modify('+1 days');
$i ++;
}
return $semaine;
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
setlocale(LC_TIME, 'fr', 'fr_FR', 'fr_FR.ISO8859-1');
$nbSemaineAAfficher = 52;
$jourChoisi = 'dimanche';
$dateDeb = new DateTime();
?>
<html>
<head>
</head>
<body>
<table align="center" border="1">
<form id="form1" name="form1" method="post" action="">
<td>Date de début</td><td>Date de fin</td><td>Libre</td><td>Occupé</td><td>Prix</td>
<?php echo calculSemaine($nbSemaineAAfficher, calculDateDebut($dateDeb, $jourChoisi)); ?>
</form>
</table>
</body>
</html> |
Partager