ikano.pm initial commit, svc_dsl UI initial commit, and svc_dsl on-going work, RT7111
[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
50
51 Primary key (assigned automatcially for new DSL))
52
53 =item pushed
54
55 Time the DSL order was pushed to a vendor, if exporting orders to a vendor/telco
56
57 =item desired_dd
58
59 Desired Due Date
60
61 =item dd
62
63 Due Date (e.g. once order is in Assigned status or similar by the telco)
64
65 =item vendor_order_id
66
67 Vendor/telco DSL order #
68
69 =item vendor_order_type
70
71 Vendor/telco DSL order type (e.g. (M)ove, (A)dd, (C)hange, (D)elete, or similar)
72
73 =item vendor_order_status
74
75 Vendor/telco DSL order status (e.g. (N)ew, (A)ssigned, (R)ejected, (M)revised,
76 (C)ompleted, (X)cancelled, or similar)
77
78 =item first
79
80 End-user first name
81
82 =item last
83
84 End-user last name
85
86 =item company
87
88 End-user company name
89
90 =item svctn
91
92 DSL Telephone Number
93
94 =item loop_type
95
96 Loop-type - vendor/telco-specific
97
98 =item lvp
99
100 Local Voice Provider's name
101
102 =item cktnum
103
104 Circuit #
105
106 =item rate_band
107
108 Rate Band
109
110 =item isp_chg
111
112 =item isp_prev
113
114 =item staticips
115
116 =item vendor_qual_id
117
118 Ikano-specific fields, do not use otherwise
119
120 =item username
121
122 If outsourced PPPoE/RADIUS, username
123
124 =item password
125
126 If outsourced PPPoE/RADIUS, password
127
128 =item monitored
129
130 Order is monitored (auto-pull/sync), either Y or blank
131
132 =item last_pull
133
134 Time of last data pull from vendor/telco
135
136 =item notes
137
138 DSL order notes placed by staff or vendor/telco on the vendor/telco order
139
140
141 =back
142
143 =head1 METHODS
144
145 =over 4
146
147 =item new HASHREF
148
149 Creates a new DSL.  To add the DSL to the database, see L<"insert">.
150
151 Note that this stores the hash reference, not a distinct copy of the hash it
152 points to.  You can ask the object for a copy with the I<hash> method.
153
154 =cut
155
156 # the new method can be inherited from FS::Record, if a table method is defined
157
158 sub table_info {
159     my %dis1 = ( disable_default=>1, disable_fixed=>1, disable_inventory=>1, disable_select=>1 );
160     my %dis2 = ( disable_inventory=>1, disable_select=>1 );
161
162     {
163         'name' => 'DSL',
164         'sorts' => [ 'svctn' ],
165         'display_weight' => 55,
166         'cancel_weight' => 75,
167         'fields' => {
168             'pushed' => {       label => 'Pushed', 
169                                 type => 'disabled' },
170             'desired_dd' => {   label => 'Desired Due Date', %dis2, },
171             'dd' => {           label => 'Due Date', %dis2, },
172             'vendor_order_id' => { label => 'Vendor Order Id', %dis2, },
173             'vendor_qual_id' => { label => 'Vendor Qualification Id', 
174                                 type => 'disabled' },
175             'vendor_order_type' => { label => 'Vendor Order Type',
176                                     disable_inventory => 1,
177                                 },
178             'vendor_order_status' => { label => 'Vendor Order Status',
179                                     disable_inventory => 1,
180                                     },
181             'first' => {        label => 'First Name', %dis2, },
182             'last' => {         label => 'Last Name', %dis2, },
183             'company' => {      label => 'Company Name', %dis2, },
184             'svctn' => {        label => 'Service Telephone Number', },
185             'loop_type' => {    label => 'Loop Type',
186                                     disable_inventory => 1,
187                         },
188             'lvp' => {          label => 'Local Voice Provider',
189                                     disable_inventory => 1,
190                         },
191             'cktnum' => {       label => 'Circuit #',   },
192             'rate_band' => {    label => 'Rate Band',
193                                     disable_inventory => 1,
194                         },
195             'isp_chg' => {      label => 'ISP Changing?', 
196                                 type => 'checkbox', %dis2 },
197             'isp_prev' => {     label => 'Current or Previous ISP',
198                                     disable_inventory => 1,
199                         },
200             'username' => {     label => 'PPPoE Username',
201                                 type => 'text',
202                         },
203             'password' => {     label => 'PPPoE Password', %dis2 },
204             'staticips' => {    label => 'Static IPs', %dis1 },
205             'monitored' => {    label => 'Monitored', 
206                                 type => 'checkbox', %dis2 },
207             'last_pull' => {    label => 'Last Pull', type => 'disabled' },
208             'notes' => {        label => 'Order Notes', %dis1 },
209         },
210     };
211 }
212
213 sub table { 'svc_dsl'; }
214
215 sub label {
216    my $self = shift;
217    return $self->svctn if $self->svctn;
218    return $self->username if $self->username;
219    return $self->vendor_order_id if $self->vendor_order_id;
220    return $self->svcnum;
221 }
222
223 =item insert
224
225 Adds this record to the database.  If there is an error, returns the error,
226 otherwise returns false.
227
228 =cut
229
230 # the insert method can be inherited from FS::Record
231
232 =item delete
233
234 Delete this record from the database.
235
236 =cut
237
238 # the delete method can be inherited from FS::Record
239
240 =item replace OLD_RECORD
241
242 Replaces the OLD_RECORD with this one in the database.  If there is an error,
243 returns the error, otherwise returns false.
244
245 =cut
246
247 # the replace method can be inherited from FS::Record
248
249 =item check
250
251 Checks all fields to make sure this is a valid DSL.  If there is
252 an error, returns the error, otherwise returns false.  Called by the insert
253 and replace methods.
254
255 =cut
256
257 # the check method should currently be supplied - FS::Record contains some
258 # data checking routines
259
260 sub check {
261   my $self = shift;
262
263   my $error = 
264     $self->ut_numbern('svcnum')
265     || $self->ut_numbern('pushed')
266     || $self->ut_number('desired_dd')
267     || $self->ut_numbern('dd')
268     || $self->ut_textn('vendor_order_id')
269     || $self->ut_textn('vendor_qual_id')
270     || $self->ut_alpha('vendor_order_type')
271     || $self->ut_alphan('vendor_order_status')
272     || $self->ut_text('first')
273     || $self->ut_text('last')
274     || $self->ut_textn('company')
275     || $self->ut_numbern('svctn')
276     || $self->ut_alphasn('loop_type')
277     || $self->ut_textn('lvp')
278     || $self->ut_textn('cktnum')
279     || $self->ut_textn('rate_band')
280     || $self->ut_alphan('isp_chg')
281     || $self->ut_textn('isp_prev')
282     || $self->ut_textn('username')
283     || $self->ut_textn('password')
284     || $self->ut_textn('staticips')
285     || $self->ut_enum('monitored',    [ '', 'Y' ])
286     || $self->ut_numbern('last_pull')
287     || $self->ut_textn('notes')
288   ;
289   return $error if $error;
290
291   $self->SUPER::check;
292 }
293
294 =back
295
296 =head1 BUGS
297
298 This doesn't do anything yet.
299
300 =head1 SEE ALSO
301
302 L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,
303 export.html from the base documentation, L<FS::Record>, L<FS::Conf>,
304 L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, L<FS::queue>,
305 L<freeside-queued>, schema.html from the base documentation.
306
307 =cut
308
309 1;
310