X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fcacti_graphs.html;h=9a90b894d84eb752419665915308d8dc1b1dc392;hp=9cc5e24941805d3d5978059b570a34da82947c69;hb=acb5db886076201922167d39d76fd9b3e9e54c9c;hpb=d9db63d82fce670cc3c21f86e577dd99c3d14028 diff --git a/httemplate/misc/cacti_graphs.html b/httemplate/misc/cacti_graphs.html index 9cc5e2494..9a90b894d 100644 --- a/httemplate/misc/cacti_graphs.html +++ b/httemplate/misc/cacti_graphs.html @@ -21,33 +21,58 @@ process(); -% } else { -% if ($error) { +% } elsif ($error) { -

<% $error %>

+

<% emt($error) %>

+
+ + + +
-% } else { +% } else { -<% slurp($htmlfile) %> +<% $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 $graphnum = $cgi->param('graphnum') || ''; -my $htmlfile = $FS::UID::cache_dir - . '/cacti-graphs/' - . 'svc_' - . $svcnum; -$htmlfile .= '_graph_' . $graphnum - if $graphnum; -$htmlfile .= '.html'; +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.'; + } +} -my $error = (-e $htmlfile) ? '' : 'File not found';