generalize progressbar code in preparation for using it wherever needed
[freeside.git] / httemplate / misc / progress.html
1 <%
2   my( $jobnum ) = $cgi->param('jobnum');
3   my( $url ) = $cgi->param('url');
4   my $job = '';
5   if ( $jobnum =~ /^(\d+)$/ ) {
6     $job = qsearchs('queue', { 'jobnum' => $jobnum } );
7   }
8   if ( $job && $job->status ne 'failed' ) {
9 %>
10
11 <HTML>
12   <HEAD>
13     <TITLE>
14       Please wait...
15     </TITLE>
16     <META HTTP-Equiv="Cache-Control" Content="no-cache">
17     <META HTTP-Equiv="Pragma" Content="no-cache">
18     <META HTTP-Equiv="Expires" Content="0"> 
19
20     <!-- could do more JSRS magic and avoid refreshing... but works for now -->
21     <META HTTP-Equiv="Refresh" Content="5">
22   </HEAD>
23   <BODY BGCOLOR="#e8e8e8">
24     <P ALIGN="center">Please wait...
25     <script TYPE="text/javascript" src="../elements/qlib/control.js"></script>
26     <script TYPE="text/javascript" src="../elements/qlib/imagelist.js"></script>
27     <script TYPE="text/javascript" src="../elements/qlib/progress.js"></script>
28     <P ALIGN="center">
29     <script TYPE="text/javascript">
30       // Create imagelist
31       SEGS = new QImageList(4, 23, "../images/progressbar-empty.png", "../images/progressbar-full.png");
32
33       // Create bars
34       bar1 = new QProgress(null, "bar1", SEGS, 100);
35       bar1.set(<%= $job->statustext %>);
36       // bar1.update;
37     </script>
38     <BR><%= $job->statustext %>%
39     <P ALIGN="center">(progress of job #<%= $jobnum %>)
40   </BODY>
41 </HTML>
42
43 <%
44   } elsif ( !$job ) { #handle job gone case : job sucessful
45                       # so close popup, redirect parent window...
46     #eidiot("write success handler (jobnum $jobnum)");
47 %>
48
49 <HTML>
50   <HEAD>
51     <TITLE>
52       Operation successful
53     </TITLE>
54     <META HTTP-Equiv="Cache-Control" Content="no-cache">
55     <META HTTP-Equiv="Pragma" Content="no-cache">
56     <META HTTP-Equiv="Expires" Content="0"> 
57
58   </HEAD>
59   <BODY BGCOLOR="#e8e8e8">
60     <SCRIPT TYPE="text/javascript">
61       top.opener.window.location.href = '<%= $cgi->param('url') %>';
62       window.close();
63     </SCRIPT>
64   </BODY>
65 </HTML>
66
67 <%
68   } else {
69 %>
70
71   <HEAD>
72     <TITLE>
73       Error
74     </TITLE>
75     <META HTTP-Equiv="Cache-Control" Content="no-cache">
76     <META HTTP-Equiv="Pragma" Content="no-cache">
77     <META HTTP-Equiv="Expires" Content="0"> 
78   </HEAD>
79   <BODY BGCOLOR="#e8e8e8">
80     <P ALIGN="center"><FONT COLOR="#ff0000">Error: <%= $job ? $job->statustext : $jobnum %></FONT>
81     <P ALIGN="center"><INPUT TYPE="button" onClick="top.opener.document.OneTrueForm.submit.disabled=false; window.close();" VALUE="OK">
82   </BODY>
83 </HTML>
84
85 <% } %>
86
87
88