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.9 -r1.10 --- openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 21 Aug 2003 22:34:43 -0000 1.9 +++ openacs-4/contrib/packages/project-manager/www/task-add-edit.tcl 23 Aug 2003 00:24:34 -0000 1.10 @@ -56,18 +56,52 @@ # --------------------------------------------------------------- # +# 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 } -#if {[info exists end_date]} { -# for {set i 1} {$i <= $number} {incr i} { -# ns_log Notice "End_date: $end_date($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 project_term [parameter::get -parameter "ProjectName" -default "Project"] set task_term [parameter::get -parameter "TaskName" -default "Task"] @@ -124,7 +158,7 @@ } -select_query_name task_query -after_submit { - ad_returnredirect "task-constraint-add-edit?[export_vars -url task_revisions:multiple]" + ad_returnredirect "task-constraint-add-edit?[export_vars -url {task_revisions:multiple project_item_id}]" ad_script_abort } @@ -134,50 +168,41 @@ # DaveB showed me this trick. It lets you make a multiple out of # the items by stuffing them in an array. Long live DaveB. - append add_edit_definition " - {task_title.$i:text - {label \"Subject \#$i\"} - {html {size 39}} - } - - {description.$i:text(textarea) - {label \"Description\"} - {html {rows 7 cols 40}} - } - - {parent_id.$i:text(hidden) - } - - {end_date.$i:date,to_sql(linear_date),from_sql(sql_date) - {label \"End date\"} - {format \"MONTH DD YYYY\"} - {help} - } - - {estimated_hours_work_min.$i:integer - {label \"Hours estimate - min\"} - {html {size 3}} - } - - {estimated_hours_work_max.$i:integer - {label \"Hours estimate - max\"} - {html {size 3}} - } - " - + ad_form -extend -name add_edit -form \ + [list \ + [list \ + task_title.$i:text \ + {label "Subject \#$i"} \ + {html {size 39}} + ] \ + [list \ + description.$i:text(textarea) \ + {label "Description"} \ + {html {rows 7 cols 40}} + ] \ + [list \ + parent_id.$i:text(hidden) \ + ] \ + [list \ + end_date.$i:date,to_sql(linear_date) \ + {label "Deadline"} \ + {format "MONTH DD YYYY"} \ + {value {[util::date::today]}} \ + {help} \ + ] \ + [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}} \ + ] \ + ] } -ad_form -extend -name add_edit -form $add_edit_definition -# we are editing? -if {[exists_and_not_null task_id]} { - - ad_form -extend -name add_edit -form { - {percent_complete:integer - {label "Percent complete"} - {html {size 4}} - } -select_query_name task_query - } -}