<?php
include_once('top.inc.php');
include_once('db.php');
include_once('funzioni.php');
//Global $_GET;
if ($_GET['x'] == NULL){
$mese_ = date('m');
$anno_ = date('Y');
}
else{
$mese_ = (int)strftime( "%m" ,(int)$_GET['x']);
$anno_ = (int)strftime( "%Y" ,(int)$_GET['x']);
}
$prev = mktime(0, 0, 0, $mese_ -1, 1, $anno_);
$next = mktime(0, 0, 0, $mese_ +1, 1, $anno_);
$human_month = array("error", "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" );
$settimana = array("Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica");
$colonne = 7;
$giorni = date("t",mktime(0, 0, 0, $mese_, 1, $anno_)); //giorni del mese in questione
$primo_lunedi= date("w",mktime(0, 0, 0, $mese_, 1, $anno_)); //Array_parte da 0
if($primo_lunedi==0){
$primo_lunedi = 7; //siamo mica americani
}
echo('<div><a href="?x='.$prev.'" class="cal_gg">«</a> <span class="cal_gg">'.$human_month[(int)$mese_].' '.$anno_.'</span> <a href="?x='.$next.'" class="cal_gg">»</a></div><br />'); //mese - anno
echo('<table width="90%" class="tab_cal" border="1"><tr>'); //table
foreach($settimana as $val){
echo('<td class="cal_gg">'.$val.'</td>');
}
echo('</tr>');
$tr = TRUE;
for($i = 1; $i<$giorni+$primo_lunedi; $i++){
if($tr==TRUE){
echo('<tr>');
$tr = FALSE;
}
if($i<$primo_lunedi){
echo('<td class="td_cal_vuota"> </td>');
$tr = false;
if ($vuoti == NULL) {
$vuoti = 1;
}
else {
$vuoti++;
}
}
else{
$giorno_= $i-($primo_lunedi-1);
$a = strtotime(date($anno_."-".$mese_."-".$giorno_));
$b = strtotime(date("Y-m-d"));
// uncomment when debugging
/*echo($giorno_."-".$mese_."-".$anno_);
echo(" -> ");
echo(strftime("%d-%m-%Y",$a));
//echo($a);
echo(" -> ");
echo(strftime("%d-%m-%Y",$b));
//echo($b);
echo("<br>");
*/
if($a != $b){
echo('<td class="txt_day">'.$giorno_);
eventi($anno_, $mese_, $giorno_);
echo('</td>');
}
else{
echo('<td class="txt_today">'.$giorno_);
eventi($anno_, $mese_, $giorno_);
echo('</td>');
}
}
if($i % $colonne==0){
echo('</tr>');
$tr = TRUE;
}
}
//disegno le celle vuote
for ($rim = $giorni % 7 + $vuoti; $rim >= 0; $rim--) {
echo('<td class="td_cal_vuota"> </td>');
}
echo('</tr></table>');
include_once('bottom.inc.php');
?>