示例#1
0
$time = optional_param('time', time(), PARAM_INT);
$room_obj = $DB->get_record('roomscheduler_rooms', array('id' => $room));
/* CONTEXT AND SECURITY */
$coursecontext = get_context_instance(CONTEXT_COURSE, $course);
$courseobj = $DB->get_record('course', array('id' => $course));
$personalcontext = get_context_instance(CONTEXT_USER, $USER->id);
require_login();
/* HEADER */
$navlinks[] = array('name' => get_string('pluginname', 'block_roomscheduler'), 'link' => '/blocks/roomscheduler/rooms.php?course=' . $course, 'type' => 'misc');
$navlinks[] = array('name' => $room_obj->name, 'link' => '/blocks/roomscheduler/room.php?course=' . $course . '&room=' . $room_obj->id, 'type' => 'misc');
$navigation = build_navigation($navlinks);
$PAGE->set_course($courseobj);
$PAGE->set_url('/blocks/roomscheduler/room.php', array('course' => $course, 'room' => $room));
$PAGE->set_title(get_string('pluginname', 'block_roomscheduler') . ' - ' . $room_obj->name);
$PAGE->set_heading(get_string('pluginname', 'block_roomscheduler') . ' - ' . $room_obj->name);
$PAGE->requires->js('/blocks/roomscheduler/fancybox/jquery.min.js');
$PAGE->requires->js('/blocks/roomscheduler/fancybox/jquery.fancybox-1.3.1.pack.js');
$PAGE->requires->js('/blocks/roomscheduler/fancybox/roomscheduler.js');
$PAGE->requires->css('/blocks/roomscheduler/fancybox/jquery.fancybox-1.3.1.css');
$PAGE->requires->js('/blocks/roomscheduler/roomscheduler.js');
$PAGE->requires->css('/blocks/roomscheduler/style.css');
echo $OUTPUT->header();
/* CONTENT */
echo $OUTPUT->heading($room_obj->name);
echo '<div style="width:90%;margin-left:auto;margin-right:auto;">';
$cal = new calendar_day($room, $time, $course, 8, 17);
echo $cal;
$cal->render_apptForm();
echo '</div>';
/* FOOTER */
echo $OUTPUT->footer();
 /**
  * Renders the table into HTML markup.
  *
  * @return string $string HTML markup
  */
 public function __toString()
 {
     global $OUTPUT, $DB, $CFG, $USER, $PAGE;
     $context = get_context_instance(CONTEXT_COURSE, $this->course);
     $PAGE->set_context($context);
     $this->focus_time = $this->day;
     $string = '<div id="' . $this->get_instance() . '">';
     if ($this->show_toolbar) {
         $cal_style = 'width:70%;float:left;';
         $string .= '<table cellspacing="0" cellpadding="0" style="width:20%;float:left;">';
         //Mode picker
         $string .= '<tr><td style="margin:0;padding:0;">';
         $string .= '<div class="calendar_day" style="margin-right:10px;padding:0px;border:0;">';
         $string .= '<table style="width:100%;margin:0;padding:0;"><tr>';
         $string .= '<td class="calendar_side_picker" style="background-color:#DDDDDD;">' . get_string('day', 'block_roomscheduler') . '</td>';
         $string .= '<td class="calendar_side_picker" onclick="window.location.href=\'' . $CFG->wwwroot . '/blocks/roomscheduler/room_week.php?course=' . $this->course . '&room=' . $this->room . '&time=' . $this->focus_time . '\';">' . get_string('week', 'block_roomscheduler') . '</td>';
         $string .= '<td class="calendar_side_picker" onclick="window.location.href=\'' . $CFG->wwwroot . '/blocks/roomscheduler/room_calendar.php?course=' . $this->course . '&room=' . $this->room . '&time=' . $this->focus_time . '\';">' . get_string('month', 'block_roomscheduler') . '</td>';
         $string .= '</tr></table>';
         $string .= '</div></td></tr>';
         //Mini calendar picker
         $string .= '<tr><td style="margin:0;padding:0;">';
         $string .= '<div class="calendar_day" style="margin-right:10px;margin-top:10px;padding:5px;">';
         $string .= '<table style="font-size:10px;width:100%;">';
         //Month
         $string .= '<tr>';
         $string .= '<th style="font-align:left;">';
         $string .= $OUTPUT->pix_icon('t/left', '', 'moodle', array('class' => 'calendar_icon', 'onclick' => 'calendar_phpFunction(\'' . $this->get_instance() . '\',\'miniCal_previousMonth\',[]);'));
         $string .= '</th><th colspan="5">';
         $string .= strftime('%B %Y', $this->get_miniCal());
         $string .= '</th><th style="font-align:right;">';
         $string .= $OUTPUT->pix_icon('t/right', '', 'moodle', array('class' => 'calendar_icon', 'onclick' => 'calendar_phpFunction(\'' . $this->get_instance() . '\',\'miniCal_nextMonth\',[]);'));
         $string .= '</th>';
         $string .= '</tr>';
         //Days of week
         $sunday = strtotime('8/8/2010');
         //Use this as a reference point for sunday
         $string .= '<tr class="calendar_minical_daysofweek">';
         for ($day = 0; $day < 7; $day++) {
             $string .= '<th>' . strftime('%a', $sunday + 86400 * $day) . '</th>';
         }
         $string .= '</tr>';
         //Determine which day of the week is the first day of the month
         $month = date('n', $this->get_miniCal());
         $year = date('Y', $this->get_miniCal());
         $dayofweek_first = strftime_dayofweek_compatible(mktime(0, 0, 0, $month, 1, $year));
         $totaldays = date('t', mktime(0, 0, 0, $month, 1, $year));
         //Calculate offset, offset is dayofweek_first (except in the case of sunday)
         if ($dayofweek_first == 7) {
             $dayofweek_first = 0;
         }
         //Days
         $count = 1;
         for ($week = 1; $week <= 6; $week++) {
             $string .= '<tr>';
             for ($dayofweek = 0; $dayofweek < 7; $dayofweek++) {
                 //Beginning offset period
                 if ($dayofweek_first > 0) {
                     $dayofweek_first--;
                     $string .= '<td></td>';
                 } else {
                     if ($count > $totaldays) {
                         $string .= '<td></td>';
                     } else {
                         $daystamp = mktime(0, 0, 0, $month, $count, $year);
                         $string .= '<td style="text-align:right;" class="calendar_miniCal_day" onclick="calendar_phpFunction(\'' . $this->get_instance() . '\',\'set_day\',[\'' . $daystamp . '\']);">';
                         $string .= '<div ';
                         if ($month == date('n') && $count == date('j') && $year == date('Y')) {
                             if ($month == date('n', $this->get_day()) && $count == date('j', $this->get_day()) && $year == date('Y', $this->get_day())) {
                                 $string .= 'class="calendar_miniCal_todaySelected"';
                             } else {
                                 $string .= 'class="calendar_miniCal_today"';
                             }
                         } else {
                             if ($month == date('n', $this->get_day()) && $count == date('j', $this->get_day()) && $year == date('Y', $this->get_day())) {
                                 $string .= 'class="calendar_miniCal_selected"';
                             }
                         }
                         $string .= '>';
                         $string .= $count;
                         $string .= '</div></td>';
                         $count++;
                     }
                 }
             }
             $string .= '</tr>';
         }
         $string .= '</table>';
         $string .= '</div>';
         $string .= '</td></tr>';
         //Resources
         $room_obj = $DB->get_record('roomscheduler_rooms', array('id' => $this->room));
         if ($room_obj->resources != '') {
             $string .= '<tr><td style="margin:0;padding:0;">';
             $string .= '<div class="calendar_day" style="margin-right:10px;margin-top:10px;padding:5px;">';
             $resources = explode(',', $room_obj->resources);
             $string .= '<ul style="margin-top:0;margin-bottom:0;">';
             foreach ($resources as $resource) {
                 $resource = trim($resource);
                 $string .= '<li>' . $resource . '</li>';
             }
             $string .= '</ul>';
             $string .= '</div>';
             $string .= '</td></tr>';
         }
         //Other rooms picker
         $string .= '<tr><td style="margin:0;padding:0;">';
         $string .= '<div class="calendar_day" style="margin-right:10px;margin-top:10px;padding:5px;">';
         $rooms = $DB->get_records('roomscheduler_rooms', array('active' => 1), 'name ASC');
         $string .= '<select onchange="window.location.href=(this.options[this.selectedIndex].value);">';
         foreach ($rooms as $room) {
             $string .= '<option value="' . $CFG->wwwroot . '/blocks/roomscheduler/room.php?time=' . $this->focus_time . '&course=' . $this->course . '&room=' . $room->id . '"';
             if ($this->room == $room->id) {
                 $string .= 'SELECTED';
             }
             $string .= '>' . $room->name . '</option>';
         }
         $string .= '</select>';
         $string .= '</div>';
         $string .= '</td></tr>';
         $string .= '</table>';
     } else {
         $cal_style = 'width:100%;';
     }
     $string .= '<table class="calendar_day" style="' . $cal_style . '">';
     //Date
     $string .= '<tr><th colspan="3">';
     $string .= $OUTPUT->pix_icon('t/left', '', 'moodle', array('class' => 'calendar_icon', 'onclick' => 'calendar_phpFunction(\'' . $this->get_instance() . '\',\'previousDay\',[]);'));
     $string .= '&nbsp;&nbsp;';
     $string .= strftime('%B %d, %Y', $this->get_day());
     $string .= '&nbsp;&nbsp;';
     $string .= $OUTPUT->pix_icon('t/right', '', 'moodle', array('class' => 'calendar_icon', 'onclick' => 'calendar_phpFunction(\'' . $this->get_instance() . '\',\'nextDay\',[]);'));
     $string .= '</th></tr>';
     //Time picker
     $string .= '<tr><td colspan="3" style="font-size:10px;text-align:center;">';
     $string .= calendar_day::calendar_hourdropdown($this->get_startTime(), 'calendar_phpFunction(\'' . $this->get_instance() . '\',\'set_startTime\',[this.value]);');
     $string .= '&nbsp;&nbsp; - &nbsp;&nbsp;';
     $string .= calendar_day::calendar_hourdropdown($this->get_endTime(), 'calendar_phpFunction(\'' . $this->get_instance() . '\',\'set_endTime\',[this.value]);');
     $string .= '</td></tr>';
     if (has_capability('block/roomscheduler:reserve', $context) && isset($room_obj) && !$room_obj->reservable && !has_capability('block/roomscheduler:manage', $context)) {
         $string .= '<tr><th colspan="3">';
         $string .= '<font size="1" color="red">To book this book this room please contant:</font>' . $this->email_icon($room_obj);
         $string .= '</th></tr>';
     }
     //Day of week + day
     $string .= '<tr><th style="text-align:left;">';
     $string .= strftime('%A', $this->get_day());
     $string .= '</th><th></th><th style="text-align:right;">';
     $string .= strftime('%d', $this->get_day());
     $string .= '</th></tr>';
     $day = date('j', $this->get_day());
     $month = date('n', $this->get_day());
     $year = date('Y', $this->get_day());
     $block_counter = 1;
     //Count how many blocks are printed out
     for ($hour = $this->get_startTime(); $hour < $this->get_endTime(); $hour++) {
         $count = 1;
         for ($minute = 0; $minute < 60; $minute += 10) {
             if ($minute == 0) {
                 $minute = '00';
                 $string .= '<tr class="calendar_tophour">';
                 $string .= '<td rowspan="6" style="width:20%;" valign="top" id="calendar_time_' . $hour . '"></td>';
             } else {
                 $string .= '<tr>';
             }
             $timestamp = mktime($hour, $minute, 0, $month, $day, $year);
             if ($reservation = get_reservation_byTime($this->room, $timestamp)) {
                 $user = $DB->get_record('user', array('id' => $reservation->meetingorganizer));
                 //Set style of calendar event
                 if ($reservation->categories == '') {
                     $category = 'default';
                 } else {
                     $category = $reservation->categories;
                 }
                 //Top portion
                 if ($timestamp == $reservation->startdate || $block_counter == 1) {
                     $string .= '<td class="calendar_' . $category . '_top">';
                     $starttimedisplay = strftime('%H:%M', $reservation->startdate);
                     $endtimedisplay = strftime('%H:%M', $reservation->enddate);
                     if ($reservation->alldayevent == 1) {
                         $string .= '&nbsp;' . get_string('alldayevent', 'block_roomscheduler');
                         $string .= ' - ' . strftime('%h %d', $reservation->startdate);
                         $string .= '&nbsp;' . get_string('to', 'block_roomscheduler') . '&nbsp;';
                         $string .= strftime('%h %d', $reservation->enddate - 600);
                     } else {
                         $string .= '&nbsp;' . $starttimedisplay . ' - ' . $endtimedisplay;
                     }
                     $string .= ' : ' . $reservation->subject;
                     if (has_capability('block/roomscheduler:manage', $context) || $reservation->meetingorganizer == $USER->id) {
                         $string .= '&nbsp;&nbsp;<span style="font-weight:normal;"><a href="" onclick="calendar_removeAppt(\'' . $reservation->id . '\',\'' . get_string('reservationdelete', 'block_roomscheduler') . '\');">[' . get_string('remove', 'block_roomscheduler') . ']</a></span>';
                         $string .= '&nbsp;&nbsp;<span style="font-weight:normal;"><a href="#" onclick="calendar_editAppt(\'' . $reservation->id . '\',\'' . apptForm_edit::apptForm_formName() . '\', \'single\');">[' . get_string('edit', 'block_roomscheduler') . ']</a></span>';
                         if ($reservation->recurrence_id > 0) {
                             $string .= '&nbsp;&nbsp;<span style="font-weight:normal;"><a href="#" onclick="calendar_editAppt(\'' . $reservation->id . '\',\'' . apptForm_recursiveEdit::apptForm_formName() . '\', \'recursive\');">[' . get_string('editall', 'block_roomscheduler') . ']</a></span>';
                             $string .= '&nbsp;&nbsp;<span style="font-weight:normal;"><a href="" onclick="calendar_removeAppts(\'' . $reservation->id . '\',\'' . get_string('reservationdeletes', 'block_roomscheduler') . '\');">[' . get_string('removeall', 'block_roomscheduler') . ']</a></span>';
                         }
                     }
                     if ($reservation->confirm == 0) {
                         $string .= '&nbsp;&nbsp;&nbsp;<span style="font-weight:normal;">';
                         if (has_capability('block/roomscheduler:manage', $context)) {
                             //  $string .= '<a href="" onclick="calendar_confirmAppt(\'' . $reservation->id . '\',\'' . get_string('confirmconfirmation', 'block_roomscheduler') . '\');">';
                         }
                         // $string .= '['.get_string('unconfirmed','block_roomscheduler').']';
                         if (has_capability('block/roomscheduler:manage', $context)) {
                             //     $string .= '</a>';
                         }
                         $string .= '</span>';
                     }
                     if ($reservation->recurrence_id != 0 && $reservation->confirm == 0 && has_capability('block/roomscheduler:manage', $context)) {
                         //  $string .= '&nbsp;&nbsp;&nbsp;<span style="font-weight:normal;"><a href="" onclick="calendar_confirmAppts(\'' . $reservation->id . '\',\'' . get_string('confirmconfirmations', 'block_roomscheduler') . '\');">['.get_string('confirmall','block_roomscheduler').']</a></span>';
                     }
                     $string .= '</td>';
                     $block_counter++;
                 } else {
                     if ($timestamp == $reservation->enddate - 600) {
                         $string .= '<td class="calendar_' . $category . '_bottom">';
                         if ($block_counter == 2) {
                             $string .= '&nbsp;' . $reservation->description;
                         }
                         /*
                          else if($block_counter==3){
                          $string .= '&nbsp;'.$user->firstname.' '.$user->lastname;
                          }
                         *
                         */
                         $string .= '</td>';
                         $block_counter = 1;
                     } else {
                         $string .= '<td class="calendar_' . $category . '_middle">';
                         if ($block_counter == 2) {
                             $string .= '&nbsp;' . $reservation->description;
                         }
                         /*
                          else if($block_counter==3){
                          $string .= '&nbsp;'.$user->firstname.' '.$user->lastname;
                          }
                         *
                         */
                         $string .= '</td>';
                         $block_counter++;
                     }
                 }
             } else {
                 //blank row
                 $string .= '<td style="font-size:10px;"';
                 if (has_capability('block/roomscheduler:reserve', $context) && isset($room_obj) && $room_obj->reservable) {
                     $string .= ' onmousedown="calendar_startAppt(this);" onmouseover="hoverAppt(this);" onmouseup="calendar_endAppt(this);"';
                 } elseif (has_capability('block/roomscheduler:manage', $context)) {
                     $string .= ' onmousedown="calendar_startAppt(this);" onmouseover="hoverAppt(this);" onmouseup="calendar_endAppt(this);"';
                 }
                 $string .= ' id="' . $timestamp . '"></td>';
             }
             $string .= '<td style="width:10%;"></td></tr>';
             $count++;
         }
     }
     $string .= '</table>';
     $string .= '</div>';
     $string .= '</div>';
     $this->serialize();
     return $string;
 }
 /**
  * Renders the table into HTML markup.
  *
  * @return string $string HTML markup
  */
 public function __toString()
 {
     global $OUTPUT, $DB, $COURSE, $CFG, $USER, $PAGE;
     $context = get_context_instance(CONTEXT_COURSE, $this->course);
     $PAGE->set_context($context);
     $room_obj = $DB->get_record('roomscheduler_rooms', array('id' => $this->room));
     $string = '<div id="' . $this->get_instance() . '">';
     //Mode picker
     $string .= '<div class="calendar_day" style="margin-right:10px;padding:0px;border:0;width:20%;">';
     $string .= '<table style="width:100%;margin:0;padding:0;"><tr>';
     $string .= '<td class="calendar_side_picker" style="border-bottom:0;" onclick="window.location.href=\'' . $CFG->wwwroot . '/blocks/roomscheduler/room.php?course=' . $this->course . '&room=' . $this->room . '&time=' . $this->focus_time . '\';">' . get_string('day', 'block_roomscheduler') . '</td>';
     $string .= '<td class="calendar_side_picker" style="background-color:#DDDDDD;border-bottom:0;">' . get_string('week', 'block_roomscheduler') . '</td>';
     $string .= '<td class="calendar_side_picker" style="border-bottom:0;" onclick="window.location.href=\'' . $CFG->wwwroot . '/blocks/roomscheduler/room_calendar.php?course=' . $this->course . '&room=' . $this->room . '&time=' . $this->focus_time . '\';">' . get_string('month', 'block_roomscheduler') . '</td>';
     $string .= '</tr></table>';
     $string .= '</div>';
     $string .= '<table class="calendar_day" style="width:100%;">';
     //Date
     $string .= '<tr><th colspan="9">';
     $string .= $OUTPUT->pix_icon('t/left', '', 'moodle', array('class' => 'calendar_icon', 'onclick' => 'calendar_phpFunction(\'' . $this->get_instance() . '\',\'previousWeek\',[]);'));
     $string .= '&nbsp;&nbsp;';
     //Get Sunday of week
     $focus_dayofweek = strftime('%w', $this->get_focusTime());
     $sunday = $this->get_focusTime() - $focus_dayofweek * 86400;
     $difference_to_sat = 6 - $focus_dayofweek;
     $saturday = $this->get_focusTime() + $difference_to_sat * 86400;
     $string .= strftime('%B %d, %Y', $sunday);
     $string .= ' - ';
     $string .= strftime('%B %d, %Y', $saturday);
     $string .= '&nbsp;&nbsp;';
     $string .= $OUTPUT->pix_icon('t/right', '', 'moodle', array('class' => 'calendar_icon', 'onclick' => 'calendar_phpFunction(\'' . $this->get_instance() . '\',\'nextWeek\',[]);'));
     $string .= '</th></tr>';
     //Time picker
     $string .= '<tr><td colspan="9" style="font-size:10px;text-align:center;">';
     $string .= calendar_day::calendar_hourdropdown($this->get_startTime(), 'calendar_phpFunction(\'' . $this->get_instance() . '\',\'set_startTime\',[this.value]);');
     $string .= '&nbsp;&nbsp; - &nbsp;&nbsp;';
     $string .= calendar_day::calendar_hourdropdown($this->get_endTime(), 'calendar_phpFunction(\'' . $this->get_instance() . '\',\'set_endTime\',[this.value]);');
     $string .= '</td></tr>';
     if (has_capability('block/roomscheduler:reserve', $context) && isset($room_obj) && !$room_obj->reservable && !has_capability('block/roomscheduler:manage', $context)) {
         $string .= '<tr><th colspan="9">';
         $string .= '<font size="1" color="red">To book this book this room please contant:</font>' . $this->email_icon($room_obj);
         $string .= '</th></tr>';
     }
     //Days of week
     $string .= '<tr><th style="width:9%;"></th>';
     for ($i = 0; $i < 7; $i++) {
         $string .= '<th style="width:13%">' . strftime('%A', $sunday + $i * 86400) . '</th>';
     }
     $string .= '<td style="width:2%;"></td>';
     $string .= '</tr>';
     $day = date('j', $sunday);
     $month = date('n', $sunday);
     $year = date('Y', $sunday);
     for ($hour = $this->get_startTime(); $hour < $this->get_endTime(); $hour++) {
         for ($minute = 0; $minute < 60; $minute += 10) {
             if ($minute == 0) {
                 $minute = '00';
                 $string .= '<tr class="calendar_tophour">';
                 $string .= '<td rowspan="6" style="width:7%;" valign="top" id="calendar_time_' . $hour . '"></td>';
             } else {
                 $string .= '<tr>';
             }
             for ($dayofweek = 0; $dayofweek < 7; $dayofweek++) {
                 $timestamp = mktime($hour, $minute, 0, $month, $day + $dayofweek, $year);
                 if ($reservation = get_reservation_byTime($this->room, $timestamp)) {
                     $user = $DB->get_record('user', array('id' => $reservation->meetingorganizer));
                     //Set style of calendar event
                     if ($reservation->categories == '') {
                         $category = 'default';
                     } else {
                         $category = $reservation->categories;
                     }
                     //Top portion
                     if ($timestamp == $reservation->startdate) {
                         $string .= '<td class="calendar_' . $category . '_top">';
                         $starttimedisplay = strftime('%H:%M', $reservation->startdate);
                         $endtimedisplay = strftime('%H:%M', $reservation->enddate);
                         if ($reservation->alldayevent == 1) {
                             $string .= '&nbsp;' . get_string('alldayevent', 'block_roomscheduler');
                             $string .= '-' . strftime('%h %d', $reservation->startdate);
                             $string .= '&nbsp;' . get_string('to', 'block_roomscheduler') . '&nbsp;';
                             $string .= strftime('%h %d', $reservation->enddate - 600);
                         } else {
                             $string .= '&nbsp;' . $starttimedisplay . '-' . $endtimedisplay;
                         }
                         if (has_capability('block/roomscheduler:manage', $context) || $reservation->meetingorganizer == $USER->id) {
                             $string .= '&nbsp;<span style="font-weight:normal;"><a href="" onclick="calendar_removeAppt(\'' . $reservation->id . '\',\'' . get_string('reservationdelete', 'block_roomscheduler') . '\');">[' . get_string('remove', 'block_roomscheduler') . ']</a></span>';
                         }
                         $string .= '</td>';
                     } else {
                         if ($timestamp == $reservation->startdate + 600) {
                             $string .= '<td class="calendar_' . $category . '_top">';
                             $string .= '&nbsp;' . $reservation->subject;
                             $string .= '</td>';
                         } else {
                             if ($timestamp == $reservation->startdate + 1200) {
                                 $string .= '<td class="calendar_' . $category . '_bottom">';
                                 $string .= '&nbsp;' . $reservation->description;
                                 $string .= '</td>';
                             } else {
                                 if ($timestamp == $reservation->enddate - 600) {
                                     $string .= '<td class="calendar_' . $category . '_bottom">';
                                     $string .= '</td>';
                                 } else {
                                     $string .= '<td class="calendar_' . $category . '_middle">';
                                     $string .= '</td>';
                                 }
                             }
                         }
                     }
                 } else {
                     $string .= '<td style="font-size:10px;"';
                     if (has_capability('block/roomscheduler:reserve', $context) && isset($room_obj) && $room_obj->reservable) {
                         $string .= 'onmousedown="calendar_startAppt(this)" onmouseover="hoverAppt(this)" onmouseup="calendar_endAppt(this)"';
                     } elseif (has_capability('block/roomscheduler:manage', $context)) {
                         $string .= 'onmousedown="calendar_startAppt(this)" onmouseover="hoverAppt(this)" onmouseup="calendar_endAppt(this)"';
                     }
                     $string .= ' id="' . $timestamp . '";></td>';
                 }
             }
             $string .= '<td style="width:2%;"></td>';
             $string .= '</tr>';
         }
     }
     $string .= '</table>';
     $string .= '</div>';
     $string .= '</div>';
     $this->serialize();
     return $string;
 }
示例#4
0
 function draw()
 {
     global $TPL;
     $this->draw_canvas();
     $this->draw_row_header();
     $this->draw_body();
     $i = -7;
     while (date("D", mktime(0, 0, 0, date("m"), date("d") + $i, date("Y"))) != $this->first_day_of_week) {
         $i++;
     }
     $i = $i - $this->week_start * 7;
     $sunday_day = date("d", mktime(0, 0, 0, date("m"), date("d") + $i, date("Y")));
     $sunday_month = date("m", mktime(0, 0, 0, date("m"), date("d") + $i, date("Y")));
     $sunday_year = date("Y", mktime(0, 0, 0, date("m"), date("d") + $i, date("Y")));
     $i = 0;
     $absences = $this->get_cal_absences();
     $reminders = $this->get_cal_reminders();
     $tasks_to_start = $this->get_cal_tasks_to_start();
     $tasks_to_complete = $this->get_cal_tasks_to_complete();
     // For each single week...
     while ($i < $this->weeks_to_display) {
         $this->draw_row();
         $a = 0;
         while ($a < 7) {
             $dates_of_week[$this->days_of_week[$a]] = date("Y-m-d", mktime(0, 0, 0, $sunday_month, $sunday_day + 7 * $i + $a, $sunday_year));
             $a++;
         }
         foreach ($dates_of_week as $day => $date) {
             $d = new calendar_day();
             #$d->set_date(date("Y-m-d", mktime(0, 0, 0, $sunday_month, $sunday_day + (7 * $i + $k), $sunday_year));
             $d->set_date($date);
             $d->set_links($this->get_link_new_task($date) . $this->get_link_new_reminder($date) . $this->get_link_new_absence($date));
             // Tasks to be Started
             $tasks_to_start[$date] or $tasks_to_start[$date] = array();
             foreach ($tasks_to_start[$date] as $t) {
                 unset($extra);
                 $t["timeLimit"] and $extra = " (" . sprintf("Limit %0.1fhrs", $t["timeLimit"]) . ")";
                 $d->start_tasks[] = '<a href="' . $TPL["url_alloc_task"] . 'taskID=' . $t["taskID"] . '">' . page::htmlentities($t["taskName"] . $extra) . "</a>";
             }
             // Tasks to be Completed
             $tasks_to_complete[$date] or $tasks_to_complete[$date] = array();
             foreach ($tasks_to_complete[$date] as $t) {
                 unset($extra);
                 $t["timeLimit"] and $extra = " (" . sprintf("Limit %0.1fhrs", $t["timeLimit"]) . ")";
                 $d->complete_tasks[] = '<a href="' . $TPL["url_alloc_task"] . 'taskID=' . $t["taskID"] . '">' . page::htmlentities($t["taskName"] . $extra) . "</a>";
             }
             // Reminders
             $reminders[$date] or $reminders[$date] = array();
             foreach ($reminders[$date] as $r) {
                 #if (date("Y-m-d",$r["reminderTime"]) == $date) {
                 unset($wrap_start, $wrap_end);
                 if (!$r["reminderActive"]) {
                     $wrap_start = "<strike>";
                     $wrap_end = "</strike>";
                 }
                 $text = page::htmlentities($r["reminderSubject"]);
                 $r["reminderTime"] and $text = date("g:ia", $r["reminderTime"]) . " " . $text;
                 $d->reminders[] = '<a href="' . $TPL["url_alloc_reminder"] . '&step=3&reminderID=' . $r["reminderID"] . '&returnToParent=' . $this->rtp . '&personID=' . $r["personID"] . '">' . $wrap_start . $text . $wrap_end . '</a>';
                 #}
             }
             // Absences
             $absences[$date] or $absences[$date] = array();
             foreach ($absences[$date] as $a) {
                 $d->absences[] = '<a href="' . $TPL["url_alloc_absence"] . 'absenceID=' . $a["absenceID"] . '&returnToParent=' . $this->rtp . '">' . person::get_fullname($a["personID"]) . ': ' . page::htmlentities($a["absenceType"]) . '</a>';
             }
             $d->draw_day_html();
             $k++;
         }
         $i++;
         $this->draw_row_end();
     }
     $this->draw_body_end();
     $this->draw_canvas_end();
 }