This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / FS / FS / svc_dsl.pm
1 package FS::svc_dsl;
2
3 use strict;
4 use vars qw( @ISA $conf $DEBUG $me );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::svc_Common;
7 use FS::dsl_note;
8 use FS::qual;
9
10 @ISA = qw( FS::svc_Common );
11 $DEBUG = 0;
12 $me = '[FS::svc_dsl]';
13
14 FS::UID->install_callback( sub { 
15   $conf = new FS::Conf;
16 }
17 );
18
19 =head1 NAME
20
21 FS::svc_dsl - Object methods for svc_dsl records
22
23 =head1 SYNOPSIS
24
25   use FS::svc_dsl;
26
27   $record = new FS::svc_dsl \%hash;
28   $record = new FS::svc_dsl { 'column' => 'value' };
29
30   $error = $record->insert;
31
32   $error = $new_record->replace($old_record);
33
34   $error = $record->delete;
35
36   $error = $record->check;
37   
38   $error = $record->suspend;
39
40   $error = $record->unsuspend;
41
42   $error = $record->cancel;
43
44 =head1 DESCRIPTION
45
46 An FS::svc_dsl object represents a DSL service.  FS::svc_dsl inherits from
47 FS::svc_Common.  The following fields are currently supported:
48
49 =over 4
50
51 =item svcnum - Primary key (assigned automatcially for new DSL))
52
53 =item pushed - Time DSL order pushed to vendor/telco, if applicable
54
55 =item desired_due_date - Desired Due Date
56
57 =item due_date - Due Date
58
59 =item vendor_order_id - Vendor/telco DSL order #
60
61 =item vendor_order_type
62
63 Vendor/telco DSL order type (e.g. (M)ove, (A)dd, (C)hange, (D)elete, or similar)
64
65 =item vendor_order_status
66
67 Vendor/telco DSL order status (e.g. (N)ew, (A)ssigned, (R)ejected, (M)revised,
68 (C)ompleted, (X)cancelled, or similar)
69
70 =item first - End-user first name
71
72 =item last - End-user last name
73
74 =item company - End-user company name
75
76 =item phonenum - DSL Telephone Number
77
78 =item loop_type - Loop-type - vendor/telco-specific
79
80 =item local_voice_provider - Local Voice Provider's name
81
82 =item circuitnum - Circuit #
83
84 =item vpi
85
86 =item vci
87
88 =item rate_band - Rate Band
89
90 =item isp_chg
91
92 =item isp_prev
93
94 =item staticips
95
96 =item vendor_qual_id
97
98 Ikano-specific fields, do not use otherwise
99
100 =item username - if outsourced PPPoE/RADIUS, username
101
102 =item password - if outsourced PPPoE/RADIUS, password
103
104 =item monitored - Order is monitored (auto-pull/sync), either Y or blank
105
106 =item last_pull - time of last data pull from vendor/telco
107
108
109 =back
110
111 =head1 METHODS
112
113 =over 4
114
115 =item new HASHREF
116
117 Creates a new DSL.  To add the DSL to the database, see L<"insert">.
118
119 Note that this stores the hash reference, not a distinct copy of the hash it
120 points to.  You can ask the object for a copy with the I<hash> method.
121
122 =cut
123
124 # the new method can be inherited from FS::Record, if a table method is defined
125
126 sub table_info {
127     my %dis1 = ( disable_default=>1, disable_fixed=>1, disable_inventory=>1, disable_select=>1 );
128     my %dis2 = ( disable_inventory=>1, disable_select=>1 );
129
130     {
131         'name' => 'DSL',
132         'name_plural' => 'DSLs',
133         'lcname_plural' => 'DSLs',
134         'sorts' => [ 'phonenum' ],
135         'display_weight' => 55,
136         'cancel_weight' => 75,
137         'fields' => {
138             'pushed' => {       label => 'Pushed', 
139                                 type => 'disabled' },
140             'desired_due_date' => {     label => 'Desired Due Date', %dis2, },
141             'due_date' => {             label => 'Due Date', %dis2, },
142             'vendor_order_id' => { label => 'Vendor Order Id', %dis2, },
143             'vendor_qual_id' => { label => 'Vendor Qualification Id', 
144                                 type => 'disabled' },
145             'vendor_order_type' => { label => 'Vendor Order Type',
146                                     disable_inventory => 1,
147                                 },
148             'vendor_order_status' => { label => 'Vendor Order Status',
149                                     disable_inventory => 1,
150                                     },
151             'first' => {        label => 'First Name', %dis2, },
152             'last' => {         label => 'Last Name', %dis2, },
153             'company' => {      label => 'Company Name', %dis2, },
154             'phonenum' => {     label => 'Service Telephone Number', },
155             'loop_type' => {    label => 'Loop Type',
156                                     disable_inventory => 1,
157                         },
158             'local_voice_provider' => {         label => 'Local Voice Provider',
159                                     disable_inventory => 1,
160                         },
161             'circuitnum' => {   label => 'Circuit #',   },
162             'rate_band' => {    label => 'Rate Band',
163                                     disable_inventory => 1,
164                         },
165             'vpi' => { label => 'VPI', disable_inventory => 1 },
166             'vci' => { label => 'VCI', disable_inventory => 1 },
167             'isp_chg' => {      label => 'ISP Changing?', 
168                                 type => 'checkbox', %dis2 },
169             'isp_prev' => {     label => 'Current or Previous ISP',
170                                     disable_inventory => 1,
171                         },
172             'username' => {     label => 'PPPoE Username',
173                                 type => 'text',
174                         },
175             'password' => {     label => 'PPPoE Password', %dis2 },
176             'staticips' => {    label => 'Static IPs', %dis1 },
177             'monitored' => {    label => 'Monitored', 
178                                 type => 'checkbox', %dis2 },
179             'last_pull' => {    label => 'Last Pull', type => 'disabled' },
180         },
181     };
182 }
183
184 sub table { 'svc_dsl'; }
185
186 sub label {
187    my $self = shift;
188    return $self->phonenum if $self->phonenum;
189    return $self->username if $self->username;
190    return $self->vendor_order_id if $self->vendor_order_id;
191    return $self->svcnum;
192 }
193
194 =item notes
195
196 Returns the set of FS::dsl_notes associated with this service
197
198 =cut 
199 sub notes {
200   my $self = shift;
201   qsearch( 'dsl_note', { 'svcnum' => $self->svcnum } );
202 }
203
204 =item insert
205
206 Adds this record to the database.  If there is an error, returns the error,
207 otherwise returns false.
208
209 =cut
210
211 # the insert method can be inherited from FS::Record
212
213 =item delete
214
215 Delete this record from the database.
216
217 =cut
218
219 # the delete method can be inherited from FS::Record
220
221 =item replace OLD_RECORD
222
223 Replaces the OLD_RECORD with this one in the database.  If there is an error,
224 returns the error, otherwise returns false.
225
226 =cut
227
228 # the replace method can be inherited from FS::Record
229
230 =item check
231
232 Checks all fields to make sure this is a valid DSL.  If there is
233 an error, returns the error, otherwise returns false.  Called by the insert
234 and replace methods.
235
236 =cut
237
238 # the check method should currently be supplied - FS::Record contains some
239 # data checking routines
240
241 sub check {
242   my $self = shift;
243
244   my $error = 
245     $self->ut_numbern('svcnum')
246     || $self->ut_numbern('pushed')
247     || $self->ut_numbern('desired_due_date')
248     || $self->ut_numbern('due_date')
249     || $self->ut_textn('vendor_order_id')
250     || $self->ut_textn('vendor_qual_id')
251     || $self->ut_alphan('vendor_order_type')
252     || $self->ut_alphan('vendor_order_status')
253     || $self->ut_text('first')
254     || $self->ut_text('last')
255     || $self->ut_textn('company')
256     || $self->ut_numbern('phonenum')
257     || $self->ut_alphasn('loop_type')
258     || $self->ut_textn('local_voice_provider')
259     || $self->ut_textn('circuitnum')
260     || $self->ut_textn('rate_band')
261     || $self->ut_numbern('vpi')
262     || $self->ut_numbern('vci')
263     || $self->ut_alphan('isp_chg')
264     || $self->ut_textn('isp_prev')
265     || $self->ut_textn('username')
266     || $self->ut_textn('password')
267     || $self->ut_textn('staticips')
268     || $self->ut_enum('monitored',    [ '', 'Y' ])
269     || $self->ut_numbern('last_pull')
270   ;
271   return $error if $error;
272
273   $self->SUPER::check;
274 }
275
276 sub predelete_hook_first {
277     my $self = shift;
278     my @exports = $self->part_svc->part_export_dsl_pull;
279     return 'More than one DSL-pulling export attached' if scalar(@exports) > 1;
280     if ( scalar(@exports) == 1 ) {
281         my $export = $exports[0];
282         return $export->dsl_pull($self);
283     }
284     '';
285 }
286
287 sub predelete_hook {
288     my $self = shift;
289     my @notes = $self->notes;
290     foreach my $note ( @notes ) {
291         my $error = $note->delete;
292         return $error if $error;
293     }
294     '';
295 }
296
297 =back
298
299 =head1 SEE ALSO
300
301 L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,
302 export.html from the base documentation, L<FS::Record>, L<FS::Conf>,
303 L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, L<FS::queue>,
304 L<freeside-queued>, schema.html from the base documentation.
305
306 =cut
307
308 1;
309