1 <% include('elements/svc_Common.html',
5 'html_foot' => $html_foot,
10 use Date::Parse 'str2time';
12 my $conf = new FS::Conf;
13 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
15 my $fields = FS::svc_port->table_info->{'fields'};
16 my %labels = map { $_ => ( ref($fields->{$_})
17 ? $fields->{$_}{'label'}
21 my @fields = keys %$fields;
23 my $start = $cgi->param('start');
24 my $end = $cgi->param('end');
27 my($start,$end,$label,$date_format) = (shift,shift,shift,shift);
28 $start = time2str($date_format,$start);
29 $end = time2str($date_format,$end);
30 return '<A HREF="javascript:void(0);" onclick="preset_range(\''
31 .$start.'\',\''.$end.'\')">'.$label.'</A>';
36 my $svcnum = $svc_port->svcnum;
37 my $default_end = time;
38 my $default_start = $default_end-86400;
41 my $nms = new FS::NetworkMonitoringSystem;
42 my $url = $nms->port_graphs_link($svc_port->serviceid);
43 my $link = $url ? qq(<A HREF="$url">Torrus Graphs</A><BR><BR>) : '';
45 if ( $start && $end ) {
46 my($s, $e) = ($start, $end);
47 if ( $date_format eq '%d/%m/%Y' ) {
48 $start =~ /^\s*(\d+)\D+(\d+)\D+(\d+)\s*$/ and $s = "$2/$1/$3";
49 $end =~ /^\s*(\d+)\D+(\d+)\D+(\d+)\s*$/ and $e = "$2/$1/$3";
51 $graph = "<BR><BR><IMG SRC=${p}/view/port_graph.html?svcnum=$svcnum".
52 ";start=".str2time("$s 00:00:00").
53 ";end=". str2time("$e 23:59:59").
58 <script type="text/javascript">
59 function preset_range(start,end){
60 document.getElementById(\'start_text\').value = start;
61 document.getElementById(\'end_text\').value = end;
64 <FORM ACTION=? METHOD="GET">
65 <INPUT TYPE="HIDDEN" NAME="svcnum" VALUE="'.$svcnum.'">
67 <B>Bandwidth Graph</B><BR>
68 '.preset_range($default_start,$default_end,'Last Day',$date_format)
69 .' | '.preset_range($default_end-86400*7,$default_end,'Last Week',$date_format)
70 .' | '.preset_range($default_end-86400*30,$default_end,'Last Month',$date_format)
71 .' | '.preset_range($default_end-86400*365,$default_end,'Last Year',$date_format)
74 . include('/elements/tr-input-date-field.html', {
76 'label' => 'Start Date',
79 . include('/elements/tr-input-date-field.html', {
81 'label' => 'End Date',
85 . '<TR><TD colspan="2"><input type="submit" value="Display"></TR>