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
51 Create a new record. To add the record to the database, see "insert".
55 sub table { 'router'; }
59 Adds this record to the database. If there is an error, returns the error,
60 otherwise returns false.
64 Deletes this record from the database. If there is an error, returns the
65 error, otherwise returns false.
67 =item replace OLD_RECORD
69 Replaces OLD_RECORD with this one in the database. If there is an error,
70 returns the error, otherwise returns false.
74 Checks all fields to make sure this is a valid record. If there is an error,
75 returns the error, otherwise returns false. Called by the insert and replace
84 $self->ut_numbern('routernum')
85 || $self->ut_text('routername')
86 || $self->ut_agentnum_acl('agentnum', 'Broadband global configuration')
88 return $error if $error;
95 Deletes this router if and only if no address blocks (see L<FS::addr_block>)
96 are currently allocated to it.
103 return 'Router has address blocks allocated to it' if $self->addr_block;
105 local $SIG{HUP} = 'IGNORE';
106 local $SIG{INT} = 'IGNORE';
107 local $SIG{QUIT} = 'IGNORE';
108 local $SIG{TERM} = 'IGNORE';
109 local $SIG{TSTP} = 'IGNORE';
110 local $SIG{PIPE} = 'IGNORE';
112 my $oldAutoCommit = $FS::UID::AutoCommit;
113 local $FS::UID::AutoCommit = 0;
116 my $error = $self->SUPER::delete;
118 $dbh->rollback if $oldAutoCommit;
122 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
128 Returns a list of FS::addr_block objects (address blocks) associated
135 return qsearch('addr_block', { routernum => $self->routernum });
138 =item part_svc_router
140 Returns a list of FS::part_svc_router objects associated with this
141 object. This is unlikely to be useful for any purpose other than retrieving
142 the associated FS::part_svc objects. See below.
146 sub part_svc_router {
148 return qsearch('part_svc_router', { routernum => $self->routernum });
153 Returns a list of FS::part_svc objects associated with this object.
159 return map { qsearchs('part_svc', { svcpart => $_->svcpart }) }
160 $self->part_svc_router;
165 Returns the agent associated with this router, if any.
170 qsearchs('agent', { 'agentnum' => shift->agentnum });
177 FS::svc_broadband, FS::router, FS::addr_block, FS::part_svc,
178 schema.html from the base documentation.