don't re-my var, quiet warning
[freeside.git] / FS / FS / router.pm
1 package FS::router;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record qw( qsearchs qsearch );
6 use FS::addr_block;
7
8 @ISA = qw( FS::Record );
9
10 =head1 NAME
11
12 FS::router - Object methods for router records
13
14 =head1 SYNOPSIS
15
16   use FS::router;
17
18   $record = new FS::router \%hash;
19   $record = new FS::router { 'column' => 'value' };
20
21   $error = $record->insert;
22
23   $error = $new_record->replace($old_record);
24
25   $error = $record->delete;
26
27   $error = $record->check;
28
29 =head1 DESCRIPTION
30
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:
34
35 =over 4
36
37 =item routernum - primary key
38
39 =item routername - descriptive name for the router
40
41 =item svcnum - svcnum of the owning FS::svc_broadband, if appropriate
42
43 =back
44
45 =head1 METHODS
46
47 =over 4
48
49 =item new HASHREF
50
51 Create a new record.  To add the record to the database, see "insert".
52
53 =cut
54
55 sub table { 'router'; }
56
57 =item insert
58
59 Adds this record to the database.  If there is an error, returns the error,
60 otherwise returns false.
61
62 =item delete
63
64 Deletes this record from the database.  If there is an error, returns the
65 error, otherwise returns false.
66
67 =item replace OLD_RECORD
68
69 Replaces OLD_RECORD with this one in the database.  If there is an error,
70 returns the error, otherwise returns false.
71
72 =item check
73
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
76 methods.
77
78 =cut
79
80 sub check {
81   my $self = shift;
82
83   my $error =
84     $self->ut_numbern('routernum')
85     || $self->ut_text('routername');
86   return $error if $error;
87
88   $self->SUPER::check;
89 }
90
91 =item addr_block
92
93 Returns a list of FS::addr_block objects (address blocks) associated
94 with this object.
95
96 =cut
97
98 sub addr_block {
99   my $self = shift;
100   return qsearch('addr_block', { routernum => $self->routernum });
101 }
102
103 =item part_svc_router
104
105 Returns a list of FS::part_svc_router objects associated with this 
106 object.  This is unlikely to be useful for any purpose other than retrieving 
107 the associated FS::part_svc objects.  See below.
108
109 =cut
110
111 sub part_svc_router {
112   my $self = shift;
113   return qsearch('part_svc_router', { routernum => $self->routernum });
114 }
115
116 =item part_svc
117
118 Returns a list of FS::part_svc objects associated with this object.
119
120 =cut
121
122 sub part_svc {
123   my $self = shift;
124   return map { qsearchs('part_svc', { svcpart => $_->svcpart }) }
125       $self->part_svc_router;
126 }
127
128 =back
129
130 =head1 VERSION
131
132 $Id:
133
134 =head1 BUGS
135
136 =head1 SEE ALSO
137
138 FS::svc_broadband, FS::router, FS::addr_block, FS::part_svc,
139 schema.html from the base documentation.
140
141 =cut
142
143 1;
144