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(); }