5 * \defgroup CalHtmlHandles Handles the HTML display of calendar items.
10 #include "webserver.h"
12 #ifndef WEBCIT_WITH_CALENDAR_SERVICE
14 /**\brief stub for non-libical builds */
15 void do_calendar_view(void) {
16 wprintf("<CENTER><I>");
17 wprintf(_("The calendar view is not available."));
18 wprintf("</I></CENTER><br />\n");
21 /**\brief stub for non-libical builds */
22 void do_tasks_view(void) {
23 wprintf("<CENTER><I>");
24 wprintf(_("The tasks view is not available."));
25 wprintf("</I></CENTER><br />\n");
28 #else /* WEBCIT_WITH_CALENDAR_SERVICE */
30 /****************************************************************************/
33 * \brief Display one day of a whole month view of a calendar
34 * \param thetime the month we want to see
36 void calendar_month_view_display_events(time_t thetime) {
42 struct icaltimetype t;
44 int all_day_event = 0;
46 if (WC->num_cal == 0) {
47 wprintf("<br /><br /><br />\n");
51 localtime_r(&thetime, &today_tm);
52 month = today_tm.tm_mon + 1;
53 day = today_tm.tm_mday;
54 year = today_tm.tm_year + 1900;
56 for (i=0; i<(WC->num_cal); ++i) {
57 p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
58 ICAL_DTSTART_PROPERTY);
60 t = icalproperty_get_dtstart(p);
61 event_tt = icaltime_as_timet(t);
63 if (t.is_date) all_day_event = 1;
64 else all_day_event = 0;
67 gmtime_r(&event_tt, &event_tm);
70 localtime_r(&event_tt, &event_tm);
73 if ((event_tm.tm_year == today_tm.tm_year)
74 && (event_tm.tm_mon == today_tm.tm_mon)
75 && (event_tm.tm_mday == today_tm.tm_mday)) {
77 p = icalcomponent_get_first_property(
79 ICAL_SUMMARY_PROPERTY);
83 wprintf("<TABLE border=0 cellpadding=2><TR>"
84 "<TD BGCOLOR=\"#CCCCDD\">"
88 wprintf("<FONT SIZE=-1>"
89 "<a href=\"display_edit_event?msgnum=%ld&calview=%s&year=%s&month=%s&day=%s\">",
90 WC->disp_cal[i].cal_msgnum,
97 icalproperty_get_comment(p));
98 wprintf("</A></FONT><br />\n");
101 wprintf("</TD></TR></TABLE>");
115 * \brief Display one day of a whole month view of a calendar
116 * \param thetime the month we want to see
118 void calendar_month_view_brief_events(time_t thetime, const char *daycolor) {
128 struct icaltimetype t;
129 int month, day, year;
130 int all_day_event = 0;
131 char calhourformat[16];
134 get_preference("calhourformat", calhourformat, sizeof calhourformat);
135 if (!strcasecmp(calhourformat, "24")) timeformat="%k:%M";
136 else timeformat="%I:%M %p";
138 localtime_r(&thetime, &today_tm);
139 month = today_tm.tm_mon + 1;
140 day = today_tm.tm_mday;
141 year = today_tm.tm_year + 1900;
143 for (i=0; i<(WC->num_cal); ++i) {
144 p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
145 ICAL_DTSTART_PROPERTY);
147 t = icalproperty_get_dtstart(p);
148 event_tt = icaltime_as_timet(t);
150 if (t.is_date) all_day_event = 1;
151 else all_day_event = 0;
154 gmtime_r(&event_tts, &event_tms);
157 localtime_r(&event_tts, &event_tms);
159 /** \todo epoch &! daymask */
160 if ((event_tms.tm_year == today_tm.tm_year)
161 && (event_tms.tm_mon == today_tm.tm_mon)
162 && (event_tms.tm_mday == today_tm.tm_mday)) {
168 p = icalcomponent_get_first_property(
170 ICAL_SUMMARY_PROPERTY);
171 e = icalcomponent_get_first_property(
173 ICAL_DTEND_PROPERTY);
174 if ((p != NULL) && (e != NULL)) {
177 t = icalproperty_get_dtend(e);
178 event_tte = icaltime_as_timet(t);
179 localtime_r(&event_tte, &event_tme);
180 difftime=(event_tte-event_tts)/60;
181 hours=(int)(difftime / 60);
182 minutes=difftime % 60;
183 wprintf("<tr><td bgcolor='%s'>%i:%2i</td><td bgcolor='%s'>"
185 "<a href=\"display_edit_event?msgnum=%ld&calview=%s&year=%s&month=%s&day=%s\">",
189 WC->disp_cal[i].cal_msgnum,
197 icalproperty_get_comment(p));
198 /** \todo: allso ammitime format */
199 wc_strftime(&sbuf[0], sizeof(sbuf), timeformat, &event_tms);
200 wc_strftime(&ebuf[0], sizeof(sbuf), timeformat, &event_tme);
202 wprintf("</a></font></td>"
203 "<td bgcolor='%s'>%s</td><td bgcolor='%s'>%s</td></tr>",
220 * \brief view one month. pretty view
221 * \param year the year
222 * \param month the month
223 * \param day the actual day we want to see
225 void calendar_month_view(int year, int month, int day) {
226 struct tm starting_tm;
230 time_t previous_month;
232 time_t colheader_time;
233 struct tm colheader_tm;
234 char colheader_label[32];
236 /** Determine what day to start.
237 * First, back up to the 1st of the month...
239 memset(&starting_tm, 0, sizeof(struct tm));
240 starting_tm.tm_year = year - 1900;
241 starting_tm.tm_mon = month - 1;
242 starting_tm.tm_mday = day;
243 thetime = mktime(&starting_tm);
245 memcpy(&tm, &starting_tm, sizeof(struct tm));
246 while (tm.tm_mday != 1) {
247 thetime = thetime - (time_t)86400; /* go back 24 hours */
248 localtime_r(&thetime, &tm);
251 /** Determine previous and next months ... for links */
252 previous_month = thetime - (time_t)864000L; /* back 10 days */
253 next_month = thetime + (time_t)(31L * 86400L); /* ahead 31 days */
255 /** Now back up until we're on a Sunday */
256 localtime_r(&thetime, &tm);
257 while (tm.tm_wday != 0) {
258 thetime = thetime - (time_t)86400; /* go back 24 hours */
259 localtime_r(&thetime, &tm);
262 /** Outer table (to get the background color) */
263 wprintf("<div class=\"fix_scrollbar_bug\">"
264 "<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
265 "bgcolor=#204B78><TR><TD>\n");
267 wprintf("<TABLE width=100%% border=0 cellpadding=0 cellspacing=0><tr>\n");
269 wprintf("<TD ALIGN=CENTER>");
271 localtime_r(&previous_month, &tm);
272 wprintf("<a href=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
273 (int)(tm.tm_year)+1900, tm.tm_mon + 1);
274 wprintf("<IMG ALIGN=MIDDLE src=\"static/prevdate_32x.gif\" BORDER=0></A>\n");
276 wc_strftime(colheader_label, sizeof colheader_label, "%B", &starting_tm);
277 wprintf(" "
278 "<FONT SIZE=+1 COLOR=\"#FFFFFF\">"
281 " ", colheader_label, year);
283 localtime_r(&next_month, &tm);
284 wprintf("<a href=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
285 (int)(tm.tm_year)+1900, tm.tm_mon + 1);
286 wprintf("<IMG ALIGN=MIDDLE src=\"static/nextdate_32x.gif\" BORDER=0></A>\n");
288 wprintf("</TD></TR></TABLE>\n");
290 /** Inner table (the real one) */
291 wprintf("<TABLE width=100%% border=0 cellpadding=1 cellspacing=1 "
292 "bgcolor=#204B78><TR>");
293 colheader_time = thetime;
294 for (i=0; i<7; ++i) {
295 colheader_time = thetime + (i * 86400) ;
296 localtime_r(&colheader_time, &colheader_tm);
297 wc_strftime(colheader_label, sizeof colheader_label, "%A", &colheader_tm);
298 wprintf("<TD ALIGN=CENTER WIDTH=14%%>"
299 "<FONT COLOR=\"#FFFFFF\">%s</FONT></TH>", colheader_label);
303 /** Now do 35 days */
304 for (i = 0; i < 35; ++i) {
305 localtime_r(&thetime, &tm);
307 /** Before displaying Sunday, start a new row */
312 wprintf("<TD BGCOLOR=\"#%s\" WIDTH=14%% HEIGHT=60 align=left VALIGN=TOP><B>",
313 ((tm.tm_mon != month-1) ? "DDDDDD" :
314 ((tm.tm_wday==0 || tm.tm_wday==6) ? "EEEECC" :
317 if ((i==0) || (tm.tm_mday == 1)) {
318 wc_strftime(colheader_label, sizeof colheader_label, "%B", &tm);
319 wprintf("%s ", colheader_label);
321 wprintf("<a href=\"readfwd?calview=day&year=%d&month=%d&day=%d\">"
328 /** put the data here, stupid */
329 calendar_month_view_display_events(thetime);
333 /** After displaying Saturday, end the row */
338 thetime += (time_t)86400; /** ahead 24 hours */
341 wprintf("</TABLE>" /** end of inner table */
342 "</TD></TR></TABLE>" /** end of outer table */
347 * \brief view one month. brief view
348 * \param year the year
349 * \param month the month
350 * \param day the actual day we want to see
352 void calendar_brief_month_view(int year, int month, int day) {
353 struct tm starting_tm;
357 time_t previous_month;
359 char month_label[32];
361 /** Determine what day to start.
362 * First, back up to the 1st of the month...
364 memset(&starting_tm, 0, sizeof(struct tm));
365 starting_tm.tm_year = year - 1900;
366 starting_tm.tm_mon = month - 1;
367 starting_tm.tm_mday = day;
368 thetime = mktime(&starting_tm);
370 memcpy(&tm, &starting_tm, sizeof(struct tm));
371 while (tm.tm_mday != 1) {
372 thetime = thetime - (time_t)86400; /* go back 24 hours */
373 localtime_r(&thetime, &tm);
376 /** Determine previous and next months ... for links */
377 previous_month = thetime - (time_t)864000L; /* back 10 days */
378 next_month = thetime + (time_t)(31L * 86400L); /* ahead 31 days */
380 /** Now back up until we're on a Sunday */
381 localtime_r(&thetime, &tm);
382 while (tm.tm_wday != 0) {
383 thetime = thetime - (time_t)86400; /* go back 24 hours */
384 localtime_r(&thetime, &tm);
387 /** Outer table (to get the background color) */
388 wprintf("<div class=\"fix_scrollbar_bug\">"
389 "<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
390 "bgcolor=#204B78><TR><TD>\n");
392 wprintf("<TABLE width=100%% border=0 cellpadding=0 cellspacing=0><tr>\n");
394 wprintf("<TD ALIGN=CENTER>");
396 localtime_r(&previous_month, &tm);
397 wprintf("<a href=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
398 (int)(tm.tm_year)+1900, tm.tm_mon + 1);
399 wprintf("<IMG ALIGN=MIDDLE src=\"static/prevdate_32x.gif\" BORDER=0></A>\n");
401 wc_strftime(month_label, sizeof month_label, "%B", &tm);
402 wprintf(" "
403 "<FONT SIZE=+1 COLOR=\"#FFFFFF\">"
406 " ", month_label, year);
408 localtime_r(&next_month, &tm);
409 wprintf("<a href=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
410 (int)(tm.tm_year)+1900, tm.tm_mon + 1);
411 wprintf("<IMG ALIGN=MIDDLE src=\"static/nextdate_32x.gif\" BORDER=0></A>\n");
413 wprintf("</TD></TR></TABLE>\n");
415 /** Inner table (the real one) */
416 wprintf("<TABLE width=100%% border=0 cellpadding=1 cellspacing=1 "
417 "bgcolor=#EEEECC><TR>");
419 wprintf("<TR><TD COLSPAN=\"100%\">\n");
421 /** Now do 35 days */
422 for (i = 0; i < 35; ++i) {
423 char weeknumber[255];
424 char weekday_name[32];
426 localtime_r(&thetime, &tm);
429 /** Before displaying Sunday, start a new CELL */
431 wc_strftime(&weeknumber[0], sizeof(weeknumber), "%U", &tm);
432 wprintf("<TABLE border='0' BGCOLOR=\"#EEEECC\" width='100%'> <tr><th colspan='4'>%s %s</th></tr>"
433 " <tr><td>%s</td><td width='70%'>%s</td><td>%s</td><td>%s</td></tr>\n",
443 daycolor=((tm.tm_mon != month-1) ? "DDDDDD" :
444 ((tm.tm_wday==0 || tm.tm_wday==6) ? "EEEECC" :
448 wc_strftime(weekday_name, sizeof weekday_name, "%A", &tm);
449 wprintf("<tr><td BGCOLOR='%s' colspan='1' align='left'> %s"
450 "</td><td BGCOLOR='%s' colspan='3'><hr></td></tr>\n",
455 /** put the data of one day here, stupid */
456 calendar_month_view_brief_events(thetime, daycolor);
459 /** After displaying Saturday, end the row */
461 wprintf("</td></tr></table>\n");
464 thetime += (time_t)86400; /** ahead 24 hours */
467 wprintf("</TABLE>" /** end of inner table */
468 "</TD></TR></TABLE>" /** end of outer table */
473 * \brief view one week
474 * this should view just one week, but it's not here yet.
475 * \todo ny implemented
476 * \param year the year
477 * \param month the month
478 * \param day the day which we want to see the week around
480 void calendar_week_view(int year, int month, int day) {
481 wprintf("<CENTER><I>week view FIXME</I></CENTER><br />\n");
486 * \brief display one day
487 * Display events for a particular hour of a particular day.
488 * (Specify hour < 0 to show "all day" events)
489 * \param year the year
490 * \param month the month
492 * \param hour the hour we want to start displaying?????
494 void calendar_day_view_display_events(int year, int month,
498 struct icaltimetype t;
501 int all_day_event = 0;
503 if (WC->num_cal == 0) {
504 // \todo FIXME wprintf("<br /><br /><br />\n");
508 for (i=0; i<(WC->num_cal); ++i) {
509 p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
510 ICAL_DTSTART_PROPERTY);
512 t = icalproperty_get_dtstart(p);
513 event_tt = icaltime_as_timet(t);
522 event_tm = gmtime(&event_tt);
525 event_tm = localtime(&event_tt);
528 if ((event_tm->tm_year == (year-1900))
529 && (event_tm->tm_mon == (month-1))
530 && (event_tm->tm_mday == day)
531 && ( ((event_tm->tm_hour == hour)&&(!t.is_date)) || ((hour<0)&&(t.is_date)) )
535 p = icalcomponent_get_first_property(
537 ICAL_SUMMARY_PROPERTY);
541 wprintf("<TABLE border=1 cellpadding=2><TR>"
542 "<TD BGCOLOR=\"#CCCCCC\">"
546 wprintf("<FONT SIZE=-1>"
547 "<a href=\"display_edit_event?msgnum=%ld&calview=day&year=%d&month=%d&day=%d\">",
548 WC->disp_cal[i].cal_msgnum,
552 icalproperty_get_comment(p));
553 wprintf("</A></FONT><br />\n");
556 wprintf("</TD></TR></TABLE>");
569 * \brief view one day
570 * \param year the year
571 * \param month the month
572 * \param day the day we want to display
574 void calendar_day_view(int year, int month, int day) {
576 struct icaltimetype today, yesterday, tomorrow;
577 char calhourformat[16];
580 char daystart_str[16], dayend_str[16];
584 get_preference("calhourformat", calhourformat, sizeof calhourformat);
585 get_preference("daystart", daystart_str, sizeof daystart_str);
586 if (strlen(daystart_str) > 0) daystart = atoi(daystart_str);
587 get_preference("dayend", dayend_str, sizeof dayend_str);
588 if (strlen(dayend_str) > 0) dayend = atoi(dayend_str);
591 /** Figure out the dates for "yesterday" and "tomorrow" links */
593 memset(&today, 0, sizeof(struct icaltimetype));
599 memcpy(&yesterday, &today, sizeof(struct icaltimetype));
601 yesterday = icaltime_normalize(yesterday);
603 memcpy(&tomorrow, &today, sizeof(struct icaltimetype));
605 tomorrow = icaltime_normalize(tomorrow);
608 /** Outer table (to get the background color) */
609 wprintf("<div class=\"fix_scrollbar_bug\">"
610 "<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
611 "bgcolor=#204B78><TR><TD>\n");
613 /** Inner table (the real one) */
614 wprintf("<TABLE width=100%% border=0 cellpadding=1 cellspacing=1 "
615 "bgcolor=#204B78><TR>\n");
617 /** Innermost table (contains hours etc.) */
618 wprintf("<TD WIDTH=80%%>"
619 "<TABLE width=100%% border=0 cellpadding=1 cellspacing=1 "
620 "bgcolor=#204B78>\n");
622 /** Display events before 8:00 (hour=-1 is all-day events) */
624 "<TD BGCOLOR=\"#CCCCDD\" VALIGN=MIDDLE WIDTH=10%%></TD>"
625 "<TD BGCOLOR=\"#FFFFFF\" VALIGN=TOP>");
626 for (hour = (-1); hour <= (daystart-1); ++hour) {
627 calendar_day_view_display_events(year, month, day, hour);
629 wprintf("</TD></TR>\n");
631 /** Now the middle of the day... */
632 for (hour = daystart; hour <= dayend; ++hour) { /* could do HEIGHT=xx */
633 wprintf("<TR HEIGHT=30><TD BGCOLOR=\"#CCCCDD\" ALIGN=MIDDLE "
634 "VALIGN=MIDDLE WIDTH=10%%>");
635 wprintf("<a href=\"display_edit_event?msgnum=0"
636 "&year=%d&month=%d&day=%d&hour=%d&minute=0\">",
637 year, month, day, hour
640 if (!strcasecmp(calhourformat, "24")) {
641 wprintf("%2d:00</A> ", hour);
644 wprintf("%d:00%s</A> ",
645 (hour <= 12 ? hour : hour-12),
646 (hour < 12 ? "am" : "pm")
650 wprintf("</TD><TD BGCOLOR=\"#FFFFFF\" VALIGN=TOP>");
652 /* put the data here, stupid */
653 calendar_day_view_display_events(year, month, day, hour);
655 wprintf("</TD></TR>\n");
658 /** Display events after 5:00... */
660 "<TD BGCOLOR=\"#CCCCDD\" VALIGN=MIDDLE WIDTH=10%%></TD>"
661 "<TD BGCOLOR=\"#FFFFFF\" VALIGN=TOP>");
662 for (hour = (dayend+1); hour <= 23; ++hour) {
663 calendar_day_view_display_events(year, month, day, hour);
665 wprintf("</TD></TR>\n");
668 wprintf("</TABLE>" /* end of innermost table */
672 wprintf("<TD WIDTH=20%% VALIGN=top>"); /* begin stuff-on-the-right */
675 /** Begin todays-date-with-left-and-right-arrows */
676 wprintf("<TABLE BORDER=0 WIDTH=100%% "
677 "CELLSPACING=0 CELLPADDING=0 BGCOLOR=\"#FFFFFF\">\n");
681 wprintf("<TD ALIGN=CENTER>");
682 wprintf("<a href=\"readfwd?calview=day&year=%d&month=%d&day=%d\">",
683 yesterday.year, yesterday.month, yesterday.day);
684 wprintf("<IMG ALIGN=MIDDLE src=\"static/prevdate_32x.gif\" BORDER=0></A>");
688 memset(&d_tm, 0, sizeof d_tm);
689 d_tm.tm_year = year - 1900;
690 d_tm.tm_mon = month - 1;
692 wc_strftime(d_str, sizeof d_str,
694 "<font size=+2>%B</font><br />"
695 "<font size=+3>%d</font><br />"
696 "<font size=+2>%Y</font><br />"
700 wprintf("%s", d_str);
703 wprintf("<TD ALIGN=CENTER>");
704 wprintf("<a href=\"readfwd?calview=day&year=%d&month=%d&day=%d\">",
705 tomorrow.year, tomorrow.month, tomorrow.day);
706 wprintf("<IMG ALIGN=MIDDLE src=\"static/nextdate_32x.gif\""
710 wprintf("</TR></TABLE>\n");
711 /** End todays-date-with-left-and-right-arrows */
713 /** \todo In the future we might want to put a month-o-matic here */
715 wprintf("</FONT></CENTER>\n");
717 wprintf("</TD>"); /** end stuff-on-the-right */
721 wprintf("</TR></TABLE>" /** end of inner table */
722 "</TD></TR></TABLE></div>" /** end of outer table */
730 * \brief Display today's events.
732 void calendar_summary_view(void) {
735 struct icaltimetype t;
740 int all_day_event = 0;
741 char timestring[SIZ];
743 if (WC->num_cal == 0) {
748 localtime_r(&now, &today_tm);
750 for (i=0; i<(WC->num_cal); ++i) {
751 p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
752 ICAL_DTSTART_PROPERTY);
754 t = icalproperty_get_dtstart(p);
755 event_tt = icaltime_as_timet(t);
762 fmt_time(timestring, event_tt);
765 gmtime_r(&event_tt, &event_tm);
768 localtime_r(&event_tt, &event_tm);
771 if ( (event_tm.tm_year == today_tm.tm_year)
772 && (event_tm.tm_mon == today_tm.tm_mon)
773 && (event_tm.tm_mday == today_tm.tm_mday)
777 p = icalcomponent_get_first_property(
779 ICAL_SUMMARY_PROPERTY);
782 icalproperty_get_comment(p));
783 wprintf(" (%s)<br />\n", timestring);
788 free_calendar_buffer();
793 * \brief clean up ical memory
794 * \todo this could get troubel with future ical versions
796 void free_calendar_buffer(void) {
798 if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) {
799 icalcomponent_free(WC->disp_cal[i].cal);
809 * \brief do the whole calendar page
810 * view any part of the calender. decide which way, etc.
812 void do_calendar_view(void) {
815 int year, month, day;
818 /** In case no date was specified, go with today */
820 localtime_r(&now, &tm);
821 year = tm.tm_year + 1900;
822 month = tm.tm_mon + 1;
825 /** Now see if a date was specified */
826 if (strlen(bstr("year")) > 0) year = atoi(bstr("year"));
827 if (strlen(bstr("month")) > 0) month = atoi(bstr("month"));
828 if (strlen(bstr("day")) > 0) day = atoi(bstr("day"));
830 /** How would you like that cooked? */
831 if (strlen(bstr("calview")) > 0) {
832 strcpy(calview, bstr("calview"));
835 strcpy(calview, "month");
838 /** Display the selected view */
839 if (!strcasecmp(calview, "day")) {
840 calendar_day_view(year, month, day);
842 else if (!strcasecmp(calview, "week")) {
843 calendar_week_view(year, month, day);
846 if (WC->wc_view == VIEW_CALBRIEF) {
847 calendar_brief_month_view(year, month, day);
850 calendar_month_view(year, month, day);
854 /** Free the calendar stuff */
855 free_calendar_buffer();
861 * \brief get task due date
862 * Helper function for do_tasks_view().
863 * \param vtodo a task to get the due date
864 * \return the date/time due.
866 time_t get_task_due_date(icalcomponent *vtodo) {
874 * If we're looking at a fully encapsulated VCALENDAR
875 * rather than a VTODO component, recurse into the data
876 * structure until we get a VTODO.
878 if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
879 return get_task_due_date(
880 icalcomponent_get_first_component(
881 vtodo, ICAL_VTODO_COMPONENT
886 p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
888 return(icaltime_as_timet(icalproperty_get_due(p)));
897 * \brief Compare the due dates of two tasks (this is for sorting)
898 * \param task1 first task to compare
899 * \param task2 second task to compare
901 int task_due_cmp(const void *task1, const void *task2) {
905 t1 = get_task_due_date(((struct disp_cal *)task1)->cal);
906 t2 = get_task_due_date(((struct disp_cal *)task2)->cal);
908 if (t1 < t2) return(-1);
909 if (t1 > t2) return(1);
917 * \brief do the whole task view stuff
919 void do_tasks_view(void) {
926 wprintf("<div class=\"fix_scrollbar_bug\">"
927 "<table border=0 cellspacing=0 width=100%% bgcolor=\"#FFFFFF\">\n<tr>\n"
929 wprintf(_("Name of task"));
930 wprintf("</TH><TH>");
931 wprintf(_("Date due"));
932 wprintf("</TH></TR>\n"
935 /** Sort them if necessary */
936 if (WC->num_cal > 1) {
939 sizeof(struct disp_cal),
944 if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) {
947 wprintf("<TR BGCOLOR=\"#%s\"><TD>",
948 (bg ? "DDDDDD" : "FFFFFF")
951 p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
952 ICAL_SUMMARY_PROPERTY);
953 wprintf("<a href=\"display_edit_task?msgnum=%ld&taskrm=",
954 WC->disp_cal[i].cal_msgnum );
955 urlescputs(WC->wc_roomname);
957 wprintf("<IMG ALIGN=MIDDLE "
958 "src=\"static/taskmanag_16x.gif\" BORDER=0> ");
960 escputs((char *)icalproperty_get_comment(p));
965 due = get_task_due_date(WC->disp_cal[i].cal);
966 fmt_date(buf, due, 0);
967 wprintf("<TD><FONT");
968 if (due < time(NULL)) {
969 wprintf(" COLOR=\"#FF0000\"");
971 wprintf(">%s</FONT></TD></TR>\n", buf);
974 wprintf("</table></div>\n");
977 free_calendar_buffer();
981 #endif /* WEBCIT_WITH_CALENDAR_SERVICE */