\n"; $tdWidth = 20; $tdHeight = 25; $lDays = array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); $months = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); if (empty($_REQUEST['date'])) $ShowDate = date("Ymd"); else $ShowDate = $_REQUEST['date']; $ShowDate_ts = mktime(12,0,0,substr($ShowDate,4,2),substr($ShowDate,6,2),substr($ShowDate,0,4)); $StartOfMonth_ts = mktime(12,0,0,substr($ShowDate,4,2),0,substr($ShowDate,0,4)); $sd = date("w", $StartOfMonth_ts); if ($sd == 0) $sd = 7; // else // if ($sd < 1) // $sd += 7; // get the first day of the week $tDate = date("Ymd",mktime(12,0,0,substr($ShowDate,4,2),0 - $sd,substr($ShowDate,0,4))); $eDate = date("Ymd", mktime(12,0,0,substr($ShowDate,4,2) + 1,2,substr($ShowDate,0,4))); // ******************************* display ******************************* echo "\n"; echo ""; for ($i = 0; $i < 7; $i++) { echo "\t\n"; } echo "\n"; while ($tDate <= $eDate) { echo ""; if (array_key_exists("forward",$_REQUEST)) $forward = true; else $forward = false; //control loops: i = days of week for ($i = 0; $i < 7; $i++) { $curCellId = "C$j$i"; $tLab = 0; $cell_style = ""; if (substr($tDate,4,2) < substr($ShowDate,4,2)) { // "last month" if (!empty($_REQUEST['pStart']) and !empty($_REQUEST['pEnd']) and $tDate >= $_REQUEST['pStart'] and $tDate <= $_REQUEST['pEnd']) { // is this pay period $cell_style = "background-color:#00F;color:black;cursor:pointer;"; } else if ($forward or $full) $cell_style = "background-color:red;"; else $cell_style = "background-color:#555;color:white;cursor:pointer;";//8C0 } else { if ($forward and $full) { if ($tDate == $ShowDate) $cell_style = "background-color:#F88;text-decoration:blink;"; else $cell_style = "background-color:red;"; } else { if ($tDate == $ShowDate) { // "selected day"? if ($forward) $cell_style = "background-color:#FAA;cursor:pointer;text-decoration:blink;"; else $cell_style = "background-color:yellow;cursor:pointer;text-decoration:blink;"; } else if ($tDate == date("Ymd")) { // is literally today $cell_style = "background-color:#0F0;color:black;cursor:pointer;"; } else if (!empty($_REQUEST['pStart']) and !empty($_REQUEST['pEnd']) and $tDate >= $_REQUEST['pStart'] and $tDate <= $_REQUEST['pEnd']) { // is this pay period $cell_style = "background-color:#00F;color:black;cursor:pointer;"; } else if (substr($tDate,4,2) > substr($ShowDate,4,2)) { // "next month"? if ($forward) $cell_style = "background-color:#8C0;cursor:pointer;"; else $cell_style = "background-color:#555;color:white;cursor:pointer;"; } else if ($tDate > date("Ymd")) { // "this month, after today or after this period if ($forward) $cell_style = "background-color:green;cursor:pointer;"; else $cell_style = "background-color:#999;cursor:pointer;"; } else { // "this month, before this pay period if ($forward) $cell_style = "background-color:red;cursor:pointer;"; else $cell_style = "background-color:#999;cursor:pointer;"; } } } // cell shading: days outside of the displayed month are dark // if the month shown is THIS month, then the days PAST are shaded lightly if it's pointing at today echo "\n"; $tDate = date("Ymd",mktime(12,0,0,substr($tDate,4,2),substr($tDate,-2) + 1,substr($tDate,0,4))); } echo "\n"; } echo "
"; echo $months[intval(substr($ShowDate,4,2)) - 1].", ".substr($ShowDate,0,4); echo "
"; $idx = $i; if ($idx > 6) $idx -= 7; echo $lDays[$idx]; echo "
\n"; echo "
\n"; // display cell date $today = date("Ymd"); echo "".substr($tDate,-2)."
\n"; ?>