This commit was generated by cvs2svn to compensate for changes in r10640,
[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         'sorts' => [ 'phonenum' ],
133         'display_weight' => 55,
134         'cancel_weight' => 75,
135         'fields' => {
136             'pushed' => {       label => 'Pushed', 
137                                 type => 'disabled' },
138             'desired_due_date' => {     label => 'Desired Due Date', %dis2, },
139             'due_date' => {             label => 'Due Date', %dis2, },
140             'vendor_order_id' => { label => 'Vendor Order Id', %dis2, },
141             'vendor_qual_id' => { label => 'Vendor Qualification Id', 
142                                 type => 'disabled' },
143             'vendor_order_type' => { label => 'Vendor Order Type',
144                                     disable_inventory => 1,
145                                 },
146             'vendor_order_status' => { label => 'Vendor Order Status',
147                                     disable_inventory => 1,
148                                     },
149             'first' => {        label => 'First Name', %dis2, },
150             'last' => {         label => 'Last Name', %dis2, },
151             'company' => {      label => 'Company Name', %dis2, },
152             'phonenum' => {     label => 'Service Telephone Number', },
153             'loop_type' => {    label => 'Loop Type',
154                                     disable_inventory => 1,
155                         },
156             'local_voice_provider' => {         label => 'Local Voice Provider',
157                                     disable_inventory => 1,
158                         },
159             'circuitnum' => {   label => 'Circuit #',   },
160             'rate_band' => {    label => 'Rate Band',
161                                     disable_inventory => 1,
162                         },
163             'vpi' => { label => 'VPI', disable_inventory => 1 },
164             'vci' => { label => 'VCI', disable_inventory => 1 },
165             'isp_chg' => {      label => 'ISP Changing?', 
166                                 type => 'checkbox', %dis2 },
167             'isp_prev' => {     label => 'Current or Previous ISP',
168                                     disable_inventory => 1,
169                         },
170             'username' => {     label => 'PPPoE Username',
171                                 type => 'text',
172                         },
173             'password' => {     label => 'PPPoE Password', %dis2 },
174             'staticips' => {    label => 'Static IPs', %dis1 },
175             'monitored' => {    label => 'Monitored', 
176                                 type => 'checkbox', %dis2 },
177             'last_pull' => {    label => 'Last Pull', type => 'disabled' },
178         },
179     };
180 }
181
182 sub table { 'svc_dsl'; }
183
184 sub label {
185    my $self = shift;
186    return $self->phonenum if $self->phonenum;
187    return $self->username if $self->username;
188    return $self->vendor_order_id if $self->vendor_order_id;
189    return $self->svcnum;
190 }
191
192 =item notes
193
194 Returns the set of FS::dsl_notes associated with this service
195
196 =cut 
197 sub notes {
198   my $self = shift;
199   qsearch( 'dsl_note', { 'svcnum' => $self->svcnum } );
200 }
201
202 =item insert
203
204 Adds this record to the database.  If there is an error, returns the error,
205 otherwise returns false.
206
207 =cut
208
209 # the insert method can be inherited from FS::Record
210
211 =item delete
212
213 Delete this record from the database.
214
215 =cut
216
217 # the delete method can be inherited from FS::Record
218
219 =item replace OLD_RECORD
220
221 Replaces the OLD_RECORD with this one in the database.  If there is an error,
222 returns the error, otherwise returns false.
223
224 =cut
225
226 # the replace method can be inherited from FS::Record
227
228 =item check
229
230 Checks all fields to make sure this is a valid DSL.  If there is
231 an error, returns the error, otherwise returns false.  Called by the insert
232 and replace methods.
233
234 =cut
235
236 # the check method should currently be supplied - FS::Record contains some
237 # data checking routines
238
239 sub check {
240   my $self = shift;
241
242   my $error = 
243     $self->ut_numbern('svcnum')
244     || $self->ut_numbern('pushed')
245     || $self->ut_numbern('desired_due_date')
246     || $self->ut_numbern('due_date')
247     || $self->ut_textn('vendor_order_id')
248     || $self->ut_textn('vendor_qual_id')
249     || $self->ut_alphan('vendor_order_type')
250     || $self->ut_alphan('vendor_order_status')
251     || $self->ut_text('first')
252     || $self->ut_text('last')
253     || $self->ut_textn('company')
254     || $self->ut_numbern('phonenum')
255     || $self->ut_alphasn('loop_type')
256     || $self->ut_textn('local_voice_provider')
257     || $self->ut_textn('circuitnum')
258     || $self->ut_textn('rate_band')
259     || $self->ut_numbern('vpi')
260     || $self->ut_numbern('vci')
261     || $self->ut_alphan('isp_chg')
262     || $self->ut_textn('isp_prev')
263     || $self->ut_textn('username')
264     || $self->ut_textn('password')
265     || $self->ut_textn('staticips')
266     || $self->ut_enum('monitored',    [ '', 'Y' ])
267     || $self->ut_numbern('last_pull')
268   ;
269   return $error if $error;
270
271   $self->SUPER::check;
272 }
273
274 sub predelete_hook_first {
275     my $self = shift;
276     my @exports = $self->part_svc->part_export_dsl_pull;
277     return 'More than one DSL-pulling export attached' if scalar(@exports) > 1;
278     if ( scalar(@exports) == 1 ) {
279         my $export = $exports[0];
280         return $export->dsl_pull($self);
281     }
282     '';
283 }
284
285 sub predelete_hook {
286     my $self = shift;
287     my @notes = $self->notes;
288     foreach my $note ( @notes ) {
289         my $error = $note->delete;
290         return $error if $error;
291     }
292     '';
293 }
294
295 =back
296
297 =head1 SEE ALSO
298
299 L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,
300 export.html from the base documentation, L<FS::Record>, L<FS::Conf>,
301 L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, L<FS::queue>,
302 L<freeside-queued>, schema.html from the base documentation.
303
304 =cut
305
306 1;
307