add progressbar, redirection, and improve links RT#8274
[freeside.git] / httemplate / elements / progress-popup.html
index cda704a..a292102 100644 (file)
@@ -31,25 +31,36 @@ function updateStatus( status_statustext ) {
   var statusArray = eval('(' + status_statustext + ')');
   var status = statusArray[0];
   var statustext = statusArray[1];
+  var actiontext = statusArray[2];
 
   //if ( status == 'progress' ) {
   //IE workaround, no i have no idea why
   if ( status.indexOf('progress') > -1 ) {
+    document.getElementById("progress_message").innerHTML = actiontext + '...';
     document.getElementById("progress_percent").innerHTML = statustext + '%';
     bar1.set(statustext);
     bar1.update;
     //jsrsExecute( '<%$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<% $jobnum %>' );
     job_status( '<% $jobnum %>', updateStatus );
   } else if ( status.indexOf('complete') > -1 ) {
-% if ( $message ) { 
+% if ( $message ) {
+%
+%   my $onClick = $url
+%                   ? "window.top.location.href = \\'$url\\';"
+%                   : 'parent.nd(1);';
 
     document.getElementById("progress_message").innerHTML = "<% $message %>";
     document.getElementById("progress_bar").innerHTML = '';
-    document.getElementById("progress_percent").innerHTML = '<INPUT TYPE="button" VALUE="OK" onClick="parent.nd(1);">';
+    document.getElementById("progress_percent").innerHTML =
+      '<INPUT TYPE="button" VALUE="OK" onClick="<% $onClick %>">';
     document.getElementById("progress_jobnum").innerHTML = '';
-    if ( parent.document.<%$formname%>.submit.disabled == true ) {
-      parent.document.<%$formname%>.submit.disabled=false;
-    }
+
+%   unless ( $url ) {
+        if ( parent.document.<%$formname%>.submit.disabled == true ) {
+          parent.document.<%$formname%>.submit.disabled=false;
+        }
+%   }
+
 % } elsif ( $url ) { 
 
     window.top.location.href = '<% $url %>';
@@ -58,6 +69,14 @@ function updateStatus( status_statustext ) {
     alert('job done but no url or message specified');
 % } 
 
+  } else if ( status.indexOf('done') > -1 ) {
+
+    document.getElementById("progress_message").innerHTML = "Loading report";
+    document.getElementById("progress_bar").innerHTML = '';
+    document.getElementById("progress_percent").innerHTML = '';
+    document.getElementById("progress_jobnum").innerHTML = '';
+    window.top.location.href = statustext.substr(8, statustext.length-18);
+
   } else if ( status.indexOf('error') > -1 ) {
     document.getElementById("progress_message").innerHTML = '<FONT SIZE="+1" COLOR="#FF0000">Error: ' + statustext + '</FONT>';
     document.getElementById("progress_bar").innerHTML = '';