2 use base qw(FS::Password_Mixin
6 use vars qw( $conf $DEBUG $me );
8 use FS::Record qw( qsearch qsearchs dbh );
14 $me = '[FS::svc_dsl]';
16 FS::UID->install_callback( sub {
23 FS::svc_dsl - Object methods for svc_dsl records
29 $record = new FS::svc_dsl \%hash;
30 $record = new FS::svc_dsl { 'column' => 'value' };
32 $error = $record->insert;
34 $error = $new_record->replace($old_record);
36 $error = $record->delete;
38 $error = $record->check;
40 $error = $record->suspend;
42 $error = $record->unsuspend;
44 $error = $record->cancel;
48 An FS::svc_dsl object represents a DSL service. FS::svc_dsl inherits from
49 FS::svc_Common. The following fields are currently supported:
55 Primary key (assigned automatcially for new DSL))
59 Time DSL order pushed to vendor/telco, if applicable
61 =item desired_due_date
71 Vendor/telco DSL order #
73 =item vendor_order_type
75 Vendor/telco DSL order type (e.g. (M)ove, (A)dd, (C)hange, (D)elete, or similar)
77 =item vendor_order_status
79 Vendor/telco DSL order status (e.g. (N)ew, (A)ssigned, (R)ejected, (M)revised,
80 (C)ompleted, (X)cancelled, or similar)
98 =item gateway_access_number
100 Gateway access number, if different
104 Loop-type - vendor/telco-specific
106 =item local_voice_provider
108 Local Voice Provider's name
130 Ikano-specific fields, do not use otherwise
134 if outsourced PPPoE/RADIUS, username
138 if outsourced PPPoE/RADIUS, password
142 Order is monitored (auto-pull/sync), either Y or blank
146 time of last data pull from vendor/telco
157 Creates a new DSL. To add the DSL to the database, see L<"insert">.
159 Note that this stores the hash reference, not a distinct copy of the hash it
160 points to. You can ask the object for a copy with the I<hash> method.
164 # the new method can be inherited from FS::Record, if a table method is defined
167 my %dis1 = ( disable_default=>1, disable_fixed=>1, disable_inventory=>1, disable_select=>1 );
168 my %dis2 = ( disable_inventory=>1, disable_select=>1 );
172 'name_plural' => 'DSLs',
173 'lcname_plural' => 'DSLs',
174 'sorts' => [ 'phonenum' ],
175 'display_weight' => 55,
176 'cancel_weight' => 75,
177 'ip_field' => 'staticips',
179 'pushed' => { label => 'Pushed',
180 type => 'disabled' },
181 'desired_due_date' => { label => 'Desired Due Date', %dis2, },
182 'due_date' => { label => 'Due Date', %dis2, },
183 'vendor_order_id' => { label => 'Vendor Order ID', %dis2, },
184 'vendor_qual_id' => { label => 'Vendor Qualification ID',
185 type => 'disabled' },
186 'vendor_order_type' => { label => 'Vendor Order Type',
187 disable_inventory => 1, },
188 'vendor_order_status' => { label => 'Vendor Order Status',
189 disable_inventory => 1, },
190 'first' => { label => 'First Name', %dis2, },
191 'last' => { label => 'Last Name', %dis2, },
192 'company' => { label => 'Company Name', %dis2, },
193 'phonenum' => { label => 'Service Telephone Number', },
194 'gateway_access_number' => { label => 'Gateway Access Number'.
195 ' (if different)', },
196 'loop_type' => { label => 'Loop Type',
197 disable_inventory => 1, },
198 'local_voice_provider' => { label => 'Local Voice Provider',
199 disable_inventory => 1, },
200 'circuitnum' => { label => 'Circuit #', },
201 'rate_band' => { label => 'Rate Band',
202 disable_inventory => 1, },
203 'vpi' => { label => 'VPI',
204 disable_inventory => 1 },
205 'vci' => { label => 'VCI',
206 disable_inventory => 1 },
207 'isp_chg' => { label => 'ISP Changing?',
210 'isp_prev' => { label => 'Current or Previous ISP',
211 disable_inventory => 1, },
212 'username' => { label => 'PPPoE Username',
214 'password' => { label => 'PPPoE Password', %dis2 },
215 'staticips' => { label => 'Static IPs', %dis1 },
216 'monitored' => { label => 'Monitored',
217 type => 'checkbox', %dis2 },
218 'last_pull' => { label => 'Last Pull',
219 type => 'disabled' },
224 sub table { 'svc_dsl'; }
228 return $self->phonenum if $self->phonenum;
229 return $self->username if $self->username;
230 return $self->vendor_order_id if $self->vendor_order_id;
231 return $self->svcnum;
236 Returns the set of FS::dsl_notes associated with this service
241 qsearch( 'dsl_note', { 'svcnum' => $self->svcnum } );
246 Adds this record to the database. If there is an error, returns the error,
247 otherwise returns false.
254 my $oldAutoCommit = $FS::UID::AutoCommit;
255 local $FS::UID::AutoCommit = 0;
257 my $error = $self->SUPER::insert(@_);
258 if ( length($self->password) ) {
259 $error ||= $self->insert_password_history;
263 $dbh->rollback if $oldAutoCommit;
267 $dbh->commit if $oldAutoCommit;
273 Delete this record from the database.
277 # the delete method can be inherited from FS::Record
279 =item replace OLD_RECORD
281 Replaces the OLD_RECORD with this one in the database. If there is an error,
282 returns the error, otherwise returns false.
288 my $old = shift || $new->replace_old;
290 my $oldAutoCommit = $FS::UID::AutoCommit;
291 local $FS::UID::AutoCommit = 0;
293 my $error = $new->SUPER::replace($old, @_);
294 if ( $old->password ne $new->password ) {
295 $error ||= $new->insert_password_history;
299 $dbh->rollback if $oldAutoCommit;
303 $dbh->commit if $oldAutoCommit;
307 # the replace method can be inherited from FS::Record
311 Checks all fields to make sure this is a valid DSL. If there is
312 an error, returns the error, otherwise returns false. Called by the insert
317 # the check method should currently be supplied - FS::Record contains some
318 # data checking routines
324 $self->ut_numbern('svcnum')
325 || $self->ut_numbern('pushed')
326 || $self->ut_numbern('desired_due_date')
327 || $self->ut_numbern('due_date')
328 || $self->ut_textn('vendor_order_id')
329 || $self->ut_textn('vendor_qual_id')
330 || $self->ut_alphan('vendor_order_type')
331 || $self->ut_alphan('vendor_order_status')
332 || $self->ut_textn('first')
333 || $self->ut_textn('last')
334 || $self->ut_textn('company')
335 || $self->ut_numbern('phonenum')
336 || $self->ut_numbern('gateway_access_number')
337 || $self->ut_alphasn('loop_type')
338 || $self->ut_textn('local_voice_provider')
339 || $self->ut_textn('circuitnum')
340 || $self->ut_textn('rate_band')
341 || $self->ut_numbern('vpi')
342 || $self->ut_numbern('vci')
343 || $self->ut_alphan('isp_chg')
344 || $self->ut_textn('isp_prev')
345 || $self->ut_textn('username')
346 || $self->ut_textn('password')
347 || $self->ut_textn('staticips')
348 || $self->ut_enum('monitored', [ '', 'Y' ])
349 || $self->ut_numbern('last_pull')
351 return $error if $error;
353 $self->gateway_access_number('')
354 if $self->phonenum && $self->phonenum eq $self->gateway_access_number;
359 =item gateway_access_or_phonenum
363 sub gateway_access_or_phonenum {
365 $self->gateway_access_number || $self->phonenum;
370 Returns the MAC addresses associated with this DSL service, as FS::dsl_device
375 sub predelete_hook_first {
377 my @exports = $self->part_svc->part_export_dsl_pull;
378 return 'More than one DSL-pulling export attached' if scalar(@exports) > 1;
379 if ( scalar(@exports) == 1 ) {
380 my $export = $exports[0];
381 return $export->dsl_pull($self);
388 my @notes = $self->notes;
389 foreach my $note ( @notes ) {
390 my $error = $note->delete;
391 return $error if $error;
396 # password_history compatibility
400 $self->get('password');
403 sub _password_encoding { 'plain'; }
409 L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,
410 export.html from the base documentation, L<FS::Record>, L<FS::Conf>,
411 L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, L<FS::queue>,
412 L<freeside-queued>, schema.html from the base documentation.