From: ivan Date: Sun, 16 Mar 2008 05:13:13 +0000 (+0000) Subject: bring some sanity to address block selection in svc_broadband service definition... X-Git-Tag: TRIXBOX_2_6~9 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=6ca6c8ac1a3b4125be80763567a96304af1b7826 bring some sanity to address block selection in svc_broadband service definition edit --- diff --git a/FS/FS/addr_block.pm b/FS/FS/addr_block.pm index 1fb60606d..208684b3e 100755 --- a/FS/FS/addr_block.pm +++ b/FS/FS/addr_block.pm @@ -158,8 +158,18 @@ Returns a NetAddr::IP object for this block's address and netmask. sub NetAddr { my $self = shift; + new NetAddr::IP ($self->ip_gateway, $self->ip_netmask); +} + +=item cidr + +Returns a CIDR string for this block's address and netmask, i.e. 10.4.20.0/24 - return new NetAddr::IP ($self->ip_gateway, $self->ip_netmask); +=cut + +sub cidr { + my $self = shift; + $self->NetAddr->cidr; } =item next_free_addr diff --git a/FS/FS/svc_broadband.pm b/FS/FS/svc_broadband.pm index 68e7496d1..d1235246e 100755 --- a/FS/FS/svc_broadband.pm +++ b/FS/FS/svc_broadband.pm @@ -97,7 +97,13 @@ sub table_info { 'speed_down' => 'Maximum download speed for this service in Kbps. 0 denotes unlimited.', 'speed_up' => 'Maximum upload speed for this service in Kbps. 0 denotes unlimited.', 'ip_addr' => 'IP address. Leave blank for automatic assignment.', - 'blocknum' => 'Address block.', + 'blocknum' => { 'label' => 'Address block', + 'type' => 'select', + 'select_table' => 'addr_block', + 'select_key' => 'blocknum', + 'select_label' => 'cidr', + 'disable_inventory' => 1, + }, }, }; } @@ -253,7 +259,7 @@ is /32. sub NetAddr { my $self = shift; - return new NetAddr::IP ($self->ip_addr); + new NetAddr::IP ($self->ip_addr); } =item addr_block @@ -264,8 +270,7 @@ Returns the FS::addr_block record (i.e. the address block) for this broadband se sub addr_block { my $self = shift; - - return qsearchs('addr_block', { blocknum => $self->blocknum }); + qsearchs('addr_block', { blocknum => $self->blocknum }); } =back @@ -278,8 +283,7 @@ Returns a list of allowed FS::router objects. sub allowed_routers { my $self = shift; - - return map { $_->router } qsearch('part_svc_router', { svcpart => $self->svcpart }); + map { $_->router } qsearch('part_svc_router', { svcpart => $self->svcpart }); } =head1 BUGS