5 use FS::Record qw( qsearchs qsearch dbh );
8 @ISA = qw( FS::Record FS::m2m_Common );
12 FS::router - Object methods for router records
18 $record = new FS::router \%hash;
19 $record = new FS::router { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::router record describes a broadband router, such as a DSLAM or a wireless
32 access point. FS::router inherits from FS::Record. The following
33 fields are currently supported:
37 =item routernum - primary key
39 =item routername - descriptive name for the router
41 =item svcnum - svcnum of the owning FS::svc_broadband, if appropriate
43 =item auto_addr - flag to automatically assign IP addresses to services
44 linked to this router ('Y' or null).
54 Create a new record. To add the record to the database, see "insert".
58 sub table { 'router'; }
62 Adds this record to the database. If there is an error, returns the error,
63 otherwise returns false.
67 Deletes this record from the database. If there is an error, returns the
68 error, otherwise returns false.
70 =item replace OLD_RECORD
72 Replaces OLD_RECORD with this one in the database. If there is an error,
73 returns the error, otherwise returns false.
77 Checks all fields to make sure this is a valid record. If there is an error,
78 returns the error, otherwise returns false. Called by the insert and replace
87 $self->ut_numbern('routernum')
88 || $self->ut_text('routername')
89 || $self->ut_enum('auto_addr', [ '', 'Y' ])
90 || $self->ut_agentnum_acl('agentnum', 'Broadband global configuration')
92 return $error if $error;
99 Deletes this router if and only if no address blocks (see L<FS::addr_block>)
100 are currently allocated to it.
107 return 'Router has address blocks allocated to it' if $self->addr_block;
109 local $SIG{HUP} = 'IGNORE';
110 local $SIG{INT} = 'IGNORE';
111 local $SIG{QUIT} = 'IGNORE';
112 local $SIG{TERM} = 'IGNORE';
113 local $SIG{TSTP} = 'IGNORE';
114 local $SIG{PIPE} = 'IGNORE';
116 my $oldAutoCommit = $FS::UID::AutoCommit;
117 local $FS::UID::AutoCommit = 0;
120 my $error = $self->SUPER::delete;
122 $dbh->rollback if $oldAutoCommit;
126 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
132 Returns a list of FS::addr_block objects (address blocks) associated
135 =item auto_addr_block
137 Returns a list of address blocks on which auto-assignment of IP addresses
144 return qsearch('addr_block', { routernum => $self->routernum });
147 sub auto_addr_block {
149 return () if !$self->auto_addr;
150 return qsearch('addr_block', { routernum => $self->routernum,
151 manual_flag => '' });
154 =item part_svc_router
156 Returns a list of FS::part_svc_router objects associated with this
157 object. This is unlikely to be useful for any purpose other than retrieving
158 the associated FS::part_svc objects. See below.
162 sub part_svc_router {
164 return qsearch('part_svc_router', { routernum => $self->routernum });
169 Returns a list of FS::part_svc objects associated with this object.
175 return map { qsearchs('part_svc', { svcpart => $_->svcpart }) }
176 $self->part_svc_router;
181 Returns the agent associated with this router, if any.
186 qsearchs('agent', { 'agentnum' => shift->agentnum });
193 FS::svc_broadband, FS::router, FS::addr_block, FS::part_svc,
194 schema.html from the base documentation.