summaryrefslogtreecommitdiff
path: root/httemplate/view/port_graph.html
blob: fc5d0db3fa8194fb3ab79bd5bd25e992a512af99 (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
% if ($error) { warn $error; }
% else {
<% $png %>
% }
<%init>

# NOTE: the weird warn/die stuff here is because this file is accessed as 
# IMG SRC="port_graph.html" - easier than hacking an uglier solution

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

my $svcnum = $cgi->param('svcnum');
unless ( $svcnum =~ /^\d+$/ ) {
    warn 'invalid svcnum';
    die;
}

my $start = $cgi->param('start');
my $end = $cgi->param('end');
unless ( $start =~ /^\d+$/ && $end =~ /^\d+$/ ) {
    warn 'invalid start and/or end times';
    die;
}

my $svc_port = qsearchs('svc_port', { 'svcnum' => $svcnum });
unless($svc_port) {
    warn 'invalid svc_port';
    die;
}

my $error = '';
my $png = $svc_port->graph_png('start' => $start, 'end' => $end);
$error = 'error from graph_png: '.$png if length($png) < 200;

http_header('Content-Type' => 'image/png') unless($error);

</%init>