Index: openacs-4/contrib/packages/project-manager/tcl/project-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/tcl/Attic/project-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/project-manager/tcl/project-procs.tcl 26 Aug 2003 00:05:58 -0000 1.1 @@ -0,0 +1,127 @@ +ad_library { + + Project Manager Projects Library + + Procedures that deal with projects + + @creation-date 2003-08-25 + @author Jade Rubick + @cvs-id $Id: project-procs.tcl,v 1.1 2003/08/26 00:05:58 jader Exp $ + +} + +namespace eval project_manager::project {} + + +ad_proc -public project_manager::project::compute_status {project_item_id} { + Looks at tasks and subprojects, and computes the current status of a project. + + These are the items we'd like to compute + + estimated_completion_date timestamptz, + earliest_completion_date timestamptz, + latest_completion_date timestamptz, + actual_hours_completed numeric, + estimated_hours_total numeric + + loop through all items that have parent_id equal to this item + if a subproject, + then call compute_status(subproject) + use statistics from that project + if a task + then use statistics + + after loop, then compute statistics for this project + save values to database +} { + ns_log Notice "computing status for $project_item_id" + + set project_list [list] + set task_list [list] + + foreach sub_item [db_list_of_lists select_project_children { }] { + set my_id [lindex $sub_item 0] + set my_type [lindex $sub_item 1] + + if {[string equal $my_type "pm_project"]} { + + set project_return [project_manager::project::compute_status $my_id] + lappend project_list $my_id + ns_log Notice "added project to list $my_id" + + } elseif {[string equal $my_type "pm_task"]} { + lappend task_list $my_id + } + } + + # -------------------------------- + # get information from subprojects + # -------------------------------- + set projects_total_hours_worked 0 + + if {[llength $project_list] > 0} { + db_1row projects_query { } + ns_log Notice "Project total hours: $projects_total_hours_worked" + } else { + ns_log Notice "No subprojects" + } + + # -------------------------- + # get information from tasks - note currently no support for subtasks + # -------------------------- + set tasks_total_hours_worked 0 + + if {[llength $task_list] > 0} { + db_1row tasks_query { } + ns_log Notice "Tasks total hours: $tasks_total_hours_worked" + } else { + ns_log Notice "No tasks" + } + + # estimated_completion_date timestamptz, + # earliest_completion_date timestamptz, + # latest_completion_date timestamptz, + # actual_hours_completed numeric, + # estimated_hours_total numeric + + # now update projects + set total_hours_worked [expr $projects_total_hours_worked + $tasks_total_hours_worked] + + db_dml update_project { } + + return "ok" +} + + + + +ad_proc -public project_manager::project::compute_parent_status {project_item_id} { + + When a project is updated, or a task updated within a project, we need to + update all the projects higher in the hierarchy. +} { + ns_log Notice "computing parents for $project_item_id" + + set package_id [ad_conn package_id] + + set my_item_id $project_item_id + set parent_id [db_string get_parent_id {}] + set last_item_id $my_item_id + + # trace up the hierarchy until we get one below the root + + set root_folder [db_exec_plsql get_root_folder { }] + + while {$parent_id != $root_folder} { + set parent_id [db_string get_parent_id {}] + set last_item_id $my_item_id + set my_item_id $parent_id + } + + ns_log Notice "root: $root_folder , last_item_id $last_item_id" + + set return_code [compute_status $project_item_id] + + return $return_code +} + Index: openacs-4/contrib/packages/project-manager/www/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/index-postgresql.xql,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/project-manager/www/index-postgresql.xql 22 Aug 2003 21:06:10 -0000 1.4 +++ openacs-4/contrib/packages/project-manager/www/index-postgresql.xql 26 Aug 2003 00:05:58 -0000 1.5 @@ -12,14 +12,14 @@ p.object_type as content_type, p.title as project_name, p.project_code, - to_char(p.planned_start_date, 'YYYY MM DD') as planned_start_date, - to_char(p.planned_end_date, 'YYYY MM DD') as planned_end_date, + to_char(p.planned_start_date, 'Mon DD ''YY') as planned_start_date, + to_char(p.planned_end_date, 'Mon DD ''YY') as planned_end_date, p.ongoing_p, p.estimated_completion_date - p.planned_end_date as days_late, p.earliest_completion_date - p.planned_end_date as days_late_earliest, p.latest_completion_date - p.planned_end_date as days_late_latest, - actual_hours_completed, - estimated_hours_total + p.actual_hours_completed, + p.estimated_hours_total FROM pm_projectsx p, cr_items i WHERE p.project_id = i.live_revision ORDER BY i.tree_sortkey Index: openacs-4/contrib/packages/project-manager/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/index.adp,v diff -u -r1.10 -r1.11 --- openacs-4/contrib/packages/project-manager/www/index.adp 23 Aug 2003 00:24:34 -0000 1.10 +++ openacs-4/contrib/packages/project-manager/www/index.adp 26 Aug 2003 00:05:58 -0000 1.11 @@ -14,9 +14,8 @@ Project Project Code Status - Start Date (planned) - End Date (planned) - On-going? + Start Date + End Date @@ -35,17 +34,21 @@  @projects.project_code@ + @projects.actual_hours_completed@ hrs @projects.days_late@ + + + Ongoing + +  @projects.planned_start_date@  @projects.planned_end_date@ - -  @projects.ongoing_p@ - + Index: openacs-4/contrib/packages/project-manager/www/one-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/one-postgresql.xql,v diff -u -r1.9 -r1.10 --- openacs-4/contrib/packages/project-manager/www/one-postgresql.xql 23 Aug 2003 00:24:34 -0000 1.9 +++ openacs-4/contrib/packages/project-manager/www/one-postgresql.xql 26 Aug 2003 00:05:58 -0000 1.10 @@ -1,5 +1,6 @@ + SELECT @@ -40,7 +41,9 @@ p.estimated_completion_date, p.earliest_completion_date, p.latest_completion_date, - p.estimated_hours_total + p.actual_hours_completed, + p.estimated_hours_total, + p.parent_id FROM pm_projectsx p, cr_items i WHERE @@ -100,4 +103,35 @@ t.end_date,t.title + + + + select pm_project__get_root_folder (:package_id, 'f') + + + + + + SELECT + p.item_id, + p.project_id, + p.parent_id as folder_id, + p.object_type as content_type, + p.title as project_name, + p.project_code, + to_char(p.planned_start_date, 'Mon DD ''YY') as planned_start_date, + to_char(p.planned_end_date, 'Mon DD ''YY') as planned_end_date, + p.ongoing_p, + p.estimated_completion_date - p.planned_end_date as days_late, + p.earliest_completion_date - p.planned_end_date as days_late_earliest, + p.latest_completion_date - p.planned_end_date as days_late_latest, + p.actual_hours_completed, + p.estimated_hours_total + FROM pm_projectsx p, cr_items i + WHERE p.project_id = i.live_revision and + p.parent_id = :project_item_id + ORDER BY p.title + + + Index: openacs-4/contrib/packages/project-manager/www/one.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/one.adp,v diff -u -r1.16 -r1.17 --- openacs-4/contrib/packages/project-manager/www/one.adp 23 Aug 2003 00:24:34 -0000 1.16 +++ openacs-4/contrib/packages/project-manager/www/one.adp 26 Aug 2003 00:05:58 -0000 1.17 @@ -69,13 +69,21 @@ @project.latest_completion_date@ + + Actual hours completed + @project.actual_hours_completed@ + +

Edit -Breakdown + Breakdown

+ + Subprojects: + Index: openacs-4/contrib/packages/project-manager/www/one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/one.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/contrib/packages/project-manager/www/one.tcl 23 Aug 2003 00:24:34 -0000 1.10 +++ openacs-4/contrib/packages/project-manager/www/one.tcl 26 Aug 2003 00:05:58 -0000 1.11 @@ -23,6 +23,7 @@ project_item_id:integer,optional project_id:integer,optional + {orderby_subproject ""} } -properties { context_bar:onevalue @@ -36,22 +37,19 @@ project_id:onevalue } -validate { project_item_id_exists { - if {![info exists project_item_id]} { + if {![exists_and_not_null project_item_id]} { set project_item_id [db_string get_item_id { }] } } project_id_exists { - if {![info exists project_id]} { + if {![exists_and_not_null project_id]} { set project_id [db_string get_project_id { }] } } } # --------------------------------------------------------------- # -# set up context bar -set context_bar [ad_context_bar "View"] - # the unique identifier for this package set package_id [ad_conn package_id] set user_id [ad_maybe_redirect_for_registration] @@ -66,12 +64,18 @@ set write_p [permission::permission_p -object_id $package_id -privilege write] set create_p [permission::permission_p -object_id $package_id -privilege create] - db_1row project_query { } -column_array project +set project_root [db_exec_plsql get_root_folder { }] db_multirow versions project_versions { } +# set up context bar, needs parent_id +if {[string equal $project(parent_id) $project_root]} { + set context_bar [ad_context_bar "View"] +} else { + set context_bar [ad_context_bar [list "one?project_item_id=$project(parent_id)" "Parent"] "View"] +} # Tasks, using list-builder --------------------------------- @@ -82,30 +86,27 @@ -multirow tasks \ -key item_id \ -elements { - item_id { - label "ID" + title { + label "Subject" + display_col title + link_url_col item_url + link_html { title "View this task" } display_template { - + - + - + - + - \#@tasks.item_id@ + @tasks.title@ } } - title { - label "Subject" - display_col title - link_url_col item_url - link_html { title "View this task" } - } percent_complete { label "Status" display_template "@tasks.percent_complete@\%" @@ -125,10 +126,9 @@ } } \ -orderby { - item_id {orderby item_id} percent_complete {orderby percent_complete} end_date {orderby end_date} - default_value item_id,desc + default_value end_date,desc } \ -orderby_name orderby_tasks \ -html { @@ -143,8 +143,42 @@ +# Subprojects, using list-builder --------------------------------- +db_multirow subproject project_subproject_query { } +template::list::create \ + -name subproject \ + -multirow subproject \ + -key item_id \ + -elements { + project_name { + label "Subject" + link_url_col item_url + link_html { title "View this subproject" } + } + actual_hours_completed { + label "Hours completed" + } + } \ + -orderby { + project_name {orderby project_name} + default_value project_name,desc + } \ + -orderby_name orderby_subproject \ + -html { + width 100% + } + + + +db_multirow -extend { item_url } subproject project_subproject_query { +} { + set item_url [export_vars -base "one" -override {{project_item_id $item_id}} {project_item_id}] +} + + + ad_return_template # ------------------------- END OF FILE ------------------------- # Index: openacs-4/contrib/packages/project-manager/www/task-add-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/task-add-edit.adp,v diff -u -r1.5 -r1.6 --- openacs-4/contrib/packages/project-manager/www/task-add-edit.adp 23 Aug 2003 00:24:34 -0000 1.5 +++ openacs-4/contrib/packages/project-manager/www/task-add-edit.adp 26 Aug 2003 00:05:58 -0000 1.6 @@ -28,10 +28,19 @@

- Work required:
Min: hrs
Max: hrs - + Work required:
+ + + + + + + +
Min: hrs
Max: hrs
+Skip adding constraints to tasks? + Index: openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/task-add-edit.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 23 Aug 2003 00:24:34 -0000 1.10 +++ openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 26 Aug 2003 00:05:58 -0000 1.11 @@ -31,6 +31,7 @@ percent_complete:array,optional estimated_hours_work_min:array,optional estimated_hours_work_max:array,optional + {skip_constraints ""} } -properties { context_bar:onevalue @@ -142,6 +143,10 @@ {value $number} } + {skip_constraints_p:text(checkbox) + {label "Skip adding constraints?"} + {value "t"}} + } -on_submit { set user_id [ad_conn user_id] @@ -154,12 +159,19 @@ lappend task_revisions [db_exec_plsql new_task_item { *SQL* }] } + project_manager::project::compute_parent_status $project_item_id + } -edit_data { } -select_query_name task_query -after_submit { - - ad_returnredirect "task-constraint-add-edit?[export_vars -url {task_revisions:multiple project_item_id}]" - ad_script_abort + + if {[string equal $skip_constraints_p "t"]} { + ad_returnredirect "one?[export_vars -url {project_item_id}]" + ad_script_abort + } else { + ad_returnredirect "task-constraint-add-edit?[export_vars -url {task_revisions:multiple project_item_id}]" + ad_script_abort + } } for {set i 0} {$i <= $number} {incr i} { Index: openacs-4/contrib/packages/project-manager/www/task-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/task-edit.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/project-manager/www/task-edit.tcl 21 Aug 2003 22:34:43 -0000 1.4 +++ openacs-4/contrib/packages/project-manager/www/task-edit.tcl 26 Aug 2003 00:05:58 -0000 1.5 @@ -117,6 +117,8 @@ db_exec_plsql new_task_revision { *SQL* } + project_manager::project::compute_parent_status $project_item_id + } -select_query_name task_query -after_submit { ad_returnredirect "task-one?task_id=$task_id"