Index: openacs-4/contrib/packages/project-manager/www/task-add-edit-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/project-manager/www/Attic/task-add-edit-2.tcl,v diff -u -N -r1.1.2.19 -r1.1.2.20 --- openacs-4/contrib/packages/project-manager/www/task-add-edit-2.tcl 18 Jul 2005 18:28:46 -0000 1.1.2.19 +++ openacs-4/contrib/packages/project-manager/www/task-add-edit-2.tcl 20 Jul 2005 06:07:14 -0000 1.1.2.20 @@ -67,32 +67,16 @@ set use_days_p [parameter::get -parameter "UseDayInsteadOfHour" -default "t"] foreach i $number { - - #validate date field - if {![regexp {^(--)|\d{4}(\-|/)\d{2}(\-|/)\d{2}?} [lindex $date [expr $i-1]]] && [lindex $date [expr $i-1]] != ""} { - set date [lindex $date [expr $i-1]] - ad_return_error "[_ project-manager.Error]" "[_ project-manager.Date_error]" - } - #validate status field - if {$percent_complete($i) < -1 || $percent_complete($i) > 100 } { - ad_return_error "[_ project-manager.Error]" "[_ project-manager.Please_enter_valid_percent_complete]" - } - - if {[regexp {^\d{4}/\d{2}/\d{2}?} [lindex $date [expr $i-1]]]} { - set delim "/" - } else { - set delim "-" - } - - set date_$i [split [lindex $date [expr $i-1]] $delim] + set date_$i [split [lindex $date [expr $i-1]] "-"] set end_date_${i}(day) [lindex [set date_$i] 2] set end_date_${i}(month) [lindex [set date_$i] 1] set end_date_${i}(year) [lindex [set date_$i] 0] set end_date_${i}(format) "" ad_page_contract_filter_proc_date end_date_$i end_date_$i + set log_date_$i [split [lindex $log_date [expr $i-1]] "-"] set log_date_${i}_day [lindex [set log_date_$i] 2] @@ -104,17 +88,7 @@ ad_page_contract_filter_proc_date log_date_$i log_date_$i if {[string is true $use_days_p]} { - # If empty we set these values to 0 to prevent an errror - # This is a bad place for form validation but in this - # case is probably what the users mean - if {[empty_string_p $estimated_days_work_min($i)]} { - set estimated_days_work_min($i) 0 - } - if {[empty_string_p $estimated_days_work_max($i)]} { - set estimated_days_work_max($i) 0 - } - # set the hours work if {[string is true $use_uncertain_completion_times_p]} { @@ -171,10 +145,58 @@ -project_item_id_array old_project_item_id \ -priority_array old_priority \ -set_client_properties_p t + foreach num $number { - db_transaction { - foreach num $number { + # -------------------------- + # figure out estimated hours + # -------------------------- + if {[string is true $use_uncertain_completion_times_p]} { + set estimated_hours_work($num) \ + [expr .5 * \ + ($estimated_hours_work_max($num) - \ + $estimated_hours_work_min($num)) + \ + $estimated_hours_work_min($num)] + } else { + set estimated_hours_work_min($num) $estimated_hours_work($num) + set estimated_hours_work_max($num) $estimated_hours_work($num) + } + + # ------------------------------------- + # Log hours and other variables to task + # ------------------------------------- + + set logger_project [lindex [application_data_link::get_linked -from_object_id $project_item_id($num) -to_object_type logger_project] 0] + + if {[exists_and_not_null hours($num)]} { + + pm::project::log_hours \ + -logger_project_id $logger_project \ + -variable_id $logger_variable($num) \ + -value $hours($num) \ + -description $log($num) \ + -task_item_id $task_item_id($num) \ + -project_item_id $project_item_id($num) \ + -update_status_p f \ + -party_id $user_id \ + -timestamp_ansi [set log_date_${num}] + } + + # --------- + # edit task + # --------- + + permission::require_permission -party_id $user_id -object_id $task_item_id($num) -privilege write + + + set dead_line "[set end_date_${num}(year)]-[set end_date_${num}(month)]-[set end_date_${num}(day)]" + set task_revision \ + [pm::task::edit \ + -task_item_id $task_item_id($num) \ + -project_item_id $project_item_id($num) \ + -title $task_title($num) \ + -description $description($num) \ + -mime_type $description_mime_type($num) \ -end_date [set end_date_${num}(date)] \ -percent_complete $percent_complete($num) \ -estimated_hours_work $estimated_hours_work($num) \ @@ -184,104 +206,50 @@ -update_ip $peeraddr \ -package_id $package_id \ -priority $priority($num) - $estimated_hours_work_min($num)] - } else { - set estimated_hours_work_min($num) $estimated_hours_work($num) - set estimated_hours_work_max($num) $estimated_hours_work($num) - } - - # ------------------------------------- - # Log hours and other variables to task - # ------------------------------------- - - set logger_project [pm::project::get_logger_project \ - -project_item_id $project_item_id($num)] - - - if {[exists_and_not_null hours($num)]} { - - pm::project::log_hours \ - -logger_project_id $logger_project \ - -variable_id $logger_variable($num) \ - -value $hours($num) \ - -description $log($num) \ - -task_item_id $task_item_id($num) \ - -project_item_id $project_item_id($num) \ - -update_status_p f \ - -party_id $user_id \ - -timestamp_ansi [set log_date_${num}] - } - - # --------- - # edit task - # --------- - - permission::require_permission -party_id $user_id -object_id $task_item_id($num) -privilege write - - - set dead_line "[set end_date_${num}(year)]-[set end_date_${num}(month)]-[set end_date_${num}(day)]" - set task_revision \ - [pm::task::edit \ - -task_item_id $task_item_id($num) \ - -project_item_id $project_item_id($num) \ - -title $task_title($num) \ - -description $description($num) \ - -mime_type $description_mime_type($num) \ - -end_date [set end_date_${num}(date)]\ - -percent_complete $percent_complete($num) \ - -estimated_hours_work $estimated_hours_work($num) \ - -estimated_hours_work_min $estimated_hours_work_min($num) \ - -estimated_hours_work_max $estimated_hours_work_max($num) \ - -update_user $user_id \ - -update_ip $peeraddr \ - -package_id $package_id \ - -priority $priority($num) ] - # -------------------------- - # remove all old assignments - # -------------------------- - pm::task::assign_remove_everyone \ - -task_item_id $task_item_id($num) + # -------------------------- + # remove all old assignments + # -------------------------- + pm::task::assign_remove_everyone \ + -task_item_id $task_item_id($num) - # ----------------------- - # remove all dependencies - # ----------------------- - pm::task::dependency_delete_all \ - -task_item_id $task_item_id($num) - - } - # ----------------------- - # add back in assignments + # remove all dependencies # ----------------------- + pm::task::dependency_delete_all \ + -task_item_id $task_item_id($num) - foreach ass $assignee { - regexp {(\d+)-(\d+)-(\d+)} $ass match num person role + } - set task $task_item_id($num) + # ----------------------- + # add back in assignments + # ----------------------- - pm::task::assign \ - -task_item_id $task \ - -party_id $person \ - -role_id $role - } + foreach ass $assignee { + regexp {(\d+)-(\d+)-(\d+)} $ass match num person role - # ----------------------- - # add in the dependencies - # ----------------------- - foreach num $number { - if {[exists_and_not_null dependency($num)]} { - pm::task::dependency_add \ - -task_item_id $task_item_id($num) \ - -parent_id $dependency($num) \ - -dependency_type finish_before_start \ - -project_item_id $project_item_id($num) - } + set task $task_item_id($num) + + pm::task::assign \ + -task_item_id $task \ + -party_id $person \ + -role_id $role + } + + # ----------------------- + # add in the dependencies + # ----------------------- + foreach num $number { + if {[exists_and_not_null dependency($num)]} { + pm::task::dependency_add \ + -task_item_id $task_item_id($num) \ + -parent_id $dependency($num) \ + -dependency_type finish_before_start \ + -project_item_id $project_item_id($num) } - } on_error { - ad_return_error "[_ project-manager.Error]" "[_ project-manager.There_was_an_error]" } + } else { # ----------------------------------- @@ -298,92 +266,89 @@ set process_instance_id "" } - db_transaction { - foreach num $number { + foreach num $number { - # -------------------------- - # figure out estimated hours - # -------------------------- + # -------------------------- + # figure out estimated hours + # -------------------------- - if {[string is true $use_uncertain_completion_times_p]} { - set estimated_hours_work($num) \ - [expr .5 * \ - ($estimated_hours_work_max($num) - \ - $estimated_hours_work_min($num)) + \ - $estimated_hours_work_min($num)] - } else { - set estimated_hours_work_min($num) $estimated_hours_work($num) - set estimated_hours_work_max($num) $estimated_hours_work($num) - } + if {[string is true $use_uncertain_completion_times_p]} { + set estimated_hours_work($num) \ + [expr .5 * \ + ($estimated_hours_work_max($num) - \ + $estimated_hours_work_min($num)) + \ + $estimated_hours_work_min($num)] + } else { + set estimated_hours_work_min($num) $estimated_hours_work($num) + set estimated_hours_work_max($num) $estimated_hours_work($num) + } - # ----------- - # create task - # ----------- + # ----------- + # create task + # ----------- - permission::require_permission -party_id $user_id -object_id $project_item_id($num) -privilege create + permission::require_permission -party_id $user_id -object_id $project_item_id($num) -privilege create - set task_item \ - [pm::task::new \ - -project_id $project_item_id($num) \ - -title $task_title($num) \ - -description $description($num) \ - -mime_type $description_mime_type($num) \ - -end_date [set end_date_${num}(date)]\ - -percent_complete $percent_complete($num) \ - -estimated_hours_work $estimated_hours_work($num) \ - -estimated_hours_work_min $estimated_hours_work_min($num) \ - -estimated_hours_work_max $estimated_hours_work_max($num) \ - -process_instance_id $process_instance_id \ - -creation_user $user_id \ - -creation_ip $peeraddr \ - -package_id $package_id \ - -priority $priority($num) + set task_item \ + [pm::task::new \ + -project_id $project_item_id($num) \ + -title $task_title($num) \ + -description $description($num) \ + -mime_type $description_mime_type($num) \ + -end_date [set end_date_${num}(date)]\ + -percent_complete $percent_complete($num) \ + -estimated_hours_work $estimated_hours_work($num) \ + -estimated_hours_work_min $estimated_hours_work_min($num) \ + -estimated_hours_work_max $estimated_hours_work_max($num) \ + -process_instance_id $process_instance_id \ + -creation_user $user_id \ + -creation_ip $peeraddr \ + -package_id $package_id \ + -priority $priority($num) ] - set task_item_id($num) $task_item - } + set task_item_id($num) $task_item + } - # ---------------- - # add in assignees - # ---------------- + # ---------------- + # add in assignees + # ---------------- - foreach ass $assignee { - regexp {(\d+)-(\d+)-(\d+)} $ass match num person role + foreach ass $assignee { + regexp {(\d+)-(\d+)-(\d+)} $ass match num person role - set task $task_item_id($num) + set task $task_item_id($num) - pm::task::assign \ - -task_item_id $task \ - -party_id $person \ - -role_id $role - } + pm::task::assign \ + -task_item_id $task \ + -party_id $person \ + -role_id $role + } - # ------------------- - # add in dependencies - # ------------------- - foreach num $number { + # ------------------- + # add in dependencies + # ------------------- + foreach num $number { - # if there is a numXX as the dependency, then we are relying - # on new tasks that had not been created yet. So we match them - # up with the new tasks we've just created. - if {[regexp {num(.*)} $dependency($num) match parent]} { - set dependency($num) $task_item_id($parent) - } + # if there is a numXX as the dependency, then we are relying + # on new tasks that had not been created yet. So we match them + # up with the new tasks we've just created. + if {[regexp {num(.*)} $dependency($num) match parent]} { + set dependency($num) $task_item_id($parent) + } - if {[exists_and_not_null dependency($num)]} { + if {[exists_and_not_null dependency($num)]} { - pm::task::dependency_add \ - -task_item_id $task_item_id($num) \ - -parent_id $dependency($num) \ - -dependency_type finish_before_start \ - -project_item_id $project_item_id($num) - } + pm::task::dependency_add \ + -task_item_id $task_item_id($num) \ + -parent_id $dependency($num) \ + -dependency_type finish_before_start \ + -project_item_id $project_item_id($num) } - - } on_error { - ad_return_error "[_ project-manager.Error]" "[_ project-manager.There_was_an_error]" } + } + # -------------------------------------------------------------------- # Internet Explorer sucks. It really really does. Due to length limits # on URLs for IE, we have to pass these variables through