<?php // Draw a month calendar box
$startDay = 1;
$endDay = $monthDays;
if ($firstWday != 0) { $startDay -= $firstWday; }
if ($lastWday != 6) { $endDay += (6 - $lastWday); }
$tempWday = 0;
for($i=$startDay;$i<=$endDay;$i++) {
if ($tempWday == 0) { echo '<tr>'; }
$day = 'day'.$tempWday;
$class = ($tempWday == 0 or $tempWday == 6) ? 'weekEnd' : 'weekDay';
$tempWday++;
if ($i < 1 or $i > $monthDays) {
echo '<td class="'.$class.'"></td>';
continue;
}
if ($calendar->$day == 'Y') { // Working day
if (isset($timetable[$i])) {
$class = $timetableChk[$i] == $fullTimetable ? 'full' : 'busy';
}
else { $class = 'free'; }
}
if ($this->y == $this->today_y and $this->m == $this->today_m and $i == $this->today_d) { $class = 'today'; }
if ($i == $this->d) { $class = 'selected'; }
$onclick = ($calendar->$day == 'Y') ? 'onclick="changeCalendar('.$this->calendar_id.','.$this->y.','.$this->m.','.$i.');"' : '';
$style = ($calendar->$day == 'Y') ? 'style="cursor:pointer"' : '';
echo '<td class="'.$class.'" '.$onclick.' '.$style.'>',$i,'</td>';
if ($tempWday == 7) { echo '<tr>'; $tempWday=0; }
}
?>