I want to create a filter per month in the calendar.
Code:
<!DOCTYPE HTML>
<html lang="pt-pt">
<head>
<meta charset="UTF-8">
<title>Registo Refeições</title>
<?php
date_default_timezone_set('Europe/Lisbon');
$dates = date('Y/m/d');
$hoje = getdate(strtotime($dates));
$mes = array('', 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
$ultimoDia = cal_days_in_month(CAL_GREGORIAN,
$hoje['mon'],
$hoje['year']);
$primeiraSemana = (($hoje['wday'] + 1) -
($hoje['mday'] - ((int)($hoje['mday'] / 6) * 7))) % 7;
?>
<style>
td { color: #000000;}
</style>
</head>
<body>
<h1>Estamos em <?= $hoje['year'] ?> de <?= $mes[$hoje["mon"]] ?></h1>
<p><?= sprintf('Hoje é dia <strong>%0d / %0d</strong>.',
$hoje['mday'], $hoje['mon'])
?></p>
<table >
<caption><h1><center><strong><?= $mes[$hoje["mon"]] ?> - <?= $hoje['year'] ?></strong></center></h1></caption>
<tr>
<th bgcolor="silver" align="center">Domingo</th>
<th bgcolor="silver" align="center">Segunda</th>
<th bgcolor="silver" align="center">Terça</th>
<th bgcolor="silver" align="center">Quarta</th>
<th bgcolor="silver" align="center">Quinta</th>
<th bgcolor="silver" align="center">Sexta</th>
<th bgcolor="silver" align="center">Sábado</th>
</tr>
<tr>
<form action="" method="POST">
<?php
for($semana = 0; $semana < $primeiraSemana; ++$semana) {
echo '<td> </td>';
}
for($dia = 1; $dia < $ultimoDia; ++$dia) {
if( $semana > 6 ) {
$semana = 0;
echo '</tr><tr>';
}
echo "<td bgcolor='#F5F5F5' align='center' data-semana=\"$semana\"><center><font size='2px'/>";
echo "<input type='checkbox' name='"; echo "arrachar[$dia][dia]"; echo"' value='$dia'> $dia<center>
<p><input type='checkbox' name='"; echo "arrachar[$dia][OpcaoA]"; echo"' value='Peq. Almoço'> Peq. Almoço
<p><input type='checkbox' name='"; echo "arrachar[$dia][opcaoB]"; echo"' value='Almoço'> Almoço
<p><input type='checkbox' name='"; echo "arrachar[$dia][opcaoB]"; echo"' value='Almoço Dieta'> Almoço (Dieta)
<p><input type='checkbox' name='"; echo "arrachar[$dia][opcaoC]"; echo"' value='Lanche'> Lanche
<p><input type='checkbox' name='"; echo "arrachar[$dia][opcaoD]"; echo"' value='Jantar'> Jantar
<p><input type='checkbox' name='"; echo "arrachar[$dia][opcaoD]"; echo"' value='Jantar Dieta'> Jantar (Dieta)</td>";
++$semana;
}
for(; $semana < 7; ++$semana) {
echo '<td> </td>';
}
?>
<?php
if( !empty( $_POST['dias'] ) ) {
foreach( $_POST['dias'] as $key => $values ) {
echo "<br />Semana $key<br />";
foreach( $values as $dias ) {
echo "$dias<br />";
}
}
}
?>
<input type="submit" name="submit" value="Marcar">
</form>
</tr>
</table>
</body>
I intend to create a combo with the months and when selecting the calendar modifies for the chosen month. In addition to creating the combo, I need to fix my code, since the month of March has 31 days and my calendar is only mounting 30 days.