diff options
author | ivan <ivan> | 2008-08-14 11:56:07 +0000 |
---|---|---|
committer | ivan <ivan> | 2008-08-14 11:56:07 +0000 |
commit | 5da73ac30a52234cc126ead03cddaf5a4e131019 (patch) | |
tree | d08cb1c00097483f0a6f767601390371714e4b40 /httemplate/elements/form-file_upload.html | |
parent | 5d4d60dd8cbe71a96256b6c375f01e0182296f18 (diff) |
customer import: add progress bar & redirect to a search of the imported customers, #3475
Diffstat (limited to 'httemplate/elements/form-file_upload.html')
-rw-r--r-- | httemplate/elements/form-file_upload.html | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/httemplate/elements/form-file_upload.html b/httemplate/elements/form-file_upload.html new file mode 100644 index 000000000..f398ba42d --- /dev/null +++ b/httemplate/elements/form-file_upload.html @@ -0,0 +1,93 @@ +<%doc> + +Example: + + <% include( '/elements/form-file_upload.html', + + 'name' => 'form_name', + 'action' => 'process/target.cgi', #progress-init target + 'fields' => [ 'other', 'form', 'fields' ], + 'num_files' => 1, #or more + + 'url' => $url + #OR + 'message' => 'Message', + + #optional + 'key' => 'unique_key', #for using more than once on a page + ) + +% #... + +% # num_files=>1 + include( '/elements/file-upload.html', + 'field' => 'element', + 'label' => 'Label', + ) + +% # OR + +% # num_files=>2 # or more + include( '/elements/file-upload.html', + 'field' => [ 'element', 'element2', ], #etc. + 'label' => [ 'Label', 'Label2', ], #etc. + ) + + +%> + +</%doc> + +<% include( '/elements/progress-init.html', + $opt{name}, + $opt{fields}, + $opt{action}, + $msg_or_url, + $opt{key}, + ) +%> + +<SCRIPT> + + function <% $opt{key} %>gotUploaded(success, message) { + + var uploaded = document.getElementById('uploaded_files'); + var a = uploaded.value.split(','); + if (uploaded.value.split(',').length == <% $opt{num_files} %>){ + process(); + }else{ + var p = document.getElementById('uploadError'); + p.innerHTML='<FONT SIZE="+1" COLOR="#ff0000">Error: '+message+'</FONT><BR><BR>'; + p.style='display:visible'; + return false; + } + + } + +</SCRIPT> + +<div style="display:none:" id="uploadError"></div> + +<FORM NAME = "<% $opt{name} %>" + ACTION = "<% $fsurl %>misc/file-upload.html" + METHOD = "POST" + ENCTYPE = "multipart/form-data" + onSubmit = "return doUpload(this, <% $opt{key} %>gotUploaded)" +> + +<%init> + +#my( $formname, $fields, $action, $url_or_message, $key ) = @_; +my %opt = ref($_[0]) ? %{ $_[0] } : @_; + +my $key = exists $opt{key} ? $opt{key} : ''; + +push @{ $opt{fields} }, 'uploaded_files'; + +my $msg_or_url = $opt{message} + ? { 'message' => $opt{message}, + 'url' => $opt{url}, + } + : $opt{url}; + +</%init> |