public function getDay() { require_once 'Calendar/Day.php'; $oDay = new Calendar_Day($this->int_year, $this->int_month, $this->int_day); $oDay->build(); return $oDay; }
function build($events = array()) { /*include_once CALENDAR_ROOT . 'Day.php'; include_once CALENDAR_ROOT . 'Table/Helper.php'; $this->tableHelper = new Calendar_Table_Helper($this, $this->firstDay); $this->cE = & $this->getEngine(); $this->year = $this->thisYear(); $this->month = $this->thisMonth(); */ // require_once CALENDAR_ROOT.'Day.php'; include_once CALENDAR_ROOT . 'Table/Helper.php'; $this->tableHelper = new Calendar_Table_Helper($this, $this->firstDay); $this->cE =& $this->getEngine(); $this->year = $this->cE->stampToYear($this->calendar->thisWeek); $this->month = $this->cE->stampToMonth($this->calendar->thisWeek); $this->day = $this->cE->stampToDay($this->calendar->thisWeek); $end = $this->cE->getDaysInWeek($this->year, $this->month, $this->day); /* $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); for ($i=1; $i<=$daysInMonth; $i++) { $Day = new Calendar_Day(2000,1,1); // Create Day with dummy values $Day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $i)); $this->children[$i] = new Event($Day); } */ for ($i = 1; $i <= $end; $i++) { $Day = new Calendar_Day(2000, 1, 1); // Create Day with dummy values $Day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $this->day++)); $this->children[$i] = new Event($Day); /* $stamp = $this->cE->dateToStamp($year, $month, $day++); $this->children[$i] = new Calendar_Day( $this->cE->stampToYear($stamp), $this->cE->stampToMonth($stamp), $this->cE->stampToDay($stamp)); */ } $this->calendar->children = $this->children; if (count($events) > 0) { $this->setSelection($events); } //set empty days (@see Calendar_Month_Weeks::build()) if ($this->calendar->firstWeek) { $eBefore = $this->tableHelper->getEmptyDaysBefore(); for ($i = 1; $i <= $eBefore; $i++) { $this->children[$i]->setEmpty(); } } if ($this->calendar->lastWeek) { $eAfter = $this->tableHelper->getEmptyDaysAfterOffset(); for ($i = $eAfter + 1; $i <= $end; $i++) { $this->children[$i]->setEmpty(); } } return true; }
function build($events = array()) { require_once CALENDAR_ROOT . 'Day.php'; require_once CALENDAR_ROOT . 'Table/Helper.php'; $this->tableHelper =& new Calendar_Table_Helper($this, $this->firstDay); $this->cE =& $this->getEngine(); $this->year = $this->thisYear(); $this->month = $this->thisMonth(); $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); for ($i = 1; $i <= $daysInMonth; $i++) { $Day = new Calendar_Day(2000, 1, 1); // Create Day with dummy values $Day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $i)); $this->children[$i] = new DiaryEvent($Day); } if (count($events) > 0) { $this->setSelection($events); } Calendar_Month_Weekdays::buildEmptyDaysBefore(); Calendar_Month_Weekdays::shiftDays(); Calendar_Month_Weekdays::buildEmptyDaysAfter(); Calendar_Month_Weekdays::setWeekMarkers(); return true; }
/** * Appends empty days after the real days in the month * @return void * @access private */ function buildEmptyDaysAfter() { $eAfter = $this->tableHelper->getEmptyDaysAfter(); $sDOM = $this->tableHelper->getNumTableDaysInMonth(); for ($i = 1; $i <= $sDOM - $eAfter; $i++) { $Day = new Calendar_Day($this->year, $this->month + 1, $i); $Day->setEmpty(); $Day->adjust(); array_push($this->children, $Day); } }
/** * Returns the next weekday * @param string (default = 'int') return value format * @return int numeric day of week or timestamp * @access public */ function nextWeekDay($format = 'int') { $ts = $this->calendar->nextDay('timestamp'); $Day = new Calendar_Day(2000, 1, 1); $Day->setTimeStamp($ts); $day = $this->calendar->cE->getDayOfWeek($Day->thisYear(), $Day->thisMonth(), $Day->thisDay()); $day = $this->adjustWeekScale($day); return $this->returnValue('Day', $format, $ts, $day); }
require_once "inx/global.inc.php"; // calendar stuff require_once WS_PATH_COMPONENTS . '/Calendar/Calendar.php'; require_once WS_PATH_COMPONENTS . '/Calendar/Month/Weekdays.php'; require_once WS_PATH_COMPONENTS . '/Calendar/Day.php'; if (!isset($_GET['y'])) { $_GET['y'] = date('Y'); } if (!isset($_GET['m'])) { $_GET['m'] = date('m'); } if (!isset($_GET['d'])) { $_GET['d'] = date('d'); } $Month = new Calendar_Month_Weekdays($_GET['y'], $_GET['m']); $Day = new Calendar_Day($_GET['y'], $_GET['m'], $_GET['d']); $selection = array($Day); // get first second of the day $daybegin = strtotime($_GET['y'] . '/' . $_GET['m'] . '/' . $_GET['d'] . ' 00:00:00'); // add $default_workingday_start hours $daybegin = $daybegin + $default_workingday_start * 60 * 60; $endhour = $default_workingday_end - $default_workingday_start + 1; $dayend = $daybegin + $endhour * 60 * 60; if ($_GET['do'] == "zoom") { $_SESSION['zoom'] = $_GET['zoom']; } if (!$_SESSION['zoom']) { $zoom = $default_calendar_zoom; } else { $zoom = $_SESSION['zoom']; }
if (isset($_POST['update'])) { $Second =& new Calendar_Second($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h'], $_POST['i'], $_POST['s']); if (!$Second->isValid()) { $V =& $Second->getValidator(); echo '<p>Validation failed:</p>'; while ($error = $V->fetch()) { echo $error->toString() . '<br>'; } } else { echo '<p>Validation success.</p>'; echo '<p>New timestamp is: ' . $Second->getTimeStamp() . ' which could be used to update a database, for example'; } } else { $Year = new Calendar_Year($_POST['y']); $Month = new Calendar_Month($_POST['y'], $_POST['m']); $Day = new Calendar_Day($_POST['y'], $_POST['m'], $_POST['d']); $Hour = new Calendar_Hour($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h']); $Minute = new Calendar_Minute($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h'], $_POST['i']); $Second = new Calendar_Second($_POST['y'], $_POST['m'], $_POST['d'], $_POST['h'], $_POST['i'], $_POST['s']); ?> <p><b>Set the alarm clock</p></p> <form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"> Year: <input type="text" name="y" value="<?php echo $_POST['y']; ?> " size="4"> Month:<select name="m"> <?php
/** * setSelection * * @access public * @return void */ public function setSelection() { $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); for ($i = 1; $i <= $daysInMonth; $i++) { $day = new Calendar_Day(2000, 1, 1); // Create Day with dummy values $day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $i)); $this->children[$i] = new TimetableEvent($day); $stamp1 = $this->cE->dateToStamp($this->year, $this->month, $i); $stamp2 = $this->cE->dateToStamp($this->year, $this->month, $i + 1); foreach ($this->timetable->events as $event) { if ($stamp1 >= $event['start'] && $stamp1 < $event['end'] || $stamp2 > $event['start'] && $stamp2 <= $event['end'] || $stamp1 <= $event['start'] && $stamp2 >= $event['end']) { $this->children[$i]->addEntry($event); $this->children[$i]->setSelected(); } } } Calendar_Month_Weekdays::buildEmptyDaysBefore(); Calendar_Month_Weekdays::shiftDays(); Calendar_Month_Weekdays::buildEmptyDaysAfter(); Calendar_Month_Weekdays::setWeekMarkers(); }
/** * Returns a set of links to navigate the different calendar views * * @param string current_view Name of the current view * @return string */ public function viewLinks($current_view) { if (!$this->calendar->schedule->id) { return null; } $no_follow = PHPWS_Settings::get('calendar', 'no_follow'); $vars = PHPWS_Text::getGetValues(); unset($vars['module']); // if ($current_view == 'grid') { // $vars['date'] = $this->calendar->today; // } if (isset($_REQUEST['m']) && isset($_REQUEST['y']) && isset($_REQUEST['d'])) { $vars['date'] = mktime(0, 0, 0, $_REQUEST['m'], $_REQUEST['d'], $_REQUEST['y']); unset($vars['m']); unset($vars['d']); unset($vars['y']); } $links['today'] = $this->todayLink($current_view); if ($current_view == 'event') { $vars['date'] = $this->event->start_time; } if (isset($this->calendar->schedule)) { $vars['sch_id'] = $this->calendar->schedule->id; } // Get the values for the left and right arrows in a month view if ($current_view == 'list' || $current_view == 'grid') { $oMonth = $this->calendar->getMonth(); $left_arrow_time = $oMonth->prevMonth('timestamp'); $right_arrow_time = $oMonth->nextMonth('timestamp'); $left_link_title = dgettext('calendar', 'Previous month'); $right_link_title = dgettext('calendar', 'Next month'); } if ($current_view == 'grid') { //$links['GRID'] = dgettext('calendar', 'Grid'); } else { $vars['view'] = 'grid'; $glink = new PHPWS_Link(dgettext('calendar', 'Month Grid'), 'calendar', $vars); $glink->setNoFollow($no_follow); $glink->addClass('btn btn-default'); $links['GRID'] = $glink->get(); } if ($current_view == 'list') { //$links['LIST'] = dgettext('calendar', 'Month'); } else { $vars['view'] = 'list'; $glink = new PHPWS_Link(dgettext('calendar', 'Month list'), 'calendar', $vars); $glink->addClass('btn btn-default'); $glink->setNoFollow($no_follow); $links['LIST'] = $glink->get(); } if ($current_view == 'week') { require_once 'Calendar/Week.php'; $oWeek = $this->calendar->getWeek(); $left_arrow_time = $oWeek->prevWeek('timestamp'); $right_arrow_time = $oWeek->nextWeek('timestamp'); $left_link_title = dgettext('calendar', 'Previous week'); $right_link_title = dgettext('calendar', 'Next week'); } else { $vars['view'] = 'week'; $wlink = new PHPWS_Link(dgettext('calendar', 'Week'), 'calendar', $vars); $wlink->setNoFollow($no_follow); $wlink->addClass('btn btn-default'); $links['WEEK'] = $wlink->get(); } if ($current_view == 'day') { require_once 'Calendar/Day.php'; $oDay = new Calendar_Day($this->calendar->int_year, $this->calendar->int_month, $this->calendar->int_day); $left_arrow_time = $oDay->prevDay('timestamp'); $right_arrow_time = $oDay->nextDay('timestamp'); $left_link_title = dgettext('calendar', 'Previous day'); $right_link_title = dgettext('calendar', 'Next day'); $links['DAY_LINK'] = dgettext('calendar', 'Day'); } else { $vars['view'] = 'day'; $dlink = new PHPWS_Link(dgettext('calendar', 'Day'), 'calendar', $vars); $dlink->addClass('btn btn-default'); $dlink->setNoFollow($no_follow); $links['DAY_LINK'] = $dlink->get(); } $vars['view'] = $current_view; if (!empty($left_arrow_time)) { $vars['date'] = $left_arrow_time; $larrow = new PHPWS_Link('<i class="fa fa-chevron-left"></i> ', 'calendar', $vars); $larrow->addClass('btn btn-default'); $larrow->setTitle($left_link_title); $larrow->setNoFollow($no_follow); $links['LEFT_ARROW'] = $larrow->get(); } if (!empty($right_arrow_time)) { $vars['date'] = $right_arrow_time; $rarrow = new PHPWS_Link(' <i class="fa fa-chevron-right"></i>', 'calendar', $vars); $rarrow->addClass('btn btn-default'); $rarrow->setTitle($right_link_title); $rarrow->setNoFollow($no_follow); $links['RIGHT_ARROW'] = $rarrow->get(); } return $links; }
function testDay() { $Unit = new Calendar_Day(2000, 12, 32); $Validator =& $Unit->getValidator(); $this->assertFalse($Validator->isValidDay()); }
} if ($_GET["do"] == "zoom") { $_SESSION["zoom"] = $_GET["zoom"]; } if (!isset($to_pass['y'])) { $to_pass['y'] = date('Y'); } if (!isset($to_pass['m'])) { $to_pass['m'] = date('n'); } if (!isset($to_pass['d'])) { $to_pass['d'] = date('j'); } $today = $to_pass['y'] . '/' . $to_pass['m'] . '/' . $to_pass['d']; $Month = new Calendar_Month_Weekdays($to_pass['y'], $to_pass['m']); $Day = new Calendar_Day($to_pass['y'], $to_pass['m'], $to_pass['d']); $currentDateShown = strtotime($to_pass['y'] . '-' . $to_pass['m'] . '-' . $to_pass['d']); $Yesterday = array('d' => date('d', $Day->prevDay($currentDateShown)), 'm' => date('m', $Day->prevDay($currentDateShown)), 'y' => date('Y', $Day->prevDay($currentDateShown))); $Tomorrow = array('d' => date('d', $Day->nextDay($currentDateShown)), 'm' => date('m', $Day->nextDay($currentDateShown)), 'y' => date('Y', $Day->nextDay($currentDateShown))); $selection = array($Day); $ThisMonth = date("F"); // go to next year if current month is dec if ($Month->thisMonth() == 12) { $navNextYear = $Month->nextYear(); } else { $navNextYear = $Month->thisYear(); } if ($Month->thisMonth() == 1) { $navPrevYear = $Month->prevYear(); } else { $navPrevYear = $Month->thisYear();
function calendar_user_day() { $data = xarMod::apiFunc('calendar', 'user', 'getUserDateTimeInfo'); $DayEvents = new Calendar_Day($data['cal_year'], $data['cal_month'], $data['cal_day'], CALENDAR_FIRST_DAY_OF_WEEK); $args = array('day' => &$Day); $day_endts = $DayEvents->getTimestamp() + xarModVars::get('calendar', 'day_end') + 3600; // $events = xarMod::apiFunc('icalendar','user','getevents',$args); // get all the events. need to improve this query $xartable = xarDB::getTables(); $q = new Query('SELECT', $xartable['calendar_event']); // $q->qecho(); if (!$q->run()) { return; } $events = $q->output(); // Do some calculations to complete the entries' info $slots = array(); // Loop through the events $eventcount = count($events); for ($j = 0; $j < $eventcount; $j++) { // make sure events don't go past the end of the day $events[$j]['end_time'] = min($events[$j]['end_time'], $day_endts); $placed = false; $slotcount = count($slots); for ($i = 0; $i < $slotcount; $i++) { if ($events[$j]['start_time'] >= $slots[$i][1]) { foreach ($slots as $slot) { $events[$slot[0]]['neighbors'] = $slotcount; } $thisslot = $i; $slots = array(0 => array($j, $events[$j]['end_time'])); $placed = true; break; } } if (!$placed) { $thisslot = $slotcount; $slots[] = array($j, $events[$j]['end_time']); } $events[$j]['place'] = $thisslot; } foreach ($slots as $slot) { $events[$slot[0]]['neighbors'] = $slotcount; } //foreach($events as $event) {var_dump($event);echo "<br />";} /* $selection = array(); foreach ( $entries as $entry ) { $Hour = new Calendar_Hour(2000,1,1,1); $Hour->setTimeStamp($entry['start_time']); // Create the decorator, passing it the Hour $event = new Event($Hour); // Attach the payload $event->setEntry($entry); // Add the decorator to the selection $selection[] = $event; } */ $DayDecorator = new DayEvent_Decorator($DayEvents); $DayDecorator->build($events); $data['Day'] =& $DayDecorator; $data['cal_sdow'] = CALENDAR_FIRST_DAY_OF_WEEK; return $data; }
/** * Print a tabular calendar for selecting dates for appointments * Based on code from the PEAR package * * @link http://pear.php.net/package/Calendar PEAR Calendar * @link http://pearcalendar.sourceforge.net/examples/3.php Example this code based on * * @see make_appointment() * @see display_time() * * @param int $respondent_id The respondent id * @param int $questionnaire_id The questionnaire id * @param bool|int $day the day of the month if selected else false * @param bool|int $month the month of the year if selected else false * @param bool|int $year the year (4 digit) if selected else false * */ function display_calendar($respondent_id, $questionnaire_id, $year = false, $month = false, $day = false) { global $db; /** * PEAR Caldendar Weekday functions */ include_once 'Calendar/Month/Weekdays.php'; /** * PEAR Caldendar Day functions */ include_once 'Calendar/Day.php'; /** * See if questionnaire has shift restrictions */ $restricted = is_shift_restricted($questionnaire_id); $rtime = strtotime(get_respondent_time($respondent_id)); $y = date('Y', $rtime); $m = date('m', $rtime); $d = date('d', $rtime); if (!$year) { $year = $y; } if (!$month) { $month = $m; } if (!$day) { $day = $d; } $ttoday = new Calendar_Day($y, $m, $d); $Month = new Calendar_Month_Weekdays($year, $month); // Construct strings for next/previous links $PMonth = $Month->prevMonth('object'); // Get previous month as object $prev = '?y=' . $PMonth->thisYear() . '&m=' . $PMonth->thisMonth() . '&d=' . $PMonth->thisDay() . '&respondent_id=' . $respondent_id; $NMonth = $Month->nextMonth('object'); $next = '?y=' . $NMonth->thisYear() . '&m=' . $NMonth->thisMonth() . '&d=' . $NMonth->thisDay() . '&respondent_id=' . $respondent_id; // Build the days in the month $Month->build(); print "<table class=\"calendar table-hover table-condensed text-center\">"; print "<caption class=\"text-center text-primary\"><b>" . T_(date('F Y', $Month->getTimeStamp())) . "</b></caption>\r\n\t\t\t\t<thead style=\"font-weight: bolder;\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Mon") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Tue") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Wed") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Thu") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Fri") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Sat") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Sun") . "</td>\r\n\t\t\t\t</tr></thead>"; while ($Day = $Month->fetch()) { // Build a link string for each day $link = '?y=' . $Day->thisYear() . '&m=' . $Day->thisMonth() . '&d=' . $Day->thisDay() . '&respondent_id=' . $respondent_id; $today = ""; if ($year == $Day->thisYear() && $month == $Day->thisMonth() && $day == $Day->thisDay()) { $today = "today"; } // isFirst() to find start of week if ($Day->isFirst()) { echo "<tr>\n"; } if ($Day->isSelected()) { echo "<td class=\"selected {$today}\">" . $Day->thisDay() . "</td>\n"; } else { if ($Day->isEmpty()) { echo "<td> </td>\n"; } else { //if it is in the past -> unavailable if ($Day->getTimeStamp() < $ttoday->getTimeStamp()) { echo "<td style=\"color:grey;\" class=\"notavailable\">" . $Day->thisDay() . "</td>\n"; } else { if ($restricted) { $rs = $db->Execute(" SELECT s.shift_id\r\n\t\t\t\t\t\tFROM shift as s\r\n\t\t\t\t\t\tLEFT JOIN respondent as r on (r.respondent_id = '{$respondent_id}')\r\n\t\t\t\t\t\tWHERE s.questionnaire_id = '{$questionnaire_id}'\r\n\t\t\t\t\t\tAND DAY(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisDay()}'\r\n\t\t\t\t\t\tAND MONTH(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisMonth()}'\r\n\t\t\t\t\t\tAND YEAR(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisYear()}'"); if (!empty($rs) && $rs->RecordCount() == 0) { echo "<td style=\"color:grey;\" class=\"notavailable {$today}\">" . $Day->thisDay() . "</td>\n"; } else { echo "<td class=\"{$today}\"><a class=\"btn-primary btn-block \" href=\"" . $link . "\"><b>" . $Day->thisDay() . "</b></a></td>\n"; } } else { echo "<td class=\"{$today}\"><a class=\"btn-primary btn-block \" href=\"" . $link . "\"><b>" . $Day->thisDay() . "</b></a></td>\n"; } } } } // isLast() to find end of week if ($Day->isLast()) { echo "</tr>\n"; } } ?> <tr> <td> <a href="<?php echo $prev; ?> " class="prevMonth btn btn-default"><< </a> </td> <td colspan="5"><?php print "<b class=\"text-primary\">" . date('l j F Y', mktime(0, 0, 0, $month, $day, $year)) . "</b>"; ?> </td> <td> <a href="<?php echo $next; ?> " class="nextMonth btn btn-default"> >></a> </td> </tr> </table> <?php }
if (!$event['event_isrecur']) { $eventsArray[] = $event; } else { $recurEvents = $eventHandler->getRecurEventToDisplay($event, $startDay, $endDay); foreach ($recurEvents as $recurEvent) { $eventsArray[] = $recurEvent; } } } // Formating date $eventHandler->formatEventsDate($eventsArray, $xoopsModuleConfig['event_date_day']); // Assigning events to the template $xoopsTpl->assign('events', $eventsArray); // Retriving categories $cats = $catHandler->objectToArray($catHandler->getAllCat($xoopsUser)); // Assigning categories to the template $xoopsTpl->assign('cats', $cats); // Making navig data $dayCalObj = new Calendar_Day($year, $month, $day); $pDayCalObj = $dayCalObj->prevDay('object'); $nDayCalObj = $dayCalObj->nextDay('object'); $navig = array('prev' => array('uri' => 'year=' . $pDayCalObj->thisYear() . '&month=' . $pDayCalObj->thisMonth() . '&day=' . $pDayCalObj->thisDay(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_day'], $pDayCalObj->getTimestamp())), 'this' => array('uri' => 'year=' . $dayCalObj->thisYear() . '&month=' . $dayCalObj->thisMonth() . '&day=' . $dayCalObj->thisDay(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_day'], $dayCalObj->getTimestamp())), 'next' => array('uri' => 'year=' . $nDayCalObj->thisYear() . '&month=' . $nDayCalObj->thisMonth() . '&day=' . $nDayCalObj->thisDay(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_day'], $nDayCalObj->getTimestamp()))); // Assigning navig data to the template $xoopsTpl->assign('navig', $navig); // Assigning current form navig data to the template $xoopsTpl->assign('selectedCat', $cat); $xoopsTpl->assign('year', $year); $xoopsTpl->assign('month', $month); $xoopsTpl->assign('day', $day); $xoopsTpl->assign('view', "day"); include XOOPS_ROOT_PATH . '/footer.php';