RT#18834: Cacti integration [database storage]
[freeside.git] / httemplate / misc / cacti_graphs.html
1 <% include( '/elements/header.html', 'Cacti Graphs' ) %>
2
3 % if ($load) {
4
5 <FORM NAME="CactiGraphForm" ID="CactiGraphForm" style="margin-top: 0">
6 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
7 </FORM>
8 <% include( '/elements/progress-init.html',
9               'CactiGraphForm', 
10               [ 'svcnum' ],
11               $p.'misc/process/cacti_graphs.cgi',
12               { url => 'javascript:window.location.replace("'.popurl(2).'misc/cacti_graphs.html?svcnum='.$svcnum.'")' },
13 ) %>
14 <!--
15   note we use window.location.replace for the callback url above
16   so that this page gets removed from browser history after processing
17   so that process() doesn't get triggered by the back button
18 -->
19 <P>Loading graphs, please wait...</P>
20 <SCRIPT TYPE="text/javascript">
21 process();
22 </SCRIPT>
23
24 % } elsif ($error) {
25
26 <P><% emt($error) %></P>
27 <FORM NAME="CactiGraphForm" ID="CactiGraphForm" style="margin-top: 0">
28 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
29 <INPUT TYPE="hidden" NAME="load" VALUE="1">
30 <INPUT TYPE="submit" VALUE="Reload Graphs">
31 </FORM>
32
33 % } else {
34
35 <% $content %>
36
37 % }
38
39 <%init>
40 use File::Slurp qw( slurp );
41
42 die "access denied"
43   unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
44
45 my $svcnum    = $cgi->param('svcnum') or die 'Illegal svcnum';
46 my $load      = $cgi->param('load');
47 my $graphnum  = $cgi->param('graphnum') || '';
48
49 my ($content,$error);
50 unless ($load) {
51   my $page = qsearchs({
52     'table'    => 'cacti_page',
53     'hashref'  => { 'svcnum' => $svcnum, 'graphnum' => $graphnum },
54   });
55   if ($page) {
56     $content = $page->content;
57   } else {
58     $error = 'No graphs found in import cache.  Click below to retry import.';
59   }
60 }
61
62 </%init>
63