Index: openacs-4/packages/project-manager/lib/all-party-tasks.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/project-manager/lib/all-party-tasks.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/project-manager/lib/all-party-tasks.adp 10 Nov 2005 22:55:46 -0000 1.1 @@ -0,0 +1 @@ + Index: openacs-4/packages/project-manager/lib/all-party-tasks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/project-manager/lib/all-party-tasks.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/project-manager/lib/all-party-tasks.tcl 10 Nov 2005 22:55:46 -0000 1.1 @@ -0,0 +1,382 @@ +# Author: Miguel Marin (miguelmarin@viaro.net) +# Author: Viaro Networs www.viaro.net +# creation_date: 2005-11-10 +# +# Description: Display all tasks across all projects in all project-manager instances +# where a party id is currently working on. +# +# Required Values: +# --------------- +# from_party_id To get the tasks from. +# +# +# Pagination and orderby: +# ---------------------- +# page The page to show on the paginate. +# page_size The number of rows to display in the list +# pt_orderby To sort the list using this orderby value +# orderby_p Boolean that indicates if you want to have the +# orderby functionallity or not, default 't' +# +# +# Other Values: +# ------------- +# elements A list of the elements to show in the list. +# format The format of the listtemplate layout. Default to "normal" + + + +set required_param_list [list from_party_id] +set optional_param_list [list pt_orderby page page_size format orderby_p] +set optional_unset_list [list] + +foreach required_param $required_param_list { + if {![info exists $required_param]} { + return -code error "$required_param is a required parameter." + } +} + +foreach optional_param $optional_param_list { + if {![info exists $optional_param]} { + set $optional_param {} + } +} + +foreach optional_unset $optional_unset_list { + if {[info exists $optional_unset]} { + if {[empty_string_p [set $optional_unset]] || [set $optional_unset] == 0} { + unset $optional_unset + } + } +} + +if { ![exists_and_not_null orderby_p] } { + set orderby_p "t" +} + +set default_orderby [pm::task::default_orderby] + +if {[exists_and_not_null pt_orderby]} { + pm::task::default_orderby -set $pt_orderby +} + +if ![exists_and_not_null page_size] { + set page_size 15 +} + +if ![exists_and_not_null page] { + set page 1 +} + +if ![exists_and_not_null format] { + set format normal +} + +set user_id [ad_conn user_id] + +# how to get back here +set return_url [ad_return_url -qualified] + + +if ![exists_and_not_null elements] { + # Here are all elements available to show on the list + set elements [list \ + task_item_id \ + title \ + earliest_start \ + earliest_finish \ + latest_start \ + latest_finish \ + slack_time \ + end_date \ + status_type \ + status_description \ + days_remaining \ + hours_remaining \ + actual_days_worked \ + actual_hours_worked \ + project_item_id \ + priority \ + percent_complete \ + edit_url] +} + +set row_list [list] +foreach element $elements { + lappend row_list $element + lappend row_list [list] +} + +# Orderby's to use in +if { $orderby_p } { + set order_by_list [list \ + default_value $default_orderby \ + title { + label "[_ project-manager.Subject_1]" + orderby_desc "t.title desc, task_item_id" + orderby_asc "t.title asc, task_item_id" + default_direction asc + } \ + description { + label "[_ project-manager.Description]" + orderby_desc "t.description desc, task_item_id" + orderby_asc "t.description, task_item_id" + default_direction asc + } \ + slack_time { + label "[_ project-manager.Slack_1]" + orderby_desc "(latest_start - earliest_start) desc, task_item_id" + orderby_asc "(latest_start - earliest_start), task_item_id" + default_direction asc + } \ + status { + label "[_ project-manager.Status_1]" + orderby_desc "status desc, t.latest_finish desc, task_item_id" + orderby_asc "status asc, t.latest_finish desc, task_item_id" + default_direction asc + } \ + end_date { + orderby_asc "end_date, task_item_id asc" + orderby_desc "end_date desc, task_item_id desc" + default_direction asc + } \ + ] +} else { + set order_by_list [list] +} + +template::list::create \ + -name tasks \ + -multirow tasks \ + -key task_item_id \ + -orderby_name "pt_orderby" \ + -page_size $page_size \ + -page_flush_p 0 \ + -page_query_name "tasks_pagination" \ + -selected_format $format \ + -elements { + task_item_id { + label "[_ project-manager.number]" + link_url_col item_url + link_html {title "[_ project-manager.lt_View_this_project_ver]" } + display_template {@tasks.task_item_id@} + } + title { + label "[_ project-manager.Subject_1]" + display_template { + + @tasks.title@ + + + @tasks.title@ + + } + } + earliest_start { + label "[_ project-manager.Earliest_Start]" + display_template { + + @tasks.earliest_start_pretty@ + + + @tasks.earliest_start_pretty@ + + } + } + earliest_finish { + label "[_ project-manager.Earliest_Finish]" + display_template { + + @tasks.earliest_finish_pretty@ + + + @tasks.earliest_finish_pretty@ + + } + } + latest_start { + label "[_ project-manager.Latest_Start]" + display_template { + + @tasks.latest_start_pretty@ + + @tasks.latest_start_pretty@ + + } + } + latest_finish { + label "[_ project-manager.Latest_Finish]" + display_template { + + @tasks.latest_finish_pretty@ + + + @tasks.latest_finish_pretty@ + + } + } + end_date { + label "[_ project-manager.Deadline]" + display_template { + + @tasks.end_date_pretty@ + + + @tasks.end_date_pretty@ + + } + } + status_type { + label "[_ project-manager.Done_1]" + display_template { + + } + } + status_description { + label "[_ project-manager.Status_1]" + } + slack_time { + label "[_ project-manager.Slack_1]" + display_template { + + @tasks.slack_time@ + + + @tasks.slack_time@ + + } + } + priority { + label "[_ project-manager.Priority_1]" + display_template { + @tasks.priority@ + } + } + days_remaining { + label "[_ project-manager.Days_work]" + html { + align right + } + } + hours_remaining { + label "[_ project-manager.Hours_remaining]" + html { + align right + } + } + actual_days_worked { + label "[_ project-manager.Days_worked]" + html { + align right + } + } + actual_hours_worked { + label "[_ project-manager.Hours_worked]" + html { + align right + } + } + project_item_id { + label "[_ project-manager.Project_1]" + display_template {@tasks.project_name@} + hide_p {[ad_decode [exists_and_not_null project_item_id] 1 1 0]} + } + edit_url { + display_template {E} + } + percent_complete { + label "[_ project-manager.Percent_complete]" + } + } -orderby $order_by_list \ + -formats { + normal { + label "[_ project-manager.Table]" + layout table + row $row_list + } + } + +# Extend list of variables in the multirow +set extend_list [list \ + item_url \ + edit_url \ + earliest_start_pretty \ + earliest_finish_pretty \ + end_date_pretty \ + latest_start_pretty \ + latest_finish_pretty \ + slack_time \ + hours_remaining \ + days_remaining \ + actual_days_worked \ + base_url \ + task_close_url \ + project_url \ + red_title_p] + +db_multirow -extend $extend_list tasks tasks { } { + + set item_url [export_vars -base "task-one" {{task_id $task_item_id}}] + set edit_url [export_vars -base "task-add-edit" {{task_id $task_item_id} project_item_id return_url}] + + if {[parameter::get -parameter "UseDayInsteadOfHour"] == "f"} { + set fmt "%x %X" + } else { + set fmt "%x" + } + + set earliest_start_pretty [lc_time_fmt $earliest_start $fmt] + set earliest_finish_pretty [lc_time_fmt $earliest_finish $fmt] + set latest_start_pretty [lc_time_fmt $latest_start $fmt] + set latest_finish_pretty [lc_time_fmt $latest_finish $fmt] + set end_date_pretty [lc_time_fmt $end_date $fmt] + + set red_title_p 0 + set sysdate [dt_sysdate -format "%Y-%m-%d %H:%M:%S"] + if { [exists_and_not_null latest_start]} { + if { $sysdate > $latest_start } { + set red_title_p 1 + } + } else { + if { $sysdate > $end_date } { + set red_title_p 1 + } + } + + if {[exists_and_not_null earliest_start_j]} { + set slack_time [pm::task::slack_time \ + -earliest_start_j $earliest_start_j \ + -today_j $today_j \ + -latest_start_j $latest_start_j] + } else { + set slack_time "[_ project-manager.na]" + } + + if {![exists_and_not_null percent_complete]} { + set percent_complete 0 + } + + set hours_remaining \ + [pm::task::hours_remaining \ + -estimated_hours_work $estimated_hours_work \ + -estimated_hours_work_min $estimated_hours_work_min \ + -estimated_hours_work_max $estimated_hours_work_max \ + -percent_complete $percent_complete] + + set days_remaining \ + [pm::task::days_remaining \ + -estimated_hours_work $estimated_hours_work \ + -estimated_hours_work_min $estimated_hours_work_min \ + -estimated_hours_work_max $estimated_hours_work_max \ + -percent_complete $percent_complete] + + if {[exists_and_not_null actual_hours_worked]} { + set actual_days_worked [expr $actual_hours_worked / 24] + } else { + set actual_days_worked "" + } + acs_object::get -object_id $task_item_id -array task_array + set base_url [lindex [site_node::get_url_from_object_id -object_id $task_array(package_id)] 0] + set task_close_url [export_vars -base "${base_url}task-close" -url {task_item_id return_url}] + set project_url [export_vars -base "${base_url}one" {project_item_id $tasks(project_item_id)}] +} Index: openacs-4/packages/project-manager/lib/all-party-tasks.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/project-manager/lib/all-party-tasks.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/project-manager/lib/all-party-tasks.xql 10 Nov 2005 22:55:46 -0000 1.1 @@ -0,0 +1,139 @@ + + + + + + + SELECT + t.item_id as task_item_id, + t.parent_id as project_item_id, + t.title, + to_char(t.end_date,'YYYY-MM-DD HH24:MI:SS') as end_date, + to_char(t.earliest_start,'YYYY-MM-DD HH24:MI:SS') as earliest_start, + t.earliest_start - current_date as days_to_earliest_start, + to_char(t.earliest_start,'J') as earliest_start_j, + to_char(t.earliest_finish,'YYYY-MM-DD HH24:MI:SS') as earliest_finish, + t.earliest_finish - current_date as days_to_earliest_finish, + to_char(t.latest_start,'YYYY-MM-DD HH24:MI:SS') as latest_start, + t.latest_start - current_date as days_to_latest_start, + to_char(t.latest_start,'J') as latest_start_j, + to_char(current_date,'J') as today_j, + to_char(t.latest_finish,'YYYY-MM-DD HH24:MI:SS') as latest_finish, + t.latest_finish - current_date as days_to_latest_finish, + to_char(t.end_date,'YYYY-MM-DD HH24:MI:SS') as end_date, + t.end_date - current_date as days_to_end_date, + t.percent_complete, + t.estimated_hours_work, + t.estimated_hours_work_min, + t.estimated_hours_work_max, + t.actual_hours_worked, + s.status_type, + s.description as status_description, + r.is_lead_p, + r.is_observer_p, + t.priority, + t.party_id, + t.parent_id, + d.parent_task_id, + o.title as project_name + FROM + (select tr.item_id, + ta.party_id, + ta.role_id, + tr.title, + tr.end_date, + tr.earliest_start, + tr.earliest_finish, + tr.latest_start, + tr.latest_finish, + tr.percent_complete, + tr.estimated_hours_work, + tr.estimated_hours_work_min, + tr.estimated_hours_work_max, + tr.actual_hours_worked, + tr.parent_id, + tr.revision_id, + tr.description, + tr.priority + from cr_items ci, + pm_tasks_revisionsx tr + LEFT JOIN + pm_task_assignment ta ON tr.item_id = ta.task_id + -- get only live revisions + where ci.live_revision = tr.revision_id + [template::list::page_where_clause -and -name "tasks" -key "tr.item_id"]) t + LEFT JOIN + pm_roles r + ON t.role_id = r.role_id + LEFT JOIN + pm_task_dependency d + ON t.item_id = d.task_id, + pm_tasks_active ti, + pm_task_status s, + cr_items cp, + acs_objects o + WHERE + t.parent_id = cp.item_id + and t.item_id = ti.task_id + and ti.status = s.status_id + and ti.status = '1' + and cp.live_revision = o.object_id + and exists (select 1 from acs_object_party_privilege_map ppm + where ppm.object_id = ti.task_id + and ppm.privilege = 'read' + and ppm.party_id = :user_id) + and t.party_id = :from_party_id + [template::list::orderby_clause -name tasks -orderby] + + + + + + SELECT + t.item_id as task_item_id + FROM + (select tr.item_id, + ta.party_id, + ta.role_id, + tr.title, + tr.end_date, + tr.earliest_start, + tr.earliest_finish, + tr.latest_start, + tr.latest_finish, + tr.percent_complete, + tr.estimated_hours_work, + tr.estimated_hours_work_min, + tr.estimated_hours_work_max, + tr.actual_hours_worked, + tr.parent_id, + tr.revision_id, + tr.description, + tr.priority + from cr_items ci, pm_tasks_revisionsx tr + LEFT JOIN + pm_task_assignment ta ON tr.item_id = ta.task_id, pm_roles r + -- get only live revisions + where ci.live_revision = tr.revision_id + and ta.role_id = r.role_id + and exists (select 1 from acs_object_party_privilege_map ppm + where ppm.object_id = tr.item_id + and ppm.privilege = 'read' + and ppm.party_id = :user_id) + ) t, + pm_tasks_active ti, + pm_task_status s, + cr_items cp, + acs_objects o + WHERE + t.parent_id = cp.item_id + and t.item_id = ti.task_id + and ti.status = s.status_id + and ti.status = '1' + and t.party_id = :from_party_id + and cp.live_revision = o.object_id + [template::list::orderby_clause -name tasks -orderby] + + + + \ No newline at end of file