[freeside-commits] freeside/fs_selfservice/FS-SelfService/cgi selfservice.cgi, 1.55, 1.56 view_usage.html, 1.6, 1.7
Erik Levinson
levinse at wavetail.420.am
Sun Jan 30 22:30:38 PST 2011
Update of /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi
In directory wavetail.420.am:/tmp/cvs-serv30961/fs_selfservice/FS-SelfService/cgi
Modified Files:
selfservice.cgi view_usage.html
Log Message:
torrus various changes, RT10574
Index: selfservice.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/selfservice.cgi,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -w -d -r1.55 -r1.56
--- selfservice.cgi 26 Dec 2010 04:09:26 -0000 1.55
+++ selfservice.cgi 31 Jan 2011 06:30:36 -0000 1.56
@@ -8,6 +8,7 @@
use Text::Template;
use HTML::Entities;
use Date::Format;
+use Date::Parse 'str2time';
use Number::Format 1.50;
use FS::SelfService qw(
access_info login_info login customer_info edit_info invoice
@@ -17,7 +18,7 @@
unprovision_svc change_pkg suspend_pkg domainselector
list_svcs list_svc_usage list_cdr_usage list_support_usage
myaccount_passwd list_invoices create_ticket get_ticket did_report
- mason_comp
+ mason_comp port_graph
);
$template_dir = '.';
@@ -796,19 +797,32 @@
sub view_usage {
list_svcs(
'session_id' => $session_id,
- 'svcdb' => [ 'svc_acct', 'svc_phone' ],
+ 'svcdb' => [ 'svc_acct', 'svc_phone', 'svc_port', ],
'ncancelled' => 1,
);
}
sub view_usage_details {
- list_svc_usage(
+ my $svcnum = $cgi->param('svcnum');
+
+ # for svc_port graphs
+ if($cgi->param($svcnum.'_start') && $cgi->param($svcnum.'_end')) {
+ return port_graph(
'session_id' => $session_id,
- 'svcnum' => $cgi->param('svcnum'),
+ 'svcnum' => $svcnum,
+ 'start' => str2time($cgi->param($svcnum.'_start')),
+ 'end' => str2time($cgi->param($svcnum.'_end')),
+ );
+ }
+ else {
+ return list_svc_usage(
+ 'session_id' => $session_id,
+ 'svcnum' => $svcnum,
'beginning' => $cgi->param('beginning') || '',
'ending' => $cgi->param('ending') || '',
);
}
+}
sub view_cdr_details {
list_cdr_usage(
Index: view_usage.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/view_usage.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -d -r1.6 -r1.7
--- view_usage.html 21 Jan 2010 08:34:01 -0000 1.6
+++ view_usage.html 31 Jan 2011 06:30:36 -0000 1.7
@@ -1,6 +1,7 @@
<%= $url = "$selfurl?session=$session_id;action=";
@svc_acct = grep { $_->{svcdb} eq 'svc_acct' } @svcs;
@svc_phone = grep { $_->{svcdb} eq 'svc_phone' } @svcs;
+ @svc_port = grep { $_->{svcdb} eq 'svc_port' } @svcs;
'';
%>
<%= include('header', 'Account usage') %>
@@ -81,5 +82,61 @@
<%= scalar(@svc_phone) ? '</TABLE><BR><BR>' : '' %>
+<%= if ( @svc_port ) {
+ $OUT.= '<FONT SIZE="4">Bandwidth Graphs</FONT><BR><BR>
+ <script type="text/javascript">
+ function preset_range(start,end,prefix){
+ document.getElementById(prefix+\'_start\').value = start;
+ document.getElementById(prefix+\'_end\').value = end;
+ }
+ </script>
+ <TABLE BGCOLOR="#cccccc">
+ <TR>
+ <TH ALIGN="left">Service</TH>
+ <TH ALIGN="right">
+ </TH>
+ </TR>';
+ }
+ $OUT .= '';
+%>
+
+<%=
+
+sub preset_range {
+ my($start,$end,$label,$date_format,$prefix) = (shift,shift,shift,shift,shift);
+ $start = Date::Format::time2str($date_format,$start);
+ $end = Date::Format::time2str($date_format,$end);
+ return '<A HREF="javascript:void(0);" onclick="preset_range(\''
+ .$start.'\',\''.$end.'\',\''.$prefix.'\')">'.$label.'</A>';
+}
+
+foreach my $svc_port ( @svc_port ) {
+ $svcnum = $svc_port->{'svcnum'};
+ $default_end = time;
+ $default_start = $default_end-86400;
+
+ $OUT .= '<TR><TD>'. $svc_port->{'label'}. ': '. $svc_port->{'value'}.'</TD>';
+ $OUT .= qq! <TD><FORM ACTION="$url" METHOD="GET">
+ <INPUT TYPE="hidden" name="svcnum" value="$svcnum">
+ <INPUT TYPE="hidden" name="action" value="view_usage_details">
+ <INPUT TYPE="hidden" name="session" value="$session_id"> !;
+ $OUT .= preset_range($default_start,$default_end,'Last Day',$date_format,$svcnum)
+ .' | '.preset_range($default_end-86400*7,$default_end,'Last Week',$date_format,$svcnum)
+ .' | '.preset_range($default_end-86400*30,$default_end,'Last Month',$date_format,$svcnum)
+ .' | '.preset_range($default_end-86400*365,$default_end,'Last Year',$date_format,$svcnum);
+
+ $OUT .= qq! <BR>
+ Start Date <INPUT TYPE="TEXT" id="${svcnum}_start" name="${svcnum}_start" SIZE="10" MAXLENGTH="10">
+ End Date <INPUT TYPE="TEXT" id="${svcnum}_end" name="${svcnum}_end" SIZE="10" MAXLENGTH="10">
+ <BR>
+ <INPUT TYPE="submit" value="Display"> !;
+
+ $OUT .= '</FORM></TD></TR>';
+}
+%>
+
+<%= scalar(@svc_port) ? '</TABLE><BR><BR>' : '' %>
+
+
</TD></TR></TABLE>
<%= include('footer') %>
More information about the freeside-commits
mailing list