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.23 -r1.24 --- openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 10 Nov 2003 19:34:54 -0000 1.23 +++ openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 11 Dec 2003 21:39:44 -0000 1.24 @@ -1,4 +1,4 @@ -ns_log notice task assign add edit page +ns_log notice task add edit page set mypage [ns_getform] if {[string equal "" $mypage]} { ns_log notice no form was submitted on my page @@ -218,131 +218,9 @@ {value $number} } -} -on_submit { - - set user_id [ad_conn user_id] - set peeraddr [ad_conn peeraddr] - -} -new_data { - - ns_log Notice "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) - } - - - if {![exists_and_not_null end_date_$i]} { - set end_date_$i "{} {} {} {} {} {}" - } - - # set up variables, pulling from arrays - set p_task_title $task_title($i) - set p_description $description($i) - set p_work $estimated_hours_work($i) - set p_work_min $estimated_hours_work_min($i) - set p_work_max $estimated_hours_work_max($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) "on"]} { - lappend revision_has_dependencies $this_revision_id - } else { - lappend revision_no_dependencies $this_revision_id - } - - lappend process_task_id $process_task_ids($i) - } - -} -edit_data { - - ns_log Notice "edit_data" - - # -------------------------------------------------------------- - # each task we edit 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) - } - - if {![exists_and_not_null end_date_$i]} { - set end_date_$i "{} {} {} {} {} {}" - } - - # set up variables, pulling from arrays - set p_task_item_id $task_item_id($i) - set p_task_title $task_title($i) - set p_description $description($i) - set p_percent $percent_complete($i) - set p_work $estimated_hours_work($i) - set p_work_min $estimated_hours_work_min($i) - set p_work_max $estimated_hours_work_max($i) - set p_hours $actual_hours_worked($i) - - # do the actual edit - set this_revision_id [db_exec_plsql new_task_revision { }] - - ns_log Notice "Added in $this_revision_id" - - # BUG: we need to make sure we take care of deleting dependencies - # if unchecked, adding dependencies, etc.. - - 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 - } - } - - project_manager::project::compute_parent_status $project_item_id - -} -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 project_item_id process_task_id:multiple}]" - ad_script_abort - } + # ---------------------------------- # we set the values for edited tasks # ---------------------------------- @@ -544,3 +422,134 @@ } } + + +ad_form -extend -name add_edit -select_query_name task_query -on_submit { + + set user_id [ad_conn user_id] + set peeraddr [ad_conn peeraddr] + +} -new_data { + + ns_log Notice "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) + } + + + if {![exists_and_not_null end_date_$i]} { + set end_date_$i "{} {} {} {} {} {}" + } + + # set up variables, pulling from arrays + set p_task_title $task_title($i) + set p_description $description($i) + set p_work $estimated_hours_work($i) + set p_work_min $estimated_hours_work_min($i) + set p_work_max $estimated_hours_work_max($i) + + ns_log Notice "adding task: pii: $project_item_id tt:$p_task_title d:$p_description ed: end_date($i) w:$p_work m:$p_work_min mx:$p_work_max" + + set this_revision_id [db_exec_plsql new_task_item { *SQL* }] + + if {[info exists use_dependency_p($i)] && [string equal $use_dependency_p($i) "on"]} { + lappend revision_has_dependencies $this_revision_id + } else { + lappend revision_no_dependencies $this_revision_id + } + + lappend process_task_id $process_task_ids($i) + } + +} -edit_data { + + ns_log Notice "edit_data" + + # -------------------------------------------------------------- + # each task we edit 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) + } + + if {![exists_and_not_null end_date_$i]} { + set end_date_$i "{} {} {} {} {} {}" + } + + # set up variables, pulling from arrays + set p_task_item_id $task_item_id($i) + set p_task_title $task_title($i) + set p_description $description($i) + set p_percent $percent_complete($i) + set p_work $estimated_hours_work($i) + set p_work_min $estimated_hours_work_min($i) + set p_work_max $estimated_hours_work_max($i) + set p_hours $actual_hours_worked($i) + + # do the actual edit + set this_revision_id [db_exec_plsql new_task_revision { }] + + ns_log Notice "Added in $this_revision_id" + + # BUG: we need to make sure we take care of deleting dependencies + # if unchecked, adding dependencies, etc.. + + 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 + } + } + + project_manager::project::compute_parent_status $project_item_id + + ns_log Notice "computed parent pre redirect" + +} -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 project_item_id process_task_id:multiple}]" + ad_script_abort + +} +