5 use FS::Record qw( qsearchs qsearch );
11 @ISA = qw( FS::Record );
15 FS::ac - Object methods for ac records
21 $record = new FS::ac_block \%hash;
22 $record = new FS::ac_block { 'column' => 'value' };
24 $error = $record->insert;
26 $error = $new_record->replace($old_record);
28 $error = $record->delete;
30 $error = $record->check;
34 An FS::ac_block record describes an address block assigned for broadband
35 access. FS::ac_block inherits from FS::Record. The following fields are
40 =item acnum - the access concentrator (see L<FS::ac_type>) to which this
43 =item ip_gateway - the gateway address used by customers within this block.
44 This functions as the primary key.
46 =item ip_netmask - the netmask of the block, expressed as an integer.
56 Create a new record. To add the record to the database, see L<"insert">.
60 sub table { 'ac_block'; }
64 Adds this record to the database. If there is an error, returns the error,
65 otherwise returns false.
69 Deletes this record from the database. If there is an error, returns the
70 error, otherwise returns false.
72 =item replace OLD_RECORD
74 Replaces OLD_RECORD with this one in the database. If there is an error,
75 returns the error, otherwise returns false.
79 Checks all fields to make sure this is a valid record. If there is an error,
80 returns the error, otherwise returns false. Called by the insert and replace
89 $self->ut_number('acnum')
90 || $self->ut_ip('ip_gateway')
91 || $self->ut_number('ip_netmask')
93 return $error if $error;
95 return "Unknown acnum"
98 my $self_addr = new NetAddr::IP ($self->ip_gateway, $self->ip_netmask);
99 return "Cannot parse address: ". $self->ip_gateway . '/' . $self->ip_netmask
103 my $block_addr = new NetAddr::IP ($_->ip_gateway, $_->ip_netmask);
104 if($block_addr->contains($self_addr)
105 or $self_addr->contains($block_addr)) { $_; };
106 } qsearch( 'ac_block', {});
109 return "Block intersects existing block ".$_->ip_gateway."/".$_->ip_netmask;
118 Returns the L<FS::ac> object corresponding to this object.
124 return qsearchs('ac', { acnum => $self->acnum });
129 Returns a list of L<FS::svc_broadband> objects associated
136 # my @svc = qsearch('svc_broadband', { actypenum => $self->ac->ac_type->actypenum });
138 # my $svc_addr = new NetAddr::IP($_->ip_addr, $_->ip_netmask);
139 # $self_addr->contains($svc_addr);