<script type="text/javascript">
function changeColorCell(id_cell) {
var cell= document.getElementById(id_cell);
var campo= document.getElementById('hid_' + id_cell);
if (cell.style.backgroundColor=='red') {
cell.style.backgroundColor='green';
campo.value=id_cell;
}
else {
cell.style.backgroundColor='red';
campo.value='0';
}
}
function submit_form() {
document.forms['myform'].submit();
}
</script>
<?
if($mese==1) {
$mese_precedente=12;
$mese_successivo=$mese+1;
$anno_precedente=$anno-1;
$anno_successivo=$anno;
}
elseif($mese==12) {
$mese_successivo=1;
$mese_precedente=$mese-1;
$anno_precedente=$anno;
$anno_successivo=$anno+1;
}
else {
$mese_successivo=$mese+1;
$mese_precedente=$mese-1;
$anno_precedente=$anno;
$anno_successivo=$anno;
}
$mese_stamp=mktime(0,0,0,$mese,1,$anno);
$numero_giorni=intval(date("t",$mese_stamp));?>
<h3><?=$mesi[$mese]." ".$anno;?></h3><?
?>
<form id="myform" action="action.php" method="post">
<table>
<tr>
<td class="days_calendar">LUN</td>
<td class="days_calendar">MAR</td>
<td class="days_calendar">MER</td>
<td class="days_calendar">GIO</td>
<td class="days_calendar">VEN</td>
<td class="days_calendar">SAB</td>
<td class="days_calendar">DOM</td>
</tr>
<tr><?
$w=date('w',mktime(0,0,0,$mese,date(1),$anno));
$day=1;
$num_celle= ($w+$numero_giorni) > 36? 42 : 35;
for($i=1;$i<=$num_celle;$i++) {
$time_stamp=mktime(0,0,0,$mese,date($day),$anno);
if($i<$w || $day>$numero_giorni) {?>
<td class="no_day"> </td><?
}
elseif($time_stamp < time()) {?>
<td id="<?=$time_stamp;?>" style="background-color:#999999" class="cell_calendar"><?=$day;?></td><?
$day++;
}
else {?>
<td id="<?=$time_stamp;?>" onclick="changeColorCell('<?=$time_stamp;?>')" class="cell_calendar"<?
$query="SELECT timestamp FROM calendario WHERE timestamp='".$time_stamp."' AND id_utente='".$_SESSION['id']."'";
$query=mysql_query($query,$connessione);
if(mysql_num_rows($query))
echo ' style="background-color:green;"';
?>><?=$day;$day++;?>
<input type="hidden" id="hid_<?=$time_stamp;?>" name="calendario[]" value="<?
if(mysql_num_rows($query))
echo $time_stamp;
?>" /></td><?
}
if($i%7==0) {?>
</tr>
<tr><?
}
}?>
</tr>
<tr>
<td>
<a href="prove.php?mese=<?=$mese_precedente;?>&anno=<?=$anno_precedente;?>#CAL" onclick="submit_form()">«</a>
</td>
<td colspan="5"> </td>
<td align="right">
<a href="prove.php?mese=<?=$mese_successivo;?>&anno=<?=$anno_successivo;?>#CAL" onclick="submit_form()">»</a>
</td>
</tr>
</table>
<a name="CAL"></a>
<br />
<input type="hidden" id="mese" name="mese" value="<?=$mese;?>" />
<input type="hidden" id="anno" name="anno" value="<?=$anno;?>" />
<input type="hidden" id="ACTION" name="ACTION" value="calendario" />
<div align="center"><input type="submit" id="procedi" name="procedi" value="Procedi" /></div>
</form><?
$q=mysql_query("SELECT decide_prove FROM utenti WHERE id='".$_SESSION['id']."'",$connessione);
$decide_prove=mysql_result($q,0,'decide_prove');
if($decide_prove) {?>
<br /><br />
<a href="action.php?ACTION=decidi_prove">Decidi le prossime prove</a><?
}
?>