Location: PHPKode > projects > Silicon Fodder > SiliconFodder/DocumentRoot/diary/diary.php
<? require_once("../common/includes.php"); ?>
<? require_once("../admin/util.php"); ?>
<? require_once("../util/general.php"); ?>
<? require_once("../diary/util.php"); ?>
<? require_once("../diary/getevents.php"); ?>
<?
$daysToView = $HTTP_GET_VARS["dtv"];

$mulview    = $HTTP_GET_VARS["mulview"];
if($mulview == "true") {
	require_once("../permissions/util.php");
	$useridsToShow = getUserIdsArr(1, 0);
}

$currentDay   = $HTTP_GET_VARS["cd"] - 1;
$currentWeek  = $HTTP_GET_VARS["cw"];
$currentMonth = $HTTP_GET_VARS["cm"];
$currentYear  = $HTTP_GET_VARS["cy"];
$viewFor      = $HTTP_GET_VARS["viewFor"];
$p2           = $HTTP_GET_VARS["p2"];
$p2n          = $HTTP_GET_VARS["p2n"];
$client	      = $HTTP_GET_VARS["client"];
$openDiary    = $HTTP_GET_VARS["od"];
$myaction     = $HTTP_GET_VARS["myaction"];
$productId    = $HTTP_GET_VARS["productId"];
$eventType    = $HTTP_GET_VARS["eventType"];

$firstDayOfMonth = strtotime($arrMonths[$currentMonth]." 1, ".$currentYear." 12:00:00");
// note - setting the above to 12:00, since DateAdd() function used below has slight problems when adding days over summertime boundry
$firstDay        = (date("w",$firstDayOfMonth) - 1) % 7;
if($firstDay<0) $firstDay += 7;

// date for first block on page
$currentDate = DateAdd("d", (($currentWeek - 1) * 7) - $firstDay, $firstDayOfMonth);
// Todo - Fixes problems I caused by adding "12:00:00" above - needs sorting properly
// Note the 2 - I added this recently because recurring events had trouble over british summer time boundry
$currentDate = mktime(2, 0, 0, date("n", $currentDate), date("j", $currentDate), date("Y", $currentDate));
if($daysToView == 31) $currentDate = $firstDayOfMonth;
?>
<html>
<head>
<? $noSwish = true; ?>
<? require_once("../common/head.php"); ?>
<? require_once("../common/js.php"); ?>
<style>
.dispDate {
	text-align: right;
	color: #000000;
	background-color: #ECE9D8;
	height: 15px;
	width: 50%;
}
.dispContent {
	vertical-align: top;
	background-color: #FFFFD5;
	height: 33%;
}
.dispContentHol {
	vertical-align: top;
	background-color: #<?=$holidaycolour?>;
	height: 33%;
}
.dispContent2 {
	vertical-align: top;
	background-color: #FFFFD5;
	height: 17%;
}
.dispContentHol2 {
	vertical-align: top;
	background-color: #<?=$holidaycolour?>;
	height: 17%;
}
.dispAdd {
	text-align: left;
	background-color: #ECE9D8;
	height:15px;
}
.singleHour {
	background-color: #EEEEB5;
	font-size: 10px;
	vertical-align: top;
}
.busySingleHour {
	background-color: #BBBB95";
	font-size: 10px;
	vertical-align: top;
}
.timesheetSingleHour {
	background-color: <?=$eventColours[991]?>;
	font-size: 10px;
	vertical-align: top;
}
.notworkingSingleHour {
	background-color: #ECE9D8;
	font-size: 10px;
	vertical-align: top;
}
.holidaySingleHour {
	background-color: #<?=$holidaycolour?>;
	font-size: 10px;
	vertical-align: top;
}
.mview {
	background-color: #FFFFD5;
	height: 70px;
	width: 14%;
	vertical-align: top;
}
.mviewblank {
	background-color: #EEEEEE;
	height: 70px;
	width: 14%;
	vertical-align: top;
}
</style>
<script type="text/javascript">
function addEvent(myDay, myMonth, myYear) {
	popup('addDiary.php?ad=' + myDay + '&am=' + myMonth + '&ay=' + myYear + '&p2=<?=$p2?>&p2n=<?=eregi_replace("'", "\\'", $p2n)?>&startTime=09:00&endTime=11:00&client=<?=$client?>','Diary','','','',400,350);
}
function addEventWithTime(myDay, myMonth, myYear, myStartTime, myEndTime) {
	popup('addDiary.php?ad=' + myDay + '&am=' + myMonth + '&ay=' + myYear + '&p2=<?=$p2?>&p2n=<?=eregi_replace("'", "\\'", $p2n)?>&startTime=' + myStartTime + '&endTime=' + myEndTime + '&client=<?=$client?>','Diary','','','',400,350);
}
function addEventWithTimeAndPerson(myDay, myMonth, myYear, myStartTime, myEndTime, p2, p2n) {
<? if($eventType == 991) { ?>
	parent.location = '../projects/viewall.php';
<? } else { ?>
	popup('addDiary.php?ad=' + myDay + '&am=' + myMonth + '&ay=' + myYear + '&p2=' + p2 + '&p2n=' + p2n + '&startTime=' + myStartTime + '&endTime=' + myEndTime + '&client=<?=$client?>','Diary','','','',400,350);
<? } ?>
}
function viewEvent(diaryId, smartdb) {
	popup('addDiary.php?did=' + diaryId + '&sdb=' + smartdb,'Diary','','','',400,350);
}
function viewProject(diaryId) {
	parent.location = '../projects/project.php?diaryId='+diaryId;
}
function viewBooking(diaryId) {
	parent.location = '../bookings/index.php?diaryId='+diaryId;
}
function confirmapp(userid, busykey) {
	parent.location = '../bookings/makebooking.php?clientid=<?=$client?>&productId=<?=$productId?>&myaction=confirmbooking&userid='+userid+'&hourkey='+busykey+'&dbdate=<?=displayDay($currentDate, $currentDay, false, true)?>';
}
<?
if($openDiary != "") {
	echo "viewEvent(".$openDiary.",'');\n";
}
?>
</script>
</head>
<?
if($HTTP_SESSION_VARS["is-smart"] == "true") {
	$sqlWhere = "eventType=995 AND";
	$viewFor = "all";
} elseif($eventType != "" && $eventType != "0") {
	$sqlWhere = "eventType=".$eventType." AND";
	$viewFor = "all";
} elseif($p2 != "") {
	$sqlWhere = "(userid=0 OR userid=".$p2.") AND";
} elseif($viewFor == "me") {
	$sqlWhere = "(userid=0 OR userid=".$HTTP_SESSION_VARS["mwoid"].") AND";
} elseif($viewFor == "all") {
	$sqlWhere = "";
} else {
	$sqlWhere = "(userid=0 OR department=".$viewFor.") AND";
}
// unless we just on time-sheet view, strip out time sheets (and tasks too)
if($eventType != "991") {
	$sqlWhere.= " eventType NOT IN (991,996,997) AND";
} else {
	$sqlWhere.= " eventType NOT IN (996,997) AND";
}

if($daysToView == 31) {
	$dbdate1 = dateForDb($currentDate, getDaysInMonth($currentMonth, $currentYear) - 1);
	$dbdate2 = dateForDb($currentDate, 0);
} elseif($daysToView == 1) {
	$dbdate1 = dateForDb($currentDate, $currentDay + 1);
	$dbdate2 = dateForDb($currentDate, $currentDay);
} else {
	$dbdate1 = dateForDb($currentDate, 7);
	$dbdate2 = dateForDb($currentDate, 0);
}

// arrays for week view - holds content for each day, and colour (for holidays)
$diaryContent = array();
$diaryType    = array();

// dictionary for day view, will have values like diaryMinutes("8:30")
$diaryMinutes = array();

// keep track of linked diary items - we only want to display them once!
$linkedItemsSeen = array();

// does the hard work of getting events from the database
// (not for multiple view, since we call this function once per user further down)
if($mulview != "true") {
	getevents($dbdate1, $dbdate2, $sqlWhere);
}

echo "<body>";

if($client != "") {
	$diaryHeadStr = "Add appointment";
} elseif($eventType != "" && $eventType != "0") {
	$diaryHeadStr = "Timesheets";
} else {
	$diaryHeadStr = "Diary";
}
if($p2n != "") {
	$diaryHeadStr.= " for ".$p2n;
}
if($daysToView == 7) {
	//##### WEEK VIEW #####
	$diaryHeadStr.= " - ".displayDay($currentDate, 0)." to ".displayDay($currentDate, 6);
	if(getApplicationObject("SHOW_WEEK_NUMBER_YN") == "True") {
		$diaryHeadStr.= " (Week number ".getWeekNumber($currentDate).")";
	}
	dispHeader($diaryHeadStr);
	echo dispAdminView($mulview, $myaction);
	
	for($i=0; $i<7; $i++) {
		$testday = DateAdd("d", $i, $currentDate);
		if(date("Y", $testday) == date("Y") && date("n", $testday) == date("n") && date("d", $testday) == date("d")) {
			$todayStyle[$i] = " style=\"border-width: 2px;border-style: solid;border-color: red;\"";
		}
	}
?>
<table width="100%" height="98%" border="0">
<tr><td class="dispAdd">&nbsp;<a href="#" onClick="addEvent(<?=jscriptDate($currentDate, 0)?>);return false">[add]</a>&nbsp;</td><td class="dispDate"><?=$arrDayNames[0]." ".displayDay($currentDate, 0)?></td><td class="dispAdd">&nbsp;<a href="#" onClick="addEvent(<?=jscriptDate($currentDate, 1)?>);">[add]</a>&nbsp;</td><td class="dispDate"><?=$arrDayNames[1]." ".displayDay($currentDate, 1)?></td></tr>
<tr><td colspan="2" <?=$todayStyle[0]?> class="dispContent<?=$diaryType[0]?>" onDblClick="addEvent(<?=jscriptDate($currentDate, 0)?>);return false"><?=$diaryContent[0]?>&nbsp;</td><td colspan="2" <?=$todayStyle[1]?> class="dispContent<?=$diaryType[1]?>" onDblClick="addEvent(<?=jscriptDate($currentDate, 1)?>);"><?=$diaryContent[1]?>&nbsp;</td></tr>
<tr><td class="dispAdd">&nbsp;<a href="#" onClick="addEvent(<?=jscriptDate($currentDate, 2)?>);">[add]</a>&nbsp;</td><td class="dispDate"><?=$arrDayNames[2]." ".displayDay($currentDate, 2)?></td><td class="dispAdd">&nbsp;<a href="#" onClick="addEvent(<?=jscriptDate($currentDate, 3)?>);">[add]</a>&nbsp;</td><td class="dispDate"><?=$arrDayNames[3]." ".displayDay($currentDate, 3)?></td></tr>
<tr><td colspan="2" <?=$todayStyle[2]?> class="dispContent<?=$diaryType[2]?>" onDblClick="addEvent(<?=jscriptDate($currentDate, 2)?>);"><?=$diaryContent[2]?>&nbsp;</td><td colspan="2" <?=$todayStyle[3]?> class="dispContent<?=$diaryType[3]?>" onDblClick="addEvent(<?=jscriptDate($currentDate, 3)?>);"><?=$diaryContent[3]?>&nbsp;</td></tr>
<tr><td class="dispAdd">&nbsp;<a href="#" onClick="addEvent(<?=jscriptDate($currentDate, 4)?>);">[add]</a>&nbsp;</td><td class="dispDate"><?=$arrDayNames[4]." ".displayDay($currentDate, 4)?></td><td class="dispAdd">&nbsp;<a href="#" onClick="addEvent(<?=jscriptDate($currentDate, 5)?>);">[add]</a>&nbsp;</td><td class="dispDate"><?=$arrDayNames[5]." ".displayDay($currentDate, 5)?></td></tr>
<tr><td colspan="2" <?=$todayStyle[4]?> rowspan="3" class="dispContent<?=$diaryType[4]?>" onDblClick="addEvent(<?=jscriptDate($currentDate, 4)?>);"><?=$diaryContent[4]?>&nbsp;</td><td colspan="2" <?=$todayStyle[5]?> class="dispContent<?=$diaryType[5]?>2" onDblClick="addEvent(<?=jscriptDate($currentDate, 5)?>);"><?=$diaryContent[5]?>&nbsp;</td></tr>
<tr><td class="dispAdd">&nbsp;<a href="#" onClick="addEvent(<?=jscriptDate($currentDate, 6)?>);">[add]</a>&nbsp;</td><td class="dispDate"><?=$arrDayNames[6]." ".displayDay($currentDate, 6)?></td></tr>
<tr><td colspan="2" <?=$todayStyle[6]?> class="dispContent<?=$diaryType[6]?>2" onDblClick="addEvent(<?=jscriptDate($currentDate, 6)?>);"><?=$diaryContent[6]?>&nbsp;</td></tr>
</table>
<?
} elseif($daysToView == 1) {
	//##### ONE DAY VIEW #####
	$diaryHeadStr.= " - ".displayDay($currentDate, $currentDay, true);
	if(getApplicationObject("SHOW_WEEK_NUMBER_YN") == "True") {
		$diaryHeadStr.= " (Week number ".getWeekNumber($currentDate).")";
	}
	dispHeader($diaryHeadStr);
	echo dispAdminView($mulview, $myaction);

	echo displayErrorMessage();
	if($mulview == "true") {
		// get data for each user
		$arrHoldsAll = array();
		$showspanrow = false;
		foreach($useridsToShow as $useridtoshow => $usernametoshow) {
			$sqlWhere = "(userid=0 OR userid=".$useridtoshow.") AND";
			if($eventType != "" && $eventType != "0") $sqlWhere.= " eventType=".$eventType." AND";
			if($eventType != 991) $sqlWhere.= " eventType!=991 AND";

			$linkedItemsSeen = array();
			$diaryMinutes = array();
			$diaryContent = array();
			$busyContent  = array();
			$busyDiaryIds = array();
			if(getApplicationObject("webofficestartendtimes") == "yes") {
				setBusyIntervalsWithStartEndTime($useridtoshow, $currentDay, $currentDate);
			}
			getevents($dbdate1, $dbdate2, $sqlWhere);
			$arrHoldsAll[$useridtoshow]["linkedItemsSeen"] = $linkedItemsSeen;
			$arrHoldsAll[$useridtoshow]["diaryContent"] = $diaryContent;
			$arrHoldsAll[$useridtoshow]["diaryMinutes"] = $diaryMinutes;
			$arrHoldsAll[$useridtoshow]["busyContent"]  = $busyContent;
			$arrHoldsAll[$useridtoshow]["busyDiaryIds"] = $busyDiaryIds;

			if($diaryMinutes[$currentDay]["span"] != "") $showspanrow = true;
		}
		$colspan = count($useridsToShow);
		$percentwidth = floor(98 / $colspan);
?>
<table width="100%" height="98%">
<tr><td width="2%" class="dispAdd">&nbsp;</td><td colspan="<?=$colspan?>" width="98%" class="dispDate" style="position:relative"><?=$bestext.$arrDayNames[$currentDay]." ".displayDay($currentDate, $currentDay)?></td></tr>
<?
echo "<tr><td width=\"2%\" class=\"dispAdd\">&nbsp;</td>";
foreach($useridsToShow as $useridtoshow => $usernametoshow) {
	echo "<td class=\"dispAdd\" width=\"".$percentwidth."%\"><a target=\"main\" href=\"../phonebook/userItem.php?sourcePage=diary&userID=".$useridtoshow."\">".$usernametoshow."</a></td>";
}
echo "</tr>";
if($showspanrow) {
	echo "<tr><td width=\"2%\" class=\"dispAdd\">&nbsp;</td>";
	foreach($useridsToShow as $useridtoshow => $usernametoshow) {
		echo "<td class=\"singleHour\" width=\"".$percentwidth."%\">".showHourContent("span", $currentDay)."</td>";
	}
	echo "</tr>";
}
$busydaykey = date("Ymd", DateAdd("d", $currentDay, $currentDate));

$timeinc = 0.5;
if(getApplicationObject("weboffice15mins") == "yes") $timeinc = 0.25;

if($eventType==991) {
?>
<form target="main" name="frmtimesheet" method="post" action="../projects/project.php" style="padding:0px;margin:0px">
<input type="hidden" name="posted" value="3">
<input type="hidden" name="pid" value="">
<input type="hidden" name="startdate2" value="<?=displayDay($currentDate, $currentDay, false, true)?>">
<input type="hidden" name="firstblock" value="">
<input type="hidden" name="duration" value="">
<input type="hidden" name="redirectto" value="/diary/index.php?mulview=true&eventType=991">
</form>
<script language="javascript">
document.onselectstart = new Function ("event.returnValue=false; event.cancelBubble = true;");
var startdown = "";
var currentlydown = "";
var onesset = new Array(100);
for(i=0; i<onesset.length; i++) onesset[i] = 0;
function over(id) {
	if(startdown != "") {
		setcell(id);
		currentlydown = id;
	}
	enablecontext();
}
function out(id) {
}
function down(id) {
	if(event.button == 1) {
		startdown = id;
		currentlydown = id;
		clearall()
		setcell(id);
	}
}
function up(id) {
	startdown = "";
	currentlydown = "";
}
function clearall() {
	for(i=0; i<100; i++) clearcell(i);
}
function clearcell(id) {
	onesset[id] = 0;
	if(document.getElementById('cell' + id)) {
		document.getElementById('cell' + id).style.backgroundColor = '#FFFFD5';
	}
}
function setcell(id) {
	onesset[id] = 1;
	document.getElementById('cell' + id).style.backgroundColor = '#FFAAAA';
}
function showallprojects() {
	popup('../projects/projectspop.php','Projects','Yes','','',350,500);
}
function addtimesheet(id) {
	// get first one hightlighted, and the duration
	var firstone = -1;
	var numhighlighted = 0;
	var inhighlightedregion = false;
	for(i=0; i<onesset.length; i++) {
		if(onesset[i] == 1 && inhighlightedregion == false) {
			inhighlightedregion = true;
			firstone = i;
			numhighlighted = 1;
		} else if(onesset[i] == 1 && inhighlightedregion == true) {
			numhighlighted++;
		} else if(onesset[i] == 0 && inhighlightedregion == true) {
			inhighlightedregion = false;
			break;
		}
	}
	if(numhighlighted > 0) {
<? if(getApplicationObject("weboffice15mins") == "yes") { ?>
		document.frmtimesheet.firstblock.value = firstone-32;
		document.frmtimesheet.duration.value = numhighlighted * 15;
<? } else { ?>
		document.frmtimesheet.firstblock.value = firstone-16;
		document.frmtimesheet.duration.value = numhighlighted * 30;
<? } ?>
		document.frmtimesheet.pid.value = id;
		document.frmtimesheet.submit();
	}
}
</script>
<style>
/* Context menu Script - Dynamic Drive (www.dynamicdrive.com) */
.skin0 {
position:absolute;
width:165px;
border:1px solid #888888;
background-color:menu;
font-family:Verdana;
line-height:16px;
font-size:11px;
z-index:100;
visibility:hidden;
}
.menuitems {
padding-left:5px;                                                                                                                                            padding-right:5px;
cursor:pointer;
}
/* End Content Menu */
</style>
<div id="ie5menu" class="skin0" onMouseover="cancelremovecontext(); highlightie5(event)" onMouseout="removecontextinonesecond(); lowlightie5(event)" onClick="jumptoie5(event)" display:none>
<?
$myCount = 0;
$mySQL = "SELECT projects.*, companies.companyname FROM projects, companies WHERE projects.companiesId=companies.id AND userId=".$HTTP_SESSION_VARS["mwoid"]." AND projects.status>=0 ORDER BY companyname";
$rows = gendb_query($mySQL, $myDb) or die(gendb_error());
while($row = gendb_fetch_assoc($rows)) {
	$myCount++;
	if($myCount > 5) {
		break;
	}
	echo "<div class=\"menuitems\" js=\"addtimesheet(".$row["id"].")\"><strong>".$row["companyname"]."</strong> - ".$row["project"]."</div>";
}
echo "<div class=\"menuitems\" js=\"showallprojects()\">Show all...</div>";
gendb_free_result($rows);
?>
<div><hr></div>
<div class="menuitems">Cancel</div>
</div>
<script language="javascript" type="text/javascript" src="../email/context.js"></script>
<?
}

// work out rowspans for one-day-view items
foreach($useridsToShow as $useridtoshow => $usernametoshow) {
	$busyRowSpans = array();
	$busyDiaryIds = &$arrHoldsAll[$useridtoshow]["busyDiaryIds"];
	$prevDiaryId = "";
	$colspancount = 1;
	$busykeystart = "";
	for($myTime = 8; $myTime <= 23; $myTime += $timeinc) {
		if(getApplicationObject("weboffice15mins") == "yes") {
			$busykey = $myTime * 4;
		} else {
			$busykey = $myTime * 2;
		}
		$diaryId = $busyDiaryIds[$busydaykey][$busykey];

		if($diaryId == "" || strpos($diaryId, ",") !== false) {
			// empty cell or a clash
			$busyRowSpans[$busydaykey][$busykey] = 1;
			if($busykeystart != "") {$busyRowSpans[$busydaykey][$busykeystart] = $colspancount; $busykeystart = ""; $prevDiaryId = "";}
		} elseif($diaryId == $prevDiaryId) {
			// continuing a diary event
			$busyRowSpans[$busydaykey][$busykey] = 0;
			$colspancount++;
		} else {
			// start of a new diary event
			if($busykeystart != "") {$busyRowSpans[$busydaykey][$busykeystart] = $colspancount; $busykeystart = ""; $prevDiaryId = "";}
			$colspancount = 1;
			$busykeystart = $busykey;
			$prevDiaryId = $diaryId;
		}
	}
	if($busykeystart != "") {$busyRowSpans[$busydaykey][$busykeystart] = $colspancount;}
	$arrHoldsAll[$useridtoshow]["busyRowSpans"] = $busyRowSpans;
}

for($myTime = 8; $myTime <= 23; $myTime += $timeinc) {
	echo "<tr><td width=\"2%\" class=\"singleHour\">".showTime($myTime)."</td>";
	foreach($useridsToShow as $useridtoshow => $usernametoshow) {
		$linkedItemsSeen = &$arrHoldsAll[$useridtoshow]["linkedItemsSeen"];
		$diaryContent = &$arrHoldsAll[$useridtoshow]["diaryContent"];
		$diaryMinutes = &$arrHoldsAll[$useridtoshow]["diaryMinutes"];
		$busyContent  = &$arrHoldsAll[$useridtoshow]["busyContent"];
		$busyRowSpans = &$arrHoldsAll[$useridtoshow]["busyRowSpans"];

		if(getApplicationObject("weboffice15mins") == "yes") {
			$busykey = $myTime * 4;
		} else {
			$busykey = $myTime * 2;
		}

		// if rowspan not working, uncomment the following line
		//$busyRowSpans[$busydaykey][$busykey] = 1;
		if($busyRowSpans[$busydaykey][$busykey] == 0) continue;

		if($eventType==991) {
			if($useridtoshow == $HTTP_SESSION_VARS["mwoid"] && $busyContent[$busydaykey][$busykey] == "") {
				$tdextra = "onMouseDown=\"down(".$busykey.")\" onMouseUp=\"up(".$busykey.")\" onMouseOver=\"over(".$busykey.")\" onMouseOut=\"out(".$busykey.")\" id=\"cell".$busykey."\"";
			} else {
				$tdextra = "onMouseOver=\"disablecontext()\"";
			}
		}

		if(substr($busyContent[$busydaykey][$busykey], 0, 1) == "#") {
			$td = "style=\"vertical-align:top;background-color:".$busyContent[$busydaykey][$busykey]."\"";
		} elseif($busyContent[$busydaykey][$busykey] == 1 && $eventType == 991) {
			$td = "class=\"timesheetSingleHour\"";
		} elseif($busyContent[$busydaykey][$busykey] == 1) {
			$td = "class=\"busySingleHour\"";
		} elseif($busyContent[$busydaykey][$busykey] == 3) {
			$td = "class=\"holidaySingleHour\"";
		} else {
			$td = "class=\"singleHour\" title=\"".showTime($myTime)."\"";
			if($myaction == "confirmbooking") {
				$td.= " onClick=\"confirmapp(".$useridtoshow.", ".$busykey.")\" onMouseOver=\"oldbgcol=this.style.backgroundColor;this.style.cursor='pointer';this.style.backgroundColor='#FFAAAA'\" onMouseOut=\"this.style.backgroundColor=oldbgcol\"";
			}
			$td.= " onDblClick=\"addEventWithTimeAndPerson(".jscriptDate($currentDate, $currentDay).",'".showTime($myTime)."','".showTime($myTime + 1)."', ".$useridtoshow.", '".str_replace("'", "\\'", $usernametoshow)."');\"";
		}

		echo "<td rowspan=\"".$busyRowSpans[$busydaykey][$busykey]."\" ";
		echo $tdextra." width=\"".$percentwidth."%\" ".$td.">".showHourContent($myTime, $currentDay)."</td>";

	}
	echo "</tr>";
}
?>
</table>
<?
	} else {
	// standard - old school - one-day view
?>
<table width="100%" height="98%">
<tr><td width="2%" class="dispAdd">&nbsp;<a href="#" onClick="addEvent(<?=jscriptDate($currentDate, $currentDay)?>);return false">[add]</a>&nbsp;</td><td width="98%" class="dispDate"><?=$arrDayNames[$currentDay]." ".displayDay($currentDate, $currentDay)?></td></tr>
<?
if($diaryMinutes[$currentDay]["span"] != "") {
?>
<tr><td width="2%" class="singleHour">&nbsp;</td><td width="98%" class="singleHour"><?=showHourContent("span", $currentDay)?></td></tr>
<?
}
for($myTime = 8; $myTime <= 23; $myTime += 0.5) {
?>
<tr><td width="2%" class="singleHour"><?=showTime($myTime)?></td><td width="98%" class="singleHour" onDblClick="addEventWithTime(<?=jscriptDate($currentDate, $currentDay)?>,'<?=showTime($myTime)?>','<?=showTime($myTime + 1)?>');"><?=showHourContent($myTime, $currentDay)?></td></tr>
<?
	}
?>
</table>
<?
}
?>
<? } else {
	//##### ONE MONTH VIEW #####
	$diaryHeadStr.= " - ".date("F Y", $firstDayOfMonth);
	dispHeader($diaryHeadStr);
	echo dispAdminView($mulview, $myaction);
	$col = 1;
	$row = 1;
	echo "<table width=\"100%\">";
	echo "<tr><td class=\"dispAdd\">Monday</td><td class=\"dispAdd\">Tuesday</td><td class=\"dispAdd\">Wednesday</td><td class=\"dispAdd\">Thursday</td><td class=\"dispAdd\">Friday</td><td class=\"dispAdd\">Saturday</td><td class=\"dispAdd\">Sunday</td></tr>";
	// display the blanks at start of month
	echo "<tr>";
	for($j = 0; $j<$firstDay; $j++) {
		echo("<td class=\"mviewblank\">&nbsp;</td>");
		$col++;
	}
	// display all days in month
	for($j = 1; $j <= getDaysInMonth($currentMonth, $currentYear); $j++) {
		if($col == 8) {
			echo "</tr><tr>";
			$col = 1;
			$row++;
		}
		echo "<td class=\"mview\"";
		if($currentYear == date("Y") && $currentMonth == (date("n")-1) && $j == date("d")) {
			echo " style=\"border-width: 2px;border-style: solid;border-color: red;\"";
		}
		echo " onDblClick=\"addEvent(".$j.",".$currentMonth.",".$currentYear.");return false\">".$j."&nbsp;<a href=\"#\" onClick=\"addEvent(".$j.",".$currentMonth.",".$currentYear.");return false\">[add]</a><br>".$diaryContent[$j - 1]."</td>";
		$col++;
	}
	// trailing blanks
	for($j = $col; $j < 8; $j++) {
		echo "<td class=\"mviewblank\">&nbsp;</td>" ;
	}
	echo "</tr>" ;
	echo "</table>";

} ?>
<? if(isAdminUser()) { ?>
<hr>
<table><tr><td><img alt="Change settings" width="23" height="22" src="/images/settings.gif"></td><td><a target="_parent" href="settings.php?mulview=<?=$mulview?>">Change settings &gt;&gt;</a></td></tr></table>
<? } ?>
</body>
</html>
<? require_once("../common/incFinal.php"); ?>
Return current item: Silicon Fodder