Index: openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/sql/postgresql/Attic/project-manager-drop.sql,v diff -u -r1.9 -r1.10 --- openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-drop.sql 12 Sep 2003 01:20:56 -0000 1.9 +++ openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-drop.sql 15 Sep 2003 23:09:56 -0000 1.10 @@ -16,12 +16,30 @@ drop sequence pm_task_dependency_seq; drop sequence pm_tasks_number_seq; +------------- -- WORKGROUPS +------------- drop sequence pm_workgroup_seq; drop table pm_workgroup_parties; drop table pm_workgroup; +------------ +-- PROCESSES +------------ + +drop sequence pm_process_seq; +drop sequence pm_process_task_seq; +drop sequence pm_process_task_dependency_seq; + +drop table pm_process_task_assignment; +drop table pm_process_task_dependency; +drop table pm_process_task; +drop table pm_process; + +--------- +-- OTHERS +--------- drop table pm_default_roles; drop table pm_project_assignment; drop table pm_task_assignment; Index: openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-table-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/sql/postgresql/Attic/project-manager-table-create.sql,v diff -u -r1.12 -r1.13 --- openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-table-create.sql 12 Sep 2003 17:58:43 -0000 1.12 +++ openacs-4/contrib/packages/project-manager/sql/postgresql/project-manager-table-create.sql 15 Sep 2003 23:09:56 -0000 1.13 @@ -402,3 +402,111 @@ comment on table pm_project_assignment is ' Maps who is a part of what project, and in what capacity '; + + +-- PROCESSES + +create sequence pm_process_seq; + +create table pm_process ( + process_id integer + constraint pm_process_id_pk + primary key, + one_line varchar(200) + constraint pm_process_one_line_nn + not null, + description varchar(1000), + party_id integer + constraint pm_process_party_fk + references parties + constraint pm_process_party_nn + not null, + creation_date timestamptz +); + +comment on table pm_process is ' + Processes are a set of templates for tasks, so that people can + create sets of tasks quickly. Their structure needs to match that of + tasks. The process holds the meta information, and is also an identifier + that is used by the user to select which process they''d like to copy or + use +'; + +create sequence pm_process_task_seq; + +create table pm_process_task ( + process_task_id integer + constraint pm_process_task_id_pk + primary key, + process_id integer + constraint pm_process_process_id_fk + references + pm_process + constraint pm_process_process_id_nn + not null, + one_line varchar(200) + constraint pm_process_task_one_line_nn + not null, + description varchar(4000), + -- dates are optional, because it may be computed in reference + -- to all other items, or simply not have a deadline + end_date timestamptz, + -- percent complete is always 0 + estimated_hours_work numeric, + -- PERT charts require minimum and maximum estimates + -- these are optionally used + estimated_hours_work_min numeric, + estimated_hours_work_max numeric +); + +comment on table pm_process_task is ' + A template for the tasks that will be created by the process +'; + +create sequence pm_process_task_dependency_seq; + +create table pm_process_task_dependency ( + dependency_id integer + constraint pm_proc_task_dependcy_pk + primary key, + process_task_id integer + constraint pm_proc_task_proc_task_fk + references pm_process_task + on delete cascade, + parent_task_id integer + constraint pm_proc_task_parent_id_fk + references pm_process_task + on delete cascade, + dependency_type varchar + constraint pm_process_task_dep_type + references pm_task_dependency_types, + constraint pm_proc_task_depend_uq + unique (process_task_id, parent_task_id) +); + +comment on table pm_process_task_dependency is ' + Keeps track of dependencies. Used to create the dependencies in the + new tasks. +'; + +create table pm_process_task_assignment ( + process_task_id integer + constraint pm_proc_task_assign_task_fk + references pm_process_task(process_task_id) + on delete cascade, + role_id integer + constraint pm_task_assignment_role_fk + references pm_roles, + party_id integer + constraint pm_task_assignment_party_fk + references parties(party_id) + on delete cascade, + constraint pm_proc_task_assgn_uq + unique (process_task_id, role_id, party_id) +); + + +comment on table pm_process_task_assignment is ' + Maps who is assigned to process tasks. These will be the default people + assigned to the new tasks +'; 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.15 -r1.16 --- openacs-4/contrib/packages/project-manager/www/index.adp 12 Sep 2003 01:20:57 -0000 1.15 +++ openacs-4/contrib/packages/project-manager/www/index.adp 15 Sep 2003 23:09:57 -0000 1.16 @@ -7,14 +7,16 @@ + - + + Index: openacs-4/contrib/packages/project-manager/www/process-add-edit-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/process-add-edit-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/project-manager/www/process-add-edit-postgresql.xql 15 Sep 2003 23:09:57 -0000 1.1 @@ -0,0 +1,49 @@ + + + + + select current_timestamp from dual; + + + + + + insert into pm_process + (process_id, + one_line, + description, + party_id, + creation_date) + values + (:process_id, + :one_line, + :description, + :party_id, + :creation_date) + + + + + + update pm_process + set one_line = :one_line, + description = :description, + party_id = :party_id + + + + + + select + process_id, + one_line, + description, + party_id, + creation_date + from + pm_process + where process_id = :process_id + + + + Index: openacs-4/contrib/packages/project-manager/www/process-add-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/process-add-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/project-manager/www/process-add-edit.adp 15 Sep 2003 23:09:57 -0000 1.1 @@ -0,0 +1,7 @@ + +@context_bar@ +@title@ + +
+ +
Index: openacs-4/contrib/packages/project-manager/www/process-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/process-add-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/project-manager/www/process-add-edit.tcl 15 Sep 2003 23:09:57 -0000 1.1 @@ -0,0 +1,109 @@ +ad_page_contract { + + Simple add/edit form for processs + + @author jader@bread.com + @creation-date 2003-09-15 + @cvs-id $Id: process-add-edit.tcl,v 1.1 2003/09/15 23:09:57 jader Exp $ + + @return context_bar Context bar. + @return title Page title. + +} { + + process_id:integer,optional + {one_line ""} + {description ""} + {number_of_tasks:integer ""} + +} -properties { + + context_bar:onevalue + title:onevalue + +} + +ns_log notice it's my page! +set mypage [ns_getform] +if {[string equal "" $mypage]} { + ns_log notice no form was submitted on my page +} else { + ns_log notice the following form was submitted on my page + ns_set print $mypage +} + + +# --------------------------------------------------------------- # +# the unique identifier for this package +set package_id [ad_conn package_id] +set user_id [ad_maybe_redirect_for_registration] + +# terminology +set project_term [parameter::get -parameter "ProjectName" -default "Project"] +set project_term_lower [parameter::get -parameter "projectname" -default "project"] + +if {[exists_and_not_null process_id]} { + set title "Edit a Process" + set context_bar [ad_context_bar "Edit Process"] + + # permissions + permission::require_permission -party_id $user_id -object_id $package_id -privilege write +} else { + set title "Add a Process" + set context_bar [ad_context_bar "New Process"] + + # permissions + permission::require_permission -party_id $user_id -object_id $package_id -privilege create +} + + +ad_form -name add_edit -form { + process_id:key + + {one_line:text + {label "Subject"} + {value $one_line} + } + + {description:text(textarea),optional + {label "Description"} + {value $description} + {html { rows 5 cols 40 wrap soft}}} + + {number_of_tasks:text + {label "Number of new tasks"} + {value "1"} + } + +} -select_query_name process_query -on_submit { + + set party_id [ad_conn user_id] + set creation_date [db_string get_today { }] + +} -new_data { + set process_id [db_nextval pm_process_seq] + + db_dml new_process { *SQL* } + + ad_returnredirect "process-task-add-edit?[export_vars -url {{number $number_of_tasks} process_id}]" + ad_script_abort + +} -edit_data { + + db_dml edit_process { *SQL* } + +} -after_submit { + + ad_returnredirect "process-task-add-edit?[export_vars -url {{number $number_of_tasks} process_id}]" + ad_script_abort +} + + +ns_log notice end of my page! +set mypage [ns_getform] +if {[string equal "" $mypage]} { + ns_log notice no form was submitted on my page +} else { + ns_log notice the following form was submitted on my page + ns_set print $mypage +} Index: openacs-4/contrib/packages/project-manager/www/process-task-add-edit-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/process-task-add-edit-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/project-manager/www/process-task-add-edit-postgresql.xql 15 Sep 2003 23:09:57 -0000 1.1 @@ -0,0 +1,44 @@ + + + + + select pm_task__new_task_item ( + null, + :project_item_id, + '$task_title($i)', + '$description($i)', + [project_manager::project::util::datenvl -value [set end_date_$i] -value_if_null "null," -value_if_not_null "to_timestamp('[set end_date_$i]','YYYY MM DD HH24 MI SS'),"] + '0', + '$estimated_hours_work($i)', + '$estimated_hours_work_min($i)', + '$estimated_hours_work_max($i)', + now(), + :user_id, + :peeraddr, + :package_id + ); + + + + + + select + t.task_revision_id, + t.title as task_title, + t.item_id, + t.description, + t.name, + t.parent_id, + to_char(t.end_date,'YYYY MM DD') as end_date, + t.percent_complete, + t.estimated_hours_work, + t.estimated_hours_work_min, + t.estimated_hours_work_max + FROM + pm_tasks_revisionsx t, cr_items i + WHERE + t.item_id = :task_id and + t.revision_id = i.live_revision + + + Index: openacs-4/contrib/packages/project-manager/www/process-task-add-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/process-task-add-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/project-manager/www/process-task-add-edit.adp 15 Sep 2003 23:09:57 -0000 1.1 @@ -0,0 +1,79 @@ + +@context_bar@ +@title@ + + +
+ +
My @project_term_lower@s All @project_term_lower@s My @task_term_lower@s All @task_term_lower@sProcessesProcesses  Admin pages
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
 @num.rownum@  Subject:*

+ + Description:

+ + + + + + + + + + + + + + + + + + + + + + +
Work required:*
Min: hrs  schedule constrained by other @task_term_lower@
Max: hrs
hrs depends on another @task_term_lower@
+ + +

+ +
+ + Deadline: + + + +

+ [i] + You may optionally enter a hard deadline, otherwise it is computed

+ +
+ + +

+ Index: openacs-4/contrib/packages/project-manager/www/process-task-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/process-task-add-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/project-manager/www/process-task-add-edit.tcl 15 Sep 2003 23:09:57 -0000 1.1 @@ -0,0 +1,238 @@ +ad_page_contract { + + Add/edit form for tasks + + @author jader@bread.com + @creation-date 2003-07-28 + @cvs-id $Id: process-task-add-edit.tcl,v 1.1 2003/09/15 23:09:57 jader Exp $ + + @return context_bar Context bar. + @return title Page title. + @return num num is used as a multirow datasource to iterate over the ad_form elements + + @param process_id Specifies which process this task is associated with + @param number The number of Tasks to create +} { + + process_item_id:integer,optional + process_id:integer,optional + {number:integer "1"} + +} -properties { + + context_bar:onevalue + title:onevalue + num:multirow + use_uncertain_completion_times_p:onevalue + +} -validate { + number_is_in_range -requires {number:integer} { + # todo: make 100 a parameter + if {$number < 1 || $number > 100} { + ad_complain + } + } + percent_is_in_range -requires {percent_complete:integer} { + if {$percent_complete < 0 || $percent_complete > 100} { + ad_complain + } + } +} -errors { + number_is_in_range {Number must be between 1 and 100} + percent_is_in_range {Percent completed must be between 0 and 100} +} + +# --------------------------------------------------------------- # + +# create a multirow we can use to iterate +template::multirow create num number + +for {set i 1} {$i <= $number} {incr i} { + template::multirow append num $i +} + + +# The evilest hack of all time. +# ------------------------------------------------------- +# This is a workaround the fact that using multiple dates +# with ad_form is extremely difficult. Dates are formatted +# like arrays, with values like end_date.day, end_date.month, +# end_date.year, and end_date.format . The problem is we want +# to have multiple end_dates. Using the multiple method, we +# then get entries like this: end_date.1.year, end_date.2.year, +# end_date.2.day, etc.. +# +# What this loop does is go through the array, and rename the +# values into other variables. We then feed these variables into +# the SQL function that creates the new tasks. This works. I'm +# sure there must be a better way to do it, but my posting on +# the forums didn't result in any other suggestions. + +if {[info exists end_date]} { + + set searchToken [array startsearch end_date] + + while {[array anymore end_date $searchToken]} { + + set keyname [array nextelement end_date $searchToken] + set keyvalu $end_date($keyname) + + # element_num is 1...n, element_type is year, format, day, month + regexp {(.*)\.(.*)} $keyname match element_num element_type + + set end_date_[set element_type]($element_num) $keyvalu + + } + + for {set i 1} {$i <= $number} {incr i} { + # set up date variable names + set end_date_$i [list $end_date_year($i) $end_date_month($i) $end_date_day($i) {} {} {}] + } +} + +# terminology +set task_term [parameter::get -parameter "TaskName" -default "Task"] +set task_term_lower [parameter::get -parameter "taskname" -default "task"] +set use_uncertain_completion_times_p [parameter::get -parameter "UseUncertainCompletionTimesP" -default "1"] + + +# the unique identifier for this package +set package_id [ad_conn package_id] +set user_id [ad_maybe_redirect_for_registration] + +# permissions + +set title "Process" +set context_bar [ad_context_bar Process] + +if {[exists_and_not_null task_id]} { +# set title "Edit a $task_term_lower" +# set context_bar [ad_context_bar [list "one?item_id=$process_item_id&process_id=$process_id" "One $process_term"] "Edit $task_term"] +# permission::require_permission -party_id $user_id -object_id $package_id -privilege write +} else { +# set title "Add a $task_term_lower" +# set context_bar [ad_context_bar [list "one?item_id=$process_item_id&process_id=$process_id" "One $process_term"] "New $task_term"] +# permission::require_permission -party_id $user_id -object_id $package_id -privilege create +} + + +ad_form -name add_edit -form { + task_id:key + + {process_id:text(hidden) + {value $process_id} + } + + {number:text(hidden) + {value $number} + } + +} -on_submit { + + set user_id [ad_conn user_id] + set peeraddr [ad_conn peeraddr] + +} -new_data { + + # each task we add in returns a task_revision_id + # we set up two lists, one for tasks that will need dependencies + # another for tasks that don't + + set revision_has_dependencies [list] + set revision_no_dependencies [list] + + for {set i 1} {$i <= $number} {incr i} { + + if {![exists_and_not_null estimated_hours_work($i)]} { + set estimated_hours_work($i) [expr .5 * ($estimated_hours_work_max($i) - $estimated_hours_work_min($i)) + $estimated_hours_work_min($i)] + } + + if {![exists_and_not_null estimated_hours_work_min($i)]} { + set estimated_hours_work_min($i) $estimated_hours_work($i) + } + + if {![exists_and_not_null estimated_hours_work_max($i)]} { + set estimated_hours_work_max($i) $estimated_hours_work($i) + } + + set this_revision_id [db_exec_plsql new_task_item { *SQL* }] + + if {[info exists use_dependency_p($i)] && [string equal $use_dependency_p($i) "t"]} { + lappend revision_has_dependencies $this_revision_id + } else { + lappend revision_no_dependencies $this_revision_id + } + } + +} -edit_data { + +} -select_query_name task_query -after_submit { + + # now go through the use_dependency_p items. For each that is checked, + # we add that to a list of ids that we pass to the dependency-add-edit + # page. + + ad_returnredirect "task-assign-add-edit?[export_vars -url {revision_has_dependencies:multiple revision_no_dependencies:multiple process_item_id}]" + ad_script_abort + +} + +for {set i 1} {$i <= $number} {incr i} { + + # reading this code, you may wonder why we put the .$i at the end. + # DaveB showed me this trick. It lets you make a multiple out of + # the items by stuffing them in an array. Long live DaveB. + + ad_form -extend -name add_edit -form \ + [list \ + [list \ + task_title.$i:text \ + {label "Subject \#$i"} \ + {html {size 39}} \ + ] \ + [list \ + description.$i:text(textarea),optional \ + {label "Description"} \ + {html {rows 7 cols 40}} \ + ] \ + [list \ + use_dependency_p.$i:text(checkbox) \ + {label "Use dependency"} \ + {value "t"} \ + ] \ + [list \ + parent_id.$i:text(hidden) \ + ] \ + [list \ + end_date.$i:date,to_sql(linear_date),optional \ + {label "Deadline"} \ + {format "MONTH DD YYYY"} \ + {help} \ + ] \ + ] + + if {$use_uncertain_completion_times_p} { + ad_form -extend -name add_edit -form \ + [list \ + [list \ + estimated_hours_work_min.$i:integer \ + {label "Hours estimate - min"} \ + {html {size 3}} \ + ] \ + [list \ + estimated_hours_work_max.$i:integer \ + {label "Hours estimate - max"} \ + {html {size 3}} \ + ] \ + ] + } else { + ad_form -extend -name add_edit -form \ + [list \ + [list \ + estimated_hours_work.$i:integer \ + {label "Hours estimate"} \ + {html {size 3}} \ + ] \ + ] + } +} Index: openacs-4/contrib/packages/project-manager/www/processes-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/processes-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/project-manager/www/processes-postgresql.xql 15 Sep 2003 23:09:57 -0000 1.1 @@ -0,0 +1,18 @@ + + +postgresql7.2 + + + + SELECT + p.process_id, + p.one_line, + p.description, + p.party_id, + to_char(p.creation_date,'Mon DD ''YY') as creation_date + FROM + pm_process p + + + + Index: openacs-4/contrib/packages/project-manager/www/processes.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/processes.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/project-manager/www/processes.adp 15 Sep 2003 23:09:57 -0000 1.1 @@ -0,0 +1,35 @@ + + + + +Processes +@context_bar@ + + + + + + + + + + + + + + + + + + + + +
My @project_term_lower@sAll @project_term_lower@sMy @task_term_lower@sAll @task_term_lower@sProcesses Admin pages
Add Process +
+ + +

+ + + + Index: openacs-4/contrib/packages/project-manager/www/processes.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/processes.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/project-manager/www/processes.tcl 15 Sep 2003 23:09:57 -0000 1.1 @@ -0,0 +1,96 @@ +ad_page_contract { + + Main view page for projects. + + @author jader@bread.com, ncarroll@ee.usyd.edu.au + @creation-date 2003-05-15 + @cvs-id $Id: processes.tcl,v 1.1 2003/09/15 23:09:57 jader Exp $ + + @return title Page title. + @return context Context bar. + @return projects Multirow data set of projects. + @return task_term Terminology for tasks + @return task_term_lower Terminology for tasks (lower case) + @return project_term Terminology for projects + @return project_term_lower Terminology for projects (lower case) + +} -properties { + + context_bar:onevalue + processes:multirow + write_p:onevalue + create_p:onevalue + admin_p:onevalue + task_term:onevalue + task_term_lower:onevalue + project_term:onevalue + project_term_lower:onevalue +} + +# --------------------------------------------------------------- # + +# terminology +set task_term [parameter::get -parameter "TaskName" -default "Task"] +set task_term_lower [parameter::get -parameter "taskname" -default "task"] +set project_term [parameter::get -parameter "ProjectName" -default "Project"] +set project_term_lower [parameter::get -parameter "projectname" -default "project"] + +# set up context bar +set context_bar [ad_context_bar "Processes"] + +# the unique identifier for this package +set package_id [ad_conn package_id] +set user_id [ad_maybe_redirect_for_registration] + +# permissions +permission::require_permission -party_id $user_id -object_id $package_id -privilege read + +set write_p [permission::permission_p -object_id $package_id -privilege write] +set create_p [permission::permission_p -object_id $package_id -privilege create] +set admin_p [permission::permission_p -object_id $package_id -privilege admin] + +# root CR folder +# set root_folder [db_string get_root "select pm_project__get_root_folder (:package_id, 'f')"] + +# Processes, using list-builder --------------------------------- + +template::list::create \ + -name processes \ + -multirow processes \ + -key item_id \ + -elements { + one_line { + label "Subject" + link_url_col item_url + link_html { title "Use this process" } + } + description { + label "Description" + } + creation_date { + label "Created" + } + } \ + -main_class { + narrow + } \ + -filters { + orderby_process {} + } \ + -orderby { + one_line {orderby one_line} + default_value one_line,desc + } \ + -orderby_name orderby_project \ + -html { + width 100% + } + + +db_multirow -extend { item_url } processes process_query { +} { + set item_url [export_vars -base "process-add-edit" {process_id}] +} + + +# ------------------------- END OF FILE ------------------------- #