|
set process $conn[now tag]
global todomgr_datasheets
set pipe [open "|${todomgr_home}pdm datasheet [ns_set get $form start] [ns_set get $form ver] $process" "r"]
set datasheet [read $pipe]
close $pipe
set pipe [open "$todomgr_datasheets/$process" "w"]
puts $pipe $datasheet
close $pipe
set size [ns_set size $form]
for {set i 0} {$i < $size} {incr i} {
if {-1 < [lsearch {start ver} [ns_set key $form $i]]} { continue }
datasheet_setvalue $process "" [ns_set key $form $i] "" [ns_set value $form $i]
}
set pipe [open "|${todomgr_home}wftk start $process" "r"]
set workflow [read $pipe]
close $pipe
set wf [split $workflow \n]
set fields [list id status started]
set values [list '$process' 'active' '[now]']
lappend fields title
set title [string range [lindex $wf 0] 2 end]
lappend values "'[sql_safe_string $title]'"
set wf [lrange $wf 2 end]
while {![string compare "" [lindex $wf 0]]} { set wf [lrange $wf 1 end] }
set desc ""
while {[string compare EOF [lindex $wf 0]]} {
append desc "[lindex $wf 0] "
set wf [lrange $wf 1 end]
}
set wf [lrange $wf 1 end]
lappend fields description
lappend values "'[sql_safe_string $desc]'"
lappend fields owner
lappend values "'[sql_safe_string $user]'"
lappend fields definition
set procdef "[ns_set get $form start]_[ns_set get $form ver].xml"
lappend values "'[sql_safe_string $procdef]'"
lappend fields datasheet
lappend values "'$process'"
set query "insert into process ("
append query [join $fields ", "]
append query ") values ("
append query [join $values ", "]
append query ")"
ns_db dml $db $query
wftk_interpret $db $process $wf
return [ns_returnredirect $conn overview?process=$process]
|