<?php
/*
* ARBS - Advanced Resource Booking System
* Copyright (C) 2005-2007 ITMC der TU Dortmund
* Based on MRBS by Daniel Gardner <http://mrbs.sourceforge.net/>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
function minicals($year, $month, $day, $area, $category) {
// PHP Calendar Class
//
// Copyright David Wilkinson 2000. All Rights reserved.
//
// This software may be used, modified and distributed freely
// providing this copyright notice remains intact at the head
// of the file.
//
// This software is freeware. The author accepts no liability for
// any loss or damages whatsoever incurred directly or indirectly
// from the use of this script.
//
// URL: http://www.cascade.org.uk/software/php/calendar/
// Email: hide@address.com
class Calendar{
var $month;
var $year;
var $day;
var $h;
var $area;
var $category;
function Calendar($day, $month, $year, $h, $area,$category){
$this->day = $day;
$this->month = $month;
$this->year = $year;
$this->h = $h;
$this->area = $area;
$this->category = $category;
}
function getCalendarLink($month, $year){
return "";
}
function getDateLink($href, $day, $month, $year) {
return "week.php".$href."year=$year&month=$month&day=$day&area=".$this->area."&category=".$this->category;
}
function getDaysInMonth($month, $year){
if ($month < 1 || $month > 12){
return 0;
}
$days = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$d = $days[$month - 1];
if ($month == 2){
// Check for leap year
// Forget the 4000 rule, I doubt I'll be around then...
if ($year%4 == 0){
if ($year%100 == 0){
if ($year%400 == 0){
$d = 29;
}
}
else{
$d = 29;
}
}
}
return $d;
}
function getFirstDays(){
global $weekstarts;
$basetime = mktime(12,0,0,6,11+$weekstarts,2000);
for ($i = 0, $s = ""; $i < 7; $i++){
$show = $basetime + ($i * 24 * 60 * 60);
$fl = substr(parseDate(strftime('%a',$show)),0,1);
$s .= "<td align=center valign=top class=\"calendarHeader\">$fl</td>\n";
}
return $s;
}
function getHTML(){
global $weekstarts;
if (!isset($weekstarts)) $weekstarts = 0;
$s = "";
$daysInMonth = $this->getDaysInMonth($this->month, $this->year);
$date = mktime(12, 0, 0, $this->month, 1, $this->year);
$first = (strftime("%w",$date) + 7 - $weekstarts) % 7;
$monthName = parseDate(strftime("%B",$date));
$prevMonth = $this->getCalendarLink($this->month - 1 > 0 ? $this->month - 1 : 12, $this->month - 1 > 0 ? $this->year : $this->year - 1);
$nextMonth = $this->getCalendarLink($this->month + 1 <= 12 ? $this->month + 1 : 1, $this->month + 1 <= 12 ? $this->year : $this->year + 1);
$s .= "<table class=\"calendar\">\n";
$s .= "<tr>\n";
//$s .= "<td align=center valign=top>" . (($prevMonth == "") ? " " : "<a href=\"$prevMonth\"><<</a>") . "</td>\n";
$s .= "<td align=center valign=top class=\"calendarHeader\" colspan=7>$monthName $this->year</td>\n";
//$s .= "<td align=center valign=top>" . (($nextMonth == "") ? " " : "<a href=\"$nextMonth\">>></a>") . "</td>\n";
$s .= "</tr>\n";
$s .= "<tr>\n";
$s .= $this->getFirstDays();
$s .= "</tr>\n";
$d = 1 - $first;
while ($d <= $daysInMonth){
$s .= "<tr>\n";
for ($i = 0; $i < 7; $i++){
$s .= "<td class=\"calendar\" align=right valign=top>";
if ($d > 0 && $d <= $daysInMonth){
$link = $this->getDateLink($href,$d, $this->month, $this->year);
if ($link == "")
$s .= $d;
elseif (($d == $this->day) and ($this->h))
$s .= "<a href=\"$link\"><font color=\"red\">$d</font></a>";
else
$s .= "<a href=\"$link\">$d</a>";
}
else{
$s .= " ";
}
$s .= "</td>\n";
$d++;
}
$s .= "</tr>\n";
}
$s .= "</table>\n";
return $s;
}
}
$lastmonth = mktime(0, 0, 0, $month-1, 1, $year);
$thismonth = mktime(0, 0, 0, $month, $day, $year);
$nextmonth = mktime(0, 0, 0, $month+1, 1, $year);
echo "<td width='15%'>";
$cal = new Calendar(date("d",$lastmonth), date("m",$lastmonth), date("Y",$lastmonth), 0, $area,$category);
echo $cal->getHTML();
echo "</td>";
echo "<td width='15%'>";
$cal = new Calendar(date("d",$thismonth), date("m",$thismonth), date("Y",$thismonth), 1, $area,$category);
echo $cal->getHTML();
echo "</td>";
echo "<td width='15%'>";
$cal = new Calendar(date("d",$nextmonth), date("m",$nextmonth), date("Y",$nextmonth), 0, $area,$category);
echo $cal->getHTML();
echo "</td>";
}
?>