コード例 #1
0
             $timeStart = $rowDiffDay["timeStart"];
         }
         if ($rowDiffDay["timeEnd"] > $timeEnd) {
             $timeEnd = $rowDiffDay["timeEnd"];
         }
     }
 }
 //Final calc
 $diffTime = strtotime($timeEnd) - strtotime($timeStart);
 $width = ceil(690 / $daysInWeek) - 20 . "px";
 $count = 0;
 print "<table class='mini' cellspacing='0' style='width: 760px; margin: 0px 0px 30px 0px;'>";
 print "<tr class='head'>";
 print "<th style='vertical-align: top; width: 70px; text-align: center'>";
 //Calculate week number
 $week = getWeekNumber($startDayStamp, $connection2, $guid);
 if ($week != false) {
     print _("Week") . " " . $week . "<br/>";
 }
 print "<span style='font-weight: normal; font-style: italic;'>" . _('Time') . "<span>";
 print "</th>";
 if ($days["Mon"] == "Y") {
     print "<th style='vertical-align: top; text-align: center; width: " . 550 / $daysInWeek . "px'>";
     print _("Mon") . "<br/>";
     print "<span style='font-size: 80%; font-style: italic'>" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp + 86400 * 0) . "</span><br/>";
     print "</th>";
 }
 if ($days["Tue"] == "Y") {
     print "<th style='vertical-align: top; text-align: center; width: " . 550 / $daysInWeek . "px'>";
     print _("Tue") . "<br/>";
     print "<span style='font-size: 80%; font-style: italic'>" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp + 86400 * 1) . "</span><br/>";
コード例 #2
0
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>&nbsp;</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;
}
コード例 #3
0
ファイル: functions.inc.php プロジェクト: JeromeDevome/GRR
function cal($month, $year)
{
    global $weekstarts;
    if (!isset($weekstarts)) {
        $weekstarts = 0;
    }
    $s = "";
    $daysInMonth = getDaysInMonth($month, $year);
    $date = mktime(12, 0, 0, $month, 1, $year);
    $first = (strftime("%w", $date) + 7 - $weekstarts) % 7;
    $monthName = ucfirst(utf8_strftime("%B", $date));
    $s .= '<table class="table calendar2">' . PHP_EOL;
    $s .= '<tr>' . PHP_EOL;
    $s .= '<td class="calendarHeader2" colspan="8">' . $monthName . ' ' . $year . '</td>' . PHP_EOL;
    $s .= '</tr>' . PHP_EOL;
    $d = 1 - $first;
    $is_ligne1 = 'y';
    while ($d <= $daysInMonth) {
        $s .= '<tr>' . PHP_EOL;
        for ($i = 0; $i < 7; $i++) {
            $basetime = mktime(12, 0, 0, 6, 11 + $weekstarts, 2000);
            $show = $basetime + $i * 24 * 60 * 60;
            $nameday = utf8_strftime('%A', $show);
            $temp = mktime(0, 0, 0, $month, $d, $year);
            if ($i == 0) {
                $s .= '<td class="calendar2" style="vertical-align:bottom;"><b>S' . getWeekNumber($temp) . '</b></td>' . PHP_EOL;
            }
            $s .= '<td class="calendar2" align="center" valign="top">' . PHP_EOL;
            if ($is_ligne1 == 'y') {
                $s .= '<b>' . ucfirst(substr($nameday, 0, 1)) . '</b><br />';
            }
            if ($d > 0 && $d <= $daysInMonth) {
                $s .= $d;
                $day = grr_sql_query1("SELECT day FROM " . TABLE_PREFIX . "_calendar WHERE day='{$temp}'");
                $s .= '<br><input type="checkbox" name="' . $temp . '" value="' . $nameday . '" ';
                if (!($day < 0)) {
                    $s .= 'checked="checked" ';
                }
                $s .= '/>';
            } else {
                $s .= " ";
            }
            $s .= '</td>' . PHP_EOL;
            $d++;
        }
        $s .= '</tr>' . PHP_EOL;
        $is_ligne1 = 'n';
    }
    $s .= '</table>' . PHP_EOL;
    return $s;
}
コード例 #4
0
ファイル: moduleFunctions.php プロジェクト: dpredster/core
function renderTTSpace($guid, $connection2, $gibbonSpaceID, $gibbonTTID, $title = "", $startDayStamp = "", $q = "", $params = "")
{
    $output = "";
    $blank = TRUE;
    if ($startDayStamp == "") {
        $startDayStamp = time();
    }
    $zCount = 0;
    $top = 0;
    //Find out which timetables I am involved in this year
    try {
        $data = array("gibbonSpaceID" => $gibbonSpaceID, "gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"]);
        $sql = "SELECT DISTINCT gibbonTT.gibbonTTID, gibbonTT.name FROM gibbonTT JOIN gibbonTTDay ON (gibbonTT.gibbonTTID=gibbonTTDay.gibbonTTID) JOIN gibbonTTDayRowClass ON (gibbonTTDayRowClass.gibbonTTDayID=gibbonTTDay.gibbonTTDayID) JOIN gibbonCourseClass ON (gibbonTTDayRowClass.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonSpaceID=:gibbonSpaceID AND gibbonSchoolYearID=:gibbonSchoolYearID AND active='Y' ";
        $result = $connection2->prepare($sql);
        $result->execute($data);
    } catch (PDOException $e) {
        $output .= "<div class='error'>" . $e->getMessage() . "</div>";
    }
    //If I am not involved in any timetables display all within the year
    if ($result->rowCount() == 0) {
        try {
            $data = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"]);
            $sql = "SELECT gibbonTT.gibbonTTID, gibbonTT.name FROM gibbonTT WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND active='Y' ";
            $result = $connection2->prepare($sql);
            $result->execute($data);
        } catch (PDOException $e) {
            $output .= "<div class='error'>" . $e->getMessage() . "</div>";
        }
    }
    //link to other TTs
    if ($result->rowcount() > 1) {
        $output .= "<table class='noIntBorder' style='width: 100%'>";
        $output .= "<tr>";
        $output .= "<td>";
        $output .= "<span style='font-size: 115%; font-weight: bold'>" . _('Timetable Chooser') . "</span>: ";
        while ($row = $result->fetch()) {
            $output .= "<form method='post' action='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q={$q}" . $params . "&gibbonTTID=" . $row["gibbonTTID"] . "'>";
            $output .= "<input name='ttDate' value='" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp) . "' type='hidden'>";
            $output .= "<input name='schoolCalendar' value='" . $_SESSION[$guid]["viewCalendarSchool"] . "' type='hidden'>";
            $output .= "<input name='personalCalendar' value='" . $_SESSION[$guid]["viewCalendarPersonal"] . "' type='hidden'>";
            $output .= "<input name='spaceBookingCalendar' value='" . $_SESSION[$guid]["viewCalendarSpaceBooking"] . "' type='hidden'>";
            $output .= "<input name='fromTT' value='Y' type='hidden'>";
            $output .= "<input class='buttonLink' style='min-width: 30px; margin-top: 0px; float: left' type='submit' value='" . $row["name"] . "'>";
            $output .= "</form>";
        }
        try {
            $result = $connection2->prepare($sql);
            $result->execute($data);
        } catch (PDOException $e) {
            $output .= "<div class='error'>" . $e->getMessage() . "</div>";
        }
        $output .= "</td>";
        $output .= "</tr>";
        $output .= "</table>";
        if ($gibbonTTID != "") {
            $data = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"], "gibbonTTID" => $gibbonTTID);
            $sql = "SELECT DISTINCT gibbonTT.gibbonTTID, gibbonTT.name FROM gibbonTT JOIN gibbonTTDay ON (gibbonTT.gibbonTTID=gibbonTTDay.gibbonTTID) JOIN gibbonTTDayRowClass ON (gibbonTTDayRowClass.gibbonTTDayID=gibbonTTDay.gibbonTTDayID) JOIN gibbonCourseClass ON (gibbonTTDayRowClass.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonSpaceID={$gibbonSpaceID} AND gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonTT.gibbonTTID=:gibbonTTID";
        }
        try {
            $result = $connection2->prepare($sql);
            $result->execute($data);
        } catch (PDOException $e) {
            $output .= "<div class='error'>" . $e->getMessage() . "</div>";
        }
    }
    //Get space booking array
    $eventsSpaceBooking = FALSE;
    if ($_SESSION[$guid]["viewCalendarSpaceBooking"] == "Y") {
        $eventsSpaceBooking = getSpaceBookingEventsSpace($guid, $connection2, $startDayStamp, $gibbonSpaceID);
    }
    //Display first TT
    if ($result->rowCount() > 0) {
        $row = $result->fetch();
        if ($title != FALSE) {
            $output .= "<h2>" . $row["name"] . "</h2>";
        }
        $output .= "<table cellspacing='0' class='noIntBorder' cellspacing='0' style='width: 100%; margin: 10px 0 10px 0'>";
        $output .= "<tr>";
        $output .= "<td style='vertical-align: top'>";
        $output .= "<form method='post' action='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q={$q}" . $params . "&gibbonTTID=" . $row["gibbonTTID"] . "'>";
        $output .= "<input name='ttDate' maxlength=10 value='" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp - 7 * 24 * 60 * 60) . "' type='hidden'>";
        $output .= "<input name='schoolCalendar' value='" . $_SESSION[$guid]["viewCalendarSchool"] . "' type='hidden'>";
        $output .= "<input name='personalCalendar' value='" . $_SESSION[$guid]["viewCalendarPersonal"] . "' type='hidden'>";
        $output .= "<input name='spaceBookingCalendar' value='" . $_SESSION[$guid]["viewCalendarSpaceBooking"] . "' type='hidden'>";
        $output .= "<input name='fromTT' value='Y' type='hidden'>";
        $output .= "<input class='buttonLink' style='min-width: 30px; margin-top: 0px; float: left' type='submit' value='" . _('Last Week') . "'>";
        $output .= "</form>";
        $output .= "<form method='post' action='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q={$q}" . $params . "&gibbonTTID=" . $row["gibbonTTID"] . "'>";
        $output .= "<input name='ttDate' value='" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp + 7 * 24 * 60 * 60) . "' type='hidden'>";
        $output .= "<input name='schoolCalendar' value='" . $_SESSION[$guid]["viewCalendarSchool"] . "' type='hidden'>";
        $output .= "<input name='personalCalendar' value='" . $_SESSION[$guid]["viewCalendarPersonal"] . "' type='hidden'>";
        $output .= "<input name='spaceBookingCalendar' value='" . $_SESSION[$guid]["viewCalendarSpaceBooking"] . "' type='hidden'>";
        $output .= "<input name='fromTT' value='Y' type='hidden'>";
        $output .= "<input class='buttonLink' style='min-width: 30px; margin-top: 0px; float: left' type='submit' value='" . _('Next Week') . "'>";
        $output .= "</form>";
        $output .= "</td>";
        $output .= "<td style='vertical-align: top; text-align: right'>";
        $output .= "<form method='post' action='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q={$q}" . $params . "&gibbonTTID=" . $row["gibbonTTID"] . "'>";
        $output .= "<input name='ttDate' id='ttDate' maxlength=10 value='" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp) . "' type='text' style='height: 22px; width:100px; margin-right: 0px; float: none'>";
        $output .= "<script type=\"text/javascript\">";
        $output .= "var ttDate=new LiveValidation('ttDate');";
        $output .= "ttDate.add( Validate.Format, {pattern: ";
        if ($_SESSION[$guid]["i18n"]["dateFormatRegEx"] == "") {
            $output .= "/^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\\d\\d\$/i";
        } else {
            $output .= $_SESSION[$guid]["i18n"]["dateFormatRegEx"];
        }
        $output .= ", failureMessage: \"Use ";
        if ($_SESSION[$guid]["i18n"]["dateFormat"] == "") {
            $output .= "dd/mm/yyyy";
        } else {
            $output .= $_SESSION[$guid]["i18n"]["dateFormat"];
        }
        $output .= ".\" } );";
        $output .= "ttDate.add(Validate.Presence);";
        $output .= "</script>";
        $output .= "<script type=\"text/javascript\">";
        $output .= "\$(function() {";
        $output .= "\$(\"#ttDate\").datepicker();";
        $output .= "});";
        $output .= "</script>";
        $output .= "<input style='margin-top: 0px; margin-right: -2px' type='submit' value='" . _('Go') . "'>";
        $output .= "<input name='schoolCalendar' value='" . $_SESSION[$guid]["viewCalendarSchool"] . "' type='hidden'>";
        $output .= "<input name='personalCalendar' value='" . $_SESSION[$guid]["viewCalendarPersonal"] . "' type='hidden'>";
        $output .= "<input name='spaceBookingCalendar' value='" . $_SESSION[$guid]["viewCalendarSpaceBooking"] . "' type='hidden'>";
        $output .= "<input name='fromTT' value='Y' type='hidden'>";
        $output .= "</form>";
        $output .= "</td>";
        $output .= "</tr>";
        $output .= "</table>";
        //Count back to first Monday before first day
        while (date("D", $startDayStamp) != "Mon") {
            $startDayStamp = $startDayStamp - 86400;
        }
        //Check which days are school days
        $daysInWeek = 0;
        $days = array();
        $timeStart = "";
        $timeEnd = "";
        $days["Mon"] = "N";
        $days["Tue"] = "N";
        $days["Wed"] = "N";
        $days["Thu"] = "N";
        $days["Fri"] = "N";
        $days["Sat"] = "N";
        $days["Sun"] = "N";
        try {
            $dataDays = array();
            $sqlDays = "SELECT * FROM gibbonDaysOfWeek WHERE schoolDay='Y'";
            $resultDays = $connection2->prepare($sqlDays);
            $resultDays->execute($dataDays);
        } catch (PDOException $e) {
            $output .= "<div class='error'>" . $e->getMessage() . "</div>";
        }
        while ($rowDays = $resultDays->fetch()) {
            //Max diff time for week based on days of week
            if ($timeStart == "") {
                $timeStart = $rowDays["schoolStart"];
            }
            if ($rowDays["schoolStart"] < $timeStart) {
                $timeStart = $rowDays["schoolStart"];
            }
            if ($timeEnd == "") {
                $timeEnd = $rowDays["schoolEnd"];
            }
            if ($rowDays["schoolEnd"] > $timeEnd) {
                $timeEnd = $rowDays["schoolEnd"];
            }
            //See which days are school days
            if ($rowDays["nameShort"] == "Mon") {
                $days["Mon"] = "Y";
                $daysInWeek++;
            } else {
                if ($rowDays["nameShort"] == "Tue") {
                    $days["Tue"] = "Y";
                    $daysInWeek++;
                } else {
                    if ($rowDays["nameShort"] == "Wed") {
                        $days["Wed"] = "Y";
                        $daysInWeek++;
                    } else {
                        if ($rowDays["nameShort"] == "Thu") {
                            $days["Thu"] = "Y";
                            $daysInWeek++;
                        } else {
                            if ($rowDays["nameShort"] == "Fri") {
                                $days["Fri"] = "Y";
                                $daysInWeek++;
                            } else {
                                if ($rowDays["nameShort"] == "Sat") {
                                    $days["Sat"] = "Y";
                                    $daysInWeek++;
                                } else {
                                    if ($rowDays["nameShort"] == "Sun") {
                                        $days["Sun"] = "Y";
                                        $daysInWeek++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        //Count forward to the end of the week
        $endDayStamp = $startDayStamp + 86400 * $daysInWeek;
        $schoolCalendarAlpha = 0.85;
        $ttAlpha = 1.0;
        if ($_SESSION[$guid]["viewCalendarSpaceBooking"] != "N") {
            $ttAlpha = 0.75;
        }
        //Max diff time for week based on timetables
        try {
            $dataDiff = array("date1" => date("Y-m-d", $startDayStamp + 86400 * 0), "date2" => date("Y-m-d", $endDayStamp + 86400 * 1), "gibbonTTID" => $row["gibbonTTID"]);
            $sqlDiff = "SELECT DISTINCT gibbonTTColumn.gibbonTTColumnID FROM gibbonTTDay JOIN gibbonTTDayDate ON (gibbonTTDay.gibbonTTDayID=gibbonTTDayDate.gibbonTTDayID) JOIN gibbonTTColumn ON (gibbonTTDay.gibbonTTColumnID=gibbonTTColumn.gibbonTTColumnID) WHERE (date>=:date1 AND date<=:date2) AND gibbonTTID=:gibbonTTID";
            $resultDiff = $connection2->prepare($sqlDiff);
            $resultDiff->execute($dataDiff);
        } catch (PDOException $e) {
            $output .= "<div class='error'>" . $e->getMessage() . "</div>";
        }
        while ($rowDiff = $resultDiff->fetch()) {
            try {
                $dataDiffDay = array("gibbonTTColumnID" => $rowDiff["gibbonTTColumnID"]);
                $sqlDiffDay = "SELECT * FROM gibbonTTColumnRow WHERE gibbonTTColumnID=:gibbonTTColumnID ORDER BY timeStart";
                $resultDiffDay = $connection2->prepare($sqlDiffDay);
                $resultDiffDay->execute($dataDiffDay);
            } catch (PDOException $e) {
                $output .= "<div class='error'>" . $e->getMessage() . "</div>";
            }
            while ($rowDiffDay = $resultDiffDay->fetch()) {
                if ($rowDiffDay["timeStart"] < $timeStart) {
                    $timeStart = $rowDiffDay["timeStart"];
                }
                if ($rowDiffDay["timeEnd"] > $timeEnd) {
                    $timeEnd = $rowDiffDay["timeEnd"];
                }
            }
        }
        //Max diff time for week based on special days timing change
        try {
            $dataDiff = array("date1" => date("Y-m-d", $startDayStamp + 86400 * 0), "date2" => date("Y-m-d", $startDayStamp + 86400 * 6));
            $sqlDiff = "SELECT * FROM gibbonSchoolYearSpecialDay WHERE date>=:date1 AND date<=:date2 AND type='Timing Change' AND NOT schoolStart IS NULL AND NOT schoolEnd IS NULL";
            $resultDiff = $connection2->prepare($sqlDiff);
            $resultDiff->execute($dataDiff);
        } catch (PDOException $e) {
            $output .= "<div class='error'>" . $e->getMessage() . "</div>";
        }
        while ($rowDiff = $resultDiff->fetch()) {
            if ($rowDiff["schoolStart"] < $timeStart) {
                $timeStart = $rowDiff["schoolStart"];
            }
            if ($rowDiff["schoolEnd"] > $timeEnd) {
                $timeEnd = $rowDiff["schoolEnd"];
            }
        }
        //Max diff based on space booking events
        if ($eventsSpaceBooking != FALSE) {
            foreach ($eventsSpaceBooking as $event) {
                if ($event[3] <= date("Y-m-d", $startDayStamp + 86400 * 6)) {
                    if ($event[4] < $timeStart) {
                        $timeStart = $event[4];
                    }
                    if ($event[5] > $timeEnd) {
                        $timeEnd = $event[5];
                    }
                }
            }
        }
        //Final calc
        $diffTime = strtotime($timeEnd) - strtotime($timeStart);
        $width = ceil(690 / $daysInWeek) - 20 . "px";
        $count = 0;
        $output .= "<table cellspacing='0' class='mini' cellspacing='0' style='width: 750px; margin: 0px 0px 30px 0px;'>";
        //Spit out controls for displaying calendars
        if ($_SESSION[$guid]["viewCalendarSpaceBooking"] != "") {
            $output .= "<tr class='head' style='height: 37px;'>";
            $output .= "<th class='ttCalendarBar' colspan=" . ($daysInWeek + 1) . ">";
            $output .= "<form method='post' action='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q={$q}" . $params . "' style='padding: 5px 5px 0 0'>";
            if ($_SESSION[$guid]["viewCalendarSpaceBooking"] != "") {
                $checked = "";
                if ($_SESSION[$guid]["viewCalendarSpaceBooking"] == "Y") {
                    $checked = "checked";
                }
                $output .= "<span class='ttSpaceBookingCalendar' style='opacity: {$schoolCalendarAlpha}'>" . _('Space Booking') . " ";
                $output .= "<input {$checked} style='margin-left: 3px' type='checkbox' name='spaceBookingCalendar' onclick='submit();'/>";
                $output .= "</span>";
            }
            $output .= "<input type='hidden' name='ttDate' value='" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp) . "'>";
            $output .= "<input name='fromTT' value='Y' type='hidden'>";
            $output .= "</form>";
            $output .= "</th>";
            $output .= "</tr>";
        }
        $output .= "<tr class='head'>";
        $output .= "<th style='vertical-align: top; width: 70px; text-align: center'>";
        //Calculate week number
        $week = getWeekNumber($startDayStamp, $connection2, $guid);
        if ($week != false) {
            $output .= sprintf(_('Week %1$s'), $week) . "<br/>";
        }
        $output .= "<span style='font-weight: normal; font-style: italic;'>" . _('Time') . "<span>";
        $output .= "</th>";
        if ($days["Mon"] == "Y") {
            $output .= "<th style='vertical-align: top; text-align: center; width: " . 550 / $daysInWeek . "px'>";
            $output .= _("Mon") . "<br/>";
            $output .= "<span style='font-size: 80%; font-style: italic'>" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp + 86400 * 0) . "</span><br/>";
            try {
                $dataSpecial = array("date" => date("Y-m-d", $startDayStamp + 86400 * 0));
                $sqlSpecial = "SELECT * FROM gibbonSchoolYearSpecialDay WHERE date=:date AND type='Timing Change'";
                $resultSpecial = $connection2->prepare($sqlSpecial);
                $resultSpecial->execute($dataSpecial);
            } catch (PDOException $e) {
                $output .= "<div class='error'>" . $e->getMessage() . "</div>";
            }
            if ($resultSpecial->rowCount() == 1) {
                $rowSpecial = $resultSpecial->fetch();
                $output .= "<span style='font-size: 80%; font-weight: bold'><u>" . $rowSpecial["name"] . "</u></span>";
            }
            $output .= "</th>";
        }
        if ($days["Tue"] == "Y") {
            $output .= "<th style='vertical-align: top; text-align: center; width: " . 550 / $daysInWeek . "px'>";
            $output .= _("Tue") . "<br/>";
            $output .= "<span style='font-size: 80%; font-style: italic'>" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp + 86400 * 1) . "</span><br/>";
            try {
                $dataSpecial = array("date" => date("Y-m-d", $startDayStamp + 86400 * 1));
                $sqlSpecial = "SELECT * FROM gibbonSchoolYearSpecialDay WHERE date=:date AND type='Timing Change'";
                $resultSpecial = $connection2->prepare($sqlSpecial);
                $resultSpecial->execute($dataSpecial);
            } catch (PDOException $e) {
                $output .= "<div class='error'>" . $e->getMessage() . "</div>";
            }
            if ($resultSpecial->rowCount() == 1) {
                $rowSpecial = $resultSpecial->fetch();
                $output .= "<span style='font-size: 80%; font-weight: bold'><u>" . $rowSpecial["name"] . "</u></span>";
            }
            $output .= "</th>";
        }
        if ($days["Wed"] == "Y") {
            $output .= "<th style='vertical-align: top; text-align: center; width: " . 550 / $daysInWeek . "px'>";
            $output .= _("Wed") . "<br/>";
            $output .= "<span style='font-size: 80%; font-style: italic'>" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp + 86400 * 2) . "</span><br/>";
            try {
                $dataSpecial = array("date" => date("Y-m-d", $startDayStamp + 86400 * 2));
                $sqlSpecial = "SELECT * FROM gibbonSchoolYearSpecialDay WHERE date=:date AND type='Timing Change'";
                $resultSpecial = $connection2->prepare($sqlSpecial);
                $resultSpecial->execute($dataSpecial);
            } catch (PDOException $e) {
                $output .= "<div class='error'>" . $e->getMessage() . "</div>";
            }
            if ($resultSpecial->rowCount() == 1) {
                $rowSpecial = $resultSpecial->fetch();
                $output .= "<span style='font-size: 80%; font-weight: bold'><u>" . $rowSpecial["name"] . "</u></span>";
            }
            $output .= "</th>";
        }
        if ($days["Thu"] == "Y") {
            $output .= "<th style='vertical-align: top; text-align: center; width: " . 550 / $daysInWeek . "px'>";
            $output .= _("Thu") . "<br/>";
            $output .= "<span style='font-size: 80%; font-style: italic'>" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp + 86400 * 3) . "</span><br/>";
            try {
                $dataSpecial = array("date" => date("Y-m-d", $startDayStamp + 86400 * 3));
                $sqlSpecial = "SELECT * FROM gibbonSchoolYearSpecialDay WHERE date=:date AND type='Timing Change'";
                $resultSpecial = $connection2->prepare($sqlSpecial);
                $resultSpecial->execute($dataSpecial);
            } catch (PDOException $e) {
                $output .= "<div class='error'>" . $e->getMessage() . "</div>";
            }
            if ($resultSpecial->rowCount() == 1) {
                $rowSpecial = $resultSpecial->fetch();
                $output .= "<span style='font-size: 80%; font-weight: bold'><u>" . $rowSpecial["name"] . "</u></span>";
            }
            $output .= "</th>";
        }
        if ($days["Fri"] == "Y") {
            $output .= "<th style='vertical-align: top; text-align: center; width: " . 550 / $daysInWeek . "px'>";
            $output .= _("Fri") . "<br/>";
            $output .= "<span style='font-size: 80%; font-style: italic'>" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp + 86400 * 4) . "</span><br/>";
            try {
                $dataSpecial = array("date" => date("Y-m-d", $startDayStamp + 86400 * 4));
                $sqlSpecial = "SELECT * FROM gibbonSchoolYearSpecialDay WHERE date=:date AND type='Timing Change'";
                $resultSpecial = $connection2->prepare($sqlSpecial);
                $resultSpecial->execute($dataSpecial);
            } catch (PDOException $e) {
                $output .= "<div class='error'>" . $e->getMessage() . "</div>";
            }
            if ($resultSpecial->rowCount() == 1) {
                $rowSpecial = $resultSpecial->fetch();
                $output .= "<span style='font-size: 80%; font-weight: bold'><u>" . $rowSpecial["name"] . "</u></span>";
            }
            $output .= "</th>";
        }
        if ($days["Sat"] == "Y") {
            $output .= "<th style='vertical-align: top; text-align: center; width: " . 550 / $daysInWeek . "px'>";
            $output .= _("Sat") . "<br/>";
            $output .= "<span style='font-size: 80%; font-style: italic'>" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp + 86400 * 5) . "</span><br/>";
            try {
                $dataSpecial = array("date" => date("Y-m-d", $startDayStamp + 86400 * 5));
                $sqlSpecial = "SELECT * FROM gibbonSchoolYearSpecialDay WHERE date=:date AND type='Timing Change'";
                $resultSpecial = $connection2->prepare($sqlSpecial);
                $resultSpecial->execute($dataSpecial);
            } catch (PDOException $e) {
                $output .= "<div class='error'>" . $e->getMessage() . "</div>";
            }
            if ($resultSpecial->rowCount() == 1) {
                $rowSpecial = $resultSpecial->fetch();
                $output .= "<span style='font-size: 80%; font-weight: bold'><u>" . $rowSpecial["name"] . "</u></span>";
            }
            $output .= "</th>";
        }
        if ($days["Sun"] == "Y") {
            $output .= "<th style='vertical-align: top; text-align: center; width: " . 550 / $daysInWeek . "px'>";
            $output .= _("Sun") . "<br/>";
            $output .= "<span style='font-size: 80%; font-style: italic'>" . date($_SESSION[$guid]["i18n"]["dateFormatPHP"], $startDayStamp + 86400 * 6) . "</span><br/>";
            try {
                $dataSpecial = array("date" => date("Y-m-d", $startDayStamp + 86400 * 6));
                $sqlSpecial = "SELECT * FROM gibbonSchoolYearSpecialDay WHERE date=:date AND type='Timing Change'";
                $resultSpecial = $connection2->prepare($sqlSpecial);
                $resultSpecial->execute($dataSpecial);
            } catch (PDOException $e) {
                $output .= "<div class='error'>" . $e->getMessage() . "</div>";
            }
            if ($resultSpecial->rowCount() == 1) {
                $rowSpecial = $resultSpecial->fetch();
                $output .= "<span style='font-size: 80%; font-weight: bold'><u>" . $rowSpecial["name"] . "</u></span>";
            }
            $output .= "</th>";
        }
        $output .= "</tr>";
        $output .= "<tr style='height:" . (ceil($diffTime / 60) + 14) . "px'>";
        $output .= "<td class='ttTime' style='height: 300px; width: 75px; text-align: center; vertical-align: top'>";
        $output .= "<div style='position: relative; width: 71px'>";
        $countTime = 0;
        $time = $timeStart;
        $output .= "<div {$title} style='position: absolute; top: -3px; width: 71px ; border: none; height: 60px; margin: 0px; padding: 0px; font-size: 92%'>";
        $output .= substr($time, 0, 5) . "<br/>";
        $output .= "</div>";
        $time = date("H:i:s", strtotime($time) + 3600);
        $spinControl = 0;
        while ($time <= $timeEnd and $spinControl < @(23 - date("H", $timeStart))) {
            $countTime++;
            $output .= "<div {$title} style='position: absolute; top:" . ($countTime * 60 - 5) . "px ; width: 71px ; border: none; height: 60px; margin: 0px; padding: 0px; font-size: 92%'>";
            $output .= substr($time, 0, 5) . "<br/>";
            $output .= "</div>";
            $time = date("H:i:s", strtotime($time) + 3600);
            $spinControl++;
        }
        $output .= "</div>";
        $output .= "</td>";
        //Check to see if week is at all in term time...if it is, then display the grid
        $isWeekInTerm = FALSE;
        try {
            $dataTerm = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"]);
            $sqlTerm = "SELECT gibbonSchoolYearTerm.firstDay, gibbonSchoolYearTerm.lastDay FROM gibbonSchoolYearTerm, gibbonSchoolYear WHERE gibbonSchoolYearTerm.gibbonSchoolYearID=gibbonSchoolYear.gibbonSchoolYearID AND gibbonSchoolYear.gibbonSchoolYearID=:gibbonSchoolYearID";
            $resultTerm = $connection2->prepare($sqlTerm);
            $resultTerm->execute($dataTerm);
        } catch (PDOException $e) {
            $output .= "<div class='error'>" . $e->getMessage() . "</div>";
        }
        $weekStart = date("Y-m-d", $startDayStamp + 86400 * 0);
        $weekEnd = date("Y-m-d", $startDayStamp + 86400 * 6);
        while ($rowTerm = $resultTerm->fetch()) {
            if ($weekStart <= $rowTerm["firstDay"] and $weekEnd >= $rowTerm["firstDay"]) {
                $isWeekInTerm = TRUE;
            } else {
                if ($weekStart >= $rowTerm["firstDay"] and $weekEnd <= $rowTerm["lastDay"]) {
                    $isWeekInTerm = TRUE;
                } else {
                    if ($weekStart <= $rowTerm["lastDay"] and $weekEnd >= $rowTerm["lastDay"]) {
                        $isWeekInTerm = TRUE;
                    }
                }
            }
        }
        if ($isWeekInTerm == TRUE) {
            $blank = FALSE;
        }
        //Run through days of the week
        $dayOfWeek = "";
        for ($d = 0; $d < 7; $d++) {
            $day = "";
            if ($d == 0) {
                $dayOfWeek = "Mon";
            } else {
                if ($d == 1) {
                    $dayOfWeek = "Tue";
                } else {
                    if ($d == 2) {
                        $dayOfWeek = "Wed";
                    } else {
                        if ($d == 3) {
                            $dayOfWeek = "Thu";
                        } else {
                            if ($d == 4) {
                                $dayOfWeek = "Fri";
                            } else {
                                if ($d == 5) {
                                    $dayOfWeek = "Sat";
                                } else {
                                    if ($d == 6) {
                                        $dayOfWeek = "Sun";
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if ($days[$dayOfWeek] == "Y") {
                //Check to see if day is term time
                $isDayInTerm = FALSE;
                try {
                    $dataTerm = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"]);
                    $sqlTerm = "SELECT gibbonSchoolYearTerm.firstDay, gibbonSchoolYearTerm.lastDay FROM gibbonSchoolYearTerm, gibbonSchoolYear WHERE gibbonSchoolYearTerm.gibbonSchoolYearID=gibbonSchoolYear.gibbonSchoolYearID AND gibbonSchoolYear.gibbonSchoolYearID=:gibbonSchoolYearID";
                    $resultTerm = $connection2->prepare($sqlTerm);
                    $resultTerm->execute($dataTerm);
                } catch (PDOException $e) {
                    $output .= "<div class='error'>" . $e->getMessage() . "</div>";
                }
                while ($rowTerm = $resultTerm->fetch()) {
                    if (date("Y-m-d", $startDayStamp + 86400 * $count) >= $rowTerm["firstDay"] and date("Y-m-d", $startDayStamp + 86400 * $count) <= $rowTerm["lastDay"]) {
                        $isDayInTerm = TRUE;
                    }
                }
                if ($isDayInTerm == TRUE) {
                    //Check for school closure day
                    try {
                        $dataClosure = array("date" => date("Y-m-d", $startDayStamp + 86400 * $count));
                        $sqlClosure = "SELECT * FROM gibbonSchoolYearSpecialDay WHERE date=:date";
                        $resultClosure = $connection2->prepare($sqlClosure);
                        $resultClosure->execute($dataClosure);
                    } catch (PDOException $e) {
                        $output .= "<div class='error'>" . $e->getMessage() . "</div>";
                    }
                    if ($resultClosure->rowCount() == 1) {
                        $rowClosure = $resultClosure->fetch();
                        if ($rowClosure["type"] == "School Closure") {
                            $day .= "<td style='text-align: center; vertical-align: top; font-size: 11px'>";
                            $day .= "<div style='position: relative'>";
                            $day .= "<div class='ttClosure' style='z-index: {$zCount}; position: absolute; width: {$width} ; height: " . ceil($diffTime / 60) . "px; margin: 0px; padding: 0px; opacity: {$ttAlpha}'>";
                            $day .= "<div style='position: relative; top: 50%'>";
                            $day .= "<span>" . $rowClosure["name"] . "</span>";
                            $day .= "</div>";
                            $day .= "</div>";
                            $day .= "</div>";
                            $day .= "</td>";
                        } else {
                            if ($rowClosure["type"] == "Timing Change") {
                                $day = renderTTSpaceDay($guid, $connection2, $row["gibbonTTID"], $startDayStamp, $count, $daysInWeek, $gibbonSpaceID, $timeStart, $diffTime, $eventsSpaceBooking, $rowClosure["schoolStart"], $rowClosure["schoolEnd"]);
                            }
                        }
                    } else {
                        $day = renderTTSpaceDay($guid, $connection2, $row["gibbonTTID"], $startDayStamp, $count, $daysInWeek, $gibbonSpaceID, $timeStart, $diffTime, $eventsSpaceBooking);
                    }
                } else {
                    $day .= "<td style='text-align: center; vertical-align: top; font-size: 11px'>";
                    $day .= "<div style='position: relative'>";
                    $day .= "<div class='ttClosure' style='z-index: {$zCount}; position: absolute; top: {$top}; width: {$width}; height: " . ceil($diffTime / 60) . "px; margin: 0px; padding: 0px; opacity: {$ttAlpha}'>";
                    $day .= "<div style='position: relative; top: 50%'>";
                    $day .= "<span style='color: rgba(255,0,0,{$ttAlpha});'>" . _('School Closed') . "</span>";
                    $day .= "</div>";
                    $day .= "</div>";
                    $day .= "</div>";
                    $day .= "</td>";
                }
                if ($day == "") {
                    $day .= "<td style='text-align: center; vertical-align: top; font-size: 11px'></td>";
                }
                $output .= $day;
                $count++;
            }
        }
        $output .= "</tr>";
        $output .= "</table>";
    }
    return $output;
}
コード例 #5
0
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>&nbsp;</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>&nbsp;</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 = "&nbsp;";
        }
        $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;
}
コード例 #6
0
function cal3($month, $year)
{
    global $weekstarts;
    if (!isset($weekstarts)) {
        $weekstarts = 0;
    }
    $s = "";
    $daysInMonth = getDaysInMonth($month, $year);
    $date = mktime(12, 0, 0, $month, 1, $year);
    $first = (strftime("%w", $date) + 7 - $weekstarts) % 7;
    $monthName = utf8_strftime("%B", $date);
    $s .= "<table class=\"calendar2\" border=\"1\" cellspacing=\"2\">\n";
    $s .= "<tr>\n";
    $s .= "<td class=\"calendarHeader2\" colspan=\"8\">{$monthName}&nbsp;{$year}</td>\n";
    $s .= "</tr>\n";
    $d = 1 - $first;
    $is_ligne1 = 'y';
    while ($d <= $daysInMonth) {
        $s .= "<tr>\n";
        for ($i = 0; $i < 7; $i++) {
            $basetime = mktime(12, 0, 0, 6, 11 + $weekstarts, 2000);
            $show = $basetime + $i * 24 * 60 * 60;
            $nameday = utf8_strftime('%A', $show);
            $temp = mktime(0, 0, 0, $month, $d, $year);
            if ($i == 0) {
                $s .= "<td class=\"calendar2\" style=\"vertical-align:bottom;\"><b>S" . getWeekNumber($temp) . "</b></td>\n";
            }
            if ($d > 0 && $d <= $daysInMonth) {
                $temp = mktime(0, 0, 0, $month, $d, $year);
                $day = grr_sql_query1("SELECT day FROM " . TABLE_PREFIX . "_calendrier_jours_cycle WHERE day='{$temp}'");
                $jour = grr_sql_query1("SELECT Jours FROM " . TABLE_PREFIX . "_calendrier_jours_cycle WHERE DAY='{$temp}'");
                if (intval($jour) > 0) {
                    $alt = get_vocab('jour_cycle') . " " . $jour;
                    $jour = ucfirst(substr(get_vocab("rep_type_6"), 0, 1)) . $jour;
                } else {
                    $alt = get_vocab('jour_cycle') . ' ' . $jour;
                    if (strlen($jour) > 5) {
                        $jour = substr($jour, 0, 3) . "..";
                    }
                }
                if (!isset($_GET["pview"])) {
                    if ($day < 0) {
                        $s .= "<td class=\"calendar2\" valign=\"top\" style=\"background-color:#FF8585\">";
                    } else {
                        $s .= "<td class=\"calendar2\" valign=\"top\" style=\"background-color:#C0FF82\">";
                    }
                } else {
                    $s .= "<td style=\"text-align:center;\" valign=\"top\">";
                }
                if ($is_ligne1 == 'y') {
                    $s .= '<b>' . ucfirst(substr($nameday, 0, 1)) . '</b><br />';
                }
                $s .= "<b>" . $d . "</b>";
                // Pour aller checher la date ainsi que son Jour cycle
                $s .= "<br />";
                if (isset($_GET["pview"])) {
                    if ($day < 0) {
                        $s .= "<img src=\"../img_grr/stop.png\" class=\"image\" width=\"16\" height=\"16\" alt=\"no\"/>";
                    } else {
                        $s .= "<span class=\"jour-cycle\">" . $jour . "</span>";
                    }
                } else {
                    if ($day < 0) {
                        $s .= "<a href=\"admin_calend_jour_cycle.php?page_calend=3&amp;date=" . $temp . "\"><img src=\"../img_grr/stop.png\" class=\"image\" alt=\"(aucun)\"  width=\"16\" height=\"16\" /></a>";
                    } else {
                        $s .= "<a class=\"jour-cycle\" href=\"admin_calend_jour_cycle.php?page_calend=3&amp;date=" . $temp . "\" title=\"" . $alt . "\" >" . $jour . "</a>";
                    }
                }
            } else {
                if (!isset($_GET["pview"])) {
                    $s .= "<td class=\"calendar2\" valign=\"top\">";
                } else {
                    $s .= "<td style=\"text-align:center;\" valign=\"top\">";
                }
                if ($is_ligne1 == 'y') {
                    $s .= '<b>' . ucfirst(substr($nameday, 0, 1)) . '</b><br />';
                }
                $s .= "&nbsp;";
            }
            $s .= "</td>\n";
            $d++;
        }
        $s .= "</tr>\n";
        $is_ligne1 = 'n';
    }
    $s .= "</table>\n";
    return $s;
}
コード例 #7
0
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>&nbsp;</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;
}
コード例 #8
0
/**
 * 祝日テーブルを作成
 * @param	int $year  西暦年(計算開始年)
 * @return	string 祝日の名称/FALSE=祝日ではない
*/
function getHoliday($year)
{
    static $youbi = array('日', '月', '火', '水', '木', '金', '土', '日');
    if ($year == FALSE) {
        return '';
    }
    $holidays = array();
    $flag = FALSE;
    //Google Calendar APIを使って祝日を取得
    for ($yyyy = $year; $yyyy < $year + 3; $yyyy++) {
        $n = getHoliday_by_Google($yyyy, $holidays);
        if ($n > 0) {
            $flag = TRUE;
        }
        if (!$flag) {
            break;
        }
    }
    if ($flag) {
        $msg = "<table border=\"1\">\n";
        for ($yyyy = $year; $yyyy < $year + 3; $yyyy++) {
            $cnt = 1;
            $msg .= sprintf("<tr><td colspan=\"3\">%04d年</td></tr>\n", $yyyy);
            for ($month = 1; $month <= 12; $month++) {
                $day_of_month = getDaysInMonth($yyyy, $month);
                for ($day = 1; $day <= $day_of_month; $day++) {
                    $key = sprintf("%04d-%02d-%02d", $year, $month, $day);
                    $name = isset($holidays[$key]) ? $holidays[$key] : FALSE;
                    $ww = getWeekNumber($yyyy, $month, $day);
                    if ($name != FALSE) {
                        $msg .= sprintf("<tr><td>%02d</td><td>%02d月%02d日(%s)</td><td>%s</td></tr>\n", $cnt, $month, $day, $youbi[$ww], $name);
                        $cnt++;
                    }
                }
            }
        }
        $msg .= "</table>\n";
    } else {
        $msg = 'error > Google Calendar APIから祝日を取得できません.';
    }
    return $msg;
}
コード例 #9
0
 /**
  * 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]&nbsp;&nbsp;</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'>&nbsp;</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;
 }
コード例 #10
0
function getTodayWeekNumber()
{
    return getWeekNumber(date("d"), date("m"), date("Y"));
}