Index: openacs-4/contrib/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/template-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 15 Dec 2003 13:40:22 -0000 1.12 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 15 Dec 2003 14:50:12 -0000 1.13 @@ -133,73 +133,55 @@ # Update sim_simulations table set set_clauses [list] - foreach col {sim_type suggested_duration} { + foreach col {sim_type enroll_type casting_type} { if { [info exists edit_array($col)] } { - if { [string equal $col suggested_duration] } { - # Suggested duration needs special interval update syntax - if { [empty_string_p $edit_array($col)] } { - lappend set_clauses "$col = null" - } else { - lappend set_clauses "$col = (interval '$edit_array($col)')" - } - } else { - lappend set_clauses "$col = :$col" - } - + lappend set_clauses "$col = :$col" set $col $edit_array($col) } } + if { [info exists edit_array(suggested_duration)] } { + if { [empty_string_p $edit_array($col)] } { + lappend set_clauses "$col = null" + } else { + lappend set_clauses "$col = (interval '$edit_array($col)')" + } + + set parties $edit_array(suggested_duration) + } + + foreach col {enroll_start enroll_end send_start_note_date case_start case_end} { + if { [info exists edit_array($col)] } { + lappend set_clauses "$col = to_date(:$col, 'YYYY-MM-DD')" + set $col $edit_array($col) + } + } + if { [llength $set_clauses] > 0 } { db_dml edit_sim " update sim_simulations set [join $set_clauses ", "] where simulation_id=:workflow_id " } - } -} -ad_proc -public simulation::template::instantiate_edit { - {-workflow_id:required} - {-enroll_start:required} - {-enroll_end:required} - {-notification_date:required} - {-case_start:required} - {-case_end:required} - {-enroll_type:required} - {-casting_type:required} - {-parties:required} -} { - Edit properties of a simulation set during instantiation. - - TODO: merge this proc with ::edit? + # Update sim_party_sim_map table - @author Peter Marklund -} { - db_dml update_instantiate_template { - update sim_simulations - set enroll_start = to_date(:enroll_start, 'YYYY-MM-DD'), - enroll_end = to_date(:enroll_end, 'YYYY-MM-DD'), - send_start_note_date = to_date(:notification_date, 'YYYY-MM-DD'), - case_start = to_date(:case_start, 'YYYY-MM-DD'), - case_end = to_date(:case_end, 'YYYY-MM-DD'), - enroll_type = :enroll_type, - casting_type = :casting_type - where simulation_id = :workflow_id - } + if { [info exists edit_array(parties)] } { - # Clear out old mappings first - db_dml clear_old_mappings { - delete from sim_party_sim_map - where simulation_id = :workflow_id - } + # Clear out old mappings first + db_dml clear_old_mappings { + delete from sim_party_sim_map + where simulation_id = :workflow_id + } - foreach party_id $parties { - db_dml map_party_to_template { - insert into sim_party_sim_map - (simulation_id, party_id) - values (:workflow_id, :party_id) + foreach party_id $edit_array(parties) { + db_dml map_party_to_template { + insert into sim_party_sim_map + (simulation_id, party_id) + values (:workflow_id, :party_id) + } + } } } } Index: openacs-4/contrib/packages/simulation/www/simbuild/template-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simbuild/Attic/template-edit.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/contrib/packages/simulation/www/simbuild/template-edit.tcl 15 Dec 2003 13:40:22 -0000 1.10 +++ openacs-4/contrib/packages/simulation/www/simbuild/template-edit.tcl 15 Dec 2003 14:50:12 -0000 1.11 @@ -152,4 +152,3 @@ set delete_url [export_vars -base template-delete { workflow_id }] set spec_url [export_vars -base template-spec { workflow_id }] - Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-casting-2.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-2.tcl 15 Dec 2003 10:40:49 -0000 1.4 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-2.tcl 15 Dec 2003 14:50:12 -0000 1.5 @@ -4,7 +4,9 @@ workflow_id:integer } -set page_title "Cast simulation" +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] @@ -45,13 +47,13 @@ } {enroll_type:text(radio) {label "Enrollment type"} - {options {{Closed closed} {Open closed}}} - {value closed} + {options {{Invite invite} {Open open}}} + {value $sim_template(enroll_type)} } {casting_type:text(radio) {label "Casting type"} - {options {{Automatic automatic} {Group group} {Open open}}} - {value automatic} + {options {{Automatic auto} {Group group} {Open open}}} + {value $sim_template(casting_type)} } {user_group:integer(checkbox),multiple,optional {label "Invite all users in these groups"} @@ -65,19 +67,20 @@ set ${var_name}_ansi "[lindex [set $var_name] 0]-[lindex [set $var_name] 1]-[lindex [set $var_name] 2]" } - simulation::template::instantiate_edit \ + array unset sim_template + set sim_template(enroll_start) $enroll_start_ansi + set sim_template(enroll_end) $enroll_end_ansi + set sim_template(notification_date) $notification_date_ansi + set sim_template(case_start) $case_start_ansi + set sim_template(case_end) $case_end_ansi + set sim_template(enroll_type) $enroll_type + set sim_template(casting_type) $casting_type + set sim_template(parties $user_group + + simulation::template::edit \ -workflow_id $workflow_id \ - -enroll_start $enroll_start_ansi \ - -enroll_end $enroll_end_ansi \ - -notification_date $notification_date_ansi \ - -case_start $case_start_ansi \ - -case_end $case_end_ansi \ - -enroll_type $enroll_type \ - -casting_type $casting_type \ - -parties $user_group + -array sim_template - # Proceed to - ad_returnredirect [export_vars -base "simulation-casting-2" { workflow_id }] + ad_returnredirect . ad_script_abort } - Index: openacs-4/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/template-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/simulation/tcl/template-procs.tcl 15 Dec 2003 13:40:22 -0000 1.12 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 15 Dec 2003 14:50:12 -0000 1.13 @@ -133,73 +133,55 @@ # Update sim_simulations table set set_clauses [list] - foreach col {sim_type suggested_duration} { + foreach col {sim_type enroll_type casting_type} { if { [info exists edit_array($col)] } { - if { [string equal $col suggested_duration] } { - # Suggested duration needs special interval update syntax - if { [empty_string_p $edit_array($col)] } { - lappend set_clauses "$col = null" - } else { - lappend set_clauses "$col = (interval '$edit_array($col)')" - } - } else { - lappend set_clauses "$col = :$col" - } - + lappend set_clauses "$col = :$col" set $col $edit_array($col) } } + if { [info exists edit_array(suggested_duration)] } { + if { [empty_string_p $edit_array($col)] } { + lappend set_clauses "$col = null" + } else { + lappend set_clauses "$col = (interval '$edit_array($col)')" + } + + set parties $edit_array(suggested_duration) + } + + foreach col {enroll_start enroll_end send_start_note_date case_start case_end} { + if { [info exists edit_array($col)] } { + lappend set_clauses "$col = to_date(:$col, 'YYYY-MM-DD')" + set $col $edit_array($col) + } + } + if { [llength $set_clauses] > 0 } { db_dml edit_sim " update sim_simulations set [join $set_clauses ", "] where simulation_id=:workflow_id " } - } -} -ad_proc -public simulation::template::instantiate_edit { - {-workflow_id:required} - {-enroll_start:required} - {-enroll_end:required} - {-notification_date:required} - {-case_start:required} - {-case_end:required} - {-enroll_type:required} - {-casting_type:required} - {-parties:required} -} { - Edit properties of a simulation set during instantiation. - - TODO: merge this proc with ::edit? + # Update sim_party_sim_map table - @author Peter Marklund -} { - db_dml update_instantiate_template { - update sim_simulations - set enroll_start = to_date(:enroll_start, 'YYYY-MM-DD'), - enroll_end = to_date(:enroll_end, 'YYYY-MM-DD'), - send_start_note_date = to_date(:notification_date, 'YYYY-MM-DD'), - case_start = to_date(:case_start, 'YYYY-MM-DD'), - case_end = to_date(:case_end, 'YYYY-MM-DD'), - enroll_type = :enroll_type, - casting_type = :casting_type - where simulation_id = :workflow_id - } + if { [info exists edit_array(parties)] } { - # Clear out old mappings first - db_dml clear_old_mappings { - delete from sim_party_sim_map - where simulation_id = :workflow_id - } + # Clear out old mappings first + db_dml clear_old_mappings { + delete from sim_party_sim_map + where simulation_id = :workflow_id + } - foreach party_id $parties { - db_dml map_party_to_template { - insert into sim_party_sim_map - (simulation_id, party_id) - values (:workflow_id, :party_id) + foreach party_id $edit_array(parties) { + db_dml map_party_to_template { + insert into sim_party_sim_map + (simulation_id, party_id) + values (:workflow_id, :party_id) + } + } } } } Index: openacs-4/packages/simulation/www/simbuild/template-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simbuild/template-edit.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/simulation/www/simbuild/template-edit.tcl 15 Dec 2003 13:40:22 -0000 1.10 +++ openacs-4/packages/simulation/www/simbuild/template-edit.tcl 15 Dec 2003 14:50:12 -0000 1.11 @@ -152,4 +152,3 @@ set delete_url [export_vars -base template-delete { workflow_id }] set spec_url [export_vars -base template-spec { workflow_id }] - 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.4 -r1.5 --- openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl 15 Dec 2003 10:40:49 -0000 1.4 +++ openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl 15 Dec 2003 14:50:12 -0000 1.5 @@ -4,7 +4,9 @@ workflow_id:integer } -set page_title "Cast simulation" +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] @@ -45,13 +47,13 @@ } {enroll_type:text(radio) {label "Enrollment type"} - {options {{Closed closed} {Open closed}}} - {value closed} + {options {{Invite invite} {Open open}}} + {value $sim_template(enroll_type)} } {casting_type:text(radio) {label "Casting type"} - {options {{Automatic automatic} {Group group} {Open open}}} - {value automatic} + {options {{Automatic auto} {Group group} {Open open}}} + {value $sim_template(casting_type)} } {user_group:integer(checkbox),multiple,optional {label "Invite all users in these groups"} @@ -65,19 +67,20 @@ set ${var_name}_ansi "[lindex [set $var_name] 0]-[lindex [set $var_name] 1]-[lindex [set $var_name] 2]" } - simulation::template::instantiate_edit \ + array unset sim_template + set sim_template(enroll_start) $enroll_start_ansi + set sim_template(enroll_end) $enroll_end_ansi + set sim_template(notification_date) $notification_date_ansi + set sim_template(case_start) $case_start_ansi + set sim_template(case_end) $case_end_ansi + set sim_template(enroll_type) $enroll_type + set sim_template(casting_type) $casting_type + set sim_template(parties $user_group + + simulation::template::edit \ -workflow_id $workflow_id \ - -enroll_start $enroll_start_ansi \ - -enroll_end $enroll_end_ansi \ - -notification_date $notification_date_ansi \ - -case_start $case_start_ansi \ - -case_end $case_end_ansi \ - -enroll_type $enroll_type \ - -casting_type $casting_type \ - -parties $user_group + -array sim_template - # Proceed to - ad_returnredirect [export_vars -base "simulation-casting-2" { workflow_id }] + ad_returnredirect . ad_script_abort } -