summaryrefslogtreecommitdiff
path: root/httemplate/misc/cacti_graphs.html
blob: 9a90b894d84eb752419665915308d8dc1b1dc392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<% include( '/elements/header.html', 'Cacti Graphs' ) %>

% if ($load) {

<FORM NAME="CactiGraphForm" ID="CactiGraphForm" style="margin-top: 0">
<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
</FORM>
<% include( '/elements/progress-init.html',
              'CactiGraphForm', 
              [ 'svcnum' ],
              $p.'misc/process/cacti_graphs.cgi',
              { url => 'javascript:window.location.replace("'.popurl(2).'misc/cacti_graphs.html?svcnum='.$svcnum.'")' },
) %>
<!--
  note we use window.location.replace for the callback url above
  so that this page gets removed from browser history after processing
  so that process() doesn't get triggered by the back button
-->
<P>Loading graphs, please wait...</P>
<SCRIPT TYPE="text/javascript">
process();
</SCRIPT>

% } elsif ($error) {

<P><% emt($error) %></P>
<FORM NAME="CactiGraphForm" ID="CactiGraphForm" style="margin-top: 0">
<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
<INPUT TYPE="hidden" NAME="load" VALUE="1">
<INPUT TYPE="submit" VALUE="Reload Graphs">
</FORM>

% } else {

<% $content %>

% }

<%init>
use File::Slurp qw( slurp );

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('View customer services');

my $svcnum    = $cgi->param('svcnum') or die 'Illegal svcnum';

# false laziness with view/elements/svc_Common.html
# only doing this to check agent access, don't actually use $svc_x
my $svc_x = qsearchs({
  'select'    => 'svc_broadband.*',
  'table'     => 'svc_broadband',
  'addl_from' => ' LEFT JOIN cust_svc  USING ( svcnum  ) '.
                 ' LEFT JOIN cust_pkg  USING ( pkgnum  ) '.
                 ' LEFT JOIN cust_main USING ( custnum ) ',
  'hashref'   => { 'svcnum' => $svcnum },
  'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql(
                            'null_right' => 'View/link unlinked services'
                          ),
}) or die "Unknown svcnum $svcnum in svc_broadband table\n";

my $load      = $cgi->param('load');
my $graphnum  = $cgi->param('graphnum') || '';

my ($content,$error);
unless ($load) {
  my $page = qsearchs({
    'table'    => 'cacti_page',
    'hashref'  => { 'svcnum' => $svcnum, 'graphnum' => $graphnum },
  });
  if ($page) {
    $content = $page->content;
  } else {
    $error = 'No graphs found in import cache.  Click below to retry import.';
  }
}

</%init>