X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fsvc_broadband.cgi;h=75e673c4f89332ce4b53cb7bc3f11b38ff8096e8;hb=68cd93a81814d8725118a66b54f20e2c2c1c20f0;hp=de39f6ae48f84caeb65945f14115c3e6e80ab9c0;hpb=8cbe016ac2c28cd209c48f053f361573368e7988;p=freeside.git diff --git a/httemplate/view/svc_broadband.cgi b/httemplate/view/svc_broadband.cgi index de39f6ae4..75e673c4f 100644 --- a/httemplate/view/svc_broadband.cgi +++ b/httemplate/view/svc_broadband.cgi @@ -2,6 +2,7 @@ table => 'svc_broadband', labels => \%labels, fields => \@fields, + svc_callback => \&svc_callback, &> <%init> @@ -16,7 +17,6 @@ my %labels = map { $_ => ( ref($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'); @@ -26,12 +26,12 @@ $labels{'coordinates'} = 'Latitude/Longitude'; my @fields = ( 'description', - { field => 'router', value => \&router }, + { field => 'routernum', value => \&router }, 'speed_down', 'speed_up', { field => 'ip_addr', value => \&ip_addr }, { field => 'sectornum', value => \§ornum }, - 'mac_addr', + { field => 'mac_addr', value => \&mac_addr }, #'latitude', #'longitude', { field => 'coordinates', value => \&coordinates }, @@ -47,9 +47,11 @@ push @fields, 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 $router = $svc->router; + my $block = $svc->addr_block; + $router = $router->routernum . ': ' . $router->routername if $router; + $block = '; '.$block->cidr if $block; + $router . $block } sub ip_addr { @@ -65,6 +67,11 @@ sub ip_addr { $out; } +sub mac_addr { + my $svc = shift; + join(':', $svc->mac_addr =~ /../g); +} + sub usergroup { my $svc = shift; my $usergroup = $svc->usergroup; @@ -87,14 +94,43 @@ sub coordinates { return '' unless $s->latitude && $s->longitude; my $d = $s->description; + my $agentnum; unless ($d) { - my $cust_pkg = $s->cust_svc->cust_pkg; - $d = $cust_pkg->cust_main->name_short if $cust_pkg; + if ( my $cust_pkg = $s->cust_svc->cust_pkg ) { + $d = $cust_pkg->cust_main->name_short; + $agentnum = $cust_pkg->cust_main->agentnum; + } } #'Latitude: '. $s->latitude. ', Longitude: '. $s->longitude. ' '. $s->latitude. ', '. $s->longitude. ' '. - include('/elements/coord-links.html', $s->latitude, $s->longitude, $d); + include('/elements/coord-links.html', + $s->latitude, + $s->longitude, + $d, + $agentnum + ); } +sub svc_callback { + # trying to move to the callback style + my ($cgi, $svc_x, $part_svc, $cust_pkg, $fields, $opt) = @_; + # again, we assume at most one of these exports per part_svc + my ($nas_export) = $part_svc->part_export('broadband_nas'); + if ( $nas_export ) { + my $nas = qsearchs('nas', { 'svcnum' => $svc_x->svcnum }); + if ( $nas ) { + $svc_x->set($_, $nas->$_) foreach (fields('nas')); + push @$fields, qw(shortname secret type ports server community); + $opt->{'labels'}{'shortname'} = 'Short name'; + $opt->{'labels'}{'secret'} = 'Shared secret'; + $opt->{'labels'}{'type'} = 'Type'; + $opt->{'labels'}{'ports'} = 'Ports'; + $opt->{'labels'}{'server'} = 'Server'; + $opt->{'labels'}{'community'} = 'Community'; + } #if $nas + } #$nas_export +}; + +