Index: openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/Attic/simulation-casting-2.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl 6 Jan 2004 14:56:42 -0000 1.16 +++ openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl 6 Jan 2004 16:26:37 -0000 1.17 @@ -6,126 +6,134 @@ simulation::template::get -workflow_id $workflow_id -array sim_template -set page_title "Cast $sim_template(pretty_name)" -set context [list [list "." "SimInst"] $page_title] -set package_id [ad_conn package_id] +if { ![string equal $sim_template(sim_type) "casting_sim"] } { + set page_title "Begin Casting" + set begin_casting_url [export_vars -base simulation-casting { workflow_id {return_url {[ad_return_url]}} }] -subsite::get -array closest_subsite -set group_admin_url "${closest_subsite(url)}admin/group-types/one?group_type=group" +} else { -# TODO: verify that prepopulated values work correctly + set page_title "Cast $sim_template(pretty_name)" + set package_id [ad_conn package_id] -# TODO: provide more sensible default dates? -# Notification send could be start date minus some parameter -set in_a_month_date [clock format [expr [clock seconds] + 3600*24*31] -format "%Y-%m-%d"] -set in_two_months_date [clock format [expr [clock seconds] + 2*3600*24*31] -format "%Y-%m-%d"] -set in_two_and_a_half_months_date [clock format [expr [clock seconds] + 3*3600*24*31 - 3600*24*15] -format "%Y-%m-%d"] -set in_three_months_date [clock format [expr [clock seconds] + 3*3600*24*31] -format "%Y-%m-%d"] -set in_four_months_date [clock format [expr [clock seconds] + 4*3600*24*31] -format "%Y-%m-%d"] + subsite::get -array closest_subsite + set group_admin_url "${closest_subsite(url)}admin/group-types/one?group_type=group" -set eligible_groups [simulation::casting_groups -workflow_id $workflow_id] + # TODO: verify that prepopulated values work correctly -ad_form -export { workflow_id } -name simulation -form { - {enroll_type:text(radio) - {label "Enrollment type"} - {options {{"By invitation only" closed} {Open open}}} - {html {onChange "javascript:FormRefresh('simulation');"}} - } - {enroll_start:date,to_sql(ansi),from_sql(ansi),optional - {label "Enrollment start date"} - } - {enroll_end:date,to_sql(ansi),from_sql(ansi),optional - {label "Enrollment end date"} - } - {send_start_note_date:date,to_sql(ansi),from_sql(ansi),optional - {label "Date to send start notification (mockup only)"} - } - {case_start:date,to_sql(ansi),from_sql(ansi),optional - {label "Simulation start date"} - } - {case_end:date,to_sql(ansi),from_sql(ansi),optional - {label "Simulation end date"} - } - {casting_type:text(radio) - {label "Casting type"} - {options {{Automatic auto} {Group group} {Open open}}} - } - {auto_enroll:integer(checkbox),multiple,optional - {label "Enroll all users in these groups"} - {options $eligible_groups} - {help_text {Use Group Administration to add groups}} - } - {invite_groups:integer(checkbox),multiple,optional - {label "Invite all users in these groups (mockup only)"} - {options $eligible_groups} - {help_text {Use Group Administration to add groups}} - } -} -on_request { + # TODO: provide more sensible default dates? + # Notification send could be start date minus some parameter + set in_a_month_date [clock format [expr [clock seconds] + 3600*24*31] -format "%Y-%m-%d"] + set in_two_months_date [clock format [expr [clock seconds] + 2*3600*24*31] -format "%Y-%m-%d"] + set in_two_and_a_half_months_date [clock format [expr [clock seconds] + 3*3600*24*31 - 3600*24*15] -format "%Y-%m-%d"] + set in_three_months_date [clock format [expr [clock seconds] + 3*3600*24*31] -format "%Y-%m-%d"] + set in_four_months_date [clock format [expr [clock seconds] + 4*3600*24*31] -format "%Y-%m-%d"] - foreach elm { - enroll_type - casting_type - enroll_start - enroll_end - case_start - case_end - send_start_note_date - } { - set $elm $sim_template($elm) - } + set eligible_groups [simulation::casting_groups -workflow_id $workflow_id] - set auto_enroll [simulation::template::get_parties -workflow_id $workflow_id -rel_type auto_enroll] + ad_form -export { workflow_id } -name simulation -form { + {enroll_type:text(radio) + {label "Enrollment type"} + {options {{"By invitation only" closed} {Open open}}} + {html {onChange "javascript:FormRefresh('simulation');"}} + } + {enroll_start:date,to_sql(ansi),from_sql(ansi),optional + {label "Enrollment start date"} + } + {enroll_end:date,to_sql(ansi),from_sql(ansi),optional + {label "Enrollment end date"} + } + {send_start_note_date:date,to_sql(ansi),from_sql(ansi),optional + {label "Date to send start notification (mockup only)"} + } + {case_start:date,to_sql(ansi),from_sql(ansi),optional + {label "Simulation start date"} + } + {case_end:date,to_sql(ansi),from_sql(ansi),optional + {label "Simulation end date"} + } + {casting_type:text(radio) + {label "Casting type"} + {options {{Automatic auto} {Group group} {Open open}}} + } + {auto_enroll:integer(checkbox),multiple,optional + {label "Enroll all users in these groups"} + {options $eligible_groups} + {help_text {Use Group Administration to add groups}} + } + {invite_groups:integer(checkbox),multiple,optional + {label "Invite all users in these groups (mockup only)"} + {options $eligible_groups} + {help_text {Use Group Administration to add groups}} + } + } -on_request { - # Default values - if { [empty_string_p $enroll_start] } { - set enroll_start $in_a_month_date - } - if { [empty_string_p $enroll_end] } { - set enroll_end $in_two_months_date - } - if { [empty_string_p $send_start_note_date] } { - set send_start_note_date $in_two_and_a_half_months_date - } - if { [empty_string_p $case_start] } { - set case_start $in_three_months_date - } - if { [empty_string_p $case_end] } { - set case_end $in_three_months_date - } - if { [empty_string_p $enroll_type] } { - set enroll_type "closed" - } - if { [empty_string_p $casting_type] } { - set casting_type "auto" - } + foreach elm { + enroll_type + casting_type + enroll_start + enroll_end + case_start + case_end + send_start_note_date + } { + set $elm $sim_template($elm) + } - if { [string equal $enroll_type "closed"] } { - element set_properties simulation enroll_start -widget hidden - element set_properties simulation enroll_end -widget hidden - } + set auto_enroll [simulation::template::get_parties -workflow_id $workflow_id -rel_type auto_enroll] -} -on_refresh { + # Default values + if { [empty_string_p $enroll_start] } { + set enroll_start $in_a_month_date + } + if { [empty_string_p $enroll_end] } { + set enroll_end $in_two_months_date + } + if { [empty_string_p $send_start_note_date] } { + set send_start_note_date $in_two_and_a_half_months_date + } + if { [empty_string_p $case_start] } { + set case_start $in_three_months_date + } + if { [empty_string_p $case_end] } { + set case_end $in_three_months_date + } + if { [empty_string_p $enroll_type] } { + set enroll_type "closed" + } + if { [empty_string_p $casting_type] } { + set casting_type "auto" + } - if { [string equal $enroll_type "closed"] } { - element set_properties simulation enroll_start -widget hidden - element set_properties simulation enroll_end -widget hidden - } else { - element set_properties simulation enroll_start -widget date - element set_properties simulation enroll_end -widget date - } + if { [string equal $enroll_type "closed"] } { + element set_properties simulation enroll_start -widget hidden + element set_properties simulation enroll_end -widget hidden + } -} -on_submit { - foreach elm { enroll_start enroll_end send_start_note_date case_start case_end enroll_type casting_type auto_enroll } { - set row($elm) [set $elm] - } - - # TODO: add invite_gropus to list of elements above + } -on_refresh { - simulation::template::edit \ - -workflow_id $workflow_id \ - -array row + if { [string equal $enroll_type "closed"] } { + element set_properties simulation enroll_start -widget hidden + element set_properties simulation enroll_end -widget hidden + } else { + element set_properties simulation enroll_start -widget date + element set_properties simulation enroll_end -widget date + } - wizard forward + } -on_submit { + foreach elm { enroll_start enroll_end send_start_note_date case_start case_end enroll_type casting_type auto_enroll } { + set row($elm) [set $elm] + } + + # TODO: add invite_gropus to list of elements above + + simulation::template::edit \ + -workflow_id $workflow_id \ + -array row + + wizard forward + } + + wizard submit simulation -buttons { back next } } -wizard submit simulation -buttons { back next } +set context [list [list "." "SimInst"] $page_title]