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:
53 =item svcnum - Primary key (assigned automatcially for new DSL))
55 =item pushed - Time DSL order pushed to vendor/telco, if applicable
57 =item desired_due_date - Desired Due Date
59 =item due_date - Due Date
61 =item vendor_order_id - Vendor/telco DSL order #
63 =item vendor_order_type
65 Vendor/telco DSL order type (e.g. (M)ove, (A)dd, (C)hange, (D)elete, or similar)
67 =item vendor_order_status
69 Vendor/telco DSL order status (e.g. (N)ew, (A)ssigned, (R)ejected, (M)revised,
70 (C)ompleted, (X)cancelled, or similar)
72 =item first - End-user first name
74 =item last - End-user last name
76 =item company - End-user company name
78 =item phonenum - DSL Telephone Number
80 =item gateway_access_number - Gateway access number, if different
82 =item loop_type - Loop-type - vendor/telco-specific
84 =item local_voice_provider - Local Voice Provider's name
86 =item circuitnum - Circuit #
92 =item rate_band - Rate Band
102 Ikano-specific fields, do not use otherwise
104 =item username - if outsourced PPPoE/RADIUS, username
106 =item password - if outsourced PPPoE/RADIUS, password
108 =item monitored - Order is monitored (auto-pull/sync), either Y or blank
110 =item last_pull - time of last data pull from vendor/telco
121 Creates a new DSL. To add the DSL to the database, see L<"insert">.
123 Note that this stores the hash reference, not a distinct copy of the hash it
124 points to. You can ask the object for a copy with the I<hash> method.
128 # the new method can be inherited from FS::Record, if a table method is defined
131 my %dis1 = ( disable_default=>1, disable_fixed=>1, disable_inventory=>1, disable_select=>1 );
132 my %dis2 = ( disable_inventory=>1, disable_select=>1 );
136 'name_plural' => 'DSLs',
137 'lcname_plural' => 'DSLs',
138 'sorts' => [ 'phonenum' ],
139 'display_weight' => 55,
140 'cancel_weight' => 75,
141 'ip_field' => 'staticips',
143 'pushed' => { label => 'Pushed',
144 type => 'disabled' },
145 'desired_due_date' => { label => 'Desired Due Date', %dis2, },
146 'due_date' => { label => 'Due Date', %dis2, },
147 'vendor_order_id' => { label => 'Vendor Order ID', %dis2, },
148 'vendor_qual_id' => { label => 'Vendor Qualification ID',
149 type => 'disabled' },
150 'vendor_order_type' => { label => 'Vendor Order Type',
151 disable_inventory => 1, },
152 'vendor_order_status' => { label => 'Vendor Order Status',
153 disable_inventory => 1, },
154 'first' => { label => 'First Name', %dis2, },
155 'last' => { label => 'Last Name', %dis2, },
156 'company' => { label => 'Company Name', %dis2, },
157 'phonenum' => { label => 'Service Telephone Number', },
158 'gateway_access_number' => { label => 'Gateway Access Number'.
159 ' (if different)', },
160 'loop_type' => { label => 'Loop Type',
161 disable_inventory => 1, },
162 'local_voice_provider' => { label => 'Local Voice Provider',
163 disable_inventory => 1, },
164 'circuitnum' => { label => 'Circuit #', },
165 'rate_band' => { label => 'Rate Band',
166 disable_inventory => 1, },
167 'vpi' => { label => 'VPI',
168 disable_inventory => 1 },
169 'vci' => { label => 'VCI',
170 disable_inventory => 1 },
171 'isp_chg' => { label => 'ISP Changing?',
174 'isp_prev' => { label => 'Current or Previous ISP',
175 disable_inventory => 1, },
176 'username' => { label => 'PPPoE Username',
178 'password' => { label => 'PPPoE Password', %dis2 },
179 'staticips' => { label => 'Static IPs', %dis1 },
180 'monitored' => { label => 'Monitored',
181 type => 'checkbox', %dis2 },
182 'last_pull' => { label => 'Last Pull',
183 type => 'disabled' },
188 sub table { 'svc_dsl'; }
192 return $self->phonenum if $self->phonenum;
193 return $self->username if $self->username;
194 return $self->vendor_order_id if $self->vendor_order_id;
195 return $self->svcnum;
200 Returns the set of FS::dsl_notes associated with this service
205 qsearch( 'dsl_note', { 'svcnum' => $self->svcnum } );
210 Adds this record to the database. If there is an error, returns the error,
211 otherwise returns false.
218 my $oldAutoCommit = $FS::UID::AutoCommit;
219 local $FS::UID::AutoCommit = 0;
221 my $error = $self->SUPER::insert(@_);
222 if ( length($self->password) ) {
223 $error ||= $self->insert_password_history;
227 $dbh->rollback if $oldAutoCommit;
231 $dbh->commit if $oldAutoCommit;
237 Delete this record from the database.
241 # the delete method can be inherited from FS::Record
243 =item replace OLD_RECORD
245 Replaces the OLD_RECORD with this one in the database. If there is an error,
246 returns the error, otherwise returns false.
252 my $old = shift || $new->replace_old;
254 my $oldAutoCommit = $FS::UID::AutoCommit;
255 local $FS::UID::AutoCommit = 0;
257 my $error = $new->SUPER::replace($old, @_);
258 if ( $old->password ne $new->password ) {
259 $error ||= $new->insert_password_history;
263 $dbh->rollback if $oldAutoCommit;
267 $dbh->commit if $oldAutoCommit;
271 # the replace method can be inherited from FS::Record
275 Checks all fields to make sure this is a valid DSL. If there is
276 an error, returns the error, otherwise returns false. Called by the insert
281 # the check method should currently be supplied - FS::Record contains some
282 # data checking routines
288 $self->ut_numbern('svcnum')
289 || $self->ut_numbern('pushed')
290 || $self->ut_numbern('desired_due_date')
291 || $self->ut_numbern('due_date')
292 || $self->ut_textn('vendor_order_id')
293 || $self->ut_textn('vendor_qual_id')
294 || $self->ut_alphan('vendor_order_type')
295 || $self->ut_alphan('vendor_order_status')
296 || $self->ut_textn('first')
297 || $self->ut_textn('last')
298 || $self->ut_textn('company')
299 || $self->ut_numbern('phonenum')
300 || $self->ut_numbern('gateway_access_number')
301 || $self->ut_alphasn('loop_type')
302 || $self->ut_textn('local_voice_provider')
303 || $self->ut_textn('circuitnum')
304 || $self->ut_textn('rate_band')
305 || $self->ut_numbern('vpi')
306 || $self->ut_numbern('vci')
307 || $self->ut_alphan('isp_chg')
308 || $self->ut_textn('isp_prev')
309 || $self->ut_textn('username')
310 || $self->ut_textn('password')
311 || $self->ut_textn('staticips')
312 || $self->ut_enum('monitored', [ '', 'Y' ])
313 || $self->ut_numbern('last_pull')
315 return $error if $error;
317 $self->gateway_access_number('')
318 if $self->phonenum && $self->phonenum eq $self->gateway_access_number;
323 =item gateway_access_or_phonenum
327 sub gateway_access_or_phonenum {
329 $self->gateway_access_number || $self->phonenum;
334 Returns the MAC addresses associated with this DSL service, as FS::dsl_device
339 sub predelete_hook_first {
341 my @exports = $self->part_svc->part_export_dsl_pull;
342 return 'More than one DSL-pulling export attached' if scalar(@exports) > 1;
343 if ( scalar(@exports) == 1 ) {
344 my $export = $exports[0];
345 return $export->dsl_pull($self);
352 my @notes = $self->notes;
353 foreach my $note ( @notes ) {
354 my $error = $note->delete;
355 return $error if $error;
360 # password_history compatibility
364 $self->get('password');
367 sub _password_encoding { 'plain'; }
373 L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,
374 export.html from the base documentation, L<FS::Record>, L<FS::Conf>,
375 L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, L<FS::queue>,
376 L<freeside-queued>, schema.html from the base documentation.