function generateMonthView_small($month, $year, $view_diary) { global $_GET; $OUTPUT = "\r\n\t\t<table width=190 cellspacing=0>\r\n\t\t\t<tr>\r\n\t\t\t\t<td height=20 align=center " . TMPL_calSmallMonthTitleStyle . "\r\n\t\t\t\t\t\tonClick='document.location.href=\"" . SELF . "?key=month&month={$month}&year={$year}\"'>\r\n\t\t\t\t\t<b>" . getMonthText($month) . " {$year}</b>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td align=center " . TMPL_calSmallMonthBodyStyle . ">"; // generate the titles of the weekdays $OUTPUT .= "\r\n\t\t\t<table width='184' cellspacing=0>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td width=23> </td>\r\n\t\t\t\t\t<td width=23 align=center><b>M</b></td>\r\n\t\t\t\t\t<td width=23 align=center><b>T</b></td>\r\n\t\t\t\t\t<td width=23 align=center><b>W</b></td>\r\n\t\t\t\t\t<td width=23 align=center><b>T</b></td>\r\n\t\t\t\t\t<td width=23 align=center><b>F</b></td>\r\n\t\t\t\t\t<td width=23 align=center bgcolor=" . TMPL_calFillSaturday . "><b>S</b></td>\r\n\t\t\t\t\t<td width=23 align=center bgcolor=" . TMPL_calFillSunday . "><b>S</b></td>\r\n\t\t\t\t</tr>"; // get the weekday number of the first of this month $first_wd = getWeekdayNum(1, $month, $year); // the following code will generate the first entries on the calendar, which is for the previous month (if any) // month and year of previous month if ($month == 1) { $tmp_month = 12; $tmp_year = $year - 1; } else { $tmp_month = $month - 1; $tmp_year = $year; } // date of last monday in previous month (where the entries will start) if ($first_wd > 1) { $tmp_day = getDaysInMonth($tmp_month, $tmp_year) - ($first_wd - 2); } else { $tmp_day = 1; $tmp_month = $month; $tmp_year = $year; } // create a view variables $selected_month = $_GET["month"]; // create the previous month's entries $c_weeknum = getWeekNumber($tmp_day, $tmp_month, $tmp_year); $selected_weeknum = getWeekNumber($_GET["mday"], $_GET["month"], $_GET["year"]); // if today's week number = the current generated week's number, hightlight the row, as so with the selected week, if ($c_weeknum == getTodayWeekNumber() && $tmp_year == date("Y") && $month == date("m") || getTodayWeekNumber() == 0 && $month == date("m") && $year == date("Y")) { // today's week $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>"; $ROW_COLORED = 1; } else { if ($month == $_GET["month"] && $c_weeknum == $selected_weeknum && $month == $_GET["month"] || $c_weeknum == 52 && $selected_weeknum == 0) { // selected week, the last check is for the first week in jan $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>"; $ROW_COLORED = 1; } else { // other dates $OUTPUT .= "<tr>"; $ROW_COLORED = 0; } } if ($first_wd != 1) { // only if there is a day in this week of previous month, print the week number $OUTPUT .= "<td width=23 " . TMPL_calSmallMonthWeekNumberStyle . " align=center>{$c_weeknum}</td>"; } for ($c_wd = 1; $c_wd < $first_wd; $c_wd++, $tmp_day++) { // fill differently for saturday and sunday (only when row wasn't already highlighted) if ($c_wd == 6 && !$ROW_COLORED) { $dayfill = "bgcolor=" . TMPL_calFillSaturday; } else { if ($c_wd == 7) { $dayfill = "bgcolor=" . TMPL_calFillSunday; } else { $dayfill = ""; } } $OUTPUT .= "<td {$dayfill} width=23 align=center>\r\n\t\t\t\t\t\t\t<a id='calSmallMonthOMLink' href='" . SELF . "?mday={$tmp_day}&month={$tmp_month}&year={$tmp_year}'>{$tmp_day}</a>\r\n\t\t\t\t\t\t</td>"; } // start creating this month's entries $cm_days = getDaysInMonth($month, $year); for ($c_day = 1; $c_day <= $cm_days; $c_day++) { $c_weeknum = getWeekNumber($c_day, $month, $year); if ($c_wd == 1) { // start a new row (it's MONDAY!!!!!) // if today's week number = the current generated week's number, hightlight the row, as so with the selected week if ($c_weeknum == getTodayWeekNumber() && $year == date("Y") && $month == date("m")) { // today's week $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>"; $ROW_COLORED = 1; } else { if ($month == $_GET["month"] && $c_weeknum == $selected_weeknum) { // selected week $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>"; $ROW_COLORED = 1; } else { // other dates $OUTPUT .= "<tr>"; $ROW_COLORED = 0; } } // attach the week number $OUTPUT .= "<td align=center width=23 " . TMPL_calSmallMonthWeekNumberStyle . ">{$c_weeknum}</td>"; } // change the fill color if it it 2day's date we are printing, or the selected date if ($c_day == $_GET["mday"] && $month == $_GET["month"] && $year == $_GET["year"]) { // selected date $dayfill = "bgcolor=" . TMPL_calSmallMonthSelectedDay; $a_id = "calSmallMonthCMLinkSelected"; } else { if (date("d") == $c_day && date("m") == $month && date("Y") == $year) { // 2day's date $dayfill = "bgcolor=" . TMPL_calSmallMonthCurrentDay; $a_id = "calSmallMonthCMLinkToday"; } else { // other dates // fill differently for saturday and sunday (only when the row has not already been colored) if ($c_wd == 6 && !$ROW_COLORED) { $dayfill = "bgcolor=" . TMPL_calFillSaturday; } else { if ($c_wd == 7 && !$ROW_COLORED) { $dayfill = "bgcolor=" . TMPL_calFillSunday; } else { $dayfill = ""; } } $a_id = "calSmallMonthCMLink"; } } $OUTPUT .= "<td width=23 {$dayfill} align=center>\r\n\t\t\t\t\t\t\t<a id='{$a_id}' href='" . SELF . "?mday={$c_day}&month={$month}&year={$year}&view_diary={$view_diary}'>{$c_day}</a>\r\n\t\t\t\t\t\t</td>"; if ($c_wd == 7) { // end the output $OUTPUT .= "</tr>"; } $c_wd == 7 ? $c_wd = 1 : $c_wd++; } // next month variables if ($month == 12) { $tmp_month = 1; $tmp_year = $year + 1; } else { $tmp_month = $month + 1; $tmp_year = $year; } // finish with the next months entries for ($c_day = 1; $c_wd <= 7 && $c_wd > 1; $c_wd++, $c_day++) { // fill differently for saturday and sunday if ($c_wd == 6 && !$ROW_COLORED) { $dayfill = "bgcolor=" . TMPL_calFillSaturday; } else { if ($c_wd == 7 && !$ROW_COLORED) { $dayfill = "bgcolor=" . TMPL_calFillSunday; } else { $dayfill = ""; } } $OUTPUT .= "<td {$dayfill} width=23 align=center>\r\n\t\t\t\t\t\t\t<a id='calSmallMonthOMLink' href='" . SELF . "?mday={$c_day}&month={$tmp_month}&year={$tmp_year}'>{$c_day}</a>\r\n\t\t\t\t\t\t</td>"; } // finish the tables and return $OUTPUT .= "\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t"; return $OUTPUT; }
function generateMonthView_small_mail($view_diary) { global $_GET; extract($_GET); $pyear = extractYear(mkdatet($year - 1, $month, 1)); $pmonth = extractMonth(mkdatet($year, $month - 1, 1)); $nyear = extractYear(mkdatet($year + 1, $month, 1)); $nmonth = extractMonth(mkdatet($year, $month + 1, 1)); $OUTPUT = "\n\t\t<table width=190 cellspacing=0>\n\t\t\t<tr>\n\t\t\t\t<td height=20 align=center " . TMPL_calSmallMonthTitleStyle . ">\n\t\t\t\t\t<a href='" . SELF . "?month={$month}&year={$pyear}'><img border='0' src='left_year.gif'></a>\n\t\t\t\t\t<a href='" . SELF . "?month={$pmonth}&year={$year}'><img border='0' src='left_month.gif'></a>\n\t\t\t\t\t<b><a class='month_text' href='javascript:ajaxLink(\"iframe.php\", \"script=diary-index.php&key=month&month={$month}&year={$year}\");'>" . getMonthName($month) . " {$year}</a></b>\n\t\t\t\t\t<a href='" . SELF . "?month={$nmonth}&year={$year}'><img border='0' src='right_month.gif'></a>\n\t\t\t\t\t<a href='" . SELF . "?month={$month}&year={$nyear}'><img border='0' src='right_year.gif'></a>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td align=center " . TMPL_calSmallMonthBodyStyle . " colspan='5'>"; // generate the titles of the weekdays $OUTPUT .= "\n\t\t\t<table width='184' cellspacing=0>\n\t\t\t\t<tr>\n\t\t\t\t\t<td width=23> </td>\n\t\t\t\t\t<td width=23 align=center><b>M</b></td>\n\t\t\t\t\t<td width=23 align=center><b>T</b></td>\n\t\t\t\t\t<td width=23 align=center><b>W</b></td>\n\t\t\t\t\t<td width=23 align=center><b>T</b></td>\n\t\t\t\t\t<td width=23 align=center><b>F</b></td>\n\t\t\t\t\t<td width=23 align=center bgcolor=" . TMPL_calFillSaturday . "><b>S</b></td>\n\t\t\t\t\t<td width=23 align=center bgcolor=" . TMPL_calFillSunday . "><b>S</b></td>\n\t\t\t\t</tr>"; // get the weekday number of the first of this month $first_wd = getWeekdayNum(1, $month, $year); // the following code will generate the first entries on the calendar, which is for the previous month (if any) // month and year of previous month if ($month == 1) { $tmp_month = 12; $tmp_year = $year - 1; } else { $tmp_month = $month - 1; $tmp_year = $year; } // date of last monday in previous month (where the entries will start) if ($first_wd > 1) { $tmp_day = getDaysInMonth($tmp_month, $tmp_year) - ($first_wd - 2); } else { $tmp_day = 1; $tmp_month = $month; $tmp_year = $year; } // create a view variables $selected_month = $smonth; // create the previous month's entries $c_weeknum = getWeekNumber($tmp_day, $tmp_month, $tmp_year); $selected_weeknum = getWeekNumber($sday, $smonth, $syear); // if today's week number = the current generated week's number, hightlight the row, as so with the selected week, if ($c_weeknum == getTodayWeekNumber() && $tmp_year == date("Y") && $month == date("m") || getTodayWeekNumber() == 0 && $month == date("m") && $year == date("Y")) { // today's week $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>"; $ROW_COLORED = 1; } else { if ($month == $smonth && $c_weeknum == $selected_weeknum || $c_weeknum == 52 && $selected_weeknum == 0) { // selected week, the last check is for the first week in jan $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>"; $ROW_COLORED = 1; } else { // other dates $OUTPUT .= "<tr>"; $ROW_COLORED = 0; } } if ($first_wd != 1) { // only if there is a day in this week of previous month, print the week number $OUTPUT .= "<td width=23 " . TMPL_calSmallMonthWeekNumberStyle . " align=center>{$c_weeknum}</td>"; } for ($c_wd = 1; $c_wd < $first_wd; $c_wd++, $tmp_day++) { // fill differently for saturday and sunday (only when row wasn't already highlighted) if ($c_wd == 6 && !$ROW_COLORED) { $dayfill = "bgcolor=" . TMPL_calFillSaturday; } else { if ($c_wd == 7) { $dayfill = "bgcolor=" . TMPL_calFillSunday; } else { $dayfill = ""; } } // ** 2006-05-08 ** // $OUTPUT.="<td $dayfill width=23 align=center> // <a id='calSmallMonthOMLink' href='#' onClick='parent.rightframe.document.location.href=\"diary-index.php?mday=$tmp_day&month=$tmp_month&year=$tmp_year\"'>$tmp_day</a> // </td>"; $OUTPUT .= "<td {$dayfill} width='23' align='center'>\n\t\t\t<a id='calSmallMonthOMLink' href='javascript:ajaxLink(\"iframe.php\", \"script=diary-index.php&mday={$tmp_day}&month={$tmp_month}&year={$tmp_year}\");'>{$tmp_day}</a></td>"; } // start creating this month's entries $cm_days = getDaysInMonth($month, $year); for ($c_day = 1; $c_day <= $cm_days; $c_day++) { $c_weeknum = getWeekNumber($c_day, $month, $year); if ($c_wd == 1) { // start a new row (it's MONDAY!!!!!) // if today's week number = the current generated week's number, hightlight the row, as so with the selected week if ($c_weeknum == getTodayWeekNumber() && $year == date("Y") && $month == date("m")) { // today's week $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>"; $ROW_COLORED = 1; } else { if ($month == $smonth && $c_weeknum == $selected_weeknum) { // selected week $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>"; $ROW_COLORED = 1; } else { // other dates $OUTPUT .= "<tr>"; $ROW_COLORED = 0; } } // attach the week number $OUTPUT .= "<td align=center width=23 " . TMPL_calSmallMonthWeekNumberStyle . ">{$c_weeknum}</td>"; } // change the fill color if it it 2day's date we are printing, or the selected date if ($c_day == $sday && $month == $smonth && $year == $syear) { // selected date $dayfill = "bgcolor=" . TMPL_calSmallMonthSelectedDay; $a_id = "calSmallMonthCMLinkSelected"; } else { if (date("d") == $c_day && date("m") == $month && date("Y") == $year) { // 2day's date $dayfill = "bgcolor=" . TMPL_calSmallMonthCurrentDay; $a_id = "calSmallMonthCMLinkToday"; } else { // other dates // fill differently for saturday and sunday (only when the row has not already been colored) if ($c_wd == 6 && !$ROW_COLORED) { $dayfill = "bgcolor=" . TMPL_calFillSaturday; } else { if ($c_wd == 7 && !$ROW_COLORED) { $dayfill = "bgcolor=" . TMPL_calFillSunday; } else { $dayfill = ""; } } $a_id = "calSmallMonthCMLink"; } } // ** 2006-05-08 ** // $OUTPUT.="<td width=23 $dayfill align=center> // <a id='$a_id' href='#' onClick='parent.rightframe.document.location.href=\"diary-index.php?mday=$c_day&month=$month&year=$year&view_diary=$view_diary\"'>$c_day</a> // </td>"; $OUTPUT .= "<td width='23' {$dayfill} align='center'>\n\t\t\t<a id='{$a_id}' href='javascript:ajaxLink(\"iframe.php\", \"script=diary-index.php&mday={$c_day}&month={$month}&year={$year}\");'>{$c_day}</a></td>"; if ($c_wd == 7) { // end the output $OUTPUT .= "</tr>"; } $c_wd == 7 ? $c_wd = 1 : $c_wd++; } // next month variables if ($month == 12) { $tmp_month = 1; $tmp_year = $year + 1; } else { $tmp_month = $month + 1; $tmp_year = $year; } // finish with the next months entries for ($c_day = 1; $c_wd <= 7 && $c_wd > 1; $c_wd++, $c_day++) { // fill differently for saturday and sunday if ($c_wd == 6 && !$ROW_COLORED) { $dayfill = "bgcolor=" . TMPL_calFillSaturday; } else { if ($c_wd == 7 && !$ROW_COLORED) { $dayfill = "bgcolor=" . TMPL_calFillSunday; } else { $dayfill = ""; } } // ** 2006-05-08 ** // $OUTPUT.="<td $dayfill width=23 align=center> // <a id='calSmallMonthOMLink' href='#' inClick='parent.rightframe.document.location.href=\"diary-index.php?mday=$c_day&month=$tmp_month&year=$tmp_year\"'>$c_day</a> // </td>"; $OUTPUT .= "<td {$dayfill} width='23' align='center'>\n\t\t\t<a id='calSmallMonthOMLink' href='javascript:ajaxLink(\"iframe.php?script=diary-index.php\", \"mday={$c_day}&month={$tmp_month}&year={$tmp_year}\");'>{$c_day}</a>"; } // finish the tables and return $OUTPUT .= "\n\t\t\t\t</tr>\n\t\t\t</table>\n\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>"; return $OUTPUT; }
function generateMonthView_large($month, $year, $view_diary) { global $_GET; $valid_date = mktime(0, 0, 0, $month, 1, $year); $month = date("m", $valid_date); $year = date("Y", $valid_date); $select_month = "<select name=month>"; for ($i = 1; $i <= 12; $i++) { if ($month == $i) { $sel = "selected"; } else { $sel = ""; } $select_month .= "<option {$sel} value='{$i}'>" . getMonthText($i) . "</option>"; } $select_month .= "</select>"; $select_year = "<select name=year>"; for ($i = 1971; $i <= 2028; $i++) { if ($year == $i) { $sel = "selected"; } else { $sel = ""; } $select_year .= "<option {$sel} value={$i}>{$i}</option>"; } $select_year .= "</select>"; $OUTPUT = "\r\n\t<table width=600 cellspacing=0>\r\n\t<tr>\r\n\t\t<td align=center style='font-size: 14px; color: #ffffff; font-weight: bold;' colspan=3>\r\n\t\t\t<form method=post action='" . SELF . "'>\r\n\t\t\t<input type=hidden name=key value='month'>\r\n\t\t\tGoto: {$select_month} {$select_year} <input type=submit value='Go'>\r\n\t\t\t</form>\r\n\t\t</td>\r\n\t</tr>\r\n\t<tr><td> </td></tr>\r\n <tr>\r\n \t<td colspan=3 " . TMPL_calTimeStyle2 . ">\r\n \t<table width=100%><tr>\r\n \t<td width=30% align=center valign=middle>\r\n \t\t<a href='" . SELF . "?key=month&month=" . ($month - 1) . "&year={$year}&view_diary={$view_diary}'>\r\n \t\t\t<img src='left_day.gif' border=0>\r\n\t\t\t</a>\r\n\t\t</td>\r\n\t\t<td width=40% valign=middle align=center " . TMPL_calTimeStyleHeader . ">\r\n\t\t\t<b>" . getMonthText($month) . " {$year}</b>\r\n\t\t</td>\r\n\t\t<td width=30% align=center valign=middle>\r\n\t\t\t<a href='" . SELF . "?key=month&month=" . ($month + 1) . "&year={$year}&view_diary={$view_diary}'>\r\n\t\t\t\t<img src='right_day.gif' border=0>\r\n\t\t\t</a>\r\n\t\t</td>\r\n\t\t</tr></table>\r\n\t\t</td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td align=center " . TMPL_calLargeMonthBodyStyle . " colspan=3>\r\n\t\t<table width='600' cellspacing=0>\r\n\t\t<tr>\r\n\t\t\t<td width=75 height=60> </td>\r\n\t\t\t<td width=75 height=60 align=center><h1>M</h1></td>\r\n\t\t\t<td width=75 height=60 align=center><h1>T</h1></td>\r\n\t\t\t<td width=75 height=60 align=center><h1>W</h1></td>\r\n\t\t\t<td width=75 height=60 align=center><h1>T</h1></td>\r\n\t\t\t<td width=75 height=60 align=center><h1>F</h1></td>\r\n\t\t\t<td width=75 height=60 align=center bgcolor=" . TMPL_calFillSaturday . "><h1>S</h1></td>\r\n\t\t\t<td width=75 height=60 align=center bgcolor=" . TMPL_calFillSunday . "><h1>S</h1></td>\r\n\t\t</tr>"; // get the weekday number of the first of this month $first_wd = getWeekdayNum(1, $month, $year); // the following code will generate the first entries on the calendar, which is for the previous month (if any) // and year of previous month if ($month == 1) { $tmp_month = 12; $tmp_year = $year - 1; } else { $tmp_month = $month - 1; $tmp_year = $year; } // date of last monday in previous month (where the entries will start) if ($first_wd > 1) { $tmp_day = getDaysInMonth($tmp_month, $tmp_year) - ($first_wd - 2); } else { $tmp_day = 1; $tmp_month = $month; $tmp_year = $year; } // create a view variables $selected_month = $_GET["month"]; // create the previous month's entries $c_weeknum = getWeekNumber($tmp_day, $tmp_month, $tmp_year); $selected_weeknum = getWeekNumber($_GET["mday"], $_GET["month"], $_GET["year"]); $OUTPUT .= "<tr>"; if ($first_wd != 1) { // only if there is a day in this week of previous month, print the week number $OUTPUT .= "<td width=75 height=60 " . TMPL_calLargeMonthWeekNumberStyle . " align=center>{$c_weeknum}</td>"; } for ($c_wd = 1; $c_wd < $first_wd; $c_wd++, $tmp_day++) { // fill differently for saturday and sunday (only when row wasn't already highlighted) if ($c_wd == 6) { $dayfill = "bgcolor=" . TMPL_calFillSaturday; } else { if ($c_wd == 7) { $dayfill = "bgcolor=" . TMPL_calFillSunday; } else { $dayfill = ""; } } $OUTPUT .= "<td {$dayfill} width=75 style='border-bottom: 1px solid #000000;' height=60 align=center>\r\n\t\t\t\t<a id='calSmallMonthOMLink' href='" . SELF . "?mday={$tmp_day}&month={$tmp_month}&year={$tmp_year}'>{$tmp_day}</a>\r\n\t\t\t</td>"; } // start creating this month's entries $cm_days = getDaysInMonth($month, $year); for ($c_day = 1; $c_day <= $cm_days; $c_day++) { $c_weeknum = getWeekNumber($c_day, $month, $year); if ($c_wd == 1) { // start a new row (it's MONDAY!!!!!) $OUTPUT .= "<tr>"; // attach the week number $OUTPUT .= "<td align=center width=75 height=60 " . TMPL_calLargeMonthWeekNumberStyle . ">{$c_weeknum}</td>"; } // change the fill color if it is 2day's date we are printing, or the selected date if (date("d") == $c_day && date("m") == $month && date("Y") == $year) { // 2day's date $dayfill = "bgcolor=" . TMPL_calLargeMonthSelectedDay; $a_id = "calSmallMonthCMLinkToday"; } else { // other dates // fill differently for saturday and sunday (only when the row has not already been colored) if ($c_weeknum == getTodayWeekNumber() && $year == date("Y") && $month == date("m")) { $dayfill = "bgcolor='" . TMPL_calLargeMonthCurrentWeek . "'"; } else { if ($c_wd == 6) { $dayfill = "bgcolor=" . TMPL_calFillSaturday; } else { if ($c_wd == 7) { $dayfill = "bgcolor=" . TMPL_calFillSunday; } else { $dayfill = ""; } } } $a_id = "calSmallMonthCMLink"; } $weeknum_first = getWeekNumber(1, $month, $year); $weeknum_last = getWeekNumber(getDaysInMonth($month, $year), $month, $year); // create the borders for the days $b_top = "border-top: 1px solid #000000;"; $b_bottom = "border-bottom: 1px solid #000000;"; $b_right = "border-right: 1px solid #000000;"; $b_left = "border-left: 1px solid #000000;"; $day_style = "cursor: pointer; cursor: hand; {$b_left} {$b_bottom}"; // first_week if ($c_weeknum == $weeknum_first) { $day_style .= "{$b_top} {$b_left}"; } // sundays if ($c_wd == 7 || getDaysInMonth($month, $year) == $c_day) { $day_style .= "{$b_right}"; } // check appointment, reminders and create the day information $checkdate_start = date("Y-m-d", mktime(0, 0, 0, $month, $c_day, $year)); $checkdate_end = date("Y-m-d", mktime(0, 0, 0, $month, $c_day + 1, $year)); db_conn("cubit"); $sql = "SELECT * FROM diary_entries\r\n\t\t\tWHERE (DATE '{$checkdate_start}', DATE '{$checkdate_end}') OVERLAPS (time_start, time_end)"; $rslt = db_exec($sql) or errDie("Error checking for appointments"); $entrycount = pg_num_rows($rslt); if ($entrycount > 0) { $count_entireday = 0; $day_information = "<table width=100%>"; while ($row = pg_fetch_array($rslt)) { $appointment_url = "diary-appointment.php?entry_id={$row['entry_id']}&key=view"; $onClick = "popupOpen(\"{$appointment_url}\",\"appointment_popup\",\"scrollbars=yes,width=500,height=590\")"; $day_information .= "\r\n\t\t\t\t\t<tr><td onClick='{$onClick}' nowrap>\r\n\t\t\t\t\t\t{$row['title']}\r\n\t\t\t\t\t</td></tr>"; } $day_information .= "</table>"; } else { $day_information = " "; } $OUTPUT .= "\r\n\t\t\t<td width=75 height=60 {$dayfill} valign=top align=center style='{$day_style}'>\r\n\t\t\t\t<table width=100% height=100%>\r\n\t\t\t\t<tr><td valign=top align=right height=0% onClick='document.location.href=\"" . SELF . "?mday={$c_day}&month={$month}&year={$year}&view_diary={$view_diary}\";'>\r\n\t\t\t\t\t<font size=2 color='" . TMPL_calLargeMonthOMLink_a . "'><b>{$c_day}</b></font>\r\n\t\t\t\t</td></tr>\r\n\t\t\t\t<tr><td valign=top align=center height=100%>\r\n\t\t\t\t\t{$day_information}\r\n\t\t\t\t</td></tr>\r\n\t\t\t\t</table>\r\n\t\t\t</td>"; if ($c_wd == 7) { // end the output $OUTPUT .= "</tr>"; } $c_wd == 7 ? $c_wd = 1 : $c_wd++; } // next month variables if ($month == 12) { $tmp_month = 1; $tmp_year = $year + 1; } else { $tmp_month = $month + 1; $tmp_year = $year; } // finish with the next months entries for ($c_day = 1; $c_wd <= 7 && $c_wd > 1; $c_wd++, $c_day++) { // fill differently for saturday and sunday if ($c_wd == 6) { $dayfill = "bgcolor=" . TMPL_calFillSaturday; } else { if ($c_wd == 7) { $dayfill = "bgcolor=" . TMPL_calFillSunday; } else { $dayfill = ""; } } $OUTPUT .= "<td {$dayfill} width=75 height=60 align=center>\r\n\t\t\t\t<a id='calSmallMonthOMLink' href='" . SELF . "?mday={$c_day}&month={$tmp_month}&year={$tmp_year}'>{$c_day}</a>\r\n\t\t\t</td>"; } // finish the tables and return $OUTPUT .= "\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</table>"; return $OUTPUT; }
/** * returns html for a date selection * * the form fields to update must have in id in the form of * ${idpfx}_day, ${idpfx}_month, ${idpfx}_year in the order day, month, year * respectively. * * @ignore * @param string idpfx prefix for form fields to update * @return string html */ function dateSelection($idpfx) { global $GWPP; /* all the different date parts with default values -> false */ $date_fields = array("day", "month", "year", "sday", "smonth", "syear"); foreach ($date_fields as $k) { if (!isset($_REQUEST[$k])) { ${$k} = false; } else { ${$k} = $_REQUEST[$k]; } } /* why check only date === false but set all of them to date() values? what if they have values you gonna overwrite? because I dont want bugs like day isset, month not, year isset causing some weird month to be shown */ if ($day === false) { $day = date("d"); $month = date("m"); $year = date("Y"); } if ($sday === false) { $sday = $day; $smonth = $month; $syear = $year; } /* forcibly fix the date */ explodeDate(date("Y-m-d", mktime(0, 0, 0, $smonth, $sday, $syear)), $syear, $smonth, $sday); /* previous year */ $pyear = extractYear(mkdatet($year - 1, $month, 1)); /* previous month */ $pmonth = extractMonth(mkdatet($year, $month - 1, 1)); $pmyear = extractYear(mkdatet($year, $month - 1, 1)); /* next month */ $nmonth = extractMonth(mkdatet($year, $month + 1, 1)); $nmyear = extractYear(mkdatet($year, $month + 1, 1)); /* next year */ $nyear = extractYear(mkdatet($year + 1, $month, 1)); /* month/year selections */ $dateselmove = "dateSelMoveBySelect(\"{$idpfx}\", \"{$day}\", \"{$sday}\", \"{$smonth}\", \"{$syear}\", \"{$GWPP}\");"; $move_month = mksel_month("datesel_move_month", $month, "onchange='{$dateselmove}'", true); $move_year = mksel_year("datesel_move_year", $year, "onchange='{$dateselmove}'"); $title_style = "onMouseUp='moveXLayer(false);' onMouseDown='moveXLayer(true);'"; $OUTPUT = "\n\t<div id='datesel_container' style='background: #fdeb89; border: 1px dashed black;' >\n\t<div id='datesel_loading' style='position: absolute; visibility: hidden;'>\n\t\t<p style='margin-left: 25px; margin-top: 60px;'>\n\t\t\t<strong>Loading. Please Wait...</strong>\n\t\t</p>\n\t</div>\n\t<div id='datesel_calender'>\n\t<table>\n\t<tr>\n\t\t<td nowrap='t' align='left'>\n\t\t\t{$move_month} {$move_year}\n\t\t\t<!--<input type='button' onclick='{$dateselmove}' value='Go'/>-->\n\t\t</td>\n\t\t<td align='right' nowrap='t' onMouseUp='moveXLayer(false);' onMouseDown='moveXLayer(true);'>\n\t\t\t<b><a id='xpopup_cls' href='javascript: XPopupHideAct()'>[X] </a></b>\n\t\t</td>\n\t</tr>\n\t<tr><td colspan='2'>\n\n\t<table width='190' cellspacing='0'>\n\t<tr>\n\t\t<td {$title_style} " . TMPL_calSmallMonthTitleStyleLeft . ">\n\t\t\t<a href='javascript: dateSelMove(\"{$idpfx}\", \"{$day}\", \"{$month}\", \"{$pyear}\", \"{$sday}\", \"{$smonth}\", \"{$syear}\", \"{$GWPP}\");'><img border='0' src='{$GWPP}/left_year.gif' /></a>\n\t\t\t<a href='javascript: dateSelMove(\"{$idpfx}\", \"{$day}\", \"{$pmonth}\", \"{$pmyear}\", \"{$sday}\", \"{$smonth}\", \"{$syear}\", \"{$GWPP}\");'><img border='0' src='{$GWPP}/left_month.gif' /></a>\n\t\t</td>\n\t\t<td {$title_style} " . TMPL_calSmallMonthTitleStyleCenter . ">\n\t\t\t" . getMonthName($month) . " {$year}\n\t\t</td>\n\t\t<td {$title_style} " . TMPL_calSmallMonthTitleStyleRight . ">\n\t\t\t<a href='javascript: dateSelMove(\"{$idpfx}\", \"{$day}\", \"{$nmonth}\", \"{$nmyear}\", \"{$sday}\", \"{$smonth}\", \"{$syear}\", \"{$GWPP}\");'><img border='0' src='{$GWPP}/right_month.gif' /></a>\n\t\t\t<a href='javascript: dateSelMove(\"{$idpfx}\", \"{$day}\", \"{$month}\", \"{$nyear}\", \"{$sday}\", \"{$smonth}\", \"{$syear}\", \"{$GWPP}\");'><img border='0' src='{$GWPP}/right_year.gif' /></a>\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t<td align='center' " . TMPL_calSmallMonthBodyStyle . " colspan='5'>"; // generate the titles of the weekdays $OUTPUT .= "\n\t\t<table width='184' cellspacing='0'>\n\t\t\t<tr>\n\t\t\t\t<td width='23'> </td>\n\t\t\t\t<td width='23' align='center'><b>M</b></td>\n\t\t\t\t<td width='23' align='center'><b>T</b></td>\n\t\t\t\t<td width='23' align='center'><b>W</b></td>\n\t\t\t\t<td width='23' align='center'><b>T</b></td>\n\t\t\t\t<td width='23' align='center'><b>F</b></td>\n\t\t\t\t<td width='23' align='center' bgcolor=" . TMPL_calFillSaturday . "><b>S</b></td>\n\t\t\t\t<td width='23' align='center' bgcolor=" . TMPL_calFillSunday . "><b>S</b></td>\n\t\t\t</tr>"; // get the weekday number of the first of this month $first_wd = getWeekdayNum(1, $month, $year); // the following code will generate the first entries on the calendar, which is for the previous month (if any) // month and year of previous month if ($month == 1) { $tmp_month = 12; $tmp_year = $year - 1; } else { $tmp_month = $month - 1; $tmp_year = $year; } // date of last monday in previous month (where the entries will start) if ($first_wd > 1) { $tmp_day = getDaysInMonth($tmp_month, $tmp_year) - ($first_wd - 2); } else { $tmp_day = 1; $tmp_month = $month; $tmp_year = $year; } // create a view variables $selected_month = $smonth; // create the previous month's entries $c_weeknum = getWeekNumber($tmp_day, $tmp_month, $tmp_year); $selected_weeknum = getWeekNumber($sday, $smonth, $syear); // if today's week number = the current generated week's number, hightlight the row, as so with the selected week, if ($c_weeknum == getTodayWeekNumber() && $tmp_year == date("Y") && $month == date("m") || getTodayWeekNumber() == 0 && $month == date("m") && $year == date("Y")) { // today's week $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>"; $ROW_COLORED = 1; } else { if ($year == $syear && $month == $smonth && $c_weeknum == $selected_weeknum || $c_weeknum == 52 && $selected_weeknum == 0) { // selected week, the last check is for the first week in jan $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>"; $ROW_COLORED = 1; } else { // other dates $OUTPUT .= "<tr>"; $ROW_COLORED = 0; } } if ($first_wd != 1) { // only if there is a day in this week of previous month, print the week number $OUTPUT .= "<td width='23' " . TMPL_calSmallMonthWeekNumberStyle . " align='center'>{$c_weeknum}</td>"; } for ($c_wd = 1; $c_wd < $first_wd; $c_wd++, $tmp_day++) { // fill differently for saturday and sunday (only when row wasn't already highlighted) if ($c_wd == 6 && !$ROW_COLORED) { $dayfill = "bgcolor='" . TMPL_calFillSaturday . "'"; } else { if ($c_wd == 7) { $dayfill = "bgcolor='" . TMPL_calFillSunday . "'"; } else { $dayfill = ""; } } $OUTPUT .= "\n\t\t\t<td {$dayfill} width='23' align='center'>\n\t\t\t\t<a id='calSmallMonthOMLink' href='javascript: dateSelUpdate(\"{$idpfx}\", \"{$tmp_day}\", \"{$tmp_month}\", \"{$tmp_year}\");'>{$tmp_day}</a>\n\t\t\t</td>"; } // start creating this month's entries $cm_days = getDaysInMonth($month, $year); for ($c_day = 1; $c_day <= $cm_days; $c_day++) { $c_weeknum = getWeekNumber($c_day, $month, $year); if ($c_wd == 1) { // start a new row (it's MONDAY!!!!!) // if today's week number = the current generated week's number, hightlight the row, as so with the selected week if ($c_weeknum == getTodayWeekNumber() && $year == date("Y") && $month == date("m")) { // today's week $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>"; $ROW_COLORED = 1; } else { if ($year == $syear && $month == $smonth && $c_weeknum == $selected_weeknum) { // selected week $OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>"; $ROW_COLORED = 1; } else { // other dates $OUTPUT .= "<tr>"; $ROW_COLORED = 0; } } // attach the week number $OUTPUT .= "<td align='center' width='23' " . TMPL_calSmallMonthWeekNumberStyle . ">{$c_weeknum}</td>"; } /* change the fill color if it it 2day's date we are printing */ if ($c_day == $sday && $month == $smonth && $year == $syear) { // selected date $dayfill = "bgcolor=" . TMPL_calSmallMonthSelectedDay; $a_id = "calSmallMonthCMLinkSelected"; } else { if (date("d") == $c_day && date("m") == $month && date("Y") == $year) { // 2day's date $dayfill = "bgcolor='" . TMPL_calSmallMonthCurrentDay . "'"; $a_id = "calSmallMonthCMLinkToday"; } else { // other dates // fill differently for saturday and sunday (only when the row has not already been colored) if ($c_wd == 6 && !$ROW_COLORED) { $dayfill = "bgcolor='" . TMPL_calFillSaturday . "'"; } else { if ($c_wd == 7 && !$ROW_COLORED) { $dayfill = "bgcolor='" . TMPL_calFillSunday . "'"; } else { $dayfill = ""; } } $a_id = "calSmallMonthCMLink"; } } $OUTPUT .= "\n\t\t\t<td width='23' {$dayfill} align='center'>\n\t\t\t\t<a id='{$a_id}' href='javascript: dateSelUpdate(\"{$idpfx}\", \"{$c_day}\", \"{$month}\", \"{$year}\");'>{$c_day}</a>\n\t\t\t</td>"; /* end of output */ if ($c_wd == 7) { $OUTPUT .= "</tr>"; } $c_wd = $c_wd == 7 ? 1 : $c_wd + 1; } // next month variables if ($month == 12) { $tmp_month = 1; $tmp_year = $year + 1; } else { $tmp_month = $month + 1; $tmp_year = $year; } // finish with the next months entries for ($c_day = 1; $c_wd <= 7 && $c_wd > 1; $c_wd++, $c_day++) { // fill differently for saturday and sunday if ($c_wd == 6 && !$ROW_COLORED) { $dayfill = "bgcolor='" . TMPL_calFillSaturday . "'"; } else { if ($c_wd == 7 && !$ROW_COLORED) { $dayfill = "bgcolor='" . TMPL_calFillSunday . "'"; } else { $dayfill = ""; } } $OUTPUT .= "\n\t\t<td {$dayfill} width='23' align='center'>\n\t\t\t<a id='calSmallMonthOMLink' href='javascript: dateSelUpdate(\"{$idpfx}\", \"{$c_day}\", \"{$tmp_month}\", \"{$tmp_year}\");'>{$c_day}</a>\n\t\t</td>"; } /* finish the tables and return */ $OUTPUT .= "\n\t\t\t</tr>\n\t\t</table>\n\t\t</td>\n\t</tr>\n\t</table>\n\n\t</td></tr>\n\t</table>\n\t</div>\n\t</div>"; return $OUTPUT; }