* All OS-level includes are now included from webcit.h instead of from
[citadel.git] / webcit / calendar_view.c
index 1dfbf351d1629edac0b5e67aa07f44be110e2bcb..c43cb5b979f92abc36022bd9292cbba077657f47 100644 (file)
@@ -4,25 +4,6 @@
  * Handles the HTML display of calendar items.
  */
 
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <limits.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <string.h>
-#include <pwd.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <pthread.h>
-#include <signal.h>
-#include <time.h>
 #include "webcit.h"
 #include "webserver.h"
 
@@ -155,8 +136,8 @@ void calendar_month_view(int year, int month, int day) {
        }
 
        /* Outer table (to get the background color) */
-       wprintf("<center>"
-               "<TABLE width=99%% border=0 cellpadding=0 cellspacing=0 "
+       wprintf("<div id=\"fix_scrollbar_bug\">"
+               "<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
                "bgcolor=#204B78><TR><TD>\n");
 
        wprintf("<TABLE width=100%% border=0 cellpadding=0 cellspacing=0><tr>\n");
@@ -166,7 +147,7 @@ void calendar_month_view(int year, int month, int day) {
        localtime_r(&previous_month, &tm);
        wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
                (int)(tm.tm_year)+1900, tm.tm_mon + 1);
-       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/back.gif\" BORDER=0></A>\n");
+       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/prevdate_32x.gif\" BORDER=0></A>\n");
 
        wprintf("&nbsp;&nbsp;"
                "<FONT SIZE=+1 COLOR=\"#FFFFFF\">"
@@ -177,7 +158,7 @@ void calendar_month_view(int year, int month, int day) {
        localtime_r(&next_month, &tm);
        wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
                (int)(tm.tm_year)+1900, tm.tm_mon + 1);
-       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/forward.gif\" BORDER=0></A>\n");
+       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/nextdate_32x.gif\" BORDER=0></A>\n");
 
        wprintf("</TD></TR></TABLE>\n");
 
@@ -229,7 +210,7 @@ void calendar_month_view(int year, int month, int day) {
 
        wprintf("</TABLE>"                      /* end of inner table */
                "</TD></TR></TABLE>"            /* end of outer table */
-               "</CENTER>\n");
+               "</div>\n");
 }
 
 
@@ -252,7 +233,7 @@ void calendar_day_view_display_events(int year, int month,
        int all_day_event = 0;
 
        if (WC->num_cal == 0) {
-               wprintf("<br /><br /><br />\n");
+               // FIXME wprintf("<br /><br /><br />\n");
                return;
        }
 
@@ -315,7 +296,9 @@ void calendar_day_view_display_events(int year, int month,
 void calendar_day_view(int year, int month, int day) {
        int hour;
        struct icaltimetype today, yesterday, tomorrow;
+       char calhourformat[16];
 
+       get_preference("calhourformat", calhourformat, sizeof calhourformat);
 
        /* Figure out the dates for "yesterday" and "tomorrow" links */
 
@@ -335,8 +318,8 @@ void calendar_day_view(int year, int month, int day) {
 
 
        /* Outer table (to get the background color) */
-       wprintf("<center>"
-               "<TABLE width=99%% border=0 cellpadding=0 cellspacing=0 "
+       wprintf("<div id=\"fix_scrollbar_bug\">"
+               "<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
                "bgcolor=#204B78><TR><TD>\n");
 
        /* Inner table (the real one) */
@@ -365,10 +348,17 @@ void calendar_day_view(int year, int month, int day) {
                        "&year=%d&month=%d&day=%d&hour=%d&minute=0\">",
                        year, month, day, hour
                );
-               wprintf("%d:00%s</A> ",
-                       (hour <= 12 ? hour : hour-12),
-                       (hour < 12 ? "am" : "pm")
-               );
+
+               if (!strcasecmp(calhourformat, "24")) {
+                       wprintf("%2d:00</A> ", hour);
+               }
+               else {
+                       wprintf("%d:00%s</A> ",
+                               (hour <= 12 ? hour : hour-12),
+                               (hour < 12 ? "am" : "pm")
+                       );
+               }
+
                wprintf("</TD><TD BGCOLOR=\"#FFFFFF\" VALIGN=TOP>");
 
                /* put the data here, stupid */
@@ -403,7 +393,7 @@ void calendar_day_view(int year, int month, int day) {
        wprintf("<TD ALIGN=CENTER>");
        wprintf("<A HREF=\"readfwd?calview=day&year=%d&month=%d&day=%d\">",
                yesterday.year, yesterday.month, yesterday.day);
-       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/back.gif\" BORDER=0></A>");
+       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/prevdate_32x.gif\" BORDER=0></A>");
        wprintf("</TD>");
 
        /* Today's date */
@@ -418,23 +408,14 @@ void calendar_day_view(int year, int month, int day) {
        wprintf("<TD ALIGN=CENTER>");
        wprintf("<A HREF=\"readfwd?calview=day&year=%d&month=%d&day=%d\">",
                tomorrow.year, tomorrow.month, tomorrow.day);
-       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/forward.gif\""
+       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/nextdate_32x.gif\""
                " BORDER=0></A>\n");
        wprintf("</TD>");
 
        wprintf("</TR></TABLE>\n");
        /* End todays-date-with-left-and-right-arrows */
 
-       wprintf("<br /><br /><CENTER><font color=#FFFFFF>"
-               "&nbsp;<A HREF=\"/display_edit_event?msgnum=0"
-               "&year=%d&month=%d&day=%d\">"
-               "Add new calendar event</A>"
-               "<br /><br />\n",
-               year, month, day
-       );
-
-       wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">"
-               "Back to month view</A>\n", year, month);
+       /* In the future we might want to put a month-o-matic here */
 
        wprintf("</FONT></CENTER>\n");
 
@@ -443,7 +424,7 @@ void calendar_day_view(int year, int month, int day) {
 
 
        wprintf("</TR></TABLE>"                 /* end of inner table */
-               "</TD></TR></TABLE></center>"   /* end of outer table */
+               "</TD></TR></TABLE></div>"      /* end of outer table */
        );
 
 
@@ -623,9 +604,8 @@ void do_tasks_view(void) {
        char buf[SIZ];
        icalproperty *p;
 
-       do_template("beginbox_nt");
-
-       wprintf("<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%%>\n<TR>\n"
+       wprintf("<div id=\"fix_scrollbar_bug\">"
+               "<table border=0 cellspacing=0 width=100%% bgcolor=\"#FFFFFF\">\n<tr>\n"
                "<TH>Name of task</TH>\n"
                "<TH>Date due</TH></TR>\n"
        );
@@ -652,6 +632,8 @@ void do_tasks_view(void) {
                        WC->disp_cal[i].cal_msgnum );
                urlescputs(WC->wc_roomname);
                wprintf("\">");
+               wprintf("<IMG ALIGN=MIDDLE "
+                       "SRC=\"/static/taskmanag_16x.gif\" BORDER=0>&nbsp;");
                if (p != NULL) {
                        escputs((char *)icalproperty_get_comment(p));
                }
@@ -659,7 +641,7 @@ void do_tasks_view(void) {
                wprintf("</TD>\n");
 
                due = get_task_due_date(WC->disp_cal[i].cal);
-               fmt_date(buf, due);
+               fmt_date(buf, due, 0);
                wprintf("<TD><FONT");
                if (due < time(NULL)) {
                        wprintf(" COLOR=\"#FF0000\"");
@@ -667,10 +649,7 @@ void do_tasks_view(void) {
                wprintf(">%s</FONT></TD></TR>\n", buf);
        }
 
-       wprintf("</TABLE>\n");
-
-       do_template("endbox");
-
+       wprintf("</table></div>\n");
 
        /* Free the list */
        free_calendar_buffer();