- return(0L);
- }
-}
-
-
-/*
- * Compare the due dates of two tasks (this is for sorting)
- */
-int task_due_cmp(const void *vtask1, const void *vtask2) {
- disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
- disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2);
-
- time_t t1;
- time_t t2;
-
- t1 = get_task_due_date(Task1->cal);
- t2 = get_task_due_date(Task2->cal);
- if (t1 < t2) return(-1);
- if (t1 > t2) return(1);
- return(0);
-}
-
-/*
- * qsort filter to move completed tasks to bottom of task list
- */
-int task_completed_cmp(const void *vtask1, const void *vtask2) {
- disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
-// disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2);
-
- icalproperty_status t1 = icalcomponent_get_status((Task1)->cal);
- // icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal);
-
- if (t1 == ICAL_STATUS_COMPLETED)
- return 1;
- return 0;
-}
-
-
-
-/*
- * do the whole task view stuff
- */
-void do_tasks_view(void) {
- long hklen;
- const char *HashKey;
- void *vCal;
- disp_cal *Cal;
- HashPos *Pos;
- int nItems;
- time_t due;
- char buf[SIZ];
- icalproperty *p;
- struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
-
- wprintf("<div class=\"fix_scrollbar_bug\">"
- "<table class=\"calendar_view_background\"><tbody id=\"taskview\">\n<tr>\n"
- "<th>");
- wprintf(_("Completed?"));
- wprintf("</th><th>");
- wprintf(_("Name of task"));
- wprintf("</th><th>");
- wprintf(_("Date due"));
- wprintf("</th><th>");
- wprintf(_("Category"));
- wprintf(" (<select id=\"selectcategory\"><option value=\"showall\">%s</option></select>)</th></tr>\n",
- _("Show All"));
-
- nItems = GetCount(WC->disp_cal_items);
-
- /* Sort them if necessary
- if (nItems > 1) {
- SortByPayload(WC->disp_cal_items, task_due_cmp);
- }
- * this shouldn't be neccessary, since we sort by the start time.
- */
-
- /* And then again, by completed */
- if (nItems > 1) {
- SortByPayload(WC->disp_cal_items,
- task_completed_cmp);
- }
-
- Pos = GetNewHashPos();
- while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
- Cal = (disp_cal*)vCal;
- wprintf("<tr><td>");
- icalproperty_status todoStatus = icalcomponent_get_status(Cal->cal);
- wprintf("<input type=\"checkbox\" name=\"completed\" value=\"completed\" ");
- if (todoStatus == ICAL_STATUS_COMPLETED) {
- wprintf("checked=\"checked\" ");
- }
- wprintf("disabled=\"disabled\">\n</td><td>");
- p = icalcomponent_get_first_property(Cal->cal,
- ICAL_SUMMARY_PROPERTY);
- wprintf("<a href=\"display_edit_task?msgnum=%ld&taskrm=",
- Cal->cal_msgnum );
- urlescputs(WC->wc_roomname);
- wprintf("\">");
- /* wprintf("<img align=middle "
- "src=\"static/taskmanag_16x.gif\" border=0> "); */
- if (p != NULL) {
- escputs((char *)icalproperty_get_comment(p));
- }
- wprintf("</a>\n");
- wprintf("</td>\n");
-
- due = get_task_due_date(Cal->cal);
- wprintf("<td><span");
- if (due > 0) {
- webcit_fmt_date(buf, due, 0);
- wprintf(">%s",buf);