Index: openacs-4/packages/calendar-portlet/tcl/calendar-portlet-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/tcl/calendar-portlet-procs.tcl,v
diff -u -N -r1.10 -r1.11
--- openacs-4/packages/calendar-portlet/tcl/calendar-portlet-procs.tcl 12 Nov 2001 18:43:32 -0000 1.10
+++ openacs-4/packages/calendar-portlet/tcl/calendar-portlet-procs.tcl 12 Nov 2001 20:48:56 -0000 1.11
@@ -76,43 +76,44 @@
# otherwise, get the calendar_name for the give_id
set calendar_name [calendar_get_name $calendar_id]
set view $config(default_view)
-
- # big non-ported query, i'm bad
- db_foreach get_day_items "
- select to_char(start_date, 'HH24') as start_hour,
- to_char(start_date, 'HH24:MI') as pretty_start_date,
- to_char(end_date, 'HH24:MI') as pretty_end_date,
- nvl(e.name, a.name) as name,
- e.event_id as item_id
- from acs_activities a,
- acs_events e,
- timespans s,
- time_intervals t
- where e.timespan_id = s.timespan_id
- and s.interval_id = t.interval_id
- and e.activity_id = a.activity_id
- and start_date between
- to_date(:current_date,:date_format) and
- to_date(:current_date,:date_format) + (24 - 1/3600)/24
- and e.event_id
- in (
- select cal_item_id
- from cal_items
- where on_which_calendar = :calendar_id
- )" {
- ns_set put $set_id $start_hour \
- "
- $pretty_start_date - $pretty_end_date $name ($calendar_name)
-
"
- }
- # shaded_p support version 1
- if { $config(shaded_p) == "f" } {
-
+
+ if { $view == "day" } {
+ # big non-ported query, i'm bad
+ db_foreach get_day_items "
+ select to_char(start_date, 'HH24') as start_hour,
+ to_char(start_date, 'HH24:MI') as pretty_start_date,
+ to_char(end_date, 'HH24:MI') as pretty_end_date,
+ nvl(e.name, a.name) as name,
+ e.event_id as item_id
+ from acs_activities a,
+ acs_events e,
+ timespans s,
+ time_intervals t
+ where e.timespan_id = s.timespan_id
+ and s.interval_id = t.interval_id
+ and e.activity_id = a.activity_id
+ and start_date between
+ to_date(:current_date,:date_format) and
+ to_date(:current_date,:date_format) + (24 - 1/3600)/24
+ and e.event_id
+ in (
+ select cal_item_id
+ from cal_items
+ where on_which_calendar = :calendar_id
+ )" {
+ ns_set put $set_id $start_hour \
+ "
+ $pretty_start_date - $pretty_end_date $name ($calendar_name)
+
"
+ }
+
+ # shaded_p support version 1
+
set row_html "
- Time | Title |
+ Time | Title |
\n"
while {$i < $num_hour_rows} {
@@ -122,65 +123,237 @@
if {$i < 10} { set cal_hour "0$i" } else { set cal_hour "$i" }
# am or pm determination logic
- if {$i < 12} {
- if {$i == 0} {
- set time "12:00 am"
- } else {
- set time "$cal_hour:00 am"
- }
+ if {$i < 12} {
+ if {$i == 0} {
+ set time "12:00 am"
} else {
- if {$i == 12} {
- set time "12:00 pm"
- } else {
- set fm_hour [expr $i - 12]
- if {$fm_hour < 10} {
- set fm_hour "0$fm_hour"
- }
- set time "$fm_hour:00 pm"
- }
+ set time "$cal_hour:00 am"
}
+ } else {
+ if {$i == 12} {
+ set time "12:00 pm"
+ } else {
+ set fm_hour [expr $i - 12]
+ if {$fm_hour < 10} {
+ set fm_hour "0$fm_hour"
+ }
+ set time "$fm_hour:00 pm"
+ }
+ }
+
+ set cal_item_index [ns_set find $set_id $cal_hour]
+
+ append row_html "
+
+
+ $time
+ |
+ "
+
+ if {$cal_item_index == -1} {
+ append row_html " "
+ }
+
+ while {$cal_item_index > -1} {
+ append row_html "[ns_set value $set_id $cal_item_index]"
+ ns_set delete $set_id $cal_item_index
+ set cal_item_index [ns_set find $set_id $cal_hour]
+ }
+
+ append row_html " |
+
\n"
+
+ incr i
+ }
+
+ append row_html "
"
+
+ # aks - week support
+ } elseif { $view == "week" } {
+
+ db_1row get_weekday_info "
+ select to_char(to_date(:current_date, 'yyyy-mm-dd'), 'D')
+ as day_of_the_week,
+ to_char(next_day(to_date(:current_date, 'yyyy-mm-dd')-7, 'SUNDAY'))
+ as sunday_of_the_week,
+ to_char(next_day(to_date(:current_date, 'yyyy-mm-dd'), 'Saturday'))
+ as saturday_of_the_week
+ from dual
+ "
+
+ set mlist ""
+ set set_id [ns_set new week_items]
+
+ db_foreach get_day_items {
+ select to_char(start_date, 'J') as start_date,
+ to_char(start_date, 'HH24:MI') as pretty_start_date,
+ to_char(end_date, 'HH24:MI') as pretty_end_date,
+ nvl(e.name, a.name) as name,
+ e.event_id as item_id
+ from acs_activities a,
+ acs_events e,
+ timespans s,
+ time_intervals t
+ where e.timespan_id = s.timespan_id
+ and s.interval_id = t.interval_id
+ and e.activity_id = a.activity_id
+ and start_date between
+ to_date(:sunday_of_the_week,'YYYY-MM-DD') and
+ to_date(:saturday_of_the_week,'YYYY-MM-DD')
+ and e.event_id
+ in (
+ select cal_item_id
+ from cal_items
+ where on_which_calendar = :calendar_id
+ )
+ } {
+ ns_set put $set_id $start_date \
+ "
+ $pretty_start_date - $pretty_end_date $name ($calendar_name)
+ "
+ append items "
+ $pretty_start_date - $pretty_end_date $name ($calendar_name)
+
"
+ }
+
+ set num_hour_rows 7
+ set i 0
+
+ set bgcolor_html "bgcolor=DCDCDC"
+
+ set row_html "
+ "
+
+ while {$i < $num_hour_rows} {
- set cal_item_index [ns_set find $set_id $cal_hour]
-
+ set sql "
+ select
+ to_char(next_day(to_date(:current_date, 'yyyy-mm-dd')-7,
+ 'SUNDAY')+$i, 'DAY')
+ as weekday,
+ to_char(next_day(to_date(:current_date,
+ 'yyyy-mm-dd')-7, 'SUNDAY')+$i, 'YYYY-MM-DD')
+ as pretty_date,
+ to_char(next_day(to_date(:current_date, 'yyyy-mm-dd')-7,
+ 'SUNDAY')+$i, 'J')
+ as start_date
+ from dual
+ "
+ db_1row week_data $sql
append row_html "
+
+ $weekday
+ $pretty_date
+ |
+
+
-
- $time
- |
- "
+ | "
- if {$cal_item_index == -1} {
- append row_html " "
- }
-
- while {$cal_item_index > -1} {
- append row_html "[ns_set value $set_id $cal_item_index]"
+ set cal_item_index [ns_set find $set_id $start_date]
+
+ if {$cal_item_index == -1} { append row_html " " }
+
+ while {$cal_item_index > -1} {
+
+ append row_html [ns_set value $set_id $cal_item_index]
+
ns_set delete $set_id $cal_item_index
- set cal_item_index [ns_set find $set_id $cal_hour]
+ set cal_item_index [ns_set find $set_id $start_date]
}
- append row_html " |
-
\n"
-
+ append row_html "
+
+
+ "
+
incr i
- }
-
+ }
+
append row_html "
"
+ } elseif { $view == "month" } {
+
+ set set_id [ns_set new month_items]
+
+ db_foreach get_monthly_items "
+ select to_char(start_date, 'j') as start_date,
+ nvl(e.name, a.name) as name,
+ nvl(e.description, a.description) as description,
+ e.event_id as item_id
+ from acs_activities a,
+ acs_events e,
+ timespans s,
+ time_intervals t
+ where e.timespan_id = s.timespan_id
+ and s.interval_id = t.interval_id
+ and e.activity_id = a.activity_id
+ and e.event_id
+ in (
+ select cal_item_id
+ from cal_items
+ where on_which_calendar = :calendar_id
+ ) " {
+ ns_set put $set_id $start_date \
+ "
+ $name ($calendar_name)
+
"
+ }
- } else {
+ set row_html \
+ [dt_widget_month -header_text_size "+0" \
+ -calendar_details $set_id -date $date]
+
+ } elseif { $view == "list"} {
+
+ set items ""
+
+ db_foreach get_day_items "
+ select to_char(start_date, 'j') as start_date,
+ to_char(start_date, 'HH24:MI') as pretty_start_date,
+ to_char(end_date, 'HH24:MI') as pretty_end_date,
+ nvl(e.name, a.name) as name,
+ e.event_id as item_id
+ from acs_activities a,
+ acs_events e,
+ timespans s,
+ time_intervals t
+ where e.timespan_id = s.timespan_id
+ and s.interval_id = t.interval_id
+ and e.activity_id = a.activity_id
+ and start_date between
+ to_date(:current_date,:date_format) and
+ to_date(:current_date,:date_format) + (24 - 1/3600)/24
+ and e.event_id
+ in (
+ select cal_item_id
+ from cal_items
+ where on_which_calendar = :calendar_id
+ )" {
+ ns_set put $set_id $start_date \
+ "
+ $pretty_start_date - $pretty_end_date $name ($calendar_name)
+
"
+ append items "
+ $pretty_start_date - $pretty_end_date $name ($calendar_name)
+
"
+ }
+
+ set date [dt_systime]
+
+ set row_html "For $date: $items"
+ }
+
+ if { $config(shaded_p) == "t" } {
# shaded_p
set row_html ""
}
- set template "
- $row_html
- "
-
+ set template "$row_html"
+
set code [template::adp_compile -string $template]
set output [template::adp_eval code]
return $output
-
}
ad_proc -public edit {
@@ -205,7 +378,6 @@
day
week
month
- year
list
"
}
@@ -216,7 +388,6 @@
day
week
month
- year
list
"
}
@@ -227,30 +398,17 @@
day
week
month
- year
list
"
}
- "year" {
- set html "Set default view to:
-
-
- day
- week
- month
- year
- list
- "
- }
"list" {
set html "Set default view to:
day
week
month
- year
list
"
}