- return(0L);
- }
-}
-
-
-/**
- * \brief Compare the due dates of two tasks (this is for sorting)
- * \param task1 first task to compare
- * \param task2 second task to compare
- */
-int task_due_cmp(const void *task1, const void *task2) {
- time_t t1;
- time_t t2;
-
- t1 = get_task_due_date(((struct disp_cal *)task1)->cal);
- t2 = get_task_due_date(((struct disp_cal *)task2)->cal);
- if (t1 < t2) return(-1);
- if (t1 > t2) return(1);
- return(0);
-}
-
-/**
- * \brief qsort filter to move completed tasks to bottom of task list
- */
-int task_completed_cmp(const void *task1, const void *task2) {
- icalproperty_status t1 = icalcomponent_get_status(((struct disp_cal *)task1)->cal);
- // icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal);
-
- if (t1 == ICAL_STATUS_COMPLETED)
- return 1;
- return 0;
-}
-
-
-
-/**
- * \brief do the whole task view stuff
- */
-void do_tasks_view(void) {
- int i;
- time_t due;
- char buf[SIZ];
- icalproperty *p;
- 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"));
-
- /** Sort them if necessary */
- if (WC->num_cal > 1) {
- qsort(WC->disp_cal,
- WC->num_cal,
- sizeof(struct disp_cal),
- task_due_cmp
- );
- }
- /** And then again, by completed */
- if (WC->num_cal > 1) {
- qsort(WC->disp_cal,
- WC->num_cal,
- sizeof(struct disp_cal),
- task_completed_cmp
- );
- }
-
- if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) {
- wprintf("<tr><td>");
- icalproperty_status todoStatus = icalcomponent_get_status(WC->disp_cal[i].cal);
- wprintf("<input style=\"text-align: center;\" 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(WC->disp_cal[i].cal,
- ICAL_SUMMARY_PROPERTY);
- wprintf("<a href=\"display_edit_task?msgnum=%ld&taskrm=",
- WC->disp_cal[i].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(WC->disp_cal[i].cal);
- wprintf("<td><span");
- if (due > 0) {
- webcit_fmt_date(buf, due, 0);
- wprintf(">%s",buf);