3 In misc/something.html:
6 <INPUT TYPE="hidden" NAME="recordnum" VALUE="42">
7 <INPUT TYPE="hidden" NAME="what_to_do" VALUE="delete">
8 <% include( '/elements/progress-init.html',
10 [ 'recordnum', 'what_to_do' ],
11 $p.'misc/process_something.html',
12 { url => $p.'where_to_go_next.html' },
13 #or { message => 'Finished!' },
16 <SCRIPT TYPE="text/javascript>process();</SCRIPT>
18 In misc/process_something.html:
21 my $server = FS::UI::Web::JSRPC->new('FS::something::process_whatever', $cgi);
23 <% $server->process %>
27 sub process_whatever { #class method
29 my $param = thaw(base64_decode(shift));
30 # param = { 'recordnum' => 42, 'what_to_do' => delete }
31 # make use of this as you like
33 $job->update_statustext(20);
35 $job->update_statustext(40);
37 $job->update_statustext(60);
39 return 'this value will be ignored';
43 <% include('/elements/xmlhttp.html',
46 'subs' => [ 'start_job' ],
51 <% include('/elements/init_overlib.html') %>
53 <SCRIPT TYPE="text/javascript">
55 function <%$key%>process () {
57 //alert('<%$key%>process for form <%$formname%>');
59 if ( document.<%$formname%>.submit.disabled == false ) {
60 document.<%$formname%>.submit.disabled=true;
63 overlib( 'Submitting job to server...', WIDTH, 444, HEIGHT, 168, CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 );
65 var Hash = new Array();
68 for (var i = 0; i<document.<%$formname%>.elements.length; i++) {
69 field = document.<%$formname%>.elements[i];
70 if ( <% join(' || ', map { "(field.name.indexOf('$_') > -1)" } @$fields ) %>
73 if ( field.type == 'select-multiple' ) {
74 //alert('select-multiple ' + field.name);
75 for (var j=0; j < field.options.length; j++) {
76 if ( field.options[j].selected ) {
77 //alert(field.name + ' => ' + field.options[j].value);
78 Hash[x++] = field.name;
79 Hash[x++] = field.options[j].value;
82 } else if ( ( field.type != 'radio' && field.type != 'checkbox' )
83 || ( ( field.type == 'radio' || field.type == 'checkbox' )
84 && document.<%$formname%>.elements[i].checked
88 Hash[x++] = field.name;
89 Hash[x++] = field.value;
95 // jsrsExecute( '<% $action %>', <%$key%>myCallback, 'start_job', Hash );
97 //alert('start_job( ' + Hash + ', <%$key%>myCallback )' );
98 //alert('start_job()' );
99 <%$key%>start_job( Hash, <%$key%>myCallback );
103 function <%$key%>myCallback( jobnum ) {
105 overlib( OLiframeContent('<%$p%>elements/progress-popup.html?jobnum=' + jobnum + ';<%$url_or_message_link%>;formname=<%$formname%>' , 444, 168, '<% $popup_name %>'), CAPTION, 'Please wait...', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', CLOSECLICK, MIDX, 0, MIDY, 0 );
113 my( $formname, $fields, $action, $url_or_message, $key ) = @_;
114 $key = '' unless defined $key;
116 my $url_or_message_link;
117 if ( ref($url_or_message) ) { #its a message or something
118 $url_or_message_link = 'message='. uri_escape( $url_or_message->{'message'} );
119 $url_or_message_link .= ';url='. uri_escape( $url_or_message->{'url'} )
120 if $url_or_message->{'url'};
122 $url_or_message_link = "url=$url_or_message";
125 #stupid safari is caching the "location" of popup iframs, and submitting them
126 #instead of displaying them. this should prevent that.
127 my $popup_name = 'popup-'.time. "-$$-". rand() * 2**32;