} require_once W2P_BASE_DIR . '/modules/calendar/links_events.php'; $html .= '</form>'; $html .= '<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">'; $rows = 0; for ($i = 0, $n = ($end - $start) * 60 / $inc; $i < $n; $i++) { $html .= '<tr>'; $tm = $this_day->format($tf); $html .= '<td width="1%" align="right" nowrap="nowrap">' . ($this_day->getMinute() ? $tm : '<b>' . $tm . '</b>') . '</td>'; $timeStamp = $this_day->format('%H%M%S'); if (isset($events2[$timeStamp])) { $count = count($events2[$timeStamp]); for ($j = 0; $j < $count; $j++) { $row = $events2[$timeStamp][$j]; $et = new CDate($row['event_end_date']); $rows = ($et->getHour() * 60 + $et->getMinute() - ($this_day->getHour() * 60 + $this_day->getMinute())) / $inc; $href = '?m=calendar&a=view&event_id=' . $row['event_id']; $alt = $row['event_description']; $html .= '<td class="event" rowspan="' . $rows . '" valign="top">'; $html .= '<table cellspacing="0" cellpadding="0" border="0"><tr>'; $html .= '<td>' . w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar'); $html .= '</td><td> <b>' . $AppUI->_($types[$row['event_type']]) . '</b></td></tr></table>'; $html .= w2PtoolTip($row['event_title'], getEventTooltip($row['event_id']), true); $html .= $href ? '<a href="' . $href . '" class="event">' : ''; $html .= $row['event_title']; $html .= $href ? '</a>' : ''; $html .= w2PendTip(); $html .= '</td>'; } } else { if (--$rows <= 0) {
public function calcFinish($durn, $durnType) { // since one will alter the date ($this) one better copies it to a new instance $f = new CDate(); $f->copy($this); // get w2P time constants $cal_day_start = intval(w2PgetConfig('cal_day_start')); $cal_day_end = intval(w2PgetConfig('cal_day_end')); $workHours = intval(w2PgetConfig('daily_working_hours')); $workingDays = w2PgetConfig('cal_working_days'); $working_days = explode(',', $workingDays); //temporary variables $inc = floor($durn); $hoursToAddToLastDay = 0; $hoursToAddToFirstDay = $durn; $fullWorkingDays = 0; $int_st_hour = $f->getHour(); //catch the gap between the working hours and the open hours (like lunch periods) $workGap = $cal_day_end - $cal_day_start - $workHours; // calculate the number of non-working days $k = 7 - count($working_days); $durnMins = ($durn - $inc) * 60; if ($f->getMinute() + $durnMins >= 60) { $inc++; } $mins = ($f->getMinute() + $durnMins) % 60; if ($mins > 38) { $f->setMinute(45); } elseif ($mins > 23) { $f->setMinute(30); } elseif ($mins > 8) { $f->setMinute(15); } else { $f->setMinute(0); } // jump over to the first working day for ($i = 0; $i < $k; $i++) { if (array_search($f->getDayOfWeek(), $working_days) === false) { $f->addDays(1); } } if ($durnType == 24) { if ($f->getHour() == $cal_day_start && $f->getMinute() == 0) { $fullWorkingDays = ceil($inc); $f->setMinute(0); } else { $fullWorkingDays = ceil($inc) + 1; } // Include start day as a working day (if it is one) if (!(array_search($f->getDayOfWeek(), $working_days) === false)) { $fullWorkingDays--; } for ($i = 0; $i < $fullWorkingDays; $i++) { $f->addDays(1); if (array_search($f->getDayOfWeek(), $working_days) === false) { $i--; } } if ($f->getHour() == $cal_day_start && $f->getMinute() == 0) { $f->setHour($cal_day_end); $f->setMinute(0); } } else { $hoursToAddToFirstDay = $inc; if ($f->getHour() + $inc > $cal_day_end - $workGap) { $hoursToAddToFirstDay = $cal_day_end - $workGap - $f->getHour(); } if ($hoursToAddToFirstDay > $workHours) { $hoursToAddToFirstDay = $workHours; } $inc -= $hoursToAddToFirstDay; $hoursToAddToLastDay = $inc % $workHours; $fullWorkingDays = floor(($inc - $hoursToAddToLastDay) / $workHours); if ($hoursToAddToLastDay <= 0 && !($hoursToAddToFirstDay == $workHours)) { $f->setHour($f->getHour() + $hoursToAddToFirstDay); } elseif ($hoursToAddToLastDay == 0) { $f->setHour($f->getHour() + $hoursToAddToFirstDay + $workGap); } else { $f->setHour($cal_day_start + $hoursToAddToLastDay); $f->addDays(1); } if (($f->getHour() == $cal_day_end || $f->getHour() - $int_st_hour == $workHours + $workGap) && $mins > 0) { $f->addDays(1); $f->setHour($cal_day_start); } // boolean for setting later if we just found a non-working day // and therefore do not have to add a day in the next loop // (which would have caused to not respecting multiple non-working days after each other) $g = false; for ($i = 0, $i_cmp = ceil($fullWorkingDays); $i < $i_cmp; $i++) { if (!$g) { $f->addHours(1); } $g = false; // calculate overriden non-working days if (array_search($f->getDayOfWeek(), $working_days) === false) { $f->addDays(1); $i--; $g = true; } } } // if there was no fullworkingday we have to check whether the end day is a working day // and in the negative case postpone the end date by appropriate days for ($i = 0, $i_cmp = 7 - count($working_days); $i < $i_cmp; $i++) { // override possible non-working enddays if (array_search($f->getDayOfWeek(), $working_days) === false) { $f->addDays(1); } } return $f; }
echo $start_date ? $start_date->format($df) : ""; ?> " class="text" disabled="disabled" /> <a href="#" onClick="popCalendar(document.datesFrm.start_date)"> <img src="./images/calendar.gif" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?> " border="0"> </a> </td> <td> <table><tr> <?php echo "<td>" . arraySelect($hours, "start_hour", 'size="1" onchange="setAMPM(this)" class="text"', $start_date ? $start_date->getHour() : $start) . "</td><td>" . " : " . "</td>"; echo "<td>" . arraySelect($minutes, "start_minute", 'size="1" class="text"', $start_date ? $start_date->getMinute() : "0") . "</td>"; if (stristr($AppUI->getPref('TIMEFORMAT'), "%p")) { echo '<td><input type="text" name="start_hour_ampm" id="start_hour_ampm" value="' . ($start_date ? $start_date->getAMPM() : ($start > 11 ? "pm" : "am")) . '" disabled="disabled" class="text" size="2" /></td>'; } ?> </tr></table> </td> </tr> <tr> <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Finish Date'); ?> </td> <td nowrap="nowrap"> <input type="hidden" name="task_end_date" id="task_end_date" value="<?php echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : '';
public function check() { // ensure changes to check boxes and select lists are honoured $this->event_private = intval($this->event_private); $this->event_type = intval($this->event_type); $this->event_cwd = intval($this->event_cwd); //If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date //so that the event starts recurring from the start day onwards n times after the start date for the period given //Meaning: The event end date day is useless as far as recurring events are concerned. if ($this->event_recurs) { $start_date = new CDate($this->event_start_date); $end_date = new CDate($this->event_end_date); $hour = $end_date->getHour(); $minute = $end_date->getMinute(); $end_date->setDate($start_date->getDate()); $end_date->setHour($hour); $end_date->setMinute($minute); $this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL); } return null; }
', 'datesFrm', null, true)" href="javascript: void(0);"> <img src="<?php echo w2PfindImage('calendar.gif'); ?> " width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?> " border="0" /> </a> </td> <td> <table><tr> <?php echo '<td>' . arraySelect($hours, 'start_hour', 'size="1" onchange="setAMPM(this)" class="text"', $start_date ? $start_date->getHour() : $start) . '</td><td> : </td>'; echo '<td>' . arraySelect($minutes, 'start_minute', 'size="1" class="text"', $start_date ? $start_date->getMinute() : '0') . '</td>'; if (stristr($AppUI->getPref('TIMEFORMAT'), '%p')) { echo '<td><input type="text" name="start_hour_ampm" id="start_hour_ampm" value="' . ($start_date ? $start_date->getAMPM() : ($start > 11 ? 'pm' : 'am')) . '" disabled="disabled" class="text" size="2" /></td>'; } ?> </tr></table> </td> </tr> <tr> <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Finish Date'); ?> </td> <td nowrap="nowrap"> <input type='hidden' id='task_end_date' name='task_end_date' value='<?php echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : '';