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