last login reporting (#2952)
[freeside.git] / httemplate / view / svc_acct.cgi
index 8647868..d764afe 100755 (executable)
@@ -79,6 +79,7 @@
 
   Upload: <B><% sprintf("%.3f", $input) %></B> megabytes<BR>
   Download: <B><% sprintf("%.3f", $output) %></B> megabytes<BR>
+  Last Login: <B><% $svc_acct->last_login_text %></B><BR>
 % my $href = qq!<A HREF="${p}search/sqlradius.cgi?svcnum=$svcnum!; 
 
   View session detail:
@@ -245,17 +246,20 @@ Service #<B><% $svcnum %></B>
     </TD>
   </TR>
 % } 
-% my %ulabel = ( seconds    => 'Seconds',
+% my %ulabel = ( seconds    => 'Time',
 %                upbytes    => 'Upload bytes',
 %                downbytes  => 'Download bytes',
 %                totalbytes => 'Total bytes',
 %              );
 % foreach my $uf ( keys %ulabel ) {
 %   my $tf = $uf . "_threshold";
-%   if ( $svc_acct->$tf ne '' ) {
+%   if ( $svc_acct->$uf ne '' ) {
+%     my $v = $uf eq 'seconds'
+%       ? (($svc_acct->$uf < 0 ? '-' : ''). duration_exact($svc_acct->$uf) )
+%       : FS::UI::bytecount::display_bytecount($svc_acct->$uf);
     <TR>
       <TD ALIGN="right"><% $ulabel{$uf} %> remaining</TD>
-      <TD BGCOLOR="#ffffff"><% $svc_acct->$uf %></TD>
+      <TD BGCOLOR="#ffffff"><% $v %></TD>
     </TR>
 
 %   }
@@ -286,13 +290,6 @@ Service #<B><% $svcnum %></B>
   <TD ALIGN="right">RADIUS groups</TD>
   <TD BGCOLOR="#ffffff"><% join('<BR>', $svc_acct->radius_groups) %></TD>
 </TR>
-% if ( $svc_acct->seconds =~ /^\d+$/ ) { 
-
-  <TR>
-    <TD ALIGN="right">Prepaid time</TD>
-    <TD BGCOLOR="#ffffff"><% duration_exact($svc_acct->seconds) %></TD>
-  </TR>
-% } 
 %
 %# Can this be abstracted further?  Maybe a library function like
 %# widget('HTML', 'view', $svc_acct) ?  It would definitely make UI 
@@ -308,6 +305,22 @@ Service #<B><% $svcnum %></B>
 </FORM>
 <BR><BR>
 
+% if ( @svc_www ) {
+  Hosting
+  <% &ntable("#cccccc") %><TR><TD><% &ntable("#cccccc",2) %>
+%   foreach my $svc_www (@svc_www) {
+%     my($label, $value) = $svc_www->cust_svc->label;
+%     my $link = $p. 'view/svc_www.cgi?'. $svc_www->svcnum;
+      <TR>
+        <TD BGCOLOR="#ffffff">
+          <A HREF="<% $link %>"><% "$label: $value" %></A>
+        </TD>
+      </TR>
+%   }
+  </TABLE></TD></TR></TABLE>
+  <BR><BR>
+% }
+
 <% join("<BR>", $conf->config('svc_acct-notes') ) %>
 <BR><BR>
 
@@ -322,16 +335,18 @@ die "access denied"
 
 my $conf = new FS::Conf;
 
+my $addl_from = ' LEFT JOIN cust_svc  USING ( svcnum  ) '.
+                ' LEFT JOIN cust_pkg  USING ( pkgnum  ) '.
+                ' LEFT JOIN cust_main USING ( custnum ) ';
+
 my($query) = $cgi->keywords;
 $query =~ /^(\d+)$/;
 my $svcnum = $1;
 my $svc_acct = qsearchs({
   'select'    => 'svc_acct.*',
   'table'     => 'svc_acct',
-  'addl_from' => ' LEFT JOIN cust_svc  USING ( svcnum  ) '.
-                 ' LEFT JOIN cust_pkg  USING ( pkgnum  ) '.
-                 ' LEFT JOIN cust_main USING ( custnum ) ',
-  'hashref'   => {'svcnum'=>$svcnum},
+  'addl_from' => $addl_from,
+  'hashref'   => { 'svcnum' => $svcnum },
   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
 });
 die "Unknown svcnum" unless $svc_acct;
@@ -361,4 +376,17 @@ die 'Unknown domain (domsvc '. $svc_acct->domsvc.
   unless $svc_domain;
 my $domain = $svc_domain->domain;
 
+my @svc_www = qsearch({
+  'select'    => 'svc_www.*',
+  'table'     => 'svc_www',
+  'addl_from' => $addl_from,
+  'hashref'   => { 'usersvc' => $svcnum },
+  #XXX shit outta luck if you somehow got them linked across agents
+  # maybe we should show but not link to them?  kinda makes sense...
+  # (maybe a specific ACL for this situation???)
+  'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql(
+                            'null_right' => 'View/link unlinked services'
+                          ),
+});
+
 </%init>