* Completed the calendar day view
authorArt Cancro <ajc@citadel.org>
Sun, 29 Sep 2002 20:15:43 +0000 (20:15 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 29 Sep 2002 20:15:43 +0000 (20:15 +0000)
webcit/ChangeLog
webcit/calendar_tools.c
webcit/calendar_view.c
webcit/event.c

index 6c5e38b103e43ccfb8162a54e94d3bf952902708..a0b996785ce4012e7fe2f9df66dad67ab9f45d04 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 400.31  2002/09/29 20:15:43  ajc
+* Completed the calendar day view
+
 Revision 400.30  2002/09/28 04:01:30  ajc
 * started fleshing out the calendar day view
 
@@ -1043,3 +1046,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 581d044d92442082c401e50f458dfc0b5d975ec0..b7cf8fbe7130e3df373992363db4efb03402b48f 100644 (file)
@@ -111,6 +111,10 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
        }
        wprintf("</SELECT>\n");
 
+       wprintf("<INPUT TYPE=\"checkbox\" NAME=\"%s_alldayevent\" "
+               "VALUE=\"yes\" %s> All day event",
+               prefix,
+               ((t->is_date) ? "CHECKED" : ""));
 }
 
 
@@ -128,6 +132,13 @@ struct icaltimetype icaltime_from_webform(char *prefix) {
        sprintf(vname, "%s_hour", prefix);      t.hour = atoi(bstr(vname));
        sprintf(vname, "%s_minute", prefix);    t.minute = atoi(bstr(vname));
 
+       sprintf(vname, "%s_alldayevent", prefix);
+       if (!strcasecmp(bstr(vname), "yes")) {
+               t.hour = 0;
+               t.minute = 0;
+               t.is_date = 1;
+       }
+
        t = icaltime_normalize(t);
        return(t);
 }
index ed5fd34e82e57d44490bd5778862a245fc3c1e72..d43e4910320d3bba7e3b30d82710f15b9f613378 100644 (file)
@@ -205,21 +205,57 @@ void calendar_week_view(int year, int month, int day) {
 }
 
 
-void calendar_day_view(int year, int month, int day) {
-       struct tm starting_tm;
-       time_t thetime;
+/*
+ * Display events for a particular hour of a particular day.
+ * (Specify hour < 0 to show "all day" events)
+ */
+void calendar_day_view_display_events(int year, int month,
+                                       int day, int hour) {
        int i;
+       icalproperty *p;
+       struct icaltimetype t;
 
-       /* Determine what day we're viewing.
-        */
-       memset(&starting_tm, 0, sizeof(struct tm));
-       starting_tm.tm_year = year - 1900;
-       starting_tm.tm_mon = month - 1;
-       starting_tm.tm_mday = day;
-       thetime = mktime(&starting_tm);
+       if (WC->num_cal == 0) {
+               wprintf("<BR><BR><BR>\n");
+               return;
+       }
+
+       for (i=0; i<(WC->num_cal); ++i) {
+               p = icalcomponent_get_first_property(WC->disp_cal[i],
+                                               ICAL_DTSTART_PROPERTY);
+               if (p != NULL) {
+                       t = icalproperty_get_dtstart(p);
+                       if ((t.year == year)
+                          && (t.month == month)
+                          && (t.day == day)
+                          && ( (t.hour == hour) || ((hour<0)&&(t.is_date)) )
+                          ) {
+
+                               p = icalcomponent_get_first_property(
+                                                       WC->disp_cal[i],
+                                                       ICAL_SUMMARY_PROPERTY);
+                               if (p != NULL) {
+                                       wprintf("<FONT SIZE=-1>"
+                                               "<A HREF=\"/display_edit_event?msgnum=%ld&calview=day&year=%d&month=%d&day=%d\">",
+                                               WC->cal_msgnum[i],
+                                               year, month, day
+                                       );
+                                       escputs((char *)
+                                               icalproperty_get_comment(p));
+                                       wprintf("</A></FONT>\n");
+                               }
+
+                       }
+
+
+               }
+       }
+}
 
 
-/**********************************************************************/
+
+void calendar_day_view(int year, int month, int day) {
+       int hour;
 
        /* Outer table (to get the background color) */
        wprintf("<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
@@ -253,16 +289,32 @@ void calendar_day_view(int year, int month, int day) {
                "<TABLE width=100%% border=0 cellpadding=1 cellspacing=1 "
                "bgcolor=#4444FF>\n");
 
-       /* Now do 7 hours */
-       for (i = 0; i < 7; ++i) {
-               wprintf("<TR><TD BGCOLOR=FFFFFF HEIGHT=60 VALIGN=TOP>");
+       /* Display events before 8:00 (hour=-1 is all-day events) */
+       wprintf("<TR><TD BGCOLOR=FFFFFF VALIGN=TOP>");
+       for (hour = (-1); hour <= 7; ++hour) {
+               calendar_day_view_display_events(year, month, day, hour);
+       }
+       wprintf("</TD></TR>\n");
 
-               /* put the data here, stupid  ... FIXME add hour */
-               calendar_month_view_display_events(thetime);
+       /* Now the middle of the day... */      
+       for (hour = 8; hour <= 17; ++hour) {    /* could do HEIGHT=xx */
+               wprintf("<TR><TD BGCOLOR=FFFFFF VALIGN=TOP>");
+               wprintf("%d:00 ", hour);
+
+               /* put the data here, stupid */
+               calendar_day_view_display_events(year, month, day, hour);
 
                wprintf("</TD></TR>\n");
        }
 
+       /* Display events after 5:00... */
+       wprintf("<TR><TD BGCOLOR=FFFFFF VALIGN=TOP>");
+       for (hour = 18; hour <= 23; ++hour) {
+               calendar_day_view_display_events(year, month, day, hour);
+       }
+       wprintf("</TD></TR>\n");
+
+
        wprintf("</TABLE>"                      /* end of innermost table */
                "</TD></TR></TABLE>"            /* end of inner table */
                "</TD></TR></TABLE>"            /* end of outer table */
index d9ae239f8da0a4c30fb59ee4ab8d0b52e495a0b5..df2b63a21eef3ae0702c7270cf9233bcb91fb727 100644 (file)
@@ -70,16 +70,20 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"day\" VALUE=\"%s\">\n",
                bstr("day"));
 
-       wprintf("Summary: "
+
+       /* Put it in a borderless table so it lines up nicely */
+       wprintf("<TABLE border=0 width=100%%>\n");
+
+       wprintf("<TR><TD><B>Summary</B></TD><TD>\n"
                "<INPUT TYPE=\"text\" NAME=\"summary\" "
                "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
        p = icalcomponent_get_first_property(vevent, ICAL_SUMMARY_PROPERTY);
        if (p != NULL) {
                escputs((char *)icalproperty_get_comment(p));
        }
-       wprintf("\"><BR>\n");
+       wprintf("\"></TD></TR>\n");
 
-       wprintf("Start date/time: ");
+       wprintf("<TR><TD><B>Start</B></TD><TD>\n");
        p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY);
        if (p != NULL) {
                t = icalproperty_get_dtstart(p);
@@ -88,9 +92,9 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
                t = icaltime_from_timet(now, 0);
        }
        display_icaltimetype_as_webform(&t, "dtstart");
-       wprintf("<BR>\n");
+       wprintf("</TD></TR>\n");
 
-       wprintf("End date/time: ");
+       wprintf("<TR><TD><B>End</B></TD><TD>\n");
        p = icalcomponent_get_first_property(vevent, ICAL_DTEND_PROPERTY);
        if (p != NULL) {
                t = icalproperty_get_dtend(p);
@@ -99,18 +103,20 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
                t = icaltime_from_timet(now, 0);
        }
        display_icaltimetype_as_webform(&t, "dtend");
-       wprintf("<BR>\n");
+       wprintf("</TD></TR>\n");
 
-       wprintf("<CENTER><TEXTAREA NAME=\"description\" wrap=soft "
+       wprintf("<TR><TD><B>Notes</B></TD><TD>\n"
+               "<TEXTAREA NAME=\"description\" wrap=soft "
                "ROWS=10 COLS=80 WIDTH=80>\n"
        );
        p = icalcomponent_get_first_property(vevent, ICAL_DESCRIPTION_PROPERTY);
        if (p != NULL) {
                escputs((char *)icalproperty_get_comment(p));
        }
-       wprintf("</TEXTAREA><BR>\n");
+       wprintf("</TEXTAREA></TD></TR></TABLE>\n");
 
-       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save\">"
+       wprintf("<CENTER>"
+               "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save\">"
                "&nbsp;&nbsp;"
                "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">\n"
                "&nbsp;&nbsp;"