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.27.2.1 -r1.27.2.2 --- openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 23 Mar 2004 07:53:15 -0000 1.27.2.1 +++ openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 20 May 2004 17:30:05 -0000 1.27.2.2 @@ -2,6 +2,13 @@ Add/edit form for tasks +

+ + I plan to eventually get rid of the task-select-project page, because + the ability to choose the project is now within this page. However, + I'm waiting to do that until after my company updates our projects + with the customer in each field. + @author jader@bread.com @creation-date 2003-07-28 @cvs-id $Id$ @@ -12,31 +19,54 @@ @return edit_p if t then we are editing. Used to show different portions of the form @param process_task_ids Specifies what process task ids were used if a process were used. We pass this on to future pages to determine things such as assignments - @param project_item_id Specifies which project this task is associated with - @param project_id Specifies which project revision this task is associated with + @param project_item_id Specifies which project each task is associated with. If this is a new task, this specifies the project that it will be assigned under. + @param my_key if set, then ad_form knows that this is an edit + @param process_task_ids + @param project_item_id This is optionally passed in to this page to + indictate the project that the tasks should be associated with. + @param project_item_ids Used internally to keep track of the projects + associated with each task @param number The number of Tasks to create - @param added_tasks @param task_revision_id Specifies the revision this task represents (each revision of a task has a separate id) @param task_id Specifies the item for the task (every revision of a task shares the same task_id) Also used as the key for the ad_form. For this reason, when editing, we have to pass in task_iid instead - @param my_key if set, then ad_form knows that this is an edit @param task_title - @param skip_task_p Whether or not to skip this particular task. Used by processes, if t, then the task is not created @param process_id The process we're using to create this task - @param use_uncertain_completion_times_p Whether or not to use PERT-style completion time uncertainty 1 = yes - @return using_process_p Lets the UI know if there is a process being used (t if so) + @param description + @param old_description + @param comment + @param name + @param end_date + @param percent_complete + @param actual_hours_worked + @param new_hours_logged + @param new_description_logged + @param estimated_hours_work + @param estimated_hours_work_min + @param estimated_hours_work_max + @param dependency_type + @param dependency_task_id + @param skip_task_p Whether or not to skip this particular task. Used by processes, if t, then the task is not created + @param using_process_p Lets the UI know if there is a process being used (t if so) + } { my_key:integer,optional process_task_ids:array,optional - project_item_id:integer,optional - project_id:integer,optional + {project_item_id:integer ""} + project_item_ids:array,optional {number:integer "1"} task_revision_id:integer,optional {task_id:multiple ""} task_item_id:array,optional task_title:array,optional {process_id:integer ""} - description:array,optional +<<<<<<< task-add-edit.tcl + description:html,array,optional +======= + description:html,array,optional + {old_description ""} + comment:html,array,optional +>>>>>>> 1.33 name:array,optional end_date:array,optional percent_complete:array,optional @@ -50,6 +80,7 @@ dependency_task_id:array,optional skip_task_p:array,optional {using_process_p "f"} + {return_url ""} } -properties { @@ -61,12 +92,6 @@ using_process_p:onevalue } -validate { - project_exists { - if {![exists_and_not_null project_item_id] && \ - ![exists_and_not_null project_id]} { - ad_complain - } - } number_is_in_range -requires {number:integer} { # todo: make 100 a parameter if {$number < 1 || $number > 100} { @@ -90,6 +115,7 @@ set package_id [ad_conn package_id] + # --------------------------------------------------------------- # # terminology # --------------------------------------------------------------- # @@ -100,11 +126,20 @@ # --------------------------------------------------------------- # +<<<<<<< task-add-edit.tcl if {![exists_and_not_null project_id]} { set project_id [db_string get_project_id { }] } + +# ns_log Notice "return_url: $return_url" + + + + +======= +>>>>>>> 1.33 # -------------------------------------------------------------------- # If we are using a process, then we need to get the information on # the process now. This is necessary because we need to do things like @@ -128,12 +163,27 @@ set estimated_hours_work_max_v($process_tid) $estimated_hours_work_max set dependency_v($process_tid) $process_parent_task + # make sure that we don't have empty values for estimated + # hours work + if {[empty_string_p $estimated_hours_work_v($process_tid)]} { + set estimated_hours_work_v($process_tid) 0 + } + if {[empty_string_p $estimated_hours_work_min_v($process_tid)]} { + set estimated_hours_work_min_v($process_tid) 0 + } + if {[empty_string_p $estimated_hours_work_max_v($process_tid)]} { + set estimated_hours_work_max_v($process_tid) 0 + } + + lappend process_tasks $process_tid } set number [llength $process_tasks] } + + # --------------------------------------------------------------- # @@ -142,6 +192,10 @@ set task_id_pass [string map {"-" " "} $task_id] set task_id $task_id_pass +# we sort this because we want to keep the ordering +# consistent. Otherwise, we can run into problems when editing +# multiple tasks. Their values can get crossed. +set task_id [lsort -integer $task_id] # --------------------------------------------------------------- # # Create a multirow: num @@ -154,12 +208,12 @@ # create a multirow we can use to iterate # we also set the number variable for future use # ----------------------------------------------------- - template::multirow create num number + template::multirow create num number task_id set i 1 set number 0 foreach tid $task_id { - template::multirow append num $i + template::multirow append num $i [lindex $task_id [expr $i-1]] incr i incr number } @@ -168,10 +222,10 @@ } else { # create a multirow we can use to iterate - template::multirow create num number + template::multirow create num number task_id for {set i 1} {$i <= $number} {incr i} { - template::multirow append num $i + template::multirow append num $i [lindex $task_id [expr $i-1]] } set edit_p f @@ -205,19 +259,201 @@ set keyname [array nextelement end_date $searchToken] set keyvalu $end_date($keyname) + # ns_log Notice "keyname: $keyname keyvalu: $keyvalu" + # element_num is 1...n, element_type is year, format, day, month regexp {(.*)\.(.*)} $keyname match element_num element_type + # ns_log Notice "element_num: $element_num element_type: $element_type" + set end_date_[set element_type]($element_num) $keyvalu + # ns_log notice "set end_date_[set element_type] to $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) {} {} {}] +<<<<<<< task-add-edit.tcl + # ns_log Notice "end_date_$i: [set end_date_$i]" } } +# ------------------------------------------------------- # +# The second evilest hack of all time. +# ------------------------------------------------------- +# This is a workaround the fact that using multiple richtext items +# with ad_form is extremely difficult. The description field +# will come in like an array, with values like +# description.1 = 1234 bold +# description.1.format = text/enhanced +# description.1.spellcheck = :nospell: +# The problem is we want +# to have multiple descriptions. +# +# 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. +# ------------------------------------------------------- # + +if {[info exists description] && ![exists_and_not_null process_id]} { + + set searchToken [array startsearch description] + + while {[array anymore description $searchToken]} { + + # these next two lines are important + set element_num "" + set element_type "" + + set keyname [array nextelement description $searchToken] + set keyvalu $description($keyname) + + # ns_log Notice "keyname: $keyname keyvalu: $keyvalu" + + # element_num is 1...n, element_type is format, spellcheck + regexp {(.*)\.(.*)} $keyname match element_num element_type + + # ns_log Notice "element_num: $element_num element_type: $element_type" + + set description_[set element_type]($element_num) $keyvalu + + # ns_log notice "set description_[set element_type] to $keyvalu" + +======= + # ns_log Notice "end_date_$i: [set end_date_$i]" + } +} + +# ------------------------------------------------------- # +# The second evilest hack of all time. +# ------------------------------------------------------- +# This is a workaround the fact that using multiple richtext items +# with ad_form is extremely difficult. The description field +# will come in like an array, with values like +# description.1 = 1234 bold +# description.1.format = text/enhanced +# description.1.spellcheck = :nospell: +# The problem is we want +# to have multiple descriptions. +# +# 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. +# ------------------------------------------------------- # + +if {[info exists description] && ![exists_and_not_null process_id]} { + + set searchToken [array startsearch description] + + while {[array anymore description $searchToken]} { + + # these next two lines are important + set element_num "" + set element_type "" + + set keyname [array nextelement description $searchToken] + set keyvalu $description($keyname) + + # ns_log Notice "keyname: $keyname keyvalu: $keyvalu" + + # element_num is 1...n, element_type is format, spellcheck + regexp {(.*)\.(.*)} $keyname match element_num element_type + + # ns_log Notice "element_num: $element_num element_type: $element_type" + + set description_[set element_type]($element_num) $keyvalu + + # ns_log notice "set description_[set element_type] to $keyvalu" + + } + +} + +# ------------------------------------------------------- # +# The third evilest hack of all time. +# ------------------------------------------------------- +# This is a workaround the fact that using multiple richtext items +# with ad_form is extremely difficult. The comment field +# will come in like an array (if the task is edited), +# with values like +# comment.1 = 1234 bold +# comment.1.format = text/enhanced +# comment.1.spellcheck = :nospell: +# The problem is we want +# to have multiple comments. +# +# 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. +# ------------------------------------------------------- # +if {[string equal $edit_p t] && [info exists comment]} { + + set searchToken [array startsearch comment] + + while {[array anymore comment $searchToken]} { + + # these next two lines are important + set element_num "" + set element_type "" + + set keyname [array nextelement comment $searchToken] + set keyvalu $comment($keyname) + + # ns_log Notice "keyname: $keyname keyvalu: $keyvalu" + + # element_num is 1...n, element_type is format, spellcheck + regexp {(.*)\.(.*)} $keyname match element_num element_type + + # if element_num is null, then this is actually the value for + # the comment + if {[empty_string_p $element_num]} { + set comment_[set keyname] $keyvalu + } + + # ns_log Notice "element_num: $element_num element_type: $element_type" + + set comment_[set element_type]($element_num) $keyvalu + + # ns_log notice "set comment_[set element_type] to $keyvalu" + +>>>>>>> 1.33 + } +<<<<<<< task-add-edit.tcl + +======= + +} else { + + for {set i 1} {$i <= $number} {incr i} { + # we explicitly set all the values to plaintext and empty for + # new tasks + set comment_format($i) "text/plain" + set comment_$i "" + } +} + +for {set i 1} {$i <= $number} {incr i} { + + set format $comment_format($i) + set richtext_list [list [set comment_$i] $format] + lappend comment_list [ad_html_to_text [template::util::richtext::get_property html_value $richtext_list]] +>>>>>>> 1.33 +} + +<<<<<<< task-add-edit.tcl + +======= + +# ns_log Notice "comment_list $comment_list" + + + + +>>>>>>> 1.33 # --------------------------------------------------------------- # # permissions and title setup, etc # we should update the permissions to not just use package_id, so @@ -229,7 +465,7 @@ if {[exists_and_not_null task_id]} { set title "Edit a $task_term_lower" - set context [list [list "one?item_id=$project_item_id&project_id=$project_id" "One $project_term"] "Edit $task_term"] + set context [list [list $return_url "Go back"] "Edit $task_term"] permission::require_permission \ -party_id $user_id \ -object_id $package_id \ @@ -238,7 +474,7 @@ } else { set title "Add a $task_term_lower" - set context [list [list "one?item_id=$project_item_id&project_id=$project_id" "One $project_term"] "New $task_term"] + set context [list [list "one?item_id=$project_item_id" "One $project_term"] "New $task_term"] permission::require_permission \ -party_id $user_id \ -object_id $package_id \ @@ -249,6 +485,8 @@ # we use this to pass through the task_ids set task_id_pass [string map {" " "-"} $task_id] +# set up options for editing projects +set project_options [pm::project::get_list_of_open] # --------------------------------------------------------------- # @@ -258,16 +496,25 @@ ad_form -name add_edit -form { my_key:key(acs_object_id_seq) - {project_item_id:text(hidden) - {value $project_item_id} - } - {task_id:text(hidden) {value $task_id_pass} } + {edit_p:text(hidden) + {value $edit_p} + } + +<<<<<<< task-add-edit.tcl + {return_url:text(hidden) + {value $return_url} + } + {project_id:text(hidden) {value $project_id} +======= + {return_url:text(hidden) + {value $return_url} +>>>>>>> 1.33 } {number:text(hidden) @@ -281,22 +528,60 @@ # we set the values for edited tasks # ---------------------------------- + +# we set the initial value to 0, because we need at least one value to +# pass to SQL. Otherwise, when we do the IN (123, 234, 455), there +# won't be any values inside, and it will fail. +set my_dependencies [list 0] + + if {![ad_form_new_p -key task_id]} { + # this form is being edited, not new + + # note we are indexing values from 1... set i 1 + set old_description [list] db_foreach get_old_tasks { *SQL* } { set task_title_arr($i) $my_task_title set description_arr($i) $my_description +<<<<<<< task-add-edit.tcl + set mime_type_arr($i) $my_mime_type + set template_arr($i) [list $my_description $my_mime_type] +======= + lappend old_description $my_description + set mime_type_arr($i) $my_mime_type + set template_arr($i) [list $my_description $my_mime_type] +>>>>>>> 1.33 set estimated_hours_arr($i) $my_estimated_work set estimated_hours_min_arr($i) $my_estimated_work_min set estimated_hours_max_arr($i) $my_estimated_work_max - set end_date_arr($i) $my_end_date + + # We need the date to be in the right format in order to pass + # through the validate filter. + + # the end date comes in this format 2004 05 17 + # we need to get it in the {2004} {05} {17} {} {} {} format + regexp {(.*) (.*) (.*)} $my_end_date match year month day + if {[exists_and_not_null year]} { + set end_date_arr($i) "$year $month $day {} {} {}" + } else { + set end_date_arr($i) "{} {} {} {} {} {}" + } + set percent_complete_arr($i) $my_percent_complete set actual_hours_worked_arr($i) $my_actual_hours_worked + set project_item_id_arr($i) $my_project_item_id set task_item_id_arr($i) [lindex $task_id [expr $i - 1]] set dependency_arr($i) $my_dependency + # we keep track of this to make sure that depedencies that + # are from closed tasks are still shown on the list of + # possible dependencies to select from + if {[exists_and_not_null my_dependency]} { + lappend my_dependencies $my_dependency + } # we are not using a process set process_task_id_arr($i) "" @@ -307,6 +592,11 @@ # log hours as well. # ----------------------------------------------------- + # we also want to pass throught he old description so that + # we can do a word diff on the next page, so people can see + # what has changed + + ad_form -extend \ -name add_edit \ -form \ @@ -337,9 +627,34 @@ ] \ ] + # ------------------------------------------------------ + # we allow people to enter general comments when editing + # ------------------------------------------------------ + ad_form -extend \ + -name add_edit \ + -form \ + [list [list \ + comment.$i:richtext,optional,nospell \ + {label "Comment"} \ + {html {rows 7 cols 40}} \ + ] \ + ] + incr i } + + # we want to add in the old_description values as well + ad_form -extend \ + -name add_edit \ + -form \ + [list [list \ + comment.$i:text(hidden) \ + {value {$old_description}} \ + ] \ + ] + + } else { # ---------------------------------------------------------- @@ -352,13 +667,16 @@ for {set i 1} {$i <= $number} {incr i} { set task_title_arr($i) "" set description_arr($i) "" + set mime_type_arr($i) "text/plain" + set template_arr($i) [list "" "text/plain"] set estimated_hours_arr($i) "0" set estimated_hours_min_arr($i) "0" set estimated_hours_max_arr($i) "0" set parent_arr($i) "" set end_date_arr($i) "" set percent_complete_arr($i) 0 set actual_hours_worked_arr($i) 0 + set project_item_id_arr($i) $project_item_id set task_item_id_arr($i) "" set process_task_id_arr($i) "" set dependency_arr($i) "" @@ -369,6 +687,10 @@ set task_title_arr($i) $one_line_v($ptask_id) set description_arr($i) $description_v($ptask_id) + + set mime_type_arr($i) "text/plain" + set template_arr($i) [list "$description_v($ptask_id)" "text/plain"] + set estimated_hours_arr($i) $estimated_hours_work_v($ptask_id) set estimated_hours_min_arr($i) $estimated_hours_work_min_v($ptask_id) set estimated_hours_max_arr($i) $estimated_hours_work_max_v($ptask_id) @@ -396,6 +718,7 @@ {help_text {If you skip this task, it will not be created}} \ ] \ ] + } else { @@ -426,31 +749,45 @@ ] \ ] - } -} + # ----------------------------------------------------------- + # we only allow people to enter general comments when editing + # we also want to pass throught he old description so that + # we can do a word diff on the next page, so people can see + # what has changed + # ----------------------------------------------------------- + ad_form -extend \ + -name add_edit \ + -form \ + [list [list \ + comment.$i:text(hidden) \ + {value ""} \ + ] \ + ] -# get dependency types -set options [list] -db_foreach get_dependency_types { } -column_array dependencies { - lappend options "{\"$dependencies(description)\" $dependencies(short_name)}" -} + } -# get tasks this task can depend on + # we want to add in the old_description values as well + ad_form -extend \ + -name add_edit \ + -form \ + [list [list \ + comment.$i:text(hidden) \ + {value {}} \ + ] \ + ] -set dependency_keys [list] -db_foreach get_dependency_tasks { } -column_array dependency_tasks { - - set dependency_options($dependency_tasks(task_title)) $dependency_tasks(item_id) - lappend dependency_keys $dependency_tasks(task_title) } -set dependency_keys [lsort $dependency_keys] +# get dependency types +#set options [list] +#db_foreach get_dependency_types { } -column_array dependencies { +# lappend options "{\"$dependencies(description)\" $dependencies(short_name)}" +#} - # ---------------------------------------------- # extend the form with all the items that repeat # ---------------------------------------------- @@ -472,9 +809,6 @@ # any loops! # --------------------------------------------------- - set dependency_options_full "" - append dependency_options_full "{\"--None--\" \"\"} " - if {[string equal $edit_p f]} { # if we have a process, we need to bring in the dependencies @@ -516,33 +850,39 @@ } - # now set up dependency options - for {set j 1} {$j <= $number} {incr j} { - if {![string equal $i $j]} { - append dependency_options_full "{\"New Task \#$j\" \"num$j\"} " - } - } - } - # for editing tasks, we skip ourselves (because depending on - # ourselves just sometimes isn't an option) - if {[string equal $edit_p t]} { - foreach key $dependency_keys { +<<<<<<< task-add-edit.tcl # make sure we're not dependent on ourselves if {![string equal $task_item_id_arr($i) $dependency_options($key)]} { - append dependency_options_full "{\"$key\" $dependency_options($key)} " + # check for case when there is a quote in the name of + # a task. We have to filter this out, or we get an error. + append dependency_options_full "{{$key} $dependency_options($key)} " } } } else { foreach key $dependency_keys { - append dependency_options_full "{\"$key\" $dependency_options($key)} " + + # check for case when there is a quote in the name of + # a task. We have to filter this out, or we get an error. + append dependency_options_full "{{$key} $dependency_options($key)} " } } +======= + set dependency_options_full [pm::task::dependency_options \ + -edit_p $edit_p \ + -task_item_id $task_item_id_arr($i) \ + -project_item_id $project_item_id_arr($i) \ + -dependency_task_ids "$my_dependencies" \ + -number $number \ + -current_number $i] +>>>>>>> 1.33 + # ns_log Notice "end_date.$i : $end_date_arr($i)" + ad_form -extend \ -name add_edit \ -form \ @@ -553,6 +893,11 @@ {html {size 40}} \ {value {$task_title_arr($i)}} ] \ + [list project_item_ids.$i:text(select) \ + {label "Project"} \ + {options $project_options} \ + {value {$project_item_id_arr($i)}} \ + ] \ [list task_item_id.$i:text(hidden) \ {label "Task item id"} \ {value {$task_item_id_arr($i)}} \ @@ -562,10 +907,10 @@ {value {$process_task_id_arr($i)}} \ ] \ [list \ - description.$i:text(textarea),optional \ + description.$i:richtext,optional,nospell \ {label "Description"} \ {html {rows 7 cols 40}} \ - {value {$description_arr($i)}} \ + {value {$template_arr($i)}} \ ] \ [list \ end_date.$i:date,to_sql(linear_date),optional \ @@ -575,9 +920,8 @@ {help} \ ] \ [list \ - dependency_type.$i:text(select),optional \ + dependency_type.$i:text(hidden),optional \ {label \"Dependency type\"} \ - {options {[join $options " "]}} \ {value {finish_before_start}} \ ] \ [list \ @@ -587,21 +931,21 @@ {value {$dependency_arr($i)}} \ {help_text {$task_term the dependency is based on}} \ ] \ - ] + ] if {$use_uncertain_completion_times_p} { ad_form -extend \ -name add_edit \ -form \ [list \ [list \ - estimated_hours_work_min.$i:integer \ + estimated_hours_work_min.$i:text \ {label "Hours estimate - min"} \ {html {size 5}} \ {value {$estimated_hours_min_arr($i)}} \ ] \ [list \ - estimated_hours_work_max.$i:integer \ + estimated_hours_work_max.$i:text \ {label "Hours estimate - max"} \ {html {size 5}} \ {value {$estimated_hours_max_arr($i)}} \ @@ -612,7 +956,7 @@ -form \ [list \ [list \ - estimated_hours_work.$i:integer \ + estimated_hours_work.$i:text \ {label "Hours estimate"} \ {html {size 5}} \ {value {$estimated_hours_arr($i)}} \ @@ -623,6 +967,7 @@ + ad_form -extend -name add_edit -select_query_name task_query -on_submit { set user_id [ad_conn user_id] @@ -652,12 +997,21 @@ if {![exists_and_not_null end_date_$i]} { - set end_date_$i [db_null] + set end_date_$i "{} {} {} {} {} {}" } # set up variables, pulling from arrays + set p_project_item_id $project_item_ids($i) + set p_task_title $task_title($i) + set p_description $description($i) + + # ns_log Notice "Format: $description_format($i)" + + + set p_mime_type $description_format($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) @@ -666,21 +1020,23 @@ set p_parent_task_id $dependency_task_id($i) set p_skip_p $skip_task_p($i) - ns_log Notice "end date: $p_end_date" +<<<<<<< task-add-edit.tcl + # ns_log Notice "end date: $p_end_date" +======= + # we don't do anything for the comments field, because they + # are not added in for new tasks. - # Make sure we do not insert bogus stuff into the database. + # ns_log Notice "end date: $p_end_date" +>>>>>>> 1.33 - if {$p_end_date == "{} {} {} {} {} {}"} { - set p_end_date [db_null] - } - # add in the new task if {[string equal $p_skip_p "f"]} { set this_revision_id [pm::task::new \ - -project_id $project_item_id \ + -project_id $p_project_item_id \ -title $p_task_title \ -description $p_description \ + -mime_type $p_mime_type \ -end_date $p_end_date \ -percent_complete "0" \ -estimated_hours_work $p_work \ @@ -692,8 +1048,6 @@ set this_task_id [db_string get_task_item_id {}] - - set dependent_task_id($i) $this_task_id if {[exists_and_not_null p_parent_task_id]} { @@ -718,7 +1072,7 @@ -task_item_id $this_task_id \ -parent_id $p_parent_task_id \ -dependency_type $p_dep_type \ - -project_item_id $project_item_id + -project_item_id $p_project_item_id } } @@ -744,21 +1098,22 @@ -task_item_id $this_task_id \ -parent_id $parent_task_id \ -dependency_type $p_dep_type \ - -project_item_id $project_item_id + -project_item_id $p_project_item_id } } } - pm::project::compute_parent_status $project_item_id - } -edit_data { set timestamp_ansi [db_string get_today " SELECT to_char(current_date, 'YYYY-MM-DD')"] + # insert the comment into the database + set is_live [ad_parameter AutoApproveCommentsP {general-comments} {t}] + # -------------------------------------------------------------- # each task we edit returns a task_revision_id # -------------------------------------------------------------- @@ -782,9 +1137,21 @@ } # set up variables, pulling from arrays + set p_project_item_id $project_item_ids($i) + set p_task_item_id $task_item_id($i) set p_task_title $task_title($i) set p_description $description($i) +<<<<<<< task-add-edit.tcl + set p_mime_type $description_format($i) + +======= + set p_mime_type $description_format($i) + + set p_comment $comment($i) + set p_comment_type $comment_format($i) + +>>>>>>> 1.33 set p_percent $percent_complete($i) set p_work $estimated_hours_work($i) set p_work_min $estimated_hours_work_min($i) @@ -798,7 +1165,7 @@ $p_new_hours > 0} { set logger_project [pm::project::get_logger_project \ - -project_item_id $project_item_id] + -project_item_id $p_project_item_id] set variable_id [logger::variable::get_default_variable_id] # add in the new log entry @@ -809,7 +1176,7 @@ -description $p_new_description \ -timestamp_ansi $timestamp_ansi \ -task_item_id $p_task_item_id \ - -project_item_id $project_item_id \ + -project_item_id $p_project_item_id \ -update_status_p f] if {[string equal p_hours -1]} { @@ -825,9 +1192,10 @@ # do the actual edit set this_revision_id [pm::task::edit \ -task_item_id $p_task_item_id \ - -project_item_id $project_item_id \ + -project_item_id $p_project_item_id \ -title $p_task_title \ -description $p_description \ + -mime_type $p_mime_type \ -end_date "[set end_date_[set i]]" \ -percent_complete $p_percent \ -estimated_hours_work $p_work \ @@ -850,16 +1218,113 @@ -task_item_id $p_task_item_id \ -parent_id $p_parent_task_id \ -dependency_type jfdsafesa\ - -project_item_id $project_item_id + -project_item_id $p_project_item_id } + # add in general comments for the task + + if {![empty_string_p $p_comment]} { + + set comment_id [db_nextval acs_object_id_seq] + + db_transaction { + db_exec_plsql insert_comment { + select acs_message__new ( + :comment_id, -- 1 p_message_id + NULL, -- 2 p_reply_to + current_timestamp, -- 3 p_sent_date + NULL, -- 4 p_sender + NULL, -- 5 p_rfc822_id + :p_task_title, -- 6 p_title + NULL, -- 7 p_description + :p_comment_type, -- 8 p_mime_type + NULL, -- 9 p_text + NULL, -- empty_blob(), -- 10 p_data + 0, -- 11 p_parent_id + :p_task_item_id, -- 12 p_context_id + :user_id, -- 13 p_creation_user + :peeraddr, -- 14 p_creation_ip + 'acs_message', -- 15 p_object_type + :is_live -- 16 p_is_live + ) + } + + db_dml add_entry { + insert into general_comments + (comment_id, + object_id, + category) + values + (:comment_id, + :p_task_item_id, + null) + } + + db_1row get_revision { + select content_item__get_latest_revision(:comment_id) as revision_id + } + + db_dml set_content { + update cr_revisions + set content = :p_comment + where revision_id = :revision_id + } + + db_exec_plsql grant_permission { + begin + perform acs_permission__grant_permission ( + /* object_id => */ :comment_id, + /* grantee_id => */ :user_id, + /* privilege => */ 'read' + ); + perform acs_permission__grant_permission ( + /* object_id => */ :comment_id, + /* grantee_id => */ :user_id, + /* privilege => */ 'write' + ); + return 0; + end; + } + } + } + } - pm::project::compute_parent_status $project_item_id +<<<<<<< task-add-edit.tcl +} -after_submit { + # ns_log Notice "tae: return_url: $return_url" + + ad_returnredirect "task-assign-add-edit?[export_vars -url {project_item_id return_url process_task_id:multiple revisions:multiple task_id:multiple}]" + pm::project::compute_parent_status $project_item_id +======= } -after_submit { - ad_returnredirect "task-assign-add-edit?[export_vars -url {project_item_id process_task_id:multiple revisions:multiple task_id:multiple}]" + ad_returnredirect "task-assign-add-edit?[export_vars -url {comment_list edit_p return_url process_task_id:multiple revisions:multiple task_id:multiple old_description}]" +>>>>>>> 1.33 + +<<<<<<< task-add-edit.tcl +======= + # compile a list of which projects the tasks are assigned to + # there is a bug here, because we don't update a project when a + # task is edited and changed to another project. + + set project_item_id_list [list] + for {set i 1} {$i <= $number} {incr i} { + + if {[string equal [lsearch $project_item_id_list $project_item_ids($i)] -1]} { + lappend project_item_id_list $project_item_ids($i) + } + + } + + foreach proj_item $project_item_id_list { + + pm::project::compute_parent_status $proj_item + + } + +>>>>>>> 1.33 ad_script_abort }