Location: PHPKode > projects > Silicon Fodder > SiliconFodder/DocumentRoot/diary/calPop.php
<? require_once("../common/nocache.php"); ?>
<? require_once("../common/appobjects.php"); ?>
<? require_once("../common/db.php"); ?>
<? require_once("../common/checkIsLoggedIn.php"); ?>
<?
$myDay     = $HTTP_GET_VARS["dd"];
$myMonth   = $HTTP_GET_VARS["mm"];
$myYear    = $HTTP_GET_VARS["yy"];
$myTime    = $HTTP_GET_VARS["tt"];
$dateField = $HTTP_GET_VARS["df"];
if($dateField == "") {
	$dateField = "1";
}
if($myDay == "") {
	$myDay   = date("d");
	$myMonth = date("m");
	$myYear  = date("Y");
}
?>
<html>
<head>
<title>My Web Office - Popup</title>
<script language="javascript">
<!--
var dDate = new Date();
var dCurMonth = dDate.getMonth();
var dCurDayOfMonth = dDate.getDate();
var dCurYear = dDate.getFullYear();

function fToggleColor(myElement) {
var toggleColor = "#ff0000";
if (myElement.id == "calDateText") {
if (myElement.color == toggleColor) {
myElement.color = "";
} else {
myElement.color = toggleColor;
   }
} else if (myElement.id == "calCell") {
for (var i in myElement.children) {
if (myElement.children[i].id == "calDateText") {
if (myElement.children[i].color == toggleColor) {
myElement.children[i].color = "";
} else {
myElement.children[i].color = toggleColor;
            }
         }
      }
   }
}
function fSetSelectedDay(myElement){
if (myElement.id == "calCell") {
if (!isNaN(parseInt(myElement.children["calDateText"].innerText))) {
	opener.setDate(parseInt(myElement.children["calDateText"].innerText),document.frm.tbSelMonth.value, document.frm.tbSelYear.value,<?=$dateField?>);
	self.close();
      }
   }
}
function fGetDaysInMonth(iMonth, iYear) {
var dPrevDate = new Date(iYear, iMonth, 0);
return dPrevDate.getDate();
}
function fBuildCal(iYear, iMonth, iDayStyle) {
var aMonth = new Array();
aMonth[0] = new Array(7);
aMonth[1] = new Array(7);
aMonth[2] = new Array(7);
aMonth[3] = new Array(7);
aMonth[4] = new Array(7);
aMonth[5] = new Array(7);
aMonth[6] = new Array(7);
var dCalDate = new Date(iYear, iMonth-1, 1);
var iDayOfFirst = dCalDate.getDay();
var iDaysInMonth = fGetDaysInMonth(iMonth, iYear);
var iVarDate = 1;
var i, d, w;
if (iDayStyle == 2) {
aMonth[0][0] = "Sunday";
aMonth[0][1] = "Monday";
aMonth[0][2] = "Tuesday";
aMonth[0][3] = "Wednesday";
aMonth[0][4] = "Thursday";
aMonth[0][5] = "Friday";
aMonth[0][6] = "Saturday";
} else if (iDayStyle == 1) {
aMonth[0][0] = "Sun";
aMonth[0][1] = "Mon";
aMonth[0][2] = "Tue";
aMonth[0][3] = "Wed";
aMonth[0][4] = "Thu";
aMonth[0][5] = "Fri";
aMonth[0][6] = "Sat";
} else {
aMonth[0][0] = "Su";
aMonth[0][1] = "Mo";
aMonth[0][2] = "Tu";
aMonth[0][3] = "We";
aMonth[0][4] = "Th";
aMonth[0][5] = "Fr";
aMonth[0][6] = "Sa";
}
for (d = iDayOfFirst; d < 7; d++) {
aMonth[1][d] = iVarDate;
iVarDate++;
}
for (w = 2; w < 7; w++) {
for (d = 0; d < 7; d++) {
if (iVarDate <= iDaysInMonth) {
aMonth[w][d] = iVarDate;
iVarDate++;
      }
   }
}
return aMonth;
}
function fDrawCal(iYear, iMonth, iCellWidth, iCellHeight, iDayStyle) {
var myMonth;
myMonth = fBuildCal(iYear, iMonth, iDayStyle);
document.write("<table cellpadding='0' cellspacing='0' border='0' style='border: 1px black solid' width='100%'>")
document.write("<tr class='title'>");
document.write("<td class='day'>" + myMonth[0][0] + "</td>");
document.write("<td class='day'>" + myMonth[0][1] + "</td>");
document.write("<td class='day'>" + myMonth[0][2] + "</td>");
document.write("<td class='day'>" + myMonth[0][3] + "</td>");
document.write("<td class='day'>" + myMonth[0][4] + "</td>");
document.write("<td class='day'>" + myMonth[0][5] + "</td>");
document.write("<td class='day'>" + myMonth[0][6] + "</td>");
document.write("</tr>");
for (w = 1; w < 7; w++) {
document.write("<tr>")
for (d = 0; d < 7; d++) {
if (!isNaN(myMonth[w][d])) {
document.write("<td class='isaday' align='left' id=calCell style='CURSOR:Hand' onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>");
document.write("<font id=calDateText style='CURSOR:Hand;' onclick=fSetSelectedDay(this)>" + myMonth[w][d] + "</font>");
} else {
document.write("<td class='notaday' align='left' id=calCell style='CURSOR:Hand' onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>");
document.write("<font id=calDateText style='CURSOR:Hand;' onclick=fSetSelectedDay(this)> </font>");
}
document.write("</td>")
}
document.write("</tr>");
}
document.write("</table>")
}
function fUpdateCal(iYear, iMonth) {
myMonth = fBuildCal(iYear, iMonth);
for (w = 1; w < 7; w++) {
for (d = 0; d < 7; d++) {
if (!isNaN(myMonth[w][d])) {
calDateText[((7*w)+d)-7].innerText = myMonth[w][d];
calCell[((7*w)+d)-7].style.backgroundColor = '#EEEEEE';
} else {
calDateText[((7*w)+d)-7].innerText = "";
calCell[((7*w)+d)-7].style.backgroundColor = '#E2E2E2';
         }
      }
   }
}
function clearDate() {
        opener.clearDate(<?=$dateField?>);
        self.close();
}
// End -->
</script>
<style>
body {
	background-color: #FFFFD5;
}
td {
	color: #000000;
	font-size: 9pt;
	font-family: Verdana, Arial, Helvetica;
	text-align: center;
	padding-left:5px;
	padding-right:5px;
	height: 20px;
}
.week {
	cursor: pointer;
}
a {
	color: #000000;
	text-decoration: none;
}
table {
	empty-cells: show;
}
select {
	font-size: 8pt;
}
.day {
	border-bottom: 1px solid #000000;
}
.isaday {
	background-color: #EEEEEE;
}
.notaday {
	background-color: #E2E2E2;
}
.title {
	background-color: #9EBEF5;
	font-weight: bold;
}
.today {
	border-width: 2px;
	border-style: solid;
	border-color: red;
}
</style>
</head>
<body onLoad="self.focus()">

<form name="frm" method="post" action="">

<table border="0">
<tr>
<td nowrap>
<select name="tbSelMonth" onchange='fUpdateCal(frm.tbSelYear.value, frm.tbSelMonth.value)'>
<option value="1"<?if($myMonth == 1) echo(" selected")?>>January</option>
<option value="2"<?if($myMonth == 2) echo(" selected")?>>February</option>
<option value="3"<?if($myMonth == 3) echo(" selected")?>>March</option>
<option value="4"<?if($myMonth == 4) echo(" selected")?>>April</option>
<option value="5"<?if($myMonth == 5) echo(" selected")?>>May</option>
<option value="6"<?if($myMonth == 6) echo(" selected")?>>June</option>
<option value="7"<?if($myMonth == 7) echo(" selected")?>>July</option>
<option value="8"<?if($myMonth == 8) echo(" selected")?>>August</option>
<option value="9"<?if($myMonth == 9) echo(" selected")?>>September</option>
<option value="10"<?if($myMonth == 10) echo(" selected")?>>October</option>
<option value="11"<?if($myMonth == 11) echo(" selected")?>>November</option>
<option value="12"<?if($myMonth == 12) echo(" selected")?>>December</option>
</select>

<select name="tbSelYear" onchange='fUpdateCal(frm.tbSelYear.value, frm.tbSelMonth.value)'>
<?
for($i=2004; $i<=2010; $i++) {
?>
<option value="<?=$i?>"<?if($myYear == $i) echo(" selected")?>><?=$i?></option>
<?
}
?>
</select>
<!--<input onClick="clearDate()" style="font-size:10px" type="button" value="Clear date">-->
</td>
</tr>
<tr>
<td>
<br>
<script language="JavaScript">
var dCurDate = new Date();
fDrawCal(<?=$myYear?>, <?=$myMonth?>, 20, 20, 0);
</script>
</td>
</tr>
</table>
</form>
</body>
</html>
Return current item: Silicon Fodder