pro trace_submit_request, qfile=qfile, debug=debug
;+
;   Name: trace_submit_request
;
;   Purpose: post processing of WWW data request - append options->success file
;
;   Keyword Parameters:
;      qfile - WWW Post Query filename  
;  
;   History:
;     19-May-1998 - S.L.Freeland
;-
debug=keyword_set(debug)
configure_http,/trace                     ; set WWW defaults to TRACE

; --------------- read and decode the FORM input -----------
break_file,qfile,log,paths,qfil,qver,qext
qfile=concat_dir(concat_dir(get_logenv('path_http'),'text_client'),qfil+qver+qext)
outfil=qfile + '.text'
qstr=url_decode(qfile=qfile)
tnames=tag_names(qstr)
bad_success=concat_dir(paths,'bad_success.dat')
success_file=gt_tagval(qstr,/success_file,missing=bad_success)
break_file,success_file,ll,pp,ff,ee,vv
sfname=ff+ee+vv
; --------------- -----------------------------------------

; ----------  derive HTML output document ---------------------
htmlfile=str_replace(outfil,'text','html')
html_doc,htmlfile,/header
file_append,htmlfile,['<em>Your <b>TRACE</b> data request was submitted for offline processing', $
  '<br>We will notify <b>'+gt_tagval(qstr,/email,missing='????') + '</b> when complete<p><b>Job Description</b>']	     
for i=1,n_tags(qstr)-1 do begin
     file_append, htmlfile, '<br><em>' + tnames(i)+ $              ; update WWW
     '</em>&#32 <font color=red>' + qstr.(i) +'</font>
     file_append,success_file,';;; ' + tnames(i) + ':' + qstr.(i)  ; -> success
endfor

; ------- now copy option appended success -> order queue ----------
order_dir=concat_dir(concat_dir(concat_dir('path_http','Data'),'orders'),'requested')
ordername=concat_dir(order_dir,sfname)
file_append,ordername,rd_tfile(success_file),/new       ; copy -> order queue

html_doc,htmlfile,/trailer
; ----------------------------------------------------------------
if debug then stop

return
end

