X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fsvc_broadband.cgi;h=de39f6ae48f84caeb65945f14115c3e6e80ab9c0;hb=822645aade15a4c4ac0558b116f7aacf9491002c;hp=e614fe4183536d1b0db4c3d6eccb9b807ba1a2b0;hpb=c648976f0b7975f2328ebd7ba8c711fad0ca4195;p=freeside.git diff --git a/httemplate/view/svc_broadband.cgi b/httemplate/view/svc_broadband.cgi index e614fe418..de39f6ae4 100644 --- a/httemplate/view/svc_broadband.cgi +++ b/httemplate/view/svc_broadband.cgi @@ -1,211 +1,100 @@ -<%include("/elements/header.html",'Broadband Service View', menubar( - ( ( $custnum ) - ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", - ) - : ( "Cancel this (unaudited) website" => - "${p}misc/cancel-unaudited.cgi?$svcnum" ) - ) -)) -%> - -Edit this information -
-<%ntable("#cccccc")%> - - - <%ntable("#cccccc",2)%> - - Service number - <%$svcnum%> - - - Description - <%$description%> - - - Router - <%$routernum%>: <%$routername%> - - - Download Speed - <%$speed_down%> - - - Upload Speed - <%$speed_up%> - - - IP Address - <%$ip_addr%> - - - IP Netmask - <%$ip_netmask%> - - - IP Gateway - <%$ip_gateway%> - - - MAC Address - <%$mac_addr%> - - - Latitude - <%$latitude%> - - - Longitude - <%$longitude%> - - - Altitude - <%$altitude%> - - - VLAN Profile - <%$vlan_profile%> - - - Authentication Key - <%$auth_key%> - - -% -%foreach (sort { $a cmp $b } $svc_broadband->virtual_fields) { -% print $svc_broadband->pvf($_)->widget('HTML', 'view', -% $svc_broadband->getfield($_)), "\n"; -%} -% -% - - - - - - -
-<%ntable("#cccccc", 2)%> -% -% my $sb_router = qsearchs('router', { svcnum => $svcnum }); -% if ($sb_router) { -% - - Router associated: <%$sb_router->routername%> - - (details) - -
-% my @sb_addr_block; -% if (@sb_addr_block = $sb_router->addr_block) { -% - - Address space - - (edit) - -
-% print ntable("#cccccc", 1); -% foreach (@sb_addr_block) { - - - <%$_->ip_gateway%>/<%$_->ip_netmask%> - -% } - - -% } else { - - No address space allocated. -% } - -
-% -% } else { -% - - -
- -Add router named - - -
-% -%} -% - - -
-<%joblisting({'svcnum'=>$svcnum}, 1)%> - -<% include('/elements/footer.html') %> +<& elements/svc_Common.html, + table => 'svc_broadband', + labels => \%labels, + fields => \@fields, +&> <%init> -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('View customer services'); +my $conf = FS::Conf->new; +my $fields = FS::svc_broadband->table_info->{'fields'}; +my %labels = map { $_ => ( ref($fields->{$_}) + ? $fields->{$_}{'label'} + : $fields->{$_} + ); + } keys %$fields; + +#my %labels = (); + +$labels{'description'} = emt('Description'); +$labels{'router'} = emt('Router'); +$labels{'speed_down'} = emt('Download Speed'); +$labels{'speed_up'} = emt('Upload Speed'); +$labels{'ip_addr'} = emt('IP Address'); +$labels{'usergroup'} = emt('RADIUS groups'); #? + +$labels{'coordinates'} = 'Latitude/Longitude'; + +my @fields = ( + 'description', + { field => 'router', value => \&router }, + 'speed_down', + 'speed_up', + { field => 'ip_addr', value => \&ip_addr }, + { field => 'sectornum', value => \§ornum }, + 'mac_addr', + #'latitude', + #'longitude', + { field => 'coordinates', value => \&coordinates }, + 'altitude', + 'vlan_profile', + 'authkey', + 'plan_id', +); + +push @fields, + { field => 'usergroup', value => \&usergroup } + if $conf->exists('svc_broadband-radius'); + +sub router { + my $svc = shift; + my $addr_block = $svc->addr_block or return ''; + my $router = $addr_block->router or return ''; + $router->routernum . ': ' . $router->routername; +} -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, -}) or die "svc_broadband: Unknown svcnum $svcnum"; +sub ip_addr { + my $svc = shift; + my $ip_addr = $svc->ip_addr; + my $out = $ip_addr; + $out .= ' (' . include('/elements/popup_link-ping.html', ip => $ip_addr) . ')' + if $ip_addr; + if ( my $addr_block = $svc->addr_block ) { + $out .= '
Netmask: ' . $addr_block->NetAddr->mask . + '
Gateway: ' . $addr_block->ip_gateway; + } + $out; +} -#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 = ''; +sub usergroup { + my $svc = shift; + my $usergroup = $svc->usergroup; + join('
', $svc->radius_groups('long_description')); } -#eofalse -my $addr_block = $svc_broadband->addr_block; -my $router = $addr_block->router; +sub sectornum { + my $svc_broadband = shift; + return '' unless $svc_broadband->sectornum; + my $tower_sector = $svc_broadband->tower_sector; + my $link = $tower_sector->ip_addr + ? '' + : ''; -if (not $router) { die "Could not lookup router for svc_broadband (svcnum $svcnum)" }; + $link . $tower_sector->description. ( $link ? '' : ''); +} -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, - ); +sub coordinates { + my $s = shift; #$svc_broadband + return '' unless $s->latitude && $s->longitude; + + my $d = $s->description; + unless ($d) { + my $cust_pkg = $s->cust_svc->cust_pkg; + $d = $cust_pkg->cust_main->name_short if $cust_pkg; + } + + #'Latitude: '. $s->latitude. ', Longitude: '. $s->longitude. ' '. + $s->latitude. ', '. $s->longitude. ' '. + include('/elements/coord-links.html', $s->latitude, $s->longitude, $d); +}