lars
committed
on 29 Apr 04
Fixed bug with sorting bugs list
openacs-4/.../calendar/www/cal-dayview.tcl (+9 -11)
9 9     @cvs-id $Id$
10 10 } {
11 11     {date now}
12 12     {view day}
13 13     {calendar_id:integer "-1"}
14 14     {calendar_list:multiple,optional {}}
15 15 } -properties {
16 16     row_html:onevalue
17 17     date:onevalue
18 18 }
19 19
20 20 if { $date ==  "now"} {
21 21     set date [dt_sysdate]
22 22 }
23 23
24 24
25 25 #-------------------------------------------------
26 26 # find out the user_id
27 27 set user_id [ad_verify_and_get_user_id]
28 28
29  
30 29 set current_date $date
31   set date_format "YYYY-MM-DD"
  30 set date_format "YYYY-MM-DD HH24:MI"
32 31
33 32 #get cal-item
34 33 set sql "
35 34 select   to_char(start_date, 'HH24') as start_hour,
36 35          to_char(start_date, 'HH24:MI') as pretty_start_date,
37 36          to_char(end_date, 'HH24:MI') as pretty_end_date,
38 37          coalesce(e.name, a.name) as name,
39 38          e.event_id as item_id
40 39 from     acs_activities a,
41 40          acs_events e,
42 41          timespans s,
43 42          time_intervals t
44 43 where    e.timespan_id = s.timespan_id
45 44 and      s.interval_id = t.interval_id
46 45 and      e.activity_id = a.activity_id
47 46 and      start_date between
48 47          to_date(:current_date,:date_format) and
49 48          to_date(:current_date,:date_format) + (24 - 1/3600)/24
50 49 and      e.event_id
51 50 in       (
 
69 68 #where    e.timespan_id = s.timespan_id
70 69 #and      s.interval_id = t.interval_id
71 70 #and      e.activity_id = a.activity_id
72 71 #and      start_date between
73 72 #         to_date(:current_date,:date_format) and
74 73 #         to_date(:current_date,:date_format) + (24 - 1/3600)/24
75 74 #and      e.event_id
76 75 #in       (
77 76 #         select  cal_item_id
78 77 #         from    cal_items
79 78 #         where   on_which_calendar = :calendar_id
80 79 #         )
81 80 #"
82 81
83 82
84 83
85 84 set mlist ""
86 85 set set_id [ns_set new day_items]
87 86
88 87
89  
90 88 #-------------------------------------------------
91 89 # verifiy if the calendar_list has elements or not
92 90
93 91 if {[llength $calendar_list] == 0} {
94 92    
95 93     # in the case when there are no elements, we check the
96 94     # default, the calendar is set to -1
97 95
98 96     if { [string equal $calendar_id "-1"] } {
99 97         # find out the calendar_id of the private calendar
100 98         
101 99         set calendar_id [calendar_have_private_p -return_id 1 $user_id]
102 100         set calendar_name "Private"
103 101         
104 102     } else {
105 103
106 104         # otherwise, get the calendar_name for the give_id
107 105         set calendar_name [calendar_get_name $calendar_id]
108 106     }
109 107    
110 108     db_foreach get_day_items $sql {
111 109         ns_set put $set_id  $start_hour "<a href=?date=$date&action=edit&cal_item_id=$item_id>
112 110                                      $pretty_start_date - $pretty_end_date $name ($calendar_name)
  111
113 112                                      </a><br>"
114 113     } 
115 114 } else {
116 115
117 116     # when there are elements, we construct the query to extract all
118 117     # the cal_items associated with the calendar in which the given
119 118     # party has read permissions to.
120 119        
121 120     foreach item $calendar_list {
122 121         set calendar_id [lindex $item 0]
123 122         
124 123         if { [string equal $calendar_id "-1"] } {
125 124
126 125             # find out the calendar_id of the private calendar
127 126             set calendar_id [calendar_have_private_p -return_id 1 $user_id]
128 127             set calendar_name "Private"
129 128
130 129         } else {
131 130             set calendar_name [calendar_get_name $calendar_id]
132 131         }
133 132
134 133         db_foreach get_day_items $sql {
135 134             ns_set put $set_id  $start_hour "<a href=?action=edit&cal_item_id=$item_id>
136               $pretty_start_date - $pretty_end_date $name ($calendar_name)
  135             $pretty_start_time - $pretty_end_date $name ($calendar_name)
137 136             </a><br>"
138 137         }
139 138
140 139     }
141 140 }
142 141
143 142
144 143 #-------------------------------------------------
145 144 #
146 145 set num_hour_rows 24
147 146 set i 0
148 147
149 148 set bgcolor_html "border=1 color=blue"
150 149
151 150 set row_html "
152 151 <table cellpadding=2 cellspacing=0 border=1 width=500>
153 152 <tr>
154 153   <td width=90>
155 154     <b>Time</b>
156 155   </td>