| |
111 |
111 |
if { |
| |
112 |
112 |
( [info exists object_query] && ![info exists object_ids] && ![info exists object_id] ) || |
| |
113 |
113 |
( ![info exists object_query] && [info exists object_ids] && ![info exists object_id] ) || |
| |
114 |
114 |
( ![info exists object_query] && [info exists object_ids] && ![info exists object_id] ) |
| |
115 |
115 |
} { |
| |
116 |
116 |
# we only have one provided object_id list, this is correct set up |
| |
117 |
117 |
} else { |
| |
118 |
118 |
# error "packages/tasks/lib/tasks - invalid include you must specify one (and only one) of the following: object_query, object_ids, object_id :: $object_id" |
| |
119 |
119 |
} |
| |
120 |
120 |
|
| |
121 |
121 |
set single_object_p 0 |
| |
122 |
122 |
if { [info exists object_ids] } { |
| |
123 |
123 |
set object_query [template::util::tcl_to_sql_list $object_ids] |
| |
124 |
124 |
} elseif { [info exists object_id] } { |
| |
125 |
125 |
set single_object_p 1 |
| |
126 |
126 |
set object_query '$object_id' |
| |
127 |
127 |
} |
| |
128 |
128 |
|
| |
129 |
129 |
append limitations_clause "\n and t.object_id in ( $object_query )" |
| |
130 |
130 |
|
| |
131 |
|
# you may specify a list of assignees as well if you like, they are similar to the object |
| |
132 |
|
# queries and ids this is not required. You may only specify one of the following, assignee_query, assignee_ids, assignee_id |
| |
133 |
131 |
|
| |
134 |
|
if { [info exists assignee_query] || [info exists assignee_ids] || [info exists assignee_id] } { |
| |
135 |
|
if { |
| |
136 |
|
( [info exists assignee_query] && ![info exists assignee_ids] && ![info exists assignee_id] ) || |
| |
137 |
|
( ![info exists assignee_query] && [info exists assignee_ids] && ![info exists assignee_id] ) || |
| |
138 |
|
( ![info exists assignee_query] && [info exists assignee_ids] && ![info exists assignee_id] ) |
| |
139 |
|
} { |
| |
140 |
|
# we only have one provided object_id list, this is correct set up |
| |
141 |
|
} else { |
| |
142 |
|
error "packages/tasks/lib/tasks - invalid include you must specify one (and only one) of the following: assignee_query, assignee_ids, assignee_id" |
| |
143 |
|
} |
| |
144 |
|
|
| |
145 |
|
if { [info exists assignee_ids] } { |
| |
146 |
|
set assignee_query [template::util::tcl_to_sql_list $object_ids] |
| |
147 |
|
} elseif { [info exists object_id] } { |
| |
148 |
|
set assignee_query '$object_id' |
| |
149 |
|
} |
| |
150 |
|
|
| |
151 |
|
if { [exists_and_not_null assignee_query] } { |
| |
152 |
|
append limitations_clause "\n and t.assignee_id in ( $assignee_query )" |
| |
153 |
|
} |
| |
154 |
|
} |
| |
155 |
|
|
| |
156 |
132 |
append limitations_clause "\n and ao.package_id = [ad_conn package_id]" |
| |
157 |
133 |
|
| |
158 |
134 |
if { $start_date ne "" } { |
| |
159 |
135 |
append limitations_clause "\n and CASE WHEN t.status_id <> '2' THEN t.due_date::date ELSE t.completed_date::date END >= '$start_date'::date" |
| |
160 |
136 |
} |
| |
161 |
137 |
|
| |
162 |
138 |
if { $end_date ne "" } { |
| |
163 |
139 |
append limitations_clause "\n and CASE WHEN t.status_id <> '2' THEN t.due_date::date ELSE t.completed_date::date END <= '$end_date'::date" |
| |
164 |
140 |
} |
| |
165 |
141 |
|
| |
166 |
142 |
|
| |
167 |
143 |
|
| |
168 |
144 |
|
| |
169 |
145 |
|
| |
170 |
146 |
|
| |
171 |
147 |
# before doing anything we check for the special vars task_action and task_action_id |
| |
172 |
148 |
# these actions are performed here because it requires less code to maintain just this |
| |
173 |
149 |
# one page, instead of routing to specialized pages. |
| |
174 |
150 |
# |
| |
175 |
151 |
# we are also able to verify that this user is in fact able to perform this action |
|
| |
277 |
253 |
|
| |
278 |
254 |
|
| |
279 |
255 |
|
| |
280 |
256 |
|
| |
281 |
257 |
|
| |
282 |
258 |
#if { ![exists_and_not_null tasks_previous] } { |
| |
283 |
259 |
# set tasks_previous 0 |
| |
284 |
260 |
#} |
| |
285 |
261 |
#if { ![exists_and_not_null tasks_future] } { |
| |
286 |
262 |
# set tasks_future 7 |
| |
287 |
263 |
#} |
| |
288 |
264 |
#if { ![exists_and_not_null orderby] } { |
| |
289 |
265 |
# set orderby "priority,desc" |
| |
290 |
266 |
#} |
| |
291 |
267 |
#if { ![exists_and_not_null status_id] } { |
| |
292 |
268 |
# set status_id "1" |
| |
293 |
269 |
#} |
| |
294 |
270 |
|
| |
295 |
271 |
|
| |
296 |
272 |
|
| |
|
273 |
# you may specify a list of assignees as well if you like, they are similar to the object |
| |
|
274 |
# queries and ids this is not required. You may only specify one of the following, assignee_query, assignee_ids, assignee_id |
| |
|
275 |
if { [info exists assignee_query] || [info exists assignee_ids] || [info exists assignee_id] } { |
| |
|
276 |
if { |
| |
|
277 |
( [info exists assignee_query] && ![info exists assignee_ids] && ![info exists assignee_id] ) || |
| |
|
278 |
( ![info exists assignee_query] && [info exists assignee_ids] && ![info exists assignee_id] ) || |
| |
|
279 |
( ![info exists assignee_query] && [info exists assignee_ids] && ![info exists assignee_id] ) |
| |
|
280 |
} { |
| |
|
281 |
# we only have one provided object_id list, this is correct set up |
| |
|
282 |
} else { |
| |
|
283 |
error "packages/tasks/lib/tasks - invalid include you must specify one (and only one) of the following: assignee_query, assignee_ids, assignee_id" |
| |
|
284 |
} |
| |
297 |
285 |
|
| |
|
286 |
if { [info exists assignee_query] || [info exists assignee_ids] } { |
| |
|
287 |
# the users should be able to select from a list of assignees |
| |
|
288 |
if { ![info exists assignee_query] } { |
| |
|
289 |
set assignee_query [template::util::tcl_to_sql_list $assignee_ids] |
| |
|
290 |
} |
| |
|
291 |
set package_id [ad_conn package_id] |
| |
|
292 |
set selected_assignee_id [ns_queryget selected_assignee_id] |
| |
|
293 |
set assignees [db_list_of_lists get_them " select contact__name( party_id ), |
| |
|
294 |
party_id |
| |
|
295 |
from parties |
| |
|
296 |
where party_id in ( $assignee_query ) |
| |
|
297 |
and party_id in ( |
| |
|
298 |
select t_tasks.assignee_id |
| |
|
299 |
from t_tasks |
| |
|
300 |
where t_tasks.object_id in ( $object_query ))"] |
| |
|
301 |
set filters_list [list selected_assignee_id [list label [_ tasks.Assignee] values [concat [list [list "- - - -" ""]] $assignees]]] |
| |
|
302 |
} |
| |
|
303 |
if { [exists_and_not_null selected_assignee_id] } { |
| |
|
304 |
set assignee_query '${selected_assignee_id}' |
| |
|
305 |
} else { |
| |
|
306 |
if { [info exists assignee_ids] } { |
| |
|
307 |
set assignee_query [template::util::tcl_to_sql_list $assignee_ids] |
| |
|
308 |
} elseif { [info exists assignee_id] } { |
| |
|
309 |
set assignee_query '$assignee_id' |
| |
|
310 |
} |
| |
|
311 |
} |
| |
298 |
312 |
|
| |
|
313 |
if { [exists_and_not_null assignee_query] } { |
| |
|
314 |
append limitations_clause "\n and t.assignee_id in ( $assignee_query )" |
| |
|
315 |
} |
| |
|
316 |
} |
| |
299 |
317 |
|
| |
300 |
318 |
|
| |
301 |
319 |
|
| |
302 |
320 |
|
| |
|
321 |
|
| |
|
322 |
|
| |
303 |
323 |
set row_list [list] |
| |
304 |
324 |
foreach element [list checkbox deleted_p priority title process_title object_name date assignee] { |
| |
305 |
325 |
if { $single_object_p && $element == "object_name" } { |
| |
306 |
326 |
} elseif { [lsearch $hide_elements $element] < 0 } { |
| |
307 |
327 |
lappend row_list $element {} |
| |
308 |
328 |
} |
| |
309 |
329 |
} |
| |
310 |
330 |
|
| |
311 |
331 |
|
| |
312 |
332 |
set status_options [db_list_of_lists status_options {}] |
| |
313 |
333 |
set status_options [lang::util::localize $status_options] |
| |
314 |
334 |
# by default we only show pending tasks |
| |
315 |
335 |
lappend filters_list status_id [list label [_ tasks.Status] values $status_options where_clause { t.status_id = :status_id } default_value "1"] |
| |
316 |
336 |
|
| |
317 |
|
|
| |
|
337 |
#lappend filters_list |
| |
318 |
338 |
if { [lsearch $hide_elements checkbox] >= 0 } { |
| |
319 |
339 |
set bulk_actions [list] |
| |
320 |
340 |
} else { |
| |
321 |
341 |
set bulk_actions [list "[_ tasks.Change_Assignee]" "tasks-change-assignee" "[_ tasks.Change_Assignee]"] |
| |
322 |
342 |
lappend bulk_actions "[_ tasks.Delete]" "tasks-delete" "[_ tasks.Delete]" |
| |
323 |
343 |
} |
| |
324 |
344 |
template::list::create \ |
| |
325 |
345 |
-name tasks \ |
| |
326 |
346 |
-multirow tasks \ |
| |
327 |
347 |
-bulk_actions $bulk_actions \ |
| |
328 |
348 |
-bulk_action_export_vars {return_url} \ |
| |
329 |
349 |
-key task_id \ |
| |
330 |
350 |
-selected_format "normal" \ |
| |
331 |
351 |
-orderby_name tasks_orderby \ |
| |
332 |
352 |
-page_size $page_size \ |
| |
333 |
353 |
-page_flush_p $page_flush_p \ |
| |
334 |
354 |
-page_query_name tasks_pagination \ |
| |
335 |
355 |
-elements { |
| |
336 |
356 |
deleted_p { |
| |
337 |
357 |
label {<img src="/resources/acs-subsite/checkboxchecked.gif" alt="[_ tasks.Not_Done]" border="0" height="13" width="13">} |