DNS, RT#8933
[freeside.git] / httemplate / view / svc_broadband.cgi
index cfece5c..f552e9b 100644 (file)
@@ -1,76 +1,16 @@
-<!-- mason kludge -->
-%
-%
-%my($query) = $cgi->keywords;
-%$query =~ /^(\d+)$/;
-%my $svcnum = $1;
-%my $svc_broadband = qsearchs( 'svc_broadband', { 'svcnum' => $svcnum } )
-%  or die "svc_broadband: Unknown svcnum $svcnum";
-%
-%#false laziness w/all svc_*.cgi
-%my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $svcnum } );
-%my $pkgnum = $cust_svc->getfield('pkgnum');
-%my($cust_pkg, $custnum);
-%if ($pkgnum) {
-%  $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } );
-%  $custnum = $cust_pkg->custnum;
-%} else {
-%  $cust_pkg = '';
-%  $custnum = '';
-%}
-%#eofalse
-%
-%my $addr_block = $svc_broadband->addr_block;
-%my $router = $addr_block->router;
-%
-%if (not $router) { die "Could not lookup router for svc_broadband (svcnum $svcnum)" };
-%
-%my (
-%     $routername,
-%     $routernum,
-%     $speed_down,
-%     $speed_up,
-%     $ip_addr,
-%     $ip_gateway,
-%     $ip_netmask,
-%     $mac_addr,
-%     $latitude,
-%     $longitude,
-%     $altitude,
-%     $vlan_profile,
-%     $auth_key,
-%     $description,
-%   ) = (
-%     $router->getfield('routername'),
-%     $router->getfield('routernum'),
-%     $svc_broadband->getfield('speed_down'),
-%     $svc_broadband->getfield('speed_up'),
-%     $svc_broadband->getfield('ip_addr'),
-%     $addr_block->ip_gateway,
-%     $addr_block->NetAddr->mask,
-%     $svc_broadband->mac_addr,
-%     $svc_broadband->latitude,
-%     $svc_broadband->longitude,
-%     $svc_broadband->altitude,
-%     $svc_broadband->vlan_profile,
-%     $svc_broadband->auth_key,
-%     $svc_broadband->description,
-%   );
-%
-
-
 <%include("/elements/header.html",'Broadband Service View', menubar(
   ( ( $custnum )
-    ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
+    ? ( "View this customer (#$display_custnum)" => "${p}view/cust_main.cgi?$custnum",
       )                                                                       
     : ( "Cancel this (unaudited) website" =>
           "${p}misc/cancel-unaudited.cgi?$svcnum" )
-  ),
-  "Main menu" => $p,
+  )
 ))
 %>
 
-<A HREF="<%${p}%>edit/svc_broadband.cgi?<%$svcnum%>">Edit this information</A>
+<% include('/elements/init_overlib.html') %>
+
+<A HREF="<%$p%>edit/svc_broadband.cgi?<%$svcnum%>">Edit this information</A>
 <BR>
 <%ntable("#cccccc")%>
   <TR>
           <TD ALIGN="right">Description</TD>
           <TD BGCOLOR="#ffffff"><%$description%></TD>
         </TR>
-        <TR>
-          <TD ALIGN="right">Router</TD>
-          <TD BGCOLOR="#ffffff"><%$routernum%>: <%$routername%></TD>
-        </TR>
+
+%       if ( $router ) {
+          <TR>
+            <TD ALIGN="right">Router</TD>
+            <TD BGCOLOR="#ffffff"><%$router->routernum%>: <%$router->routername%></TD>
+          </TR>
+%       }
+
         <TR>
           <TD ALIGN="right">Download Speed</TD>
           <TD BGCOLOR="#ffffff"><%$speed_down%></TD>
           <TD ALIGN="right">Upload Speed</TD>
           <TD BGCOLOR="#ffffff"><%$speed_up%></TD>
         </TR>
-        <TR>
-          <TD ALIGN="right">IP Address</TD>
-          <TD BGCOLOR="#ffffff"><%$ip_addr%></TD>
-        </TR>
-        <TR>
-          <TD ALIGN="right">IP Netmask</TD>
-          <TD BGCOLOR="#ffffff"><%$ip_netmask%></TD>
-        </TR>
-        <TR>
-          <TD ALIGN="right">IP Gateway</TD>
-          <TD BGCOLOR="#ffffff"><%$ip_gateway%></TD>
-        </TR>
+
+%       if ( $ip_addr ) { 
+          <TR>
+            <TD ALIGN="right">IP Address</TD>
+            <TD BGCOLOR="#ffffff">
+              <%$ip_addr%>
+              (<% include('/elements/popup_link-ping.html', 'ip'=>$ip_addr ) %>)
+            </TD>
+          </TR>
+          <TR>
+            <TD ALIGN="right">IP Netmask</TD>
+            <TD BGCOLOR="#ffffff"><%$addr_block->NetAddr->mask%></TD>
+          </TR>
+          <TR>
+            <TD ALIGN="right">IP Gateway</TD>
+            <TD BGCOLOR="#ffffff"><%$addr_block->ip_gateway%></TD>
+          </TR>
+%       }
+
         <TR>
           <TD ALIGN="right">MAC Address</TD>
           <TD BGCOLOR="#ffffff"><%$mac_addr%></TD>
@@ -200,6 +151,69 @@ Add router named
 
 <BR>
 <%joblisting({'svcnum'=>$svcnum}, 1)%>
-  </BODY>
-</HTML>
 
+<% include('/elements/footer.html') %>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
+
+my($query) = $cgi->keywords;
+$query =~ /^(\d+)$/;
+my $svcnum = $1;
+my $svc_broadband = 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 "svc_broadband: Unknown svcnum $svcnum";
+
+#false laziness w/all svc_*.cgi
+my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $svcnum } );
+my $pkgnum = $cust_svc->getfield('pkgnum');
+my($cust_pkg, $custnum, $display_custnum);
+if ($pkgnum) {
+  $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } );
+  $custnum = $cust_pkg->custnum;
+  $display_custnum = $cust_pkg->cust_main->display_custnum;
+} else {
+  $cust_pkg = '';
+  $custnum = '';
+}
+#eofalse
+
+my $addr_block = $svc_broadband->addr_block;
+my $router = $addr_block->router if $addr_block;
+
+#if (not $router) { die "Could not lookup router for svc_broadband (svcnum $svcnum)" };
+
+my (
+     $speed_down,
+     $speed_up,
+     $ip_addr,
+     $mac_addr,
+     $latitude,
+     $longitude,
+     $altitude,
+     $vlan_profile,
+     $auth_key,
+     $description,
+   ) = (
+     $svc_broadband->getfield('speed_down'),
+     $svc_broadband->getfield('speed_up'),
+     $svc_broadband->getfield('ip_addr'),
+     $svc_broadband->mac_addr,
+     $svc_broadband->latitude,
+     $svc_broadband->longitude,
+     $svc_broadband->altitude,
+     $svc_broadband->vlan_profile,
+     $svc_broadband->auth_key,
+     $svc_broadband->description,
+   );
+
+</%init>